diff --git a/contracts/staking/contracts/src/immutable/MixinDeploymentConstants.sol b/contracts/staking/contracts/src/immutable/MixinDeploymentConstants.sol index 6aa23444b3..70735152c7 100644 --- a/contracts/staking/contracts/src/immutable/MixinDeploymentConstants.sol +++ b/contracts/staking/contracts/src/immutable/MixinDeploymentConstants.sol @@ -28,16 +28,24 @@ contract MixinDeploymentConstants { // @TODO SET THESE VALUES FOR DEPLOYMENT // Mainnet WETH9 Address - address constant private WETH_ADDRESS = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); + // address constant private WETH_ADDRESS = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // Kovan WETH9 Address - // address constant private WETH_ADDRESS = address(0xd0a1e359811322d97991e03f863a0c30c2cf029c); + // address constant private WETH_ADDRESS = address(0xd0A1E359811322d97991E03f863a0C30C2cF029C); // Ropsten & Rinkeby WETH9 Address - // address constant private WETH_ADDRESS = address(0xc778417e063141139fce010982780140aa0cd5ab); + address constant private WETH_ADDRESS = address(0xc778417E063141139Fce010982780140Aa0cD5Ab); // @TODO SET THESE VALUES FOR DEPLOYMENT - address constant private ZRX_VAULT_ADDRESS = address(1); + + // Kovan ZrxVault address + // address constant private ZRX_VAULT_ADDRESS = address(0xf36eabdFE986B35b62c8FD5a98A7f2aEBB79B291); + + // Ropsten ZrxVault address + address constant private ZRX_VAULT_ADDRESS = address(0xffD161026865Ad8B4aB28a76840474935eEc4DfA); + + // Rinkeby ZrxVault address + // address constant private ZRX_VAULT_ADDRESS = address(0xA5Bf6aC73bC40790FC6Ffc9DBbbCE76c9176e224); /// @dev An overridable way to access the deployed WETH contract. /// Must be view to allow overrides to access state. diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts index 9252949b94..20e56f1633 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts @@ -313,6 +313,14 @@ export class AssetProxyOwnerContract extends BaseContract { 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. @@ -465,6 +473,14 @@ export class AssetProxyOwnerContract extends BaseContract { 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. @@ -624,6 +640,14 @@ export class AssetProxyOwnerContract extends BaseContract { ]); 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. @@ -778,6 +802,14 @@ export class AssetProxyOwnerContract extends BaseContract { ]); 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 = { /** @@ -1036,6 +1068,14 @@ export class AssetProxyOwnerContract extends BaseContract { ]); 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 = { /** @@ -1752,6 +1792,14 @@ export class AssetProxyOwnerContract extends BaseContract { ); 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. @@ -1902,6 +1950,14 @@ export class AssetProxyOwnerContract extends BaseContract { ]); 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. @@ -2084,6 +2140,14 @@ export class AssetProxyOwnerContract extends BaseContract { ]); 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 = { /** @@ -2281,6 +2345,14 @@ export class AssetProxyOwnerContract extends BaseContract { ]); 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 = { /** @@ -2530,6 +2602,14 @@ export class AssetProxyOwnerContract extends BaseContract { ]); 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 = { /** diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts index ff71948443..238bc768c9 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts @@ -484,6 +484,16 @@ export class CoordinatorContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as CoordinatorContract; + const abiEncoder = self._lookupAbiEncoder( + 'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', + ); + return abiEncoder.getSelector(); + }, }; public EIP712_EXCHANGE_DOMAIN_HASH = { /** diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts index 103645e98f..57abe22dc0 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts @@ -203,6 +203,14 @@ export class CoordinatorRegistryContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as CoordinatorRegistryContract; + const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)'); + return abiEncoder.getSelector(); + }, }; /** * Gets the endpoint for a Coordinator. diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts index 6420fa4849..70bd9bed76 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts @@ -2072,6 +2072,16 @@ export class DevUtilsContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DevUtilsContract; + const abiEncoder = self._lookupAbiEncoder( + 'getSimulatedOrderTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),address,uint256)', + ); + return abiEncoder.getSelector(); + }, }; /** * Simulates all of the transfers for each given order and returns the indices of each first failed transfer. @@ -2370,6 +2380,16 @@ export class DevUtilsContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DevUtilsContract; + const abiEncoder = self._lookupAbiEncoder( + 'getSimulatedOrdersTransferResults((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],address[],uint256[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Gets the amount of an asset transferable by the owner. diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts index 311a30e135..304044c949 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts @@ -338,6 +338,14 @@ export class DummyERC20TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + return abiEncoder.getSelector(); + }, }; /** * Query the balance of owner @@ -582,6 +590,14 @@ export class DummyERC20TokenContract extends BaseContract { const abiEncodedTransactionData = self._strictEncodeArguments('mint(uint256)', [_value]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder('mint(uint256)'); + return abiEncoder.getSelector(); + }, }; public name = { /** @@ -849,6 +865,14 @@ export class DummyERC20TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder('setBalance(address,uint256)'); + return abiEncoder.getSelector(); + }, }; public symbol = { /** @@ -1108,6 +1132,14 @@ export class DummyERC20TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + return abiEncoder.getSelector(); + }, }; /** * ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. See https://github.com/ethereum/EIPs/issues/717 @@ -1314,6 +1346,14 @@ export class DummyERC20TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + return abiEncoder.getSelector(); + }, }; public transferOwnership = { /** @@ -1456,6 +1496,14 @@ export class DummyERC20TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + return abiEncoder.getSelector(); + }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts index bbc525276d..5fb1cf8f24 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts @@ -250,6 +250,14 @@ export class DummyERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + return abiEncoder.getSelector(); + }, }; /** * NFTs assigned to the zero address are considered invalid, and this @@ -477,6 +485,14 @@ export class DummyERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('burn(address,uint256)'); + return abiEncoder.getSelector(); + }, }; /** * Throws if `_tokenId` is not a valid NFT. @@ -759,6 +775,14 @@ export class DummyERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('mint(address,uint256)'); + return abiEncoder.getSelector(); + }, }; public name = { /** @@ -1105,6 +1129,14 @@ export class DummyERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); + return abiEncoder.getSelector(); + }, }; /** * Throws unless `msg.sender` is the current owner, an authorized @@ -1333,6 +1365,14 @@ export class DummyERC721TokenContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); + return abiEncoder.getSelector(); + }, }; /** * Emits the ApprovalForAll event. The contract MUST allow @@ -1520,6 +1560,14 @@ export class DummyERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); + return abiEncoder.getSelector(); + }, }; public symbol = { /** @@ -1771,6 +1819,14 @@ export class DummyERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + return abiEncoder.getSelector(); + }, }; public transferOwnership = { /** @@ -1913,6 +1969,14 @@ export class DummyERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as DummyERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + return abiEncoder.getSelector(); + }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts index 9489d74f25..15a3297209 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts @@ -281,6 +281,16 @@ export class DutchAuctionContract extends BaseContract { ); 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 @@ -677,6 +687,16 @@ export class DutchAuctionContract extends BaseContract { ); 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, diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts index e28018bbac..9d8a0f0167 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_mintable.ts @@ -19,7 +19,13 @@ import { SupportedProvider, } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types'; +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'; @@ -69,6 +75,9 @@ export interface ERC1155MintableURIEventArgs extends DecodedLogArgs { // tslint:disable:no-parameter-reassignment // tslint:disable-next-line:class-name export class ERC1155MintableContract extends BaseContract { + /** + * @ignore + */ public static deployedBytecode = '0x608060405234801561001057600080fd5b50600436106101765760003560e01c80639f4b286a116100d8578063e0a5c9491161008c578063f242432a11610066578063f242432a146107bb578063f94190881461085d578063fc67bf1c146108d457610176565b8063e0a5c94914610726578063e44591f014610763578063e985e9c51461078057610176565b8063adebf6f2116100bd578063adebf6f21461067a578063cc10e40114610697578063cd53d08e1461070957610176565b80639f4b286a146105c8578063a22cb4651461063f57610176565b80636352211e1161012f5780637269a327116101145780637269a327146104c557806378b27221146104e25780639cca1c64146105ab57610176565b80636352211e146104625780636f969c2d146104a857610176565b80632eb2c2d6116101605780632eb2c2d6146101e35780634e1273f41461031f5780635e81b9581461043157610176565b8062fdd58e1461017b57806308d7d469146101c6575b600080fd5b6101b46004803603604081101561019157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356108dc565b60408051918252519081900360200190f35b6101b4600480360360208110156101dc57600080fd5b5035610966565b61031d600480360360a08110156101f957600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359091169181019060608101604082013564010000000081111561023a57600080fd5b82018360208201111561024c57600080fd5b8035906020019184602083028401116401000000008311171561026e57600080fd5b91939092909160208101903564010000000081111561028c57600080fd5b82018360208201111561029e57600080fd5b803590602001918460208302840111640100000000831117156102c057600080fd5b9193909290916020810190356401000000008111156102de57600080fd5b8201836020820111156102f057600080fd5b8035906020019184600183028401116401000000008311171561031257600080fd5b509092509050610978565b005b6103e16004803603604081101561033557600080fd5b81019060208101813564010000000081111561035057600080fd5b82018360208201111561036257600080fd5b8035906020019184602083028401116401000000008311171561038457600080fd5b9193909290916020810190356401000000008111156103a257600080fd5b8201836020820111156103b457600080fd5b803590602001918460208302840111640100000000831117156103d657600080fd5b509092509050611192565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561041d578181015183820152602001610405565b505050509050019250505060405180910390f35b61044e6004803603602081101561044757600080fd5b5035611357565b604080519115158252519081900360200190f35b61047f6004803603602081101561047857600080fd5b503561139d565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101b4600480360360208110156104be57600080fd5b50356113c5565b61044e600480360360208110156104db57600080fd5b50356113ea565b61031d600480360360608110156104f857600080fd5b8135919081019060408101602082013564010000000081111561051a57600080fd5b82018360208201111561052c57600080fd5b8035906020019184602083028401116401000000008311171561054e57600080fd5b91939092909160208101903564010000000081111561056c57600080fd5b82018360208201111561057e57600080fd5b803590602001918460208302840111640100000000831117156105a057600080fd5b50909250905061142f565b6101b4600480360360208110156105c157600080fd5b5035611760565b61031d600480360360408110156105de57600080fd5b8135919081019060408101602082013564010000000081111561060057600080fd5b82018360208201111561061257600080fd5b8035906020019184600183028401116401000000008311171561063457600080fd5b509092509050611775565b61031d6004803603604081101561065557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001351515611875565b61044e6004803603602081101561069057600080fd5b503561190e565b6101b4600480360360408110156106ad57600080fd5b8101906020810181356401000000008111156106c857600080fd5b8201836020820111156106da57600080fd5b803590602001918460018302840111640100000000831117156106fc57600080fd5b9193509150351515611934565b61047f6004803603602081101561071f57600080fd5b5035611a6d565b61072e611a95565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b61044e6004803603602081101561077957600080fd5b5035611ab9565b61044e6004803603604081101561079657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611ae1565b61031d600480360360a08110156107d157600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359091169160408201359160608101359181019060a08101608082013564010000000081111561081e57600080fd5b82018360208201111561083057600080fd5b8035906020019184600183028401116401000000008311171561085257600080fd5b509092509050611b1c565b61031d6004803603604081101561087357600080fd5b8135919081019060408101602082013564010000000081111561089557600080fd5b8201836020820111156108a757600080fd5b803590602001918460208302840111640100000000831117156108c957600080fd5b5090925090506120fb565b61072e61242b565b60006108e782611357565b1561092e5760008281526020819052604090205473ffffffffffffffffffffffffffffffffffffffff848116911614610921576000610924565b60015b60ff169050610960565b50600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020545b92915050565b60056020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff87166109fa57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f43414e4e4f545f5452414e534645525f544f5f414444524553535f5a45524f00604482015290519081900360640190fd5b848314610a6857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f544f4b454e5f414e445f56414c5545535f4c454e4754485f4d49534d41544348604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8816331480610ac1575073ffffffffffffffffffffffffffffffffffffffff8816600090815260026020908152604080832033845290915290205460ff1615156001145b610b2c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e53554646494349454e545f414c4c4f57414e434500000000000000000000604482015290519081900360640190fd5b60005b85811015610deb576000878783818110610b4557fe5b9050602002013590506000868684818110610b5c57fe5b905060200201359050610b6e82611ab9565b15610cc85780600114610be257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f414d4f554e545f455155414c5f544f5f4f4e455f524551554952454400000000604482015290519081900360640190fd5b60008281526020819052604090205473ffffffffffffffffffffffffffffffffffffffff8c8116911614610c7757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e46545f4e4f545f4f574e45445f42595f46524f4d5f41444452455353000000604482015290519081900360640190fd5b600082815260208190526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8c16179055610de1565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8f168452909152902054610d02908261244f565b6001600084815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610db06001600084815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482612473565b600083815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8f1684529091529020555b5050600101610b2f565b508673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb898989896040518080602001806020018381038352878782818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169091018481038352858152602090810191508690860280828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039850909650505050505050a4610f1f8773ffffffffffffffffffffffffffffffffffffffff1661248f565b156111885760008773ffffffffffffffffffffffffffffffffffffffff1663bc197c81338b8a8a8a8a8a8a6040518963ffffffff1660e01b8152600401808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001806020018060200184810384528a8a82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169091018581038452888152602090810191508990890280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810383528681526020019050868680828437600081840152601f19601f8201169050808301925050509b505050505050505050505050602060405180830381600087803b1580156110a857600080fd5b505af11580156110bc573d6000803e3d6000fd5b505050506040513d60208110156110d257600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167fbc197c81000000000000000000000000000000000000000000000000000000001461118657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505b5050505050505050565b60608382146111ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061256a6024913960400191505060405180910390fd5b604080518581526020808702820101909152848015611215578160200160208202803883390190505b50905060005b8481101561134e57600084848381811061123157fe5b90506020020135905061124381611357565b156112b95786868381811061125457fe5b600084815260208181526040909120549102929092013573ffffffffffffffffffffffffffffffffffffffff9081169216919091149050611296576000611299565b60015b60ff168383815181106112a857fe5b602002602001018181525050611345565b6000818152600160205260408120908888858181106112d457fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483838151811061133857fe5b6020026020010181815250505b5060010161121b565b50949350505050565b60007f80000000000000000000000000000000000000000000000000000000000000008083161480156109605750506fffffffffffffffffffffffffffffffff16151590565b60009081526020819052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b7fffffffffffffffffffffffffffffffff000000000000000000000000000000001690565b60007f80000000000000000000000000000000000000000000000000000000000000008083161480156109605750506fffffffffffffffffffffffffffffffff161590565b600085815260046020526040902054859073ffffffffffffffffffffffffffffffffffffffff16331461146157600080fd5b61146a8661190e565b6114bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d81526020018061258e602d913960400191505060405180910390fd5b60005b848110156117575760008686838181106114d857fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff169050600085858481811061150557fe5b60008c815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8916845282529091205491029290920135925061154a91839150612473565b60008a815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083528184209490945580518d8152918201859052805133927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46115d68273ffffffffffffffffffffffffffffffffffffffff1661248f565b1561174d57604080517ff23a6e6100000000000000000000000000000000000000000000000000000000815233600482018190526024820152604481018b90526064810183905260a06084820152600060a48201819052915173ffffffffffffffffffffffffffffffffffffffff85169163f23a6e619160e480830192602092919082900301818787803b15801561166d57600080fd5b505af1158015611681573d6000803e3d6000fd5b505050506040513d602081101561169757600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e61000000000000000000000000000000000000000000000000000000001461174b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505b50506001016114c2565b50505050505050565b6fffffffffffffffffffffffffffffffff1690565b600083815260046020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915581518781529283018490528151849391927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62928290030190a4801561187057827f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b838360405180806020018281038252848482818152602001925080828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039550909350505050a25b505050565b33600081815260026020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b7f8000000000000000000000000000000000000000000000000000000000000000161590565b600380546001019081905560801b811561196b577f8000000000000000000000000000000000000000000000000000000000000000175b600081815260046020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915581518581529283018490528151849391927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62928290030190a48215611a6657807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b858560405180806020018281038252848482818152602001925080828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039550909350505050a25b9392505050565b60046020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b7ff23a6e610000000000000000000000000000000000000000000000000000000081565b7f80000000000000000000000000000000000000000000000000000000000000009081161490565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260026020908152604080832093909416825291909152205460ff1690565b73ffffffffffffffffffffffffffffffffffffffff8516611b9e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f43414e4e4f545f5452414e534645525f544f5f414444524553535f5a45524f00604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8616331480611bf7575073ffffffffffffffffffffffffffffffffffffffff8616600090815260026020908152604080832033845290915290205460ff1615156001145b611c6257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e53554646494349454e545f414c4c4f57414e434500000000000000000000604482015290519081900360640190fd5b611c6b84611ab9565b15611dc55782600114611cdf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f414d4f554e545f455155414c5f544f5f4f4e455f524551554952454400000000604482015290519081900360640190fd5b60008481526020819052604090205473ffffffffffffffffffffffffffffffffffffffff878116911614611d7457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e46545f4e4f545f4f574e45445f42595f46524f4d5f41444452455353000000604482015290519081900360640190fd5b600084815260208190526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8716179055611e74565b600084815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8a168452909152902054611dff908461244f565b600085815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8b81168552925280832093909355871681522054611e439084612473565b600085815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8a1684529091529020555b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628787604051808381526020018281526020019250505060405180910390a4611f178573ffffffffffffffffffffffffffffffffffffffff1661248f565b156120f35760008573ffffffffffffffffffffffffffffffffffffffff1663f23a6e613389888888886040518763ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050975050505050505050602060405180830381600087803b15801561201557600080fd5b505af1158015612029573d6000803e3d6000fd5b505050506040513d602081101561203f57600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e61000000000000000000000000000000000000000000000000000000001461175757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505050505050565b600083815260046020526040902054839073ffffffffffffffffffffffffffffffffffffffff16331461212d57600080fd5b61213684611ab9565b61218b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d81526020018061253d602d913960400191505060405180910390fd5b600084815260056020526040812054600101905b838110156123f75760008585838181106121b557fe5b8486018a176000818152602081815260408083208054958302979097013573ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffff00000000000000000000000000000000000000009095168517909655855183815260019181019190915285519396509194869450909233927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46122768273ffffffffffffffffffffffffffffffffffffffff1661248f565b156123ed57604080517ff23a6e6100000000000000000000000000000000000000000000000000000000815233600482018190526024820152604481018390526001606482015260a06084820152600060a48201819052915173ffffffffffffffffffffffffffffffffffffffff85169163f23a6e619160e480830192602092919082900301818787803b15801561230d57600080fd5b505af1158015612321573d6000803e3d6000fd5b505050506040513d602081101561233757600080fd5b505190507fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e6100000000000000000000000000000000000000000000000000000000146123eb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4241445f52454345495645525f52455455524e5f56414c554500000000000000604482015290519081900360640190fd5b505b505060010161219f565b50600085815260056020526040902054612412908490612473565b6000958652600560205260409095209490945550505050565b7fbc197c810000000000000000000000000000000000000000000000000000000081565b60008282111561246d5761246d61246860028585612495565b612534565b50900390565b600082820183811015611a6657611a6661246860008686612495565b3b151590565b606063e946c1bb60e01b848484604051602401808460038111156124b557fe5b60ff1681526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fdfe54524945445f544f5f4d494e545f4e4f4e5f46554e4749424c455f464f525f46554e4749424c455f544f4b454e4f574e4552535f414e445f4944535f4d5553545f484156455f53414d455f4c454e47544854524945445f544f5f4d494e545f46554e4749424c455f464f525f4e4f4e5f46554e4749424c455f544f4b454ea265627a7a723158205af7d187cbffb255b374d24e5838a04f6b3a3245622025907396b2a61f9d93da64736f6c634300050c0032'; public ERC1155_BATCH_RECEIVED = { @@ -113,41 +122,6 @@ export class ERC1155MintableContract extends BaseContract { // tslint:enable boolean-naming return result; }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('ERC1155_BATCH_RECEIVED()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('ERC1155_BATCH_RECEIVED()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('ERC1155_BATCH_RECEIVED()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; public ERC1155_RECEIVED = { /** @@ -191,41 +165,6 @@ export class ERC1155MintableContract extends BaseContract { // tslint:enable boolean-naming return result; }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('ERC1155_RECEIVED()', []); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): void { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('ERC1155_RECEIVED()'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('ERC1155_RECEIVED()'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; public balanceOf = { /** @@ -279,48 +218,6 @@ export class ERC1155MintableContract extends BaseContract { // 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 The address of the token holder - * @param id ID of the Token - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(owner: string, id: BigNumber): string { - assert.isString('owner', owner); - assert.isBigNumber('id', id); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address,uint256)', [ - owner.toLowerCase(), - id, - ]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('balanceOf(address,uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('balanceOf(address,uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; public balanceOfBatch = { /** @@ -374,48 +271,6 @@ export class ERC1155MintableContract extends BaseContract { // 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 owners The addresses of the token holders - * @param ids ID of the Tokens - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(owners: string[], ids: BigNumber[]): string { - assert.isArray('owners', owners); - assert.isArray('ids', ids); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('balanceOfBatch(address[],uint256[])', [ - owners, - ids, - ]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): string[] { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('balanceOfBatch(address[],uint256[])'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber[] { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('balanceOfBatch(address[],uint256[])'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; /** * creates a new token @@ -429,7 +284,12 @@ export class ERC1155MintableContract extends BaseContract { * @param txData Additional data for transaction * @returns The hash of the transaction */ - async sendTransactionAsync(uri: string, isNF: boolean, txData?: Partial | undefined): Promise { + async sendTransactionAsync( + uri: string, + isNF: boolean, + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { assert.isString('uri', uri); assert.isBoolean('isNF', isNF); const self = (this as any) as ERC1155MintableContract; @@ -446,6 +306,10 @@ export class ERC1155MintableContract extends BaseContract { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); } + if (opts.shouldValidate !== false) { + await self.create.callAsync(uri, isNF, txDataWithDefaults); + } + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); return txHash; }, @@ -462,21 +326,20 @@ export class ERC1155MintableContract extends BaseContract { uri: string, isNF: boolean, txData?: Partial, - pollingIntervalMs?: number, - timeoutMs?: number, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, ): PromiseWithTransactionHash { assert.isString('uri', uri); assert.isBoolean('isNF', isNF); const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.create.sendTransactionAsync(uri, isNF, txData); + const txHashPromise = self.create.sendTransactionAsync(uri, isNF, txData, opts); return new PromiseWithTransactionHash( txHashPromise, (async (): Promise => { // When the transaction hash resolves, wait for it to be mined. return self._web3Wrapper.awaitTransactionSuccessAsync( await txHashPromise, - pollingIntervalMs, - timeoutMs, + opts.pollingIntervalMs, + opts.timeoutMs, ); })(), ); @@ -508,15 +371,6 @@ export class ERC1155MintableContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, - async validateAndSendTransactionAsync( - uri: string, - isNF: boolean, - txData?: Partial | undefined, - ): Promise { - await (this as any).create.callAsync(uri, isNF, txData); - const txHash = await (this as any).create.sendTransactionAsync(uri, isNF, txData); - return txHash; - }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -584,28 +438,12 @@ export class ERC1155MintableContract extends BaseContract { return abiEncodedTransactionData; }, /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. + * Returns the 4 byte function selector as a hex string. */ - getABIDecodedTransactionData(callData: string): string { + getSelector(): string { const self = (this as any) as ERC1155MintableContract; const abiEncoder = self._lookupAbiEncoder('create(string,bool)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('create(string,bool)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; + return abiEncoder.getSelector(); }, }; /** @@ -624,6 +462,7 @@ export class ERC1155MintableContract extends BaseContract { type_: BigNumber, uri: string, txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, ): Promise { assert.isBigNumber('type_', type_); assert.isString('uri', uri); @@ -641,6 +480,10 @@ export class ERC1155MintableContract extends BaseContract { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); } + if (opts.shouldValidate !== false) { + await self.createWithType.callAsync(type_, uri, txDataWithDefaults); + } + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); return txHash; }, @@ -657,21 +500,20 @@ export class ERC1155MintableContract extends BaseContract { type_: BigNumber, uri: string, txData?: Partial, - pollingIntervalMs?: number, - timeoutMs?: number, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, ): PromiseWithTransactionHash { assert.isBigNumber('type_', type_); assert.isString('uri', uri); const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.createWithType.sendTransactionAsync(type_, uri, txData); + const txHashPromise = self.createWithType.sendTransactionAsync(type_, uri, txData, opts); return new PromiseWithTransactionHash( txHashPromise, (async (): Promise => { // When the transaction hash resolves, wait for it to be mined. return self._web3Wrapper.awaitTransactionSuccessAsync( await txHashPromise, - pollingIntervalMs, - timeoutMs, + opts.pollingIntervalMs, + opts.timeoutMs, ); })(), ); @@ -703,15 +545,6 @@ export class ERC1155MintableContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, - async validateAndSendTransactionAsync( - type_: BigNumber, - uri: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).createWithType.callAsync(type_, uri, txData); - const txHash = await (this as any).createWithType.sendTransactionAsync(type_, uri, txData); - return txHash; - }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -781,28 +614,12 @@ export class ERC1155MintableContract extends BaseContract { return abiEncodedTransactionData; }, /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. + * Returns the 4 byte function selector as a hex string. */ - getABIDecodedTransactionData(callData: string): [BigNumber, string] { + getSelector(): string { const self = (this as any) as ERC1155MintableContract; const abiEncoder = self._lookupAbiEncoder('createWithType(uint256,string)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[BigNumber, string]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('createWithType(uint256,string)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; + return abiEncoder.getSelector(); }, }; public creators = { @@ -852,42 +669,6 @@ export class ERC1155MintableContract extends BaseContract { // tslint:enable boolean-naming return result; }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(index_0: BigNumber): string { - assert.isBigNumber('index_0', index_0); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('creators(uint256)', [index_0]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('creators(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('creators(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; /** * Returns base type of non-fungible token @@ -918,7 +699,7 @@ export class ERC1155MintableContract extends BaseContract { let rawCallResult; try { - rawCallResult = await self.evmExecAsync(encodedDataBytes); + rawCallResult = await self._evmExecAsync(encodedDataBytes); } catch (err) { BaseContract._throwIfThrownErrorIsRevertError(err); throw err; @@ -931,42 +712,6 @@ export class ERC1155MintableContract extends BaseContract { // 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(id: BigNumber): string { - assert.isBigNumber('id', id); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('getNonFungibleBaseType(uint256)', [id]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('getNonFungibleBaseType(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('getNonFungibleBaseType(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; /** * Returns index of non-fungible token @@ -997,7 +742,7 @@ export class ERC1155MintableContract extends BaseContract { let rawCallResult; try { - rawCallResult = await self.evmExecAsync(encodedDataBytes); + rawCallResult = await self._evmExecAsync(encodedDataBytes); } catch (err) { BaseContract._throwIfThrownErrorIsRevertError(err); throw err; @@ -1010,42 +755,6 @@ export class ERC1155MintableContract extends BaseContract { // 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(id: BigNumber): string { - assert.isBigNumber('id', id); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('getNonFungibleIndex(uint256)', [id]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('getNonFungibleIndex(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('getNonFungibleIndex(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; public isApprovedForAll = { /** @@ -1102,48 +811,6 @@ export class ERC1155MintableContract extends BaseContract { // 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 The owner of the Tokens - * @param operator Address of authorized operator - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(owner: string, operator: string): string { - assert.isString('owner', owner); - assert.isString('operator', operator); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ - owner.toLowerCase(), - operator.toLowerCase(), - ]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): boolean { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; /** * Returns true if token is fungible @@ -1170,7 +837,7 @@ export class ERC1155MintableContract extends BaseContract { let rawCallResult; try { - rawCallResult = await self.evmExecAsync(encodedDataBytes); + rawCallResult = await self._evmExecAsync(encodedDataBytes); } catch (err) { BaseContract._throwIfThrownErrorIsRevertError(err); throw err; @@ -1183,42 +850,6 @@ export class ERC1155MintableContract extends BaseContract { // 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(id: BigNumber): string { - assert.isBigNumber('id', id); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('isFungible(uint256)', [id]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isFungible(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): boolean { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isFungible(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; /** * Returns true if token is non-fungible @@ -1245,7 +876,7 @@ export class ERC1155MintableContract extends BaseContract { let rawCallResult; try { - rawCallResult = await self.evmExecAsync(encodedDataBytes); + rawCallResult = await self._evmExecAsync(encodedDataBytes); } catch (err) { BaseContract._throwIfThrownErrorIsRevertError(err); throw err; @@ -1258,42 +889,6 @@ export class ERC1155MintableContract extends BaseContract { // 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(id: BigNumber): string { - assert.isBigNumber('id', id); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('isNonFungible(uint256)', [id]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isNonFungible(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): boolean { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isNonFungible(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; /** * Returns true if input is base-type of a non-fungible token @@ -1320,7 +915,7 @@ export class ERC1155MintableContract extends BaseContract { let rawCallResult; try { - rawCallResult = await self.evmExecAsync(encodedDataBytes); + rawCallResult = await self._evmExecAsync(encodedDataBytes); } catch (err) { BaseContract._throwIfThrownErrorIsRevertError(err); throw err; @@ -1333,42 +928,6 @@ export class ERC1155MintableContract extends BaseContract { // 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(id: BigNumber): string { - assert.isBigNumber('id', id); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('isNonFungibleBaseType(uint256)', [id]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isNonFungibleBaseType(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): boolean { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isNonFungibleBaseType(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; /** * Returns true if input is a non-fungible token @@ -1395,7 +954,7 @@ export class ERC1155MintableContract extends BaseContract { let rawCallResult; try { - rawCallResult = await self.evmExecAsync(encodedDataBytes); + rawCallResult = await self._evmExecAsync(encodedDataBytes); } catch (err) { BaseContract._throwIfThrownErrorIsRevertError(err); throw err; @@ -1408,42 +967,6 @@ export class ERC1155MintableContract extends BaseContract { // 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(id: BigNumber): string { - assert.isBigNumber('id', id); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('isNonFungibleItem(uint256)', [id]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isNonFungibleItem(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): boolean { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('isNonFungibleItem(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; public maxIndex = { /** @@ -1492,42 +1015,6 @@ export class ERC1155MintableContract extends BaseContract { // tslint:enable boolean-naming return result; }, - /** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). - * @returns The ABI encoded transaction data as a string - */ - getABIEncodedTransactionData(index_0: BigNumber): string { - assert.isBigNumber('index_0', index_0); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('maxIndex(uint256)', [index_0]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('maxIndex(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('maxIndex(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; /** * mints fungible tokens @@ -1547,6 +1034,7 @@ export class ERC1155MintableContract extends BaseContract { to: string[], quantities: BigNumber[], txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, ): Promise { assert.isBigNumber('id', id); assert.isArray('to', to); @@ -1569,6 +1057,10 @@ export class ERC1155MintableContract extends BaseContract { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); } + if (opts.shouldValidate !== false) { + await self.mintFungible.callAsync(id, to, quantities, txDataWithDefaults); + } + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); return txHash; }, @@ -1587,22 +1079,21 @@ export class ERC1155MintableContract extends BaseContract { to: string[], quantities: BigNumber[], txData?: Partial, - pollingIntervalMs?: number, - timeoutMs?: number, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, ): PromiseWithTransactionHash { assert.isBigNumber('id', id); assert.isArray('to', to); assert.isArray('quantities', quantities); const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.mintFungible.sendTransactionAsync(id, to, quantities, txData); + const txHashPromise = self.mintFungible.sendTransactionAsync(id, to, quantities, txData, opts); return new PromiseWithTransactionHash( txHashPromise, (async (): Promise => { // When the transaction hash resolves, wait for it to be mined. return self._web3Wrapper.awaitTransactionSuccessAsync( await txHashPromise, - pollingIntervalMs, - timeoutMs, + opts.pollingIntervalMs, + opts.timeoutMs, ); })(), ); @@ -1645,16 +1136,6 @@ export class ERC1155MintableContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, - async validateAndSendTransactionAsync( - id: BigNumber, - to: string[], - quantities: BigNumber[], - txData?: Partial | undefined, - ): Promise { - await (this as any).mintFungible.callAsync(id, to, quantities, txData); - const txHash = await (this as any).mintFungible.sendTransactionAsync(id, to, quantities, txData); - return txHash; - }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1734,28 +1215,12 @@ export class ERC1155MintableContract extends BaseContract { return abiEncodedTransactionData; }, /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. + * Returns the 4 byte function selector as a hex string. */ - getABIDecodedTransactionData(callData: string): [BigNumber, string[], BigNumber[]] { + getSelector(): string { const self = (this as any) as ERC1155MintableContract; const abiEncoder = self._lookupAbiEncoder('mintFungible(uint256,address[],uint256[])'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[BigNumber, string[], BigNumber[]]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('mintFungible(uint256,address[],uint256[])'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; + return abiEncoder.getSelector(); }, }; /** @@ -1774,6 +1239,7 @@ export class ERC1155MintableContract extends BaseContract { type_: BigNumber, to: string[], txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, ): Promise { assert.isBigNumber('type_', type_); assert.isArray('to', to); @@ -1791,6 +1257,10 @@ export class ERC1155MintableContract extends BaseContract { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); } + if (opts.shouldValidate !== false) { + await self.mintNonFungible.callAsync(type_, to, txDataWithDefaults); + } + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); return txHash; }, @@ -1807,21 +1277,20 @@ export class ERC1155MintableContract extends BaseContract { type_: BigNumber, to: string[], txData?: Partial, - pollingIntervalMs?: number, - timeoutMs?: number, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, ): PromiseWithTransactionHash { assert.isBigNumber('type_', type_); assert.isArray('to', to); const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.mintNonFungible.sendTransactionAsync(type_, to, txData); + const txHashPromise = self.mintNonFungible.sendTransactionAsync(type_, to, txData, opts); return new PromiseWithTransactionHash( txHashPromise, (async (): Promise => { // When the transaction hash resolves, wait for it to be mined. return self._web3Wrapper.awaitTransactionSuccessAsync( await txHashPromise, - pollingIntervalMs, - timeoutMs, + opts.pollingIntervalMs, + opts.timeoutMs, ); })(), ); @@ -1853,15 +1322,6 @@ export class ERC1155MintableContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, - async validateAndSendTransactionAsync( - type_: BigNumber, - to: string[], - txData?: Partial | undefined, - ): Promise { - await (this as any).mintNonFungible.callAsync(type_, to, txData); - const txHash = await (this as any).mintNonFungible.sendTransactionAsync(type_, to, txData); - return txHash; - }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1931,28 +1391,12 @@ export class ERC1155MintableContract extends BaseContract { return abiEncodedTransactionData; }, /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): [BigNumber, string[]] { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('mintNonFungible(uint256,address[])'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[BigNumber, string[]]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. + * Returns the 4 byte function selector as a hex string. */ - getABIDecodedReturnData(returnData: string): void { + getSelector(): string { const self = (this as any) as ERC1155MintableContract; const abiEncoder = self._lookupAbiEncoder('mintNonFungible(uint256,address[])'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; + return abiEncoder.getSelector(); }, }; /** @@ -2001,42 +1445,6 @@ export class ERC1155MintableContract extends BaseContract { // 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(id: BigNumber): string { - assert.isBigNumber('id', id); - const self = (this as any) as ERC1155MintableContract; - const abiEncodedTransactionData = self._strictEncodeArguments('ownerOf(uint256)', [id]); - return abiEncodedTransactionData; - }, - /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): BigNumber { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): string { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('ownerOf(uint256)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; - }, }; /** * MUST emit TransferBatch event on success. Caller must be approved to manage the _from account's tokens (see isApprovedForAll). MUST throw if `_to` is the zero address. MUST throw if length of `_ids` is not the same as length of `_values`. MUST throw if any of the balance of sender for token `_ids` is lower than the respective `_values` sent. MUST throw on any other error. When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). If so, it MUST call `onERC1155BatchReceived` on `_to` and revert if the return value is not `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`. @@ -2060,6 +1468,7 @@ export class ERC1155MintableContract extends BaseContract { values: BigNumber[], data: string, txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, ): Promise { assert.isString('from', from); assert.isString('to', to); @@ -2083,6 +1492,10 @@ export class ERC1155MintableContract extends BaseContract { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); } + if (opts.shouldValidate !== false) { + await self.safeBatchTransferFrom.callAsync(from, to, ids, values, data, txDataWithDefaults); + } + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); return txHash; }, @@ -2105,8 +1518,7 @@ export class ERC1155MintableContract extends BaseContract { values: BigNumber[], data: string, txData?: Partial, - pollingIntervalMs?: number, - timeoutMs?: number, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, ): PromiseWithTransactionHash { assert.isString('from', from); assert.isString('to', to); @@ -2121,6 +1533,7 @@ export class ERC1155MintableContract extends BaseContract { values, data, txData, + opts, ); return new PromiseWithTransactionHash( txHashPromise, @@ -2128,8 +1541,8 @@ export class ERC1155MintableContract extends BaseContract { // When the transaction hash resolves, wait for it to be mined. return self._web3Wrapper.awaitTransactionSuccessAsync( await txHashPromise, - pollingIntervalMs, - timeoutMs, + opts.pollingIntervalMs, + opts.timeoutMs, ); })(), ); @@ -2177,25 +1590,6 @@ export class ERC1155MintableContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, - async validateAndSendTransactionAsync( - from: string, - to: string, - ids: BigNumber[], - values: BigNumber[], - data: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).safeBatchTransferFrom.callAsync(from, to, ids, values, data, txData); - const txHash = await (this as any).safeBatchTransferFrom.sendTransactionAsync( - from, - to, - ids, - values, - data, - txData, - ); - return txHash; - }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -2291,34 +1685,14 @@ export class ERC1155MintableContract extends BaseContract { return abiEncodedTransactionData; }, /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. + * Returns the 4 byte function selector as a hex string. */ - getABIDecodedTransactionData(callData: string): [string, string, BigNumber[], BigNumber[], string] { + getSelector(): string { const self = (this as any) as ERC1155MintableContract; const abiEncoder = self._lookupAbiEncoder( 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', ); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[string, string, BigNumber[], BigNumber[], string]>( - callData, - ); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder( - 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)', - ); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; + return abiEncoder.getSelector(); }, }; /** @@ -2343,6 +1717,7 @@ export class ERC1155MintableContract extends BaseContract { value: BigNumber, data: string, txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, ): Promise { assert.isString('from', from); assert.isString('to', to); @@ -2369,6 +1744,10 @@ export class ERC1155MintableContract extends BaseContract { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); } + if (opts.shouldValidate !== false) { + await self.safeTransferFrom.callAsync(from, to, id, value, data, txDataWithDefaults); + } + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); return txHash; }, @@ -2391,8 +1770,7 @@ export class ERC1155MintableContract extends BaseContract { value: BigNumber, data: string, txData?: Partial, - pollingIntervalMs?: number, - timeoutMs?: number, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, ): PromiseWithTransactionHash { assert.isString('from', from); assert.isString('to', to); @@ -2407,6 +1785,7 @@ export class ERC1155MintableContract extends BaseContract { value, data, txData, + opts, ); return new PromiseWithTransactionHash( txHashPromise, @@ -2414,8 +1793,8 @@ export class ERC1155MintableContract extends BaseContract { // When the transaction hash resolves, wait for it to be mined. return self._web3Wrapper.awaitTransactionSuccessAsync( await txHashPromise, - pollingIntervalMs, - timeoutMs, + opts.pollingIntervalMs, + opts.timeoutMs, ); })(), ); @@ -2466,18 +1845,6 @@ export class ERC1155MintableContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, - async validateAndSendTransactionAsync( - from: string, - to: string, - id: BigNumber, - value: BigNumber, - data: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).safeTransferFrom.callAsync(from, to, id, value, data, txData); - const txHash = await (this as any).safeTransferFrom.sendTransactionAsync(from, to, id, value, data, txData); - return txHash; - }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -2568,30 +1935,12 @@ export class ERC1155MintableContract extends BaseContract { return abiEncodedTransactionData; }, /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. - */ - getABIDecodedTransactionData(callData: string): [string, string, BigNumber, BigNumber, string] { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,uint256,bytes)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[string, string, BigNumber, BigNumber, string]>( - callData, - ); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. + * Returns the 4 byte function selector as a hex string. */ - getABIDecodedReturnData(returnData: string): void { + getSelector(): string { const self = (this as any) as ERC1155MintableContract; const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,uint256,bytes)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; + return abiEncoder.getSelector(); }, }; /** @@ -2610,6 +1959,7 @@ export class ERC1155MintableContract extends BaseContract { operator: string, approved: boolean, txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, ): Promise { assert.isString('operator', operator); assert.isBoolean('approved', approved); @@ -2630,6 +1980,10 @@ export class ERC1155MintableContract extends BaseContract { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); } + if (opts.shouldValidate !== false) { + await self.setApprovalForAll.callAsync(operator, approved, txDataWithDefaults); + } + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); return txHash; }, @@ -2646,21 +2000,25 @@ export class ERC1155MintableContract extends BaseContract { operator: string, approved: boolean, txData?: Partial, - pollingIntervalMs?: number, - timeoutMs?: number, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, ): PromiseWithTransactionHash { assert.isString('operator', operator); assert.isBoolean('approved', approved); const self = (this as any) as ERC1155MintableContract; - const txHashPromise = self.setApprovalForAll.sendTransactionAsync(operator.toLowerCase(), approved, txData); + const txHashPromise = self.setApprovalForAll.sendTransactionAsync( + operator.toLowerCase(), + approved, + txData, + opts, + ); return new PromiseWithTransactionHash( txHashPromise, (async (): Promise => { // When the transaction hash resolves, wait for it to be mined. return self._web3Wrapper.awaitTransactionSuccessAsync( await txHashPromise, - pollingIntervalMs, - timeoutMs, + opts.pollingIntervalMs, + opts.timeoutMs, ); })(), ); @@ -2699,15 +2057,6 @@ export class ERC1155MintableContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, - async validateAndSendTransactionAsync( - operator: string, - approved: boolean, - txData?: Partial | undefined, - ): Promise { - await (this as any).setApprovalForAll.callAsync(operator, approved, txData); - const txHash = await (this as any).setApprovalForAll.sendTransactionAsync(operator, approved, txData); - return txHash; - }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -2780,28 +2129,12 @@ export class ERC1155MintableContract extends BaseContract { return abiEncodedTransactionData; }, /** - * Decode the ABI-encoded transaction data into its input arguments - * @param callData The ABI-encoded transaction data - * @returns An array representing the input arguments in order. Keynames of nested structs are preserved. + * Returns the 4 byte function selector as a hex string. */ - getABIDecodedTransactionData(callData: string): [string, boolean] { + getSelector(): string { const self = (this as any) as ERC1155MintableContract; const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<[string, boolean]>(callData); - return abiDecodedCallData; - }, - /** - * Decode the ABI-encoded return data from a transaction - * @param returnData the data returned after transaction execution - * @returns An array representing the output results in order. Keynames of nested structs are preserved. - */ - getABIDecodedReturnData(returnData: string): void { - const self = (this as any) as ERC1155MintableContract; - const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); - return abiDecodedReturnData; + return abiEncoder.getSelector(); }, }; private readonly _subscriptionManager: SubscriptionManager; diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts index a3a2bf881e..d5c947103f 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts @@ -208,6 +208,14 @@ export class ERC1155ProxyContract extends BaseContract { ]); 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 = { /** @@ -583,6 +591,14 @@ export class ERC1155ProxyContract extends BaseContract { ]); 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. @@ -769,6 +785,14 @@ export class ERC1155ProxyContract extends BaseContract { ); 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. @@ -1001,6 +1025,14 @@ export class ERC1155ProxyContract extends BaseContract { ); 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 = { /** @@ -1143,6 +1175,14 @@ export class ERC1155ProxyContract extends BaseContract { ]); 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( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts index 95cd7444b4..5608cbf8e0 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts @@ -208,6 +208,14 @@ export class ERC20ProxyContract extends BaseContract { ]); 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 = { /** @@ -406,6 +414,14 @@ export class ERC20ProxyContract extends BaseContract { ]); 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 = { /** @@ -635,6 +651,14 @@ export class ERC20ProxyContract extends BaseContract { ); 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. @@ -911,6 +935,14 @@ export class ERC20ProxyContract extends BaseContract { ]); 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( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts index f8b8109085..df2b061a3a 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts @@ -239,6 +239,14 @@ export class ERC20TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + return abiEncoder.getSelector(); + }, }; /** * Query total supply of token @@ -492,6 +500,14 @@ export class ERC20TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + return abiEncoder.getSelector(); + }, }; /** * Query the balance of owner @@ -714,6 +730,14 @@ export class ERC20TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ERC20TokenContract; + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + return abiEncoder.getSelector(); + }, }; public allowance = { /** diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts index d80cd4dd1e..7b84ca85b7 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts @@ -208,6 +208,14 @@ export class ERC721ProxyContract extends BaseContract { ]); 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 = { /** @@ -406,6 +414,14 @@ export class ERC721ProxyContract extends BaseContract { ]); 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 = { /** @@ -635,6 +651,14 @@ export class ERC721ProxyContract extends BaseContract { ); 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. @@ -911,6 +935,14 @@ export class ERC721ProxyContract extends BaseContract { ]); 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( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts index dcb5db41f3..00ee288b74 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts @@ -250,6 +250,14 @@ export class ERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + return abiEncoder.getSelector(); + }, }; /** * NFTs assigned to the zero address are considered invalid, and this @@ -673,6 +681,14 @@ export class ERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)'); + return abiEncoder.getSelector(); + }, }; /** * Throws unless `msg.sender` is the current owner, an authorized @@ -901,6 +917,14 @@ export class ERC721TokenContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)'); + return abiEncoder.getSelector(); + }, }; /** * Emits the ApprovalForAll event. The contract MUST allow @@ -1088,6 +1112,14 @@ export class ERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)'); + return abiEncoder.getSelector(); + }, }; /** * Throws unless `msg.sender` is the current owner, an authorized @@ -1296,6 +1328,14 @@ export class ERC721TokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ERC721TokenContract; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + return abiEncoder.getSelector(); + }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts index a168c3df1e..bb4329eef8 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts @@ -501,6 +501,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'batchCancelOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Executes a batch of Exchange method calls in the context of signer(s). @@ -728,6 +738,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'batchExecuteTransactions((uint256,uint256,uint256,address,bytes)[],bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Executes multiple calls of fillOrKillOrder. @@ -1037,6 +1057,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'batchFillOrKillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Executes multiple calls of fillOrder. @@ -1341,6 +1371,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Executes multiple calls of fillOrder. If any fill reverts, the error is caught and ignored. @@ -1650,6 +1690,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'batchFillOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Match complementary orders that have a profitable spread. @@ -2076,6 +2126,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'batchMatchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Match complementary orders that have a profitable spread. @@ -2503,6 +2563,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'batchMatchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * After calling, the order can not be filled anymore. @@ -2742,6 +2812,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'cancelOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes))', + ); + return abiEncoder.getSelector(); + }, }; /** * Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch @@ -2902,6 +2982,14 @@ export class ExchangeContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder('cancelOrdersUpTo(uint256)'); + return abiEncoder.getSelector(); + }, }; public cancelled = { /** @@ -3205,6 +3293,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'executeTransaction((uint256,uint256,uint256,address,bytes),bytes)', + ); + return abiEncoder.getSelector(); + }, }; /** * Fills the input order. Reverts if exact takerAssetFillAmount not filled. @@ -3494,6 +3592,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'fillOrKillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + ); + return abiEncoder.getSelector(); + }, }; /** * Fills the input order. @@ -3784,6 +3892,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes)', + ); + return abiEncoder.getSelector(); + }, }; public filled = { /** @@ -4466,6 +4584,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'marketBuyOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Executes multiple calls of fillOrder until total amount of makerAsset is bought by taker. @@ -4768,6 +4896,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'marketBuyOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Calls marketSellOrdersNoThrow then reverts if < takerAssetFillAmount has been sold. @@ -5069,6 +5207,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'marketSellOrdersFillOrKill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. @@ -5371,6 +5519,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'marketSellOrdersNoThrow((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[])', + ); + return abiEncoder.getSelector(); + }, }; /** * Match two complementary orders that have a profitable spread. @@ -5778,6 +5936,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + ); + return abiEncoder.getSelector(); + }, }; /** * Match two complementary orders that have a profitable spread. @@ -6185,6 +6353,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'matchOrdersWithMaximalFill((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),bytes,bytes)', + ); + return abiEncoder.getSelector(); + }, }; public orderEpoch = { /** @@ -6430,6 +6608,14 @@ export class ExchangeContract extends BaseContract { const abiEncodedTransactionData = self._strictEncodeArguments('preSign(bytes32)', [hash]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder('preSign(bytes32)'); + return abiEncoder.getSelector(); + }, }; public preSigned = { /** @@ -6724,6 +6910,14 @@ export class ExchangeContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder('registerAssetProxy(address)'); + return abiEncoder.getSelector(); + }, }; /** * Allows the owner to update the protocolFeeCollector address. @@ -6896,6 +7090,14 @@ export class ExchangeContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder('setProtocolFeeCollectorAddress(address)'); + return abiEncoder.getSelector(); + }, }; /** * Allows the owner to update the protocol fee multiplier. @@ -7063,6 +7265,14 @@ export class ExchangeContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder('setProtocolFeeMultiplier(uint256)'); + return abiEncoder.getSelector(); + }, }; /** * Approves/unnapproves a Validator contract to verify signatures on signer's behalf @@ -7250,6 +7460,14 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder('setSignatureValidatorApproval(address,bool)'); + return abiEncoder.getSelector(); + }, }; /** * This function may be used to simulate any amount of transfers As they would occur through the Exchange contract. Note that this function will always revert, even if all transfers are successful. However, it may be used with eth_call or with a try/catch pattern in order to simulate the results of the transfers. @@ -7500,6 +7718,16 @@ export class ExchangeContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder( + 'simulateDispatchTransferFromCalls(bytes[],address[],address[],uint256[])', + ); + return abiEncoder.getSelector(); + }, }; public transactionsExecuted = { /** @@ -7690,6 +7918,14 @@ export class ExchangeContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ExchangeContract; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + return abiEncoder.getSelector(); + }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts index ed11ba7808..fd921962fc 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts @@ -189,6 +189,14 @@ export class ForwarderContract extends BaseContract { const abiEncodedTransactionData = self._strictEncodeArguments('approveMakerAssetProxy(bytes)', [assetData]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ForwarderContract; + const abiEncoder = self._lookupAbiEncoder('approveMakerAssetProxy(bytes)'); + return abiEncoder.getSelector(); + }, }; /** * Attempt to buy makerAssetBuyAmount of makerAsset by selling ETH provided with transaction. @@ -524,6 +532,16 @@ export class ForwarderContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ForwarderContract; + const abiEncoder = self._lookupAbiEncoder( + 'marketBuyOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256,bytes[],uint256,address)', + ); + return abiEncoder.getSelector(); + }, }; /** * Purchases as much of orders' makerAssets as possible by selling as much of the ETH value sent @@ -840,6 +858,16 @@ export class ForwarderContract extends BaseContract { ); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ForwarderContract; + const abiEncoder = self._lookupAbiEncoder( + 'marketSellOrdersWithEth((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],bytes[],uint256,address)', + ); + return abiEncoder.getSelector(); + }, }; public owner = { /** @@ -1025,6 +1053,14 @@ export class ForwarderContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ForwarderContract; + const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)'); + return abiEncoder.getSelector(); + }, }; /** * Withdraws assets from this contract. The contract formerly required a ZRX balance in order @@ -1199,6 +1235,14 @@ export class ForwarderContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ForwarderContract; + const abiEncoder = self._lookupAbiEncoder('withdrawAsset(bytes,uint256)'); + return abiEncoder.getSelector(); + }, }; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts index 0383c018a4..1862f8c11a 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts @@ -259,6 +259,14 @@ export class IAssetProxyContract extends BaseContract { ); 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. diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts index 857ddaecc9..752c5eba6e 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts @@ -259,6 +259,14 @@ export class MultiAssetProxyContract extends BaseContract { ]); 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 = { /** @@ -510,6 +518,14 @@ export class MultiAssetProxyContract extends BaseContract { ]); 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 = { /** @@ -739,6 +755,14 @@ export class MultiAssetProxyContract extends BaseContract { ); 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. @@ -981,6 +1005,14 @@ export class MultiAssetProxyContract extends BaseContract { ]); 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. @@ -1170,6 +1202,14 @@ export class MultiAssetProxyContract extends BaseContract { ]); 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( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts index 3d5c5cbf14..ee4032ab99 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts @@ -271,6 +271,14 @@ export class WETH9Contract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as WETH9Contract; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + return abiEncoder.getSelector(); + }, }; public totalSupply = { /** @@ -501,6 +509,14 @@ export class WETH9Contract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as WETH9Contract; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + return abiEncoder.getSelector(); + }, }; public withdraw = { /** @@ -641,6 +657,14 @@ export class WETH9Contract extends BaseContract { const abiEncodedTransactionData = self._strictEncodeArguments('withdraw(uint256)', [wad]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as WETH9Contract; + const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); + return abiEncoder.getSelector(); + }, }; public decimals = { /** @@ -930,6 +954,14 @@ export class WETH9Contract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as WETH9Contract; + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + return abiEncoder.getSelector(); + }, }; public deposit = { /** @@ -1063,6 +1095,14 @@ export class WETH9Contract extends BaseContract { const abiEncodedTransactionData = self._strictEncodeArguments('deposit()', []); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as WETH9Contract; + const abiEncoder = self._lookupAbiEncoder('deposit()'); + return abiEncoder.getSelector(); + }, }; public allowance = { /** diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts index 3586560204..811787ec7b 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts @@ -268,6 +268,14 @@ export class ZRXTokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ZRXTokenContract; + const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); + return abiEncoder.getSelector(); + }, }; public totalSupply = { /** @@ -517,6 +525,14 @@ export class ZRXTokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ZRXTokenContract; + const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); + return abiEncoder.getSelector(); + }, }; public decimals = { /** @@ -806,6 +822,14 @@ export class ZRXTokenContract extends BaseContract { ]); return abiEncodedTransactionData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as ZRXTokenContract; + const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); + return abiEncoder.getSelector(); + }, }; public allowance = { /** diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index de66262620..73b8d81211 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "4.4.0-beta.0", + "changes": [ + { + "note": "Add `getSelector` method to all functions", + "pr": 2224 + } + ] + }, { "version": "4.3.0-beta.0", "changes": [ diff --git a/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars b/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars index 9fee7996f7..64780645ea 100644 --- a/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars +++ b/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars @@ -1,4 +1,4 @@ -{{!-- if ((NOT constant) AND (NOT debug)), to avoid repetition bbecause we use all 3 functions if (debug) --}} +{{!-- if ((NOT constant) AND (NOT debug)), to avoid repetition bbecause we use all 4 functions if (debug) --}} {{^if constant~}} {{^if debug~}} /** @@ -18,6 +18,14 @@ getABIEncodedTransactionData( const abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); return abiEncodedTransactionData; }, +/** + * Returns the 4 byte function selector as a hex string. + */ +getSelector(): string { + const self = this as any as {{contractName}}Contract; + const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); + return abiEncoder.getSelector(); +} {{/if~}} {{/if~}} @@ -67,4 +75,12 @@ getABIDecodedReturnData( const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(returnData); return abiDecodedReturnData; }, +/** + * Returns the 4 byte function selector as a hex string. + */ +getSelector(): string { + const self = this as any as {{contractName}}Contract; + const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); + return abiEncoder.getSelector(); +} {{/if}} diff --git a/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts b/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts index 702c55dec0..816a927f33 100644 --- a/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts @@ -126,6 +126,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('simpleRequire()'); + return abiEncoder.getSelector(); + }, }; /** * a method that accepts an array of bytes @@ -203,6 +211,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('acceptsAnArrayOfBytes(bytes[])'); + return abiEncoder.getSelector(); + }, }; /** * Tests decoding when both input and output are non-empty. @@ -284,6 +300,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('simpleInputSimpleOutput(uint256)'); + return abiEncoder.getSelector(); + }, }; public withdraw = { /** @@ -448,6 +472,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)'); + return abiEncoder.getSelector(); + }, }; /** * Tests decoding when the input and output are complex and have more than one argument. @@ -540,6 +572,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<[string, string, string]>(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('multiInputMultiOutput(uint256,bytes,string)'); + return abiEncoder.getSelector(); + }, }; /** * test that devdocs will be generated and @@ -650,6 +690,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('ecrecoverFn(bytes32,uint8,bytes32,bytes32)'); + return abiEncoder.getSelector(); + }, }; public acceptsBytes = { /** @@ -722,6 +770,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('acceptsBytes(bytes)'); + return abiEncoder.getSelector(); + }, }; /** * Tests decoding when input is empty and output is non-empty. @@ -795,6 +851,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('noInputSimpleOutput()'); + return abiEncoder.getSelector(); + }, }; public revertWithConstant = { /** @@ -865,6 +929,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('revertWithConstant()'); + return abiEncoder.getSelector(); + }, }; public simpleRevert = { /** @@ -935,6 +1007,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('simpleRevert()'); + return abiEncoder.getSelector(); + }, }; public methodUsingNestedStructWithInnerStructNotUsedElsewhere = { /** @@ -1016,6 +1096,14 @@ export class AbiGenDummyContract extends BaseContract { ); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('methodUsingNestedStructWithInnerStructNotUsedElsewhere()'); + return abiEncoder.getSelector(); + }, }; public nestedStructOutput = { /** @@ -1103,6 +1191,14 @@ export class AbiGenDummyContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('nestedStructOutput()'); + return abiEncoder.getSelector(); + }, }; public requireWithConstant = { /** @@ -1173,6 +1269,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('requireWithConstant()'); + return abiEncoder.getSelector(); + }, }; public withAddressInput = { /** @@ -1267,6 +1371,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('withAddressInput(address,uint256,uint256,address,uint256)'); + return abiEncoder.getSelector(); + }, }; public structInput = { /** @@ -1353,6 +1465,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('structInput((bytes,uint32,bytes[],string))'); + return abiEncoder.getSelector(); + }, }; public nonPureMethod = { /** @@ -1510,6 +1630,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('nonPureMethod()'); + return abiEncoder.getSelector(); + }, }; /** * Tests decoding when the input and output are complex. @@ -1609,6 +1737,14 @@ export class AbiGenDummyContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('complexInputComplexOutput((uint256,bytes,string))'); + return abiEncoder.getSelector(); + }, }; /** * Tests decoding when both input and output are empty. @@ -1682,6 +1818,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('noInputNoOutput()'); + return abiEncoder.getSelector(); + }, }; public simplePureFunctionWithInput = { /** @@ -1754,6 +1898,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('simplePureFunctionWithInput(uint256)'); + return abiEncoder.getSelector(); + }, }; public nonPureMethodThatReturnsNothing = { /** @@ -1911,6 +2063,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('nonPureMethodThatReturnsNothing()'); + return abiEncoder.getSelector(); + }, }; public simplePureFunction = { /** @@ -1981,6 +2141,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('simplePureFunction()'); + return abiEncoder.getSelector(); + }, }; public nestedStructInput = { /** @@ -2096,6 +2264,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('nestedStructInput(((bytes,uint32,bytes[],string),string))'); + return abiEncoder.getSelector(); + }, }; public methodReturningMultipleValues = { /** @@ -2166,6 +2342,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<[BigNumber, string]>(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('methodReturningMultipleValues()'); + return abiEncoder.getSelector(); + }, }; public methodReturningArrayOfStructs = { /** @@ -2245,6 +2429,14 @@ export class AbiGenDummyContract extends BaseContract { >(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('methodReturningArrayOfStructs()'); + return abiEncoder.getSelector(); + }, }; public emitSimpleEvent = { /** @@ -2402,6 +2594,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('emitSimpleEvent()'); + return abiEncoder.getSelector(); + }, }; /** * a method that returns a struct @@ -2491,6 +2691,14 @@ export class AbiGenDummyContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('structOutput()'); + return abiEncoder.getSelector(); + }, }; public pureFunctionWithConstant = { /** @@ -2561,6 +2769,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('pureFunctionWithConstant()'); + return abiEncoder.getSelector(); + }, }; /** * Tests decoding when input is not empty but output is empty. @@ -2640,6 +2856,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('simpleInputNoOutput(uint256)'); + return abiEncoder.getSelector(); + }, }; public overloadedMethod2 = { /** @@ -2712,6 +2936,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('overloadedMethod(string)'); + return abiEncoder.getSelector(); + }, }; public overloadedMethod1 = { /** @@ -2784,6 +3016,14 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as AbiGenDummyContract; + const abiEncoder = self._lookupAbiEncoder('overloadedMethod(int256)'); + return abiEncoder.getSelector(); + }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts b/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts index 61e5cbe2ef..0af33346f0 100644 --- a/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts @@ -110,6 +110,14 @@ export class TestLibDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as TestLibDummyContract; + const abiEncoder = self._lookupAbiEncoder('publicAddConstant(uint256)'); + return abiEncoder.getSelector(); + }, }; public publicAddOne = { /** @@ -182,6 +190,14 @@ export class TestLibDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, + /** + * Returns the 4 byte function selector as a hex string. + */ + getSelector(): string { + const self = (this as any) as TestLibDummyContract; + const abiEncoder = self._lookupAbiEncoder('publicAddOne(uint256)'); + return abiEncoder.getSelector(); + }, }; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, diff --git a/packages/contract-addresses/CHANGELOG.json b/packages/contract-addresses/CHANGELOG.json index 6292a31230..0450bcc83d 100644 --- a/packages/contract-addresses/CHANGELOG.json +++ b/packages/contract-addresses/CHANGELOG.json @@ -5,6 +5,14 @@ { "note": "Removed `getNetworkIdByExchangeAddressOrThrow`. It's not needed with V3 tooling.", "pr": 2170 + }, + { + "note": "Add `zrxVault`, `readOnlyProxy`, `staking`, and `stakingProxy` schema with addresses for each tesnet", + "pr": 2224 + }, + { + "note": "Update `assetProxyOwner` address for each testnet", + "pr": 2224 } ], "timestamp": 1570135330 diff --git a/packages/contract-addresses/src/index.ts b/packages/contract-addresses/src/index.ts index 3e66e46fe9..a80bc70cbc 100644 --- a/packages/contract-addresses/src/index.ts +++ b/packages/contract-addresses/src/index.ts @@ -5,6 +5,7 @@ export interface ContractAddresses { erc721Proxy: string; zrxToken: string; etherToken: string; + exchangeV2: string; exchange: string; assetProxyOwner: string; forwarder: string; @@ -16,6 +17,10 @@ export interface ContractAddresses { staticCallProxy: string; erc1155Proxy: string; devUtils: string; + zrxVault: string; + readOnlyProxy: string; + staking: string; + stakingProxy: string; } export enum NetworkId { @@ -30,6 +35,7 @@ const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'; const networkToAddresses: { [networkId: number]: ContractAddresses } = { 1: { + exchangeV2: '0x080bf510fcbf18b91105470639e9561022937712', exchange: NULL_ADDRESS, erc20Proxy: '0x95e6f48254609a6ee006f7d493c8e5fb97094cef', erc721Proxy: '0xefc70a1b18c432bdc64b596838b4d138f6bc6cad', @@ -44,6 +50,10 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = { multiAssetProxy: '0xef701d5389ae74503d633396c4d654eabedc9d78', staticCallProxy: '0x3517b88c19508c08650616019062b898ab65ed29', erc1155Proxy: '0x7eefbd48fd63d441ec7435d024ec7c5131019add', + zrxVault: NULL_ADDRESS, + readOnlyProxy: NULL_ADDRESS, + staking: NULL_ADDRESS, + stakingProxy: NULL_ADDRESS, devUtils: NULL_ADDRESS, }, 3: { @@ -51,6 +61,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = { erc721Proxy: '0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4', zrxToken: '0xff67881f8d12f372d91baae9752eb3631ff0ed00', etherToken: '0xc778417e063141139fce010982780140aa0cd5ab', + exchangeV2: '0xbff9493f92a3df4b0429b6d00743b3cfb4c85831', exchange: '0x725bc2f8c85ed0289d3da79cde3125d33fc1d7e6', assetProxyOwner: '0xdcf20f7b447d51f2b3e5499b7f6cbbf7295a5d26', forwarder: '0x31c3890769ed3bb30b2781fd238a5bb7ecfeb7c8', @@ -62,8 +73,13 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = { staticCallProxy: '0xe1b97e47aa3796276033a5341e884d2ba46b6ac1', erc1155Proxy: '0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d', devUtils: '0x3dfd5157eec10eb1a357c1074de30787ce92cb43', + zrxVault: '0xffd161026865ad8b4ab28a76840474935eec4dfa', + readOnlyProxy: '0x8e1dfaf747b804d041adaed79d68dcef85b8de85', + staking: '0xb2ca5824630e526f0f3181a4ea0447c795a84411', + stakingProxy: '0x5d751aa855a1aee5fe44cf5350ed25b5727b66ae', }, 4: { + exchangeV2: '0xbff9493f92a3df4b0429b6d00743b3cfb4c85831', exchange: '0x8e1dfaf747b804d041adaed79d68dcef85b8de85', erc20Proxy: '0x2f5ae4f6106e89b4147651688a92256885c5f410', erc721Proxy: '0x7656d773e11ff7383a14dcf09a9c50990481cd10', @@ -79,12 +95,17 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = { staticCallProxy: '0xe1b97e47aa3796276033a5341e884d2ba46b6ac1', erc1155Proxy: '0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d', devUtils: '0xcfc66b8e75e8f075c3e1d61e6487d73dfe35d808', + zrxVault: '0xa5bf6ac73bc40790fc6ffc9dbbbce76c9176e224', + readOnlyProxy: '0xffd161026865ad8b4ab28a76840474935eec4dfa', + staking: '0x8ec5a989a06432dace637c8d592727627a45a592', + stakingProxy: '0xb2ca5824630e526f0f3181a4ea0447c795a84411', }, 42: { erc20Proxy: '0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e', erc721Proxy: '0x2a9127c745688a165106c11cd4d647d2220af821', zrxToken: '0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa', etherToken: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + exchangeV2: '0x30589010550762d2f0d06f650d8e8b6ade6dbf4b', exchange: '0x617602cd3f734cf1e028c96b3f54c0489bed8022', assetProxyOwner: '0x3654e5363cd75c8974c76208137df9691e820e97', forwarder: '0x4c4edb103a6570fa4b58a309d7ff527b7d9f7cf2', @@ -96,6 +117,10 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = { staticCallProxy: '0x48e94bdb9033640d45ea7c721e25f380f8bffa43', erc1155Proxy: '0x64517fa2b480ba3678a2a3c0cf08ef7fd4fad36f', devUtils: '0xb1863ac46ae23ec55d6eeb8ecc8815655ee638a8', + zrxVault: '0xf36eabdfe986b35b62c8fd5a98a7f2aebb79b291', + readOnlyProxy: '0x25397d8aa7e6844dae70ee658fe072d45d6cf528', + staking: '0xd67f2f346f6e85db70632d9f18f50e04192ab54d', + stakingProxy: '0x9e7eef766702c3d9056a3de779e5d9d976bc3bdb', }, // NetworkId 50 represents our Ganache snapshot generated from migrations. 50: { @@ -104,6 +129,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = { erc1155Proxy: '0x6a4a62e5a7ed13c361b176a5f62c2ee620ac0df8', zrxToken: '0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c', etherToken: '0x0b1ba0af832d7c05fd64161e0db78e85978e8082', + exchangeV2: '0x48bacb9266a570d521063ef5dd96e61686dbe788', exchange: '0x48bacb9266a570d521063ef5dd96e61686dbe788', assetProxyOwner: NULL_ADDRESS, forwarder: NULL_ADDRESS, @@ -114,6 +140,10 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = { multiAssetProxy: '0xcfc18cec799fbd1793b5c43e773c98d4d61cc2db', staticCallProxy: '0x6dfff22588be9b3ef8cf0ad6dc9b84796f9fb45f', devUtils: '0x38ef19fdf8e8415f18c307ed71967e19aac28ba1', + zrxVault: NULL_ADDRESS, + readOnlyProxy: NULL_ADDRESS, + staking: NULL_ADDRESS, + stakingProxy: NULL_ADDRESS, }, }; diff --git a/packages/migrations/package.json b/packages/migrations/package.json index 548e739b20..873377b56e 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -55,6 +55,10 @@ "yargs": "^10.0.3" }, "dependencies": { + "@0x/contracts-multisig": "^3.2.0-beta.0", + "@0x/contracts-staking": "^1.1.0-beta.0", + "@0x/contracts-exchange": "^2.2.0-beta.0", + "@0x/contracts-utils": "^3.3.0-beta.0", "@0x/abi-gen-wrappers": "^5.4.0-beta.0", "@0x/base-contract": "^5.5.0-beta.0", "@0x/contract-addresses": "^3.3.0-beta.0", diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index 1b36128f20..994c8c2bd4 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -7,6 +7,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { MethodAbi, SupportedProvider, TxData } from 'ethereum-types'; import * as _ from 'lodash'; +import { constants } from './utils/constants'; import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info'; // HACK (xianny): Copied from @0x/order-utils to get rid of circular dependency @@ -142,58 +143,26 @@ export async function runMigrationsAsync( artifacts, ); - await web3Wrapper.awaitTransactionSuccessAsync( - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await erc1155Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await multiAssetProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, txDefaults), - ); + await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); + await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); + await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); + await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, txDefaults); // MultiAssetProxy - await web3Wrapper.awaitTransactionSuccessAsync( - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await erc1155Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc721Proxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc1155Proxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await multiAssetProxy.registerAssetProxy.sendTransactionAsync(staticCallProxy.address, txDefaults), - ); + await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); + await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); + await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); + await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, txDefaults); + await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, txDefaults); + await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, txDefaults); + await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address, txDefaults); // Register the Asset Proxies to the Exchange - await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(erc721Proxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(erc1155Proxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(multiAssetProxy.address, txDefaults), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(staticCallProxy.address, txDefaults), - ); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, txDefaults); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, txDefaults); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, txDefaults); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(multiAssetProxy.address, txDefaults); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(staticCallProxy.address, txDefaults); // Forwarder const forwarder = await wrappers.ForwarderContract.deployFrom0xArtifactAsync( @@ -270,9 +239,7 @@ export async function runMigrationsAsync( // Fund the Forwarder with ZRX const zrxDecimals = await zrxToken.decimals.callAsync(); const zrxForwarderAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(5000), zrxDecimals); - await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transfer.sendTransactionAsync(forwarder.address, zrxForwarderAmount, txDefaults), - ); + await zrxToken.transfer.awaitTransactionSuccessAsync(forwarder.address, zrxForwarderAmount, txDefaults); // CoordinatorRegistry const coordinatorRegistry = await wrappers.CoordinatorRegistryContract.deployFrom0xArtifactAsync( @@ -316,7 +283,7 @@ export async function runMigrationsAsync( etherToken: etherToken.address, exchange: exchange.address, // TODO (xianny): figure out how to deploy AssetProxyOwnerContract - assetProxyOwner: '0x0000000000000000000000000000000000000000', + assetProxyOwner: constants.NULL_ADDRESS, forwarder: forwarder.address, orderValidator: orderValidator.address, dutchAuction: dutchAuction.address, @@ -325,6 +292,11 @@ export async function runMigrationsAsync( multiAssetProxy: multiAssetProxy.address, staticCallProxy: staticCallProxy.address, devUtils: devUtils.address, + exchangeV2: constants.NULL_ADDRESS, + zrxVault: constants.NULL_ADDRESS, + readOnlyProxy: constants.NULL_ADDRESS, + staking: constants.NULL_ADDRESS, + stakingProxy: constants.NULL_ADDRESS, }; return contractAddresses; diff --git a/packages/migrations/src/test_contract_configs.ts b/packages/migrations/src/test_contract_configs.ts index 08ad3cfe4e..f22a601131 100644 --- a/packages/migrations/src/test_contract_configs.ts +++ b/packages/migrations/src/test_contract_configs.ts @@ -1,6 +1,8 @@ #!/usr/bin/env node import * as wrappers from '@0x/abi-gen-wrappers'; import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses'; +import { ExchangeContract } from '@0x/contracts-exchange'; +import { StakingContract, StakingProxyContract, ZrxVaultContract } from '@0x/contracts-staking'; import { EmptyWalletSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders'; import { AssetProxyId } from '@0x/types'; import { logUtils, providerUtils } from '@0x/utils'; @@ -8,13 +10,16 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { SupportedProvider } from 'ethereum-types'; // NOTE: add your own Infura Project ID to RPC urls before running +const INFURA_PROJECT_ID = ''; + const networkIdToRpcUrl = { - 1: 'https://mainnet.infura.io/v3/', - 3: 'https://ropsten.infura.io/v3/', - 4: 'https://rinkeby.infura.io/v3/', - 42: 'https://kovan.infura.io/v3/', + 1: `https://mainnet.infura.io/v3/${INFURA_PROJECT_ID}`, + 3: `https://ropsten.infura.io/v3/${INFURA_PROJECT_ID}`, + 4: `https://rinkeby.infura.io/v3/${INFURA_PROJECT_ID}`, + 42: `https://kovan.infura.io/v3/${INFURA_PROJECT_ID}`, }; +// tslint:disable:custom-no-magic-numbers async function testContractConfigsAsync(provider: SupportedProvider): Promise { const web3Wrapper = new Web3Wrapper(provider); const networkId = await web3Wrapper.getNetworkIdAsync(); @@ -26,140 +31,235 @@ async function testContractConfigsAsync(provider: SupportedProvider): Promise { + const exchangeOwner = await exchangeV2.owner.callAsync(); + warnIfMismatch(exchangeOwner, assetProxyOwner.address, 'Unexpected ExchangeV2 owner'); + + const registeredERC20Proxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.ERC20); + warnIfMismatch(registeredERC20Proxy, erc20Proxy.address, 'Unexpected ERC20Proxy registered in ExchangeV2'); + + const registeredERC721Proxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.ERC721); + warnIfMismatch(registeredERC721Proxy, erc721Proxy.address, 'Unexpected ERC721Proxy registered in ExchangeV2'); + + const registeredERC1155Proxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.ERC1155); + warnIfMismatch( + registeredERC1155Proxy, + erc1155Proxy.address, + 'Unexpected ERC1155Proxy registered in ExchangeV2', + ); + + const registeredMultiAssetProxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.MultiAsset); + warnIfMismatch( + registeredMultiAssetProxy, + multiAssetProxy.address, + 'Unexpected MultiAssetProxy registered in ExchangeV2', + ); + + const registeredStaticCallProxy = await exchangeV2.getAssetProxy.callAsync(AssetProxyId.StaticCall); + warnIfMismatch( + registeredStaticCallProxy, + addresses.staticCallProxy, + 'Unexpected StaticCallProxy registered in ExchangeV2', + ); + } + + async function verifyExchangeV3ConfigsAsync(): Promise { + const exchangeOwner = await exchange.owner.callAsync(); + warnIfMismatch(exchangeOwner, assetProxyOwner.address, 'Unexpected Exchange owner'); + + const registeredERC20Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC20); + warnIfMismatch(registeredERC20Proxy, erc20Proxy.address, 'Unexpected ERC20Proxy registered in Exchange'); + + const registeredERC721Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC721); + warnIfMismatch(registeredERC721Proxy, erc721Proxy.address, 'Unexpected ERC721Proxy registered in Exchange'); + + const registeredERC1155Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC1155); + warnIfMismatch(registeredERC1155Proxy, erc1155Proxy.address, 'Unexpected ERC1155Proxy registered in Exchange'); + + const registeredMultiAssetProxy = await exchange.getAssetProxy.callAsync(AssetProxyId.MultiAsset); + warnIfMismatch( + registeredMultiAssetProxy, + multiAssetProxy.address, + 'Unexpected MultiAssetProxy registered in Exchange', + ); + + const registeredStaticCallProxy = await exchange.getAssetProxy.callAsync(AssetProxyId.StaticCall); + warnIfMismatch( + registeredStaticCallProxy, + addresses.staticCallProxy, + 'Unexpected StaticCallProxy registered in Exchange', + ); + + const protocolFeeCollector = await exchange.protocolFeeCollector.callAsync(); + warnIfMismatch(protocolFeeCollector, addresses.stakingProxy, 'Unexpected StakingProxy attached to Exchange'); + + const protocolFeeMultiplier = await exchange.protocolFeeMultiplier.callAsync(); + warnIfMismatch(protocolFeeMultiplier.toString(), '150000', 'Unexpected protocolFeeMultiplier in Exchange'); + } + + async function verifyAssetProxyConfigsAsync(): Promise { + // Verify ERC20Proxy configs + const erc20ProxyOwner = await erc20Proxy.owner.callAsync(); + warnIfMismatch(erc20ProxyOwner, assetProxyOwner.address, 'Unexpected ERC20Proxy owner'); + + const erc20AuthorizedAddresses = await erc20Proxy.getAuthorizedAddresses.callAsync(); + warnIfMismatch(erc20AuthorizedAddresses.length, 4, 'Unexpected number of authorized addresses in ERC20Proxy'); + + const isExchangeV2AuthorizedInERC20Proxy = await erc20Proxy.authorized.callAsync(exchangeV2.address); + warnIfMismatch(isExchangeV2AuthorizedInERC20Proxy, true, 'ExchangeV2 not authorized in ERC20Proxy'); + + const isExchangeAuthorizedInERC20Proxy = await erc20Proxy.authorized.callAsync(exchange.address); + warnIfMismatch(isExchangeAuthorizedInERC20Proxy, true, 'Exchange not authorized in ERC20Proxy'); + + const isMAPAuthorizedInER20Proxy = await erc20Proxy.authorized.callAsync(multiAssetProxy.address); + warnIfMismatch(isMAPAuthorizedInER20Proxy, true, 'MultiAssetProxy not authorized in ERC20Proxy'); + + const isZrxVaultAuthorizedInER20Proxy = await erc20Proxy.authorized.callAsync(zrxVault.address); + warnIfMismatch(isZrxVaultAuthorizedInER20Proxy, true, 'ZrxVault not authorized in ERC20Proxy'); + + // Verify ERC721Proxy configs + const erc721ProxyOwner = await erc721Proxy.owner.callAsync(); + warnIfMismatch(erc721ProxyOwner, assetProxyOwner.address, 'Unexpected ERC721Proxy owner'); + + const erc721AuthorizedAddresses = await erc721Proxy.getAuthorizedAddresses.callAsync(); + warnIfMismatch(erc721AuthorizedAddresses.length, 3, 'Unexpected number of authorized addresses in ERC721Proxy'); + + const isExchangeV2AuthorizedInERC721Proxy = await erc721Proxy.authorized.callAsync(exchangeV2.address); + warnIfMismatch(isExchangeV2AuthorizedInERC721Proxy, true, 'ExchangeV2 not authorized in ERC721Proxy'); + + const isExchangeAuthorizedInERC721Proxy = await erc721Proxy.authorized.callAsync(exchange.address); + warnIfMismatch(isExchangeAuthorizedInERC721Proxy, true, 'Exchange not authorized in ERC721Proxy'); + + const isMAPAuthorizedInER721Proxy = await erc721Proxy.authorized.callAsync(multiAssetProxy.address); + warnIfMismatch(isMAPAuthorizedInER721Proxy, true, 'MultiAssetProxy not authorized in ERC721Proxy'); + + // Verify ERC1155Proxy configs + const erc1155ProxyOwner = await erc1155Proxy.owner.callAsync(); + warnIfMismatch(erc1155ProxyOwner, assetProxyOwner.address, 'Unexpected ERC1155Proxy owner'); + + const erc1155AuthorizedAddresses = await erc1155Proxy.getAuthorizedAddresses.callAsync(); + warnIfMismatch( + erc1155AuthorizedAddresses.length, + 3, + 'Unexpected number of authorized addresses in ERC1155Proxy', + ); + + const isExchangeV2AuthorizedInERC1155Proxy = await erc1155Proxy.authorized.callAsync(exchangeV2.address); + warnIfMismatch(isExchangeV2AuthorizedInERC1155Proxy, true, 'ExchangeV2 not authorized in ERC1155Proxy'); + + const isExchangeAuthorizedInERC1155Proxy = await erc1155Proxy.authorized.callAsync(exchange.address); + warnIfMismatch(isExchangeAuthorizedInERC1155Proxy, true, 'Exchange not authorized in ERC1155Proxy'); + + const isMAPAuthorizedInER1155Proxy = await erc1155Proxy.authorized.callAsync(multiAssetProxy.address); + warnIfMismatch(isMAPAuthorizedInER1155Proxy, true, 'MultiAssetProxy not authorized in ERC1155Proxy'); + + // Verify MultiAssetProxy configs + const multiAssetProxyOwner = await multiAssetProxy.owner.callAsync(); + warnIfMismatch(multiAssetProxyOwner, assetProxyOwner.address, 'Unexpected MultiAssetProxy owner'); + + const multiAssetProxyAuthorizedAddresses = await multiAssetProxy.getAuthorizedAddresses.callAsync(); + warnIfMismatch( + multiAssetProxyAuthorizedAddresses.length, + 2, + 'Unexpected number of authorized addresses in MultiAssetProxy', + ); + + const isExchangeV2AuthorizedInMultiAssetProxy = await multiAssetProxy.authorized.callAsync(exchangeV2.address); + warnIfMismatch(isExchangeV2AuthorizedInMultiAssetProxy, true, 'ExchangeV2 not authorized in MultiAssetProxy'); + + const isExchangeAuthorizedInMultiAssetProxy = await multiAssetProxy.authorized.callAsync(exchange.address); + warnIfMismatch(isExchangeAuthorizedInMultiAssetProxy, true, 'Exchange not authorized in MultiAssetProxy'); + + const registeredERC20ProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC20); + warnIfMismatch( + registeredERC20ProxyInMAP, + erc20Proxy.address, + 'Unexpected ERC20Proxy registered in MultiAssetProxy', + ); + + const registeredERC721ProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC721); + warnIfMismatch( + registeredERC721ProxyInMAP, + erc721Proxy.address, + 'Unexpected ERC721Proxy registered in MultiAssetProxy', + ); + + const registeredERC1155ProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.ERC1155); + warnIfMismatch( + registeredERC1155ProxyInMAP, + erc1155Proxy.address, + 'Unexpected ERC1155Proxy registered in MultiAssetProxy', + ); + + const registeredStaticCallProxyInMAP = await multiAssetProxy.getAssetProxy.callAsync(AssetProxyId.StaticCall); + warnIfMismatch( + registeredStaticCallProxyInMAP, + addresses.staticCallProxy, + 'Unexpected StaticCallProxy registered in MultiAssetProxy', + ); + } + + async function verifyStakingConfigsAsync(): Promise { + const stakingLogicAddress = await stakingProxy.stakingContract.callAsync(); + warnIfMismatch(stakingLogicAddress, addresses.staking, 'Unexpected Staking contract attached to StakingProxy'); + + const readOnlyProxy = await stakingProxy.readOnlyProxy.callAsync(); + warnIfMismatch(readOnlyProxy, addresses.readOnlyProxy, 'Unexpected ReadOnlyProxy set in StakingProxy'); + + const readOnlyCallee = await stakingProxy.readOnlyProxyCallee.callAsync(); + warnIfMismatch(readOnlyCallee, addresses.staking, 'Unexpected readOnlyProxyCallee'); + + const zrxVaultAddress = await stakingContract.getZrxVault.callAsync(); + warnIfMismatch(zrxVaultAddress, addresses.zrxVault, 'Unexpected ZrxVault set in Staking contract'); + + const wethAddress = await stakingContract.getWethContract.callAsync(); + warnIfMismatch(wethAddress, addresses.etherToken, 'Unexpected WETH contract set in Staking contract'); + + const stakingProxyOwner = await stakingProxy.owner.callAsync(); + warnIfMismatch(stakingProxyOwner, addresses.assetProxyOwner, 'Unexpected StakingProxy owner'); + + const zrxVaultOwner = await zrxVault.owner.callAsync(); + warnIfMismatch(zrxVaultOwner, addresses.assetProxyOwner, 'Unexpected ZrxVault owner'); + + const stakingProxyAuthorizedAddresses = await stakingProxy.getAuthorizedAddresses.callAsync(); + warnIfMismatch( + stakingProxyAuthorizedAddresses.length, + 1, + 'Unexpected number of authorized addresses in StakingProxy', + ); + const isAssetProxyOwnerAuthorizedInStakingProxy = await stakingProxy.authorized.callAsync( + addresses.assetProxyOwner, + ); + warnIfMismatch( + isAssetProxyOwnerAuthorizedInStakingProxy, + true, + 'AssetProxyOwner not authorized in StakingProxy', + ); + + const zrxVaultAuthorizedAddresses = await zrxVault.getAuthorizedAddresses.callAsync(); + warnIfMismatch(zrxVaultAuthorizedAddresses.length, 1, 'Unexpected number of authorized addresses in ZrxVault'); + const isAssetProxyOwnerAuthorizedInZrxVault = await zrxVault.authorized.callAsync(addresses.assetProxyOwner); + warnIfMismatch(isAssetProxyOwnerAuthorizedInZrxVault, true, 'AssetProxyOwner not authorized in ZrxVault'); + } + + // TODO: implement AssetProxyOwner config tests + // async function verifyAssetProxyOwnerConfigsAsync(): Promise {} - // Verify Exchange configs - const exchangeOwner = await exchange.owner.callAsync(); - warnIfMismatch(exchangeOwner, assetProxyOwner.address, 'Unexpected Exchange owner'); - - const registeredERC20Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC20); - warnIfMismatch(registeredERC20Proxy, erc20Proxy.address, 'Unexpected ERC20Proxy registered in Exchange'); - - const registeredERC721Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC721); - warnIfMismatch(registeredERC721Proxy, erc721Proxy.address, 'Unexpected ERC721Proxy registered in Exchange'); - - const registeredERC1155Proxy = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC1155); - warnIfMismatch(registeredERC1155Proxy, erc1155Proxy.address, 'Unexpected ERC1155Proxy registered in Exchange'); - - const registeredMultiAssetProxy = await exchange.getAssetProxy.callAsync(AssetProxyId.MultiAsset); - warnIfMismatch( - registeredMultiAssetProxy, - multiAssetProxy.address, - 'Unexpected MultiAssetProxy registered in Exchange', - ); - - const registeredStaticCallProxy = await exchange.getAssetProxy.callAsync(AssetProxyId.StaticCall); - warnIfMismatch( - registeredStaticCallProxy, - addresses.staticCallProxy, - 'Unexpected StaticCallProxy registered in Exchange', - ); - - // Verify ERC20Proxy configs - const erc20ProxyOwner = await erc20Proxy.owner.callAsync(); - warnIfMismatch(erc20ProxyOwner, assetProxyOwner.address, 'Unexpected ERC20Proxy owner'); - - const erc20AuthorizedAddresses = await erc20Proxy.getAuthorizedAddresses.callAsync(); - warnIfMismatch(erc20AuthorizedAddresses.length, 2, 'Unexpected number of authorized addresses in ERC20Proxy'); - - const isExchangeAuthorizedInERC20Proxy = await erc20Proxy.authorized.callAsync(exchange.address); - warnIfMismatch(isExchangeAuthorizedInERC20Proxy, true, 'Exchange not authorized in ERC20Proxy'); - - const isMAPAuthorizedInER20Proxy = await erc20Proxy.authorized.callAsync(multiAssetProxy.address); - warnIfMismatch(isMAPAuthorizedInER20Proxy, true, 'MultiAssetProxy not authorized in ERC20Proxy'); - - // Verify ERC721Proxy configs - const erc721ProxyOwner = await erc721Proxy.owner.callAsync(); - warnIfMismatch(erc721ProxyOwner, assetProxyOwner.address, 'Unexpected ERC721Proxy owner'); - - const erc721AuthorizedAddresses = await erc721Proxy.getAuthorizedAddresses.callAsync(); - warnIfMismatch(erc721AuthorizedAddresses.length, 2, 'Unexpected number of authorized addresses in ERC721Proxy'); - - const isExchangeAuthorizedInERC721Proxy = await erc721Proxy.authorized.callAsync(exchange.address); - warnIfMismatch(isExchangeAuthorizedInERC721Proxy, true, 'Exchange not authorized in ERC721Proxy'); - - const isMAPAuthorizedInER721Proxy = await erc721Proxy.authorized.callAsync(multiAssetProxy.address); - warnIfMismatch(isMAPAuthorizedInER721Proxy, true, 'MultiAssetProxy not authorized in ERC721Proxy'); - - // Verify ERC1155Proxy configs - const erc1155ProxyOwner = await erc1155Proxy.owner.callAsync(); - warnIfMismatch(erc1155ProxyOwner, assetProxyOwner.address, 'Unexpected ERC1155Proxy owner'); - - const erc1155AuthorizedAddresses = await erc1155Proxy.getAuthorizedAddresses.callAsync(); - warnIfMismatch(erc1155AuthorizedAddresses.length, 2, 'Unexpected number of authorized addresses in ERC1155Proxy'); - - const isExchangeAuthorizedInERC1155Proxy = await erc1155Proxy.authorized.callAsync(exchange.address); - warnIfMismatch(isExchangeAuthorizedInERC1155Proxy, true, 'Exchange not authorized in ERC1155Proxy'); - - const isMAPAuthorizedInER1155Proxy = await erc1155Proxy.authorized.callAsync(multiAssetProxy.address); - warnIfMismatch(isMAPAuthorizedInER1155Proxy, true, 'MultiAssetProxy not authorized in ERC1155Proxy'); - - // Verify MultiAssetProxy configs - const multiAssetProxyOwner = await multiAssetProxy.owner.callAsync(); - warnIfMismatch(multiAssetProxyOwner, assetProxyOwner.address, 'Unexpected MultiAssetProxy owner'); - - const multiAssetProxyAuthorizedAddresses = await multiAssetProxy.getAuthorizedAddresses.callAsync(); - warnIfMismatch( - multiAssetProxyAuthorizedAddresses.length, - 1, - 'Unexpected number of authorized addresses in MultiAssetProxy', - ); - - const isExchangeAuthorizedInMultiAssetProxy = await multiAssetProxy.authorized.callAsync(exchange.address); - warnIfMismatch(isExchangeAuthorizedInMultiAssetProxy, true, 'Exchange not authorized in MultiAssetProxy'); - - const registeredERC20ProxyInMAP = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC20); - warnIfMismatch( - registeredERC20ProxyInMAP, - erc20Proxy.address, - 'Unexpected ERC20Proxy registered in MultiAssetProxy', - ); - - const registeredERC721ProxyInMAP = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC721); - warnIfMismatch( - registeredERC721ProxyInMAP, - erc721Proxy.address, - 'Unexpected ERC721Proxy registered in MultiAssetProxy', - ); - - const registeredERC1155ProxyInMAP = await exchange.getAssetProxy.callAsync(AssetProxyId.ERC1155); - warnIfMismatch( - registeredERC1155ProxyInMAP, - erc1155Proxy.address, - 'Unexpected ERC1155Proxy registered in MultiAssetProxy', - ); - - const registeredStaticCallProxyInMAP = await exchange.getAssetProxy.callAsync(AssetProxyId.StaticCall); - warnIfMismatch( - registeredStaticCallProxyInMAP, - addresses.staticCallProxy, - 'Unexpected StaticCallProxy registered in MultiAssetProxy', - ); - - // Verify AssetProxyOwner configs - // TODO (xianny): re-enable when AssetProxyOwner contract is finalised - // const isERC20ProxyRegisteredInAPOwner = await assetProxyOwner.getAssetProxy.callAsync(erc20Proxy.address); - // warnIfMismatch(isERC20ProxyRegisteredInAPOwner, true, 'ERC20Proxy not registered in AssetProxyOwner'); - - // const isERC721ProxyRegisteredInAPOwner = await assetProxyOwner.getAssetProxy.callAsync( - // erc721Proxy.address, - // ); - // warnIfMismatch(isERC721ProxyRegisteredInAPOwner, true, 'ERC721Proxy not registered in AssetProxyOwner'); - - // const isERC1155ProxyRegisteredInAPOwner = await assetProxyOwner.getAssetProxy.callAsync( - // erc1155Proxy.address, - // ); - // warnIfMismatch(isERC1155ProxyRegisteredInAPOwner, true, 'ERC1155Proxy not registered in AssetProxyOwner'); - - // const isMultiAssetProxyRegisteredInAPOwner = await assetProxyOwner.getAssetProxy.callAsync( - // multiAssetProxy.address, - // ); - // warnIfMismatch(isMultiAssetProxyRegisteredInAPOwner, true, 'MultiAssetProxy not registered in AssetProxyOwner'); + await verifyExchangeV2ConfigsAsync(); + await verifyExchangeV3ConfigsAsync(); + await verifyStakingConfigsAsync(); + await verifyAssetProxyConfigsAsync(); } (async () => { diff --git a/packages/migrations/src/testnet_migrations.ts b/packages/migrations/src/testnet_migrations.ts new file mode 100644 index 0000000000..49c086a2d9 --- /dev/null +++ b/packages/migrations/src/testnet_migrations.ts @@ -0,0 +1,259 @@ +import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses'; +import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange'; +import { artifacts, AssetProxyOwnerContract, AssetProxyOwnerSubmissionEventArgs } from '@0x/contracts-multisig'; +import { + artifacts as stakingArtifacts, + ReadOnlyProxyContract, + StakingContract, + StakingProxyContract, + ZrxVaultContract, +} from '@0x/contracts-staking'; +import { IAuthorizableContract, IOwnableContract } from '@0x/contracts-utils'; +import { AbiEncoder, BigNumber, logUtils, providerUtils } from '@0x/utils'; +import { Web3Wrapper } from '@0x/web3-wrapper'; +import { LogWithDecodedArgs, SupportedProvider, TxData } from 'ethereum-types'; + +import { constants } from './utils/constants'; +import { providerFactory } from './utils/provider_factory'; + +async function submitAndExecuteTransactionAsync( + assetProxyOwner: AssetProxyOwnerContract, + destination: string, + data: string, +): Promise { + const txReceipt = await assetProxyOwner.submitTransaction.awaitTransactionSuccessAsync( + destination, + constants.ZERO_AMOUNT, + data, + ); + // tslint:disable-next-line:no-unnecessary-type-assertion + const txId = (txReceipt.logs[0] as LogWithDecodedArgs).args.transactionId; + logUtils.log(`${txId} submitted`); + await assetProxyOwner.executeTransaction.awaitTransactionSuccessAsync(txId); + logUtils.log(`${txId} executed`); +} + +/** + * Deploys all 3.0 contracts and reconfigures existing 2.0 contracts. + * @param supportedProvider Web3 provider instance. Your provider instance should connect to the testnet you want to deploy to. + * @param txDefaults Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter). + */ +export async function runMigrationsAsync(supportedProvider: SupportedProvider, txDefaults: TxData): Promise { + const provider = providerUtils.standardizeOrThrow(supportedProvider); + const web3Wrapper = new Web3Wrapper(provider); + const networkId = await web3Wrapper.getNetworkIdAsync(); + const chainId = new BigNumber(await providerUtils.getChainIdAsync(provider)); + const deployedAddresses = getContractAddressesForNetworkOrThrow(networkId); + + // NOTE: This must be deployed before running these migrations, since its address is hard coded in the + // staking logic contract. + const zrxVault = new ZrxVaultContract(deployedAddresses.zrxVault, provider, txDefaults); + + // NOTE: This may need to be deployed in its own step, since this contract requires a smaller + // amount of optimizer runs in order to deploy below the codesize limit. + const stakingLogic = await StakingContract.deployFrom0xArtifactAsync( + stakingArtifacts.Staking, + provider, + txDefaults, + stakingArtifacts, + ); + + const exchange = await ExchangeContract.deployFrom0xArtifactAsync( + exchangeArtifacts.Exchange, + provider, + txDefaults, + exchangeArtifacts, + chainId, + ); + + const readOnlyProxy = await ReadOnlyProxyContract.deployFrom0xArtifactAsync( + stakingArtifacts.ReadOnlyProxy, + provider, + txDefaults, + stakingArtifacts, + ); + + const stakingProxy = await StakingProxyContract.deployFrom0xArtifactAsync( + stakingArtifacts.StakingProxy, + provider, + txDefaults, + stakingArtifacts, + stakingLogic.address, + readOnlyProxy.address, + ); + + const authorizableInterface = new IAuthorizableContract(constants.NULL_ADDRESS, provider, txDefaults); + const ownableInterface = new IOwnableContract(constants.NULL_ADDRESS, provider, txDefaults); + + const customTimeLocks = [ + { + destination: deployedAddresses.erc20Proxy, + functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.erc20Proxy, + functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.erc721Proxy, + functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.erc721Proxy, + functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.erc1155Proxy, + functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.erc1155Proxy, + functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.multiAssetProxy, + functionSelector: authorizableInterface.removeAuthorizedAddress.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.multiAssetProxy, + functionSelector: authorizableInterface.removeAuthorizedAddressAtIndex.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.stakingProxy, + functionSelector: stakingProxy.setReadOnlyMode.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.zrxVault, + functionSelector: zrxVault.enterCatastrophicFailure.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, + }, + { + destination: deployedAddresses.stakingProxy, + functionSelector: stakingProxy.attachStakingContract.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, // 3 epochs on mainnet + }, + { + destination: deployedAddresses.stakingProxy, + functionSelector: stakingLogic.setParams.getSelector(), + secondsTimeLocked: constants.ZERO_AMOUNT, // 1 epoch on mainnet + }, + ]; + + const assetProxyOwner = await AssetProxyOwnerContract.deployFrom0xArtifactAsync( + artifacts.AssetProxyOwner, + provider, + txDefaults, + artifacts, + customTimeLocks.map(timeLockInfo => timeLockInfo.functionSelector), + customTimeLocks.map(timeLockInfo => timeLockInfo.destination), + customTimeLocks.map(timeLockInfo => timeLockInfo.secondsTimeLocked), + constants.ASSET_PROXY_OWNER_OWNERS, + constants.ASSET_PROXY_OWNER_CONFIRMATIONS, + constants.ASSET_PROXY_OWNER_TIMELOCK, + ); + + logUtils.log('Configuring Exchange...'); + await exchange.setProtocolFeeCollectorAddress.awaitTransactionSuccessAsync(stakingProxy.address); + await exchange.setProtocolFeeMultiplier.awaitTransactionSuccessAsync(new BigNumber(150000)); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.erc20Proxy); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.erc721Proxy); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.erc1155Proxy); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.multiAssetProxy); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(deployedAddresses.staticCallProxy); + await exchange.transferOwnership.awaitTransactionSuccessAsync(assetProxyOwner.address); + logUtils.log('Exchange configured!'); + + logUtils.log('Configuring ZrxVault...'); + await zrxVault.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyOwner.address); + logUtils.log('ZrxVault configured!'); + + logUtils.log('Configuring StakingProxy...'); + await stakingProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(assetProxyOwner.address); + logUtils.log('StakingProxy configured!'); + + logUtils.log('Transfering ownership of 2.0 contracts...'); + const oldAssetProxyOwner = new AssetProxyOwnerContract(deployedAddresses.assetProxyOwner, provider, txDefaults); + await submitAndExecuteTransactionAsync( + oldAssetProxyOwner, + deployedAddresses.exchangeV2, // Exchange 2.1 address + ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address), + ); + await submitAndExecuteTransactionAsync( + oldAssetProxyOwner, + deployedAddresses.erc20Proxy, + ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address), + ); + await submitAndExecuteTransactionAsync( + oldAssetProxyOwner, + deployedAddresses.erc721Proxy, + ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address), + ); + await submitAndExecuteTransactionAsync( + oldAssetProxyOwner, + deployedAddresses.erc1155Proxy, + ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address), + ); + await submitAndExecuteTransactionAsync( + oldAssetProxyOwner, + deployedAddresses.multiAssetProxy, + ownableInterface.transferOwnership.getABIEncodedTransactionData(assetProxyOwner.address), + ); + logUtils.log('Ownership transferred!'); + + const functionCalls = [ + { + destination: zrxVault.address, + data: zrxVault.setStakingProxy.getABIEncodedTransactionData(stakingProxy.address), + }, + { + destination: stakingProxy.address, + data: stakingLogic.addExchangeAddress.getABIEncodedTransactionData(exchange.address), + }, + { + destination: deployedAddresses.erc20Proxy, + data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + }, + { + destination: deployedAddresses.erc20Proxy, + data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(zrxVault.address), + }, + { + destination: deployedAddresses.erc721Proxy, + data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + }, + { + destination: deployedAddresses.erc1155Proxy, + data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + }, + { + destination: deployedAddresses.multiAssetProxy, + data: authorizableInterface.addAuthorizedAddress.getABIEncodedTransactionData(exchange.address), + }, + ]; + const batchTransactionEncoder = AbiEncoder.create('(bytes[],address[],uint256[])'); + const batchTransactionData = batchTransactionEncoder.encode([ + functionCalls.map(item => item.data), + functionCalls.map(item => item.destination), + functionCalls.map(() => constants.ZERO_AMOUNT), + ]); + await submitAndExecuteTransactionAsync(assetProxyOwner, assetProxyOwner.address, batchTransactionData); +} + +(async () => { + const networkId = 4; + const rpcUrl = 'https://rinkeby.infura.io/v3/'; + const provider = await providerFactory.getLedgerProviderAsync(networkId, rpcUrl); + await runMigrationsAsync(provider, { from: constants.ASSET_PROXY_OWNER_OWNERS[0], gasPrice: 60000000000 }); +})().catch(err => { + logUtils.log(err); + process.exit(1); +}); diff --git a/packages/migrations/src/utils/constants.ts b/packages/migrations/src/utils/constants.ts index 8b16a0520b..15629e870e 100644 --- a/packages/migrations/src/utils/constants.ts +++ b/packages/migrations/src/utils/constants.ts @@ -15,4 +15,5 @@ export const constants = { KOVAN_NETWORK_ID: 42, MAINNET_RPC_URL: 'https://mainnet.infura.io/', MAINNET_NETWORK_ID: 1, + ZERO_AMOUNT: new BigNumber(0), }; diff --git a/packages/migrations/src/utils/provider_factory.ts b/packages/migrations/src/utils/provider_factory.ts index 330a263e87..0806981fb7 100644 --- a/packages/migrations/src/utils/provider_factory.ts +++ b/packages/migrations/src/utils/provider_factory.ts @@ -5,35 +5,21 @@ import Eth from '@ledgerhq/hw-app-eth'; import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'; import { Provider } from 'ethereum-types'; -import { constants } from './constants'; - async function ledgerEthereumNodeJsClientFactoryAsync(): Promise { const ledgerConnection = await TransportNodeHid.create(); const ledgerEthClient = new Eth(ledgerConnection); return ledgerEthClient; } export const providerFactory = { - async getKovanLedgerProviderAsync(): Promise { - const provider = new Web3ProviderEngine(); - const ledgerWalletConfigs = { - networkId: constants.KOVAN_NETWORK_ID, - ledgerEthereumClientFactoryAsync: ledgerEthereumNodeJsClientFactoryAsync, - }; - const ledgerSubprovider = new LedgerSubprovider(ledgerWalletConfigs); - provider.addProvider(ledgerSubprovider); - provider.addProvider(new RPCSubprovider(constants.KOVAN_RPC_URL)); - providerUtils.startProviderEngine(provider); - return provider; - }, - async getMainnetLedgerProviderAsync(): Promise { + async getLedgerProviderAsync(networkId: number, rpcUrl: string): Promise { const provider = new Web3ProviderEngine(); const ledgerWalletConfigs = { - networkId: constants.MAINNET_NETWORK_ID, + networkId, ledgerEthereumClientFactoryAsync: ledgerEthereumNodeJsClientFactoryAsync, }; const ledgerSubprovider = new LedgerSubprovider(ledgerWalletConfigs); provider.addProvider(ledgerSubprovider); - provider.addProvider(new RPCSubprovider(constants.MAINNET_RPC_URL)); + provider.addProvider(new RPCSubprovider(rpcUrl)); providerUtils.startProviderEngine(provider); return provider; }, diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index 176896ea82..b2fabad0c2 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -40,7 +40,6 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md", "devDependencies": { "@0x/dev-utils": "^2.4.0-beta.0", - "@0x/migrations": "^4.4.0-beta.0", "@0x/subproviders": "^5.1.0-beta.0", "@0x/ts-doc-gen": "^0.0.22", "@0x/tslint-config": "^3.0.1",