aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/compiler.json1
-rw-r--r--packages/contracts/package.json15
-rw-r--r--packages/contracts/src/1.0.0/Arbitrage/Arbitrage.sol (renamed from packages/contracts/src/contracts/previous/Arbitrage/Arbitrage.sol)0
-rw-r--r--packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol (renamed from packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol)0
-rw-r--r--packages/contracts/src/1.0.0/EtherDelta/AccountLevels.sol (renamed from packages/contracts/src/contracts/previous/EtherDelta/AccountLevels.sol)0
-rw-r--r--packages/contracts/src/1.0.0/EtherDelta/EtherDelta.sol (renamed from packages/contracts/src/contracts/previous/EtherDelta/EtherDelta.sol)0
-rw-r--r--packages/contracts/src/1.0.0/Exchange/Exchange_v1.sol (renamed from packages/contracts/src/contracts/previous/Exchange/Exchange_v1.sol)0
-rw-r--r--packages/contracts/src/1.0.0/Exchange/IExchange_v1.sol (renamed from packages/contracts/src/contracts/previous/Exchange/IExchange_v1.sol)0
-rw-r--r--packages/contracts/src/1.0.0/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol (renamed from packages/contracts/src/contracts/previous/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol)0
-rw-r--r--packages/contracts/src/1.0.0/Ownable/IOwnable_v1.sol (renamed from packages/contracts/src/contracts/previous/Ownable/IOwnable_v1.sol)0
-rw-r--r--packages/contracts/src/1.0.0/Ownable/Ownable_v1.sol (renamed from packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol)0
-rw-r--r--packages/contracts/src/1.0.0/SafeMath/SafeMath_v1.sol (renamed from packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol)0
-rw-r--r--packages/contracts/src/1.0.0/Token/Token_v1.sol (renamed from packages/contracts/src/contracts/previous/Token/Token_v1.sol)0
-rw-r--r--packages/contracts/src/1.0.0/TokenRegistry/ITokenRegistery.sol (renamed from packages/contracts/src/contracts/previous/TokenRegistry/ITokenRegistery.sol)0
-rw-r--r--packages/contracts/src/1.0.0/TokenRegistry/TokenRegistry.sol (renamed from packages/contracts/src/contracts/previous/TokenRegistry/TokenRegistry.sol)0
-rw-r--r--packages/contracts/src/1.0.0/TokenTransferProxy/TokenTransferProxy_v1.sol (renamed from packages/contracts/src/contracts/previous/TokenTransferProxy/TokenTransferProxy_v1.sol)0
-rw-r--r--packages/contracts/src/1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol (renamed from packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol)0
-rw-r--r--packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol (renamed from packages/contracts/src/contracts/current/multisig/MultiSigWallet.sol)0
-rw-r--r--packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol (renamed from packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol132
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol218
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol (renamed from packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAuthorizable.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol (renamed from packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetData.sol)12
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol (renamed from packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetProxy.sol)2
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol (renamed from packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAuthorizable.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol (renamed from packages/contracts/src/contracts/current/protocol/AssetProxy/libs/LibAssetProxyErrors.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol (renamed from packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAuthorizable.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol (renamed from packages/contracts/src/contracts/current/protocol/AssetProxyOwner/AssetProxyOwner.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol)48
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/MixinMatchOrders.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/MixinTransactions.sol)7
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol)14
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchange.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchangeCore.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IMatchOrders.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISignatureValidator.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ITransactions.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IValidator.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWallet.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWrapperFunctions.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/libs/LibConstants.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/libs/LibEIP712.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol)3
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/libs/LibFillResults.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/libs/LibMath.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/libs/LibOrder.sol)15
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol)5
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/mixins/MMatchOrders.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/mixins/MTransactions.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol (renamed from packages/contracts/src/contracts/current/test/DummyERC20Token/DummyERC20Token.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol (renamed from packages/contracts/src/contracts/current/test/DummyERC721Receiver/DummyERC721Receiver.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol (renamed from packages/contracts/src/contracts/current/test/DummyERC721Token/DummyERC721Token.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol (renamed from packages/contracts/src/contracts/current/test/ExchangeWrapper/ExchangeWrapper.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/Mintable/Mintable.sol (renamed from packages/contracts/src/contracts/current/test/Mintable/Mintable.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol (renamed from packages/contracts/src/contracts/current/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol (renamed from packages/contracts/src/contracts/current/test/TestAssetProxyOwner/TestAssetProxyOwner.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol (renamed from packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol (renamed from packages/contracts/src/contracts/current/test/TestLibs/TestLibs.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol (renamed from packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol (renamed from packages/contracts/src/contracts/current/test/TestValidator/TestValidator.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol (renamed from packages/contracts/src/contracts/current/test/TestWallet/TestWallet.sol)0
-rw-r--r--packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol (renamed from packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol)0
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol (renamed from packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol)0
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol (renamed from packages/contracts/src/contracts/current/tokens/ERC20Token/IERC20Token.sol)0
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol (renamed from packages/contracts/src/contracts/current/tokens/ERC721Token/ERC721Token.sol)0
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol (renamed from packages/contracts/src/contracts/current/tokens/ERC721Token/IERC721Receiver.sol)0
-rw-r--r--packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol (renamed from packages/contracts/src/contracts/current/tokens/ERC721Token/IERC721Token.sol)0
-rw-r--r--packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol (renamed from packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol)0
-rw-r--r--packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol (renamed from packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol)0
-rw-r--r--packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol (renamed from packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol)2
-rw-r--r--packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol (renamed from packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol)0
-rw-r--r--packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol (renamed from packages/contracts/src/contracts/current/utils/Ownable/IOwnable.sol)0
-rw-r--r--packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol (renamed from packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol)0
-rw-r--r--packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol (renamed from packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol)0
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol167
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol207
-rw-r--r--packages/contracts/src/utils/artifacts.ts49
-rw-r--r--packages/contracts/src/utils/assertions.ts79
-rw-r--r--packages/contracts/test/asset_proxy/authorizable.ts28
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts244
-rw-r--r--packages/contracts/test/exchange/core.ts70
-rw-r--r--packages/contracts/test/exchange/dispatcher.ts187
-rw-r--r--packages/contracts/test/exchange/fill_order.ts18
-rw-r--r--packages/contracts/test/exchange/libs.ts14
-rw-r--r--packages/contracts/test/exchange/match_orders.ts72
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts30
-rw-r--r--packages/contracts/test/exchange/transactions.ts50
-rw-r--r--packages/contracts/test/exchange/wrapper.ts46
-rw-r--r--packages/contracts/test/global_hooks.ts4
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts56
-rw-r--r--packages/contracts/test/multisig/asset_proxy_owner.ts (renamed from packages/contracts/test/asset_proxy_owner.ts)41
-rw-r--r--packages/contracts/test/multisig/multi_sig_with_time_lock.ts (renamed from packages/contracts/test/multi_sig_with_time_lock.ts)22
-rw-r--r--packages/contracts/test/token_registry.ts45
-rw-r--r--packages/contracts/test/tokens/ether_token.ts (renamed from packages/contracts/test/ether_token.ts)14
-rw-r--r--packages/contracts/test/tokens/unlimited_allowance_token.ts (renamed from packages/contracts/test/unlimited_allowance_token.ts)18
-rw-r--r--packages/contracts/test/tokens/zrx_token.ts (renamed from packages/contracts/test/zrx_token.ts)10
-rw-r--r--packages/contracts/test/utils/abstract_asset_wrapper.ts (renamed from packages/contracts/src/abstract/abstract_asset_wrapper.ts)0
-rw-r--r--packages/contracts/test/utils/address_utils.ts (renamed from packages/contracts/src/utils/address_utils.ts)0
-rw-r--r--packages/contracts/test/utils/artifacts.ts51
-rw-r--r--packages/contracts/test/utils/assertions.ts159
-rw-r--r--packages/contracts/test/utils/asset_wrapper.ts (renamed from packages/contracts/src/utils/asset_wrapper.ts)14
-rw-r--r--packages/contracts/test/utils/chai_setup.ts (renamed from packages/contracts/src/utils/chai_setup.ts)0
-rw-r--r--packages/contracts/test/utils/constants.ts (renamed from packages/contracts/src/utils/constants.ts)2
-rw-r--r--packages/contracts/test/utils/core_combinatorial_utils.ts (renamed from packages/contracts/src/utils/core_combinatorial_utils.ts)169
-rw-r--r--packages/contracts/test/utils/coverage.ts (renamed from packages/contracts/src/utils/coverage.ts)0
-rw-r--r--packages/contracts/test/utils/erc20_wrapper.ts (renamed from packages/contracts/src/utils/erc20_wrapper.ts)4
-rw-r--r--packages/contracts/test/utils/erc721_wrapper.ts (renamed from packages/contracts/src/utils/erc721_wrapper.ts)4
-rw-r--r--packages/contracts/test/utils/exchange_wrapper.ts (renamed from packages/contracts/src/utils/exchange_wrapper.ts)18
-rw-r--r--packages/contracts/test/utils/formatters.ts (renamed from packages/contracts/src/utils/formatters.ts)0
-rw-r--r--packages/contracts/test/utils/increase_time.ts (renamed from packages/contracts/src/utils/increase_time.ts)0
-rw-r--r--packages/contracts/test/utils/log_decoder.ts (renamed from packages/contracts/src/utils/log_decoder.ts)0
-rw-r--r--packages/contracts/test/utils/match_order_tester.ts (renamed from packages/contracts/src/utils/match_order_tester.ts)14
-rw-r--r--packages/contracts/test/utils/multi_sig_wrapper.ts (renamed from packages/contracts/src/utils/multi_sig_wrapper.ts)4
-rw-r--r--packages/contracts/test/utils/order_factory.ts (renamed from packages/contracts/src/utils/order_factory.ts)0
-rw-r--r--packages/contracts/test/utils/order_factory_from_scenario.ts (renamed from packages/contracts/src/utils/order_factory_from_scenario.ts)2
-rw-r--r--packages/contracts/test/utils/order_utils.ts (renamed from packages/contracts/src/utils/order_utils.ts)0
-rw-r--r--packages/contracts/test/utils/profiler.ts (renamed from packages/contracts/src/utils/profiler.ts)0
-rw-r--r--packages/contracts/test/utils/revert_trace.ts (renamed from packages/contracts/src/utils/revert_trace.ts)0
-rw-r--r--packages/contracts/test/utils/signing_utils.ts (renamed from packages/contracts/src/utils/signing_utils.ts)0
-rw-r--r--packages/contracts/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts (renamed from packages/contracts/src/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts)0
-rw-r--r--packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts (renamed from packages/contracts/src/utils/simple_order_filled_cancelled_fetcher.ts)0
-rw-r--r--packages/contracts/test/utils/token_registry_wrapper.ts (renamed from packages/contracts/src/utils/token_registry_wrapper.ts)2
-rw-r--r--packages/contracts/test/utils/transaction_factory.ts (renamed from packages/contracts/src/utils/transaction_factory.ts)0
-rw-r--r--packages/contracts/test/utils/types.ts (renamed from packages/contracts/src/utils/types.ts)0
-rw-r--r--packages/contracts/test/utils/web3_wrapper.ts (renamed from packages/contracts/src/utils/web3_wrapper.ts)0
131 files changed, 1225 insertions, 1163 deletions
diff --git a/packages/contracts/compiler.json b/packages/contracts/compiler.json
index 1ee58081a..56c8b1761 100644
--- a/packages/contracts/compiler.json
+++ b/packages/contracts/compiler.json
@@ -29,6 +29,7 @@
"Exchange",
"ExchangeWrapper",
"IAssetData",
+ "IAssetProxy",
"IValidator",
"IWallet",
"MixinAuthorizable",
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index b5a599fe5..448871c23 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -14,7 +14,7 @@
"watch_without_deps": "yarn pre_build && tsc -w",
"build": "yarn pre_build && tsc",
"pre_build": "run-s compile copy_artifacts generate_contract_wrappers",
- "copy_artifacts": "copyfiles -u 4 '../migrations/artifacts/2.0.0/**/*' ./lib/src/artifacts;",
+ "copy_artifacts": "copyfiles -u 4 '../migrations/artifacts/2.0.0/**/*' ./lib/artifacts;",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s build test",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
@@ -22,10 +22,10 @@
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
"run_mocha":
"mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
- "compile": "sol-compiler",
- "clean": "shx rm -rf lib src/generated_contract_wrappers",
+ "compile": "sol-compiler --contracts-dir src",
+ "clean": "shx rm -rf lib generated_contract_wrappers",
"generate_contract_wrappers":
- "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers",
+ "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output generated_contract_wrappers --backend ethers",
"lint": "tslint --project . --exclude **/src/generated_contract_wrappers/**/* --exclude **/lib/**/*",
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
@@ -35,7 +35,7 @@
},
"config": {
"abis":
- "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Receiver|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|ExchangeWrapper|IAssetData|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestAssetProxyDispatcher|TestLibBytes|TestLibs|TestSignatureValidator|TestValidator|TestWallet|TokenRegistry|Whitelist|WETH9|ZRXToken).json"
+ "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Receiver|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|ExchangeWrapper|IAssetData|IAssetProxy|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestAssetProxyDispatcher|TestLibBytes|TestLibs|TestSignatureValidator|TestValidator|TestWallet|TokenRegistry|Whitelist|WETH9|ZRXToken).json"
},
"repository": {
"type": "git",
@@ -80,12 +80,11 @@
"@0xproject/typescript-typings": "^0.4.1",
"@0xproject/utils": "^0.7.1",
"@0xproject/web3-wrapper": "^0.7.1",
- "ethereum-types": "^0.0.1",
+ "ethereum-types": "^0.0.2",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
"ethereumjs-util": "^5.1.1",
"ethers": "3.0.22",
- "lodash": "^4.17.4",
- "web3": "^0.20.0"
+ "lodash": "^4.17.4"
}
}
diff --git a/packages/contracts/src/contracts/previous/Arbitrage/Arbitrage.sol b/packages/contracts/src/1.0.0/Arbitrage/Arbitrage.sol
index 5054afc2f..5054afc2f 100644
--- a/packages/contracts/src/contracts/previous/Arbitrage/Arbitrage.sol
+++ b/packages/contracts/src/1.0.0/Arbitrage/Arbitrage.sol
diff --git a/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol b/packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol
index e05ee2d5e..e05ee2d5e 100644
--- a/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol
+++ b/packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol
diff --git a/packages/contracts/src/contracts/previous/EtherDelta/AccountLevels.sol b/packages/contracts/src/1.0.0/EtherDelta/AccountLevels.sol
index 8d7a930d3..8d7a930d3 100644
--- a/packages/contracts/src/contracts/previous/EtherDelta/AccountLevels.sol
+++ b/packages/contracts/src/1.0.0/EtherDelta/AccountLevels.sol
diff --git a/packages/contracts/src/contracts/previous/EtherDelta/EtherDelta.sol b/packages/contracts/src/1.0.0/EtherDelta/EtherDelta.sol
index fe599ca0a..fe599ca0a 100644
--- a/packages/contracts/src/contracts/previous/EtherDelta/EtherDelta.sol
+++ b/packages/contracts/src/1.0.0/EtherDelta/EtherDelta.sol
diff --git a/packages/contracts/src/contracts/previous/Exchange/Exchange_v1.sol b/packages/contracts/src/1.0.0/Exchange/Exchange_v1.sol
index 3f8e7368d..3f8e7368d 100644
--- a/packages/contracts/src/contracts/previous/Exchange/Exchange_v1.sol
+++ b/packages/contracts/src/1.0.0/Exchange/Exchange_v1.sol
diff --git a/packages/contracts/src/contracts/previous/Exchange/IExchange_v1.sol b/packages/contracts/src/1.0.0/Exchange/IExchange_v1.sol
index ec4bce7b0..ec4bce7b0 100644
--- a/packages/contracts/src/contracts/previous/Exchange/IExchange_v1.sol
+++ b/packages/contracts/src/1.0.0/Exchange/IExchange_v1.sol
diff --git a/packages/contracts/src/contracts/previous/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol b/packages/contracts/src/1.0.0/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
index 241e02d4a..241e02d4a 100644
--- a/packages/contracts/src/contracts/previous/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
+++ b/packages/contracts/src/1.0.0/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
diff --git a/packages/contracts/src/contracts/previous/Ownable/IOwnable_v1.sol b/packages/contracts/src/1.0.0/Ownable/IOwnable_v1.sol
index 7e22d544d..7e22d544d 100644
--- a/packages/contracts/src/contracts/previous/Ownable/IOwnable_v1.sol
+++ b/packages/contracts/src/1.0.0/Ownable/IOwnable_v1.sol
diff --git a/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol b/packages/contracts/src/1.0.0/Ownable/Ownable_v1.sol
index c87438fa4..c87438fa4 100644
--- a/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol
+++ b/packages/contracts/src/1.0.0/Ownable/Ownable_v1.sol
diff --git a/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol b/packages/contracts/src/1.0.0/SafeMath/SafeMath_v1.sol
index 341d611ec..341d611ec 100644
--- a/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol
+++ b/packages/contracts/src/1.0.0/SafeMath/SafeMath_v1.sol
diff --git a/packages/contracts/src/contracts/previous/Token/Token_v1.sol b/packages/contracts/src/1.0.0/Token/Token_v1.sol
index de619fb7e..de619fb7e 100644
--- a/packages/contracts/src/contracts/previous/Token/Token_v1.sol
+++ b/packages/contracts/src/1.0.0/Token/Token_v1.sol
diff --git a/packages/contracts/src/contracts/previous/TokenRegistry/ITokenRegistery.sol b/packages/contracts/src/1.0.0/TokenRegistry/ITokenRegistery.sol
index b8bdaf3b9..b8bdaf3b9 100644
--- a/packages/contracts/src/contracts/previous/TokenRegistry/ITokenRegistery.sol
+++ b/packages/contracts/src/1.0.0/TokenRegistry/ITokenRegistery.sol
diff --git a/packages/contracts/src/contracts/previous/TokenRegistry/TokenRegistry.sol b/packages/contracts/src/1.0.0/TokenRegistry/TokenRegistry.sol
index 7417a10a3..7417a10a3 100644
--- a/packages/contracts/src/contracts/previous/TokenRegistry/TokenRegistry.sol
+++ b/packages/contracts/src/1.0.0/TokenRegistry/TokenRegistry.sol
diff --git a/packages/contracts/src/contracts/previous/TokenTransferProxy/TokenTransferProxy_v1.sol b/packages/contracts/src/1.0.0/TokenTransferProxy/TokenTransferProxy_v1.sol
index e3659d8ba..e3659d8ba 100644
--- a/packages/contracts/src/contracts/previous/TokenTransferProxy/TokenTransferProxy_v1.sol
+++ b/packages/contracts/src/1.0.0/TokenTransferProxy/TokenTransferProxy_v1.sol
diff --git a/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol b/packages/contracts/src/1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol
index 46379c43d..46379c43d 100644
--- a/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol
+++ b/packages/contracts/src/1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol
diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWallet.sol b/packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol
index 79fd92029..79fd92029 100644
--- a/packages/contracts/src/contracts/current/multisig/MultiSigWallet.sol
+++ b/packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol
diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock.sol b/packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol
index 9766c2158..9766c2158 100644
--- a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock.sol
+++ b/packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol
new file mode 100644
index 000000000..aed62f54f
--- /dev/null
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol
@@ -0,0 +1,132 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity ^0.4.24;
+pragma experimental ABIEncoderV2;
+
+import "../../utils/LibBytes/LibBytes.sol";
+import "./MixinAuthorizable.sol";
+
+contract ERC20Proxy is
+ MixinAuthorizable
+{
+ // Id of this proxy.
+ bytes4 constant PROXY_ID = bytes4(keccak256("ERC20Token(address)"));
+
+ function ()
+ external
+ {
+ assembly {
+ // The first 4 bytes of calldata holds the function selector
+ let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)
+
+ // `transferFrom` will be called with the following parameters:
+ // assetData Encoded byte array.
+ // from Address to transfer asset from.
+ // to Address to transfer asset to.
+ // amount Amount of asset to transfer.
+ // bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
+ if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {
+
+ // To lookup a value in a mapping, we load from the storage location keccak256(k, p),
+ // where k is the key left padded to 32 bytes and p is the storage slot
+ let start := mload(64)
+ mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff))
+ mstore(add(start, 32), authorized_slot)
+
+ // Revert if authorized[msg.sender] == false
+ if iszero(sload(keccak256(start, 64))) {
+ // Revert with `Error("SENDER_NOT_AUTHORIZED")`
+ mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
+ mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
+ mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)
+ mstore(96, 0)
+ revert(0, 100)
+ }
+
+ /////// Token contract address ///////
+ // The token address is found as follows:
+ // * It is stored at offset 4 in `assetData` contents.
+ // * This is stored at offset 32 from `assetData`.
+ // * The offset to `assetData` from Params is stored at offset
+ // 4 in calldata.
+ // * The offset of Params in calldata is 4.
+ // So we read location 4 and add 32 + 4 + 4 to it.
+ let token := calldataload(add(calldataload(4), 40))
+
+ /////// Setup Header Area ///////
+ // This area holds the 4-byte `transferFrom` selector.
+ // Any trailing data in transferFromSelector will be
+ // overwritten in the next `mstore` call.
+ mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
+
+ /////// Setup Params Area ///////
+ // We copy the fields `from`, `to` and `amount` in bulk
+ // from our own calldata to the new calldata.
+ calldatacopy(4, 36, 96)
+
+ /////// Call `token.transferFrom` using the calldata ///////
+ let success := call(
+ gas, // forward all gas
+ token, // call address of token contract
+ 0, // don't send any ETH
+ 0, // pointer to start of input
+ 100, // length of input
+ 0, // write output over input
+ 32 // output size should be 32 bytes
+ )
+
+ /////// Check return data. ///////
+ // If there is no return data, we assume the token incorrectly
+ // does not return a bool. In this case we expect it to revert
+ // on failure, which was handled above.
+ // If the token does return data, we require that it is a single
+ // nonzero 32 bytes value.
+ // So the transfer succeeded if the call succeeded and either
+ // returned nothing, or returned a non-zero 32 byte value.
+ success := and(success, or(
+ iszero(returndatasize),
+ and(
+ eq(returndatasize, 32),
+ gt(mload(0), 0)
+ )
+ ))
+ if success {
+ return(0, 0)
+ }
+
+ // Revert with `Error("TRANSFER_FAILED")`
+ mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
+ mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
+ mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
+ mstore(96, 0)
+ revert(0, 100)
+ }
+ }
+ }
+
+ /// @dev Gets the proxy id associated with the proxy address.
+ /// @return Proxy id.
+ function getProxyId()
+ external
+ pure
+ returns (bytes4)
+ {
+ return PROXY_ID;
+ }
+}
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol
new file mode 100644
index 000000000..b73dc36cc
--- /dev/null
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol
@@ -0,0 +1,218 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity ^0.4.24;
+pragma experimental ABIEncoderV2;
+
+import "../../utils/LibBytes/LibBytes.sol";
+import "./MixinAuthorizable.sol";
+
+contract ERC721Proxy is
+ MixinAuthorizable
+{
+ // Id of this proxy.
+ bytes4 constant PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)"));
+
+ function ()
+ external
+ {
+ assembly {
+ // The first 4 bytes of calldata holds the function selector
+ let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)
+
+ // `transferFrom` will be called with the following parameters:
+ // assetData Encoded byte array.
+ // from Address to transfer asset from.
+ // to Address to transfer asset to.
+ // amount Amount of asset to transfer.
+ // bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
+ if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {
+
+ // To lookup a value in a mapping, we load from the storage location keccak256(k, p),
+ // where k is the key left padded to 32 bytes and p is the storage slot
+ let start := mload(64)
+ mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff))
+ mstore(add(start, 32), authorized_slot)
+
+ // Revert if authorized[msg.sender] == false
+ if iszero(sload(keccak256(start, 64))) {
+ // Revert with `Error("SENDER_NOT_AUTHORIZED")`
+ mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
+ mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
+ mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)
+ mstore(96, 0)
+ revert(0, 100)
+ }
+
+ // `transferFrom`.
+ // The function is marked `external`, so no abi decodeding is done for
+ // us. Instead, we expect the `calldata` memory to contain the
+ // following:
+ //
+ // | Area | Offset | Length | Contents |
+ // |----------|--------|---------|-------------------------------------|
+ // | Header | 0 | 4 | function selector |
+ // | Params | | 4 * 32 | function parameters: |
+ // | | 4 | | 1. offset to assetData (*) |
+ // | | 36 | | 2. from |
+ // | | 68 | | 3. to |
+ // | | 100 | | 4. amount |
+ // | Data | | | assetData: |
+ // | | 132 | 32 | assetData Length |
+ // | | 164 | ** | assetData Contents |
+ //
+ // (*): offset is computed from start of function parameters, so offset
+ // by an additional 4 bytes in the calldata.
+ //
+ // WARNING: The ABIv2 specification allows additional padding between
+ // the Params and Data section. This will result in a larger
+ // offset to assetData.
+
+ // Asset data itself is encoded as follows:
+ //
+ // | Area | Offset | Length | Contents |
+ // |----------|--------|---------|-------------------------------------|
+ // | Header | 0 | 4 | function selector |
+ // | Params | | 3 * 32 | function parameters: |
+ // | | 4 | 12 + 20 | 1. token address |
+ // | | 36 | | 2. tokenId |
+ // | | 68 | | 3. offset to receiverData (*) |
+ // | Data | | | receiverData: |
+ // | | 100 | 32 | receiverData Length |
+ // | | 132 | ** | receiverData Contents |
+
+ // We construct calldata for the `token.safeTransferFrom` ABI.
+ // The layout of this calldata is in the table below.
+ //
+ // | Area | Offset | Length | Contents |
+ // |----------|--------|---------|-------------------------------------|
+ // | Header | 0 | 4 | function selector |
+ // | Params | | 4 * 32 | function parameters: |
+ // | | 4 | | 1. from |
+ // | | 36 | | 2. to |
+ // | | 68 | | 3. tokenId |
+ // | | 100 | | 4. offset to receiverData (*) |
+ // | Data | | | receiverData: |
+ // | | 132 | 32 | receiverData Length |
+ // | | 164 | ** | receiverData Contents |
+
+ // There exists only 1 of each token.
+ // require(amount == 1, "INVALID_AMOUNT")
+ if sub(calldataload(100), 1) {
+ // Revert with `Error("INVALID_AMOUNT")`
+ mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
+ mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
+ mstore(64, 0x0000000e494e56414c49445f414d4f554e540000000000000000000000000000)
+ mstore(96, 0)
+ revert(0, 100)
+ }
+
+ // Require assetData to be at least 132 bytes
+ let offset := calldataload(4)
+ if lt(calldataload(add(offset, 4)), 132) {
+ // Revert with `Error("LENGTH_GREATER_THAN_131_REQUIRED")`
+ mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
+ mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
+ mstore(64, 0x000000204c454e4754485f475245415445525f5448414e5f3133315f52455155)
+ mstore(96, 0x4952454400000000000000000000000000000000000000000000000000000000)
+ revert(0, 100)
+ }
+
+ /////// Setup State ///////
+ // `cdStart` is the start of the calldata for
+ // `token.safeTransferFrom` (equal to free memory ptr).
+ let cdStart := mload(64)
+ // `dataAreaLength` is the total number of words
+ // needed to store `receiverData`
+ // As-per the ABI spec, this value is padded up to
+ // the nearest multiple of 32,
+ // and includes 32-bytes for length.
+ // It's calculated as folows:
+ // - Unpadded length in bytes = `mload(receiverData) + 32`
+ // - Add 31 to convert rounding down to rounding up.
+ // Combined with the previous and this is `63`.
+ // - Round down to nearest multiple of 32 by clearing
+ // bits 0x1F. This is done with `and` and a mask.
+
+ /////// Setup Header Area ///////
+ // This area holds the 4-byte `transferFromSelector`.
+ // Any trailing data in transferFromSelector will be
+ // overwritten in the next `mstore` call.
+ mstore(cdStart, 0xb88d4fde00000000000000000000000000000000000000000000000000000000)
+
+ /////// Setup Params Area ///////
+ // Each parameter is padded to 32-bytes.
+ // The entire Params Area is 128 bytes.
+ // Notes:
+ // 1. A 20-byte mask is applied to addresses
+ // to zero-out the unused bytes.
+ // 2. The offset to `receiverData` is the length
+ // of the Params Area (128 bytes).
+
+ let length := calldataload(add(offset, 136))
+ let token := calldataload(add(offset, 40))
+
+ // Round length up to multiple of 32
+ length := and(add(length, 31), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0)
+
+ // Copy `from` and `to`
+ calldatacopy(add(cdStart, 4), 36, 64)
+
+ // TokenId
+ mstore(add(cdStart, 68), calldataload(add(offset, 72)))
+
+ // Offset to receiverData
+ mstore(add(cdStart, 100), 128)
+
+ // receiverData (including length)
+ calldatacopy(add(cdStart, 132), add(offset, 136), add(length, 32))
+
+ /////// Call `token.safeTransferFrom` using the calldata ///////
+ let success := call(
+ gas, // forward all gas
+ token, // call address of token contract
+ 0, // don't send any ETH
+ cdStart, // pointer to start of input
+ add(length, 164), // length of input
+ 0, // write output to null
+ 0 // output size is 0 bytes
+ )
+ if success {
+ return(0, 0)
+ }
+
+ // Revert with `Error("TRANSFER_FAILED")`
+ mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
+ mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
+ mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
+ mstore(96, 0)
+ revert(0, 100)
+ }
+ }
+ }
+
+ /// @dev Gets the proxy id associated with the proxy address.
+ /// @return Proxy id.
+ function getProxyId()
+ external
+ pure
+ returns (bytes4)
+ {
+ return PROXY_ID;
+ }
+}
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAuthorizable.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol
index 3b9584a44..3b9584a44 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAuthorizable.sol
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetData.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol
index 8c78ee8c4..7ebd6acf0 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetData.sol
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol
@@ -23,14 +23,16 @@ pragma solidity ^0.4.23;
// This argument is ABI encoded as one of the methods of this interface.
interface IAssetData {
- function ERC20Token(
- address tokenContract)
- external pure;
+ function ERC20Token(address tokenContract)
+ external
+ pure;
function ERC721Token(
address tokenContract,
uint256 tokenId,
- bytes receiverData)
- external pure;
+ bytes receiverData
+ )
+ external
+ pure;
}
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetProxy.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol
index ae8e195da..eacd5a412 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetProxy.sol
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol
@@ -42,6 +42,6 @@ contract IAssetProxy is
/// @return Proxy id.
function getProxyId()
external
- view
+ pure
returns (bytes4);
}
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAuthorizable.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol
index cedd1744c..cedd1744c 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAuthorizable.sol
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/libs/LibAssetProxyErrors.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol
index 338cb12e2..338cb12e2 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/libs/LibAssetProxyErrors.sol
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAuthorizable.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol
index 6f35bd7ec..6f35bd7ec 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAuthorizable.sol
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxyOwner/AssetProxyOwner.sol b/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol
index eb58b3374..eb58b3374 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxyOwner/AssetProxyOwner.sol
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol b/packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol
index d36e9633e..d36e9633e 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol
index f7086f543..9e9d88ce7 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol
@@ -32,43 +32,28 @@ contract MixinAssetProxyDispatcher is
// Mapping from Asset Proxy Id's to their respective Asset Proxy
mapping (bytes4 => IAssetProxy) public assetProxies;
- /// @dev Registers an asset proxy to an asset proxy id.
- /// An id can only be assigned to a single proxy at a given time.
- /// @param assetProxyId Id to register`newAssetProxy` under.
- /// @param newAssetProxy Address of new asset proxy to register, or 0x0 to unset assetProxyId.
- /// @param oldAssetProxy Existing asset proxy to overwrite, or 0x0 if assetProxyId is currently unused.
- function registerAssetProxy(
- bytes4 assetProxyId,
- address newAssetProxy,
- address oldAssetProxy
- )
+ /// @dev Registers an asset proxy to its asset proxy id.
+ /// Once an asset proxy is registered, it cannot be unregistered.
+ /// @param assetProxy Address of new asset proxy to register.
+ function registerAssetProxy(address assetProxy)
external
onlyOwner
{
- // Ensure the existing asset proxy is not unintentionally overwritten
+ IAssetProxy assetProxyContract = IAssetProxy(assetProxy);
+
+ // Ensure that no asset proxy exists with current id.
+ bytes4 assetProxyId = assetProxyContract.getProxyId();
address currentAssetProxy = assetProxies[assetProxyId];
require(
- oldAssetProxy == currentAssetProxy,
- "ASSET_PROXY_MISMATCH"
+ currentAssetProxy == address(0),
+ "ASSET_PROXY_ALREADY_EXISTS"
);
- IAssetProxy assetProxy = IAssetProxy(newAssetProxy);
-
- // Ensure that the id of newAssetProxy matches the passed in assetProxyId, unless it is being reset to 0.
- if (newAssetProxy != address(0)) {
- bytes4 newAssetProxyId = assetProxy.getProxyId();
- require(
- newAssetProxyId == assetProxyId,
- "ASSET_PROXY_ID_MISMATCH"
- );
- }
-
// Add asset proxy and log registration.
- assetProxies[assetProxyId] = assetProxy;
- emit AssetProxySet(
+ assetProxies[assetProxyId] = assetProxyContract;
+ emit AssetProxyRegistered(
assetProxyId,
- newAssetProxy,
- oldAssetProxy
+ assetProxy
);
}
@@ -112,7 +97,7 @@ contract MixinAssetProxyDispatcher is
0xFFFFFFFF00000000000000000000000000000000000000000000000000000000
)
}
- IAssetProxy assetProxy = assetProxies[assetProxyId];
+ address assetProxy = assetProxies[assetProxyId];
// Ensure that assetProxy exists
require(
@@ -135,7 +120,6 @@ contract MixinAssetProxyDispatcher is
// | | 132 | 32 | assetData Length |
// | | 164 | ** | assetData Contents |
- bool success;
assembly {
/////// Setup State ///////
// `cdStart` is the start of the calldata for `assetProxy.transferFrom` (equal to free memory ptr).
@@ -173,7 +157,7 @@ contract MixinAssetProxyDispatcher is
}
/////// Call `assetProxy.transferFrom` using the constructed calldata ///////
- success := call(
+ let success := call(
gas, // forward all gas
assetProxy, // call address of asset proxy
0, // don't send any ETH
@@ -182,7 +166,7 @@ contract MixinAssetProxyDispatcher is
cdStart, // write output over input
512 // reserve 512 bytes for output
)
- if eq(success, 0) {
+ if iszero(success) {
revert(cdStart, returndatasize())
}
}
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol
index c0ed023ac..c0ed023ac 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinMatchOrders.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol
index 1a43eec79..1a43eec79 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinMatchOrders.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol
index 29172057a..29172057a 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinTransactions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol
index e0f450d0a..31f7f2847 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinTransactions.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol
@@ -60,6 +60,13 @@ contract MixinTransactions is
{
bytes32 schemaHash = EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH;
bytes32 dataHash = keccak256(data);
+ // Assembly for more efficiently computing:
+ // keccak256(abi.encode(
+ // EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH,
+ // salt,
+ // signerAddress,
+ // keccak256(data)
+ // ));
assembly {
let memPtr := mload(64)
mstore(memPtr, schemaHash)
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol
index 00668ca43..00668ca43 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol
index fa55dff00..66f3b5796 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol
@@ -20,16 +20,10 @@ pragma solidity ^0.4.24;
contract IAssetProxyDispatcher {
- /// @dev Registers an asset proxy to an asset proxy id.
- /// An id can only be assigned to a single proxy at a given time.
- /// @param assetProxyId Id to register`newAssetProxy` under.
- /// @param newAssetProxy Address of new asset proxy to register, or 0x0 to unset assetProxyId.
- /// @param oldAssetProxy Existing asset proxy to overwrite, or 0x0 if assetProxyId is currently unused.
- function registerAssetProxy(
- bytes4 assetProxyId,
- address newAssetProxy,
- address oldAssetProxy
- )
+ /// @dev Registers an asset proxy to its asset proxy id.
+ /// Once an asset proxy is registered, it cannot be unregistered.
+ /// @param assetProxy Address of new asset proxy to register.
+ function registerAssetProxy(address assetProxy)
external;
/// @dev Gets an asset proxy.
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchange.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol
index 9f21c18d7..9f21c18d7 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchange.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchangeCore.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol
index 98222f33f..98222f33f 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchangeCore.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IMatchOrders.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol
index df009d063..df009d063 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IMatchOrders.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISignatureValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol
index 511463309..511463309 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISignatureValidator.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ITransactions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol
index a7cab8f55..a7cab8f55 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ITransactions.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol
index 0b1796a66..0b1796a66 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IValidator.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWallet.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol
index c86a2c057..c86a2c057 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWallet.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWrapperFunctions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol
index 84bb683bc..84bb683bc 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWrapperFunctions.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibConstants.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol
index 488ca956c..488ca956c 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibConstants.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibEIP712.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol
index b983347a4..b983347a4 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibEIP712.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol
index e37f41ada..01aa78a1d 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol
@@ -54,8 +54,7 @@ contract LibExchangeErrors {
string constant FAILED_EXECUTION = "FAILED_EXECUTION"; // Transaction execution failed.
/// registerAssetProxy errors ///
- string constant ASSET_PROXY_MISMATCH = "ASSET_PROXY_MISMATCH"; // oldAssetProxy proxy does not match currentAssetProxy.
- string constant ASSET_PROXY_ID_MISMATCH = "ASSET_PROXY_ID_MISMATCH"; // newAssetProxyId does not match given assetProxyId.
+ string constant ASSET_PROXY_ALREADY_EXISTS = "ASSET_PROXY_ALREADY_EXISTS"; // AssetProxy with same id already exists.
/// dispatchTransferFrom errors ///
string constant ASSET_PROXY_DOES_NOT_EXIST = "ASSET_PROXY_DOES_NOT_EXIST"; // No assetProxy registered at given id.
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibFillResults.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol
index 63f1b8c87..63f1b8c87 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibFillResults.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibMath.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol
index bfe2fd33f..bfe2fd33f 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibMath.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibOrder.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol
index f3f1e9277..954f94f76 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibOrder.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol
@@ -98,6 +98,21 @@ contract LibOrder is
bytes32 schemaHash = EIP712_ORDER_SCHEMA_HASH;
bytes32 makerAssetDataHash = keccak256(order.makerAssetData);
bytes32 takerAssetDataHash = keccak256(order.takerAssetData);
+ // Assembly for more efficiently computing:
+ // keccak256(abi.encode(
+ // order.makerAddress,
+ // order.takerAddress,
+ // order.feeRecipientAddress,
+ // order.senderAddress,
+ // order.makerAssetAmount,
+ // order.takerAssetAmount,
+ // order.makerFee,
+ // order.takerFee,
+ // order.expirationTimeSeconds,
+ // order.salt,
+ // keccak256(order.makerAssetData),
+ // keccak256(order.takerAssetData)
+ // ));
assembly {
// Backup
let temp1 := mload(sub(order, 32))
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol
index c2b506dcf..5bf59c6ce 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol
@@ -26,10 +26,9 @@ contract MAssetProxyDispatcher is
{
// Logs registration of new asset proxy
- event AssetProxySet(
+ event AssetProxyRegistered(
bytes4 id, // Id of new registered AssetProxy.
- address newAssetProxy, // Address of new registered AssetProxy.
- address oldAssetProxy // Address of AssetProxy that was overwritten at given id (or null address).
+ address assetProxy // Address of new registered AssetProxy.
);
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol
index 6e406e1c4..6e406e1c4 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MMatchOrders.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol
index abe7c3596..abe7c3596 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MMatchOrders.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol
index 6cc1d7a10..6cc1d7a10 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MTransactions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol
index e2f89de01..e2f89de01 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MTransactions.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol
diff --git a/packages/contracts/src/contracts/current/test/DummyERC20Token/DummyERC20Token.sol b/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol
index b2fe2df06..b2fe2df06 100644
--- a/packages/contracts/src/contracts/current/test/DummyERC20Token/DummyERC20Token.sol
+++ b/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol
diff --git a/packages/contracts/src/contracts/current/test/DummyERC721Receiver/DummyERC721Receiver.sol b/packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol
index c584d0b54..c584d0b54 100644
--- a/packages/contracts/src/contracts/current/test/DummyERC721Receiver/DummyERC721Receiver.sol
+++ b/packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol
diff --git a/packages/contracts/src/contracts/current/test/DummyERC721Token/DummyERC721Token.sol b/packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol
index 78ea96447..78ea96447 100644
--- a/packages/contracts/src/contracts/current/test/DummyERC721Token/DummyERC721Token.sol
+++ b/packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol
diff --git a/packages/contracts/src/contracts/current/test/ExchangeWrapper/ExchangeWrapper.sol b/packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol
index 5baaf6e5a..5baaf6e5a 100644
--- a/packages/contracts/src/contracts/current/test/ExchangeWrapper/ExchangeWrapper.sol
+++ b/packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol
diff --git a/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol b/packages/contracts/src/2.0.0/test/Mintable/Mintable.sol
index a91bfee9e..a91bfee9e 100644
--- a/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol
+++ b/packages/contracts/src/2.0.0/test/Mintable/Mintable.sol
diff --git a/packages/contracts/src/contracts/current/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol
index 2ae69e0ef..2ae69e0ef 100644
--- a/packages/contracts/src/contracts/current/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol
+++ b/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol
diff --git a/packages/contracts/src/contracts/current/test/TestAssetProxyOwner/TestAssetProxyOwner.sol b/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol
index 2abcd17a0..2abcd17a0 100644
--- a/packages/contracts/src/contracts/current/test/TestAssetProxyOwner/TestAssetProxyOwner.sol
+++ b/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol
diff --git a/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol b/packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol
index f45faaf36..f45faaf36 100644
--- a/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol
+++ b/packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol
diff --git a/packages/contracts/src/contracts/current/test/TestLibs/TestLibs.sol b/packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol
index 010080703..010080703 100644
--- a/packages/contracts/src/contracts/current/test/TestLibs/TestLibs.sol
+++ b/packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol
diff --git a/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol b/packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol
index 0f84678cf..0f84678cf 100644
--- a/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol
+++ b/packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol
diff --git a/packages/contracts/src/contracts/current/test/TestValidator/TestValidator.sol b/packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol
index f9271bf7a..f9271bf7a 100644
--- a/packages/contracts/src/contracts/current/test/TestValidator/TestValidator.sol
+++ b/packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol
diff --git a/packages/contracts/src/contracts/current/test/TestWallet/TestWallet.sol b/packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol
index 17dee9e9c..17dee9e9c 100644
--- a/packages/contracts/src/contracts/current/test/TestWallet/TestWallet.sol
+++ b/packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol
diff --git a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol b/packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol
index 8b52858b1..8b52858b1 100644
--- a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
+++ b/packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol
diff --git a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol b/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol
index b6961a6ec..b6961a6ec 100644
--- a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol
+++ b/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol
diff --git a/packages/contracts/src/contracts/current/tokens/ERC20Token/IERC20Token.sol b/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol
index eb879b6a8..eb879b6a8 100644
--- a/packages/contracts/src/contracts/current/tokens/ERC20Token/IERC20Token.sol
+++ b/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol
diff --git a/packages/contracts/src/contracts/current/tokens/ERC721Token/ERC721Token.sol b/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol
index 41ba149e3..41ba149e3 100644
--- a/packages/contracts/src/contracts/current/tokens/ERC721Token/ERC721Token.sol
+++ b/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol
diff --git a/packages/contracts/src/contracts/current/tokens/ERC721Token/IERC721Receiver.sol b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol
index b0fff3c90..b0fff3c90 100644
--- a/packages/contracts/src/contracts/current/tokens/ERC721Token/IERC721Receiver.sol
+++ b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol
diff --git a/packages/contracts/src/contracts/current/tokens/ERC721Token/IERC721Token.sol b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol
index 345712d67..345712d67 100644
--- a/packages/contracts/src/contracts/current/tokens/ERC721Token/IERC721Token.sol
+++ b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol
diff --git a/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol b/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol
index f62602ab3..f62602ab3 100644
--- a/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol
+++ b/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol
diff --git a/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol b/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol
index 733ca414b..733ca414b 100644
--- a/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol
+++ b/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol
diff --git a/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol b/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol
index 2d8e74f2c..2e5b61e0b 100644
--- a/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol
+++ b/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.11;
-import { UnlimitedAllowanceToken_v1 as UnlimitedAllowanceToken } from "../../../previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol";
+import { UnlimitedAllowanceToken_v1 as UnlimitedAllowanceToken } from "../../../1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol";
contract ZRXToken is UnlimitedAllowanceToken {
diff --git a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol b/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol
index 78b1ddf7c..78b1ddf7c 100644
--- a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol
+++ b/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol
diff --git a/packages/contracts/src/contracts/current/utils/Ownable/IOwnable.sol b/packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol
index e77680903..e77680903 100644
--- a/packages/contracts/src/contracts/current/utils/Ownable/IOwnable.sol
+++ b/packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol
diff --git a/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol b/packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol
index 6f5761cc7..6f5761cc7 100644
--- a/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol
+++ b/packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol
diff --git a/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol b/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol
index e137f6ca5..e137f6ca5 100644
--- a/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol
+++ b/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol
deleted file mode 100644
index b4780b52b..000000000
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
-
- Copyright 2018 ZeroEx Intl.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-pragma solidity ^0.4.24;
-pragma experimental ABIEncoderV2;
-
-import "../../utils/LibBytes/LibBytes.sol";
-import "./interfaces/IAssetProxy.sol";
-import "./MixinAuthorizable.sol";
-
-contract ERC20Proxy is
- IAssetProxy,
- MixinAuthorizable
-{
- // Id of this proxy.
- bytes4 constant PROXY_ID = bytes4(keccak256("ERC20Token(address)"));
-
- /// @dev Internal version of `transferFrom`.
- /// @param assetData Encoded byte array.
- /// @param from Address to transfer asset from.
- /// @param to Address to transfer asset to.
- /// @param amount Amount of asset to transfer.
- function transferFrom(
- bytes assetData,
- address from,
- address to,
- uint256 amount
- )
- external
- {
- require(
- authorized[msg.sender],
- "SENDER_NOT_AUTHORIZED"
- );
-
- // `transferFrom`.
- // The function is marked `external`, so no abi decodeding is done for
- // us. Instead, we expect the `calldata` memory to contain the
- // following:
- //
- // | Area | Offset | Length | Contents |
- // |----------|--------|---------|-------------------------------------|
- // | Header | 0 | 4 | function selector |
- // | Params | | 4 * 32 | function parameters: |
- // | | 4 | | 1. offset to assetData (*) |
- // | | 36 | | 2. from |
- // | | 68 | | 3. to |
- // | | 100 | | 4. amount |
- // | Data | | | assetData: |
- // | | 132 | 32 | assetData Length |
- // | | 164 | ** | assetData Contents |
- //
- // (*): offset is computed from start of function parameters, so offset
- // by an additional 4 bytes in the calldata.
- //
- // WARNING: The ABIv2 specification allows additional padding between
- // the Params and Data section. This will result in a larger
- // offset to assetData.
-
- // Asset data itself is encoded as follows:
- //
- // | Area | Offset | Length | Contents |
- // |----------|--------|---------|-------------------------------------|
- // | Header | 0 | 4 | function selector |
- // | Params | | 1 * 32 | function parameters: |
- // | | 4 | 12 + 20 | 1. token address |
-
- // Transfer tokens.
- // We do a raw call so we can check the success separate
- // from the return data.
- // We construct calldata for the `token.transferFrom` ABI.
- // The layout of this calldata is in the table below.
- //
- // | Area | Offset | Length | Contents |
- // |----------|--------|---------|-------------------------------------|
- // | Header | 0 | 4 | function selector |
- // | Params | | 3 * 32 | function parameters: |
- // | | 4 | | 1. from |
- // | | 36 | | 2. to |
- // | | 68 | | 3. amount |
-
- assembly {
- /////// Token contract address ///////
- // The token address is found as follows:
- // * It is stored at offset 4 in `assetData` contents.
- // * This is stored at offset 32 from `assetData`.
- // * The offset to `assetData` from Params is stored at offset
- // 4 in calldata.
- // * The offset of Params in calldata is 4.
- // So we read location 4 and add 32 + 4 + 4 to it.
- let token := calldataload(add(calldataload(4), 40))
-
- /////// Setup Header Area ///////
- // This area holds the 4-byte `transferFrom` selector.
- // Any trailing data in transferFromSelector will be
- // overwritten in the next `mstore` call.
- mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
-
- /////// Setup Params Area ///////
- // We copy the fields `from`, `to` and `amount` in bulk
- // from our own calldata to the new calldata.
- calldatacopy(4, 36, 96)
-
- /////// Call `token.transferFrom` using the calldata ///////
- let success := call(
- gas, // forward all gas
- token, // call address of token contract
- 0, // don't send any ETH
- 0, // pointer to start of input
- 100, // length of input
- 0, // write output over input
- 32 // output size should be 32 bytes
- )
-
- /////// Check return data. ///////
- // If there is no return data, we assume the token incorrectly
- // does not return a bool. In this case we expect it to revert
- // on failure, which was handled above.
- // If the token does return data, we require that it is a single
- // nonzero 32 bytes value.
- // So the transfer succeeded if the call succeeded and either
- // returned nothing, or returned a non-zero 32 byte value.
- success := and(success, or(
- iszero(returndatasize),
- and(
- eq(returndatasize, 32),
- gt(mload(0), 0)
- )
- ))
- if success {
- return(0, 0)
- }
-
- // Revert with `Error("TRANSFER_FAILED")`
- mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
- mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
- mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
- mstore(96, 0)
- revert(0, 100)
- }
- }
-
- /// @dev Gets the proxy id associated with the proxy address.
- /// @return Proxy id.
- function getProxyId()
- external
- view
- returns (bytes4)
- {
- return PROXY_ID;
- }
-}
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol
deleted file mode 100644
index 8d7cea717..000000000
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
-
- Copyright 2018 ZeroEx Intl.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-pragma solidity ^0.4.24;
-pragma experimental ABIEncoderV2;
-
-import "../../utils/LibBytes/LibBytes.sol";
-import "./interfaces/IAssetProxy.sol";
-import "./MixinAuthorizable.sol";
-
-contract ERC721Proxy is
- IAssetProxy,
- MixinAuthorizable
-{
- // Id of this proxy.
- bytes4 constant PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)"));
-
- /// @dev Internal version of `transferFrom`.
- /// @param assetData Encoded byte array.
- /// @param from Address to transfer asset from.
- /// @param to Address to transfer asset to.
- /// @param amount Amount of asset to transfer.
- function transferFrom(
- bytes assetData,
- address from,
- address to,
- uint256 amount
- )
- external
- {
- require(
- authorized[msg.sender],
- "SENDER_NOT_AUTHORIZED"
- );
-
- // `transferFrom`.
- // The function is marked `external`, so no abi decodeding is done for
- // us. Instead, we expect the `calldata` memory to contain the
- // following:
- //
- // | Area | Offset | Length | Contents |
- // |----------|--------|---------|-------------------------------------|
- // | Header | 0 | 4 | function selector |
- // | Params | | 4 * 32 | function parameters: |
- // | | 4 | | 1. offset to assetData (*) |
- // | | 36 | | 2. from |
- // | | 68 | | 3. to |
- // | | 100 | | 4. amount |
- // | Data | | | assetData: |
- // | | 132 | 32 | assetData Length |
- // | | 164 | ** | assetData Contents |
- //
- // (*): offset is computed from start of function parameters, so offset
- // by an additional 4 bytes in the calldata.
- //
- // WARNING: The ABIv2 specification allows additional padding between
- // the Params and Data section. This will result in a larger
- // offset to assetData.
-
- // Asset data itself is encoded as follows:
- //
- // | Area | Offset | Length | Contents |
- // |----------|--------|---------|-------------------------------------|
- // | Header | 0 | 4 | function selector |
- // | Params | | 3 * 32 | function parameters: |
- // | | 4 | 12 + 20 | 1. token address |
- // | | 36 | | 2. tokenId |
- // | | 68 | | 3. offset to receiverData (*) |
- // | Data | | | receiverData: |
- // | | 100 | 32 | receiverData Length |
- // | | 132 | ** | receiverData Contents |
-
- // We construct calldata for the `token.safeTransferFrom` ABI.
- // The layout of this calldata is in the table below.
- //
- // | Area | Offset | Length | Contents |
- // |----------|--------|---------|-------------------------------------|
- // | Header | 0 | 4 | function selector |
- // | Params | | 4 * 32 | function parameters: |
- // | | 4 | | 1. from |
- // | | 36 | | 2. to |
- // | | 68 | | 3. tokenId |
- // | | 100 | | 4. offset to receiverData (*) |
- // | Data | | | receiverData: |
- // | | 132 | 32 | receiverData Length |
- // | | 164 | ** | receiverData Contents |
-
- assembly {
- // There exists only 1 of each token.
- // require(amount == 1, "INVALID_AMOUNT")
- if sub(calldataload(100), 1) {
- // Revert with `Error("INVALID_AMOUNT")`
- mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
- mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
- mstore(64, 0x0000000e494e56414c49445f414d4f554e540000000000000000000000000000)
- mstore(96, 0)
- revert(0, 100)
- }
-
- // Require assetData to be at least 132 bytes
- let offset := calldataload(4)
- if lt(calldataload(add(offset, 4)), 132) {
- // Revert with `Error("LENGTH_GREATER_THAN_131_REQUIRED")`
- mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
- mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
- mstore(64, 0x000000204c454e4754485f475245415445525f5448414e5f3133315f52455155)
- mstore(96, 0x4952454400000000000000000000000000000000000000000000000000000000)
- revert(0, 100)
- }
-
- /////// Setup State ///////
- // `cdStart` is the start of the calldata for
- // `token.safeTransferFrom` (equal to free memory ptr).
- let cdStart := mload(64)
- // `dataAreaLength` is the total number of words
- // needed to store `receiverData`
- // As-per the ABI spec, this value is padded up to
- // the nearest multiple of 32,
- // and includes 32-bytes for length.
- // It's calculated as folows:
- // - Unpadded length in bytes = `mload(receiverData) + 32`
- // - Add 31 to convert rounding down to rounding up.
- // Combined with the previous and this is `63`.
- // - Round down to nearest multiple of 32 by clearing
- // bits 0x1F. This is done with `and` and a mask.
-
- /////// Setup Header Area ///////
- // This area holds the 4-byte `transferFromSelector`.
- // Any trailing data in transferFromSelector will be
- // overwritten in the next `mstore` call.
- mstore(cdStart, 0xb88d4fde00000000000000000000000000000000000000000000000000000000)
-
- /////// Setup Params Area ///////
- // Each parameter is padded to 32-bytes.
- // The entire Params Area is 128 bytes.
- // Notes:
- // 1. A 20-byte mask is applied to addresses
- // to zero-out the unused bytes.
- // 2. The offset to `receiverData` is the length
- // of the Params Area (128 bytes).
-
- let length := calldataload(add(offset, 136))
- let token := calldataload(add(offset, 40))
-
- // Round length up to multiple of 32
- length := and(add(length, 31), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0)
-
- // Copy `from` and `to`
- calldatacopy(add(cdStart, 4), 36, 64)
-
- // TokenId
- mstore(add(cdStart, 68), calldataload(add(offset, 72)))
-
- // Offset to receiverData
- mstore(add(cdStart, 100), 128)
-
- // receiverData (including length)
- calldatacopy(add(cdStart, 132), add(offset, 136), add(length, 32))
-
- /////// Call `token.safeTransferFrom` using the calldata ///////
- let success := call(
- gas, // forward all gas
- token, // call address of token contract
- 0, // don't send any ETH
- cdStart, // pointer to start of input
- add(length, 164), // length of input
- 0, // write output to null
- 0 // output size is 0 bytes
- )
- if success {
- return(0, 0)
- }
-
- // Revert with `Error("TRANSFER_FAILED")`
- mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
- mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
- mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
- mstore(96, 0)
- revert(0, 100)
- }
- }
-
- /// @dev Gets the proxy id associated with the proxy address.
- /// @return Proxy id.
- function getProxyId()
- external
- view
- returns (bytes4)
- {
- return PROXY_ID;
- }
-}
diff --git a/packages/contracts/src/utils/artifacts.ts b/packages/contracts/src/utils/artifacts.ts
deleted file mode 100644
index d58e7973c..000000000
--- a/packages/contracts/src/utils/artifacts.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { ContractArtifact } from '@0xproject/sol-compiler';
-
-import * as AssetProxyOwner from '../artifacts/AssetProxyOwner.json';
-import * as DummyERC20Token from '../artifacts/DummyERC20Token.json';
-import * as DummyERC721Receiver from '../artifacts/DummyERC721Receiver.json';
-import * as DummyERC721Token from '../artifacts/DummyERC721Token.json';
-import * as ERC20Proxy from '../artifacts/ERC20Proxy.json';
-import * as ERC721Proxy from '../artifacts/ERC721Proxy.json';
-import * as Exchange from '../artifacts/Exchange.json';
-import * as ExchangeWrapper from '../artifacts/ExchangeWrapper.json';
-import * as MixinAuthorizable from '../artifacts/MixinAuthorizable.json';
-import * as MultiSigWallet from '../artifacts/MultiSigWallet.json';
-import * as MultiSigWalletWithTimeLock from '../artifacts/MultiSigWalletWithTimeLock.json';
-import * as TestAssetProxyDispatcher from '../artifacts/TestAssetProxyDispatcher.json';
-import * as TestAssetProxyOwner from '../artifacts/TestAssetProxyOwner.json';
-import * as TestLibBytes from '../artifacts/TestLibBytes.json';
-import * as TestLibs from '../artifacts/TestLibs.json';
-import * as TestSignatureValidator from '../artifacts/TestSignatureValidator.json';
-import * as TestValidator from '../artifacts/TestValidator.json';
-import * as TestWallet from '../artifacts/TestWallet.json';
-import * as TokenRegistry from '../artifacts/TokenRegistry.json';
-import * as EtherToken from '../artifacts/WETH9.json';
-import * as Whitelist from '../artifacts/Whitelist.json';
-import * as ZRX from '../artifacts/ZRXToken.json';
-
-export const artifacts = {
- AssetProxyOwner: (AssetProxyOwner as any) as ContractArtifact,
- DummyERC20Token: (DummyERC20Token as any) as ContractArtifact,
- DummyERC721Receiver: (DummyERC721Receiver as any) as ContractArtifact,
- DummyERC721Token: (DummyERC721Token as any) as ContractArtifact,
- ERC20Proxy: (ERC20Proxy as any) as ContractArtifact,
- ERC721Proxy: (ERC721Proxy as any) as ContractArtifact,
- Exchange: (Exchange as any) as ContractArtifact,
- ExchangeWrapper: (ExchangeWrapper as any) as ContractArtifact,
- EtherToken: (EtherToken as any) as ContractArtifact,
- MixinAuthorizable: (MixinAuthorizable as any) as ContractArtifact,
- MultiSigWallet: (MultiSigWallet as any) as ContractArtifact,
- MultiSigWalletWithTimeLock: (MultiSigWalletWithTimeLock as any) as ContractArtifact,
- TestAssetProxyOwner: (TestAssetProxyOwner as any) as ContractArtifact,
- TestAssetProxyDispatcher: (TestAssetProxyDispatcher as any) as ContractArtifact,
- TestLibBytes: (TestLibBytes as any) as ContractArtifact,
- TestLibs: (TestLibs as any) as ContractArtifact,
- TestSignatureValidator: (TestSignatureValidator as any) as ContractArtifact,
- TestValidator: (TestValidator as any) as ContractArtifact,
- TestWallet: (TestWallet as any) as ContractArtifact,
- TokenRegistry: (TokenRegistry as any) as ContractArtifact,
- Whitelist: (Whitelist as any) as ContractArtifact,
- ZRX: (ZRX as any) as ContractArtifact,
-};
diff --git a/packages/contracts/src/utils/assertions.ts b/packages/contracts/src/utils/assertions.ts
deleted file mode 100644
index e702a3200..000000000
--- a/packages/contracts/src/utils/assertions.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import { RevertReason } from '@0xproject/types';
-import * as chai from 'chai';
-import * as _ from 'lodash';
-
-import { constants } from './constants';
-
-const expect = chai.expect;
-
-function _expectEitherErrorAsync<T>(p: Promise<T>, error1: string, error2: string): PromiseLike<void> {
- return expect(p)
- .to.be.rejected()
- .then(e => {
- expect(e).to.satisfy(
- (err: Error) => _.includes(err.message, error1) || _.includes(err.message, error2),
- `expected promise to reject with error message that includes "${error1}" or "${error2}", but got: ` +
- `"${e.message}"\n`,
- );
- });
-}
-
-/**
- * Rejects if the given Promise does not reject with an error indicating
- * insufficient funds.
- * @param p the Promise which is expected to reject
- * @returns a new Promise which will reject if the conditions are not met and
- * otherwise resolve with no value.
- */
-export function expectInsufficientFundsAsync<T>(p: Promise<T>): PromiseLike<void> {
- return _expectEitherErrorAsync(p, 'insufficient funds', "sender doesn't have enough funds");
-}
-
-/**
- * Rejects if the given Promise does not reject with a "revert" error or the
- * given otherError.
- * @param p the Promise which is expected to reject
- * @param otherError the other error which is accepted as a valid reject error.
- * @returns a new Promise which will reject if the conditions are not met and
- * otherwise resolve with no value.
- */
-export function expectRevertOrOtherErrorAsync<T>(p: Promise<T>, otherError: string): PromiseLike<void> {
- return _expectEitherErrorAsync(p, constants.REVERT, otherError);
-}
-
-/**
- * Rejects if the given Promise does not reject with a "revert" or "always
- * failing transaction" error.
- * @param p the Promise which is expected to reject
- * @returns a new Promise which will reject if the conditions are not met and
- * otherwise resolve with no value.
- */
-export function expectRevertOrAlwaysFailingTransactionAsync<T>(p: Promise<T>): PromiseLike<void> {
- return expectRevertOrOtherErrorAsync(p, 'always failing transaction');
-}
-
-/**
- * Rejects if the given Promise does not reject with the given revert reason or "always
- * failing transaction" error.
- * @param p the Promise which is expected to reject
- * @param reason a specific revert reason
- * @returns a new Promise which will reject if the conditions are not met and
- * otherwise resolve with no value.
- */
-export function expectRevertReasonOrAlwaysFailingTransactionAsync<T>(
- p: Promise<T>,
- reason: RevertReason,
-): PromiseLike<void> {
- return _expectEitherErrorAsync(p, 'always failing transaction', reason);
-}
-
-/**
- * Rejects if the given Promise does not reject with a "revert" or "Contract
- * call failed" error.
- * @param p the Promise which is expected to reject
- * @returns a new Promise which will reject if the conditions are not met and
- * otherwise resolve with no value.
- */
-export function expectRevertOrContractCallFailedAsync<T>(p: Promise<T>): PromiseLike<void> {
- return expectRevertOrOtherErrorAsync<T>(p, 'Contract call failed');
-}
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts
index 8c9d0495d..e99c6cee3 100644
--- a/packages/contracts/test/asset_proxy/authorizable.ts
+++ b/packages/contracts/test/asset_proxy/authorizable.ts
@@ -3,12 +3,12 @@ import { RevertReason } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
-import { MixinAuthorizableContract } from '../../src/generated_contract_wrappers/mixin_authorizable';
-import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+import { MixinAuthorizableContract } from '../../generated_contract_wrappers/mixin_authorizable';
+import { artifacts } from '../utils/artifacts';
+import { expectTransactionFailedAsync } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -44,7 +44,7 @@ describe('Authorizable', () => {
});
describe('addAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }),
RevertReason.OnlyContractOwner,
);
@@ -62,7 +62,7 @@ describe('Authorizable', () => {
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
RevertReason.TargetAlreadyAuthorized,
);
@@ -75,7 +75,7 @@ describe('Authorizable', () => {
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
from: notOwner,
}),
@@ -99,7 +99,7 @@ describe('Authorizable', () => {
});
it('should throw if owner attempts to remove an address that is not authorized', async () => {
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
from: owner,
}),
@@ -115,7 +115,7 @@ describe('Authorizable', () => {
constants.AWAIT_TRANSACTION_MINED_MS,
);
const index = new BigNumber(0);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
from: notOwner,
}),
@@ -128,7 +128,7 @@ describe('Authorizable', () => {
constants.AWAIT_TRANSACTION_MINED_MS,
);
const index = new BigNumber(1);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
from: owner,
}),
@@ -137,7 +137,7 @@ describe('Authorizable', () => {
});
it('should throw if owner attempts to remove an address that is not authorized', async () => {
const index = new BigNumber(0);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
from: owner,
}),
@@ -156,7 +156,7 @@ describe('Authorizable', () => {
constants.AWAIT_TRANSACTION_MINED_MS,
);
const address1Index = new BigNumber(0);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, {
from: owner,
}),
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index 39121d95c..bf9f9bc3e 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -7,26 +7,32 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c20_token';
+import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c20_token';
import {
DummyERC721ReceiverContract,
TokenReceivedContractEventArgs,
-} from '../../src/generated_contract_wrappers/dummy_e_r_c721_receiver';
-import { DummyERC721TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c721_token';
-import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c20_proxy';
-import { ERC721ProxyContract } from '../../src/generated_contract_wrappers/e_r_c721_proxy';
-import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
-import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
-import { LogDecoder } from '../../src/utils/log_decoder';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+} from '../../generated_contract_wrappers/dummy_e_r_c721_receiver';
+import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c721_token';
+import { ERC20ProxyContract } from '../../generated_contract_wrappers/e_r_c20_proxy';
+import { ERC721ProxyContract } from '../../generated_contract_wrappers/e_r_c721_proxy';
+import { IAssetProxyContract } from '../../generated_contract_wrappers/i_asset_proxy';
+import { artifacts } from '../utils/artifacts';
+import { expectTransactionFailedAsync } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { ERC20Wrapper } from '../utils/erc20_wrapper';
+import { ERC721Wrapper } from '../utils/erc721_wrapper';
+import { LogDecoder } from '../utils/log_decoder';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
+const assetProxyInterface = new IAssetProxyContract(
+ artifacts.IAssetProxy.compilerOutput.abi,
+ constants.NULL_ADDRESS,
+ provider,
+);
// tslint:disable:no-unnecessary-type-assertion
describe('Asset Transfer Proxies', () => {
@@ -105,14 +111,18 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(10);
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ takerAddress,
+ amount,
+ );
await web3Wrapper.awaitTransactionSuccessAsync(
- await erc20Proxy.transferFrom.sendTransactionAsync(
- encodedAssetData,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
- ),
+ await web3Wrapper.sendTransactionAsync({
+ to: erc20Proxy.address,
+ data,
+ from: exchangeAddress,
+ }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
@@ -131,14 +141,18 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(0);
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ takerAddress,
+ amount,
+ );
await web3Wrapper.awaitTransactionSuccessAsync(
- await erc20Proxy.transferFrom.sendTransactionAsync(
- encodedAssetData,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
- ),
+ await web3Wrapper.sendTransactionAsync({
+ to: erc20Proxy.address,
+ data,
+ from: exchangeAddress,
+ }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
@@ -156,7 +170,13 @@ describe('Asset Transfer Proxies', () => {
const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
// Create allowance less than transfer amount. Set allowance on proxy.
const allowance = new BigNumber(0);
- const transferAmount = new BigNumber(10);
+ const amount = new BigNumber(10);
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ takerAddress,
+ amount,
+ );
await web3Wrapper.awaitTransactionSuccessAsync(
await zrxToken.approve.sendTransactionAsync(erc20Proxy.address, allowance, {
from: makerAddress,
@@ -164,14 +184,12 @@ describe('Asset Transfer Proxies', () => {
constants.AWAIT_TRANSACTION_MINED_MS,
);
// Perform a transfer; expect this to fail.
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- erc20Proxy.transferFrom.sendTransactionAsync(
- encodedAssetData,
- makerAddress,
- takerAddress,
- transferAmount,
- { from: exchangeAddress },
- ),
+ await expectTransactionFailedAsync(
+ web3Wrapper.sendTransactionAsync({
+ to: erc20Proxy.address,
+ data,
+ from: exchangeAddress,
+ }),
RevertReason.TransferFailed,
);
});
@@ -179,11 +197,18 @@ describe('Asset Transfer Proxies', () => {
it('should throw if requesting address is not authorized', async () => {
// Construct ERC20 asset data
const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
-
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(10);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- erc20Proxy.transferFrom.sendTransactionAsync(encodedAssetData, makerAddress, takerAddress, amount, {
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ takerAddress,
+ amount,
+ );
+ await expectTransactionFailedAsync(
+ web3Wrapper.sendTransactionAsync({
+ to: erc20Proxy.address,
+ data,
from: notAuthorized,
}),
RevertReason.SenderNotAuthorized,
@@ -208,14 +233,18 @@ describe('Asset Transfer Proxies', () => {
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(1);
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ takerAddress,
+ amount,
+ );
await web3Wrapper.awaitTransactionSuccessAsync(
- await erc721Proxy.transferFrom.sendTransactionAsync(
- encodedAssetData,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
- ),
+ await web3Wrapper.sendTransactionAsync({
+ to: erc721Proxy.address,
+ data,
+ from: exchangeAddress,
+ }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
@@ -231,17 +260,21 @@ describe('Asset Transfer Proxies', () => {
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(1);
- const txHash = await erc721Proxy.transferFrom.sendTransactionAsync(
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
encodedAssetData,
makerAddress,
erc721Receiver.address,
amount,
- { from: exchangeAddress },
);
- await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
- // Parse transaction logs
const logDecoder = new LogDecoder(web3Wrapper, erc721Receiver.address);
- const tx = await logDecoder.getTxWithDecodedLogsAsync(txHash);
+ const tx = await logDecoder.getTxWithDecodedLogsAsync(
+ await web3Wrapper.sendTransactionAsync({
+ to: erc721Proxy.address,
+ data,
+ from: exchangeAddress,
+ gas: constants.TRANSFER_FROM_GAS,
+ }),
+ );
// Verify that no log was emitted by erc721 receiver
expect(tx.logs.length).to.be.equal(1);
const tokenReceivedLog = tx.logs[0] as LogWithDecodedArgs<TokenReceivedContractEventArgs>;
@@ -266,17 +299,21 @@ describe('Asset Transfer Proxies', () => {
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(1);
- const txHash = await erc721Proxy.transferFrom.sendTransactionAsync(
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
encodedAssetData,
makerAddress,
erc721Receiver.address,
amount,
- { from: exchangeAddress },
);
- await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
- // Parse transaction logs
const logDecoder = new LogDecoder(web3Wrapper, erc721Receiver.address);
- const tx = await logDecoder.getTxWithDecodedLogsAsync(txHash);
+ const tx = await logDecoder.getTxWithDecodedLogsAsync(
+ await web3Wrapper.sendTransactionAsync({
+ to: erc721Proxy.address,
+ data,
+ from: exchangeAddress,
+ gas: constants.TRANSFER_FROM_GAS,
+ }),
+ );
// Validate log emitted by erc721 receiver
expect(tx.logs.length).to.be.equal(1);
const tokenReceivedLog = tx.logs[0] as LogWithDecodedArgs<TokenReceivedContractEventArgs>;
@@ -301,14 +338,19 @@ describe('Asset Transfer Proxies', () => {
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(1);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- erc721Proxy.transferFrom.sendTransactionAsync(
- encodedAssetData,
- makerAddress,
- erc20Proxy.address, // the ERC20 proxy does not have an ERC721 receiver
- amount,
- { from: exchangeAddress },
- ),
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ erc20Proxy.address, // the ERC20 proxy does not have an ERC721 receiver
+ amount,
+ );
+ return expectTransactionFailedAsync(
+ web3Wrapper.sendTransactionAsync({
+ to: erc721Proxy.address,
+ data,
+ from: exchangeAddress,
+ gas: constants.TRANSFER_FROM_GAS,
+ }),
RevertReason.TransferFailed,
);
});
@@ -321,14 +363,18 @@ describe('Asset Transfer Proxies', () => {
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(0);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- erc721Proxy.transferFrom.sendTransactionAsync(
- encodedAssetData,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
- ),
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ takerAddress,
+ amount,
+ );
+ return expectTransactionFailedAsync(
+ web3Wrapper.sendTransactionAsync({
+ to: erc721Proxy.address,
+ data,
+ from: exchangeAddress,
+ }),
RevertReason.InvalidAmount,
);
});
@@ -341,14 +387,18 @@ describe('Asset Transfer Proxies', () => {
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(500);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- erc721Proxy.transferFrom.sendTransactionAsync(
- encodedAssetData,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
- ),
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ takerAddress,
+ amount,
+ );
+ return expectTransactionFailedAsync(
+ web3Wrapper.sendTransactionAsync({
+ to: erc721Proxy.address,
+ data,
+ from: exchangeAddress,
+ }),
RevertReason.InvalidAmount,
);
});
@@ -358,15 +408,23 @@ describe('Asset Transfer Proxies', () => {
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
// Remove transfer approval for makerAddress.
await web3Wrapper.awaitTransactionSuccessAsync(
- await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, false, {
+ await erc721Token.approve.sendTransactionAsync(constants.NULL_ADDRESS, erc721MakerTokenId, {
from: makerAddress,
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
// Perform a transfer; expect this to fail.
const amount = new BigNumber(1);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- erc20Proxy.transferFrom.sendTransactionAsync(encodedAssetData, makerAddress, takerAddress, amount, {
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ takerAddress,
+ amount,
+ );
+ return expectTransactionFailedAsync(
+ web3Wrapper.sendTransactionAsync({
+ to: erc721Proxy.address,
+ data,
from: exchangeAddress,
}),
RevertReason.TransferFailed,
@@ -378,14 +436,18 @@ describe('Asset Transfer Proxies', () => {
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(1);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- erc721Proxy.transferFrom.sendTransactionAsync(
- encodedAssetData,
- makerAddress,
- takerAddress,
- amount,
- { from: notAuthorized },
- ),
+ const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
+ encodedAssetData,
+ makerAddress,
+ takerAddress,
+ amount,
+ );
+ return expectTransactionFailedAsync(
+ web3Wrapper.sendTransactionAsync({
+ to: erc721Proxy.address,
+ data,
+ from: notAuthorized,
+ }),
RevertReason.SenderNotAuthorized,
);
});
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 0c7381aac..4e70893fc 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -1,6 +1,6 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { assetProxyUtils, orderHashUtils } from '@0xproject/order-utils';
-import { AssetProxyId, RevertReason, SignedOrder } from '@0xproject/types';
+import { RevertReason, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
@@ -8,21 +8,21 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c20_token';
-import { DummyERC721TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c721_token';
-import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c20_proxy';
-import { ERC721ProxyContract } from '../../src/generated_contract_wrappers/e_r_c721_proxy';
-import { CancelContractEventArgs, ExchangeContract } from '../../src/generated_contract_wrappers/exchange';
-import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
-import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
-import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
-import { OrderFactory } from '../../src/utils/order_factory';
-import { ERC20BalancesByOwner } from '../../src/utils/types';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c20_token';
+import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c721_token';
+import { ERC20ProxyContract } from '../../generated_contract_wrappers/e_r_c20_proxy';
+import { ERC721ProxyContract } from '../../generated_contract_wrappers/e_r_c721_proxy';
+import { CancelContractEventArgs, ExchangeContract } from '../../generated_contract_wrappers/exchange';
+import { artifacts } from '../utils/artifacts';
+import { expectTransactionFailedAsync } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { ERC20Wrapper } from '../utils/erc20_wrapper';
+import { ERC721Wrapper } from '../utils/erc721_wrapper';
+import { ExchangeWrapper } from '../utils/exchange_wrapper';
+import { OrderFactory } from '../utils/order_factory';
+import { ERC20BalancesByOwner } from '../utils/types';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -90,8 +90,8 @@ describe('Exchange core', () => {
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
);
exchangeWrapper = new ExchangeWrapper(exchange, provider);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
+ await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
+ await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner);
await web3Wrapper.awaitTransactionSuccessAsync(
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
@@ -144,7 +144,7 @@ describe('Exchange core', () => {
const invalidSigBuff = Buffer.concat([v, invalidR, invalidS, signatureType]);
const invalidSigHex = `0x${invalidSigBuff.toString('hex')}`;
signedOrder.signature = invalidSigHex;
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress),
RevertReason.InvalidOrderSignature,
);
@@ -153,7 +153,7 @@ describe('Exchange core', () => {
it('should throw if no value is filled', async () => {
signedOrder = orderFactory.newSignedOrder();
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress),
RevertReason.OrderUnfillable,
);
@@ -167,7 +167,7 @@ describe('Exchange core', () => {
});
it('should throw if not sent by maker', async () => {
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.cancelOrderAsync(signedOrder, takerAddress),
RevertReason.InvalidMaker,
);
@@ -178,7 +178,7 @@ describe('Exchange core', () => {
makerAssetAmount: new BigNumber(0),
});
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress),
RevertReason.OrderUnfillable,
);
@@ -189,7 +189,7 @@ describe('Exchange core', () => {
takerAssetAmount: new BigNumber(0),
});
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress),
RevertReason.OrderUnfillable,
);
@@ -197,7 +197,7 @@ describe('Exchange core', () => {
it('should be able to cancel a full order', async () => {
await exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
takerAssetFillAmount: signedOrder.takerAssetAmount.div(2),
}),
@@ -222,7 +222,7 @@ describe('Exchange core', () => {
it('should throw if already cancelled', async () => {
await exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress),
RevertReason.OrderUnfillable,
);
@@ -232,7 +232,7 @@ describe('Exchange core', () => {
signedOrder = orderFactory.newSignedOrder({
expirationTimeSeconds: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress),
RevertReason.OrderUnfillable,
);
@@ -250,7 +250,7 @@ describe('Exchange core', () => {
});
const fillTakerAssetAmount2 = new BigNumber(1);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
takerAssetFillAmount: fillTakerAssetAmount2,
}),
@@ -264,7 +264,7 @@ describe('Exchange core', () => {
const orderEpoch = new BigNumber(1);
await exchangeWrapper.cancelOrdersUpToAsync(orderEpoch, makerAddress);
const lesserOrderEpoch = new BigNumber(0);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.cancelOrdersUpToAsync(lesserOrderEpoch, makerAddress),
RevertReason.InvalidNewOrderEpoch,
);
@@ -273,7 +273,7 @@ describe('Exchange core', () => {
it('should fail to set orderEpoch equal to existing orderEpoch', async () => {
const orderEpoch = new BigNumber(1);
await exchangeWrapper.cancelOrdersUpToAsync(orderEpoch, makerAddress);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.cancelOrdersUpToAsync(orderEpoch, makerAddress),
RevertReason.InvalidNewOrderEpoch,
);
@@ -363,7 +363,7 @@ describe('Exchange core', () => {
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerAssetFillAmount = signedOrder.takerAssetAmount;
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
RevertReason.TransferFailed,
);
@@ -386,7 +386,7 @@ describe('Exchange core', () => {
expect(initialOwnerTakerAsset).to.be.bignumber.not.equal(takerAddress);
// Call Exchange
const takerAssetFillAmount = signedOrder.takerAssetAmount;
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
RevertReason.TransferFailed,
);
@@ -409,7 +409,7 @@ describe('Exchange core', () => {
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerAssetFillAmount = signedOrder.takerAssetAmount;
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
RevertReason.InvalidAmount,
);
@@ -432,7 +432,7 @@ describe('Exchange core', () => {
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerAssetFillAmount = signedOrder.takerAssetAmount;
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
RevertReason.InvalidAmount,
);
@@ -449,7 +449,7 @@ describe('Exchange core', () => {
});
// Call Exchange
const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
RevertReason.RoundingError,
);
@@ -475,7 +475,7 @@ describe('Exchange core', () => {
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerAssetFillAmount = signedOrder.takerAssetAmount;
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
RevertReason.LengthGreaterThan131Required,
);
diff --git a/packages/contracts/test/exchange/dispatcher.ts b/packages/contracts/test/exchange/dispatcher.ts
index e35cca845..94ada1ef2 100644
--- a/packages/contracts/test/exchange/dispatcher.ts
+++ b/packages/contracts/test/exchange/dispatcher.ts
@@ -3,24 +3,29 @@ import { assetProxyUtils } from '@0xproject/order-utils';
import { AssetProxyId, RevertReason } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
+import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c20_token';
-import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c20_proxy';
-import { ERC721ProxyContract } from '../../src/generated_contract_wrappers/e_r_c721_proxy';
-import { TestAssetProxyDispatcherContract } from '../../src/generated_contract_wrappers/test_asset_proxy_dispatcher';
-import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
-import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c20_token';
+import { ERC20ProxyContract } from '../../generated_contract_wrappers/e_r_c20_proxy';
+import { ERC721ProxyContract } from '../../generated_contract_wrappers/e_r_c721_proxy';
+import {
+ AssetProxyRegisteredContractEventArgs,
+ TestAssetProxyDispatcherContract,
+} from '../../generated_contract_wrappers/test_asset_proxy_dispatcher';
+import { artifacts } from '../utils/artifacts';
+import { expectTransactionFailedAsync } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { ERC20Wrapper } from '../utils/erc20_wrapper';
+import { ERC721Wrapper } from '../utils/erc721_wrapper';
+import { LogDecoder } from '../utils/log_decoder';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-
+// tslint:disable:no-unnecessary-type-assertion
describe('AssetProxyDispatcher', () => {
let owner: string;
let notOwner: string;
@@ -82,14 +87,8 @@ describe('AssetProxyDispatcher', () => {
});
describe('registerAssetProxy', () => {
it('should record proxy upon registration', async () => {
- const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
- ),
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
@@ -98,46 +97,30 @@ describe('AssetProxyDispatcher', () => {
it('should be able to record multiple proxies', async () => {
// Record first proxy
- const prevERC20ProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevERC20ProxyAddress,
- { from: owner },
- ),
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
// Record another proxy
- const prevERC721ProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC721,
- erc721Proxy.address,
- prevERC721ProxyAddress,
- { from: owner },
- ),
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc721Proxy.address, {
+ from: owner,
+ }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC721);
expect(proxyAddress).to.be.equal(erc721Proxy.address);
});
- it('should replace proxy address upon re-registration', async () => {
+ it('should throw if a proxy with the same id is already registered', async () => {
// Initial registration
- const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
- ),
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
+ const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
// Deploy a new version of the ERC20 Transfer Proxy contract
const newErc20TransferProxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(
@@ -146,114 +129,37 @@ describe('AssetProxyDispatcher', () => {
txDefaults,
);
// Register new ERC20 Transfer Proxy contract
- const newAddress = newErc20TransferProxy.address;
- const currentAddress = erc20Proxy.address;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- newAddress,
- currentAddress,
- { from: owner },
- ),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- // Verify new asset proxy has replaced initial version
- proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(newAddress);
- });
-
- it('should throw if registering with incorrect "currentAssetProxyAddress" field', async () => {
- // Initial registration
- const prevProxyAddress = constants.NULL_ADDRESS;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
- ),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(erc20Proxy.address);
- // The following transaction will throw because the currentAddress is no longer constants.NULL_ADDRESS
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- constants.NULL_ADDRESS,
- { from: owner },
- ),
- RevertReason.AssetProxyMismatch,
+ return expectTransactionFailedAsync(
+ assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(newErc20TransferProxy.address, {
+ from: owner,
+ }),
+ RevertReason.AssetProxyAlreadyExists,
);
});
- it('should be able to reset proxy address to NULL', async () => {
- // Initial registration
- const prevProxyAddress = constants.NULL_ADDRESS;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
- ),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(erc20Proxy.address);
- // The following transaction will reset the proxy address
- const newProxyAddress = constants.NULL_ADDRESS;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- newProxyAddress,
- erc20Proxy.address,
- { from: owner },
- ),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const finalProxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(finalProxyAddress).to.be.equal(newProxyAddress);
- });
-
it('should throw if requesting address is not owner', async () => {
- const prevProxyAddress = constants.NULL_ADDRESS;
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: notOwner },
- ),
+ return expectTransactionFailedAsync(
+ assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: notOwner }),
RevertReason.OnlyContractOwner,
);
});
- it('should throw if attempting to register a proxy to the incorrect id', async () => {
- const prevProxyAddress = constants.NULL_ADDRESS;
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC721,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
- ),
- RevertReason.AssetProxyIdMismatch,
+ it('should log an event with correct arguments when an asset proxy is registered', async () => {
+ const logDecoder = new LogDecoder(web3Wrapper, assetProxyDispatcher.address);
+ const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: owner }),
);
+ const logs = txReceipt.logs;
+ const log = logs[0] as LogWithDecodedArgs<AssetProxyRegisteredContractEventArgs>;
+ expect(log.args.id).to.equal(AssetProxyId.ERC20);
+ expect(log.args.assetProxy).to.equal(erc20Proxy.address);
});
});
describe('getAssetProxy', () => {
it('should return correct address of registered proxy', async () => {
- const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
- ),
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
@@ -269,14 +175,8 @@ describe('AssetProxyDispatcher', () => {
describe('dispatchTransferFrom', () => {
it('should dispatch transfer to registered proxy', async () => {
// Register ERC20 proxy
- const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionSuccessAsync(
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
- ),
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
// Construct metadata for ERC20 proxy
@@ -310,7 +210,7 @@ describe('AssetProxyDispatcher', () => {
const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(10);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
encodedAssetData,
makerAddress,
@@ -323,3 +223,4 @@ describe('AssetProxyDispatcher', () => {
});
});
});
+// tslint:enable:no-unnecessary-type-assertion
diff --git a/packages/contracts/test/exchange/fill_order.ts b/packages/contracts/test/exchange/fill_order.ts
index d65ab2f9a..029bd66e2 100644
--- a/packages/contracts/test/exchange/fill_order.ts
+++ b/packages/contracts/test/exchange/fill_order.ts
@@ -1,10 +1,8 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import * as _ from 'lodash';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { CoreCombinatorialUtils, coreCombinatorialUtilsFactoryAsync } from '../../src/utils/core_combinatorial_utils';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
-
+import { chaiSetup } from '../utils/chai_setup';
+import { CoreCombinatorialUtils, coreCombinatorialUtilsFactoryAsync } from '../utils/core_combinatorial_utils';
import {
AllowanceAmountScenario,
AssetDataScenario,
@@ -15,7 +13,8 @@ import {
OrderAssetAmountScenario,
TakerAssetFillAmountScenario,
TakerScenario,
-} from '../../src/utils/types';
+} from '../utils/types';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
@@ -66,14 +65,7 @@ describe('FillOrder Tests', () => {
describe('fillOrder', () => {
const test = (fillScenarios: FillScenario[]) => {
_.forEach(fillScenarios, fillScenario => {
- const orderScenario = fillScenario.orderScenario;
- const description = `Combinatorial OrderFill: ${orderScenario.feeRecipientScenario} ${
- orderScenario.makerAssetAmountScenario
- } ${orderScenario.takerAssetAmountScenario} ${orderScenario.makerFeeScenario} ${
- orderScenario.takerFeeScenario
- } ${orderScenario.expirationTimeSecondsScenario} ${orderScenario.makerAssetDataScenario} ${
- orderScenario.takerAssetDataScenario
- }`;
+ const description = `Combinatorial OrderFill: ${JSON.stringify(fillScenario)}`;
it(description, async () => {
await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario);
});
diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts
index c08001198..6ded6329c 100644
--- a/packages/contracts/test/exchange/libs.ts
+++ b/packages/contracts/test/exchange/libs.ts
@@ -4,13 +4,13 @@ import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
-import { TestLibsContract } from '../../src/generated_contract_wrappers/test_libs';
-import { addressUtils } from '../../src/utils/address_utils';
-import { artifacts } from '../../src/utils/artifacts';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { OrderFactory } from '../../src/utils/order_factory';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+import { TestLibsContract } from '../../generated_contract_wrappers/test_libs';
+import { addressUtils } from '../utils/address_utils';
+import { artifacts } from '../utils/artifacts';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { OrderFactory } from '../utils/order_factory';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts
index e23ab9851..90406415f 100644
--- a/packages/contracts/test/exchange/match_orders.ts
+++ b/packages/contracts/test/exchange/match_orders.ts
@@ -1,27 +1,27 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { assetProxyUtils } from '@0xproject/order-utils';
-import { AssetProxyId, RevertReason } from '@0xproject/types';
+import { RevertReason } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c20_token';
-import { DummyERC721TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c721_token';
-import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c20_proxy';
-import { ERC721ProxyContract } from '../../src/generated_contract_wrappers/e_r_c721_proxy';
-import { ExchangeContract } from '../../src/generated_contract_wrappers/exchange';
-import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
-import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
-import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
-import { MatchOrderTester } from '../../src/utils/match_order_tester';
-import { OrderFactory } from '../../src/utils/order_factory';
-import { ERC20BalancesByOwner, ERC721TokenIdsByOwner, OrderInfo, OrderStatus } from '../../src/utils/types';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c20_token';
+import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c721_token';
+import { ERC20ProxyContract } from '../../generated_contract_wrappers/e_r_c20_proxy';
+import { ERC721ProxyContract } from '../../generated_contract_wrappers/e_r_c721_proxy';
+import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
+import { artifacts } from '../utils/artifacts';
+import { expectTransactionFailedAsync } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { ERC20Wrapper } from '../utils/erc20_wrapper';
+import { ERC721Wrapper } from '../utils/erc721_wrapper';
+import { ExchangeWrapper } from '../utils/exchange_wrapper';
+import { MatchOrderTester } from '../utils/match_order_tester';
+import { OrderFactory } from '../utils/order_factory';
+import { ERC20BalancesByOwner, ERC721TokenIdsByOwner, OrderInfo, OrderStatus } from '../utils/types';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -103,8 +103,8 @@ describe('matchOrders', () => {
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
);
exchangeWrapper = new ExchangeWrapper(exchange, provider);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
+ await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
+ await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner);
// Authorize ERC20 and ERC721 trades by exchange
await web3Wrapper.awaitTransactionSuccessAsync(
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
@@ -602,7 +602,7 @@ describe('matchOrders', () => {
// Cancel left order
await exchangeWrapper.cancelOrderAsync(signedOrderLeft, signedOrderLeft.makerAddress);
// Match orders
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress),
RevertReason.OrderUnfillable,
);
@@ -627,7 +627,7 @@ describe('matchOrders', () => {
// Cancel right order
await exchangeWrapper.cancelOrderAsync(signedOrderRight, signedOrderRight.makerAddress);
// Match orders
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress),
RevertReason.OrderUnfillable,
);
@@ -650,14 +650,8 @@ describe('matchOrders', () => {
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- matchOrderTester.matchOrdersAndVerifyBalancesAsync(
- signedOrderLeft,
- signedOrderRight,
- takerAddress,
- erc20BalancesByOwner,
- erc721TokenIdsByOwner,
- ),
+ return expectTransactionFailedAsync(
+ exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress),
RevertReason.NegativeSpreadRequired,
);
});
@@ -679,14 +673,8 @@ describe('matchOrders', () => {
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- matchOrderTester.matchOrdersAndVerifyBalancesAsync(
- signedOrderLeft,
- signedOrderRight,
- takerAddress,
- erc20BalancesByOwner,
- erc721TokenIdsByOwner,
- ),
+ return expectTransactionFailedAsync(
+ exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress),
// We are assuming assetData fields of the right order are the
// reverse of the left order, rather than checking equality. This
// saves a bunch of gas, but as a result if the assetData fields are
@@ -714,14 +702,8 @@ describe('matchOrders', () => {
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- matchOrderTester.matchOrdersAndVerifyBalancesAsync(
- signedOrderLeft,
- signedOrderRight,
- takerAddress,
- erc20BalancesByOwner,
- erc721TokenIdsByOwner,
- ),
+ return expectTransactionFailedAsync(
+ exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress),
RevertReason.InvalidOrderSignature,
);
});
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index 21cc343b3..c44d22479 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -8,17 +8,17 @@ import ethUtil = require('ethereumjs-util');
import {
SignatureValidatorApprovalContractEventArgs,
TestSignatureValidatorContract,
-} from '../../src/generated_contract_wrappers/test_signature_validator';
-import { TestValidatorContract } from '../../src/generated_contract_wrappers/test_validator';
-import { TestWalletContract } from '../../src/generated_contract_wrappers/test_wallet';
-import { addressUtils } from '../../src/utils/address_utils';
-import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertOrOtherErrorAsync } from '../../src/utils/assertions';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { LogDecoder } from '../../src/utils/log_decoder';
-import { OrderFactory } from '../../src/utils/order_factory';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+} from '../../generated_contract_wrappers/test_signature_validator';
+import { TestValidatorContract } from '../../generated_contract_wrappers/test_validator';
+import { TestWalletContract } from '../../generated_contract_wrappers/test_wallet';
+import { addressUtils } from '../utils/address_utils';
+import { artifacts } from '../utils/artifacts';
+import { expectContractCallFailed } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { LogDecoder } from '../utils/log_decoder';
+import { OrderFactory } from '../utils/order_factory';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -101,7 +101,7 @@ describe('MixinSignatureValidator', () => {
it('should revert when signature is empty', async () => {
const emptySignature = '0x';
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
signedOrder.makerAddress,
@@ -115,7 +115,7 @@ describe('MixinSignatureValidator', () => {
const unsupportedSignatureType = SignatureType.NSignatureTypes;
const unsupportedSignatureHex = `0x${unsupportedSignatureType}`;
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
signedOrder.makerAddress,
@@ -128,7 +128,7 @@ describe('MixinSignatureValidator', () => {
it('should revert when SignatureType=Illegal', async () => {
const unsupportedSignatureHex = `0x${SignatureType.Illegal}`;
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
signedOrder.makerAddress,
@@ -155,7 +155,7 @@ describe('MixinSignatureValidator', () => {
const signatureBuffer = Buffer.concat([fillerData, signatureType]);
const signatureHex = ethUtil.bufferToHex(signatureBuffer);
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
signedOrder.makerAddress,
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index c4de58bb9..959d79517 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -1,26 +1,26 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
-import { AssetProxyId, OrderWithoutExchangeAddress, RevertReason, SignedOrder } from '@0xproject/types';
+import { OrderWithoutExchangeAddress, RevertReason, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c20_token';
-import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c20_proxy';
-import { ExchangeContract } from '../../src/generated_contract_wrappers/exchange';
-import { ExchangeWrapperContract } from '../../src/generated_contract_wrappers/exchange_wrapper';
-import { WhitelistContract } from '../../src/generated_contract_wrappers/whitelist';
-import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
-import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
-import { OrderFactory } from '../../src/utils/order_factory';
-import { orderUtils } from '../../src/utils/order_utils';
-import { TransactionFactory } from '../../src/utils/transaction_factory';
-import { ERC20BalancesByOwner, SignedTransaction } from '../../src/utils/types';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c20_token';
+import { ERC20ProxyContract } from '../../generated_contract_wrappers/e_r_c20_proxy';
+import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
+import { ExchangeWrapperContract } from '../../generated_contract_wrappers/exchange_wrapper';
+import { WhitelistContract } from '../../generated_contract_wrappers/whitelist';
+import { artifacts } from '../utils/artifacts';
+import { expectTransactionFailedAsync } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { ERC20Wrapper } from '../utils/erc20_wrapper';
+import { ExchangeWrapper } from '../utils/exchange_wrapper';
+import { OrderFactory } from '../utils/order_factory';
+import { orderUtils } from '../utils/order_utils';
+import { TransactionFactory } from '../utils/transaction_factory';
+import { ERC20BalancesByOwner, SignedTransaction } from '../utils/types';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -91,7 +91,7 @@ describe('Exchange transactions', () => {
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
);
exchangeWrapper = new ExchangeWrapper(exchange, provider);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
+ await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
await web3Wrapper.awaitTransactionSuccessAsync(
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }),
@@ -134,7 +134,7 @@ describe('Exchange transactions', () => {
});
it('should throw if not called by specified sender', async () => {
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.executeTransactionAsync(signedTx, takerAddress),
RevertReason.FailedExecution,
);
@@ -177,7 +177,7 @@ describe('Exchange transactions', () => {
it('should throw if the a 0x transaction with the same transactionHash has already been executed', async () => {
await exchangeWrapper.executeTransactionAsync(signedTx, senderAddress);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.executeTransactionAsync(signedTx, senderAddress),
RevertReason.InvalidTxHash,
);
@@ -197,7 +197,7 @@ describe('Exchange transactions', () => {
});
it('should throw if not called by specified sender', async () => {
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.executeTransactionAsync(signedTx, makerAddress),
RevertReason.FailedExecution,
);
@@ -205,7 +205,7 @@ describe('Exchange transactions', () => {
it('should cancel the order when signed by maker and called by sender', async () => {
await exchangeWrapper.executeTransactionAsync(signedTx, senderAddress);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, senderAddress),
RevertReason.OrderUnfillable,
);
@@ -250,7 +250,7 @@ describe('Exchange transactions', () => {
signedOrder.signature,
);
const signedFillTx = takerTransactionFactory.newSignedTransaction(fillData);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapperContract.fillOrder.sendTransactionAsync(
orderWithoutExchangeAddress,
takerAssetFillAmount,
@@ -370,7 +370,7 @@ describe('Exchange transactions', () => {
orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
const takerAssetFillAmount = signedOrder.takerAssetAmount;
const salt = generatePseudoRandomSalt();
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
whitelist.fillOrderIfWhitelisted.sendTransactionAsync(
orderWithoutExchangeAddress,
takerAssetFillAmount,
@@ -392,7 +392,7 @@ describe('Exchange transactions', () => {
orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
const takerAssetFillAmount = signedOrder.takerAssetAmount;
const salt = generatePseudoRandomSalt();
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
whitelist.fillOrderIfWhitelisted.sendTransactionAsync(
orderWithoutExchangeAddress,
takerAssetFillAmount,
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 1af8bde9d..69f374e46 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -1,26 +1,26 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { assetProxyUtils } from '@0xproject/order-utils';
-import { AssetProxyId, RevertReason, SignedOrder } from '@0xproject/types';
+import { RevertReason, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c20_token';
-import { DummyERC721TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c721_token';
-import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c20_proxy';
-import { ERC721ProxyContract } from '../../src/generated_contract_wrappers/e_r_c721_proxy';
-import { ExchangeContract } from '../../src/generated_contract_wrappers/exchange';
-import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
-import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
-import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
-import { OrderFactory } from '../../src/utils/order_factory';
-import { ERC20BalancesByOwner } from '../../src/utils/types';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c20_token';
+import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c721_token';
+import { ERC20ProxyContract } from '../../generated_contract_wrappers/e_r_c20_proxy';
+import { ERC721ProxyContract } from '../../generated_contract_wrappers/e_r_c721_proxy';
+import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
+import { artifacts } from '../utils/artifacts';
+import { expectTransactionFailedAsync } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { ERC20Wrapper } from '../utils/erc20_wrapper';
+import { ERC721Wrapper } from '../utils/erc721_wrapper';
+import { ExchangeWrapper } from '../utils/exchange_wrapper';
+import { OrderFactory } from '../utils/order_factory';
+import { ERC20BalancesByOwner } from '../utils/types';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -87,8 +87,8 @@ describe('Exchange wrappers', () => {
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
);
exchangeWrapper = new ExchangeWrapper(exchange, provider);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
+ await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
+ await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner);
await web3Wrapper.awaitTransactionSuccessAsync(
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
@@ -174,7 +174,7 @@ describe('Exchange wrappers', () => {
expirationTimeSeconds: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress),
RevertReason.OrderUnfillable,
);
@@ -187,7 +187,7 @@ describe('Exchange wrappers', () => {
takerAssetFillAmount: signedOrder.takerAssetAmount.div(2),
});
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress),
RevertReason.CompleteFillFailed,
);
@@ -500,7 +500,7 @@ describe('Exchange wrappers', () => {
await exchangeWrapper.fillOrKillOrderAsync(signedOrders[0], takerAddress);
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
takerAssetFillAmounts,
}),
@@ -703,7 +703,7 @@ describe('Exchange wrappers', () => {
orderFactory.newSignedOrder(),
];
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
@@ -921,7 +921,7 @@ describe('Exchange wrappers', () => {
orderFactory.newSignedOrder(),
];
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
exchangeWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
diff --git a/packages/contracts/test/global_hooks.ts b/packages/contracts/test/global_hooks.ts
index 83263c5b3..cf7c52efd 100644
--- a/packages/contracts/test/global_hooks.ts
+++ b/packages/contracts/test/global_hooks.ts
@@ -1,7 +1,7 @@
import { env, EnvVars } from '@0xproject/dev-utils';
-import { coverage } from '../src/utils/coverage';
-import { profiler } from '../src/utils/profiler';
+import { coverage } from './utils/coverage';
+import { profiler } from './utils/profiler';
after('generate coverage report', async () => {
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index 3d4058cbc..c80b61e19 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -7,12 +7,12 @@ import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import { TestLibBytesContract } from '../../src/generated_contract_wrappers/test_lib_bytes';
-import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertOrOtherErrorAsync } from '../../src/utils/assertions';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { constants } from '../../src/utils/constants';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+import { TestLibBytesContract } from '../../generated_contract_wrappers/test_lib_bytes';
+import { artifacts } from '../utils/artifacts';
+import { expectContractCallFailed } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -100,7 +100,7 @@ describe('LibBytes', () => {
describe('popLastByte', () => {
it('should revert if length is 0', async () => {
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicPopLastByte.callAsync(constants.NULL_BYTES),
RevertReason.LibBytesGreaterThanZeroLengthRequired,
);
@@ -116,7 +116,7 @@ describe('LibBytes', () => {
describe('popLast20Bytes', () => {
it('should revert if length is less than 20', async () => {
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicPopLast20Bytes.callAsync(byteArrayShorterThan20Bytes),
RevertReason.LibBytesGreaterOrEqualTo20LengthRequired,
);
@@ -184,7 +184,7 @@ describe('LibBytes', () => {
describe('deepCopyBytes', () => {
it('should revert if dest is shorter than source', async () => {
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicDeepCopyBytes.callAsync(byteArrayShorterThan32Bytes, byteArrayLongerThan32Bytes),
RevertReason.LibBytesGreaterOrEqualToSourceBytesLengthRequired,
);
@@ -237,7 +237,7 @@ describe('LibBytes', () => {
it('should fail if the byte array is too short to hold an address', async () => {
const shortByteArray = '0xabcdef';
const offset = new BigNumber(0);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadAddress.callAsync(shortByteArray, offset),
RevertReason.LibBytesGreaterOrEqualTo20LengthRequired,
);
@@ -245,7 +245,7 @@ describe('LibBytes', () => {
it('should fail if the length between the offset and end of the byte array is too short to hold an address', async () => {
const byteArray = testAddress;
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadAddress.callAsync(byteArray, badOffset),
RevertReason.LibBytesGreaterOrEqualTo20LengthRequired,
);
@@ -281,7 +281,7 @@ describe('LibBytes', () => {
});
it('should fail if the byte array is too short to hold an address', async () => {
const offset = new BigNumber(0);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicWriteAddress.callAsync(byteArrayShorterThan20Bytes, offset, testAddress),
RevertReason.LibBytesGreaterOrEqualTo20LengthRequired,
);
@@ -289,7 +289,7 @@ describe('LibBytes', () => {
it('should fail if the length between the offset and end of the byte array is too short to hold an address', async () => {
const byteArray = byteArrayLongerThan32Bytes;
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicWriteAddress.callAsync(byteArray, badOffset, testAddress),
RevertReason.LibBytesGreaterOrEqualTo20LengthRequired,
);
@@ -313,14 +313,14 @@ describe('LibBytes', () => {
});
it('should fail if the byte array is too short to hold a bytes32', async () => {
const offset = new BigNumber(0);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
});
it('should fail if the length between the offset and end of the byte array is too short to hold a bytes32', async () => {
const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadBytes32.callAsync(testBytes32, badOffset),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
@@ -356,7 +356,7 @@ describe('LibBytes', () => {
});
it('should fail if the byte array is too short to hold a bytes32', async () => {
const offset = new BigNumber(0);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicWriteBytes32.callAsync(byteArrayShorterThan32Bytes, offset, testBytes32),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
@@ -364,7 +364,7 @@ describe('LibBytes', () => {
it('should fail if the length between the offset and end of the byte array is too short to hold a bytes32', async () => {
const byteArray = byteArrayLongerThan32Bytes;
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicWriteBytes32.callAsync(byteArray, badOffset, testBytes32),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
@@ -392,7 +392,7 @@ describe('LibBytes', () => {
});
it('should fail if the byte array is too short to hold a uint256', async () => {
const offset = new BigNumber(0);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
@@ -402,7 +402,7 @@ describe('LibBytes', () => {
const testUint256AsBuffer = ethUtil.toBuffer(formattedTestUint256);
const byteArray = ethUtil.bufferToHex(testUint256AsBuffer);
const badOffset = new BigNumber(testUint256AsBuffer.byteLength);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadUint256.callAsync(byteArray, badOffset),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
@@ -442,7 +442,7 @@ describe('LibBytes', () => {
});
it('should fail if the byte array is too short to hold a uint256', async () => {
const offset = new BigNumber(0);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicWriteUint256.callAsync(byteArrayShorterThan32Bytes, offset, testUint256),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
@@ -450,7 +450,7 @@ describe('LibBytes', () => {
it('should fail if the length between the offset and end of the byte array is too short to hold a uint256', async () => {
const byteArray = byteArrayLongerThan32Bytes;
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicWriteUint256.callAsync(byteArray, badOffset, testUint256),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
@@ -461,7 +461,7 @@ describe('LibBytes', () => {
// AssertionError: expected promise to be rejected with an error including 'revert' but it was fulfilled with '0x08c379a0'
it('should revert if byte array has a length < 4', async () => {
const byteArrayLessThan4Bytes = '0x010101';
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadBytes4.callAsync(byteArrayLessThan4Bytes, new BigNumber(0)),
RevertReason.LibBytesGreaterOrEqualTo4LengthRequired,
);
@@ -516,28 +516,28 @@ describe('LibBytes', () => {
it('should fail if the byte array is too short to hold the length of a nested byte array', async () => {
// The length of the nested array is 32 bytes. By storing less than 32 bytes, a length cannot be read.
const offset = new BigNumber(0);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadBytesWithLength.callAsync(byteArrayShorterThan32Bytes, offset),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
});
it('should fail if we store a nested byte array length, without a nested byte array', async () => {
const offset = new BigNumber(0);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadBytesWithLength.callAsync(testBytes32, offset),
RevertReason.LibBytesGreaterOrEqualToNestedBytesLengthRequired,
);
});
it('should fail if the length between the offset and end of the byte array is too short to hold the length of a nested byte array', async () => {
const badOffset = new BigNumber(ethUtil.toBuffer(byteArrayShorterThan32Bytes).byteLength);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadBytesWithLength.callAsync(byteArrayShorterThan32Bytes, badOffset),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
});
it('should fail if the length between the offset and end of the byte array is too short to hold the nested byte array', async () => {
const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicReadBytesWithLength.callAsync(testBytes32, badOffset),
RevertReason.LibBytesGreaterOrEqualTo32LengthRequired,
);
@@ -649,7 +649,7 @@ describe('LibBytes', () => {
it('should fail if the byte array is too short to hold the length of a nested byte array', async () => {
const offset = new BigNumber(0);
const emptyByteArray = ethUtil.bufferToHex(new Buffer(1));
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicWriteBytesWithLength.callAsync(emptyByteArray, offset, longData),
RevertReason.LibBytesGreaterOrEqualToNestedBytesLengthRequired,
);
@@ -657,7 +657,7 @@ describe('LibBytes', () => {
it('should fail if the length between the offset and end of the byte array is too short to hold the length of a nested byte array)', async () => {
const emptyByteArray = ethUtil.bufferToHex(new Buffer(shortTestBytesAsBuffer.byteLength));
const badOffset = new BigNumber(ethUtil.toBuffer(shortTestBytesAsBuffer).byteLength);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
libBytes.publicWriteBytesWithLength.callAsync(emptyByteArray, badOffset, shortData),
RevertReason.LibBytesGreaterOrEqualToNestedBytesLengthRequired,
);
diff --git a/packages/contracts/test/asset_proxy_owner.ts b/packages/contracts/test/multisig/asset_proxy_owner.ts
index 188cba5a3..16231dfcb 100644
--- a/packages/contracts/test/asset_proxy_owner.ts
+++ b/packages/contracts/test/multisig/asset_proxy_owner.ts
@@ -9,19 +9,20 @@ import {
ExecutionContractEventArgs,
ExecutionFailureContractEventArgs,
SubmissionContractEventArgs,
-} from '../src/generated_contract_wrappers/asset_proxy_owner';
-import { MixinAuthorizableContract } from '../src/generated_contract_wrappers/mixin_authorizable';
-import { TestAssetProxyOwnerContract } from '../src/generated_contract_wrappers/test_asset_proxy_owner';
-import { artifacts } from '../src/utils/artifacts';
+} from '../../generated_contract_wrappers/asset_proxy_owner';
+import { MixinAuthorizableContract } from '../../generated_contract_wrappers/mixin_authorizable';
+import { TestAssetProxyOwnerContract } from '../../generated_contract_wrappers/test_asset_proxy_owner';
+import { artifacts } from '../utils/artifacts';
import {
- expectRevertOrAlwaysFailingTransactionAsync,
- expectRevertOrContractCallFailedAsync,
-} from '../src/utils/assertions';
-import { chaiSetup } from '../src/utils/chai_setup';
-import { constants } from '../src/utils/constants';
-import { increaseTimeAndMineBlockAsync } from '../src/utils/increase_time';
-import { MultiSigWrapper } from '../src/utils/multi_sig_wrapper';
-import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
+ expectContractCallFailedWithoutReasonAsync,
+ expectContractCreationFailedWithoutReason,
+ expectTransactionFailedWithoutReasonAsync,
+} from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { increaseTimeAndMineBlockAsync } from '../utils/increase_time';
+import { MultiSigWrapper } from '../utils/multi_sig_wrapper';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -108,7 +109,7 @@ describe('AssetProxyOwner', () => {
});
it('should throw if a null address is included in assetProxyContracts', async () => {
const assetProxyContractAddresses = [erc20Proxy.address, constants.NULL_ADDRESS];
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectContractCreationFailedWithoutReason(
AssetProxyOwnerContract.deployFrom0xArtifactAsync(
artifacts.AssetProxyOwner,
provider,
@@ -150,7 +151,7 @@ describe('AssetProxyOwner', () => {
describe('registerAssetProxy', () => {
it('should throw if not called by multisig', async () => {
const isRegistered = true;
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
testAssetProxyOwner.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, isRegistered, {
from: owners[0],
}),
@@ -277,7 +278,7 @@ describe('AssetProxyOwner', () => {
);
const log = submitTxRes.logs[0] as LogWithDecodedArgs<SubmissionContractEventArgs>;
const txId = log.args.transactionId;
- return expectRevertOrContractCallFailedAsync(
+ return expectContractCallFailedWithoutReasonAsync(
testAssetProxyOwner.testValidRemoveAuthorizedAddressAtIndexTx.callAsync(txId),
);
});
@@ -312,7 +313,7 @@ describe('AssetProxyOwner', () => {
);
const log = submitTxRes.logs[0] as LogWithDecodedArgs<SubmissionContractEventArgs>;
const txId = log.args.transactionId;
- return expectRevertOrContractCallFailedAsync(
+ return expectContractCallFailedWithoutReasonAsync(
testAssetProxyOwner.testValidRemoveAuthorizedAddressAtIndexTx.callAsync(txId),
);
});
@@ -332,7 +333,7 @@ describe('AssetProxyOwner', () => {
const log = res.logs[0] as LogWithDecodedArgs<SubmissionContractEventArgs>;
const txId = log.args.transactionId;
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
testAssetProxyOwner.executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync(txId, {
from: owners[1],
}),
@@ -354,7 +355,7 @@ describe('AssetProxyOwner', () => {
await multiSigWrapper.confirmTransactionAsync(txId, owners[1]);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
testAssetProxyOwner.executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync(txId, {
from: owners[1],
}),
@@ -376,7 +377,7 @@ describe('AssetProxyOwner', () => {
await multiSigWrapper.confirmTransactionAsync(txId, owners[1]);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
testAssetProxyOwner.executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync(txId, {
from: owners[1],
}),
@@ -433,7 +434,7 @@ describe('AssetProxyOwner', () => {
const isExecuted = tx[3];
expect(isExecuted).to.equal(true);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
testAssetProxyOwner.executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync(txId, {
from: owners[1],
}),
diff --git a/packages/contracts/test/multi_sig_with_time_lock.ts b/packages/contracts/test/multisig/multi_sig_with_time_lock.ts
index aa82b9edf..a7b99d867 100644
--- a/packages/contracts/test/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/multisig/multi_sig_with_time_lock.ts
@@ -6,14 +6,14 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import {
MultiSigWalletWithTimeLockContract,
SubmissionContractEventArgs,
-} from '../src/generated_contract_wrappers/multi_sig_wallet_with_time_lock';
-import { artifacts } from '../src/utils/artifacts';
-import { expectRevertOrAlwaysFailingTransactionAsync } from '../src/utils/assertions';
-import { chaiSetup } from '../src/utils/chai_setup';
-import { constants } from '../src/utils/constants';
-import { increaseTimeAndMineBlockAsync } from '../src/utils/increase_time';
-import { MultiSigWrapper } from '../src/utils/multi_sig_wrapper';
-import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
+} from '../../generated_contract_wrappers/multi_sig_wallet_with_time_lock';
+import { artifacts } from '../utils/artifacts';
+import { expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { increaseTimeAndMineBlockAsync } from '../utils/increase_time';
+import { MultiSigWrapper } from '../utils/multi_sig_wrapper';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -67,7 +67,7 @@ describe('MultiSigWalletWithTimeLock', () => {
});
it('should throw when not called by wallet', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }),
);
});
@@ -78,7 +78,7 @@ describe('MultiSigWalletWithTimeLock', () => {
const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]);
const log = res.logs[0] as LogWithDecodedArgs<SubmissionContractEventArgs>;
const txId = log.args.transactionId;
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
);
});
@@ -147,7 +147,7 @@ describe('MultiSigWalletWithTimeLock', () => {
});
it('should throw if it has enough confirmations but is not past the time lock', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
);
});
diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts
index 095cecfce..7cc43be9b 100644
--- a/packages/contracts/test/token_registry.ts
+++ b/packages/contracts/test/token_registry.ts
@@ -4,13 +4,14 @@ import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import { TokenRegistryContract } from '../src/generated_contract_wrappers/token_registry';
-import { artifacts } from '../src/utils/artifacts';
-import { expectRevertOrAlwaysFailingTransactionAsync } from '../src/utils/assertions';
-import { chaiSetup } from '../src/utils/chai_setup';
-import { constants } from '../src/utils/constants';
-import { TokenRegWrapper } from '../src/utils/token_registry_wrapper';
-import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
+import { TokenRegistryContract } from '../generated_contract_wrappers/token_registry';
+
+import { artifacts } from './utils/artifacts';
+import { expectTransactionFailedWithoutReasonAsync } from './utils/assertions';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { TokenRegWrapper } from './utils/token_registry_wrapper';
+import { provider, txDefaults, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -74,7 +75,7 @@ describe('TokenRegistry', () => {
describe('addToken', () => {
it('should throw when not called by owner', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(tokenRegWrapper.addTokenAsync(token1, notOwner));
+ return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(token1, notOwner));
});
it('should add token metadata when called by owner', async () => {
@@ -86,20 +87,18 @@ describe('TokenRegistry', () => {
it('should throw if token already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
- return expectRevertOrAlwaysFailingTransactionAsync(tokenRegWrapper.addTokenAsync(token1, owner));
+ return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(token1, owner));
});
it('should throw if token address is null', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(tokenRegWrapper.addTokenAsync(nullToken, owner));
+ return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(nullToken, owner));
});
it('should throw if name already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
const duplicateNameToken = _.assign({}, token2, { name: token1.name });
- return expectRevertOrAlwaysFailingTransactionAsync(
- tokenRegWrapper.addTokenAsync(duplicateNameToken, owner),
- );
+ return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner));
});
it('should throw if symbol already exists', async () => {
@@ -108,7 +107,7 @@ describe('TokenRegistry', () => {
symbol: token1.symbol,
});
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner),
);
});
@@ -135,7 +134,7 @@ describe('TokenRegistry', () => {
describe('setTokenName', () => {
it('should throw when not called by owner', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: notOwner }),
);
});
@@ -161,13 +160,13 @@ describe('TokenRegistry', () => {
it('should throw if the name already exists', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: owner }),
);
});
it('should throw if token does not exist', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenName.sendTransactionAsync(nullToken.address, token2.name, { from: owner }),
);
});
@@ -175,7 +174,7 @@ describe('TokenRegistry', () => {
describe('setTokenSymbol', () => {
it('should throw when not called by owner', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
from: notOwner,
}),
@@ -201,7 +200,7 @@ describe('TokenRegistry', () => {
it('should throw if the symbol already exists', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
from: owner,
}),
@@ -209,7 +208,7 @@ describe('TokenRegistry', () => {
});
it('should throw if token does not exist', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenSymbol.sendTransactionAsync(nullToken.address, token2.symbol, {
from: owner,
}),
@@ -220,7 +219,7 @@ describe('TokenRegistry', () => {
describe('removeToken', () => {
it('should throw if not called by owner', async () => {
const index = new BigNumber(0);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.removeToken.sendTransactionAsync(token1.address, index, { from: notOwner }),
);
});
@@ -239,7 +238,7 @@ describe('TokenRegistry', () => {
it('should throw if token does not exist', async () => {
const index = new BigNumber(0);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.removeToken.sendTransactionAsync(nullToken.address, index, { from: owner }),
);
});
@@ -247,7 +246,7 @@ describe('TokenRegistry', () => {
it('should throw if token at given index does not match address', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
const incorrectIndex = new BigNumber(0);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.removeToken.sendTransactionAsync(token2.address, incorrectIndex, { from: owner }),
);
});
diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/tokens/ether_token.ts
index 01093d309..a104fc915 100644
--- a/packages/contracts/test/ether_token.ts
+++ b/packages/contracts/test/tokens/ether_token.ts
@@ -3,12 +3,12 @@ import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
-import { WETH9Contract } from '../src/generated_contract_wrappers/weth9';
-import { artifacts } from '../src/utils/artifacts';
-import { expectInsufficientFundsAsync, expectRevertOrAlwaysFailingTransactionAsync } from '../src/utils/assertions';
-import { chaiSetup } from '../src/utils/chai_setup';
-import { constants } from '../src/utils/constants';
-import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
+import { WETH9Contract } from '../../generated_contract_wrappers/weth9';
+import { artifacts } from '../utils/artifacts';
+import { expectInsufficientFundsAsync, expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -74,7 +74,7 @@ describe('EtherToken', () => {
const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
const ethTokensToWithdraw = initEthTokenBalance.plus(1);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw),
);
});
diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/tokens/unlimited_allowance_token.ts
index 0eb82b5fe..8a3b20d0f 100644
--- a/packages/contracts/test/unlimited_allowance_token.ts
+++ b/packages/contracts/test/tokens/unlimited_allowance_token.ts
@@ -3,12 +3,12 @@ import { RevertReason } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
-import { DummyERC20TokenContract } from '../src/generated_contract_wrappers/dummy_e_r_c20_token';
-import { artifacts } from '../src/utils/artifacts';
-import { expectRevertOrOtherErrorAsync } from '../src/utils/assertions';
-import { chaiSetup } from '../src/utils/chai_setup';
-import { constants } from '../src/utils/constants';
-import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
+import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c20_token';
+import { artifacts } from '../utils/artifacts';
+import { expectContractCallFailed } from '../utils/assertions';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -54,7 +54,7 @@ describe('UnlimitedAllowanceToken', () => {
it('should throw if owner has insufficient balance', async () => {
const ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance.plus(1);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
token.transfer.callAsync(spender, amountToTransfer, { from: owner }),
RevertReason.Erc20InsufficientBalance,
);
@@ -93,7 +93,7 @@ describe('UnlimitedAllowanceToken', () => {
await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
from: spender,
}),
@@ -109,7 +109,7 @@ describe('UnlimitedAllowanceToken', () => {
const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(isSpenderAllowanceInsufficient).to.be.true();
- return expectRevertOrOtherErrorAsync(
+ return expectContractCallFailed(
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
from: spender,
}),
diff --git a/packages/contracts/test/zrx_token.ts b/packages/contracts/test/tokens/zrx_token.ts
index 01ae57d4a..a0d77c924 100644
--- a/packages/contracts/test/zrx_token.ts
+++ b/packages/contracts/test/tokens/zrx_token.ts
@@ -3,11 +3,11 @@ import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
-import { ZRXTokenContract } from '../src/generated_contract_wrappers/zrx_token';
-import { artifacts } from '../src/utils/artifacts';
-import { chaiSetup } from '../src/utils/chai_setup';
-import { constants } from '../src/utils/constants';
-import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
+import { ZRXTokenContract } from '../../generated_contract_wrappers/zrx_token';
+import { artifacts } from '../utils/artifacts';
+import { chaiSetup } from '../utils/chai_setup';
+import { constants } from '../utils/constants';
+import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
diff --git a/packages/contracts/src/abstract/abstract_asset_wrapper.ts b/packages/contracts/test/utils/abstract_asset_wrapper.ts
index 4b56a8502..4b56a8502 100644
--- a/packages/contracts/src/abstract/abstract_asset_wrapper.ts
+++ b/packages/contracts/test/utils/abstract_asset_wrapper.ts
diff --git a/packages/contracts/src/utils/address_utils.ts b/packages/contracts/test/utils/address_utils.ts
index a9fb6921a..a9fb6921a 100644
--- a/packages/contracts/src/utils/address_utils.ts
+++ b/packages/contracts/test/utils/address_utils.ts
diff --git a/packages/contracts/test/utils/artifacts.ts b/packages/contracts/test/utils/artifacts.ts
new file mode 100644
index 000000000..23e93c085
--- /dev/null
+++ b/packages/contracts/test/utils/artifacts.ts
@@ -0,0 +1,51 @@
+import { ContractArtifact } from '@0xproject/sol-compiler';
+
+import * as AssetProxyOwner from '../../artifacts/AssetProxyOwner.json';
+import * as DummyERC20Token from '../../artifacts/DummyERC20Token.json';
+import * as DummyERC721Receiver from '../../artifacts/DummyERC721Receiver.json';
+import * as DummyERC721Token from '../../artifacts/DummyERC721Token.json';
+import * as ERC20Proxy from '../../artifacts/ERC20Proxy.json';
+import * as ERC721Proxy from '../../artifacts/ERC721Proxy.json';
+import * as Exchange from '../../artifacts/Exchange.json';
+import * as ExchangeWrapper from '../../artifacts/ExchangeWrapper.json';
+import * as IAssetProxy from '../../artifacts/IAssetProxy.json';
+import * as MixinAuthorizable from '../../artifacts/MixinAuthorizable.json';
+import * as MultiSigWallet from '../../artifacts/MultiSigWallet.json';
+import * as MultiSigWalletWithTimeLock from '../../artifacts/MultiSigWalletWithTimeLock.json';
+import * as TestAssetProxyDispatcher from '../../artifacts/TestAssetProxyDispatcher.json';
+import * as TestAssetProxyOwner from '../../artifacts/TestAssetProxyOwner.json';
+import * as TestLibBytes from '../../artifacts/TestLibBytes.json';
+import * as TestLibs from '../../artifacts/TestLibs.json';
+import * as TestSignatureValidator from '../../artifacts/TestSignatureValidator.json';
+import * as TestValidator from '../../artifacts/TestValidator.json';
+import * as TestWallet from '../../artifacts/TestWallet.json';
+import * as TokenRegistry from '../../artifacts/TokenRegistry.json';
+import * as EtherToken from '../../artifacts/WETH9.json';
+import * as Whitelist from '../../artifacts/Whitelist.json';
+import * as ZRX from '../../artifacts/ZRXToken.json';
+
+export const artifacts = {
+ AssetProxyOwner: (AssetProxyOwner as any) as ContractArtifact,
+ DummyERC20Token: (DummyERC20Token as any) as ContractArtifact,
+ DummyERC721Receiver: (DummyERC721Receiver as any) as ContractArtifact,
+ DummyERC721Token: (DummyERC721Token as any) as ContractArtifact,
+ ERC20Proxy: (ERC20Proxy as any) as ContractArtifact,
+ ERC721Proxy: (ERC721Proxy as any) as ContractArtifact,
+ Exchange: (Exchange as any) as ContractArtifact,
+ ExchangeWrapper: (ExchangeWrapper as any) as ContractArtifact,
+ EtherToken: (EtherToken as any) as ContractArtifact,
+ IAssetProxy: (IAssetProxy as any) as ContractArtifact,
+ MixinAuthorizable: (MixinAuthorizable as any) as ContractArtifact,
+ MultiSigWallet: (MultiSigWallet as any) as ContractArtifact,
+ MultiSigWalletWithTimeLock: (MultiSigWalletWithTimeLock as any) as ContractArtifact,
+ TestAssetProxyOwner: (TestAssetProxyOwner as any) as ContractArtifact,
+ TestAssetProxyDispatcher: (TestAssetProxyDispatcher as any) as ContractArtifact,
+ TestLibBytes: (TestLibBytes as any) as ContractArtifact,
+ TestLibs: (TestLibs as any) as ContractArtifact,
+ TestSignatureValidator: (TestSignatureValidator as any) as ContractArtifact,
+ TestValidator: (TestValidator as any) as ContractArtifact,
+ TestWallet: (TestWallet as any) as ContractArtifact,
+ TokenRegistry: (TokenRegistry as any) as ContractArtifact,
+ Whitelist: (Whitelist as any) as ContractArtifact,
+ ZRX: (ZRX as any) as ContractArtifact,
+};
diff --git a/packages/contracts/test/utils/assertions.ts b/packages/contracts/test/utils/assertions.ts
new file mode 100644
index 000000000..112a470f6
--- /dev/null
+++ b/packages/contracts/test/utils/assertions.ts
@@ -0,0 +1,159 @@
+import { RevertReason } from '@0xproject/types';
+import { logUtils } from '@0xproject/utils';
+import { NodeType } from '@0xproject/web3-wrapper';
+import * as chai from 'chai';
+import { TransactionReceipt, TransactionReceiptStatus, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
+import * as _ from 'lodash';
+
+import { web3Wrapper } from './web3_wrapper';
+
+const expect = chai.expect;
+
+let nodeType: NodeType | undefined;
+
+// Represents the return value of a `sendTransaction` call. The Promise should
+// resolve with either a transaction receipt or a transaction hash.
+export type sendTransactionResult = Promise<TransactionReceipt | TransactionReceiptWithDecodedLogs | string>;
+
+async function _getGanacheOrGethError(ganacheError: string, gethError: string): Promise<string> {
+ if (_.isUndefined(nodeType)) {
+ nodeType = await web3Wrapper.getNodeTypeAsync();
+ }
+ switch (nodeType) {
+ case NodeType.Ganache:
+ return ganacheError;
+ case NodeType.Geth:
+ return gethError;
+ default:
+ throw new Error(`Unknown node type: ${nodeType}`);
+ }
+}
+
+async function _getInsufficientFundsErrorMessageAsync(): Promise<string> {
+ return _getGanacheOrGethError("sender doesn't have enough funds", 'insufficient funds');
+}
+
+async function _getTransactionFailedErrorMessageAsync(): Promise<string> {
+ return _getGanacheOrGethError('revert', 'always failing transaction');
+}
+
+async function _getContractCallFailedErrorMessageAsync(): Promise<string> {
+ return _getGanacheOrGethError('revert', 'Contract call failed');
+}
+
+/**
+ * Rejects if the given Promise does not reject with an error indicating
+ * insufficient funds.
+ * @param p a promise resulting from a contract call or sendTransaction call.
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
+export async function expectInsufficientFundsAsync<T>(p: Promise<T>): Promise<void> {
+ const errMessage = await _getInsufficientFundsErrorMessageAsync();
+ return expect(p).to.be.rejectedWith(errMessage);
+}
+
+/**
+ * Resolves if the the sendTransaction call fails with the given revert reason.
+ * However, since Geth does not support revert reasons for sendTransaction, this
+ * falls back to expectTransactionFailedWithoutReasonAsync if the backing
+ * Ethereum node is Geth.
+ * @param p a Promise resulting from a sendTransaction call
+ * @param reason a specific revert reason
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
+export async function expectTransactionFailedAsync(p: sendTransactionResult, reason: RevertReason): Promise<void> {
+ // HACK(albrow): This dummy `catch` should not be necessary, but if you
+ // remove it, there is an uncaught exception and the Node process will
+ // forcibly exit. It's possible this is a false positive in
+ // make-promises-safe.
+ p.catch(e => {
+ _.noop(e);
+ });
+
+ if (_.isUndefined(nodeType)) {
+ nodeType = await web3Wrapper.getNodeTypeAsync();
+ }
+ switch (nodeType) {
+ case NodeType.Ganache:
+ return expect(p).to.be.rejectedWith(reason);
+ case NodeType.Geth:
+ logUtils.warn(
+ 'WARNING: Geth does not support revert reasons for sendTransaction. This test will pass if the transaction fails for any reason.',
+ );
+ return expectTransactionFailedWithoutReasonAsync(p);
+ default:
+ throw new Error(`Unknown node type: ${nodeType}`);
+ }
+}
+
+/**
+ * Resolves if the transaction fails without a revert reason, or if the
+ * corresponding transactionReceipt has a status of 0 or '0', indicating
+ * failure.
+ * @param p a Promise resulting from a sendTransaction call
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
+export async function expectTransactionFailedWithoutReasonAsync(p: sendTransactionResult): Promise<void> {
+ return p
+ .then(async result => {
+ let txReceiptStatus: TransactionReceiptStatus;
+ if (_.isString(result)) {
+ // Result is a txHash. We need to make a web3 call to get the
+ // receipt, then get the status from the receipt.
+ const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(result);
+ txReceiptStatus = txReceipt.status;
+ } else if ('status' in result) {
+ // Result is a transaction receipt, so we can get the status
+ // directly.
+ txReceiptStatus = result.status;
+ } else {
+ throw new Error('Unexpected result type: ' + typeof result);
+ }
+ expect(_.toString(txReceiptStatus)).to.equal(
+ '0',
+ 'Expected transaction to fail but receipt had a non-zero status, indicating success',
+ );
+ })
+ .catch(async err => {
+ // If the promise rejects, we expect a specific error message,
+ // depending on the backing Ethereum node type.
+ const errMessage = await _getTransactionFailedErrorMessageAsync();
+ expect(err.message).to.include(errMessage);
+ });
+}
+
+/**
+ * Resolves if the the contract call fails with the given revert reason.
+ * @param p a Promise resulting from a contract call
+ * @param reason a specific revert reason
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
+export async function expectContractCallFailed<T>(p: Promise<T>, reason: RevertReason): Promise<void> {
+ return expect(p).to.be.rejectedWith(reason);
+}
+
+/**
+ * Resolves if the contract call fails without a revert reason.
+ * @param p a Promise resulting from a contract call
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
+export async function expectContractCallFailedWithoutReasonAsync<T>(p: Promise<T>): Promise<void> {
+ const errMessage = await _getContractCallFailedErrorMessageAsync();
+ return expect(p).to.be.rejectedWith(errMessage);
+}
+
+/**
+ * Resolves if the contract creation/deployment fails without a revert reason.
+ * @param p a Promise resulting from a contract creation/deployment
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
+export async function expectContractCreationFailedWithoutReason<T>(p: Promise<T>): Promise<void> {
+ const errMessage = await _getTransactionFailedErrorMessageAsync();
+ return expect(p).to.be.rejectedWith(errMessage);
+}
diff --git a/packages/contracts/src/utils/asset_wrapper.ts b/packages/contracts/test/utils/asset_wrapper.ts
index a7f91f413..f291170a2 100644
--- a/packages/contracts/src/utils/asset_wrapper.ts
+++ b/packages/contracts/test/utils/asset_wrapper.ts
@@ -3,8 +3,7 @@ import { AssetProxyId } from '@0xproject/types';
import { BigNumber, errorUtils } from '@0xproject/utils';
import * as _ from 'lodash';
-import { AbstractAssetWrapper } from '../abstract/abstract_asset_wrapper';
-
+import { AbstractAssetWrapper } from './abstract_asset_wrapper';
import { constants } from './constants';
import { ERC20Wrapper } from './erc20_wrapper';
import { ERC721Wrapper } from './erc721_wrapper';
@@ -85,8 +84,15 @@ export class AssetWrapper {
userAddress,
);
} else if (tokenOwner === userAddress && desiredBalance.eq(0)) {
- // Burn token
- await erc721Wrapper.burnAsync(assetProxyData.tokenAddress, assetProxyData.tokenId, userAddress);
+ // Transfer token to someone else
+ const userAddresses = await (erc721Wrapper as any)._web3Wrapper.getAvailableAddressesAsync();
+ const nonOwner = _.find(userAddresses, a => a !== userAddress);
+ await erc721Wrapper.transferFromAsync(
+ assetProxyData.tokenAddress,
+ assetProxyData.tokenId,
+ tokenOwner,
+ nonOwner,
+ );
return;
} else if (
(userAddress !== tokenOwner && desiredBalance.eq(0)) ||
diff --git a/packages/contracts/src/utils/chai_setup.ts b/packages/contracts/test/utils/chai_setup.ts
index 1a8733093..1a8733093 100644
--- a/packages/contracts/src/utils/chai_setup.ts
+++ b/packages/contracts/test/utils/chai_setup.ts
diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/test/utils/constants.ts
index 2b2bd2425..7f3ad62e1 100644
--- a/packages/contracts/src/utils/constants.ts
+++ b/packages/contracts/test/utils/constants.ts
@@ -18,7 +18,6 @@ const TESTRPC_PRIVATE_KEYS_STRINGS = [
export const constants = {
INVALID_OPCODE: 'invalid opcode',
- REVERT: 'revert',
TESTRPC_NETWORK_ID: 50,
// Note(albrow): In practice V8 and most other engines limit the minimum
// interval for setInterval to 10ms. We still set it to 0 here in order to
@@ -27,6 +26,7 @@ export const constants = {
MAX_ETHERTOKEN_WITHDRAW_GAS: 43000,
MAX_TOKEN_TRANSFERFROM_GAS: 80000,
MAX_TOKEN_APPROVE_GAS: 60000,
+ TRANSFER_FROM_GAS: 150000,
DUMMY_TOKEN_NAME: '',
DUMMY_TOKEN_SYMBOL: '',
DUMMY_TOKEN_DECIMALS: new BigNumber(18),
diff --git a/packages/contracts/src/utils/core_combinatorial_utils.ts b/packages/contracts/test/utils/core_combinatorial_utils.ts
index 5b725fbe3..8c6c83014 100644
--- a/packages/contracts/src/utils/core_combinatorial_utils.ts
+++ b/packages/contracts/test/utils/core_combinatorial_utils.ts
@@ -14,20 +14,21 @@ import { LogWithDecodedArgs, Provider, TxData } from 'ethereum-types';
import * as _ from 'lodash';
import 'make-promises-safe';
-import { ExchangeContract, FillContractEventArgs } from '../generated_contract_wrappers/exchange';
-import { artifacts } from '../utils/artifacts';
-import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../utils/assertions';
-import { AssetWrapper } from '../utils/asset_wrapper';
-import { chaiSetup } from '../utils/chai_setup';
-import { constants } from '../utils/constants';
-import { ERC20Wrapper } from '../utils/erc20_wrapper';
-import { ERC721Wrapper } from '../utils/erc721_wrapper';
-import { ExchangeWrapper } from '../utils/exchange_wrapper';
-import { OrderFactoryFromScenario } from '../utils/order_factory_from_scenario';
-import { orderUtils } from '../utils/order_utils';
-import { signingUtils } from '../utils/signing_utils';
-import { SimpleAssetBalanceAndProxyAllowanceFetcher } from '../utils/simple_asset_balance_and_proxy_allowance_fetcher';
-import { SimpleOrderFilledCancelledFetcher } from '../utils/simple_order_filled_cancelled_fetcher';
+import { ExchangeContract, FillContractEventArgs } from '../../generated_contract_wrappers/exchange';
+
+import { artifacts } from './artifacts';
+import { expectTransactionFailedAsync } from './assertions';
+import { AssetWrapper } from './asset_wrapper';
+import { chaiSetup } from './chai_setup';
+import { constants } from './constants';
+import { ERC20Wrapper } from './erc20_wrapper';
+import { ERC721Wrapper } from './erc721_wrapper';
+import { ExchangeWrapper } from './exchange_wrapper';
+import { OrderFactoryFromScenario } from './order_factory_from_scenario';
+import { orderUtils } from './order_utils';
+import { signingUtils } from './signing_utils';
+import { SimpleAssetBalanceAndProxyAllowanceFetcher } from './simple_asset_balance_and_proxy_allowance_fetcher';
+import { SimpleOrderFilledCancelledFetcher } from './simple_order_filled_cancelled_fetcher';
import {
AllowanceAmountScenario,
AssetDataScenario,
@@ -39,7 +40,7 @@ import {
TakerAssetFillAmountScenario,
TakerScenario,
TraderStateScenario,
-} from '../utils/types';
+} from './types';
chaiSetup.configure();
const expect = chai.expect;
@@ -74,7 +75,7 @@ export async function coreCombinatorialUtilsFactoryAsync(
const zrxAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
const erc20FiveDecimalTokenCount = 2;
- const fiveDecimals = new BigNumber(18);
+ const fiveDecimals = new BigNumber(5);
const [erc20FiveDecimalTokenA, erc20FiveDecimalTokenB] = await erc20Wrapper.deployDummyTokensAsync(
erc20FiveDecimalTokenCount,
fiveDecimals,
@@ -96,8 +97,8 @@ export async function coreCombinatorialUtilsFactoryAsync(
zrxAssetData,
);
const exchangeWrapper = new ExchangeWrapper(exchangeContract, provider);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, ownerAddress);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, ownerAddress);
+ await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, ownerAddress);
+ await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, ownerAddress);
await web3Wrapper.awaitTransactionSuccessAsync(
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeContract.address, {
@@ -145,13 +146,39 @@ export class CoreCombinatorialUtils {
public exchangeWrapper: ExchangeWrapper;
public assetWrapper: AssetWrapper;
public static generateFillOrderCombinations(): FillScenario[] {
- const takerScenarios = [TakerScenario.Unspecified];
- const feeRecipientScenarios = [FeeRecipientAddressScenario.EthUserAddress];
- const makerAssetAmountScenario = [OrderAssetAmountScenario.Large];
- const takerAssetAmountScenario = [OrderAssetAmountScenario.Large];
- const makerFeeScenario = [OrderAssetAmountScenario.Large];
- const takerFeeScenario = [OrderAssetAmountScenario.Large];
- const expirationTimeSecondsScenario = [ExpirationTimeSecondsScenario.InFuture];
+ const takerScenarios = [
+ TakerScenario.Unspecified,
+ // TakerScenario.CorrectlySpecified,
+ // TakerScenario.IncorrectlySpecified,
+ ];
+ const feeRecipientScenarios = [
+ FeeRecipientAddressScenario.EthUserAddress,
+ // FeeRecipientAddressScenario.BurnAddress,
+ ];
+ const makerAssetAmountScenario = [
+ OrderAssetAmountScenario.Large,
+ // OrderAssetAmountScenario.Zero,
+ // OrderAssetAmountScenario.Small,
+ ];
+ const takerAssetAmountScenario = [
+ OrderAssetAmountScenario.Large,
+ // OrderAssetAmountScenario.Zero,
+ // OrderAssetAmountScenario.Small,
+ ];
+ const makerFeeScenario = [
+ OrderAssetAmountScenario.Large,
+ // OrderAssetAmountScenario.Small,
+ // OrderAssetAmountScenario.Zero,
+ ];
+ const takerFeeScenario = [
+ OrderAssetAmountScenario.Large,
+ // OrderAssetAmountScenario.Small,
+ // OrderAssetAmountScenario.Zero,
+ ];
+ const expirationTimeSecondsScenario = [
+ ExpirationTimeSecondsScenario.InFuture,
+ ExpirationTimeSecondsScenario.InPast,
+ ];
const makerAssetDataScenario = [
AssetDataScenario.ERC20FiveDecimals,
AssetDataScenario.ERC20NonZRXEighteenDecimals,
@@ -164,7 +191,55 @@ export class CoreCombinatorialUtils {
AssetDataScenario.ERC721,
AssetDataScenario.ZRXFeeToken,
];
- const takerAssetFillAmountScenario = [TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount];
+ const takerAssetFillAmountScenario = [
+ TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount,
+ // TakerAssetFillAmountScenario.GreaterThanRemainingFillableTakerAssetAmount,
+ // TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount,
+ ];
+ const makerAssetBalanceScenario = [
+ BalanceAmountScenario.Higher,
+ // BalanceAmountScenario.Exact,
+ // BalanceAmountScenario.TooLow,
+ ];
+ const makerAssetAllowanceScenario = [
+ AllowanceAmountScenario.Higher,
+ // AllowanceAmountScenario.Exact,
+ // AllowanceAmountScenario.TooLow,
+ // AllowanceAmountScenario.Unlimited,
+ ];
+ const makerZRXBalanceScenario = [
+ BalanceAmountScenario.Higher,
+ // BalanceAmountScenario.Exact,
+ // BalanceAmountScenario.TooLow,
+ ];
+ const makerZRXAllowanceScenario = [
+ AllowanceAmountScenario.Higher,
+ // AllowanceAmountScenario.Exact,
+ // AllowanceAmountScenario.TooLow,
+ // AllowanceAmountScenario.Unlimited,
+ ];
+ const takerAssetBalanceScenario = [
+ BalanceAmountScenario.Higher,
+ // BalanceAmountScenario.Exact,
+ // BalanceAmountScenario.TooLow,
+ ];
+ const takerAssetAllowanceScenario = [
+ AllowanceAmountScenario.Higher,
+ // AllowanceAmountScenario.Exact,
+ // AllowanceAmountScenario.TooLow,
+ // AllowanceAmountScenario.Unlimited,
+ ];
+ const takerZRXBalanceScenario = [
+ BalanceAmountScenario.Higher,
+ // BalanceAmountScenario.Exact,
+ // BalanceAmountScenario.TooLow,
+ ];
+ const takerZRXAllowanceScenario = [
+ AllowanceAmountScenario.Higher,
+ // AllowanceAmountScenario.Exact,
+ // AllowanceAmountScenario.TooLow,
+ // AllowanceAmountScenario.Unlimited,
+ ];
const fillScenarioArrays = CoreCombinatorialUtils._getAllCombinations([
takerScenarios,
feeRecipientScenarios,
@@ -176,9 +251,18 @@ export class CoreCombinatorialUtils {
makerAssetDataScenario,
takerAssetDataScenario,
takerAssetFillAmountScenario,
+ makerAssetBalanceScenario,
+ makerAssetAllowanceScenario,
+ makerZRXBalanceScenario,
+ makerZRXAllowanceScenario,
+ takerAssetBalanceScenario,
+ takerAssetAllowanceScenario,
+ takerZRXBalanceScenario,
+ takerZRXAllowanceScenario,
]);
const fillScenarios = _.map(fillScenarioArrays, fillScenarioArray => {
+ // tslint:disable:custom-no-magic-numbers
const fillScenario: FillScenario = {
orderScenario: {
takerScenario: fillScenarioArray[0] as TakerScenario,
@@ -193,18 +277,19 @@ export class CoreCombinatorialUtils {
},
takerAssetFillAmountScenario: fillScenarioArray[9] as TakerAssetFillAmountScenario,
makerStateScenario: {
- traderAssetBalance: BalanceAmountScenario.Higher,
- traderAssetAllowance: AllowanceAmountScenario.Higher,
- zrxFeeBalance: BalanceAmountScenario.Higher,
- zrxFeeAllowance: AllowanceAmountScenario.Higher,
+ traderAssetBalance: fillScenarioArray[10] as BalanceAmountScenario,
+ traderAssetAllowance: fillScenarioArray[11] as AllowanceAmountScenario,
+ zrxFeeBalance: fillScenarioArray[12] as BalanceAmountScenario,
+ zrxFeeAllowance: fillScenarioArray[13] as AllowanceAmountScenario,
},
takerStateScenario: {
- traderAssetBalance: BalanceAmountScenario.Higher,
- traderAssetAllowance: AllowanceAmountScenario.Higher,
- zrxFeeBalance: BalanceAmountScenario.Higher,
- zrxFeeAllowance: AllowanceAmountScenario.Higher,
+ traderAssetBalance: fillScenarioArray[14] as BalanceAmountScenario,
+ traderAssetAllowance: fillScenarioArray[15] as AllowanceAmountScenario,
+ zrxFeeBalance: fillScenarioArray[16] as BalanceAmountScenario,
+ zrxFeeAllowance: fillScenarioArray[17] as AllowanceAmountScenario,
},
};
+ // tslint:enable:custom-no-magic-numbers
return fillScenario;
});
@@ -333,7 +418,7 @@ export class CoreCombinatorialUtils {
fillRevertReasonIfExists: RevertReason | undefined,
): Promise<void> {
if (!_.isUndefined(fillRevertReasonIfExists)) {
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedAsync(
this.exchangeWrapper.fillOrderAsync(signedOrder, this.takerAddress, { takerAssetFillAmount }),
fillRevertReasonIfExists,
);
@@ -767,25 +852,17 @@ export class CoreCombinatorialUtils {
case AllowanceAmountScenario.TooLow:
const tooLowAllowance = takerFee.minus(1);
- await this.assetWrapper.setProxyAllowanceAsync(
- signedOrder.takerAddress,
- this.zrxAssetData,
- tooLowAllowance,
- );
+ await this.assetWrapper.setProxyAllowanceAsync(this.takerAddress, this.zrxAssetData, tooLowAllowance);
break;
case AllowanceAmountScenario.Exact:
const exactAllowance = takerFee;
- await this.assetWrapper.setProxyAllowanceAsync(
- signedOrder.takerAddress,
- this.zrxAssetData,
- exactAllowance,
- );
+ await this.assetWrapper.setProxyAllowanceAsync(this.takerAddress, this.zrxAssetData, exactAllowance);
break;
case AllowanceAmountScenario.Unlimited:
await this.assetWrapper.setProxyAllowanceAsync(
- signedOrder.takerAddress,
+ this.takerAddress,
this.zrxAssetData,
constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS,
);
diff --git a/packages/contracts/src/utils/coverage.ts b/packages/contracts/test/utils/coverage.ts
index de29a3ecc..de29a3ecc 100644
--- a/packages/contracts/src/utils/coverage.ts
+++ b/packages/contracts/test/utils/coverage.ts
diff --git a/packages/contracts/src/utils/erc20_wrapper.ts b/packages/contracts/test/utils/erc20_wrapper.ts
index 7f00e2061..53e9791bc 100644
--- a/packages/contracts/src/utils/erc20_wrapper.ts
+++ b/packages/contracts/test/utils/erc20_wrapper.ts
@@ -4,8 +4,8 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../generated_contract_wrappers/dummy_e_r_c20_token';
-import { ERC20ProxyContract } from '../generated_contract_wrappers/e_r_c20_proxy';
+import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c20_token';
+import { ERC20ProxyContract } from '../../generated_contract_wrappers/e_r_c20_proxy';
import { artifacts } from './artifacts';
import { constants } from './constants';
diff --git a/packages/contracts/src/utils/erc721_wrapper.ts b/packages/contracts/test/utils/erc721_wrapper.ts
index 309135ae4..6347f56e7 100644
--- a/packages/contracts/src/utils/erc721_wrapper.ts
+++ b/packages/contracts/test/utils/erc721_wrapper.ts
@@ -4,8 +4,8 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC721TokenContract } from '../generated_contract_wrappers/dummy_e_r_c721_token';
-import { ERC721ProxyContract } from '../generated_contract_wrappers/e_r_c721_proxy';
+import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c721_token';
+import { ERC721ProxyContract } from '../../generated_contract_wrappers/e_r_c721_proxy';
import { artifacts } from './artifacts';
import { constants } from './constants';
diff --git a/packages/contracts/src/utils/exchange_wrapper.ts b/packages/contracts/test/utils/exchange_wrapper.ts
index ad68c8ff4..155d0eeb0 100644
--- a/packages/contracts/src/utils/exchange_wrapper.ts
+++ b/packages/contracts/test/utils/exchange_wrapper.ts
@@ -1,12 +1,10 @@
-import { AssetProxyId, SignedOrder } from '@0xproject/types';
+import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
-import * as _ from 'lodash';
-import { ExchangeContract } from '../generated_contract_wrappers/exchange';
+import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
-import { constants } from './constants';
import { formatters } from './formatters';
import { LogDecoder } from './log_decoder';
import { orderUtils } from './order_utils';
@@ -192,20 +190,10 @@ export class ExchangeWrapper {
return tx;
}
public async registerAssetProxyAsync(
- assetProxyId: AssetProxyId,
assetProxyAddress: string,
from: string,
- opts: { oldAssetProxyAddressIfExists?: string } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const oldAssetProxyAddress = _.isUndefined(opts.oldAssetProxyAddressIfExists)
- ? constants.NULL_ADDRESS
- : opts.oldAssetProxyAddressIfExists;
- const txHash = await this._exchange.registerAssetProxy.sendTransactionAsync(
- assetProxyId,
- assetProxyAddress,
- oldAssetProxyAddress,
- { from },
- );
+ const txHash = await this._exchange.registerAssetProxy.sendTransactionAsync(assetProxyAddress, { from });
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
diff --git a/packages/contracts/src/utils/formatters.ts b/packages/contracts/test/utils/formatters.ts
index 32e4787d6..32e4787d6 100644
--- a/packages/contracts/src/utils/formatters.ts
+++ b/packages/contracts/test/utils/formatters.ts
diff --git a/packages/contracts/src/utils/increase_time.ts b/packages/contracts/test/utils/increase_time.ts
index 4565d8dbc..4565d8dbc 100644
--- a/packages/contracts/src/utils/increase_time.ts
+++ b/packages/contracts/test/utils/increase_time.ts
diff --git a/packages/contracts/src/utils/log_decoder.ts b/packages/contracts/test/utils/log_decoder.ts
index 07127ba79..07127ba79 100644
--- a/packages/contracts/src/utils/log_decoder.ts
+++ b/packages/contracts/test/utils/log_decoder.ts
diff --git a/packages/contracts/src/utils/match_order_tester.ts b/packages/contracts/test/utils/match_order_tester.ts
index fbb1b99db..6145779b0 100644
--- a/packages/contracts/src/utils/match_order_tester.ts
+++ b/packages/contracts/test/utils/match_order_tester.ts
@@ -4,15 +4,11 @@ import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { chaiSetup } from '../utils/chai_setup';
-import { ERC20Wrapper } from '../utils/erc20_wrapper';
-import { ERC721Wrapper } from '../utils/erc721_wrapper';
-import { ExchangeWrapper } from '../utils/exchange_wrapper';
-import {
- ERC20BalancesByOwner,
- ERC721TokenIdsByOwner,
- TransferAmountsByMatchOrders as TransferAmounts,
-} from '../utils/types';
+import { chaiSetup } from './chai_setup';
+import { ERC20Wrapper } from './erc20_wrapper';
+import { ERC721Wrapper } from './erc721_wrapper';
+import { ExchangeWrapper } from './exchange_wrapper';
+import { ERC20BalancesByOwner, ERC721TokenIdsByOwner, TransferAmountsByMatchOrders as TransferAmounts } from './types';
chaiSetup.configure();
const expect = chai.expect;
diff --git a/packages/contracts/src/utils/multi_sig_wrapper.ts b/packages/contracts/test/utils/multi_sig_wrapper.ts
index b0d4fa8ab..6e7746dfc 100644
--- a/packages/contracts/src/utils/multi_sig_wrapper.ts
+++ b/packages/contracts/test/utils/multi_sig_wrapper.ts
@@ -3,8 +3,8 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
-import { AssetProxyOwnerContract } from '../generated_contract_wrappers/asset_proxy_owner';
-import { MultiSigWalletContract } from '../generated_contract_wrappers/multi_sig_wallet';
+import { AssetProxyOwnerContract } from '../../generated_contract_wrappers/asset_proxy_owner';
+import { MultiSigWalletContract } from '../../generated_contract_wrappers/multi_sig_wallet';
import { LogDecoder } from './log_decoder';
diff --git a/packages/contracts/src/utils/order_factory.ts b/packages/contracts/test/utils/order_factory.ts
index 009dbc396..009dbc396 100644
--- a/packages/contracts/src/utils/order_factory.ts
+++ b/packages/contracts/test/utils/order_factory.ts
diff --git a/packages/contracts/src/utils/order_factory_from_scenario.ts b/packages/contracts/test/utils/order_factory_from_scenario.ts
index b150e59f6..9670c1a59 100644
--- a/packages/contracts/src/utils/order_factory_from_scenario.ts
+++ b/packages/contracts/test/utils/order_factory_from_scenario.ts
@@ -2,7 +2,7 @@ import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-util
import { Order } from '@0xproject/types';
import { BigNumber, errorUtils } from '@0xproject/utils';
-import { DummyERC721TokenContract } from '../generated_contract_wrappers/dummy_e_r_c721_token';
+import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_e_r_c721_token';
import { constants } from './constants';
import {
diff --git a/packages/contracts/src/utils/order_utils.ts b/packages/contracts/test/utils/order_utils.ts
index 019f6e74b..019f6e74b 100644
--- a/packages/contracts/src/utils/order_utils.ts
+++ b/packages/contracts/test/utils/order_utils.ts
diff --git a/packages/contracts/src/utils/profiler.ts b/packages/contracts/test/utils/profiler.ts
index 85ee24f22..85ee24f22 100644
--- a/packages/contracts/src/utils/profiler.ts
+++ b/packages/contracts/test/utils/profiler.ts
diff --git a/packages/contracts/src/utils/revert_trace.ts b/packages/contracts/test/utils/revert_trace.ts
index 0bf8384bc..0bf8384bc 100644
--- a/packages/contracts/src/utils/revert_trace.ts
+++ b/packages/contracts/test/utils/revert_trace.ts
diff --git a/packages/contracts/src/utils/signing_utils.ts b/packages/contracts/test/utils/signing_utils.ts
index 9c711c72c..9c711c72c 100644
--- a/packages/contracts/src/utils/signing_utils.ts
+++ b/packages/contracts/test/utils/signing_utils.ts
diff --git a/packages/contracts/src/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts b/packages/contracts/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts
index a295a40c4..a295a40c4 100644
--- a/packages/contracts/src/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts
+++ b/packages/contracts/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts
diff --git a/packages/contracts/src/utils/simple_order_filled_cancelled_fetcher.ts b/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts
index 24afe36b7..24afe36b7 100644
--- a/packages/contracts/src/utils/simple_order_filled_cancelled_fetcher.ts
+++ b/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts
diff --git a/packages/contracts/src/utils/token_registry_wrapper.ts b/packages/contracts/test/utils/token_registry_wrapper.ts
index 91895aa59..0abf20e03 100644
--- a/packages/contracts/src/utils/token_registry_wrapper.ts
+++ b/packages/contracts/test/utils/token_registry_wrapper.ts
@@ -1,7 +1,7 @@
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Provider } from 'ethereum-types';
-import { TokenRegistryContract } from '../generated_contract_wrappers/token_registry';
+import { TokenRegistryContract } from '../../generated_contract_wrappers/token_registry';
import { Token } from './types';
diff --git a/packages/contracts/src/utils/transaction_factory.ts b/packages/contracts/test/utils/transaction_factory.ts
index 348c0715d..348c0715d 100644
--- a/packages/contracts/src/utils/transaction_factory.ts
+++ b/packages/contracts/test/utils/transaction_factory.ts
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/test/utils/types.ts
index b792bb90a..b792bb90a 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/test/utils/types.ts
diff --git a/packages/contracts/src/utils/web3_wrapper.ts b/packages/contracts/test/utils/web3_wrapper.ts
index c9d83a02d..c9d83a02d 100644
--- a/packages/contracts/src/utils/web3_wrapper.ts
+++ b/packages/contracts/test/utils/web3_wrapper.ts