diff --git a/packages/abi-gen-wrappers/package.json b/packages/abi-gen-wrappers/package.json index 38a03f21f8..868d98e8a5 100644 --- a/packages/abi-gen-wrappers/package.json +++ b/packages/abi-gen-wrappers/package.json @@ -21,7 +21,7 @@ "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output src/generated-wrappers --backend ethers" }, "config": { - "abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DevUtils|DutchAuction|DummyERC20Token|DummyERC721Token|ERC1155Mintable|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IAssetProxy|IValidator|IWallet|MultiAssetProxy|OrderValidator|WETH9|ZRXToken|Coordinator|CoordinatorRegistry|EthBalanceChecker|ERC1155Proxy|StaticCallProxy|Staking|StakingProxy).json" + "abis": "../contract-artifacts/artifacts/@(DevUtils|DummyERC20Token|DummyERC721Token|ERC1155Mintable|ERC20Token|ERC721Token|Exchange|Forwarder|IValidator|IWallet|OrderValidator|WETH9|Coordinator|CoordinatorRegistry|EthBalanceChecker|Staking|StakingProxy).json" }, "repository": { "type": "git", 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 deleted file mode 100644 index 20e56f1633..0000000000 --- a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts +++ /dev/null @@ -1,3646 +0,0 @@ -// 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 { schemas } from '@0x/json-schemas'; -import { - BlockParam, - BlockParamLiteral, - BlockRange, - CallData, - ContractAbi, - ContractArtifact, - DecodedLogArgs, - LogWithDecodedArgs, - MethodAbi, - TransactionReceiptWithDecodedLogs, - TxData, - TxDataPayable, - SupportedProvider, -} from 'ethereum-types'; -import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - 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 - -export type AssetProxyOwnerEventArgs = - | AssetProxyOwnerConfirmationEventArgs - | AssetProxyOwnerConfirmationTimeSetEventArgs - | AssetProxyOwnerDepositEventArgs - | AssetProxyOwnerExecutionEventArgs - | AssetProxyOwnerExecutionFailureEventArgs - | AssetProxyOwnerFunctionCallTimeLockRegistrationEventArgs - | AssetProxyOwnerOwnerAdditionEventArgs - | AssetProxyOwnerOwnerRemovalEventArgs - | AssetProxyOwnerRequirementChangeEventArgs - | AssetProxyOwnerRevocationEventArgs - | AssetProxyOwnerSubmissionEventArgs - | AssetProxyOwnerTimeLockChangeEventArgs; - -export enum AssetProxyOwnerEvents { - Confirmation = 'Confirmation', - ConfirmationTimeSet = 'ConfirmationTimeSet', - Deposit = 'Deposit', - Execution = 'Execution', - ExecutionFailure = 'ExecutionFailure', - FunctionCallTimeLockRegistration = 'FunctionCallTimeLockRegistration', - OwnerAddition = 'OwnerAddition', - OwnerRemoval = 'OwnerRemoval', - RequirementChange = 'RequirementChange', - Revocation = 'Revocation', - Submission = 'Submission', - TimeLockChange = 'TimeLockChange', -} - -export interface AssetProxyOwnerConfirmationEventArgs extends DecodedLogArgs { - sender: string; - transactionId: BigNumber; -} - -export interface AssetProxyOwnerConfirmationTimeSetEventArgs extends DecodedLogArgs { - transactionId: BigNumber; - confirmationTime: BigNumber; -} - -export interface AssetProxyOwnerDepositEventArgs extends DecodedLogArgs { - sender: string; - value: BigNumber; -} - -export interface AssetProxyOwnerExecutionEventArgs extends DecodedLogArgs { - transactionId: BigNumber; -} - -export interface AssetProxyOwnerExecutionFailureEventArgs extends DecodedLogArgs { - transactionId: BigNumber; -} - -export interface AssetProxyOwnerFunctionCallTimeLockRegistrationEventArgs extends DecodedLogArgs { - functionSelector: string; - destination: string; - hasCustomTimeLock: boolean; - newSecondsTimeLocked: BigNumber; -} - -export interface AssetProxyOwnerOwnerAdditionEventArgs extends DecodedLogArgs { - owner: string; -} - -export interface AssetProxyOwnerOwnerRemovalEventArgs extends DecodedLogArgs { - owner: string; -} - -export interface AssetProxyOwnerRequirementChangeEventArgs extends DecodedLogArgs { - required: BigNumber; -} - -export interface AssetProxyOwnerRevocationEventArgs extends DecodedLogArgs { - sender: string; - transactionId: BigNumber; -} - -export interface AssetProxyOwnerSubmissionEventArgs extends DecodedLogArgs { - transactionId: BigNumber; -} - -export interface AssetProxyOwnerTimeLockChangeEventArgs extends DecodedLogArgs { - secondsTimeLocked: BigNumber; -} - -/* istanbul ignore next */ -// tslint:disable:no-parameter-reassignment -// tslint:disable-next-line:class-name -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 readonly _subscriptionManager: SubscriptionManager; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - _functionSelectors: string[], - _destinations: string[], - _functionCallTimeLockSeconds: BigNumber[], - _owners: string[], - _required: BigNumber, - _defaultSecondsTimeLocked: 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 AssetProxyOwnerContract.deployAsync( - bytecode, - abi, - provider, - txDefaults, - logDecodeDependenciesAbiOnly, - _functionSelectors, - _destinations, - _functionCallTimeLockSeconds, - _owners, - _required, - _defaultSecondsTimeLocked, - ); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - _functionSelectors: string[], - _destinations: string[], - _functionCallTimeLockSeconds: BigNumber[], - _owners: string[], - _required: BigNumber, - _defaultSecondsTimeLocked: 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); - [ - _functionSelectors, - _destinations, - _functionCallTimeLockSeconds, - _owners, - _required, - _defaultSecondsTimeLocked, - ] = BaseContract._formatABIDataItemList( - constructorAbi.inputs, - [ - _functionSelectors, - _destinations, - _functionCallTimeLockSeconds, - _owners, - _required, - _defaultSecondsTimeLocked, - ], - BaseContract._bigNumberToString, - ); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, [ - _functionSelectors, - _destinations, - _functionCallTimeLockSeconds, - _owners, - _required, - _defaultSecondsTimeLocked, - ]); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`AssetProxyOwner successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new AssetProxyOwnerContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = [ - _functionSelectors, - _destinations, - _functionCallTimeLockSeconds, - _owners, - _required, - _defaultSecondsTimeLocked, - ]; - return contractInstance; - } - - /** - * @returns The contract ABI - */ - public static ABI(): ContractAbi { - const abi = [ - { - inputs: [ - { - name: '_functionSelectors', - type: 'bytes4[]', - }, - { - name: '_destinations', - type: 'address[]', - }, - { - name: '_functionCallTimeLockSeconds', - type: 'uint128[]', - }, - { - name: '_owners', - type: 'address[]', - }, - { - name: '_required', - type: 'uint256', - }, - { - name: '_defaultSecondsTimeLocked', - type: 'uint256', - }, - ], - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - anonymous: false, - inputs: [ - { - name: 'sender', - type: 'address', - indexed: true, - }, - { - name: 'transactionId', - type: 'uint256', - indexed: true, - }, - ], - name: 'Confirmation', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - indexed: true, - }, - { - name: 'confirmationTime', - type: 'uint256', - indexed: false, - }, - ], - name: 'ConfirmationTimeSet', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'sender', - type: 'address', - indexed: true, - }, - { - name: 'value', - type: 'uint256', - indexed: false, - }, - ], - name: 'Deposit', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - indexed: true, - }, - ], - name: 'Execution', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - indexed: true, - }, - ], - name: 'ExecutionFailure', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'functionSelector', - type: 'bytes4', - indexed: false, - }, - { - name: 'destination', - type: 'address', - indexed: false, - }, - { - name: 'hasCustomTimeLock', - type: 'bool', - indexed: false, - }, - { - name: 'newSecondsTimeLocked', - type: 'uint128', - indexed: false, - }, - ], - name: 'FunctionCallTimeLockRegistration', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'owner', - type: 'address', - indexed: true, - }, - ], - name: 'OwnerAddition', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'owner', - type: 'address', - indexed: true, - }, - ], - name: 'OwnerRemoval', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'required', - type: 'uint256', - indexed: false, - }, - ], - name: 'RequirementChange', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'sender', - type: 'address', - indexed: true, - }, - { - name: 'transactionId', - type: 'uint256', - indexed: true, - }, - ], - name: 'Revocation', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - indexed: true, - }, - ], - name: 'Submission', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'secondsTimeLocked', - type: 'uint256', - indexed: false, - }, - ], - name: 'TimeLockChange', - outputs: [], - type: 'event', - }, - { - inputs: [], - outputs: [], - payable: true, - stateMutability: 'payable', - type: 'fallback', - }, - { - constant: true, - inputs: [], - name: 'MAX_OWNER_COUNT', - outputs: [ - { - name: '', - type: 'uint256', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'owner', - type: 'address', - }, - ], - name: 'addOwner', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: '_required', - type: 'uint256', - }, - ], - name: 'changeRequirement', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: '_secondsTimeLocked', - type: 'uint256', - }, - ], - name: 'changeTimeLock', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - }, - ], - name: 'confirmTransaction', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'uint256', - }, - ], - name: 'confirmationTimes', - outputs: [ - { - name: '', - type: 'uint256', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'uint256', - }, - { - name: 'index_1', - type: 'address', - }, - ], - name: 'confirmations', - outputs: [ - { - name: '', - type: 'bool', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - }, - ], - name: 'executeTransaction', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'bytes4', - }, - { - name: 'index_1', - type: 'address', - }, - ], - name: 'functionCallTimeLocks', - outputs: [ - { - name: 'hasCustomTimeLock', - type: 'bool', - }, - { - name: 'secondsTimeLocked', - type: 'uint128', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - }, - ], - name: 'getConfirmationCount', - outputs: [ - { - name: 'count', - type: 'uint256', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - }, - ], - name: 'getConfirmations', - outputs: [ - { - name: '_confirmations', - type: 'address[]', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getOwners', - outputs: [ - { - name: '', - type: 'address[]', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'pending', - type: 'bool', - }, - { - name: 'executed', - type: 'bool', - }, - ], - name: 'getTransactionCount', - outputs: [ - { - name: 'count', - type: 'uint256', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'from', - type: 'uint256', - }, - { - name: 'to', - type: 'uint256', - }, - { - name: 'pending', - type: 'bool', - }, - { - name: 'executed', - type: 'bool', - }, - ], - name: 'getTransactionIds', - outputs: [ - { - name: '_transactionIds', - type: 'uint256[]', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - }, - ], - name: 'isConfirmed', - outputs: [ - { - name: '', - type: 'bool', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'address', - }, - ], - name: 'isOwner', - outputs: [ - { - name: '', - type: 'bool', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'uint256', - }, - ], - name: 'owners', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'hasCustomTimeLock', - type: 'bool', - }, - { - name: 'functionSelector', - type: 'bytes4', - }, - { - name: 'destination', - type: 'address', - }, - { - name: 'newSecondsTimeLocked', - type: 'uint128', - }, - ], - name: 'registerFunctionCall', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'owner', - type: 'address', - }, - ], - name: 'removeOwner', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'owner', - type: 'address', - }, - { - name: 'newOwner', - type: 'address', - }, - ], - name: 'replaceOwner', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'required', - outputs: [ - { - name: '', - type: 'uint256', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'transactionId', - type: 'uint256', - }, - ], - name: 'revokeConfirmation', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'secondsTimeLocked', - outputs: [ - { - name: '', - type: 'uint256', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'destination', - type: 'address', - }, - { - name: 'value', - type: 'uint256', - }, - { - name: 'data', - type: 'bytes', - }, - ], - name: 'submitTransaction', - outputs: [ - { - name: 'transactionId', - type: 'uint256', - }, - ], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'transactionCount', - outputs: [ - { - name: '', - type: 'uint256', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'uint256', - }, - ], - name: 'transactions', - outputs: [ - { - name: 'destination', - type: 'address', - }, - { - name: 'value', - type: 'uint256', - }, - { - name: 'data', - type: 'bytes', - }, - { - name: 'executed', - type: 'bool', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - ] 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; - } - /** - * 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); - const logs = await this._subscriptionManager.getLogsAsync( - this.address, - eventName, - blockRange, - indexFilterValues, - AssetProxyOwnerContract.ABI(), - ); - return logs; - } - constructor( - address: string, - supportedProvider: SupportedProvider, - txDefaults?: Partial, - logDecodeDependencies?: { [contractName: string]: ContractAbi }, - deployedBytecode: string | undefined = AssetProxyOwnerContract.deployedBytecode, - ) { - super( - 'AssetProxyOwner', - AssetProxyOwnerContract.ABI(), - address, - supportedProvider, - txDefaults, - logDecodeDependencies, - deployedBytecode, - ); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); - this._subscriptionManager = new SubscriptionManager( - AssetProxyOwnerContract.ABI(), - this._web3Wrapper, - ); - } -} - -// tslint:disable:max-file-line-count -// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align -// tslint:enable:trailing-comma whitespace no-trailing-whitespace diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts deleted file mode 100644 index 15a3297209..0000000000 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts +++ /dev/null @@ -1,1096 +0,0 @@ -// 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 { schemas } from '@0x/json-schemas'; -import { - BlockParam, - BlockParamLiteral, - BlockRange, - CallData, - ContractAbi, - ContractArtifact, - DecodedLogArgs, - MethodAbi, - TransactionReceiptWithDecodedLogs, - TxData, - TxDataPayable, - SupportedProvider, -} from 'ethereum-types'; -import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - 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 - -/* istanbul ignore next */ -// tslint:disable:no-parameter-reassignment -// tslint:disable-next-line:class-name -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(); - }, - }; - 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 DutchAuctionContract.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(`DutchAuction successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new DutchAuctionContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = [_exchange]; - return contractInstance; - } - - /** - * @returns The contract ABI - */ - public static ABI(): ContractAbi { - const abi = [ - { - 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: 'getAuctionDetails', - outputs: [ - { - name: 'auctionDetails', - type: 'tuple', - components: [ - { - name: 'beginTimeSeconds', - type: 'uint256', - }, - { - name: 'endTimeSeconds', - type: 'uint256', - }, - { - name: 'beginAmount', - type: 'uint256', - }, - { - name: 'endAmount', - type: 'uint256', - }, - { - name: 'currentAmount', - type: 'uint256', - }, - { - name: 'currentTimeSeconds', - type: 'uint256', - }, - ], - }, - ], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'buyOrder', - 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: 'sellOrder', - 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: 'buySignature', - type: 'bytes', - }, - { - name: 'sellSignature', - type: 'bytes', - }, - ], - name: 'matchOrders', - outputs: [ - { - 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: 'right', - type: 'tuple', - components: [ - { - name: 'makerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'takerAssetFilledAmount', - type: 'uint256', - }, - { - name: 'makerFeePaid', - type: 'uint256', - }, - { - name: 'takerFeePaid', - type: 'uint256', - }, - ], - }, - { - name: 'leftMakerAssetSpreadAmount', - type: 'uint256', - }, - ], - }, - ], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - name: '_exchange', - type: 'address', - }, - ], - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'constructor', - }, - ] as ContractAbi; - return abi; - } - constructor( - address: string, - supportedProvider: SupportedProvider, - txDefaults?: Partial, - logDecodeDependencies?: { [contractName: string]: ContractAbi }, - deployedBytecode: string | undefined = DutchAuctionContract.deployedBytecode, - ) { - super( - 'DutchAuction', - DutchAuctionContract.ABI(), - address, - supportedProvider, - txDefaults, - logDecodeDependencies, - deployedBytecode, - ); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); - } -} - -// tslint:disable:max-file-line-count -// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align -// tslint:enable:trailing-comma whitespace no-trailing-whitespace diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts deleted file mode 100644 index d5c947103f..0000000000 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts +++ /dev/null @@ -1,1556 +0,0 @@ -// 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 { schemas } from '@0x/json-schemas'; -import { - BlockParam, - BlockParamLiteral, - BlockRange, - CallData, - ContractAbi, - ContractArtifact, - DecodedLogArgs, - LogWithDecodedArgs, - MethodAbi, - TransactionReceiptWithDecodedLogs, - TxData, - TxDataPayable, - SupportedProvider, -} from 'ethereum-types'; -import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - 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 - -export type ERC1155ProxyEventArgs = - | ERC1155ProxyAuthorizedAddressAddedEventArgs - | ERC1155ProxyAuthorizedAddressRemovedEventArgs; - -export enum ERC1155ProxyEvents { - AuthorizedAddressAdded = 'AuthorizedAddressAdded', - AuthorizedAddressRemoved = 'AuthorizedAddressRemoved', -} - -export interface ERC1155ProxyAuthorizedAddressAddedEventArgs extends DecodedLogArgs { - target: string; - caller: string; -} - -export interface ERC1155ProxyAuthorizedAddressRemovedEventArgs extends DecodedLogArgs { - target: string; - caller: string; -} - -/* istanbul ignore next */ -// tslint:disable:no-parameter-reassignment -// tslint:disable-next-line:class-name -export class ERC1155ProxyContract extends BaseContract { - /** - * @ignore - */ - 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 readonly _subscriptionManager: SubscriptionManager; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - ): 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 ERC1155ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - ): 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); - [] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, []); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`ERC1155Proxy successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new ERC1155ProxyContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = []; - return contractInstance; - } - - /** - * @returns The contract ABI - */ - public static ABI(): ContractAbi { - const abi = [ - { - anonymous: false, - inputs: [ - { - name: 'target', - type: 'address', - indexed: true, - }, - { - name: 'caller', - type: 'address', - indexed: true, - }, - ], - name: 'AuthorizedAddressAdded', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'target', - type: 'address', - indexed: true, - }, - { - name: 'caller', - type: 'address', - indexed: true, - }, - ], - name: 'AuthorizedAddressRemoved', - outputs: [], - type: 'event', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - ], - name: 'addAuthorizedAddress', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'uint256', - }, - ], - name: 'authorities', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'address', - }, - ], - name: 'authorized', - outputs: [ - { - name: '', - type: 'bool', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getAuthorizedAddresses', - outputs: [ - { - name: '', - type: 'address[]', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getProxyId', - outputs: [ - { - name: '', - type: 'bytes4', - }, - ], - payable: false, - stateMutability: 'pure', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'owner', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - ], - name: 'removeAuthorizedAddress', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - { - name: 'index', - type: 'uint256', - }, - ], - name: 'removeAuthorizedAddressAtIndex', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'assetData', - type: 'bytes', - }, - { - name: 'from', - type: 'address', - }, - { - name: 'to', - type: 'address', - }, - { - name: 'amount', - type: 'uint256', - }, - ], - name: 'transferFrom', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'newOwner', - type: 'address', - }, - ], - name: 'transferOwnership', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - ] as ContractAbi; - return abi; - } - /** - * Subscribe to an event type emitted by the ERC1155Proxy contract. - * @param eventName The ERC1155Proxy 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: ERC1155ProxyEvents, - indexFilterValues: IndexedFilterValues, - callback: EventCallback, - isVerbose: boolean = false, - blockPollingIntervalMs?: number, - ): string { - assert.doesBelongToStringEnum('eventName', eventName, ERC1155ProxyEvents); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - assert.isFunction('callback', callback); - const subscriptionToken = this._subscriptionManager.subscribe( - this.address, - eventName, - indexFilterValues, - ERC1155ProxyContract.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 ERC1155Proxy 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: ERC1155ProxyEvents, - blockRange: BlockRange, - indexFilterValues: IndexedFilterValues, - ): Promise>> { - assert.doesBelongToStringEnum('eventName', eventName, ERC1155ProxyEvents); - assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - const logs = await this._subscriptionManager.getLogsAsync( - this.address, - eventName, - blockRange, - indexFilterValues, - ERC1155ProxyContract.ABI(), - ); - return logs; - } - constructor( - address: string, - supportedProvider: SupportedProvider, - txDefaults?: Partial, - logDecodeDependencies?: { [contractName: string]: ContractAbi }, - deployedBytecode: string | undefined = ERC1155ProxyContract.deployedBytecode, - ) { - super( - 'ERC1155Proxy', - ERC1155ProxyContract.ABI(), - address, - supportedProvider, - txDefaults, - logDecodeDependencies, - deployedBytecode, - ); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); - this._subscriptionManager = new SubscriptionManager( - ERC1155ProxyContract.ABI(), - this._web3Wrapper, - ); - } -} - -// tslint:disable:max-file-line-count -// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align -// tslint:enable:trailing-comma whitespace no-trailing-whitespace diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts deleted file mode 100644 index 5608cbf8e0..0000000000 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts +++ /dev/null @@ -1,1297 +0,0 @@ -// 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 { schemas } from '@0x/json-schemas'; -import { - BlockParam, - BlockParamLiteral, - BlockRange, - CallData, - ContractAbi, - ContractArtifact, - DecodedLogArgs, - LogWithDecodedArgs, - MethodAbi, - TransactionReceiptWithDecodedLogs, - TxData, - TxDataPayable, - SupportedProvider, -} from 'ethereum-types'; -import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - 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 - -export type ERC20ProxyEventArgs = - | ERC20ProxyAuthorizedAddressAddedEventArgs - | ERC20ProxyAuthorizedAddressRemovedEventArgs; - -export enum ERC20ProxyEvents { - AuthorizedAddressAdded = 'AuthorizedAddressAdded', - AuthorizedAddressRemoved = 'AuthorizedAddressRemoved', -} - -export interface ERC20ProxyAuthorizedAddressAddedEventArgs extends DecodedLogArgs { - target: string; - caller: string; -} - -export interface ERC20ProxyAuthorizedAddressRemovedEventArgs extends DecodedLogArgs { - target: string; - caller: string; -} - -/* istanbul ignore next */ -// tslint:disable:no-parameter-reassignment -// tslint:disable-next-line:class-name -export class ERC20ProxyContract extends BaseContract { - /** - * @ignore - */ - 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 readonly _subscriptionManager: SubscriptionManager; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - ): 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 ERC20ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - ): 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); - [] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, []); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`ERC20Proxy successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new ERC20ProxyContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = []; - return contractInstance; - } - - /** - * @returns The contract ABI - */ - public static ABI(): ContractAbi { - const abi = [ - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - ], - name: 'addAuthorizedAddress', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'uint256', - }, - ], - name: 'authorities', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - ], - name: 'removeAuthorizedAddress', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'owner', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - { - name: 'index', - type: 'uint256', - }, - ], - name: 'removeAuthorizedAddressAtIndex', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getProxyId', - outputs: [ - { - name: '', - type: 'bytes4', - }, - ], - payable: false, - stateMutability: 'pure', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'address', - }, - ], - name: 'authorized', - outputs: [ - { - name: '', - type: 'bool', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getAuthorizedAddresses', - outputs: [ - { - name: '', - type: 'address[]', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'newOwner', - type: 'address', - }, - ], - name: 'transferOwnership', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'fallback', - }, - { - anonymous: false, - inputs: [ - { - name: 'target', - type: 'address', - indexed: true, - }, - { - name: 'caller', - type: 'address', - indexed: true, - }, - ], - name: 'AuthorizedAddressAdded', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'target', - type: 'address', - indexed: true, - }, - { - name: 'caller', - type: 'address', - indexed: true, - }, - ], - name: 'AuthorizedAddressRemoved', - outputs: [], - type: 'event', - }, - ] as ContractAbi; - return abi; - } - /** - * Subscribe to an event type emitted by the ERC20Proxy contract. - * @param eventName The ERC20Proxy 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: ERC20ProxyEvents, - indexFilterValues: IndexedFilterValues, - callback: EventCallback, - isVerbose: boolean = false, - blockPollingIntervalMs?: number, - ): string { - assert.doesBelongToStringEnum('eventName', eventName, ERC20ProxyEvents); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - assert.isFunction('callback', callback); - const subscriptionToken = this._subscriptionManager.subscribe( - this.address, - eventName, - indexFilterValues, - ERC20ProxyContract.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 ERC20Proxy 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: ERC20ProxyEvents, - blockRange: BlockRange, - indexFilterValues: IndexedFilterValues, - ): Promise>> { - assert.doesBelongToStringEnum('eventName', eventName, ERC20ProxyEvents); - assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - const logs = await this._subscriptionManager.getLogsAsync( - this.address, - eventName, - blockRange, - indexFilterValues, - ERC20ProxyContract.ABI(), - ); - return logs; - } - constructor( - address: string, - supportedProvider: SupportedProvider, - txDefaults?: Partial, - logDecodeDependencies?: { [contractName: string]: ContractAbi }, - deployedBytecode: string | undefined = ERC20ProxyContract.deployedBytecode, - ) { - super( - 'ERC20Proxy', - ERC20ProxyContract.ABI(), - address, - supportedProvider, - txDefaults, - logDecodeDependencies, - deployedBytecode, - ); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); - this._subscriptionManager = new SubscriptionManager( - ERC20ProxyContract.ABI(), - this._web3Wrapper, - ); - } -} - -// tslint:disable:max-file-line-count -// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align -// tslint:enable:trailing-comma whitespace no-trailing-whitespace diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts deleted file mode 100644 index 7b84ca85b7..0000000000 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts +++ /dev/null @@ -1,1297 +0,0 @@ -// 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 { schemas } from '@0x/json-schemas'; -import { - BlockParam, - BlockParamLiteral, - BlockRange, - CallData, - ContractAbi, - ContractArtifact, - DecodedLogArgs, - LogWithDecodedArgs, - MethodAbi, - TransactionReceiptWithDecodedLogs, - TxData, - TxDataPayable, - SupportedProvider, -} from 'ethereum-types'; -import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - 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 - -export type ERC721ProxyEventArgs = - | ERC721ProxyAuthorizedAddressAddedEventArgs - | ERC721ProxyAuthorizedAddressRemovedEventArgs; - -export enum ERC721ProxyEvents { - AuthorizedAddressAdded = 'AuthorizedAddressAdded', - AuthorizedAddressRemoved = 'AuthorizedAddressRemoved', -} - -export interface ERC721ProxyAuthorizedAddressAddedEventArgs extends DecodedLogArgs { - target: string; - caller: string; -} - -export interface ERC721ProxyAuthorizedAddressRemovedEventArgs extends DecodedLogArgs { - target: string; - caller: string; -} - -/* istanbul ignore next */ -// tslint:disable:no-parameter-reassignment -// tslint:disable-next-line:class-name -export class ERC721ProxyContract extends BaseContract { - /** - * @ignore - */ - 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 readonly _subscriptionManager: SubscriptionManager; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - ): 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 ERC721ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - ): 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); - [] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, []); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`ERC721Proxy successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new ERC721ProxyContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = []; - return contractInstance; - } - - /** - * @returns The contract ABI - */ - public static ABI(): ContractAbi { - const abi = [ - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - ], - name: 'addAuthorizedAddress', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'uint256', - }, - ], - name: 'authorities', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - ], - name: 'removeAuthorizedAddress', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'owner', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - { - name: 'index', - type: 'uint256', - }, - ], - name: 'removeAuthorizedAddressAtIndex', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getProxyId', - outputs: [ - { - name: '', - type: 'bytes4', - }, - ], - payable: false, - stateMutability: 'pure', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'address', - }, - ], - name: 'authorized', - outputs: [ - { - name: '', - type: 'bool', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getAuthorizedAddresses', - outputs: [ - { - name: '', - type: 'address[]', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'newOwner', - type: 'address', - }, - ], - name: 'transferOwnership', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'fallback', - }, - { - anonymous: false, - inputs: [ - { - name: 'target', - type: 'address', - indexed: true, - }, - { - name: 'caller', - type: 'address', - indexed: true, - }, - ], - name: 'AuthorizedAddressAdded', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'target', - type: 'address', - indexed: true, - }, - { - name: 'caller', - type: 'address', - indexed: true, - }, - ], - name: 'AuthorizedAddressRemoved', - outputs: [], - type: 'event', - }, - ] as ContractAbi; - return abi; - } - /** - * Subscribe to an event type emitted by the ERC721Proxy contract. - * @param eventName The ERC721Proxy 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: ERC721ProxyEvents, - indexFilterValues: IndexedFilterValues, - callback: EventCallback, - isVerbose: boolean = false, - blockPollingIntervalMs?: number, - ): string { - assert.doesBelongToStringEnum('eventName', eventName, ERC721ProxyEvents); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - assert.isFunction('callback', callback); - const subscriptionToken = this._subscriptionManager.subscribe( - this.address, - eventName, - indexFilterValues, - ERC721ProxyContract.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 ERC721Proxy 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: ERC721ProxyEvents, - blockRange: BlockRange, - indexFilterValues: IndexedFilterValues, - ): Promise>> { - assert.doesBelongToStringEnum('eventName', eventName, ERC721ProxyEvents); - assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - const logs = await this._subscriptionManager.getLogsAsync( - this.address, - eventName, - blockRange, - indexFilterValues, - ERC721ProxyContract.ABI(), - ); - return logs; - } - constructor( - address: string, - supportedProvider: SupportedProvider, - txDefaults?: Partial, - logDecodeDependencies?: { [contractName: string]: ContractAbi }, - deployedBytecode: string | undefined = ERC721ProxyContract.deployedBytecode, - ) { - super( - 'ERC721Proxy', - ERC721ProxyContract.ABI(), - address, - supportedProvider, - txDefaults, - logDecodeDependencies, - deployedBytecode, - ); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); - this._subscriptionManager = new SubscriptionManager( - ERC721ProxyContract.ABI(), - this._web3Wrapper, - ); - } -} - -// tslint:disable:max-file-line-count -// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align -// tslint:enable:trailing-comma whitespace no-trailing-whitespace 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 deleted file mode 100644 index 1862f8c11a..0000000000 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts +++ /dev/null @@ -1,444 +0,0 @@ -// 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 { schemas } from '@0x/json-schemas'; -import { - BlockParam, - BlockParamLiteral, - BlockRange, - CallData, - ContractAbi, - ContractArtifact, - DecodedLogArgs, - MethodAbi, - TransactionReceiptWithDecodedLogs, - TxData, - TxDataPayable, - SupportedProvider, -} from 'ethereum-types'; -import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - 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 - -/* istanbul ignore next */ -// tslint:disable:no-parameter-reassignment -// tslint:disable-next-line:class-name -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; - }, - }; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - ): 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 IAssetProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - ): 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); - [] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, []); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`IAssetProxy successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new IAssetProxyContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = []; - return contractInstance; - } - - /** - * @returns The contract ABI - */ - public static ABI(): ContractAbi { - const abi = [ - { - constant: false, - inputs: [ - { - name: 'assetData', - type: 'bytes', - }, - { - name: 'from', - type: 'address', - }, - { - name: 'to', - type: 'address', - }, - { - name: 'amount', - type: 'uint256', - }, - ], - name: 'transferFrom', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getProxyId', - outputs: [ - { - name: '', - type: 'bytes4', - }, - ], - payable: false, - stateMutability: 'pure', - type: 'function', - }, - ] as ContractAbi; - return abi; - } - constructor( - address: string, - supportedProvider: SupportedProvider, - txDefaults?: Partial, - logDecodeDependencies?: { [contractName: string]: ContractAbi }, - deployedBytecode: string | undefined = IAssetProxyContract.deployedBytecode, - ) { - super( - 'IAssetProxy', - IAssetProxyContract.ABI(), - address, - supportedProvider, - txDefaults, - logDecodeDependencies, - deployedBytecode, - ); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); - } -} - -// tslint:disable:max-file-line-count -// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align -// tslint:enable:trailing-comma whitespace no-trailing-whitespace 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 deleted file mode 100644 index 752c5eba6e..0000000000 --- a/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts +++ /dev/null @@ -1,1634 +0,0 @@ -// 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 { schemas } from '@0x/json-schemas'; -import { - BlockParam, - BlockParamLiteral, - BlockRange, - CallData, - ContractAbi, - ContractArtifact, - DecodedLogArgs, - LogWithDecodedArgs, - MethodAbi, - TransactionReceiptWithDecodedLogs, - TxData, - TxDataPayable, - SupportedProvider, -} from 'ethereum-types'; -import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - 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 - -export type MultiAssetProxyEventArgs = - | MultiAssetProxyAuthorizedAddressAddedEventArgs - | MultiAssetProxyAuthorizedAddressRemovedEventArgs - | MultiAssetProxyAssetProxyRegisteredEventArgs; - -export enum MultiAssetProxyEvents { - AuthorizedAddressAdded = 'AuthorizedAddressAdded', - AuthorizedAddressRemoved = 'AuthorizedAddressRemoved', - AssetProxyRegistered = 'AssetProxyRegistered', -} - -export interface MultiAssetProxyAuthorizedAddressAddedEventArgs extends DecodedLogArgs { - target: string; - caller: string; -} - -export interface MultiAssetProxyAuthorizedAddressRemovedEventArgs extends DecodedLogArgs { - target: string; - caller: string; -} - -export interface MultiAssetProxyAssetProxyRegisteredEventArgs extends DecodedLogArgs { - id: string; - assetProxy: string; -} - -/* istanbul ignore next */ -// tslint:disable:no-parameter-reassignment -// tslint:disable-next-line:class-name -export class MultiAssetProxyContract extends BaseContract { - /** - * @ignore - */ - 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 readonly _subscriptionManager: SubscriptionManager; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - ): 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 MultiAssetProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - ): 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); - [] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, []); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`MultiAssetProxy successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new MultiAssetProxyContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = []; - return contractInstance; - } - - /** - * @returns The contract ABI - */ - public static ABI(): ContractAbi { - const abi = [ - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'bytes4', - }, - ], - name: 'assetProxies', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - ], - name: 'addAuthorizedAddress', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'uint256', - }, - ], - name: 'authorities', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'assetProxyId', - type: 'bytes4', - }, - ], - name: 'getAssetProxy', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - ], - name: 'removeAuthorizedAddress', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'owner', - outputs: [ - { - name: '', - type: 'address', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'target', - type: 'address', - }, - { - name: 'index', - type: 'uint256', - }, - ], - name: 'removeAuthorizedAddressAtIndex', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getProxyId', - outputs: [ - { - name: '', - type: 'bytes4', - }, - ], - payable: false, - stateMutability: 'pure', - type: 'function', - }, - { - constant: true, - inputs: [ - { - name: 'index_0', - type: 'address', - }, - ], - name: 'authorized', - outputs: [ - { - name: '', - type: 'bool', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'assetProxy', - type: 'address', - }, - ], - name: 'registerAssetProxy', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getAuthorizedAddresses', - outputs: [ - { - name: '', - type: 'address[]', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: false, - inputs: [ - { - name: 'newOwner', - type: 'address', - }, - ], - name: 'transferOwnership', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'fallback', - }, - { - anonymous: false, - inputs: [ - { - name: 'target', - type: 'address', - indexed: true, - }, - { - name: 'caller', - type: 'address', - indexed: true, - }, - ], - name: 'AuthorizedAddressAdded', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'target', - type: 'address', - indexed: true, - }, - { - name: 'caller', - type: 'address', - indexed: true, - }, - ], - name: 'AuthorizedAddressRemoved', - outputs: [], - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - name: 'id', - type: 'bytes4', - indexed: false, - }, - { - name: 'assetProxy', - type: 'address', - indexed: false, - }, - ], - name: 'AssetProxyRegistered', - outputs: [], - type: 'event', - }, - ] as ContractAbi; - return abi; - } - /** - * Subscribe to an event type emitted by the MultiAssetProxy contract. - * @param eventName The MultiAssetProxy 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: MultiAssetProxyEvents, - indexFilterValues: IndexedFilterValues, - callback: EventCallback, - isVerbose: boolean = false, - blockPollingIntervalMs?: number, - ): string { - assert.doesBelongToStringEnum('eventName', eventName, MultiAssetProxyEvents); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - assert.isFunction('callback', callback); - const subscriptionToken = this._subscriptionManager.subscribe( - this.address, - eventName, - indexFilterValues, - MultiAssetProxyContract.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 MultiAssetProxy 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: MultiAssetProxyEvents, - blockRange: BlockRange, - indexFilterValues: IndexedFilterValues, - ): Promise>> { - assert.doesBelongToStringEnum('eventName', eventName, MultiAssetProxyEvents); - assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - const logs = await this._subscriptionManager.getLogsAsync( - this.address, - eventName, - blockRange, - indexFilterValues, - MultiAssetProxyContract.ABI(), - ); - return logs; - } - constructor( - address: string, - supportedProvider: SupportedProvider, - txDefaults?: Partial, - logDecodeDependencies?: { [contractName: string]: ContractAbi }, - deployedBytecode: string | undefined = MultiAssetProxyContract.deployedBytecode, - ) { - super( - 'MultiAssetProxy', - MultiAssetProxyContract.ABI(), - address, - supportedProvider, - txDefaults, - logDecodeDependencies, - deployedBytecode, - ); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); - this._subscriptionManager = new SubscriptionManager( - MultiAssetProxyContract.ABI(), - this._web3Wrapper, - ); - } -} - -// tslint:disable:max-file-line-count -// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align -// tslint:enable:trailing-comma whitespace no-trailing-whitespace 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 deleted file mode 100644 index c75c4d2457..0000000000 --- a/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts +++ /dev/null @@ -1,282 +0,0 @@ -// 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 { schemas } from '@0x/json-schemas'; -import { - BlockParam, - BlockParamLiteral, - BlockRange, - CallData, - ContractAbi, - ContractArtifact, - DecodedLogArgs, - MethodAbi, - TransactionReceiptWithDecodedLogs, - TxData, - TxDataPayable, - SupportedProvider, -} from 'ethereum-types'; -import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - 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 - -/* istanbul ignore next */ -// tslint:disable:no-parameter-reassignment -// tslint:disable-next-line:class-name -export class StaticCallProxyContract extends BaseContract { - /** - * @ignore - */ - 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; - }, - }; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - ): 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 StaticCallProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - ): 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); - [] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, []); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`StaticCallProxy successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new StaticCallProxyContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = []; - return contractInstance; - } - - /** - * @returns The contract ABI - */ - public static ABI(): ContractAbi { - const abi = [ - { - constant: true, - inputs: [ - { - name: 'assetData', - type: 'bytes', - }, - { - name: 'from', - type: 'address', - }, - { - name: 'to', - type: 'address', - }, - { - name: 'amount', - type: 'uint256', - }, - ], - name: 'transferFrom', - outputs: [], - payable: false, - stateMutability: 'view', - type: 'function', - }, - { - constant: true, - inputs: [], - name: 'getProxyId', - outputs: [ - { - name: '', - type: 'bytes4', - }, - ], - payable: false, - stateMutability: 'pure', - type: 'function', - }, - ] as ContractAbi; - return abi; - } - constructor( - address: string, - supportedProvider: SupportedProvider, - txDefaults?: Partial, - logDecodeDependencies?: { [contractName: string]: ContractAbi }, - deployedBytecode: string | undefined = StaticCallProxyContract.deployedBytecode, - ) { - super( - 'StaticCallProxy', - StaticCallProxyContract.ABI(), - address, - supportedProvider, - txDefaults, - logDecodeDependencies, - deployedBytecode, - ); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); - } -} - -// tslint:disable:max-file-line-count -// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align -// tslint:enable:trailing-comma whitespace no-trailing-whitespace diff --git a/packages/abi-gen-wrappers/src/index.ts b/packages/abi-gen-wrappers/src/index.ts index a4ab6b93bf..0f79381c49 100644 --- a/packages/abi-gen-wrappers/src/index.ts +++ b/packages/abi-gen-wrappers/src/index.ts @@ -1,19 +1,3 @@ -export { - AssetProxyOwnerEventArgs, - AssetProxyOwnerEvents, - AssetProxyOwnerConfirmationTimeSetEventArgs, - AssetProxyOwnerTimeLockChangeEventArgs, - AssetProxyOwnerConfirmationEventArgs, - AssetProxyOwnerRevocationEventArgs, - AssetProxyOwnerSubmissionEventArgs, - AssetProxyOwnerExecutionEventArgs, - AssetProxyOwnerExecutionFailureEventArgs, - AssetProxyOwnerDepositEventArgs, - AssetProxyOwnerOwnerAdditionEventArgs, - AssetProxyOwnerOwnerRemovalEventArgs, - AssetProxyOwnerRequirementChangeEventArgs, - AssetProxyOwnerContract, -} from './generated-wrappers/asset_proxy_owner'; export { DevUtilsContract } from './generated-wrappers/dev_utils'; export { DummyERC20TokenEventArgs, @@ -37,21 +21,6 @@ export { ERC1155MintableTransferSingleEventArgs, ERC1155MintableURIEventArgs, } from './generated-wrappers/erc1155_mintable'; -export { DutchAuctionContract } from './generated-wrappers/dutch_auction'; -export { - ERC1155ProxyEventArgs, - ERC1155ProxyEvents, - ERC1155ProxyAuthorizedAddressAddedEventArgs, - ERC1155ProxyAuthorizedAddressRemovedEventArgs, - ERC1155ProxyContract, -} from './generated-wrappers/erc1155_proxy'; -export { - ERC20ProxyEventArgs, - ERC20ProxyEvents, - ERC20ProxyAuthorizedAddressAddedEventArgs, - ERC20ProxyAuthorizedAddressRemovedEventArgs, - ERC20ProxyContract, -} from './generated-wrappers/erc20_proxy'; export { ERC20TokenEventArgs, ERC20TokenEvents, @@ -59,13 +28,6 @@ export { ERC20TokenApprovalEventArgs, ERC20TokenContract, } from './generated-wrappers/erc20_token'; -export { - ERC721ProxyEventArgs, - ERC721ProxyEvents, - ERC721ProxyAuthorizedAddressAddedEventArgs, - ERC721ProxyAuthorizedAddressRemovedEventArgs, - ERC721ProxyContract, -} from './generated-wrappers/erc721_proxy'; export { ERC721TokenEventArgs, ERC721TokenEvents, @@ -88,19 +50,9 @@ export { ExchangeTransactionExecutionEventArgs, } from './generated-wrappers/exchange'; export { ForwarderContract } from './generated-wrappers/forwarder'; -export { IAssetProxyContract } from './generated-wrappers/i_asset_proxy'; export { IValidatorContract } from './generated-wrappers/i_validator'; export { IWalletContract } from './generated-wrappers/i_wallet'; -export { - MultiAssetProxyEventArgs, - MultiAssetProxyEvents, - MultiAssetProxyAuthorizedAddressAddedEventArgs, - MultiAssetProxyAuthorizedAddressRemovedEventArgs, - MultiAssetProxyAssetProxyRegisteredEventArgs, - MultiAssetProxyContract, -} from './generated-wrappers/multi_asset_proxy'; export { OrderValidatorContract } from './generated-wrappers/order_validator'; -export { StaticCallProxyContract } from './generated-wrappers/static_call_proxy'; export { StakingAuthorizedAddressAddedEventArgs, StakingAuthorizedAddressRemovedEventArgs, @@ -141,13 +93,6 @@ export { WETH9WithdrawalEventArgs, WETH9Contract, } from './generated-wrappers/weth9'; -export { - ZRXTokenEventArgs, - ZRXTokenEvents, - ZRXTokenTransferEventArgs, - ZRXTokenApprovalEventArgs, - ZRXTokenContract, -} from './generated-wrappers/zrx_token'; export { CoordinatorContract } from './generated-wrappers/coordinator'; export { CoordinatorRegistryEventArgs, 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..6102ac862a 100644 --- a/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts +++ b/packages/asset-swapper/test/forwarder_swap_quote_consumer_test.ts @@ -77,7 +77,7 @@ describe('ForwarderSwapQuoteConsumer', () => { beforeEach(async () => { await blockchainLifecycle.startAsync(); const UNLIMITED_ALLOWANCE = UNLIMITED_ALLOWANCE_IN_BASE_UNITS; - erc20ProxyAddress = contractWrappers.erc20Proxy.address; + erc20ProxyAddress = contractAddresses.erc20Proxy; const totalFillableAmount = FILLABLE_AMOUNTS.reduce( (a: BigNumber, c: BigNumber) => a.plus(c), diff --git a/packages/asset-swapper/test/swap_quote_consumer_test.ts b/packages/asset-swapper/test/swap_quote_consumer_test.ts index 11cc89af3c..e8329f1115 100644 --- a/packages/asset-swapper/test/swap_quote_consumer_test.ts +++ b/packages/asset-swapper/test/swap_quote_consumer_test.ts @@ -71,7 +71,7 @@ describe('SwapQuoteConsumer', () => { beforeEach(async () => { await blockchainLifecycle.startAsync(); const UNLIMITED_ALLOWANCE = UNLIMITED_ALLOWANCE_IN_BASE_UNITS; - erc20ProxyAddress = contractWrappers.erc20Proxy.address; + erc20ProxyAddress = contractAddresses.erc20Proxy; const totalFillableAmount = FILLABLE_AMOUNTS.reduce( (a: BigNumber, c: BigNumber) => a.plus(c), diff --git a/packages/contract-wrappers/src/contract_wrappers.ts b/packages/contract-wrappers/src/contract_wrappers.ts index 93b40fe761..d1ab2d18a8 100644 --- a/packages/contract-wrappers/src/contract_wrappers.ts +++ b/packages/contract-wrappers/src/contract_wrappers.ts @@ -1,8 +1,5 @@ import { DevUtilsContract, - DutchAuctionContract, - ERC20ProxyContract, - ERC721ProxyContract, ExchangeContract, ForwarderContract, OrderValidatorContract, @@ -13,9 +10,7 @@ import { Coordinator, DevUtils, DutchAuction, - ERC20Proxy, ERC20Token, - ERC721Proxy, ERC721Token, Exchange, Forwarder, @@ -45,16 +40,6 @@ export class ContractWrappers { * An instance of the ExchangeContract class containing methods for interacting with the 0x Exchange smart contract. */ public exchange: ExchangeContract; - /** - * An instance of the ERC20ProxyContract class containing methods for interacting with the - * erc20Proxy smart contract. - */ - public erc20Proxy: ERC20ProxyContract; - /** - * An instance of the ERC721ProxyContract class containing methods for interacting with the - * erc721Proxy smart contract. - */ - public erc721Proxy: ERC721ProxyContract; /** * An instance of the WETH9Contract class containing methods for interacting with the * WETH9 smart contract. @@ -64,14 +49,11 @@ export class ContractWrappers { * An instance of the ForwarderContract class containing methods for interacting with any Forwarder smart contract. */ public forwarder: ForwarderContract; + // TODO(fabio): Remove orderValidator after @0x/asset-buyer is deleted /** * An instance of the OrderValidatorContract class containing methods for interacting with any OrderValidator smart contract. */ public orderValidator: OrderValidatorContract; - /** - * An instance of the DutchAuctionContract class containing methods for interacting with any DutchAuction smart contract. - */ - public dutchAuction: DutchAuctionContract; /** * An instance of the DevUtilsContract class containing methods for interacting with the DevUtils smart contract. */ @@ -99,9 +81,7 @@ export class ContractWrappers { Coordinator, DevUtils, DutchAuction, - ERC20Proxy, ERC20Token, - ERC721Proxy, ERC721Token, Exchange, Forwarder, @@ -115,13 +95,10 @@ export class ContractWrappers { config.contractAddresses === undefined ? _getDefaultContractAddresses(config.chainId) : config.contractAddresses; - this.erc20Proxy = new ERC20ProxyContract(contractAddresses.erc20Proxy, this.getProvider()); - this.erc721Proxy = new ERC721ProxyContract(contractAddresses.erc721Proxy, this.getProvider()); this.weth9 = new WETH9Contract(contractAddresses.etherToken, this.getProvider()); this.exchange = new ExchangeContract(contractAddresses.exchange, this.getProvider()); this.forwarder = new ForwarderContract(contractAddresses.forwarder, this.getProvider()); this.orderValidator = new OrderValidatorContract(contractAddresses.orderValidator, this.getProvider()); - this.dutchAuction = new DutchAuctionContract(contractAddresses.dutchAuction, this.getProvider()); this.devUtils = new DevUtilsContract(contractAddresses.devUtils, this.getProvider()); this.coordinator = new CoordinatorWrapper( this.getProvider(), @@ -137,8 +114,6 @@ export class ContractWrappers { */ public unsubscribeAll(): void { this.exchange.unsubscribeAll(); - this.erc20Proxy.unsubscribeAll(); - this.erc721Proxy.unsubscribeAll(); this.weth9.unsubscribeAll(); } /** diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index e3576f9f49..3d75dfdb60 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -14,7 +14,6 @@ export { ExchangeContract, DevUtilsContract, ForwarderContract, - DutchAuctionContract, CoordinatorContract, CoordinatorRegistryEventArgs, CoordinatorRegistryEvents, @@ -40,11 +39,6 @@ export { ERC721TokenApprovalEventArgs, ERC721TokenApprovalForAllEventArgs, ERC721TokenContract, - ERC1155ProxyEventArgs, - ERC1155ProxyEvents, - ERC1155ProxyAuthorizedAddressAddedEventArgs, - ERC1155ProxyAuthorizedAddressRemovedEventArgs, - ERC1155ProxyContract, ZRXTokenEventArgs, ZRXTokenEvents, ZRXTokenTransferEventArgs, @@ -61,16 +55,6 @@ export { DummyERC721TokenApprovalEventArgs, DummyERC721TokenApprovalForAllEventArgs, DummyERC721TokenContract, - ERC20ProxyEventArgs, - ERC20ProxyEvents, - ERC20ProxyContract, - ERC20ProxyAuthorizedAddressAddedEventArgs, - ERC20ProxyAuthorizedAddressRemovedEventArgs, - ERC721ProxyEventArgs, - ERC721ProxyEvents, - ERC721ProxyAuthorizedAddressAddedEventArgs, - ERC721ProxyAuthorizedAddressRemovedEventArgs, - ERC721ProxyContract, OrderValidatorContract, ExchangeProtocolFeeCollectorAddressEventArgs, ExchangeProtocolFeeMultiplierEventArgs, diff --git a/packages/migrations/package.json b/packages/migrations/package.json index f9effc60a0..4b9712d203 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -59,14 +59,18 @@ "@0x/base-contract": "^5.5.0-beta.1", "@0x/contract-addresses": "^3.3.0-beta.2", "@0x/contract-artifacts": "^2.3.0-beta.2", - "@0x/contracts-asset-proxy": "^2.3.0-beta.1", - "@0x/contracts-coordinator": "^2.1.0-beta.1", - "@0x/contracts-dev-utils": "^0.1.0-beta.1", - "@0x/contracts-exchange": "^2.2.0-beta.1", - "@0x/contracts-exchange-forwarder": "^3.1.0-beta.1", + "@0x/contracts-asset-proxy": "2.3.0-beta.1", + "@0x/contracts-exchange-forwarder": "3.1.0-beta.1", + "@0x/contracts-dev-utils": "0.1.0-beta.1", + "@0x/contracts-coordinator": "2.1.0-beta.1", "@0x/contracts-multisig": "^3.2.0-beta.1", "@0x/contracts-staking": "^1.1.0-beta.1", + "@0x/contracts-exchange": "^2.2.0-beta.1", + "@0x/contracts-extensions": "^4.1.0-beta.1", "@0x/contracts-utils": "^3.3.0-beta.1", + "@0x/contracts-erc20": "^2.3.0-beta.1", + "@0x/contracts-erc721": "^2.2.0-beta.1", + "@0x/contracts-erc1155": "^1.2.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/subproviders": "^5.1.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index 87982e0086..ee74cac1da 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -1,6 +1,13 @@ -import * as wrappers from '@0x/abi-gen-wrappers'; import { ContractAddresses } from '@0x/contract-addresses'; import * as artifacts from '@0x/contract-artifacts'; +import { ERC1155ProxyContract, ERC20ProxyContract, ERC721ProxyContract, MultiAssetProxyContract, StaticCallProxyContract } from '@0x/contracts-asset-proxy'; +import { CoordinatorContract, CoordinatorRegistryContract } from '@0x/contracts-coordinator'; +import { DevUtilsContract, OrderValidationUtilsContract } from '@0x/contracts-dev-utils'; +import { ERC1155MintableContract } from '@0x/contracts-erc1155'; +import { DummyERC20TokenContract, WETH9Contract, ZRXTokenContract } from '@0x/contracts-erc20'; +import { DummyERC721TokenContract } from '@0x/contracts-erc721'; +import { ExchangeContract } from '@0x/contracts-exchange'; +import { ForwarderContract } from '@0x/contracts-exchange-forwarder'; import { Web3ProviderEngine } from '@0x/subproviders'; import { AbiEncoder, BigNumber, providerUtils } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; @@ -55,13 +62,13 @@ export async function runMigrationsAsync( const chainId = new BigNumber(await providerUtils.getChainIdAsync(provider)); // Proxies - const erc20Proxy = await wrappers.ERC20ProxyContract.deployFrom0xArtifactAsync( + const erc20Proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync( artifacts.ERC20Proxy, provider, txDefaults, artifacts, ); - const erc721Proxy = await wrappers.ERC721ProxyContract.deployFrom0xArtifactAsync( + const erc721Proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync( artifacts.ERC721Proxy, provider, txDefaults, @@ -69,7 +76,7 @@ export async function runMigrationsAsync( ); // ZRX - const zrxToken = await wrappers.ZRXTokenContract.deployFrom0xArtifactAsync( + const zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync( artifacts.ZRXToken, provider, txDefaults, @@ -77,7 +84,7 @@ export async function runMigrationsAsync( ); // Ether token - const etherToken = await wrappers.WETH9Contract.deployFrom0xArtifactAsync( + const etherToken = await WETH9Contract.deployFrom0xArtifactAsync( artifacts.WETH9, provider, txDefaults, @@ -86,7 +93,7 @@ export async function runMigrationsAsync( // Exchange const zrxAssetData = encodeERC20AssetData(zrxToken.address); - const exchange = await wrappers.ExchangeContract.deployFrom0xArtifactAsync( + const exchange = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, provider, txDefaults, @@ -98,7 +105,7 @@ export async function runMigrationsAsync( for (const token of erc20TokenInfo) { const totalSupply = new BigNumber(1000000000000000000000000000); // tslint:disable-next-line:no-unused-variable - const dummyErc20Token = await wrappers.DummyERC20TokenContract.deployFrom0xArtifactAsync( + const dummyErc20Token = await DummyERC20TokenContract.deployFrom0xArtifactAsync( artifacts.DummyERC20Token, provider, txDefaults, @@ -112,7 +119,7 @@ export async function runMigrationsAsync( // ERC721 // tslint:disable-next-line:no-unused-variable - const cryptoKittieToken = await wrappers.DummyERC721TokenContract.deployFrom0xArtifactAsync( + const cryptoKittieToken = await DummyERC721TokenContract.deployFrom0xArtifactAsync( artifacts.DummyERC721Token, provider, txDefaults, @@ -122,21 +129,21 @@ export async function runMigrationsAsync( ); // 1155 Asset Proxy - const erc1155Proxy = await wrappers.ERC1155ProxyContract.deployFrom0xArtifactAsync( + const erc1155Proxy = await ERC1155ProxyContract.deployFrom0xArtifactAsync( artifacts.ERC1155Proxy, provider, txDefaults, artifacts, ); - const staticCallProxy = await wrappers.StaticCallProxyContract.deployFrom0xArtifactAsync( + const staticCallProxy = await StaticCallProxyContract.deployFrom0xArtifactAsync( artifacts.StaticCallProxy, provider, txDefaults, artifacts, ); - const multiAssetProxy = await wrappers.MultiAssetProxyContract.deployFrom0xArtifactAsync( + const multiAssetProxy = await MultiAssetProxyContract.deployFrom0xArtifactAsync( artifacts.MultiAssetProxy, provider, txDefaults, @@ -165,7 +172,7 @@ export async function runMigrationsAsync( await exchange.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address, txDefaults); // Forwarder - const forwarder = await wrappers.ForwarderContract.deployFrom0xArtifactAsync( + const forwarder = await ForwarderContract.deployFrom0xArtifactAsync( artifacts.Forwarder, provider, txDefaults, @@ -175,23 +182,24 @@ export async function runMigrationsAsync( ); // OrderValidator - const orderValidator = await wrappers.OrderValidatorContract.deployFrom0xArtifactAsync( + const orderValidator = await OrderValidationUtilsContract.deployFrom0xArtifactAsync( artifacts.OrderValidator, provider, txDefaults, artifacts, exchange.address, - zrxAssetData, ); - // DutchAuction - const dutchAuction = await wrappers.DutchAuctionContract.deployFrom0xArtifactAsync( - artifacts.DutchAuction, - provider, - txDefaults, - artifacts, - exchange.address, - ); + // TODO(fabio): Uncomment dutchAuction once the @0x/contracts-extensions is refactored + // for V3 + // // DutchAuction + // const dutchAuction = await DutchAuctionContract.deployFrom0xArtifactAsync( + // artifacts.DutchAuction, + // provider, + // txDefaults, + // artifacts, + // exchange.address, + // ); // TODO (xianny): figure out how to deploy AssetProxyOwnerContract properly // // Multisigs @@ -202,7 +210,7 @@ export async function runMigrationsAsync( // // AssetProxyOwner - // const assetProxyOwner = await wrappers.AssetProxyOwnerContract.deployFrom0xArtifactAsync( + // const assetProxyOwner = await AssetProxyOwnerContract.deployFrom0xArtifactAsync( // artifacts.AssetProxyOwner, // provider, // txDefaults, @@ -242,7 +250,7 @@ export async function runMigrationsAsync( await zrxToken.transfer.awaitTransactionSuccessAsync(forwarder.address, zrxForwarderAmount, txDefaults); // CoordinatorRegistry - const coordinatorRegistry = await wrappers.CoordinatorRegistryContract.deployFrom0xArtifactAsync( + const coordinatorRegistry = await CoordinatorRegistryContract.deployFrom0xArtifactAsync( artifacts.CoordinatorRegistry, provider, txDefaults, @@ -250,16 +258,17 @@ export async function runMigrationsAsync( ); // Coordinator - const coordinator = await wrappers.CoordinatorContract.deployFrom0xArtifactAsync( + const coordinator = await CoordinatorContract.deployFrom0xArtifactAsync( artifacts.Coordinator, provider, txDefaults, artifacts, exchange.address, + chainId, ); // Dev Utils - const devUtils = await wrappers.DevUtilsContract.deployFrom0xArtifactAsync( + const devUtils = await DevUtilsContract.deployFrom0xArtifactAsync( artifacts.DevUtils, provider, txDefaults, @@ -268,7 +277,7 @@ export async function runMigrationsAsync( ); // tslint:disable-next-line:no-unused-variable - const erc1155DummyToken = await wrappers.ERC1155MintableContract.deployFrom0xArtifactAsync( + const erc1155DummyToken = await ERC1155MintableContract.deployFrom0xArtifactAsync( artifacts.ERC1155Mintable, provider, txDefaults, @@ -288,7 +297,7 @@ export async function runMigrationsAsync( zeroExGovernor: constants.NULL_ADDRESS, forwarder: forwarder.address, orderValidator: orderValidator.address, - dutchAuction: dutchAuction.address, + dutchAuction: constants.NULL_ADDRESS, coordinatorRegistry: coordinatorRegistry.address, coordinator: coordinator.address, multiAssetProxy: multiAssetProxy.address, diff --git a/packages/migrations/src/test_contract_configs.ts b/packages/migrations/src/test_contract_configs.ts index 9c56e584b7..5408b20561 100644 --- a/packages/migrations/src/test_contract_configs.ts +++ b/packages/migrations/src/test_contract_configs.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node -import * as wrappers from '@0x/abi-gen-wrappers'; import { getContractAddressesForChainOrThrow } from '@0x/contract-addresses'; +import { ERC1155ProxyContract, ERC20ProxyContract, ERC721ProxyContract, MultiAssetProxyContract, StaticCallProxyContract } from '@0x/contracts-asset-proxy'; import { ExchangeContract } from '@0x/contracts-exchange'; import { ZeroExGovernorContract } from '@0x/contracts-multisig'; import { StakingContract, StakingProxyContract, ZrxVaultContract } from '@0x/contracts-staking'; @@ -34,11 +34,11 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise