diff options
author | Fabio Berger <me@fabioberger.com> | 2018-12-19 00:59:15 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-12-19 00:59:15 +0800 |
commit | 622b9f662e74d571da745047ede097c7a392d09e (patch) | |
tree | 68a9517882b04a3d428f6996e0790ceb82e89be4 /contracts | |
parent | e295eeb8938468b1527d5d81f212766cef40bc81 (diff) | |
parent | 67df5a433d68a2af1a3a03a8bf431629a534dc97 (diff) | |
download | dexon-0x-contracts-622b9f662e74d571da745047ede097c7a392d09e.tar.gz dexon-0x-contracts-622b9f662e74d571da745047ede097c7a392d09e.tar.zst dexon-0x-contracts-622b9f662e74d571da745047ede097c7a392d09e.zip |
Merge branch 'development' into features/orderwatcher_ws
* development: (107 commits)
Fix OrderWatcher title to fix sidebar top
Fix version picker so it doesn't overflow onto two lines
Fix bug in pull_missing_blocks with incorrect start block (#1438)
Pull approval events for ZRX and DAI (#1430)
fix semicolon and apply prettier
Fix dex order quote/base asset assigning (#1432)
Apply prettier
Publish
Updated CHANGELOGS
Rename contracts CHANGELOGs to DEPLOYs
Move Forwarder CHANGELOG entries to extensions CHANGELOG
Make contracts packages not private
Publish
Updated CHANGELOGS
Show @ price in light grey
Updated CHANGELOGS
typeof -> isString
add special case to scrape OHLCV for eth/usd (#1428)
run linter
simplify scaling input logic
...
Diffstat (limited to 'contracts')
-rw-r--r-- | contracts/.solhint.json (renamed from contracts/core/.solhint.json) | 0 | ||||
-rw-r--r-- | contracts/core/src/artifacts/index.ts | 73 | ||||
-rw-r--r-- | contracts/core/src/wrappers/index.ts | 30 | ||||
-rw-r--r-- | contracts/core/test/tutorials/arbitrage.ts | 260 | ||||
-rw-r--r-- | contracts/core/tsconfig.json | 45 | ||||
-rw-r--r-- | contracts/examples/CHANGELOG.json | 11 | ||||
-rw-r--r-- | contracts/examples/CHANGELOG.md | 10 | ||||
-rw-r--r-- | contracts/examples/README.md | 56 | ||||
-rw-r--r-- | contracts/examples/compiler.json | 22 | ||||
-rw-r--r-- | contracts/examples/contracts/ExchangeWrapper/ExchangeWrapper.sol (renamed from contracts/core/contracts/examples/ExchangeWrapper/ExchangeWrapper.sol) | 2 | ||||
-rw-r--r-- | contracts/examples/contracts/Validator/Validator.sol (renamed from contracts/core/contracts/examples/Validator/Validator.sol) | 2 | ||||
-rw-r--r-- | contracts/examples/contracts/Wallet/Wallet.sol (renamed from contracts/core/contracts/examples/Wallet/Wallet.sol) | 2 | ||||
-rw-r--r-- | contracts/examples/contracts/Whitelist/Whitelist.sol (renamed from contracts/core/contracts/examples/Whitelist/Whitelist.sol) | 2 | ||||
-rw-r--r-- | contracts/examples/package.json | 82 | ||||
-rw-r--r-- | contracts/examples/src/artifacts/index.ts | 13 | ||||
-rw-r--r-- | contracts/examples/src/index.ts | 2 | ||||
-rw-r--r-- | contracts/examples/src/wrappers/index.ts | 4 | ||||
-rw-r--r-- | contracts/examples/tsconfig.json | 16 | ||||
-rw-r--r-- | contracts/examples/tslint.json (renamed from contracts/core/tslint.json) | 0 | ||||
-rw-r--r-- | contracts/extensions/CHANGELOG.json | 11 | ||||
-rw-r--r-- | contracts/extensions/CHANGELOG.md | 10 | ||||
-rw-r--r-- | contracts/extensions/DEPLOYS.json | 31 | ||||
-rw-r--r-- | contracts/extensions/README.md | 69 | ||||
-rw-r--r-- | contracts/extensions/compiler.json | 22 | ||||
-rw-r--r-- | contracts/extensions/contracts/DutchAuction/DutchAuction.sol (renamed from contracts/core/contracts/extensions/DutchAuction/DutchAuction.sol) | 4 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/Forwarder.sol (renamed from contracts/core/contracts/extensions/Forwarder/Forwarder.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/MixinAssets.sol (renamed from contracts/core/contracts/extensions/Forwarder/MixinAssets.sol) | 4 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/MixinExchangeWrapper.sol (renamed from contracts/core/contracts/extensions/Forwarder/MixinExchangeWrapper.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/MixinForwarderCore.sol (renamed from contracts/core/contracts/extensions/Forwarder/MixinForwarderCore.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/MixinWeth.sol (renamed from contracts/core/contracts/extensions/Forwarder/MixinWeth.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/interfaces/IAssets.sol (renamed from contracts/core/contracts/extensions/Forwarder/interfaces/IAssets.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/interfaces/IForwarder.sol (renamed from contracts/core/contracts/extensions/Forwarder/interfaces/IForwarder.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/interfaces/IForwarderCore.sol (renamed from contracts/core/contracts/extensions/Forwarder/interfaces/IForwarderCore.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/libs/LibConstants.sol (renamed from contracts/core/contracts/extensions/Forwarder/libs/LibConstants.sol) | 6 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/libs/LibForwarderErrors.sol (renamed from contracts/core/contracts/extensions/Forwarder/libs/LibForwarderErrors.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/mixins/MAssets.sol (renamed from contracts/core/contracts/extensions/Forwarder/mixins/MAssets.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/mixins/MExchangeWrapper.sol (renamed from contracts/core/contracts/extensions/Forwarder/mixins/MExchangeWrapper.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/contracts/Forwarder/mixins/MWeth.sol (renamed from contracts/core/contracts/extensions/Forwarder/mixins/MWeth.sol) | 0 | ||||
-rw-r--r-- | contracts/extensions/package.json | 93 | ||||
-rw-r--r-- | contracts/extensions/src/artifacts/index.ts | 9 | ||||
-rw-r--r-- | contracts/extensions/src/index.ts | 2 | ||||
-rw-r--r-- | contracts/extensions/src/wrappers/index.ts | 2 | ||||
-rw-r--r-- | contracts/extensions/test/extensions/dutch_auction.ts (renamed from contracts/core/test/extensions/dutch_auction.ts) | 24 | ||||
-rw-r--r-- | contracts/extensions/test/extensions/forwarder.ts (renamed from contracts/core/test/extensions/forwarder.ts) | 27 | ||||
-rw-r--r-- | contracts/extensions/test/global_hooks.ts (renamed from contracts/core/test/global_hooks.ts) | 0 | ||||
-rw-r--r-- | contracts/extensions/test/utils/forwarder_wrapper.ts (renamed from contracts/core/test/utils/forwarder_wrapper.ts) | 8 | ||||
-rw-r--r-- | contracts/extensions/tsconfig.json | 11 | ||||
-rw-r--r-- | contracts/extensions/tslint.json | 6 | ||||
-rw-r--r-- | contracts/interfaces/CHANGELOG.json | 11 | ||||
-rw-r--r-- | contracts/interfaces/CHANGELOG.md | 10 | ||||
-rw-r--r-- | contracts/interfaces/README.md | 72 | ||||
-rw-r--r-- | contracts/interfaces/compiler.json | 35 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/AssetProxy/IAssetData.sol (renamed from contracts/core/contracts/protocol/AssetProxy/interfaces/IAssetData.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/AssetProxy/IAssetProxy.sol (renamed from contracts/core/contracts/protocol/AssetProxy/interfaces/IAssetProxy.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/AssetProxy/IAuthorizable.sol (renamed from contracts/core/contracts/protocol/AssetProxy/interfaces/IAuthorizable.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/Exchange/IAssetProxyDispatcher.sol (renamed from contracts/core/contracts/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/Exchange/IExchange.sol (renamed from contracts/core/contracts/protocol/Exchange/interfaces/IExchange.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/Exchange/IExchangeCore.sol (renamed from contracts/core/contracts/protocol/Exchange/interfaces/IExchangeCore.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/Exchange/IMatchOrders.sol (renamed from contracts/core/contracts/protocol/Exchange/interfaces/IMatchOrders.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/Exchange/ISignatureValidator.sol (renamed from contracts/core/contracts/protocol/Exchange/interfaces/ISignatureValidator.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/Exchange/ITransactions.sol (renamed from contracts/core/contracts/protocol/Exchange/interfaces/ITransactions.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/Exchange/IValidator.sol (renamed from contracts/core/contracts/protocol/Exchange/interfaces/IValidator.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/Exchange/IWallet.sol (renamed from contracts/core/contracts/protocol/Exchange/interfaces/IWallet.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/contracts/protocol/Exchange/IWrapperFunctions.sol (renamed from contracts/core/contracts/protocol/Exchange/interfaces/IWrapperFunctions.sol) | 0 | ||||
-rw-r--r-- | contracts/interfaces/package.json | 56 | ||||
-rw-r--r-- | contracts/interfaces/src/artifacts/index.ts | 29 | ||||
-rw-r--r-- | contracts/interfaces/src/index.ts | 2 | ||||
-rw-r--r-- | contracts/interfaces/src/wrappers/index.ts | 12 | ||||
-rw-r--r-- | contracts/interfaces/tsconfig.json | 24 | ||||
-rw-r--r-- | contracts/interfaces/tslint.json | 6 | ||||
-rw-r--r-- | contracts/libs/.solhint.json | 20 | ||||
-rw-r--r-- | contracts/libs/CHANGELOG.json | 11 | ||||
-rw-r--r-- | contracts/libs/CHANGELOG.md | 10 | ||||
-rw-r--r-- | contracts/libs/package.json | 44 | ||||
-rw-r--r-- | contracts/multisig/.solhint.json | 20 | ||||
-rw-r--r-- | contracts/multisig/CHANGELOG.json | 12 | ||||
-rw-r--r-- | contracts/multisig/CHANGELOG.md | 10 | ||||
-rw-r--r-- | contracts/multisig/package.json | 37 | ||||
-rw-r--r-- | contracts/protocol/CHANGELOG.json | 11 | ||||
-rw-r--r-- | contracts/protocol/CHANGELOG.md | 10 | ||||
-rw-r--r-- | contracts/protocol/DEPLOYS.json (renamed from contracts/core/CHANGELOG.json) | 45 | ||||
-rw-r--r-- | contracts/protocol/README.md (renamed from contracts/core/README.md) | 12 | ||||
-rw-r--r-- | contracts/protocol/compiler.json (renamed from contracts/core/compiler.json) | 23 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/AssetProxy/ERC20Proxy.sol (renamed from contracts/core/contracts/protocol/AssetProxy/ERC20Proxy.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/AssetProxy/ERC721Proxy.sol (renamed from contracts/core/contracts/protocol/AssetProxy/ERC721Proxy.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/AssetProxy/MixinAuthorizable.sol (renamed from contracts/core/contracts/protocol/AssetProxy/MixinAuthorizable.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol (renamed from contracts/core/contracts/protocol/AssetProxy/MultiAssetProxy.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol (renamed from contracts/core/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol) | 2 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol (renamed from contracts/core/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/Exchange.sol (renamed from contracts/core/contracts/protocol/Exchange/Exchange.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol (renamed from contracts/core/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol) | 2 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/MixinExchangeCore.sol (renamed from contracts/core/contracts/protocol/Exchange/MixinExchangeCore.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/MixinMatchOrders.sol (renamed from contracts/core/contracts/protocol/Exchange/MixinMatchOrders.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/MixinSignatureValidator.sol (renamed from contracts/core/contracts/protocol/Exchange/MixinSignatureValidator.sol) | 4 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/MixinTransactions.sol (renamed from contracts/core/contracts/protocol/Exchange/MixinTransactions.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/MixinWrapperFunctions.sol (renamed from contracts/core/contracts/protocol/Exchange/MixinWrapperFunctions.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol (renamed from contracts/core/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol) | 2 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/mixins/MExchangeCore.sol (renamed from contracts/core/contracts/protocol/Exchange/mixins/MExchangeCore.sol) | 2 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/mixins/MMatchOrders.sol (renamed from contracts/core/contracts/protocol/Exchange/mixins/MMatchOrders.sol) | 2 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/mixins/MSignatureValidator.sol (renamed from contracts/core/contracts/protocol/Exchange/mixins/MSignatureValidator.sol) | 2 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/mixins/MTransactions.sol (renamed from contracts/core/contracts/protocol/Exchange/mixins/MTransactions.sol) | 2 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol (renamed from contracts/core/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol) | 2 | ||||
-rw-r--r-- | contracts/protocol/contracts/protocol/OrderValidator/OrderValidator.sol (renamed from contracts/core/contracts/extensions/OrderValidator/OrderValidator.sol) | 6 | ||||
-rw-r--r-- | contracts/protocol/contracts/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol (renamed from contracts/core/contracts/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/test/TestAssetProxyOwner/TestAssetProxyOwner.sol (renamed from contracts/core/contracts/test/TestAssetProxyOwner/TestAssetProxyOwner.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/test/TestExchangeInternals/TestExchangeInternals.sol (renamed from contracts/core/contracts/test/TestExchangeInternals/TestExchangeInternals.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/test/TestSignatureValidator/TestSignatureValidator.sol (renamed from contracts/core/contracts/test/TestSignatureValidator/TestSignatureValidator.sol) | 0 | ||||
-rw-r--r-- | contracts/protocol/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol (renamed from contracts/core/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol) | 2 | ||||
-rw-r--r-- | contracts/protocol/package.json (renamed from contracts/core/package.json) | 55 | ||||
-rw-r--r-- | contracts/protocol/src/artifacts/index.ts | 29 | ||||
-rw-r--r-- | contracts/protocol/src/index.ts | 3 | ||||
-rw-r--r-- | contracts/protocol/src/wrappers/index.ts | 11 | ||||
-rw-r--r-- | contracts/protocol/test/asset_proxy/authorizable.ts (renamed from contracts/core/test/asset_proxy/authorizable.ts) | 0 | ||||
-rw-r--r-- | contracts/protocol/test/asset_proxy/proxies.ts (renamed from contracts/core/test/asset_proxy/proxies.ts) | 28 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/core.ts (renamed from contracts/core/test/exchange/core.ts) | 20 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/dispatcher.ts (renamed from contracts/core/test/exchange/dispatcher.ts) | 2 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/fill_order.ts (renamed from contracts/core/test/exchange/fill_order.ts) | 0 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/internal.ts (renamed from contracts/core/test/exchange/internal.ts) | 0 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/match_orders.ts (renamed from contracts/core/test/exchange/match_orders.ts) | 11 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/order_validator.ts (renamed from contracts/core/test/extensions/order_validator.ts) | 21 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/signature_validator.ts (renamed from contracts/core/test/exchange/signature_validator.ts) | 22 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/transactions.ts (renamed from contracts/core/test/exchange/transactions.ts) | 9 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/wrapper.ts (renamed from contracts/core/test/exchange/wrapper.ts) | 11 | ||||
-rw-r--r-- | contracts/protocol/test/global_hooks.ts | 17 | ||||
-rw-r--r-- | contracts/protocol/test/multisig/asset_proxy_owner.ts (renamed from contracts/core/test/multisig/asset_proxy_owner.ts) | 0 | ||||
-rw-r--r-- | contracts/protocol/test/utils/asset_proxy_owner_wrapper.ts (renamed from contracts/core/test/utils/asset_proxy_owner_wrapper.ts) | 3 | ||||
-rw-r--r-- | contracts/protocol/test/utils/asset_wrapper.ts (renamed from contracts/core/test/utils/asset_wrapper.ts) | 0 | ||||
-rw-r--r-- | contracts/protocol/test/utils/erc20_wrapper.ts (renamed from contracts/core/test/utils/erc20_wrapper.ts) | 4 | ||||
-rw-r--r-- | contracts/protocol/test/utils/erc721_wrapper.ts (renamed from contracts/core/test/utils/erc721_wrapper.ts) | 4 | ||||
-rw-r--r-- | contracts/protocol/test/utils/exchange_wrapper.ts (renamed from contracts/core/test/utils/exchange_wrapper.ts) | 5 | ||||
-rw-r--r-- | contracts/protocol/test/utils/fill_order_combinatorial_utils.ts (renamed from contracts/core/test/utils/fill_order_combinatorial_utils.ts) | 0 | ||||
-rw-r--r-- | contracts/protocol/test/utils/index.ts | 3 | ||||
-rw-r--r-- | contracts/protocol/test/utils/match_order_tester.ts (renamed from contracts/core/test/utils/match_order_tester.ts) | 0 | ||||
-rw-r--r-- | contracts/protocol/test/utils/order_factory_from_scenario.ts (renamed from contracts/core/test/utils/order_factory_from_scenario.ts) | 3 | ||||
-rw-r--r-- | contracts/protocol/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts (renamed from contracts/core/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts) | 0 | ||||
-rw-r--r-- | contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts (renamed from contracts/core/test/utils/simple_order_filled_cancelled_fetcher.ts) | 0 | ||||
-rw-r--r-- | contracts/protocol/tsconfig.json | 24 | ||||
-rw-r--r-- | contracts/protocol/tslint.json | 6 | ||||
-rw-r--r-- | contracts/test-utils/CHANGELOG.json | 11 | ||||
-rw-r--r-- | contracts/test-utils/CHANGELOG.md | 10 | ||||
-rw-r--r-- | contracts/test-utils/package.json | 36 | ||||
-rw-r--r-- | contracts/test-utils/src/assertions.ts | 14 | ||||
-rw-r--r-- | contracts/test-utils/src/test_with_reference.ts | 6 | ||||
-rw-r--r-- | contracts/tokens/.solhintignore (renamed from contracts/core/.solhintignore) | 0 | ||||
-rw-r--r-- | contracts/tokens/CHANGELOG.json | 11 | ||||
-rw-r--r-- | contracts/tokens/CHANGELOG.md | 10 | ||||
-rw-r--r-- | contracts/tokens/DEPLOYS.json | 16 | ||||
-rw-r--r-- | contracts/tokens/README.md | 74 | ||||
-rw-r--r-- | contracts/tokens/compiler.json | 44 | ||||
-rw-r--r-- | contracts/tokens/contracts/test/DummyERC20Token/DummyERC20Token.sol (renamed from contracts/core/contracts/test/DummyERC20Token/DummyERC20Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol (renamed from contracts/core/contracts/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/test/DummyERC20Token/DummyNoReturnERC20Token.sol (renamed from contracts/core/contracts/test/DummyERC20Token/DummyNoReturnERC20Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/test/DummyERC721Receiver/DummyERC721Receiver.sol (renamed from contracts/core/contracts/test/DummyERC721Receiver/DummyERC721Receiver.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/test/DummyERC721Receiver/InvalidERC721Receiver.sol (renamed from contracts/core/contracts/test/DummyERC721Receiver/InvalidERC721Receiver.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/test/DummyERC721Token/DummyERC721Token.sol (renamed from contracts/core/contracts/test/DummyERC721Token/DummyERC721Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/test/ReentrantERC20Token/ReentrantERC20Token.sol (renamed from contracts/core/contracts/test/ReentrantERC20Token/ReentrantERC20Token.sol) | 2 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ERC20Token/ERC20Token.sol (renamed from contracts/core/contracts/tokens/ERC20Token/ERC20Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ERC20Token/IERC20Token.sol (renamed from contracts/core/contracts/tokens/ERC20Token/IERC20Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ERC20Token/MintableERC20Token.sol (renamed from contracts/core/contracts/tokens/ERC20Token/MintableERC20Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol (renamed from contracts/core/contracts/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ERC721Token/ERC721Token.sol (renamed from contracts/core/contracts/tokens/ERC721Token/ERC721Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ERC721Token/IERC721Receiver.sol (renamed from contracts/core/contracts/tokens/ERC721Token/IERC721Receiver.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ERC721Token/IERC721Token.sol (renamed from contracts/core/contracts/tokens/ERC721Token/IERC721Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ERC721Token/MintableERC721Token.sol (renamed from contracts/core/contracts/tokens/ERC721Token/MintableERC721Token.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/EtherToken/IEtherToken.sol (renamed from contracts/core/contracts/tokens/EtherToken/IEtherToken.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/EtherToken/WETH9.sol (renamed from contracts/core/contracts/tokens/EtherToken/WETH9.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ZRXToken/ERC20Token_v1.sol (renamed from contracts/core/contracts/tokens/ZRXToken/ERC20Token_v1.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ZRXToken/Token_v1.sol (renamed from contracts/core/contracts/tokens/ZRXToken/Token_v1.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol (renamed from contracts/core/contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/contracts/tokens/ZRXToken/ZRXToken.sol (renamed from contracts/core/contracts/tokens/ZRXToken/ZRXToken.sol) | 0 | ||||
-rw-r--r-- | contracts/tokens/package.json | 92 | ||||
-rw-r--r-- | contracts/tokens/src/artifacts/index.ts | 49 | ||||
-rw-r--r-- | contracts/tokens/src/index.ts | 2 | ||||
-rw-r--r-- | contracts/tokens/src/wrappers/index.ts | 21 | ||||
-rw-r--r-- | contracts/tokens/test/erc721_token.ts (renamed from contracts/core/test/tokens/erc721_token.ts) | 8 | ||||
-rw-r--r-- | contracts/tokens/test/global_hooks.ts | 17 | ||||
-rw-r--r-- | contracts/tokens/test/unlimited_allowance_token.ts (renamed from contracts/core/test/tokens/unlimited_allowance_token.ts) | 3 | ||||
-rw-r--r-- | contracts/tokens/test/weth9.ts (renamed from contracts/core/test/tokens/weth9.ts) | 3 | ||||
-rw-r--r-- | contracts/tokens/test/zrx_token.ts (renamed from contracts/core/test/tokens/zrx_token.ts) | 3 | ||||
-rw-r--r-- | contracts/tokens/tsconfig.json | 33 | ||||
-rw-r--r-- | contracts/tokens/tslint.json | 6 | ||||
-rw-r--r-- | contracts/utils/.solhint.json | 20 | ||||
-rw-r--r-- | contracts/utils/CHANGELOG.json | 11 | ||||
-rw-r--r-- | contracts/utils/CHANGELOG.md | 10 | ||||
-rw-r--r-- | contracts/utils/package.json | 42 | ||||
-rw-r--r-- | contracts/utils/test/lib_bytes.ts | 2 |
186 files changed, 1581 insertions, 787 deletions
diff --git a/contracts/core/.solhint.json b/contracts/.solhint.json index 076afe9f3..076afe9f3 100644 --- a/contracts/core/.solhint.json +++ b/contracts/.solhint.json diff --git a/contracts/core/src/artifacts/index.ts b/contracts/core/src/artifacts/index.ts deleted file mode 100644 index d578c36fe..000000000 --- a/contracts/core/src/artifacts/index.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as AssetProxyOwner from '../../generated-artifacts/AssetProxyOwner.json'; -import * as DummyERC20Token from '../../generated-artifacts/DummyERC20Token.json'; -import * as DummyERC721Receiver from '../../generated-artifacts/DummyERC721Receiver.json'; -import * as DummyERC721Token from '../../generated-artifacts/DummyERC721Token.json'; -import * as DummyMultipleReturnERC20Token from '../../generated-artifacts/DummyMultipleReturnERC20Token.json'; -import * as DummyNoReturnERC20Token from '../../generated-artifacts/DummyNoReturnERC20Token.json'; -import * as DutchAuction from '../../generated-artifacts/DutchAuction.json'; -import * as ERC20Proxy from '../../generated-artifacts/ERC20Proxy.json'; -import * as ERC20Token from '../../generated-artifacts/ERC20Token.json'; -import * as ERC721Proxy from '../../generated-artifacts/ERC721Proxy.json'; -import * as ERC721Token from '../../generated-artifacts/ERC721Token.json'; -import * as Exchange from '../../generated-artifacts/Exchange.json'; -import * as ExchangeWrapper from '../../generated-artifacts/ExchangeWrapper.json'; -import * as Forwarder from '../../generated-artifacts/Forwarder.json'; -import * as IAssetData from '../../generated-artifacts/IAssetData.json'; -import * as IAssetProxy from '../../generated-artifacts/IAssetProxy.json'; -import * as InvalidERC721Receiver from '../../generated-artifacts/InvalidERC721Receiver.json'; -import * as IValidator from '../../generated-artifacts/IValidator.json'; -import * as IWallet from '../../generated-artifacts/IWallet.json'; -import * as MixinAuthorizable from '../../generated-artifacts/MixinAuthorizable.json'; -import * as MultiAssetProxy from '../../generated-artifacts/MultiAssetProxy.json'; -import * as OrderValidator from '../../generated-artifacts/OrderValidator.json'; -import * as ReentrantERC20Token from '../../generated-artifacts/ReentrantERC20Token.json'; -import * as TestAssetProxyDispatcher from '../../generated-artifacts/TestAssetProxyDispatcher.json'; -import * as TestAssetProxyOwner from '../../generated-artifacts/TestAssetProxyOwner.json'; -import * as TestExchangeInternals from '../../generated-artifacts/TestExchangeInternals.json'; -import * as TestSignatureValidator from '../../generated-artifacts/TestSignatureValidator.json'; -import * as TestStaticCallReceiver from '../../generated-artifacts/TestStaticCallReceiver.json'; -import * as Validator from '../../generated-artifacts/Validator.json'; -import * as Wallet from '../../generated-artifacts/Wallet.json'; -import * as WETH9 from '../../generated-artifacts/WETH9.json'; -import * as Whitelist from '../../generated-artifacts/Whitelist.json'; -import * as ZRXToken from '../../generated-artifacts/ZRXToken.json'; - -export const artifacts = { - AssetProxyOwner: AssetProxyOwner as ContractArtifact, - DummyERC20Token: DummyERC20Token as ContractArtifact, - DummyERC721Receiver: DummyERC721Receiver as ContractArtifact, - DummyERC721Token: DummyERC721Token as ContractArtifact, - DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, - DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, - DutchAuction: DutchAuction as ContractArtifact, - ERC20Proxy: ERC20Proxy as ContractArtifact, - ERC20Token: ERC20Token as ContractArtifact, - ERC721Proxy: ERC721Proxy as ContractArtifact, - ERC721Token: ERC721Token as ContractArtifact, - Exchange: Exchange as ContractArtifact, - ExchangeWrapper: ExchangeWrapper as ContractArtifact, - Forwarder: Forwarder as ContractArtifact, - IAssetData: IAssetData as ContractArtifact, - IAssetProxy: IAssetProxy as ContractArtifact, - IValidator: IValidator as ContractArtifact, - IWallet: IWallet as ContractArtifact, - InvalidERC721Receiver: InvalidERC721Receiver as ContractArtifact, - MixinAuthorizable: MixinAuthorizable as ContractArtifact, - MultiAssetProxy: MultiAssetProxy as ContractArtifact, - OrderValidator: OrderValidator as ContractArtifact, - ReentrantERC20Token: ReentrantERC20Token as ContractArtifact, - TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact, - TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact, - TestExchangeInternals: TestExchangeInternals as ContractArtifact, - TestSignatureValidator: TestSignatureValidator as ContractArtifact, - TestStaticCallReceiver: TestStaticCallReceiver as ContractArtifact, - Validator: Validator as ContractArtifact, - WETH9: WETH9 as ContractArtifact, - Wallet: Wallet as ContractArtifact, - Whitelist: Whitelist as ContractArtifact, - // Note(albrow): "as any" hack still required here because ZRXToken does not - // conform to the v2 artifact type. - ZRXToken: (ZRXToken as any) as ContractArtifact, -}; diff --git a/contracts/core/src/wrappers/index.ts b/contracts/core/src/wrappers/index.ts deleted file mode 100644 index ed9d8ef47..000000000 --- a/contracts/core/src/wrappers/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -export * from '../../generated-wrappers/asset_proxy_owner'; -export * from '../../generated-wrappers/dummy_erc20_token'; -export * from '../../generated-wrappers/dummy_erc721_receiver'; -export * from '../../generated-wrappers/dummy_erc721_token'; -export * from '../../generated-wrappers/dummy_multiple_return_erc20_token'; -export * from '../../generated-wrappers/dummy_no_return_erc20_token'; -export * from '../../generated-wrappers/dutch_auction'; -export * from '../../generated-wrappers/erc20_proxy'; -export * from '../../generated-wrappers/erc721_proxy'; -export * from '../../generated-wrappers/erc20_token'; -export * from '../../generated-wrappers/erc721_token'; -export * from '../../generated-wrappers/exchange'; -export * from '../../generated-wrappers/exchange_wrapper'; -export * from '../../generated-wrappers/forwarder'; -export * from '../../generated-wrappers/i_asset_data'; -export * from '../../generated-wrappers/i_asset_proxy'; -export * from '../../generated-wrappers/invalid_erc721_receiver'; -export * from '../../generated-wrappers/mixin_authorizable'; -export * from '../../generated-wrappers/order_validator'; -export * from '../../generated-wrappers/reentrant_erc20_token'; -export * from '../../generated-wrappers/test_asset_proxy_dispatcher'; -export * from '../../generated-wrappers/test_asset_proxy_owner'; -export * from '../../generated-wrappers/test_exchange_internals'; -export * from '../../generated-wrappers/test_signature_validator'; -export * from '../../generated-wrappers/test_static_call_receiver'; -export * from '../../generated-wrappers/validator'; -export * from '../../generated-wrappers/wallet'; -export * from '../../generated-wrappers/weth9'; -export * from '../../generated-wrappers/whitelist'; -export * from '../../generated-wrappers/zrx_token'; diff --git a/contracts/core/test/tutorials/arbitrage.ts b/contracts/core/test/tutorials/arbitrage.ts deleted file mode 100644 index 78e0bc238..000000000 --- a/contracts/core/test/tutorials/arbitrage.ts +++ /dev/null @@ -1,260 +0,0 @@ -// import { ECSignature, SignedOrder, ZeroEx } from '0x.js'; -// import { BlockchainLifecycle, devConstants, web3Factory } from '@0x/dev-utils'; -// import { ExchangeContractErrs } from 'ethereum-types'; -// import { BigNumber } from '@0x/utils'; -// import { Web3Wrapper } from '@0x/web3-wrapper'; -// import * as chai from 'chai'; -// import ethUtil = require('ethereumjs-util'); -// import * as Web3 from 'web3'; - -// import { AccountLevelsContract } from '../../src/generated_contract_wrappers/account_levels'; -// import { ArbitrageContract } from '../../src/generated_contract_wrappers/arbitrage'; -// import { DummyTokenContract } from '../../src/generated_contract_wrappers/dummy_token'; -// import { EtherDeltaContract } from '../../src/generated_contract_wrappers/ether_delta'; -// import { ExchangeContract } from '../../src/generated_contract_wrappers/exchange'; -// import { TokenTransferProxyContract } from '../../src/generated_contract_wrappers/token_transfer_proxy'; -// import { artifacts } from '../../util/artifacts'; -// import { Balances } from '../../util/balances'; -// import { constants } from '../../util/constants'; -// import { crypto } from '../../util/crypto'; -// import { ExchangeWrapper } from '../../util/exchange_wrapper'; -// import { OrderFactory } from '../../util/order_factory'; -// import { BalancesByOwner, ContractName } from '../../util/types'; -// import { chaiSetup } from '../utils/chai_setup'; - -// import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper'; - -// chaiSetup.configure(); -// const expect = chai.expect; -// const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); - -// describe('Arbitrage', () => { -// let coinbase: string; -// let maker: string; -// let edMaker: string; -// let edFrontRunner: string; -// let amountGet: BigNumber; -// let amountGive: BigNumber; -// let makerTokenAmount: BigNumber; -// let takerTokenAmount: BigNumber; -// const feeRecipient = constants.NULL_ADDRESS; -// const INITIAL_BALANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18); -// const INITIAL_ALLOWANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18); - -// let weth: DummyTokenContract; -// let zrx: DummyTokenContract; -// let arbitrage: ArbitrageContract; -// let etherDelta: EtherDeltaContract; - -// let signedOrder: SignedOrder; -// let exWrapper: ExchangeWrapper; -// let orderFactory: OrderFactory; - -// let zeroEx: ZeroEx; - -// // From a bird's eye view - we create two orders. -// // 0x order of 1 ZRX (maker) for 1 WETH (taker) -// // ED order of 2 WETH (tokenGive) for 1 ZRX (tokenGet) -// // And then we do an atomic arbitrage between them which gives us 1 WETH. -// before(async () => { -// const accounts = await web3Wrapper.getAvailableAddressesAsync(); -// [coinbase, maker, edMaker, edFrontRunner] = accounts; -// weth = await DummyTokenContract.deployFrom0xArtifactAsync( -// artifacts.DummyToken, -// provider, -// txDefaults, -// constants.DUMMY_TOKEN_NAME, -// constants.DUMMY_TOKEN_SYMBOL, -// constants.DUMMY_TOKEN_DECIMALS, -// constants.DUMMY_TOKEN_TOTAL_SUPPLY, -// ); -// zrx = await DummyTokenContract.deployFrom0xArtifactAsync( -// artifacts.DummyToken, -// provider, -// txDefaults, -// constants.DUMMY_TOKEN_NAME, -// constants.DUMMY_TOKEN_SYMBOL, -// constants.DUMMY_TOKEN_DECIMALS, -// constants.DUMMY_TOKEN_TOTAL_SUPPLY, -// ); -// const accountLevels = await AccountLevelsContract.deployFrom0xArtifactAsync( -// artifacts.AccountLevels, -// provider, -// txDefaults, -// ); -// const edAdminAddress = accounts[0]; -// const edMakerFee = new BigNumber(0); -// const edTakerFee = new BigNumber(0); -// const edFeeRebate = new BigNumber(0); -// etherDelta = await EtherDeltaContract.deployFrom0xArtifactAsync( -// artifacts.EtherDelta, -// provider, -// txDefaults, -// edAdminAddress, -// feeRecipient, -// accountLevels.address, -// edMakerFee, -// edTakerFee, -// edFeeRebate, -// ); -// const tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( -// artifacts.TokenTransferProxy, -// provider, -// txDefaults, -// ); -// const exchange = await ExchangeContract.deployFrom0xArtifactAsync( -// artifacts.Exchange, -// provider, -// txDefaults, -// zrx.address, -// tokenTransferProxy.address, -// ); -// await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: accounts[0] }); -// zeroEx = new ZeroEx(provider, { -// exchangeContractAddress: exchange.address, -// networkId: constants.TESTRPC_NETWORK_ID, -// }); -// exWrapper = new ExchangeWrapper(exchange, provider); - -// makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18); -// takerTokenAmount = makerTokenAmount; -// const defaultOrderParams = { -// exchangeContractAddress: exchange.address, -// maker, -// feeRecipient, -// makerTokenAddress: zrx.address, -// takerTokenAddress: weth.address, -// makerTokenAmount, -// takerTokenAmount, -// makerFee: new BigNumber(0), -// takerFee: new BigNumber(0), -// }; -// orderFactory = new OrderFactory(zeroEx, defaultOrderParams); -// arbitrage = await ArbitrageContract.deployFrom0xArtifactAsync( -// artifacts.Arbitrage, -// provider, -// txDefaults, -// exchange.address, -// etherDelta.address, -// tokenTransferProxy.address, -// ); -// // Enable arbitrage and withdrawals of tokens -// await arbitrage.setAllowances.sendTransactionAsync(weth.address, { from: coinbase }); -// await arbitrage.setAllowances.sendTransactionAsync(zrx.address, { from: coinbase }); - -// // Give some tokens to arbitrage contract -// await weth.setBalance.sendTransactionAsync(arbitrage.address, takerTokenAmount, { from: coinbase }); - -// // Fund the maker on exchange side -// await zrx.setBalance.sendTransactionAsync(maker, makerTokenAmount, { from: coinbase }); -// // Set the allowance for the maker on Exchange side -// await zrx.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, { from: maker }); - -// amountGive = ZeroEx.toBaseUnitAmount(new BigNumber(2), 18); -// // Fund the maker on EtherDelta side -// await weth.setBalance.sendTransactionAsync(edMaker, amountGive, { from: coinbase }); -// // Set the allowance for the maker on EtherDelta side -// await weth.approve.sendTransactionAsync(etherDelta.address, INITIAL_ALLOWANCE, { from: edMaker }); -// // Deposit maker funds into EtherDelta -// await etherDelta.depositToken.sendTransactionAsync(weth.address, amountGive, { from: edMaker }); - -// amountGet = makerTokenAmount; -// // Fund the front runner on EtherDelta side -// await zrx.setBalance.sendTransactionAsync(edFrontRunner, amountGet, { from: coinbase }); -// // Set the allowance for the front-runner on EtherDelta side -// await zrx.approve.sendTransactionAsync(etherDelta.address, INITIAL_ALLOWANCE, { from: edFrontRunner }); -// // Deposit front runner funds into EtherDelta -// await etherDelta.depositToken.sendTransactionAsync(zrx.address, amountGet, { from: edFrontRunner }); -// }); -// beforeEach(async () => { -// await blockchainLifecycle.startAsync(); -// }); -// afterEach(async () => { -// await blockchainLifecycle.revertAsync(); -// }); -// describe('makeAtomicTrade', () => { -// let addresses: string[]; -// let values: BigNumber[]; -// let v: number[]; -// let r: string[]; -// let s: string[]; -// let tokenGet: string; -// let tokenGive: string; -// let expires: BigNumber; -// let nonce: BigNumber; -// let edSignature: ECSignature; -// before(async () => { -// signedOrder = await orderFactory.newSignedOrderAsync(); -// tokenGet = zrx.address; -// tokenGive = weth.address; -// const blockNumber = await web3Wrapper.getBlockNumberAsync(); -// const ED_ORDER_EXPIRATION_IN_BLOCKS = 10; -// expires = new BigNumber(blockNumber + ED_ORDER_EXPIRATION_IN_BLOCKS); -// nonce = new BigNumber(42); -// const edOrderHash = `0x${crypto -// .solSHA256([etherDelta.address, tokenGet, amountGet, tokenGive, amountGive, expires, nonce]) -// .toString('hex')}`; -// const shouldAddPersonalMessagePrefix = false; -// edSignature = await zeroEx.signOrderHashAsync(edOrderHash, edMaker, shouldAddPersonalMessagePrefix); -// addresses = [ -// signedOrder.maker, -// signedOrder.taker, -// signedOrder.makerTokenAddress, -// signedOrder.takerTokenAddress, -// signedOrder.feeRecipient, -// edMaker, -// ]; -// const fillTakerTokenAmount = takerTokenAmount; -// const edFillAmount = makerTokenAmount; -// values = [ -// signedOrder.makerTokenAmount, -// signedOrder.takerTokenAmount, -// signedOrder.makerFee, -// signedOrder.takerFee, -// signedOrder.expirationUnixTimestampSec, -// signedOrder.salt, -// fillTakerTokenAmount, -// amountGet, -// amountGive, -// expires, -// nonce, -// edFillAmount, -// ]; -// v = [signedOrder.ecSignature.v, edSignature.v]; -// r = [signedOrder.ecSignature.r, edSignature.r]; -// s = [signedOrder.ecSignature.s, edSignature.s]; -// }); -// it('should successfully execute the arbitrage if not front-runned', async () => { -// const txHash = await arbitrage.makeAtomicTrade.sendTransactionAsync(addresses, values, v, r, s, { -// from: coinbase, -// }); -// const res = await zeroEx.awaitTransactionMinedAsync(txHash); -// const postBalance = await weth.balanceOf.callAsync(arbitrage.address); -// expect(postBalance).to.be.bignumber.equal(amountGive); -// }); -// it('should fail and revert if front-runned', async () => { -// const preBalance = await weth.balanceOf.callAsync(arbitrage.address); -// // Front-running transaction -// await etherDelta.trade.sendTransactionAsync( -// tokenGet, -// amountGet, -// tokenGive, -// amountGive, -// expires, -// nonce, -// edMaker, -// edSignature.v, -// edSignature.r, -// edSignature.s, -// amountGet, -// { from: edFrontRunner }, -// ); -// // tslint:disable-next-line:await-promise -// await expect( -// arbitrage.makeAtomicTrade.sendTransactionAsync(addresses, values, v, r, s, { from: coinbase }), -// ).to.be.rejectedWith(constants.REVERT); -// const postBalance = await weth.balanceOf.callAsync(arbitrage.address); -// expect(preBalance).to.be.bignumber.equal(postBalance); -// }); -// }); -// }); diff --git a/contracts/core/tsconfig.json b/contracts/core/tsconfig.json deleted file mode 100644 index f2f3c4e97..000000000 --- a/contracts/core/tsconfig.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, - "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], - "files": [ - "./generated-artifacts/AssetProxyOwner.json", - "./generated-artifacts/DummyERC20Token.json", - "./generated-artifacts/DummyERC721Receiver.json", - "./generated-artifacts/DummyERC721Token.json", - "./generated-artifacts/DummyMultipleReturnERC20Token.json", - "./generated-artifacts/DummyNoReturnERC20Token.json", - "./generated-artifacts/DutchAuction.json", - "./generated-artifacts/ERC20Proxy.json", - "./generated-artifacts/ERC20Token.json", - "./generated-artifacts/ERC721Proxy.json", - "./generated-artifacts/ERC721Token.json", - "./generated-artifacts/Exchange.json", - "./generated-artifacts/ExchangeWrapper.json", - "./generated-artifacts/Forwarder.json", - "./generated-artifacts/IAssetData.json", - "./generated-artifacts/IAssetProxy.json", - "./generated-artifacts/IValidator.json", - "./generated-artifacts/IWallet.json", - "./generated-artifacts/InvalidERC721Receiver.json", - "./generated-artifacts/MixinAuthorizable.json", - "./generated-artifacts/MultiAssetProxy.json", - "./generated-artifacts/OrderValidator.json", - "./generated-artifacts/ReentrantERC20Token.json", - "./generated-artifacts/TestAssetProxyDispatcher.json", - "./generated-artifacts/TestAssetProxyOwner.json", - "./generated-artifacts/TestExchangeInternals.json", - "./generated-artifacts/TestSignatureValidator.json", - "./generated-artifacts/TestStaticCallReceiver.json", - "./generated-artifacts/Validator.json", - "./generated-artifacts/WETH9.json", - "./generated-artifacts/Wallet.json", - "./generated-artifacts/Whitelist.json", - "./generated-artifacts/ZRXToken.json" - ], - "exclude": ["./deploy/solc/solc_bin"] -} diff --git a/contracts/examples/CHANGELOG.json b/contracts/examples/CHANGELOG.json new file mode 100644 index 000000000..19ac770af --- /dev/null +++ b/contracts/examples/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "timestamp": 1544741676, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + } +] diff --git a/contracts/examples/CHANGELOG.md b/contracts/examples/CHANGELOG.md new file mode 100644 index 000000000..716353d05 --- /dev/null +++ b/contracts/examples/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _December 13, 2018_ + + * Dependencies updated diff --git a/contracts/examples/README.md b/contracts/examples/README.md new file mode 100644 index 000000000..ca23d0974 --- /dev/null +++ b/contracts/examples/README.md @@ -0,0 +1,56 @@ +## Contract examples + +Example smart contracts that interact with 0x protocol. + +## Usage + +Contracts can be found in the [contracts](./contracts) directory. +This package contains example implementations of contracts that interact with the protocol but are _not_ intended for use in production. Examples include [filter](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#filter-contracts) contracts, a [Wallet](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#wallet) contract, and a [Validator](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#validator) contract, among others. + +## Contributing + +We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. + +For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install Dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/contracts-examples yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0x/contracts-examples yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` diff --git a/contracts/examples/compiler.json b/contracts/examples/compiler.json new file mode 100644 index 000000000..375fa0c55 --- /dev/null +++ b/contracts/examples/compiler.json @@ -0,0 +1,22 @@ +{ + "artifactsDir": "./generated-artifacts", + "contractsDir": "./contracts", + "compilerSettings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode.object", + "evm.bytecode.sourceMap", + "evm.deployedBytecode.object", + "evm.deployedBytecode.sourceMap" + ] + } + } + }, + "contracts": ["ExchangeWrapper", "Validator", "Wallet", "Whitelist"] +} diff --git a/contracts/core/contracts/examples/ExchangeWrapper/ExchangeWrapper.sol b/contracts/examples/contracts/ExchangeWrapper/ExchangeWrapper.sol index ca5a64a26..d98136922 100644 --- a/contracts/core/contracts/examples/ExchangeWrapper/ExchangeWrapper.sol +++ b/contracts/examples/contracts/ExchangeWrapper/ExchangeWrapper.sol @@ -19,7 +19,7 @@ pragma solidity 0.4.24; pragma experimental ABIEncoderV2; -import "../../protocol/Exchange/interfaces/IExchange.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol"; import "@0x/contracts-libs/contracts/libs/LibOrder.sol"; diff --git a/contracts/core/contracts/examples/Validator/Validator.sol b/contracts/examples/contracts/Validator/Validator.sol index 72ed528ba..e488a9ca7 100644 --- a/contracts/core/contracts/examples/Validator/Validator.sol +++ b/contracts/examples/contracts/Validator/Validator.sol @@ -18,7 +18,7 @@ pragma solidity 0.4.24; -import "../../protocol/Exchange/interfaces/IValidator.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IValidator.sol"; contract Validator is diff --git a/contracts/core/contracts/examples/Wallet/Wallet.sol b/contracts/examples/contracts/Wallet/Wallet.sol index 3738be841..8edc74eb3 100644 --- a/contracts/core/contracts/examples/Wallet/Wallet.sol +++ b/contracts/examples/contracts/Wallet/Wallet.sol @@ -18,7 +18,7 @@ pragma solidity 0.4.24; -import "../../protocol/Exchange/interfaces/IWallet.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IWallet.sol"; import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol"; diff --git a/contracts/core/contracts/examples/Whitelist/Whitelist.sol b/contracts/examples/contracts/Whitelist/Whitelist.sol index cfcddddd3..2a3d33738 100644 --- a/contracts/core/contracts/examples/Whitelist/Whitelist.sol +++ b/contracts/examples/contracts/Whitelist/Whitelist.sol @@ -19,7 +19,7 @@ pragma solidity 0.4.24; pragma experimental ABIEncoderV2; -import "../../protocol/Exchange/interfaces/IExchange.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol"; import "@0x/contracts-libs/contracts/libs/LibOrder.sol"; import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol"; diff --git a/contracts/examples/package.json b/contracts/examples/package.json new file mode 100644 index 000000000..77846241e --- /dev/null +++ b/contracts/examples/package.json @@ -0,0 +1,82 @@ +{ + "name": "@0x/contracts-examples", + "version": "1.0.2", + "engines": { + "node": ">=6.12" + }, + "description": "Smart contract examples of 0x protocol", + "main": "lib/src/index.js", + "directories": { + "test": "test" + }, + "scripts": { + "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", + "pre_build": "run-s compile generate_contract_wrappers", + "compile": "sol-compiler --contracts-dir contracts", + "clean": "shx rm -rf lib generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" + }, + "config": { + "abis": "generated-artifacts/@(ExchangeWrapper|Validator|Wallet|Whitelist).json" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/contracts/examples/README.md", + "devDependencies": { + "@0x/abi-gen": "^1.0.19", + "@0x/contracts-test-utils": "^1.0.2", + "@0x/dev-utils": "^1.0.21", + "@0x/sol-compiler": "^1.1.16", + "@0x/sol-cov": "^2.1.16", + "@0x/subproviders": "^2.1.8", + "@0x/tslint-config": "^2.0.0", + "@types/bn.js": "^4.11.0", + "@types/lodash": "4.14.104", + "@types/node": "*", + "@types/yargs": "^10.0.0", + "chai": "^4.0.1", + "chai-as-promised": "^7.1.0", + "chai-bignumber": "^2.0.1", + "dirty-chai": "^2.0.1", + "ethereumjs-abi": "0.6.5", + "make-promises-safe": "^1.1.0", + "mocha": "^4.1.0", + "npm-run-all": "^4.1.2", + "shx": "^0.2.2", + "solc": "^0.4.24", + "solhint": "^1.4.1", + "tslint": "5.11.0", + "typescript": "3.0.1", + "yargs": "^10.0.3" + }, + "dependencies": { + "@0x/base-contract": "^3.0.10", + "@0x/contracts-interfaces": "^1.0.2", + "@0x/contracts-libs": "^1.0.2", + "@0x/contracts-multisig": "^1.0.2", + "@0x/contracts-tokens": "^1.0.2", + "@0x/contracts-utils": "^1.0.2", + "@0x/order-utils": "^3.0.7", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", + "@types/js-combinatorics": "^0.5.29", + "bn.js": "^4.11.8", + "ethereum-types": "^1.1.4", + "ethereumjs-util": "^5.1.1", + "lodash": "^4.17.5" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/contracts/examples/src/artifacts/index.ts b/contracts/examples/src/artifacts/index.ts new file mode 100644 index 000000000..c921fbf89 --- /dev/null +++ b/contracts/examples/src/artifacts/index.ts @@ -0,0 +1,13 @@ +import { ContractArtifact } from 'ethereum-types'; + +import * as ExchangeWrapper from '../../generated-artifacts/ExchangeWrapper.json'; +import * as Validator from '../../generated-artifacts/Validator.json'; +import * as Wallet from '../../generated-artifacts/Wallet.json'; +import * as Whitelist from '../../generated-artifacts/Whitelist.json'; + +export const artifacts = { + ExchangeWrapper: ExchangeWrapper as ContractArtifact, + Validator: Validator as ContractArtifact, + Wallet: Wallet as ContractArtifact, + Whitelist: Whitelist as ContractArtifact, +}; diff --git a/contracts/examples/src/index.ts b/contracts/examples/src/index.ts new file mode 100644 index 000000000..d55f08ea2 --- /dev/null +++ b/contracts/examples/src/index.ts @@ -0,0 +1,2 @@ +export * from './artifacts'; +export * from './wrappers'; diff --git a/contracts/examples/src/wrappers/index.ts b/contracts/examples/src/wrappers/index.ts new file mode 100644 index 000000000..dc67277d7 --- /dev/null +++ b/contracts/examples/src/wrappers/index.ts @@ -0,0 +1,4 @@ +export * from '../../generated-wrappers/exchange_wrapper'; +export * from '../../generated-wrappers/validator'; +export * from '../../generated-wrappers/wallet'; +export * from '../../generated-wrappers/whitelist'; diff --git a/contracts/examples/tsconfig.json b/contracts/examples/tsconfig.json new file mode 100644 index 000000000..63245da1e --- /dev/null +++ b/contracts/examples/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": ".", + "resolveJsonModule": true + }, + "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], + "files": [ + "./generated-artifacts/ExchangeWrapper.json", + "./generated-artifacts/Validator.json", + "./generated-artifacts/Wallet.json", + "./generated-artifacts/Whitelist.json" + ], + "exclude": ["./deploy/solc/solc_bin"] +} diff --git a/contracts/core/tslint.json b/contracts/examples/tslint.json index 1bb3ac2a2..1bb3ac2a2 100644 --- a/contracts/core/tslint.json +++ b/contracts/examples/tslint.json diff --git a/contracts/extensions/CHANGELOG.json b/contracts/extensions/CHANGELOG.json new file mode 100644 index 000000000..19ac770af --- /dev/null +++ b/contracts/extensions/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "timestamp": 1544741676, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + } +] diff --git a/contracts/extensions/CHANGELOG.md b/contracts/extensions/CHANGELOG.md new file mode 100644 index 000000000..716353d05 --- /dev/null +++ b/contracts/extensions/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _December 13, 2018_ + + * Dependencies updated diff --git a/contracts/extensions/DEPLOYS.json b/contracts/extensions/DEPLOYS.json new file mode 100644 index 000000000..1a093bf77 --- /dev/null +++ b/contracts/extensions/DEPLOYS.json @@ -0,0 +1,31 @@ +[ + { + "name": "Forwarder", + "version": "1.1.0", + "changes": [ + { + "note": "Round up when calculating remaining amounts in marketBuy functions", + "pr": 1162, + "networks": { + "1": "0x5468a1dc173652ee28d249c271fa9933144746b1", + "3": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e", + "42": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6" + } + } + ] + }, + { + "name": "Forwarder", + "version": "1.0.0", + "changes": [ + { + "note": "protocol v2 deploy", + "networks": { + "1": "0x7afc2d5107af94c462a194d2c21b5bdd238709d6", + "3": "0x3983e204b12b3c02fb0638caf2cd406a62e0ead3", + "42": "0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8" + } + } + ] + } +] diff --git a/contracts/extensions/README.md b/contracts/extensions/README.md new file mode 100644 index 000000000..820f6e78a --- /dev/null +++ b/contracts/extensions/README.md @@ -0,0 +1,69 @@ +## Contract extensions + +Smart contracts that implement extensions for the 0x protocol. + +## Usage + +Contract extensions of the protocol can be found in the [contracts](./contracts) directory. This directory contains contracts that interact with the 2.0.0 contracts and will be used in production, such as the [Forwarder](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md) contract. + +## Bug bounty + +A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0xproject.com/wiki#Bug-Bounty). + +## Contributing + +We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. + +For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install Dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/contracts-extensions yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0x/contracts-extensions yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` + +#### Testing options + +Contracts testing options like coverage, profiling, revert traces or backing node choosing - are described [here](../TESTING.md). diff --git a/contracts/extensions/compiler.json b/contracts/extensions/compiler.json new file mode 100644 index 000000000..69d607b3e --- /dev/null +++ b/contracts/extensions/compiler.json @@ -0,0 +1,22 @@ +{ + "artifactsDir": "./generated-artifacts", + "contractsDir": "./contracts", + "compilerSettings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode.object", + "evm.bytecode.sourceMap", + "evm.deployedBytecode.object", + "evm.deployedBytecode.sourceMap" + ] + } + } + }, + "contracts": ["DutchAuction", "Forwarder"] +} diff --git a/contracts/core/contracts/extensions/DutchAuction/DutchAuction.sol b/contracts/extensions/contracts/DutchAuction/DutchAuction.sol index a40991ae7..9c9f3990a 100644 --- a/contracts/core/contracts/extensions/DutchAuction/DutchAuction.sol +++ b/contracts/extensions/contracts/DutchAuction/DutchAuction.sol @@ -19,9 +19,9 @@ pragma solidity 0.4.24; pragma experimental ABIEncoderV2; -import "../../protocol/Exchange/interfaces/IExchange.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol"; import "@0x/contracts-libs/contracts/libs/LibOrder.sol"; -import "../../tokens/ERC20Token/IERC20Token.sol"; +import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol"; import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol"; import "@0x/contracts-utils/contracts/utils/SafeMath/SafeMath.sol"; diff --git a/contracts/core/contracts/extensions/Forwarder/Forwarder.sol b/contracts/extensions/contracts/Forwarder/Forwarder.sol index 94dec40ed..94dec40ed 100644 --- a/contracts/core/contracts/extensions/Forwarder/Forwarder.sol +++ b/contracts/extensions/contracts/Forwarder/Forwarder.sol diff --git a/contracts/core/contracts/extensions/Forwarder/MixinAssets.sol b/contracts/extensions/contracts/Forwarder/MixinAssets.sol index 5f5f3456d..3ebf75161 100644 --- a/contracts/core/contracts/extensions/Forwarder/MixinAssets.sol +++ b/contracts/extensions/contracts/Forwarder/MixinAssets.sol @@ -20,8 +20,8 @@ pragma solidity 0.4.24; import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol"; import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol"; -import "../../tokens/ERC20Token/IERC20Token.sol"; -import "../../tokens/ERC721Token/IERC721Token.sol"; +import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol"; +import "@0x/contracts-tokens/contracts/tokens/ERC721Token/IERC721Token.sol"; import "./libs/LibConstants.sol"; import "./mixins/MAssets.sol"; diff --git a/contracts/core/contracts/extensions/Forwarder/MixinExchangeWrapper.sol b/contracts/extensions/contracts/Forwarder/MixinExchangeWrapper.sol index 210eb14c2..210eb14c2 100644 --- a/contracts/core/contracts/extensions/Forwarder/MixinExchangeWrapper.sol +++ b/contracts/extensions/contracts/Forwarder/MixinExchangeWrapper.sol diff --git a/contracts/core/contracts/extensions/Forwarder/MixinForwarderCore.sol b/contracts/extensions/contracts/Forwarder/MixinForwarderCore.sol index bab78d79b..bab78d79b 100644 --- a/contracts/core/contracts/extensions/Forwarder/MixinForwarderCore.sol +++ b/contracts/extensions/contracts/Forwarder/MixinForwarderCore.sol diff --git a/contracts/core/contracts/extensions/Forwarder/MixinWeth.sol b/contracts/extensions/contracts/Forwarder/MixinWeth.sol index 2a281f3ae..2a281f3ae 100644 --- a/contracts/core/contracts/extensions/Forwarder/MixinWeth.sol +++ b/contracts/extensions/contracts/Forwarder/MixinWeth.sol diff --git a/contracts/core/contracts/extensions/Forwarder/interfaces/IAssets.sol b/contracts/extensions/contracts/Forwarder/interfaces/IAssets.sol index 1e034c003..1e034c003 100644 --- a/contracts/core/contracts/extensions/Forwarder/interfaces/IAssets.sol +++ b/contracts/extensions/contracts/Forwarder/interfaces/IAssets.sol diff --git a/contracts/core/contracts/extensions/Forwarder/interfaces/IForwarder.sol b/contracts/extensions/contracts/Forwarder/interfaces/IForwarder.sol index f5a26e2ba..f5a26e2ba 100644 --- a/contracts/core/contracts/extensions/Forwarder/interfaces/IForwarder.sol +++ b/contracts/extensions/contracts/Forwarder/interfaces/IForwarder.sol diff --git a/contracts/core/contracts/extensions/Forwarder/interfaces/IForwarderCore.sol b/contracts/extensions/contracts/Forwarder/interfaces/IForwarderCore.sol index eede20bb8..eede20bb8 100644 --- a/contracts/core/contracts/extensions/Forwarder/interfaces/IForwarderCore.sol +++ b/contracts/extensions/contracts/Forwarder/interfaces/IForwarderCore.sol diff --git a/contracts/core/contracts/extensions/Forwarder/libs/LibConstants.sol b/contracts/extensions/contracts/Forwarder/libs/LibConstants.sol index 0f98ae595..4a81abf76 100644 --- a/contracts/core/contracts/extensions/Forwarder/libs/LibConstants.sol +++ b/contracts/extensions/contracts/Forwarder/libs/LibConstants.sol @@ -19,9 +19,9 @@ pragma solidity 0.4.24; import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol"; -import "../../../protocol/Exchange/interfaces/IExchange.sol"; -import "../../../tokens/EtherToken/IEtherToken.sol"; -import "../../../tokens/ERC20Token/IERC20Token.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol"; +import "@0x/contracts-tokens/contracts/tokens/EtherToken/IEtherToken.sol"; +import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol"; contract LibConstants { diff --git a/contracts/core/contracts/extensions/Forwarder/libs/LibForwarderErrors.sol b/contracts/extensions/contracts/Forwarder/libs/LibForwarderErrors.sol index fb3ade1db..fb3ade1db 100644 --- a/contracts/core/contracts/extensions/Forwarder/libs/LibForwarderErrors.sol +++ b/contracts/extensions/contracts/Forwarder/libs/LibForwarderErrors.sol diff --git a/contracts/core/contracts/extensions/Forwarder/mixins/MAssets.sol b/contracts/extensions/contracts/Forwarder/mixins/MAssets.sol index 9e7f80d97..9e7f80d97 100644 --- a/contracts/core/contracts/extensions/Forwarder/mixins/MAssets.sol +++ b/contracts/extensions/contracts/Forwarder/mixins/MAssets.sol diff --git a/contracts/core/contracts/extensions/Forwarder/mixins/MExchangeWrapper.sol b/contracts/extensions/contracts/Forwarder/mixins/MExchangeWrapper.sol index d9e71786a..d9e71786a 100644 --- a/contracts/core/contracts/extensions/Forwarder/mixins/MExchangeWrapper.sol +++ b/contracts/extensions/contracts/Forwarder/mixins/MExchangeWrapper.sol diff --git a/contracts/core/contracts/extensions/Forwarder/mixins/MWeth.sol b/contracts/extensions/contracts/Forwarder/mixins/MWeth.sol index 88e77be4e..88e77be4e 100644 --- a/contracts/core/contracts/extensions/Forwarder/mixins/MWeth.sol +++ b/contracts/extensions/contracts/Forwarder/mixins/MWeth.sol diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json new file mode 100644 index 000000000..938e1138c --- /dev/null +++ b/contracts/extensions/package.json @@ -0,0 +1,93 @@ +{ + "name": "@0x/contracts-extensions", + "version": "1.0.2", + "engines": { + "node": ">=6.12" + }, + "description": "Smart contract extensions of 0x protocol", + "main": "lib/src/index.js", + "directories": { + "test": "test" + }, + "scripts": { + "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", + "pre_build": "run-s compile generate_contract_wrappers", + "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", + "test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html", + "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 --contracts-dir contracts", + "clean": "shx rm -rf lib generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "coverage:report:text": "istanbul report text", + "coverage:report:html": "istanbul report html && open coverage/index.html", + "profiler:report:html": "istanbul report html && open coverage/index.html", + "coverage:report:lcov": "istanbul report lcov", + "test:circleci": "yarn test", + "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" + }, + "config": { + "abis": "generated-artifacts/@(DutchAuction|Forwarder).json" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md", + "devDependencies": { + "@0x/abi-gen": "^1.0.19", + "@0x/contracts-test-utils": "^1.0.2", + "@0x/dev-utils": "^1.0.21", + "@0x/sol-compiler": "^1.1.16", + "@0x/sol-cov": "^2.1.16", + "@0x/subproviders": "^2.1.8", + "@0x/tslint-config": "^2.0.0", + "@types/bn.js": "^4.11.0", + "@types/lodash": "4.14.104", + "@types/node": "*", + "@types/yargs": "^10.0.0", + "chai": "^4.0.1", + "chai-as-promised": "^7.1.0", + "chai-bignumber": "^2.0.1", + "dirty-chai": "^2.0.1", + "ethereumjs-abi": "0.6.5", + "make-promises-safe": "^1.1.0", + "mocha": "^4.1.0", + "npm-run-all": "^4.1.2", + "shx": "^0.2.2", + "solc": "^0.4.24", + "solhint": "^1.4.1", + "tslint": "5.11.0", + "typescript": "3.0.1", + "yargs": "^10.0.3" + }, + "dependencies": { + "@0x/base-contract": "^3.0.10", + "@0x/contracts-interfaces": "^1.0.2", + "@0x/contracts-libs": "^1.0.2", + "@0x/contracts-protocol": "^2.1.59", + "@0x/contracts-tokens": "^1.0.2", + "@0x/contracts-utils": "^1.0.2", + "@0x/order-utils": "^3.0.7", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", + "@types/js-combinatorics": "^0.5.29", + "bn.js": "^4.11.8", + "ethereum-types": "^1.1.4", + "ethereumjs-util": "^5.1.1", + "lodash": "^4.17.5" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/contracts/extensions/src/artifacts/index.ts b/contracts/extensions/src/artifacts/index.ts new file mode 100644 index 000000000..7588178f0 --- /dev/null +++ b/contracts/extensions/src/artifacts/index.ts @@ -0,0 +1,9 @@ +import { ContractArtifact } from 'ethereum-types'; + +import * as DutchAuction from '../../generated-artifacts/DutchAuction.json'; +import * as Forwarder from '../../generated-artifacts/Forwarder.json'; + +export const artifacts = { + DutchAuction: DutchAuction as ContractArtifact, + Forwarder: Forwarder as ContractArtifact, +}; diff --git a/contracts/extensions/src/index.ts b/contracts/extensions/src/index.ts new file mode 100644 index 000000000..d55f08ea2 --- /dev/null +++ b/contracts/extensions/src/index.ts @@ -0,0 +1,2 @@ +export * from './artifacts'; +export * from './wrappers'; diff --git a/contracts/extensions/src/wrappers/index.ts b/contracts/extensions/src/wrappers/index.ts new file mode 100644 index 000000000..90880e37f --- /dev/null +++ b/contracts/extensions/src/wrappers/index.ts @@ -0,0 +1,2 @@ +export * from '../../generated-wrappers/dutch_auction'; +export * from '../../generated-wrappers/forwarder'; diff --git a/contracts/core/test/extensions/dutch_auction.ts b/contracts/extensions/test/extensions/dutch_auction.ts index 54e6092d7..6c3b2f0f3 100644 --- a/contracts/core/test/extensions/dutch_auction.ts +++ b/contracts/extensions/test/extensions/dutch_auction.ts @@ -1,4 +1,11 @@ import { + artifacts as protocolArtifacts, + ERC20Wrapper, + ERC721Wrapper, + ExchangeContract, + ExchangeWrapper, +} from '@0x/contracts-protocol'; +import { chaiSetup, constants, ContractName, @@ -10,6 +17,12 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { + artifacts as tokensArtifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + WETH9Contract, +} from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils'; import { RevertReason, SignedOrder } from '@0x/types'; @@ -20,15 +33,8 @@ import ethAbi = require('ethereumjs-abi'); import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; -import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token'; import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction'; -import { ExchangeContract } from '../../generated-wrappers/exchange'; -import { WETH9Contract } from '../../generated-wrappers/weth9'; import { artifacts } from '../../src/artifacts'; -import { ERC20Wrapper } from '../utils/erc20_wrapper'; -import { ERC721Wrapper } from '../utils/erc721_wrapper'; -import { ExchangeWrapper } from '../utils/exchange_wrapper'; chaiSetup.configure(); const expect = chai.expect; @@ -98,12 +104,12 @@ describe(ContractName.DutchAuction, () => { const erc721Balances = await erc721Wrapper.getBalancesAsync(); erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address]; - wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults); + wethContract = await WETH9Contract.deployFrom0xArtifactAsync(tokensArtifacts.WETH9, provider, txDefaults); erc20Wrapper.addDummyTokenContract(wethContract as any); const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( - artifacts.Exchange, + protocolArtifacts.Exchange, provider, txDefaults, zrxAssetData, diff --git a/contracts/core/test/extensions/forwarder.ts b/contracts/extensions/test/extensions/forwarder.ts index 44ad4d6ff..4027f493d 100644 --- a/contracts/core/test/extensions/forwarder.ts +++ b/contracts/extensions/test/extensions/forwarder.ts @@ -1,4 +1,11 @@ import { + artifacts as protocolArtifacts, + ERC20Wrapper, + ERC721Wrapper, + ExchangeContract, + ExchangeWrapper, +} from '@0x/contracts-protocol'; +import { chaiSetup, constants, ContractName, @@ -11,6 +18,12 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { + artifacts as tokenArtifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + WETH9Contract, +} from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils } from '@0x/order-utils'; import { RevertReason, SignedOrder } from '@0x/types'; @@ -19,15 +32,9 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; -import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token'; -import { ExchangeContract } from '../../generated-wrappers/exchange'; import { ForwarderContract } from '../../generated-wrappers/forwarder'; -import { WETH9Contract } from '../../generated-wrappers/weth9'; import { artifacts } from '../../src/artifacts'; -import { ERC20Wrapper } from '../utils/erc20_wrapper'; -import { ERC721Wrapper } from '../utils/erc721_wrapper'; -import { ExchangeWrapper } from '../utils/exchange_wrapper'; + import { ForwarderWrapper } from '../utils/forwarder_wrapper'; chaiSetup.configure(); @@ -94,14 +101,14 @@ describe(ContractName.Forwarder, () => { const erc721Balances = await erc721Wrapper.getBalancesAsync(); erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address]; - wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults); + wethContract = await WETH9Contract.deployFrom0xArtifactAsync(tokenArtifacts.WETH9, provider, txDefaults); weth = new DummyERC20TokenContract(wethContract.abi, wethContract.address, provider); erc20Wrapper.addDummyTokenContract(weth); wethAssetData = assetDataUtils.encodeERC20AssetData(wethContract.address); zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( - artifacts.Exchange, + protocolArtifacts.Exchange, provider, txDefaults, zrxAssetData, @@ -172,7 +179,7 @@ describe(ContractName.Forwarder, () => { describe('constructor', () => { it('should revert if assetProxy is unregistered', async () => { const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( - artifacts.Exchange, + protocolArtifacts.Exchange, provider, txDefaults, zrxAssetData, diff --git a/contracts/core/test/global_hooks.ts b/contracts/extensions/test/global_hooks.ts index f8ace376a..f8ace376a 100644 --- a/contracts/core/test/global_hooks.ts +++ b/contracts/extensions/test/global_hooks.ts diff --git a/contracts/core/test/utils/forwarder_wrapper.ts b/contracts/extensions/test/utils/forwarder_wrapper.ts index 9c5560381..9e44ff6b9 100644 --- a/contracts/core/test/utils/forwarder_wrapper.ts +++ b/contracts/extensions/test/utils/forwarder_wrapper.ts @@ -1,4 +1,6 @@ +import { artifacts as protocolArtifacts } from '@0x/contracts-protocol'; import { constants, formatters, LogDecoder, MarketSellOrders } from '@0x/contracts-test-utils'; +import { artifacts as tokensArtifacts } from '@0x/contracts-tokens'; import { SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; @@ -58,7 +60,11 @@ export class ForwarderWrapper { constructor(contractInstance: ForwarderContract, provider: Provider) { this._forwarderContract = contractInstance; this._web3Wrapper = new Web3Wrapper(provider); - this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts); + this._logDecoder = new LogDecoder(this._web3Wrapper, { + ...artifacts, + ...tokensArtifacts, + ...protocolArtifacts, + }); } public async marketSellOrdersWithEthAsync( orders: SignedOrder[], diff --git a/contracts/extensions/tsconfig.json b/contracts/extensions/tsconfig.json new file mode 100644 index 000000000..a4ce1e002 --- /dev/null +++ b/contracts/extensions/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": ".", + "resolveJsonModule": true + }, + "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], + "files": ["./generated-artifacts/DutchAuction.json", "./generated-artifacts/Forwarder.json"], + "exclude": ["./deploy/solc/solc_bin"] +} diff --git a/contracts/extensions/tslint.json b/contracts/extensions/tslint.json new file mode 100644 index 000000000..1bb3ac2a2 --- /dev/null +++ b/contracts/extensions/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": ["@0x/tslint-config"], + "rules": { + "custom-no-magic-numbers": false + } +} diff --git a/contracts/interfaces/CHANGELOG.json b/contracts/interfaces/CHANGELOG.json new file mode 100644 index 000000000..19ac770af --- /dev/null +++ b/contracts/interfaces/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "timestamp": 1544741676, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + } +] diff --git a/contracts/interfaces/CHANGELOG.md b/contracts/interfaces/CHANGELOG.md new file mode 100644 index 000000000..716353d05 --- /dev/null +++ b/contracts/interfaces/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _December 13, 2018_ + + * Dependencies updated diff --git a/contracts/interfaces/README.md b/contracts/interfaces/README.md new file mode 100644 index 000000000..b7d519abb --- /dev/null +++ b/contracts/interfaces/README.md @@ -0,0 +1,72 @@ +## Contract interfaces + +Smart contract interfaces of the 0x protocol. + +## Usage + +Contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories: + +* [protocol](./contracts/protocol) + * This directory contains the contract interfaces that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). + +## Bug bounty + +A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0xproject.com/wiki#Bug-Bounty). + +## Contributing + +We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. + +For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install Dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/contracts-interfaces yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0x/contracts-interfaces yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` + +#### Testing options + +Contracts testing options like coverage, profiling, revert traces or backing node choosing - are described [here](../TESTING.md). diff --git a/contracts/interfaces/compiler.json b/contracts/interfaces/compiler.json new file mode 100644 index 000000000..38a232541 --- /dev/null +++ b/contracts/interfaces/compiler.json @@ -0,0 +1,35 @@ +{ + "artifactsDir": "./generated-artifacts", + "contractsDir": "./contracts", + "compilerSettings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode.object", + "evm.bytecode.sourceMap", + "evm.deployedBytecode.object", + "evm.deployedBytecode.sourceMap" + ] + } + } + }, + "contracts": [ + "IAssetData", + "IAssetProxy", + "IAuthorizable", + "IAssetProxyDispatcher", + "IExchange", + "IExchangeCore", + "IMatchOrders", + "ISignatureValidator", + "ITransactions", + "IValidator", + "IWallet", + "IWrapperFunctions" + ] +} diff --git a/contracts/core/contracts/protocol/AssetProxy/interfaces/IAssetData.sol b/contracts/interfaces/contracts/protocol/AssetProxy/IAssetData.sol index e2da68919..e2da68919 100644 --- a/contracts/core/contracts/protocol/AssetProxy/interfaces/IAssetData.sol +++ b/contracts/interfaces/contracts/protocol/AssetProxy/IAssetData.sol diff --git a/contracts/core/contracts/protocol/AssetProxy/interfaces/IAssetProxy.sol b/contracts/interfaces/contracts/protocol/AssetProxy/IAssetProxy.sol index b25d2d75a..b25d2d75a 100644 --- a/contracts/core/contracts/protocol/AssetProxy/interfaces/IAssetProxy.sol +++ b/contracts/interfaces/contracts/protocol/AssetProxy/IAssetProxy.sol diff --git a/contracts/core/contracts/protocol/AssetProxy/interfaces/IAuthorizable.sol b/contracts/interfaces/contracts/protocol/AssetProxy/IAuthorizable.sol index 96ee05dee..96ee05dee 100644 --- a/contracts/core/contracts/protocol/AssetProxy/interfaces/IAuthorizable.sol +++ b/contracts/interfaces/contracts/protocol/AssetProxy/IAuthorizable.sol diff --git a/contracts/core/contracts/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol b/contracts/interfaces/contracts/protocol/Exchange/IAssetProxyDispatcher.sol index 8db8d6f6c..8db8d6f6c 100644 --- a/contracts/core/contracts/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol +++ b/contracts/interfaces/contracts/protocol/Exchange/IAssetProxyDispatcher.sol diff --git a/contracts/core/contracts/protocol/Exchange/interfaces/IExchange.sol b/contracts/interfaces/contracts/protocol/Exchange/IExchange.sol index b92abba04..b92abba04 100644 --- a/contracts/core/contracts/protocol/Exchange/interfaces/IExchange.sol +++ b/contracts/interfaces/contracts/protocol/Exchange/IExchange.sol diff --git a/contracts/core/contracts/protocol/Exchange/interfaces/IExchangeCore.sol b/contracts/interfaces/contracts/protocol/Exchange/IExchangeCore.sol index 0da73529c..0da73529c 100644 --- a/contracts/core/contracts/protocol/Exchange/interfaces/IExchangeCore.sol +++ b/contracts/interfaces/contracts/protocol/Exchange/IExchangeCore.sol diff --git a/contracts/core/contracts/protocol/Exchange/interfaces/IMatchOrders.sol b/contracts/interfaces/contracts/protocol/Exchange/IMatchOrders.sol index b88e158c3..b88e158c3 100644 --- a/contracts/core/contracts/protocol/Exchange/interfaces/IMatchOrders.sol +++ b/contracts/interfaces/contracts/protocol/Exchange/IMatchOrders.sol diff --git a/contracts/core/contracts/protocol/Exchange/interfaces/ISignatureValidator.sol b/contracts/interfaces/contracts/protocol/Exchange/ISignatureValidator.sol index 1fd0eccf0..1fd0eccf0 100644 --- a/contracts/core/contracts/protocol/Exchange/interfaces/ISignatureValidator.sol +++ b/contracts/interfaces/contracts/protocol/Exchange/ISignatureValidator.sol diff --git a/contracts/core/contracts/protocol/Exchange/interfaces/ITransactions.sol b/contracts/interfaces/contracts/protocol/Exchange/ITransactions.sol index 4446c55ce..4446c55ce 100644 --- a/contracts/core/contracts/protocol/Exchange/interfaces/ITransactions.sol +++ b/contracts/interfaces/contracts/protocol/Exchange/ITransactions.sol diff --git a/contracts/core/contracts/protocol/Exchange/interfaces/IValidator.sol b/contracts/interfaces/contracts/protocol/Exchange/IValidator.sol index 2dd69100c..2dd69100c 100644 --- a/contracts/core/contracts/protocol/Exchange/interfaces/IValidator.sol +++ b/contracts/interfaces/contracts/protocol/Exchange/IValidator.sol diff --git a/contracts/core/contracts/protocol/Exchange/interfaces/IWallet.sol b/contracts/interfaces/contracts/protocol/Exchange/IWallet.sol index c97161ca6..c97161ca6 100644 --- a/contracts/core/contracts/protocol/Exchange/interfaces/IWallet.sol +++ b/contracts/interfaces/contracts/protocol/Exchange/IWallet.sol diff --git a/contracts/core/contracts/protocol/Exchange/interfaces/IWrapperFunctions.sol b/contracts/interfaces/contracts/protocol/Exchange/IWrapperFunctions.sol index 833bb7e88..833bb7e88 100644 --- a/contracts/core/contracts/protocol/Exchange/interfaces/IWrapperFunctions.sol +++ b/contracts/interfaces/contracts/protocol/Exchange/IWrapperFunctions.sol diff --git a/contracts/interfaces/package.json b/contracts/interfaces/package.json new file mode 100644 index 000000000..4d3e4b7f9 --- /dev/null +++ b/contracts/interfaces/package.json @@ -0,0 +1,56 @@ +{ + "name": "@0x/contracts-interfaces", + "version": "1.0.2", + "engines": { + "node": ">=6.12" + }, + "description": "Smart contract interfaces of 0x protocol", + "main": "lib/src/index.js", + "scripts": { + "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", + "pre_build": "run-s compile generate_contract_wrappers", + "compile": "sol-compiler --contracts-dir contracts", + "clean": "shx rm -rf lib generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" + }, + "config": { + "abis": "generated-artifacts/@(IAssetData|IAssetProxy|IAuthorizable|IAssetProxyDispatcher|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|ITransactions|IValidator|IWallet|IWrapperFunctions).json" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/contracts/interfaces/README.md", + "devDependencies": { + "@0x/abi-gen": "^1.0.19", + "@0x/sol-compiler": "^1.1.16", + "@0x/tslint-config": "^2.0.0", + "npm-run-all": "^4.1.2", + "shx": "^0.2.2", + "solhint": "^1.4.1", + "tslint": "5.11.0", + "typescript": "3.0.1", + "yargs": "^10.0.3" + }, + "dependencies": { + "@0x/base-contract": "^3.0.10", + "@0x/contracts-libs": "^1.0.2", + "@0x/contracts-utils": "^1.0.2", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", + "ethereum-types": "^1.1.4", + "lodash": "^4.17.5" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/contracts/interfaces/src/artifacts/index.ts b/contracts/interfaces/src/artifacts/index.ts new file mode 100644 index 000000000..5a2a37d8a --- /dev/null +++ b/contracts/interfaces/src/artifacts/index.ts @@ -0,0 +1,29 @@ +import { ContractArtifact } from 'ethereum-types'; + +import * as IAssetData from '../../generated-artifacts/IAssetData.json'; +import * as IAssetProxy from '../../generated-artifacts/IAssetProxy.json'; +import * as IAssetProxyDispatcher from '../../generated-artifacts/IAssetProxyDispatcher.json'; +import * as IAuthorizable from '../../generated-artifacts/IAuthorizable.json'; +import * as IExchange from '../../generated-artifacts/IExchange.json'; +import * as IExchangeCore from '../../generated-artifacts/IExchangeCore.json'; +import * as IMatchOrders from '../../generated-artifacts/IMatchOrders.json'; +import * as ISignatureValidator from '../../generated-artifacts/ISignatureValidator.json'; +import * as ITransactions from '../../generated-artifacts/ITransactions.json'; +import * as IValidator from '../../generated-artifacts/IValidator.json'; +import * as IWallet from '../../generated-artifacts/IWallet.json'; +import * as IWrapperFunctions from '../../generated-artifacts/IWrapperFunctions.json'; + +export const artifacts = { + IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact, + IAuthorizable: IAuthorizable as ContractArtifact, + IExchange: IExchange as ContractArtifact, + IExchangeCore: IExchangeCore as ContractArtifact, + IMatchOrders: IMatchOrders as ContractArtifact, + ISignatureValidator: ISignatureValidator as ContractArtifact, + ITransactions: ITransactions as ContractArtifact, + IWrapperFunctions: IWrapperFunctions as ContractArtifact, + IAssetData: IAssetData as ContractArtifact, + IAssetProxy: IAssetProxy as ContractArtifact, + IValidator: IValidator as ContractArtifact, + IWallet: IWallet as ContractArtifact, +}; diff --git a/contracts/interfaces/src/index.ts b/contracts/interfaces/src/index.ts new file mode 100644 index 000000000..d55f08ea2 --- /dev/null +++ b/contracts/interfaces/src/index.ts @@ -0,0 +1,2 @@ +export * from './artifacts'; +export * from './wrappers'; diff --git a/contracts/interfaces/src/wrappers/index.ts b/contracts/interfaces/src/wrappers/index.ts new file mode 100644 index 000000000..f7f72fada --- /dev/null +++ b/contracts/interfaces/src/wrappers/index.ts @@ -0,0 +1,12 @@ +export * from '../../generated-wrappers/i_asset_data'; +export * from '../../generated-wrappers/i_asset_proxy'; +export * from '../../generated-wrappers/i_asset_proxy_dispatcher'; +export * from '../../generated-wrappers/i_exchange'; +export * from '../../generated-wrappers/i_exchange_core'; +export * from '../../generated-wrappers/i_match_orders'; +export * from '../../generated-wrappers/i_signature_validator'; +export * from '../../generated-wrappers/i_transactions'; +export * from '../../generated-wrappers/i_authorizable'; +export * from '../../generated-wrappers/i_wrapper_functions'; +export * from '../../generated-wrappers/i_validator'; +export * from '../../generated-wrappers/i_wallet'; diff --git a/contracts/interfaces/tsconfig.json b/contracts/interfaces/tsconfig.json new file mode 100644 index 000000000..90b7d41bb --- /dev/null +++ b/contracts/interfaces/tsconfig.json @@ -0,0 +1,24 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": ".", + "resolveJsonModule": true + }, + "include": ["./src/**/*", "./generated-wrappers/**/*"], + "files": [ + "./generated-artifacts/IAssetData.json", + "./generated-artifacts/IAssetProxy.json", + "./generated-artifacts/IAuthorizable.json", + "./generated-artifacts/IAssetProxyDispatcher.json", + "./generated-artifacts/IExchange.json", + "./generated-artifacts/IExchangeCore.json", + "./generated-artifacts/IMatchOrders.json", + "./generated-artifacts/ISignatureValidator.json", + "./generated-artifacts/ITransactions.json", + "./generated-artifacts/IValidator.json", + "./generated-artifacts/IWallet.json", + "./generated-artifacts/IWrapperFunctions.json" + ], + "exclude": ["./deploy/solc/solc_bin"] +} diff --git a/contracts/interfaces/tslint.json b/contracts/interfaces/tslint.json new file mode 100644 index 000000000..1bb3ac2a2 --- /dev/null +++ b/contracts/interfaces/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": ["@0x/tslint-config"], + "rules": { + "custom-no-magic-numbers": false + } +} diff --git a/contracts/libs/.solhint.json b/contracts/libs/.solhint.json deleted file mode 100644 index 076afe9f3..000000000 --- a/contracts/libs/.solhint.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "default", - "rules": { - "avoid-low-level-calls": false, - "avoid-tx-origin": "warn", - "bracket-align": false, - "code-complexity": false, - "const-name-snakecase": "error", - "expression-indent": "error", - "function-max-lines": false, - "func-order": "error", - "indent": ["error", 4], - "max-line-length": ["warn", 160], - "no-inline-assembly": false, - "quotes": ["error", "double"], - "separate-by-one-line-in-contract": "error", - "space-after-comma": "error", - "statement-indent": "error" - } -} diff --git a/contracts/libs/CHANGELOG.json b/contracts/libs/CHANGELOG.json new file mode 100644 index 000000000..19ac770af --- /dev/null +++ b/contracts/libs/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "timestamp": 1544741676, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + } +] diff --git a/contracts/libs/CHANGELOG.md b/contracts/libs/CHANGELOG.md new file mode 100644 index 000000000..716353d05 --- /dev/null +++ b/contracts/libs/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _December 13, 2018_ + + * Dependencies updated diff --git a/contracts/libs/package.json b/contracts/libs/package.json index 74288be76..fa4b6e523 100644 --- a/contracts/libs/package.json +++ b/contracts/libs/package.json @@ -1,7 +1,6 @@ { - "private": true, "name": "@0x/contracts-libs", - "version": "1.0.0", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -19,8 +18,7 @@ "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", "test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html", "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", + "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler --contracts-dir contracts", "clean": "shx rm -rf lib generated-artifacts generated-wrappers", "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers", @@ -30,7 +28,7 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "lint-contracts": "solhint contracts/**/**/**/**/*.sol" + "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { "abis": "generated-artifacts/@(LibMath|LibOrder|LibFillResults|LibAbiEncoder|TestLibs|LibEIP712).json" @@ -45,13 +43,13 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/libs/README.md", "devDependencies": { - "@0x/contracts-test-utils": "^1.0.0", - "@0x/abi-gen": "^1.0.17", - "@0x/dev-utils": "^1.0.19", - "@0x/sol-compiler": "^1.1.14", - "@0x/sol-cov": "^2.1.14", - "@0x/subproviders": "^2.1.6", - "@0x/tslint-config": "^1.0.10", + "@0x/abi-gen": "^1.0.19", + "@0x/contracts-test-utils": "^1.0.2", + "@0x/dev-utils": "^1.0.21", + "@0x/sol-compiler": "^1.1.16", + "@0x/sol-cov": "^2.1.16", + "@0x/subproviders": "^2.1.8", + "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", "@types/node": "*", @@ -60,29 +58,29 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", "dirty-chai": "^2.0.1", - "make-promises-safe": "^1.1.0", "ethereumjs-abi": "0.6.5", + "make-promises-safe": "^1.1.0", "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", "solc": "^0.4.24", - "solhint": "^1.2.1", + "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.8", - "@0x/order-utils": "^3.0.4", - "@0x/contracts-multisig": "^1.0.0", - "@0x/contracts-utils": "^1.0.0", - "@0x/types": "^1.3.0", - "@0x/typescript-typings": "^3.0.4", - "@0x/utils": "^2.0.6", - "@0x/web3-wrapper": "^3.1.6", + "@0x/base-contract": "^3.0.10", + "@0x/contracts-multisig": "^1.0.2", + "@0x/contracts-utils": "^1.0.2", + "@0x/order-utils": "^3.0.7", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", - "ethereum-types": "^1.1.2", + "ethereum-types": "^1.1.4", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5" }, diff --git a/contracts/multisig/.solhint.json b/contracts/multisig/.solhint.json deleted file mode 100644 index 076afe9f3..000000000 --- a/contracts/multisig/.solhint.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "default", - "rules": { - "avoid-low-level-calls": false, - "avoid-tx-origin": "warn", - "bracket-align": false, - "code-complexity": false, - "const-name-snakecase": "error", - "expression-indent": "error", - "function-max-lines": false, - "func-order": "error", - "indent": ["error", 4], - "max-line-length": ["warn", 160], - "no-inline-assembly": false, - "quotes": ["error", "double"], - "separate-by-one-line-in-contract": "error", - "space-after-comma": "error", - "statement-indent": "error" - } -} diff --git a/contracts/multisig/CHANGELOG.json b/contracts/multisig/CHANGELOG.json index fe51488c7..19ac770af 100644 --- a/contracts/multisig/CHANGELOG.json +++ b/contracts/multisig/CHANGELOG.json @@ -1 +1,11 @@ -[] +[ + { + "timestamp": 1544741676, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + } +] diff --git a/contracts/multisig/CHANGELOG.md b/contracts/multisig/CHANGELOG.md new file mode 100644 index 000000000..716353d05 --- /dev/null +++ b/contracts/multisig/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _December 13, 2018_ + + * Dependencies updated diff --git a/contracts/multisig/package.json b/contracts/multisig/package.json index 37d064fef..b338f67f7 100644 --- a/contracts/multisig/package.json +++ b/contracts/multisig/package.json @@ -1,7 +1,6 @@ { - "private": true, "name": "@0x/contracts-multisig", - "version": "1.0.0", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -29,7 +28,7 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "lint-contracts": "solhint contracts/**/**/**/**/*.sol" + "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { "abis": "generated-artifacts/@(MultiSigWallet|MultiSigWalletWithTimeLock|TestRejectEther).json" @@ -42,15 +41,15 @@ "bugs": { "url": "https://github.com/0xProject/0x-monorepo/issues" }, - "homepage": "https://github.com/0xProject/0x-monorepo/contracts/core/README.md", + "homepage": "https://github.com/0xProject/0x-monorepo/contracts/multisig/README.md", "devDependencies": { - "@0x/contracts-test-utils": "^1.0.0", - "@0x/abi-gen": "^1.0.17", - "@0x/dev-utils": "^1.0.18", - "@0x/sol-compiler": "^1.1.13", - "@0x/sol-cov": "^2.1.13", - "@0x/subproviders": "^2.1.5", - "@0x/tslint-config": "^1.0.10", + "@0x/abi-gen": "^1.0.19", + "@0x/contracts-test-utils": "^1.0.2", + "@0x/dev-utils": "^1.0.21", + "@0x/sol-compiler": "^1.1.16", + "@0x/sol-cov": "^2.1.16", + "@0x/subproviders": "^2.1.8", + "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/ethereumjs-abi": "^0.6.0", "@types/lodash": "4.14.104", @@ -65,19 +64,19 @@ "npm-run-all": "^4.1.2", "shx": "^0.2.2", "solc": "^0.4.24", - "solhint": "^1.2.1", + "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.7", - "@0x/order-utils": "^3.0.3", - "@0x/types": "^1.3.0", - "@0x/typescript-typings": "^3.0.4", - "@0x/utils": "^2.0.6", - "@0x/web3-wrapper": "^3.1.5", - "ethereum-types": "^1.1.2", + "@0x/base-contract": "^3.0.10", + "@0x/order-utils": "^3.0.7", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", + "ethereum-types": "^1.1.4", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/contracts/protocol/CHANGELOG.json b/contracts/protocol/CHANGELOG.json new file mode 100644 index 000000000..5c3798a69 --- /dev/null +++ b/contracts/protocol/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "timestamp": 1544741676, + "version": "2.1.59", + "changes": [ + { + "note": "Dependencies updated" + } + ] + } +] diff --git a/contracts/protocol/CHANGELOG.md b/contracts/protocol/CHANGELOG.md new file mode 100644 index 000000000..d90b1b2cc --- /dev/null +++ b/contracts/protocol/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v2.1.59 - _December 13, 2018_ + + * Dependencies updated diff --git a/contracts/core/CHANGELOG.json b/contracts/protocol/DEPLOYS.json index 7dfa06990..5c24ae59c 100644 --- a/contracts/core/CHANGELOG.json +++ b/contracts/protocol/DEPLOYS.json @@ -11,7 +11,7 @@ }, { "name": "OrderValidator", - "version": "1.0.1", + "version": "1.0.0", "changes": [ { "note": "remove `getApproved` check from ERC721 approval query", @@ -20,35 +20,6 @@ ] }, { - "name": "Forwarder", - "version": "1.1.0", - "changes": [ - { - "note": "Round up when calculating remaining amounts in marketBuy functions", - "pr": 1162, - "networks": { - "1": "0x5468a1dc173652ee28d249c271fa9933144746b1", - "3": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e", - "42": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6" - } - } - ] - }, - { - "name": "Forwarder", - "version": "1.0.0", - "changes": [ - { - "note": "protocol v2 deploy", - "networks": { - "1": "0x7afc2d5107af94c462a194d2c21b5bdd238709d6", - "3": "0x3983e204b12b3c02fb0638caf2cd406a62e0ead3", - "42": "0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8" - } - } - ] - }, - { "name": "OrderValidator", "version": "1.0.0", "changes": [ @@ -117,19 +88,5 @@ } } ] - }, - { - "name": "ZRXToken", - "version": "1.0.0", - "changes": [ - { - "note": "protocol v1 deploy", - "networks": { - "1": "0xe41d2489571d322189246dafa5ebde1f4699f498", - "3": "0xff67881f8d12f372d91baae9752eb3631ff0ed00", - "42": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa" - } - } - ] } ] diff --git a/contracts/core/README.md b/contracts/protocol/README.md index 0004925c1..5fc9c0a89 100644 --- a/contracts/core/README.md +++ b/contracts/protocol/README.md @@ -8,14 +8,6 @@ Contracts that make up and interact with version 2.0.0 of the protocol can be fo * [protocol](./contracts/protocol) * This directory contains the contracts that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). -* [extensions](./contracts/extensions) - * This directory contains contracts that interact with the 2.0.0 contracts and will be used in production, such as the [Forwarder](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md) contract. -* [examples](./contracts/examples) - * This directory contains example implementations of contracts that interact with the protocol but are _not_ intended for use in production. Examples include [filter](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#filter-contracts) contracts, a [Wallet](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#wallet) contract, and a [Validator](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#validator) contract, among others. -* [tokens](./contracts/tokens) - * This directory contains implementations of different tokens and token standards, including [wETH](https://weth.io/), ZRX, [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md), and [ERC721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md). -* [utils](./contracts/utils) - * This directory contains libraries and utils that are shared across all of the other directories. * [test](./contracts/test) * This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. @@ -50,13 +42,13 @@ yarn install To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: ```bash -PKG=@0x/contracts-core yarn build +PKG=@0x/contracts-protocol yarn build ``` Or continuously rebuild on change: ```bash -PKG=@0x/contracts-core yarn watch +PKG=@0x/contracts-protocol yarn watch ``` ### Clean diff --git a/contracts/core/compiler.json b/contracts/protocol/compiler.json index 7e527130a..c05d62aba 100644 --- a/contracts/core/compiler.json +++ b/contracts/protocol/compiler.json @@ -20,37 +20,16 @@ }, "contracts": [ "AssetProxyOwner", - "DummyERC20Token", - "DummyERC721Receiver", - "DummyERC721Token", - "DummyMultipleReturnERC20Token", - "DummyNoReturnERC20Token", - "DutchAuction", "ERC20Proxy", - "ERC20Token", - "ERC721Token", "ERC721Proxy", "Exchange", - "ExchangeWrapper", - "Forwarder", - "IAssetData", - "IAssetProxy", - "InvalidERC721Receiver", - "IValidator", - "IWallet", "MixinAuthorizable", "MultiAssetProxy", "OrderValidator", - "ReentrantERC20Token", "TestAssetProxyOwner", "TestAssetProxyDispatcher", "TestExchangeInternals", "TestSignatureValidator", - "TestStaticCallReceiver", - "Validator", - "Wallet", - "WETH9", - "Whitelist", - "ZRXToken" + "TestStaticCallReceiver" ] } diff --git a/contracts/core/contracts/protocol/AssetProxy/ERC20Proxy.sol b/contracts/protocol/contracts/protocol/AssetProxy/ERC20Proxy.sol index 258443bca..258443bca 100644 --- a/contracts/core/contracts/protocol/AssetProxy/ERC20Proxy.sol +++ b/contracts/protocol/contracts/protocol/AssetProxy/ERC20Proxy.sol diff --git a/contracts/core/contracts/protocol/AssetProxy/ERC721Proxy.sol b/contracts/protocol/contracts/protocol/AssetProxy/ERC721Proxy.sol index 65b664b8b..65b664b8b 100644 --- a/contracts/core/contracts/protocol/AssetProxy/ERC721Proxy.sol +++ b/contracts/protocol/contracts/protocol/AssetProxy/ERC721Proxy.sol diff --git a/contracts/core/contracts/protocol/AssetProxy/MixinAuthorizable.sol b/contracts/protocol/contracts/protocol/AssetProxy/MixinAuthorizable.sol index 08f9b94dc..08f9b94dc 100644 --- a/contracts/core/contracts/protocol/AssetProxy/MixinAuthorizable.sol +++ b/contracts/protocol/contracts/protocol/AssetProxy/MixinAuthorizable.sol diff --git a/contracts/core/contracts/protocol/AssetProxy/MultiAssetProxy.sol b/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol index 42231e73b..42231e73b 100644 --- a/contracts/core/contracts/protocol/AssetProxy/MultiAssetProxy.sol +++ b/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol diff --git a/contracts/core/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol b/contracts/protocol/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol index d63fb7f6d..fe77048ce 100644 --- a/contracts/core/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol +++ b/contracts/protocol/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol @@ -18,7 +18,7 @@ pragma solidity 0.4.24; -import "../interfaces/IAuthorizable.sol"; +import "@0x/contracts-interfaces/contracts/protocol/AssetProxy/IAuthorizable.sol"; contract MAuthorizable is diff --git a/contracts/core/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol b/contracts/protocol/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol index bfc7b5a66..bfc7b5a66 100644 --- a/contracts/core/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol +++ b/contracts/protocol/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol diff --git a/contracts/core/contracts/protocol/Exchange/Exchange.sol b/contracts/protocol/contracts/protocol/Exchange/Exchange.sol index 65ca742ea..65ca742ea 100644 --- a/contracts/core/contracts/protocol/Exchange/Exchange.sol +++ b/contracts/protocol/contracts/protocol/Exchange/Exchange.sol diff --git a/contracts/core/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol b/contracts/protocol/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol index 02aeb4a13..36ab39b45 100644 --- a/contracts/core/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol +++ b/contracts/protocol/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol @@ -20,7 +20,7 @@ pragma solidity 0.4.24; import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol"; import "./mixins/MAssetProxyDispatcher.sol"; -import "../AssetProxy/interfaces/IAssetProxy.sol"; +import "@0x/contracts-interfaces/contracts/protocol/AssetProxy/IAssetProxy.sol"; contract MixinAssetProxyDispatcher is diff --git a/contracts/core/contracts/protocol/Exchange/MixinExchangeCore.sol b/contracts/protocol/contracts/protocol/Exchange/MixinExchangeCore.sol index 68d6a3897..68d6a3897 100644 --- a/contracts/core/contracts/protocol/Exchange/MixinExchangeCore.sol +++ b/contracts/protocol/contracts/protocol/Exchange/MixinExchangeCore.sol diff --git a/contracts/core/contracts/protocol/Exchange/MixinMatchOrders.sol b/contracts/protocol/contracts/protocol/Exchange/MixinMatchOrders.sol index fc6d73482..fc6d73482 100644 --- a/contracts/core/contracts/protocol/Exchange/MixinMatchOrders.sol +++ b/contracts/protocol/contracts/protocol/Exchange/MixinMatchOrders.sol diff --git a/contracts/core/contracts/protocol/Exchange/MixinSignatureValidator.sol b/contracts/protocol/contracts/protocol/Exchange/MixinSignatureValidator.sol index 711535aa8..80b4c0755 100644 --- a/contracts/core/contracts/protocol/Exchange/MixinSignatureValidator.sol +++ b/contracts/protocol/contracts/protocol/Exchange/MixinSignatureValidator.sol @@ -22,8 +22,8 @@ import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol"; import "@0x/contracts-utils/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol"; import "./mixins/MSignatureValidator.sol"; import "./mixins/MTransactions.sol"; -import "./interfaces/IWallet.sol"; -import "./interfaces/IValidator.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IWallet.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IValidator.sol"; contract MixinSignatureValidator is diff --git a/contracts/core/contracts/protocol/Exchange/MixinTransactions.sol b/contracts/protocol/contracts/protocol/Exchange/MixinTransactions.sol index 87c614382..87c614382 100644 --- a/contracts/core/contracts/protocol/Exchange/MixinTransactions.sol +++ b/contracts/protocol/contracts/protocol/Exchange/MixinTransactions.sol diff --git a/contracts/core/contracts/protocol/Exchange/MixinWrapperFunctions.sol b/contracts/protocol/contracts/protocol/Exchange/MixinWrapperFunctions.sol index 2d43432ff..2d43432ff 100644 --- a/contracts/core/contracts/protocol/Exchange/MixinWrapperFunctions.sol +++ b/contracts/protocol/contracts/protocol/Exchange/MixinWrapperFunctions.sol diff --git a/contracts/core/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol b/contracts/protocol/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol index 0ddfca270..fe3d03326 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol +++ b/contracts/protocol/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol @@ -18,7 +18,7 @@ pragma solidity 0.4.24; -import "../interfaces/IAssetProxyDispatcher.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IAssetProxyDispatcher.sol"; contract MAssetProxyDispatcher is diff --git a/contracts/core/contracts/protocol/Exchange/mixins/MExchangeCore.sol b/contracts/protocol/contracts/protocol/Exchange/mixins/MExchangeCore.sol index 099bdcc33..215284900 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MExchangeCore.sol +++ b/contracts/protocol/contracts/protocol/Exchange/mixins/MExchangeCore.sol @@ -21,7 +21,7 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-libs/contracts/libs/LibOrder.sol"; import "@0x/contracts-libs/contracts/libs/LibFillResults.sol"; -import "../interfaces/IExchangeCore.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchangeCore.sol"; contract MExchangeCore is diff --git a/contracts/core/contracts/protocol/Exchange/mixins/MMatchOrders.sol b/contracts/protocol/contracts/protocol/Exchange/mixins/MMatchOrders.sol index bb285de03..1eb4be329 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MMatchOrders.sol +++ b/contracts/protocol/contracts/protocol/Exchange/mixins/MMatchOrders.sol @@ -20,7 +20,7 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-libs/contracts/libs/LibOrder.sol"; import "@0x/contracts-libs/contracts/libs/LibFillResults.sol"; -import "../interfaces/IMatchOrders.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IMatchOrders.sol"; contract MMatchOrders is diff --git a/contracts/core/contracts/protocol/Exchange/mixins/MSignatureValidator.sol b/contracts/protocol/contracts/protocol/Exchange/mixins/MSignatureValidator.sol index 1fe88b908..a933976d1 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MSignatureValidator.sol +++ b/contracts/protocol/contracts/protocol/Exchange/mixins/MSignatureValidator.sol @@ -18,7 +18,7 @@ pragma solidity 0.4.24; -import "../interfaces/ISignatureValidator.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/ISignatureValidator.sol"; contract MSignatureValidator is diff --git a/contracts/core/contracts/protocol/Exchange/mixins/MTransactions.sol b/contracts/protocol/contracts/protocol/Exchange/mixins/MTransactions.sol index 4f61a4945..a6b0fdc85 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MTransactions.sol +++ b/contracts/protocol/contracts/protocol/Exchange/mixins/MTransactions.sol @@ -17,7 +17,7 @@ */ pragma solidity 0.4.24; -import "../interfaces/ITransactions.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/ITransactions.sol"; contract MTransactions is diff --git a/contracts/core/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol b/contracts/protocol/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol index 2d21bf057..101e7cb82 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol +++ b/contracts/protocol/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol @@ -21,7 +21,7 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-libs/contracts/libs/LibOrder.sol"; import "@0x/contracts-libs/contracts/libs/LibFillResults.sol"; -import "../interfaces/IWrapperFunctions.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IWrapperFunctions.sol"; contract MWrapperFunctions is diff --git a/contracts/core/contracts/extensions/OrderValidator/OrderValidator.sol b/contracts/protocol/contracts/protocol/OrderValidator/OrderValidator.sol index 9e9e63e9b..33dd1326c 100644 --- a/contracts/core/contracts/extensions/OrderValidator/OrderValidator.sol +++ b/contracts/protocol/contracts/protocol/OrderValidator/OrderValidator.sol @@ -19,10 +19,10 @@ pragma solidity 0.4.24; pragma experimental ABIEncoderV2; -import "../../protocol/Exchange/interfaces/IExchange.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol"; import "@0x/contracts-libs/contracts/libs/LibOrder.sol"; -import "../../tokens/ERC20Token/IERC20Token.sol"; -import "../../tokens/ERC721Token/IERC721Token.sol"; +import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol"; +import "@0x/contracts-tokens/contracts/tokens/ERC721Token/IERC721Token.sol"; import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol"; diff --git a/contracts/core/contracts/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol b/contracts/protocol/contracts/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol index ad71fc9a1..ad71fc9a1 100644 --- a/contracts/core/contracts/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol +++ b/contracts/protocol/contracts/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol diff --git a/contracts/core/contracts/test/TestAssetProxyOwner/TestAssetProxyOwner.sol b/contracts/protocol/contracts/test/TestAssetProxyOwner/TestAssetProxyOwner.sol index 52c66cb56..52c66cb56 100644 --- a/contracts/core/contracts/test/TestAssetProxyOwner/TestAssetProxyOwner.sol +++ b/contracts/protocol/contracts/test/TestAssetProxyOwner/TestAssetProxyOwner.sol diff --git a/contracts/core/contracts/test/TestExchangeInternals/TestExchangeInternals.sol b/contracts/protocol/contracts/test/TestExchangeInternals/TestExchangeInternals.sol index 27187f8f8..27187f8f8 100644 --- a/contracts/core/contracts/test/TestExchangeInternals/TestExchangeInternals.sol +++ b/contracts/protocol/contracts/test/TestExchangeInternals/TestExchangeInternals.sol diff --git a/contracts/core/contracts/test/TestSignatureValidator/TestSignatureValidator.sol b/contracts/protocol/contracts/test/TestSignatureValidator/TestSignatureValidator.sol index ea3e2de59..ea3e2de59 100644 --- a/contracts/core/contracts/test/TestSignatureValidator/TestSignatureValidator.sol +++ b/contracts/protocol/contracts/test/TestSignatureValidator/TestSignatureValidator.sol diff --git a/contracts/core/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol b/contracts/protocol/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol index 41aab01c8..d08da7303 100644 --- a/contracts/core/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol +++ b/contracts/protocol/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol @@ -18,7 +18,7 @@ pragma solidity 0.4.24; -import "../../tokens/ERC20Token/IERC20Token.sol"; +import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol"; // solhint-disable no-unused-vars diff --git a/contracts/core/package.json b/contracts/protocol/package.json index 43fa9370e..838189371 100644 --- a/contracts/core/package.json +++ b/contracts/protocol/package.json @@ -1,7 +1,6 @@ { - "private": true, - "name": "@0x/contracts-core", - "version": "2.1.56", + "name": "@0x/contracts-protocol", + "version": "2.1.59", "engines": { "node": ">=6.12" }, @@ -19,8 +18,7 @@ "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", "test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html", "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", + "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler --contracts-dir contracts", "clean": "shx rm -rf lib generated-artifacts generated-wrappers", "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers", @@ -30,10 +28,10 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "lint-contracts": "solhint contracts/**/**/**/**/*.sol" + "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(AssetProxyOwner|DummyERC20Token|DummyERC721Receiver|DummyERC721Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|DutchAuction|ERC20Token|ERC20Proxy|ERC721Token|ERC721Proxy|Forwarder|Exchange|ExchangeWrapper|IAssetData|IAssetProxy|InvalidERC721Receiver|MixinAuthorizable|MultiAssetProxy|OrderValidator|ReentrantERC20Token|TestAssetProxyOwner|TestAssetProxyDispatcher|TestConstants|TestExchangeInternals|TestLibBytes|TestSignatureValidator|TestStaticCallReceiver|Validator|Wallet|Whitelist|WETH9|ZRXToken).json" + "abis": "generated-artifacts/@(AssetProxyOwner|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiAssetProxy|OrderValidator|TestSignatureValidator|TestAssetProxyOwner|TestAssetProxyDispatcher|TestExchangeInternals|TestStaticCallReceiver).json" }, "repository": { "type": "git", @@ -43,15 +41,15 @@ "bugs": { "url": "https://github.com/0xProject/0x-monorepo/issues" }, - "homepage": "https://github.com/0xProject/0x-monorepo/contracts/core/README.md", + "homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md", "devDependencies": { - "@0x/contracts-test-utils": "^1.0.0", - "@0x/abi-gen": "^1.0.17", - "@0x/dev-utils": "^1.0.19", - "@0x/sol-compiler": "^1.1.14", - "@0x/sol-cov": "^2.1.14", - "@0x/subproviders": "^2.1.6", - "@0x/tslint-config": "^1.0.10", + "@0x/abi-gen": "^1.0.19", + "@0x/contracts-test-utils": "^1.0.2", + "@0x/dev-utils": "^1.0.21", + "@0x/sol-compiler": "^1.1.16", + "@0x/sol-cov": "^2.1.16", + "@0x/subproviders": "^2.1.8", + "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", "@types/node": "*", @@ -60,30 +58,33 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", "dirty-chai": "^2.0.1", - "make-promises-safe": "^1.1.0", "ethereumjs-abi": "0.6.5", + "make-promises-safe": "^1.1.0", "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", "solc": "^0.4.24", - "solhint": "^1.2.1", + "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.8", - "@0x/order-utils": "^3.0.4", - "@0x/contracts-multisig": "^1.0.0", - "@0x/contracts-utils": "^1.0.0", - "@0x/contracts-libs": "^1.0.0", - "@0x/types": "^1.3.0", - "@0x/typescript-typings": "^3.0.4", - "@0x/utils": "^2.0.6", - "@0x/web3-wrapper": "^3.1.6", + "@0x/base-contract": "^3.0.10", + "@0x/contracts-examples": "^1.0.2", + "@0x/contracts-interfaces": "^1.0.2", + "@0x/contracts-libs": "^1.0.2", + "@0x/contracts-multisig": "^1.0.2", + "@0x/contracts-tokens": "^1.0.2", + "@0x/contracts-utils": "^1.0.2", + "@0x/order-utils": "^3.0.7", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", - "ethereum-types": "^1.1.2", + "ethereum-types": "^1.1.4", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5" }, diff --git a/contracts/protocol/src/artifacts/index.ts b/contracts/protocol/src/artifacts/index.ts new file mode 100644 index 000000000..1d53ceb04 --- /dev/null +++ b/contracts/protocol/src/artifacts/index.ts @@ -0,0 +1,29 @@ +import { ContractArtifact } from 'ethereum-types'; + +import * as AssetProxyOwner from '../../generated-artifacts/AssetProxyOwner.json'; +import * as ERC20Proxy from '../../generated-artifacts/ERC20Proxy.json'; +import * as ERC721Proxy from '../../generated-artifacts/ERC721Proxy.json'; +import * as Exchange from '../../generated-artifacts/Exchange.json'; +import * as MixinAuthorizable from '../../generated-artifacts/MixinAuthorizable.json'; +import * as MultiAssetProxy from '../../generated-artifacts/MultiAssetProxy.json'; +import * as OrderValidator from '../../generated-artifacts/OrderValidator.json'; +import * as TestAssetProxyDispatcher from '../../generated-artifacts/TestAssetProxyDispatcher.json'; +import * as TestAssetProxyOwner from '../../generated-artifacts/TestAssetProxyOwner.json'; +import * as TestExchangeInternals from '../../generated-artifacts/TestExchangeInternals.json'; +import * as TestSignatureValidator from '../../generated-artifacts/TestSignatureValidator.json'; +import * as TestStaticCallReceiver from '../../generated-artifacts/TestStaticCallReceiver.json'; + +export const artifacts = { + AssetProxyOwner: AssetProxyOwner as ContractArtifact, + ERC20Proxy: ERC20Proxy as ContractArtifact, + ERC721Proxy: ERC721Proxy as ContractArtifact, + Exchange: Exchange as ContractArtifact, + MixinAuthorizable: MixinAuthorizable as ContractArtifact, + MultiAssetProxy: MultiAssetProxy as ContractArtifact, + OrderValidator: OrderValidator as ContractArtifact, + TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact, + TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact, + TestExchangeInternals: TestExchangeInternals as ContractArtifact, + TestSignatureValidator: TestSignatureValidator as ContractArtifact, + TestStaticCallReceiver: TestStaticCallReceiver as ContractArtifact, +}; diff --git a/contracts/protocol/src/index.ts b/contracts/protocol/src/index.ts new file mode 100644 index 000000000..ba813e7ca --- /dev/null +++ b/contracts/protocol/src/index.ts @@ -0,0 +1,3 @@ +export * from './artifacts'; +export * from './wrappers'; +export * from '../test/utils'; diff --git a/contracts/protocol/src/wrappers/index.ts b/contracts/protocol/src/wrappers/index.ts new file mode 100644 index 000000000..ac951d269 --- /dev/null +++ b/contracts/protocol/src/wrappers/index.ts @@ -0,0 +1,11 @@ +export * from '../../generated-wrappers/asset_proxy_owner'; +export * from '../../generated-wrappers/erc20_proxy'; +export * from '../../generated-wrappers/erc721_proxy'; +export * from '../../generated-wrappers/exchange'; +export * from '../../generated-wrappers/mixin_authorizable'; +export * from '../../generated-wrappers/order_validator'; +export * from '../../generated-wrappers/test_asset_proxy_dispatcher'; +export * from '../../generated-wrappers/test_asset_proxy_owner'; +export * from '../../generated-wrappers/test_exchange_internals'; +export * from '../../generated-wrappers/test_signature_validator'; +export * from '../../generated-wrappers/test_static_call_receiver'; diff --git a/contracts/core/test/asset_proxy/authorizable.ts b/contracts/protocol/test/asset_proxy/authorizable.ts index 853d18be0..853d18be0 100644 --- a/contracts/core/test/asset_proxy/authorizable.ts +++ b/contracts/protocol/test/asset_proxy/authorizable.ts diff --git a/contracts/core/test/asset_proxy/proxies.ts b/contracts/protocol/test/asset_proxy/proxies.ts index 2527b0fbf..c4bd95905 100644 --- a/contracts/core/test/asset_proxy/proxies.ts +++ b/contracts/protocol/test/asset_proxy/proxies.ts @@ -1,3 +1,4 @@ +import { artifacts as interfacesArtifacts, IAssetDataContract, IAssetProxyContract } from '@0x/contracts-interfaces'; import { chaiSetup, constants, @@ -8,6 +9,14 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { + artifacts as tokensArtifacts, + DummyERC20TokenContract, + DummyERC721ReceiverContract, + DummyERC721TokenContract, + DummyMultipleReturnERC20TokenContract, + DummyNoReturnERC20TokenContract, +} from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils } from '@0x/order-utils'; import { RevertReason } from '@0x/types'; @@ -15,15 +24,8 @@ import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; -import { DummyERC721ReceiverContract } from '../../generated-wrappers/dummy_erc721_receiver'; -import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token'; -import { DummyMultipleReturnERC20TokenContract } from '../../generated-wrappers/dummy_multiple_return_erc20_token'; -import { DummyNoReturnERC20TokenContract } from '../../generated-wrappers/dummy_no_return_erc20_token'; import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy'; import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy'; -import { IAssetDataContract } from '../../generated-wrappers/i_asset_data'; -import { IAssetProxyContract } from '../../generated-wrappers/i_asset_proxy'; import { MultiAssetProxyContract } from '../../generated-wrappers/multi_asset_proxy'; import { artifacts } from '../../src/artifacts'; import { ERC20Wrapper } from '../utils/erc20_wrapper'; @@ -33,12 +35,12 @@ chaiSetup.configure(); const expect = chai.expect; const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); const assetProxyInterface = new IAssetProxyContract( - artifacts.IAssetProxy.compilerOutput.abi, + interfacesArtifacts.IAssetProxy.compilerOutput.abi, constants.NULL_ADDRESS, provider, ); const assetDataInterface = new IAssetDataContract( - artifacts.IAssetData.compilerOutput.abi, + interfacesArtifacts.IAssetData.compilerOutput.abi, constants.NULL_ADDRESS, provider, ); @@ -144,7 +146,7 @@ describe('Asset Transfer Proxies', () => { constants.DUMMY_TOKEN_DECIMALS, ); noReturnErc20Token = await DummyNoReturnERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyNoReturnERC20Token, + tokensArtifacts.DummyNoReturnERC20Token, provider, txDefaults, constants.DUMMY_TOKEN_NAME, @@ -153,7 +155,7 @@ describe('Asset Transfer Proxies', () => { constants.DUMMY_TOKEN_TOTAL_SUPPLY, ); multipleReturnErc20Token = await DummyMultipleReturnERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyMultipleReturnERC20Token, + tokensArtifacts.DummyMultipleReturnERC20Token, provider, txDefaults, constants.DUMMY_TOKEN_NAME, @@ -194,7 +196,7 @@ describe('Asset Transfer Proxies', () => { // Deploy and configure ERC721 tokens and receiver [erc721TokenA, erc721TokenB] = await erc721Wrapper.deployDummyTokensAsync(); erc721Receiver = await DummyERC721ReceiverContract.deployFrom0xArtifactAsync( - artifacts.DummyERC721Receiver, + tokensArtifacts.DummyERC721Receiver, provider, txDefaults, ); @@ -558,7 +560,7 @@ describe('Asset Transfer Proxies', () => { erc721Receiver.address, amount, ); - const logDecoder = new LogDecoder(web3Wrapper, artifacts); + const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokensArtifacts }); const tx = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, diff --git a/contracts/core/test/exchange/core.ts b/contracts/protocol/test/exchange/core.ts index fd6b9ee6b..9b948f991 100644 --- a/contracts/core/test/exchange/core.ts +++ b/contracts/protocol/test/exchange/core.ts @@ -1,3 +1,4 @@ +import { artifacts as interfacesArtifacts, IAssetDataContract } from '@0x/contracts-interfaces'; import { chaiSetup, constants, @@ -11,6 +12,14 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { + artifacts as tokensArtifacts, + DummyERC20TokenContract, + DummyERC20TokenTransferEventArgs, + DummyERC721TokenContract, + DummyNoReturnERC20TokenContract, + ReentrantERC20TokenContract, +} from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils, orderHashUtils } from '@0x/order-utils'; import { RevertReason, SignatureType, SignedOrder } from '@0x/types'; @@ -21,15 +30,10 @@ import { LogWithDecodedArgs } from 'ethereum-types'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; -import { DummyERC20TokenContract, DummyERC20TokenTransferEventArgs } from '../../generated-wrappers/dummy_erc20_token'; -import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token'; -import { DummyNoReturnERC20TokenContract } from '../../generated-wrappers/dummy_no_return_erc20_token'; import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy'; import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy'; import { ExchangeCancelEventArgs, ExchangeContract } from '../../generated-wrappers/exchange'; -import { IAssetDataContract } from '../../generated-wrappers/i_asset_data'; import { MultiAssetProxyContract } from '../../generated-wrappers/multi_asset_proxy'; -import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token'; import { TestStaticCallReceiverContract } from '../../generated-wrappers/test_static_call_receiver'; import { artifacts } from '../../src/artifacts'; import { ERC20Wrapper } from '../utils/erc20_wrapper'; @@ -40,7 +44,7 @@ chaiSetup.configure(); const expect = chai.expect; const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); const assetDataInterface = new IAssetDataContract( - artifacts.IAssetData.compilerOutput.abi, + interfacesArtifacts.IAssetData.compilerOutput.abi, constants.NULL_ADDRESS, provider, ); @@ -116,7 +120,7 @@ describe('Exchange core', () => { txDefaults, ); reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.ReentrantERC20Token, + tokensArtifacts.ReentrantERC20Token, provider, txDefaults, exchange.address, @@ -341,7 +345,7 @@ describe('Exchange core', () => { describe('Testing exchange of ERC20 tokens with no return values', () => { before(async () => { noReturnErc20Token = await DummyNoReturnERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyNoReturnERC20Token, + tokensArtifacts.DummyNoReturnERC20Token, provider, txDefaults, constants.DUMMY_TOKEN_NAME, diff --git a/contracts/core/test/exchange/dispatcher.ts b/contracts/protocol/test/exchange/dispatcher.ts index 9bc5cbcce..5b1ac1e20 100644 --- a/contracts/core/test/exchange/dispatcher.ts +++ b/contracts/protocol/test/exchange/dispatcher.ts @@ -7,6 +7,7 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { DummyERC20TokenContract } from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils } from '@0x/order-utils'; import { AssetProxyId, RevertReason } from '@0x/types'; @@ -15,7 +16,6 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy'; import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy'; import { diff --git a/contracts/core/test/exchange/fill_order.ts b/contracts/protocol/test/exchange/fill_order.ts index 2bdbe4855..2bdbe4855 100644 --- a/contracts/core/test/exchange/fill_order.ts +++ b/contracts/protocol/test/exchange/fill_order.ts diff --git a/contracts/core/test/exchange/internal.ts b/contracts/protocol/test/exchange/internal.ts index 972f5efb6..972f5efb6 100644 --- a/contracts/core/test/exchange/internal.ts +++ b/contracts/protocol/test/exchange/internal.ts diff --git a/contracts/core/test/exchange/match_orders.ts b/contracts/protocol/test/exchange/match_orders.ts index 0e841b359..8e943c237 100644 --- a/contracts/core/test/exchange/match_orders.ts +++ b/contracts/protocol/test/exchange/match_orders.ts @@ -9,6 +9,12 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { + artifacts as tokensArtifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + ReentrantERC20TokenContract, +} from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils } from '@0x/order-utils'; import { RevertReason } from '@0x/types'; @@ -17,12 +23,9 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; -import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token'; import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy'; import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy'; import { ExchangeContract } from '../../generated-wrappers/exchange'; -import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token'; import { TestExchangeInternalsContract } from '../../generated-wrappers/test_exchange_internals'; import { artifacts } from '../../src/artifacts'; import { ERC20Wrapper } from '../utils/erc20_wrapper'; @@ -139,7 +142,7 @@ describe('matchOrders', () => { ); reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.ReentrantERC20Token, + tokensArtifacts.ReentrantERC20Token, provider, txDefaults, exchange.address, diff --git a/contracts/core/test/extensions/order_validator.ts b/contracts/protocol/test/exchange/order_validator.ts index 3dbe76f6e..8f53426db 100644 --- a/contracts/core/test/extensions/order_validator.ts +++ b/contracts/protocol/test/exchange/order_validator.ts @@ -7,6 +7,7 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { DummyERC20TokenContract, DummyERC721TokenContract } from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils, orderHashUtils } from '@0x/order-utils'; import { SignedOrder } from '@0x/types'; @@ -14,16 +15,16 @@ import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; -import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token'; -import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy'; -import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy'; -import { ExchangeContract } from '../../generated-wrappers/exchange'; -import { OrderValidatorContract } from '../../generated-wrappers/order_validator'; -import { artifacts } from '../../src/artifacts'; -import { ERC20Wrapper } from '../utils/erc20_wrapper'; -import { ERC721Wrapper } from '../utils/erc721_wrapper'; -import { ExchangeWrapper } from '../utils/exchange_wrapper'; +import { + artifacts, + ERC20ProxyContract, + ERC20Wrapper, + ERC721ProxyContract, + ERC721Wrapper, + ExchangeContract, + ExchangeWrapper, + OrderValidatorContract, +} from '../../src'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/core/test/exchange/signature_validator.ts b/contracts/protocol/test/exchange/signature_validator.ts index b84a488a1..3f1786b5b 100644 --- a/contracts/core/test/exchange/signature_validator.ts +++ b/contracts/protocol/test/exchange/signature_validator.ts @@ -1,3 +1,4 @@ +import { artifacts as examplesArtifacts, ValidatorContract, WalletContract } from '@0x/contracts-examples'; import { addressUtils, chaiSetup, @@ -9,6 +10,7 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { artifacts as tokensArtifacts } from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils, orderHashUtils, signatureUtils } from '@0x/order-utils'; import { RevertReason, SignatureType, SignedOrder } from '@0x/types'; @@ -17,13 +19,11 @@ import { LogWithDecodedArgs } from 'ethereum-types'; import ethUtil = require('ethereumjs-util'); import { + artifacts, TestSignatureValidatorContract, TestSignatureValidatorSignatureValidatorApprovalEventArgs, -} from '../../generated-wrappers/test_signature_validator'; -import { TestStaticCallReceiverContract } from '../../generated-wrappers/test_static_call_receiver'; -import { ValidatorContract } from '../../generated-wrappers/validator'; -import { WalletContract } from '../../generated-wrappers/wallet'; -import { artifacts } from '../../src/artifacts'; + TestStaticCallReceiverContract, +} from '../../src'; chaiSetup.configure(); const expect = chai.expect; @@ -61,13 +61,13 @@ describe('MixinSignatureValidator', () => { txDefaults, ); testWallet = await WalletContract.deployFrom0xArtifactAsync( - artifacts.Wallet, + examplesArtifacts.Wallet, provider, txDefaults, signerAddress, ); testValidator = await ValidatorContract.deployFrom0xArtifactAsync( - artifacts.Validator, + examplesArtifacts.Validator, provider, txDefaults, signerAddress, @@ -77,7 +77,7 @@ describe('MixinSignatureValidator', () => { provider, txDefaults, ); - signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, artifacts); + signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokensArtifacts }); await web3Wrapper.awaitTransactionSuccessAsync( await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync(testValidator.address, true, { from: signerAddress, @@ -135,7 +135,7 @@ describe('MixinSignatureValidator', () => { it('should revert when signature type is unsupported', async () => { const unsupportedSignatureType = SignatureType.NSignatureTypes; - const unsupportedSignatureHex = '0x' + Buffer.from([unsupportedSignatureType]).toString('hex'); + const unsupportedSignatureHex = `0x${Buffer.from([unsupportedSignatureType]).toString('hex')}`; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); return expectContractCallFailedAsync( signatureValidator.publicIsValidSignature.callAsync( @@ -148,7 +148,7 @@ describe('MixinSignatureValidator', () => { }); it('should revert when SignatureType=Illegal', async () => { - const unsupportedSignatureHex = '0x' + Buffer.from([SignatureType.Illegal]).toString('hex'); + const unsupportedSignatureHex = `0x${Buffer.from([SignatureType.Illegal]).toString('hex')}`; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); return expectContractCallFailedAsync( signatureValidator.publicIsValidSignature.callAsync( @@ -161,7 +161,7 @@ describe('MixinSignatureValidator', () => { }); it('should return false when SignatureType=Invalid and signature has a length of zero', async () => { - const signatureHex = '0x' + Buffer.from([SignatureType.Invalid]).toString('hex'); + const signatureHex = `0x${Buffer.from([SignatureType.Invalid]).toString('hex')}`; const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync( orderHashHex, diff --git a/contracts/core/test/exchange/transactions.ts b/contracts/protocol/test/exchange/transactions.ts index c4086d9be..746f3cb04 100644 --- a/contracts/core/test/exchange/transactions.ts +++ b/contracts/protocol/test/exchange/transactions.ts @@ -1,3 +1,4 @@ +import { artifacts as examplesArtifacts, ExchangeWrapperContract, WhitelistContract } from '@0x/contracts-examples'; import { chaiSetup, constants, @@ -11,6 +12,7 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { DummyERC20TokenContract } from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils'; import { OrderWithoutExchangeAddress, RevertReason, SignedOrder } from '@0x/types'; @@ -18,11 +20,8 @@ import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy'; import { ExchangeContract } from '../../generated-wrappers/exchange'; -import { ExchangeWrapperContract } from '../../generated-wrappers/exchange_wrapper'; -import { WhitelistContract } from '../../generated-wrappers/whitelist'; import { artifacts } from '../../src/artifacts'; import { ERC20Wrapper } from '../utils/erc20_wrapper'; import { ExchangeWrapper } from '../utils/exchange_wrapper'; @@ -222,7 +221,7 @@ describe('Exchange transactions', () => { before(async () => { exchangeWrapperContract = await ExchangeWrapperContract.deployFrom0xArtifactAsync( - artifacts.ExchangeWrapper, + examplesArtifacts.ExchangeWrapper, provider, txDefaults, exchange.address, @@ -336,7 +335,7 @@ describe('Exchange transactions', () => { before(async () => { whitelist = await WhitelistContract.deployFrom0xArtifactAsync( - artifacts.Whitelist, + examplesArtifacts.Whitelist, provider, txDefaults, exchange.address, diff --git a/contracts/core/test/exchange/wrapper.ts b/contracts/protocol/test/exchange/wrapper.ts index 17cb7a3bb..c9efb0c9d 100644 --- a/contracts/core/test/exchange/wrapper.ts +++ b/contracts/protocol/test/exchange/wrapper.ts @@ -11,6 +11,12 @@ import { txDefaults, web3Wrapper, } from '@0x/contracts-test-utils'; +import { + artifacts as tokensArtifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + ReentrantERC20TokenContract, +} from '@0x/contracts-tokens'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils, orderHashUtils } from '@0x/order-utils'; import { RevertReason, SignedOrder } from '@0x/types'; @@ -19,12 +25,9 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; -import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token'; import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy'; import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy'; import { ExchangeContract } from '../../generated-wrappers/exchange'; -import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token'; import { artifacts } from '../../src/artifacts'; import { ERC20Wrapper } from '../utils/erc20_wrapper'; import { ERC721Wrapper } from '../utils/erc721_wrapper'; @@ -113,7 +116,7 @@ describe('Exchange wrappers', () => { ); reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.ReentrantERC20Token, + tokensArtifacts.ReentrantERC20Token, provider, txDefaults, exchange.address, diff --git a/contracts/protocol/test/global_hooks.ts b/contracts/protocol/test/global_hooks.ts new file mode 100644 index 000000000..f8ace376a --- /dev/null +++ b/contracts/protocol/test/global_hooks.ts @@ -0,0 +1,17 @@ +import { env, EnvVars } from '@0x/dev-utils'; + +import { coverage, profiler, provider } from '@0x/contracts-test-utils'; +before('start web3 provider', () => { + provider.start(); +}); +after('generate coverage report', async () => { + if (env.parseBoolean(EnvVars.SolidityCoverage)) { + const coverageSubprovider = coverage.getCoverageSubproviderSingleton(); + await coverageSubprovider.writeCoverageAsync(); + } + if (env.parseBoolean(EnvVars.SolidityProfiler)) { + const profilerSubprovider = profiler.getProfilerSubproviderSingleton(); + await profilerSubprovider.writeProfilerOutputAsync(); + } + provider.stop(); +}); diff --git a/contracts/core/test/multisig/asset_proxy_owner.ts b/contracts/protocol/test/multisig/asset_proxy_owner.ts index daebfb7fb..daebfb7fb 100644 --- a/contracts/core/test/multisig/asset_proxy_owner.ts +++ b/contracts/protocol/test/multisig/asset_proxy_owner.ts diff --git a/contracts/core/test/utils/asset_proxy_owner_wrapper.ts b/contracts/protocol/test/utils/asset_proxy_owner_wrapper.ts index d5aaaf519..df23658d8 100644 --- a/contracts/core/test/utils/asset_proxy_owner_wrapper.ts +++ b/contracts/protocol/test/utils/asset_proxy_owner_wrapper.ts @@ -1,4 +1,5 @@ import { LogDecoder } from '@0x/contracts-test-utils'; +import { artifacts as tokensArtifacts } from '@0x/contracts-tokens'; import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; @@ -14,7 +15,7 @@ export class AssetProxyOwnerWrapper { constructor(assetproxyOwnerContract: AssetProxyOwnerContract, provider: Provider) { this._assetProxyOwner = assetproxyOwnerContract; this._web3Wrapper = new Web3Wrapper(provider); - this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts); + this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...tokensArtifacts }); } public async submitTransactionAsync( destination: string, diff --git a/contracts/core/test/utils/asset_wrapper.ts b/contracts/protocol/test/utils/asset_wrapper.ts index e4090ad74..e4090ad74 100644 --- a/contracts/core/test/utils/asset_wrapper.ts +++ b/contracts/protocol/test/utils/asset_wrapper.ts diff --git a/contracts/core/test/utils/erc20_wrapper.ts b/contracts/protocol/test/utils/erc20_wrapper.ts index d6210646c..e5ab0e36c 100644 --- a/contracts/core/test/utils/erc20_wrapper.ts +++ b/contracts/protocol/test/utils/erc20_wrapper.ts @@ -1,11 +1,11 @@ import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils'; +import { artifacts as tokensArtifacts, DummyERC20TokenContract } from '@0x/contracts-tokens'; import { assetDataUtils } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy'; import { artifacts } from '../../src/artifacts'; @@ -38,7 +38,7 @@ export class ERC20Wrapper { for (let i = 0; i < numberToDeploy; i++) { this._dummyTokenContracts.push( await DummyERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyERC20Token, + tokensArtifacts.DummyERC20Token, this._provider, txDefaults, constants.DUMMY_TOKEN_NAME, diff --git a/contracts/core/test/utils/erc721_wrapper.ts b/contracts/protocol/test/utils/erc721_wrapper.ts index b5ae34e60..1f658ce86 100644 --- a/contracts/core/test/utils/erc721_wrapper.ts +++ b/contracts/protocol/test/utils/erc721_wrapper.ts @@ -1,11 +1,11 @@ import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils'; +import { artifacts as tokensArtifacts, DummyERC721TokenContract } from '@0x/contracts-tokens'; import { generatePseudoRandomSalt } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; -import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token'; import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy'; import { artifacts } from '../../src/artifacts'; @@ -30,7 +30,7 @@ export class ERC721Wrapper { for (const i of _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY)) { this._dummyTokenContracts.push( await DummyERC721TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyERC721Token, + tokensArtifacts.DummyERC721Token, this._provider, txDefaults, constants.DUMMY_TOKEN_NAME, diff --git a/contracts/core/test/utils/exchange_wrapper.ts b/contracts/protocol/test/utils/exchange_wrapper.ts index 2a24b880f..cb6dce901 100644 --- a/contracts/core/test/utils/exchange_wrapper.ts +++ b/contracts/protocol/test/utils/exchange_wrapper.ts @@ -6,6 +6,7 @@ import { orderUtils, SignedTransaction, } from '@0x/contracts-test-utils'; +import { artifacts as tokensArtifacts } from '@0x/contracts-tokens'; import { SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; @@ -21,7 +22,7 @@ export class ExchangeWrapper { constructor(exchangeContract: ExchangeContract, provider: Provider) { this._exchange = exchangeContract; this._web3Wrapper = new Web3Wrapper(provider); - this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts); + this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...tokensArtifacts }); } public async fillOrderAsync( signedOrder: SignedOrder, @@ -228,7 +229,7 @@ export class ExchangeWrapper { return orderEpoch; } public async getOrderInfoAsync(signedOrder: SignedOrder): Promise<OrderInfo> { - const orderInfo = (await this._exchange.getOrderInfo.callAsync(signedOrder)) as OrderInfo; + const orderInfo = await this._exchange.getOrderInfo.callAsync(signedOrder); return orderInfo; } public async getOrdersInfoAsync(signedOrders: SignedOrder[]): Promise<OrderInfo[]> { diff --git a/contracts/core/test/utils/fill_order_combinatorial_utils.ts b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts index 5d0ea07a8..5d0ea07a8 100644 --- a/contracts/core/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts diff --git a/contracts/protocol/test/utils/index.ts b/contracts/protocol/test/utils/index.ts new file mode 100644 index 000000000..75cd88666 --- /dev/null +++ b/contracts/protocol/test/utils/index.ts @@ -0,0 +1,3 @@ +export * from './exchange_wrapper'; +export * from './erc20_wrapper'; +export * from './erc721_wrapper'; diff --git a/contracts/core/test/utils/match_order_tester.ts b/contracts/protocol/test/utils/match_order_tester.ts index 8f574704e..8f574704e 100644 --- a/contracts/core/test/utils/match_order_tester.ts +++ b/contracts/protocol/test/utils/match_order_tester.ts diff --git a/contracts/core/test/utils/order_factory_from_scenario.ts b/contracts/protocol/test/utils/order_factory_from_scenario.ts index 1cc962020..ecb4b2e28 100644 --- a/contracts/core/test/utils/order_factory_from_scenario.ts +++ b/contracts/protocol/test/utils/order_factory_from_scenario.ts @@ -8,12 +8,11 @@ import { OrderScenario, TakerScenario, } from '@0x/contracts-test-utils'; +import { DummyERC721TokenContract } from '@0x/contracts-tokens'; import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils'; import { Order } from '@0x/types'; import { BigNumber, errorUtils } from '@0x/utils'; -import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token'; - const TEN_UNITS_EIGHTEEN_DECIMALS = new BigNumber(10_000_000_000_000_000_000); const FIVE_UNITS_EIGHTEEN_DECIMALS = new BigNumber(5_000_000_000_000_000_000); const POINT_ONE_UNITS_EIGHTEEN_DECIMALS = new BigNumber(100_000_000_000_000_000); diff --git a/contracts/core/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts b/contracts/protocol/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts index 64b7dedbe..64b7dedbe 100644 --- a/contracts/core/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts +++ b/contracts/protocol/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts diff --git a/contracts/core/test/utils/simple_order_filled_cancelled_fetcher.ts b/contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts index af959e00e..af959e00e 100644 --- a/contracts/core/test/utils/simple_order_filled_cancelled_fetcher.ts +++ b/contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts diff --git a/contracts/protocol/tsconfig.json b/contracts/protocol/tsconfig.json new file mode 100644 index 000000000..989d3ef2b --- /dev/null +++ b/contracts/protocol/tsconfig.json @@ -0,0 +1,24 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": ".", + "resolveJsonModule": true + }, + "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], + "files": [ + "./generated-artifacts/AssetProxyOwner.json", + "./generated-artifacts/ERC20Proxy.json", + "./generated-artifacts/ERC721Proxy.json", + "./generated-artifacts/Exchange.json", + "./generated-artifacts/MixinAuthorizable.json", + "./generated-artifacts/MultiAssetProxy.json", + "./generated-artifacts/OrderValidator.json", + "./generated-artifacts/TestAssetProxyDispatcher.json", + "./generated-artifacts/TestAssetProxyOwner.json", + "./generated-artifacts/TestExchangeInternals.json", + "./generated-artifacts/TestSignatureValidator.json", + "./generated-artifacts/TestStaticCallReceiver.json" + ], + "exclude": ["./deploy/solc/solc_bin"] +} diff --git a/contracts/protocol/tslint.json b/contracts/protocol/tslint.json new file mode 100644 index 000000000..1bb3ac2a2 --- /dev/null +++ b/contracts/protocol/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": ["@0x/tslint-config"], + "rules": { + "custom-no-magic-numbers": false + } +} diff --git a/contracts/test-utils/CHANGELOG.json b/contracts/test-utils/CHANGELOG.json new file mode 100644 index 000000000..6e4682b7e --- /dev/null +++ b/contracts/test-utils/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1544739608 + } +] diff --git a/contracts/test-utils/CHANGELOG.md b/contracts/test-utils/CHANGELOG.md new file mode 100644 index 000000000..716353d05 --- /dev/null +++ b/contracts/test-utils/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _December 13, 2018_ + + * Dependencies updated diff --git a/contracts/test-utils/package.json b/contracts/test-utils/package.json index 513cfdc10..18ec8f6a8 100644 --- a/contracts/test-utils/package.json +++ b/contracts/test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-test-utils", - "version": "1.0.0", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -40,34 +40,34 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/abi-gen": "^1.0.17", - "@0x/dev-utils": "^1.0.18", - "@0x/sol-compiler": "^1.1.13", - "@0x/subproviders": "^2.1.5", - "@0x/tslint-config": "^1.0.10", + "@0x/abi-gen": "^1.0.19", + "@0x/dev-utils": "^1.0.21", + "@0x/order-utils": "^3.0.7", + "@0x/sol-compiler": "^1.1.16", + "@0x/sol-cov": "^2.1.16", + "@0x/subproviders": "^2.1.8", + "@0x/tslint-config": "^2.0.0", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", "@types/bn.js": "^4.11.0", "@types/ethereumjs-abi": "^0.6.0", + "@types/js-combinatorics": "^0.5.29", "@types/lodash": "4.14.104", "@types/node": "*", + "bn.js": "^4.11.8", "chai": "^4.0.1", + "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", "dirty-chai": "^2.0.1", - "make-promises-safe": "^1.1.0", - "@0x/order-utils": "^3.0.3", - "@0x/types": "^1.3.0", - "@0x/typescript-typings": "^3.0.4", - "@0x/utils": "^2.0.6", - "@0x/sol-cov": "^2.1.13", - "@0x/web3-wrapper": "^3.1.5", - "@types/js-combinatorics": "^0.5.29", - "chai-as-promised": "^7.1.0", - "bn.js": "^4.11.8", - "ethereum-types": "^1.1.2", + "ethereum-types": "^1.1.4", "ethereumjs-abi": "0.6.5", "ethereumjs-util": "^5.1.1", "ethers": "~4.0.4", "js-combinatorics": "^0.5.3", - "lodash": "^4.17.5" + "lodash": "^4.17.5", + "make-promises-safe": "^1.1.0" }, "publishConfig": { "access": "public" diff --git a/contracts/test-utils/src/assertions.ts b/contracts/test-utils/src/assertions.ts index 5b1cedfcc..f31651f4d 100644 --- a/contracts/test-utils/src/assertions.ts +++ b/contracts/test-utils/src/assertions.ts @@ -23,7 +23,7 @@ export type sendTransactionResult = Promise<TransactionReceipt | TransactionRece * @returns either the given ganacheError or gethError depending on the backing * node. */ -async function _getGanacheOrGethError(ganacheError: string, gethError: string): Promise<string> { +async function _getGanacheOrGethErrorAsync(ganacheError: string, gethError: string): Promise<string> { if (_.isUndefined(nodeType)) { nodeType = await web3Wrapper.getNodeTypeAsync(); } @@ -38,15 +38,15 @@ async function _getGanacheOrGethError(ganacheError: string, gethError: string): } async function _getInsufficientFundsErrorMessageAsync(): Promise<string> { - return _getGanacheOrGethError("sender doesn't have enough funds", 'insufficient funds'); + return _getGanacheOrGethErrorAsync("sender doesn't have enough funds", 'insufficient funds'); } async function _getTransactionFailedErrorMessageAsync(): Promise<string> { - return _getGanacheOrGethError('revert', 'always failing transaction'); + return _getGanacheOrGethErrorAsync('revert', 'always failing transaction'); } async function _getContractCallFailedErrorMessageAsync(): Promise<string> { - return _getGanacheOrGethError('revert', 'Contract call failed'); + return _getGanacheOrGethErrorAsync('revert', 'Contract call failed'); } /** @@ -54,7 +54,7 @@ async function _getContractCallFailedErrorMessageAsync(): Promise<string> { * contract call. The exact error message depends on the backing Ethereum node. */ export async function getInvalidOpcodeErrorMessageForCallAsync(): Promise<string> { - return _getGanacheOrGethError('invalid opcode', 'Contract call failed'); + return _getGanacheOrGethErrorAsync('invalid opcode', 'Contract call failed'); } /** @@ -65,7 +65,7 @@ export async function getInvalidOpcodeErrorMessageForCallAsync(): Promise<string * @returns the expected error message. */ export async function getRevertReasonOrErrorMessageForSendTransactionAsync(reason: RevertReason): Promise<string> { - return _getGanacheOrGethError(reason, 'always failing transaction'); + return _getGanacheOrGethErrorAsync(reason, 'always failing transaction'); } /** @@ -137,7 +137,7 @@ export async function expectTransactionFailedWithoutReasonAsync(p: sendTransacti // directly. txReceiptStatus = result.status; } else { - throw new Error('Unexpected result type: ' + typeof result); + throw new Error(`Unexpected result type: ${typeof result}`); } expect(_.toString(txReceiptStatus)).to.equal( '0', diff --git a/contracts/test-utils/src/test_with_reference.ts b/contracts/test-utils/src/test_with_reference.ts index b80be4a6c..75d15b0aa 100644 --- a/contracts/test-utils/src/test_with_reference.ts +++ b/contracts/test-utils/src/test_with_reference.ts @@ -26,7 +26,7 @@ type PromiseResult<T> = Value<T> | ErrorMessage; // TODO(albrow): This seems like a generic utility function that could exist in // lodash. We should replace it by a library implementation, or move it to our // own. -async function evaluatePromise<T>(promise: Promise<T>): Promise<PromiseResult<T>> { +async function evaluatePromiseAsync<T>(promise: Promise<T>): Promise<PromiseResult<T>> { try { return new Value<T>(await promise); } catch (e) { @@ -93,10 +93,10 @@ export async function testWithReferenceFuncAsync( values: any[], ): Promise<void> { // Measure correct behaviour - const expected = await evaluatePromise(referenceFuncAsync(...values)); + const expected = await evaluatePromiseAsync(referenceFuncAsync(...values)); // Measure actual behaviour - const actual = await evaluatePromise(testFuncAsync(...values)); + const actual = await evaluatePromiseAsync(testFuncAsync(...values)); // Compare behaviour if (expected instanceof ErrorMessage) { diff --git a/contracts/core/.solhintignore b/contracts/tokens/.solhintignore index 1e33ec53b..1e33ec53b 100644 --- a/contracts/core/.solhintignore +++ b/contracts/tokens/.solhintignore diff --git a/contracts/tokens/CHANGELOG.json b/contracts/tokens/CHANGELOG.json new file mode 100644 index 000000000..19ac770af --- /dev/null +++ b/contracts/tokens/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "timestamp": 1544741676, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + } +] diff --git a/contracts/tokens/CHANGELOG.md b/contracts/tokens/CHANGELOG.md new file mode 100644 index 000000000..716353d05 --- /dev/null +++ b/contracts/tokens/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _December 13, 2018_ + + * Dependencies updated diff --git a/contracts/tokens/DEPLOYS.json b/contracts/tokens/DEPLOYS.json new file mode 100644 index 000000000..5ff58c035 --- /dev/null +++ b/contracts/tokens/DEPLOYS.json @@ -0,0 +1,16 @@ +[ + { + "name": "ZRXToken", + "version": "1.0.0", + "changes": [ + { + "note": "protocol v1 deploy", + "networks": { + "1": "0xe41d2489571d322189246dafa5ebde1f4699f498", + "3": "0xff67881f8d12f372d91baae9752eb3631ff0ed00", + "42": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa" + } + } + ] + } +] diff --git a/contracts/tokens/README.md b/contracts/tokens/README.md new file mode 100644 index 000000000..9c4106d41 --- /dev/null +++ b/contracts/tokens/README.md @@ -0,0 +1,74 @@ +## Token contracts + +Token smart contracts that are used in the 0x protocol. Addresses of the deployed contracts can be found in the 0x [wiki](https://0xproject.com/wiki#Deployed-Addresses) or the [CHANGELOG](./CHANGELOG.json) of this package. + +## Usage + +Token contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories: + +* [tokens](./contracts/tokens) + * This directory contains implementations of different tokens and token standards, including [wETH](https://weth.io/), ZRX, [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md), and [ERC721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md). +* [test](./contracts/test) + * This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. + +## Bug bounty + +A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0xproject.com/wiki#Bug-Bounty). + +## Contributing + +We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. + +For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install Dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/contracts-tokens yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0x/contracts-tokens yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` + +#### Testing options + +Contracts testing options like coverage, profiling, revert traces or backing node choosing - are described [here](../TESTING.md). diff --git a/contracts/tokens/compiler.json b/contracts/tokens/compiler.json new file mode 100644 index 000000000..498c5d826 --- /dev/null +++ b/contracts/tokens/compiler.json @@ -0,0 +1,44 @@ +{ + "artifactsDir": "./generated-artifacts", + "contractsDir": "./contracts", + "compilerSettings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode.object", + "evm.bytecode.sourceMap", + "evm.deployedBytecode.object", + "evm.deployedBytecode.sourceMap" + ] + } + } + }, + "contracts": [ + "DummyERC20Token", + "DummyMultipleReturnERC20Token", + "DummyNoReturnERC20Token", + "DummyERC721Receiver", + "InvalidERC721Receiver", + "DummyERC721Token", + "ReentrantERC20Token", + "ERC20Token", + "IERC20Token", + "MintableERC20Token", + "UnlimitedAllowanceERC20Token", + "ERC721Token", + "IERC721Receiver", + "IERC721Token", + "MintableERC721Token", + "IEtherToken", + "WETH9", + "ERC20Token_v1", + "Token_v1", + "UnlimitedAllowanceToken_v1", + "ZRXToken" + ] +} diff --git a/contracts/core/contracts/test/DummyERC20Token/DummyERC20Token.sol b/contracts/tokens/contracts/test/DummyERC20Token/DummyERC20Token.sol index 33028db0c..33028db0c 100644 --- a/contracts/core/contracts/test/DummyERC20Token/DummyERC20Token.sol +++ b/contracts/tokens/contracts/test/DummyERC20Token/DummyERC20Token.sol diff --git a/contracts/core/contracts/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol b/contracts/tokens/contracts/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol index 733d4437e..733d4437e 100644 --- a/contracts/core/contracts/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol +++ b/contracts/tokens/contracts/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol diff --git a/contracts/core/contracts/test/DummyERC20Token/DummyNoReturnERC20Token.sol b/contracts/tokens/contracts/test/DummyERC20Token/DummyNoReturnERC20Token.sol index e16825a16..e16825a16 100644 --- a/contracts/core/contracts/test/DummyERC20Token/DummyNoReturnERC20Token.sol +++ b/contracts/tokens/contracts/test/DummyERC20Token/DummyNoReturnERC20Token.sol diff --git a/contracts/core/contracts/test/DummyERC721Receiver/DummyERC721Receiver.sol b/contracts/tokens/contracts/test/DummyERC721Receiver/DummyERC721Receiver.sol index 6c8371559..6c8371559 100644 --- a/contracts/core/contracts/test/DummyERC721Receiver/DummyERC721Receiver.sol +++ b/contracts/tokens/contracts/test/DummyERC721Receiver/DummyERC721Receiver.sol diff --git a/contracts/core/contracts/test/DummyERC721Receiver/InvalidERC721Receiver.sol b/contracts/tokens/contracts/test/DummyERC721Receiver/InvalidERC721Receiver.sol index 309633bf5..309633bf5 100644 --- a/contracts/core/contracts/test/DummyERC721Receiver/InvalidERC721Receiver.sol +++ b/contracts/tokens/contracts/test/DummyERC721Receiver/InvalidERC721Receiver.sol diff --git a/contracts/core/contracts/test/DummyERC721Token/DummyERC721Token.sol b/contracts/tokens/contracts/test/DummyERC721Token/DummyERC721Token.sol index 4c978b2df..4c978b2df 100644 --- a/contracts/core/contracts/test/DummyERC721Token/DummyERC721Token.sol +++ b/contracts/tokens/contracts/test/DummyERC721Token/DummyERC721Token.sol diff --git a/contracts/core/contracts/test/ReentrantERC20Token/ReentrantERC20Token.sol b/contracts/tokens/contracts/test/ReentrantERC20Token/ReentrantERC20Token.sol index 8e077e3e8..d8c65929d 100644 --- a/contracts/core/contracts/test/ReentrantERC20Token/ReentrantERC20Token.sol +++ b/contracts/tokens/contracts/test/ReentrantERC20Token/ReentrantERC20Token.sol @@ -21,7 +21,7 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol"; import "../../tokens/ERC20Token/ERC20Token.sol"; -import "../../protocol/Exchange/interfaces/IExchange.sol"; +import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol"; import "@0x/contracts-libs/contracts/libs/LibOrder.sol"; diff --git a/contracts/core/contracts/tokens/ERC20Token/ERC20Token.sol b/contracts/tokens/contracts/tokens/ERC20Token/ERC20Token.sol index 725d304df..725d304df 100644 --- a/contracts/core/contracts/tokens/ERC20Token/ERC20Token.sol +++ b/contracts/tokens/contracts/tokens/ERC20Token/ERC20Token.sol diff --git a/contracts/core/contracts/tokens/ERC20Token/IERC20Token.sol b/contracts/tokens/contracts/tokens/ERC20Token/IERC20Token.sol index 258d47393..258d47393 100644 --- a/contracts/core/contracts/tokens/ERC20Token/IERC20Token.sol +++ b/contracts/tokens/contracts/tokens/ERC20Token/IERC20Token.sol diff --git a/contracts/core/contracts/tokens/ERC20Token/MintableERC20Token.sol b/contracts/tokens/contracts/tokens/ERC20Token/MintableERC20Token.sol index 58bccb5a1..58bccb5a1 100644 --- a/contracts/core/contracts/tokens/ERC20Token/MintableERC20Token.sol +++ b/contracts/tokens/contracts/tokens/ERC20Token/MintableERC20Token.sol diff --git a/contracts/core/contracts/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol b/contracts/tokens/contracts/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol index 2e5bd4348..2e5bd4348 100644 --- a/contracts/core/contracts/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol +++ b/contracts/tokens/contracts/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol diff --git a/contracts/core/contracts/tokens/ERC721Token/ERC721Token.sol b/contracts/tokens/contracts/tokens/ERC721Token/ERC721Token.sol index 600cee1ab..600cee1ab 100644 --- a/contracts/core/contracts/tokens/ERC721Token/ERC721Token.sol +++ b/contracts/tokens/contracts/tokens/ERC721Token/ERC721Token.sol diff --git a/contracts/core/contracts/tokens/ERC721Token/IERC721Receiver.sol b/contracts/tokens/contracts/tokens/ERC721Token/IERC721Receiver.sol index 8e0e32ab2..8e0e32ab2 100644 --- a/contracts/core/contracts/tokens/ERC721Token/IERC721Receiver.sol +++ b/contracts/tokens/contracts/tokens/ERC721Token/IERC721Receiver.sol diff --git a/contracts/core/contracts/tokens/ERC721Token/IERC721Token.sol b/contracts/tokens/contracts/tokens/ERC721Token/IERC721Token.sol index ac992c80d..ac992c80d 100644 --- a/contracts/core/contracts/tokens/ERC721Token/IERC721Token.sol +++ b/contracts/tokens/contracts/tokens/ERC721Token/IERC721Token.sol diff --git a/contracts/core/contracts/tokens/ERC721Token/MintableERC721Token.sol b/contracts/tokens/contracts/tokens/ERC721Token/MintableERC721Token.sol index bc5cd2cc2..bc5cd2cc2 100644 --- a/contracts/core/contracts/tokens/ERC721Token/MintableERC721Token.sol +++ b/contracts/tokens/contracts/tokens/ERC721Token/MintableERC721Token.sol diff --git a/contracts/core/contracts/tokens/EtherToken/IEtherToken.sol b/contracts/tokens/contracts/tokens/EtherToken/IEtherToken.sol index 9e2e68766..9e2e68766 100644 --- a/contracts/core/contracts/tokens/EtherToken/IEtherToken.sol +++ b/contracts/tokens/contracts/tokens/EtherToken/IEtherToken.sol diff --git a/contracts/core/contracts/tokens/EtherToken/WETH9.sol b/contracts/tokens/contracts/tokens/EtherToken/WETH9.sol index 17876b86d..17876b86d 100644 --- a/contracts/core/contracts/tokens/EtherToken/WETH9.sol +++ b/contracts/tokens/contracts/tokens/EtherToken/WETH9.sol diff --git a/contracts/core/contracts/tokens/ZRXToken/ERC20Token_v1.sol b/contracts/tokens/contracts/tokens/ZRXToken/ERC20Token_v1.sol index 4920c4aac..4920c4aac 100644 --- a/contracts/core/contracts/tokens/ZRXToken/ERC20Token_v1.sol +++ b/contracts/tokens/contracts/tokens/ZRXToken/ERC20Token_v1.sol diff --git a/contracts/core/contracts/tokens/ZRXToken/Token_v1.sol b/contracts/tokens/contracts/tokens/ZRXToken/Token_v1.sol index de619fb7e..de619fb7e 100644 --- a/contracts/core/contracts/tokens/ZRXToken/Token_v1.sol +++ b/contracts/tokens/contracts/tokens/ZRXToken/Token_v1.sol diff --git a/contracts/core/contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol b/contracts/tokens/contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol index bf1b0335a..bf1b0335a 100644 --- a/contracts/core/contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol +++ b/contracts/tokens/contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol diff --git a/contracts/core/contracts/tokens/ZRXToken/ZRXToken.sol b/contracts/tokens/contracts/tokens/ZRXToken/ZRXToken.sol index 831e1822c..831e1822c 100644 --- a/contracts/core/contracts/tokens/ZRXToken/ZRXToken.sol +++ b/contracts/tokens/contracts/tokens/ZRXToken/ZRXToken.sol diff --git a/contracts/tokens/package.json b/contracts/tokens/package.json new file mode 100644 index 000000000..6f8a366dd --- /dev/null +++ b/contracts/tokens/package.json @@ -0,0 +1,92 @@ +{ + "name": "@0x/contracts-tokens", + "version": "1.0.2", + "engines": { + "node": ">=6.12" + }, + "description": "Token contracts used by 0x protocol", + "main": "lib/src/index.js", + "directories": { + "test": "test" + }, + "scripts": { + "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", + "pre_build": "run-s compile generate_contract_wrappers", + "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", + "test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html", + "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 --contracts-dir contracts", + "clean": "shx rm -rf lib generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "coverage:report:text": "istanbul report text", + "coverage:report:html": "istanbul report html && open coverage/index.html", + "profiler:report:html": "istanbul report html && open coverage/index.html", + "coverage:report:lcov": "istanbul report lcov", + "test:circleci": "yarn test", + "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" + }, + "config": { + "abis": "generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|DummyERC721Receiver|InvalidERC721Receiver|DummyERC721Token|ReentrantERC20Token|ERC20Token|IERC20Token|MintableERC20Token|UnlimitedAllowanceERC20Token|ERC721Token|IERC721Receiver|IERC721Token|MintableERC721Token|IEtherToken|WETH9|ERC20Token_v1|Token_v1|UnlimitedAllowanceToken_v1|ZRXToken).json" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md", + "devDependencies": { + "@0x/abi-gen": "^1.0.19", + "@0x/contracts-test-utils": "^1.0.2", + "@0x/dev-utils": "^1.0.21", + "@0x/sol-compiler": "^1.1.16", + "@0x/sol-cov": "^2.1.16", + "@0x/subproviders": "^2.1.8", + "@0x/tslint-config": "^2.0.0", + "@types/bn.js": "^4.11.0", + "@types/lodash": "4.14.104", + "@types/node": "*", + "@types/yargs": "^10.0.0", + "chai": "^4.0.1", + "chai-as-promised": "^7.1.0", + "chai-bignumber": "^2.0.1", + "dirty-chai": "^2.0.1", + "ethereumjs-abi": "0.6.5", + "make-promises-safe": "^1.1.0", + "mocha": "^4.1.0", + "npm-run-all": "^4.1.2", + "shx": "^0.2.2", + "solc": "^0.4.24", + "solhint": "^1.4.1", + "tslint": "5.11.0", + "typescript": "3.0.1", + "yargs": "^10.0.3" + }, + "dependencies": { + "@0x/base-contract": "^3.0.10", + "@0x/contracts-interfaces": "^1.0.2", + "@0x/contracts-libs": "^1.0.2", + "@0x/contracts-multisig": "^1.0.2", + "@0x/contracts-utils": "^1.0.2", + "@0x/order-utils": "^3.0.7", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", + "@types/js-combinatorics": "^0.5.29", + "bn.js": "^4.11.8", + "ethereum-types": "^1.1.4", + "ethereumjs-util": "^5.1.1", + "lodash": "^4.17.5" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/contracts/tokens/src/artifacts/index.ts b/contracts/tokens/src/artifacts/index.ts new file mode 100644 index 000000000..63b808748 --- /dev/null +++ b/contracts/tokens/src/artifacts/index.ts @@ -0,0 +1,49 @@ +import { ContractArtifact } from 'ethereum-types'; + +import * as DummyERC20Token from '../../generated-artifacts/DummyERC20Token.json'; +import * as DummyERC721Receiver from '../../generated-artifacts/DummyERC721Receiver.json'; +import * as DummyERC721Token from '../../generated-artifacts/DummyERC721Token.json'; +import * as DummyMultipleReturnERC20Token from '../../generated-artifacts/DummyMultipleReturnERC20Token.json'; +import * as DummyNoReturnERC20Token from '../../generated-artifacts/DummyNoReturnERC20Token.json'; +import * as ERC20Token from '../../generated-artifacts/ERC20Token.json'; +import * as ERC20Token_v1 from '../../generated-artifacts/ERC20Token_v1.json'; +import * as ERC721Token from '../../generated-artifacts/ERC721Token.json'; +import * as IERC20Token from '../../generated-artifacts/IERC20Token.json'; +import * as IERC721Receiver from '../../generated-artifacts/IERC721Receiver.json'; +import * as IERC721Token from '../../generated-artifacts/IERC721Token.json'; +import * as IEtherToken from '../../generated-artifacts/IEtherToken.json'; +import * as InvalidERC721Receiver from '../../generated-artifacts/InvalidERC721Receiver.json'; +import * as MintableERC20Token from '../../generated-artifacts/MintableERC20Token.json'; +import * as MintableERC721Token from '../../generated-artifacts/MintableERC721Token.json'; +import * as ReentrantERC20Token from '../../generated-artifacts/ReentrantERC20Token.json'; +import * as Token_v1 from '../../generated-artifacts/Token_v1.json'; +import * as UnlimitedAllowanceERC20Token from '../../generated-artifacts/UnlimitedAllowanceERC20Token.json'; +import * as UnlimitedAllowanceToken_v1 from '../../generated-artifacts/UnlimitedAllowanceToken_v1.json'; +import * as WETH9 from '../../generated-artifacts/WETH9.json'; +import * as ZRXToken from '../../generated-artifacts/ZRXToken.json'; + +export const artifacts = { + DummyERC20Token: DummyERC20Token as ContractArtifact, + DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, + DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, + DummyERC721Receiver: DummyERC721Receiver as ContractArtifact, + InvalidERC721Receiver: InvalidERC721Receiver as ContractArtifact, + DummyERC721Token: DummyERC721Token as ContractArtifact, + ReentrantERC20Token: ReentrantERC20Token as ContractArtifact, + ERC20Token: ERC20Token as ContractArtifact, + IERC20Token: IERC20Token as ContractArtifact, + MintableERC20Token: MintableERC20Token as ContractArtifact, + UnlimitedAllowanceERC20Token: UnlimitedAllowanceERC20Token as ContractArtifact, + ERC721Token: ERC721Token as ContractArtifact, + IERC721Receiver: IERC721Receiver as ContractArtifact, + IERC721Token: IERC721Token as ContractArtifact, + MintableERC721Token: MintableERC721Token as ContractArtifact, + IEtherToken: IEtherToken as ContractArtifact, + WETH9: WETH9 as ContractArtifact, + ERC20Token_v1: ERC20Token_v1 as ContractArtifact, + Token_v1: Token_v1 as ContractArtifact, + UnlimitedAllowanceToken_v1: UnlimitedAllowanceToken_v1 as ContractArtifact, + // Note(albrow): "as any" hack still required here because ZRXToken does not + // conform to the v2 artifact type. + ZRXToken: (ZRXToken as any) as ContractArtifact, +}; diff --git a/contracts/tokens/src/index.ts b/contracts/tokens/src/index.ts new file mode 100644 index 000000000..91dd7e0e3 --- /dev/null +++ b/contracts/tokens/src/index.ts @@ -0,0 +1,2 @@ +export * from './wrappers'; +export * from './artifacts'; diff --git a/contracts/tokens/src/wrappers/index.ts b/contracts/tokens/src/wrappers/index.ts new file mode 100644 index 000000000..98bf26657 --- /dev/null +++ b/contracts/tokens/src/wrappers/index.ts @@ -0,0 +1,21 @@ +export * from '../../generated-wrappers/zrx_token'; +export * from '../../generated-wrappers/weth9'; +export * from '../../generated-wrappers/unlimitedallowancetoken_v1'; +export * from '../../generated-wrappers/unlimited_allowance_erc20_token'; +export * from '../../generated-wrappers/token_v1'; +export * from '../../generated-wrappers/reentrant_erc20_token'; +export * from '../../generated-wrappers/mintable_erc721_token'; +export * from '../../generated-wrappers/mintable_erc20_token'; +export * from '../../generated-wrappers/invalid_erc721_receiver'; +export * from '../../generated-wrappers/i_ether_token'; +export * from '../../generated-wrappers/i_erc721_token'; +export * from '../../generated-wrappers/i_erc721_receiver'; +export * from '../../generated-wrappers/i_erc20_token'; +export * from '../../generated-wrappers/erc721_token'; +export * from '../../generated-wrappers/erc20token_v1'; +export * from '../../generated-wrappers/erc20_token'; +export * from '../../generated-wrappers/dummy_no_return_erc20_token'; +export * from '../../generated-wrappers/dummy_multiple_return_erc20_token'; +export * from '../../generated-wrappers/dummy_erc721_token'; +export * from '../../generated-wrappers/dummy_erc721_receiver'; +export * from '../../generated-wrappers/dummy_erc20_token'; diff --git a/contracts/core/test/tokens/erc721_token.ts b/contracts/tokens/test/erc721_token.ts index 3b0a5f001..13332cd35 100644 --- a/contracts/core/test/tokens/erc721_token.ts +++ b/contracts/tokens/test/erc721_token.ts @@ -15,15 +15,13 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import { + artifacts, DummyERC721ReceiverContract, DummyERC721ReceiverTokenReceivedEventArgs, -} from '../../generated-wrappers/dummy_erc721_receiver'; -import { DummyERC721TokenContract, DummyERC721TokenTransferEventArgs, -} from '../../generated-wrappers/dummy_erc721_token'; -import { InvalidERC721ReceiverContract } from '../../generated-wrappers/invalid_erc721_receiver'; -import { artifacts } from '../../src/artifacts'; + InvalidERC721ReceiverContract, +} from '../src'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/tokens/test/global_hooks.ts b/contracts/tokens/test/global_hooks.ts new file mode 100644 index 000000000..f8ace376a --- /dev/null +++ b/contracts/tokens/test/global_hooks.ts @@ -0,0 +1,17 @@ +import { env, EnvVars } from '@0x/dev-utils'; + +import { coverage, profiler, provider } from '@0x/contracts-test-utils'; +before('start web3 provider', () => { + provider.start(); +}); +after('generate coverage report', async () => { + if (env.parseBoolean(EnvVars.SolidityCoverage)) { + const coverageSubprovider = coverage.getCoverageSubproviderSingleton(); + await coverageSubprovider.writeCoverageAsync(); + } + if (env.parseBoolean(EnvVars.SolidityProfiler)) { + const profilerSubprovider = profiler.getProfilerSubproviderSingleton(); + await profilerSubprovider.writeProfilerOutputAsync(); + } + provider.stop(); +}); diff --git a/contracts/core/test/tokens/unlimited_allowance_token.ts b/contracts/tokens/test/unlimited_allowance_token.ts index c3e4072c5..6d5a29b23 100644 --- a/contracts/core/test/tokens/unlimited_allowance_token.ts +++ b/contracts/tokens/test/unlimited_allowance_token.ts @@ -11,8 +11,7 @@ import { RevertReason } from '@0x/types'; import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; -import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token'; -import { artifacts } from '../../src/artifacts'; +import { artifacts, DummyERC20TokenContract } from '../src'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/core/test/tokens/weth9.ts b/contracts/tokens/test/weth9.ts index 225481904..6a3948e2c 100644 --- a/contracts/core/test/tokens/weth9.ts +++ b/contracts/tokens/test/weth9.ts @@ -12,8 +12,7 @@ import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; -import { WETH9Contract } from '../../generated-wrappers/weth9'; -import { artifacts } from '../../src/artifacts'; +import { artifacts, WETH9Contract } from '../src'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/core/test/tokens/zrx_token.ts b/contracts/tokens/test/zrx_token.ts index 6bc5e164c..5dc8447f6 100644 --- a/contracts/core/test/tokens/zrx_token.ts +++ b/contracts/tokens/test/zrx_token.ts @@ -4,8 +4,7 @@ import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; -import { ZRXTokenContract } from '../../generated-wrappers/zrx_token'; -import { artifacts } from '../../src/artifacts'; +import { artifacts, ZRXTokenContract } from '../src'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/tokens/tsconfig.json b/contracts/tokens/tsconfig.json new file mode 100644 index 000000000..0d5f98cb8 --- /dev/null +++ b/contracts/tokens/tsconfig.json @@ -0,0 +1,33 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": ".", + "resolveJsonModule": true + }, + "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], + "files": [ + "./generated-artifacts/DummyERC20Token.json", + "./generated-artifacts/DummyMultipleReturnERC20Token.json", + "./generated-artifacts/DummyNoReturnERC20Token.json", + "./generated-artifacts/DummyERC721Receiver.json", + "./generated-artifacts/InvalidERC721Receiver.json", + "./generated-artifacts/DummyERC721Token.json", + "./generated-artifacts/ReentrantERC20Token.json", + "./generated-artifacts/ERC20Token.json", + "./generated-artifacts/IERC20Token.json", + "./generated-artifacts/MintableERC20Token.json", + "./generated-artifacts/UnlimitedAllowanceERC20Token.json", + "./generated-artifacts/ERC721Token.json", + "./generated-artifacts/IERC721Receiver.json", + "./generated-artifacts/IERC721Token.json", + "./generated-artifacts/MintableERC721Token.json", + "./generated-artifacts/IEtherToken.json", + "./generated-artifacts/WETH9.json", + "./generated-artifacts/ERC20Token_v1.json", + "./generated-artifacts/Token_v1.json", + "./generated-artifacts/UnlimitedAllowanceToken_v1.json", + "./generated-artifacts/ZRXToken.json" + ], + "exclude": ["./deploy/solc/solc_bin"] +} diff --git a/contracts/tokens/tslint.json b/contracts/tokens/tslint.json new file mode 100644 index 000000000..1bb3ac2a2 --- /dev/null +++ b/contracts/tokens/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": ["@0x/tslint-config"], + "rules": { + "custom-no-magic-numbers": false + } +} diff --git a/contracts/utils/.solhint.json b/contracts/utils/.solhint.json deleted file mode 100644 index 076afe9f3..000000000 --- a/contracts/utils/.solhint.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "default", - "rules": { - "avoid-low-level-calls": false, - "avoid-tx-origin": "warn", - "bracket-align": false, - "code-complexity": false, - "const-name-snakecase": "error", - "expression-indent": "error", - "function-max-lines": false, - "func-order": "error", - "indent": ["error", 4], - "max-line-length": ["warn", 160], - "no-inline-assembly": false, - "quotes": ["error", "double"], - "separate-by-one-line-in-contract": "error", - "space-after-comma": "error", - "statement-indent": "error" - } -} diff --git a/contracts/utils/CHANGELOG.json b/contracts/utils/CHANGELOG.json new file mode 100644 index 000000000..19ac770af --- /dev/null +++ b/contracts/utils/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "timestamp": 1544741676, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + } +] diff --git a/contracts/utils/CHANGELOG.md b/contracts/utils/CHANGELOG.md new file mode 100644 index 000000000..716353d05 --- /dev/null +++ b/contracts/utils/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _December 13, 2018_ + + * Dependencies updated diff --git a/contracts/utils/package.json b/contracts/utils/package.json index c0bc8bfcf..a776bdfbb 100644 --- a/contracts/utils/package.json +++ b/contracts/utils/package.json @@ -1,7 +1,6 @@ { - "private": true, "name": "@0x/contracts-utils", - "version": "1.0.0", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -19,8 +18,7 @@ "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", "test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html", "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", + "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler --contracts-dir contracts", "clean": "shx rm -rf lib generated-artifacts generated-wrappers", "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers", @@ -30,7 +28,7 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "lint-contracts": "solhint contracts/**/**/**/**/*.sol" + "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { "abis": "generated-artifacts/@(IOwnable|Ownable|LibBytes|ReentrancyGuard|SafeMath|TestConstants|TestLibBytes).json" @@ -45,13 +43,13 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/utils/README.md", "devDependencies": { - "@0x/contracts-test-utils": "^1.0.0", - "@0x/abi-gen": "^1.0.17", - "@0x/dev-utils": "^1.0.19", - "@0x/sol-compiler": "^1.1.14", - "@0x/sol-cov": "^2.1.14", - "@0x/subproviders": "^2.1.6", - "@0x/tslint-config": "^1.0.10", + "@0x/abi-gen": "^1.0.19", + "@0x/contracts-test-utils": "^1.0.2", + "@0x/dev-utils": "^1.0.21", + "@0x/sol-compiler": "^1.1.16", + "@0x/sol-cov": "^2.1.16", + "@0x/subproviders": "^2.1.8", + "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", "@types/node": "*", @@ -61,26 +59,26 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", "dirty-chai": "^2.0.1", - "make-promises-safe": "^1.1.0", "ethereumjs-abi": "0.6.5", + "make-promises-safe": "^1.1.0", "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", "solc": "^0.4.24", - "solhint": "^1.2.1", + "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.8", - "@0x/order-utils": "^3.0.4", - "@0x/contracts-multisig": "^1.0.0", - "@0x/types": "^1.3.0", - "@0x/typescript-typings": "^3.0.4", - "@0x/utils": "^2.0.6", - "@0x/web3-wrapper": "^3.1.6", - "ethereum-types": "^1.1.2", + "@0x/base-contract": "^3.0.10", + "@0x/contracts-multisig": "^1.0.2", + "@0x/order-utils": "^3.0.7", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", + "ethereum-types": "^1.1.4", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5" }, diff --git a/contracts/utils/test/lib_bytes.ts b/contracts/utils/test/lib_bytes.ts index 985a98943..6fb859c67 100644 --- a/contracts/utils/test/lib_bytes.ts +++ b/contracts/utils/test/lib_bytes.ts @@ -25,7 +25,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); // BUG: Ideally we would use Buffer.from(memory).toString('hex') // https://github.com/Microsoft/TypeScript/issues/23155 -const toHex = (buf: Uint8Array): string => buf.reduce((a, v) => a + ('00' + v.toString(16)).slice(-2), '0x'); +const toHex = (buf: Uint8Array): string => buf.reduce((a, v) => a + `00${v.toString(16)}`.slice(-2), '0x'); const fromHex = (str: string): Uint8Array => Uint8Array.from(Buffer.from(str.slice(2), 'hex')); |