diff options
Diffstat (limited to 'contracts')
102 files changed, 754 insertions, 195 deletions
diff --git a/contracts/core/CHANGELOG.json b/contracts/core/CHANGELOG.json index 7dfa06990..371f18cd4 100644 --- a/contracts/core/CHANGELOG.json +++ b/contracts/core/CHANGELOG.json @@ -117,19 +117,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/core/README.md index 0004925c1..8371d8041 100644 --- a/contracts/core/README.md +++ b/contracts/core/README.md @@ -12,10 +12,6 @@ Contracts that make up and interact with version 2.0.0 of the protocol can be fo * 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. diff --git a/contracts/core/compiler.json b/contracts/core/compiler.json index 7e527130a..606208e49 100644 --- a/contracts/core/compiler.json +++ b/contracts/core/compiler.json @@ -20,28 +20,15 @@ }, "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", @@ -49,8 +36,6 @@ "TestStaticCallReceiver", "Validator", "Wallet", - "WETH9", - "Whitelist", - "ZRXToken" + "Whitelist" ] } diff --git a/contracts/core/contracts/examples/ExchangeWrapper/ExchangeWrapper.sol b/contracts/core/contracts/examples/ExchangeWrapper/ExchangeWrapper.sol index ca5a64a26..d98136922 100644 --- a/contracts/core/contracts/examples/ExchangeWrapper/ExchangeWrapper.sol +++ b/contracts/core/contracts/examples/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/core/contracts/examples/Validator/Validator.sol index 72ed528ba..e488a9ca7 100644 --- a/contracts/core/contracts/examples/Validator/Validator.sol +++ b/contracts/core/contracts/examples/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/core/contracts/examples/Wallet/Wallet.sol index 3738be841..8edc74eb3 100644 --- a/contracts/core/contracts/examples/Wallet/Wallet.sol +++ b/contracts/core/contracts/examples/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/core/contracts/examples/Whitelist/Whitelist.sol index cfcddddd3..2a3d33738 100644 --- a/contracts/core/contracts/examples/Whitelist/Whitelist.sol +++ b/contracts/core/contracts/examples/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/core/contracts/extensions/DutchAuction/DutchAuction.sol b/contracts/core/contracts/extensions/DutchAuction/DutchAuction.sol index a40991ae7..9c9f3990a 100644 --- a/contracts/core/contracts/extensions/DutchAuction/DutchAuction.sol +++ b/contracts/core/contracts/extensions/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/MixinAssets.sol b/contracts/core/contracts/extensions/Forwarder/MixinAssets.sol index 5f5f3456d..3ebf75161 100644 --- a/contracts/core/contracts/extensions/Forwarder/MixinAssets.sol +++ b/contracts/core/contracts/extensions/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/libs/LibConstants.sol b/contracts/core/contracts/extensions/Forwarder/libs/LibConstants.sol index 0f98ae595..4a81abf76 100644 --- a/contracts/core/contracts/extensions/Forwarder/libs/LibConstants.sol +++ b/contracts/core/contracts/extensions/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/OrderValidator/OrderValidator.sol b/contracts/core/contracts/extensions/OrderValidator/OrderValidator.sol index 9e9e63e9b..33dd1326c 100644 --- a/contracts/core/contracts/extensions/OrderValidator/OrderValidator.sol +++ b/contracts/core/contracts/extensions/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/protocol/AssetProxy/mixins/MAuthorizable.sol b/contracts/core/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol index d63fb7f6d..fe77048ce 100644 --- a/contracts/core/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol +++ b/contracts/core/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/Exchange/MixinAssetProxyDispatcher.sol b/contracts/core/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol index 02aeb4a13..36ab39b45 100644 --- a/contracts/core/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol +++ b/contracts/core/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/MixinSignatureValidator.sol b/contracts/core/contracts/protocol/Exchange/MixinSignatureValidator.sol index 711535aa8..80b4c0755 100644 --- a/contracts/core/contracts/protocol/Exchange/MixinSignatureValidator.sol +++ b/contracts/core/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/mixins/MAssetProxyDispatcher.sol b/contracts/core/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol index 0ddfca270..fe3d03326 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol +++ b/contracts/core/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/core/contracts/protocol/Exchange/mixins/MExchangeCore.sol index 099bdcc33..215284900 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MExchangeCore.sol +++ b/contracts/core/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/core/contracts/protocol/Exchange/mixins/MMatchOrders.sol index bb285de03..1eb4be329 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MMatchOrders.sol +++ b/contracts/core/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/core/contracts/protocol/Exchange/mixins/MSignatureValidator.sol index 1fe88b908..a933976d1 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MSignatureValidator.sol +++ b/contracts/core/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/core/contracts/protocol/Exchange/mixins/MTransactions.sol index 4f61a4945..a6b0fdc85 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MTransactions.sol +++ b/contracts/core/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/core/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol index 2d21bf057..101e7cb82 100644 --- a/contracts/core/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol +++ b/contracts/core/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/test/TestStaticCallReceiver/TestStaticCallReceiver.sol b/contracts/core/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol index 41aab01c8..d08da7303 100644 --- a/contracts/core/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol +++ b/contracts/core/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/core/package.json index 43fa9370e..fd844ae16 100644 --- a/contracts/core/package.json +++ b/contracts/core/package.json @@ -33,7 +33,7 @@ "lint-contracts": "solhint 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|DutchAuction|ERC20Proxy|ERC721Proxy|Forwarder|Exchange|ExchangeWrapper|MixinAuthorizable|MultiAssetProxy|OrderValidator|TestAssetProxyOwner|TestAssetProxyDispatcher|TestExchangeInternals|TestSignatureValidator|TestStaticCallReceiver|Validator|Wallet|Whitelist).json" }, "repository": { "type": "git", @@ -76,7 +76,9 @@ "@0x/order-utils": "^3.0.4", "@0x/contracts-multisig": "^1.0.0", "@0x/contracts-utils": "^1.0.0", + "@0x/contracts-tokens": "^1.0.0", "@0x/contracts-libs": "^1.0.0", + "@0x/contracts-interfaces": "^1.0.0", "@0x/types": "^1.3.0", "@0x/typescript-typings": "^3.0.4", "@0x/utils": "^2.0.6", diff --git a/contracts/core/src/artifacts/index.ts b/contracts/core/src/artifacts/index.ts index d578c36fe..ac334c173 100644 --- a/contracts/core/src/artifacts/index.ts +++ b/contracts/core/src/artifacts/index.ts @@ -1,28 +1,15 @@ 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'; @@ -30,44 +17,25 @@ import * as TestSignatureValidator from '../../generated-artifacts/TestSignature 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/index.ts b/contracts/core/src/index.ts new file mode 100644 index 000000000..d55f08ea2 --- /dev/null +++ b/contracts/core/src/index.ts @@ -0,0 +1,2 @@ +export * from './artifacts'; +export * from './wrappers'; diff --git a/contracts/core/src/wrappers/index.ts b/contracts/core/src/wrappers/index.ts index ed9d8ef47..ff26a171e 100644 --- a/contracts/core/src/wrappers/index.ts +++ b/contracts/core/src/wrappers/index.ts @@ -1,23 +1,12 @@ 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'; @@ -25,6 +14,4 @@ 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/asset_proxy/proxies.ts b/contracts/core/test/asset_proxy/proxies.ts index 2527b0fbf..c4bd95905 100644 --- a/contracts/core/test/asset_proxy/proxies.ts +++ b/contracts/core/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/core/test/exchange/core.ts index fd6b9ee6b..9b948f991 100644 --- a/contracts/core/test/exchange/core.ts +++ b/contracts/core/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/core/test/exchange/dispatcher.ts index 9bc5cbcce..5b1ac1e20 100644 --- a/contracts/core/test/exchange/dispatcher.ts +++ b/contracts/core/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/match_orders.ts b/contracts/core/test/exchange/match_orders.ts index 0e841b359..8e943c237 100644 --- a/contracts/core/test/exchange/match_orders.ts +++ b/contracts/core/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/exchange/signature_validator.ts b/contracts/core/test/exchange/signature_validator.ts index b84a488a1..a968570b6 100644 --- a/contracts/core/test/exchange/signature_validator.ts +++ b/contracts/core/test/exchange/signature_validator.ts @@ -9,6 +9,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 +18,13 @@ 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, + ValidatorContract, + WalletContract, +} from '../../src'; chaiSetup.configure(); const expect = chai.expect; @@ -77,7 +78,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 +136,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 +149,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 +162,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/core/test/exchange/transactions.ts index c4086d9be..ad0ca41c2 100644 --- a/contracts/core/test/exchange/transactions.ts +++ b/contracts/core/test/exchange/transactions.ts @@ -11,6 +11,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,7 +19,6 @@ 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'; diff --git a/contracts/core/test/exchange/wrapper.ts b/contracts/core/test/exchange/wrapper.ts index 17cb7a3bb..c9efb0c9d 100644 --- a/contracts/core/test/exchange/wrapper.ts +++ b/contracts/core/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/core/test/extensions/dutch_auction.ts b/contracts/core/test/extensions/dutch_auction.ts index 54e6092d7..b396d4206 100644 --- a/contracts/core/test/extensions/dutch_auction.ts +++ b/contracts/core/test/extensions/dutch_auction.ts @@ -10,6 +10,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,11 +26,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'; @@ -98,7 +101,7 @@ 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); diff --git a/contracts/core/test/extensions/forwarder.ts b/contracts/core/test/extensions/forwarder.ts index 44ad4d6ff..ffa015dd2 100644 --- a/contracts/core/test/extensions/forwarder.ts +++ b/contracts/core/test/extensions/forwarder.ts @@ -11,6 +11,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,11 +25,8 @@ 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'; @@ -94,7 +97,7 @@ 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); diff --git a/contracts/core/test/extensions/order_validator.ts b/contracts/core/test/extensions/order_validator.ts index 3dbe76f6e..622710c98 100644 --- a/contracts/core/test/extensions/order_validator.ts +++ b/contracts/core/test/extensions/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,8 +15,6 @@ 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'; diff --git a/contracts/core/test/utils/asset_proxy_owner_wrapper.ts b/contracts/core/test/utils/asset_proxy_owner_wrapper.ts index d5aaaf519..df23658d8 100644 --- a/contracts/core/test/utils/asset_proxy_owner_wrapper.ts +++ b/contracts/core/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/erc20_wrapper.ts b/contracts/core/test/utils/erc20_wrapper.ts index d6210646c..e5ab0e36c 100644 --- a/contracts/core/test/utils/erc20_wrapper.ts +++ b/contracts/core/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/core/test/utils/erc721_wrapper.ts index b5ae34e60..1f658ce86 100644 --- a/contracts/core/test/utils/erc721_wrapper.ts +++ b/contracts/core/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/core/test/utils/exchange_wrapper.ts index 2a24b880f..cb6dce901 100644 --- a/contracts/core/test/utils/exchange_wrapper.ts +++ b/contracts/core/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/forwarder_wrapper.ts b/contracts/core/test/utils/forwarder_wrapper.ts index 9c5560381..4c78ecd79 100644 --- a/contracts/core/test/utils/forwarder_wrapper.ts +++ b/contracts/core/test/utils/forwarder_wrapper.ts @@ -1,4 +1,5 @@ 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 +59,7 @@ 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 }); } public async marketSellOrdersWithEthAsync( orders: SignedOrder[], diff --git a/contracts/core/test/utils/order_factory_from_scenario.ts b/contracts/core/test/utils/order_factory_from_scenario.ts index 1cc962020..ecb4b2e28 100644 --- a/contracts/core/test/utils/order_factory_from_scenario.ts +++ b/contracts/core/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/tsconfig.json b/contracts/core/tsconfig.json index f2f3c4e97..ea493cbb8 100644 --- a/contracts/core/tsconfig.json +++ b/contracts/core/tsconfig.json @@ -8,38 +8,23 @@ "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" + "./generated-artifacts/Whitelist.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/interfaces/.solhint.json b/contracts/interfaces/.solhint.json new file mode 100644 index 000000000..076afe9f3 --- /dev/null +++ b/contracts/interfaces/.solhint.json @@ -0,0 +1,20 @@ +{ + "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/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..b79ae20ff --- /dev/null +++ b/contracts/interfaces/package.json @@ -0,0 +1,57 @@ +{ + "private": true, + "name": "@0x/contracts-interfaces", + "version": "1.0.0", + "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 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.17", + "@0x/sol-compiler": "^1.1.14", + "@0x/tslint-config": "^1.0.10", + "npm-run-all": "^4.1.2", + "shx": "^0.2.2", + "solhint": "^1.2.1", + "tslint": "5.11.0", + "typescript": "3.0.1", + "yargs": "^10.0.3" + }, + "dependencies": { + "@0x/base-contract": "^3.0.8", + "@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", + "ethereum-types": "^1.1.2", + "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/test-utils/src/assertions.ts b/contracts/test-utils/src/assertions.ts index 5b1cedfcc..b1dec1281 100644 --- a/contracts/test-utils/src/assertions.ts +++ b/contracts/test-utils/src/assertions.ts @@ -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/tokens/.solhint.json b/contracts/tokens/.solhint.json new file mode 100644 index 000000000..076afe9f3 --- /dev/null +++ b/contracts/tokens/.solhint.json @@ -0,0 +1,20 @@ +{ + "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/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..5ff58c035 --- /dev/null +++ b/contracts/tokens/CHANGELOG.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..0666ea89a --- /dev/null +++ b/contracts/tokens/package.json @@ -0,0 +1,94 @@ +{ + "private": true, + "name": "@0x/contracts-tokens", + "version": "1.0.0", + "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 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/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", + "@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", + "make-promises-safe": "^1.1.0", + "ethereumjs-abi": "0.6.5", + "mocha": "^4.1.0", + "npm-run-all": "^4.1.2", + "shx": "^0.2.2", + "solc": "^0.4.24", + "solhint": "^1.2.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/contracts-interfaces": "^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", + "@types/js-combinatorics": "^0.5.29", + "bn.js": "^4.11.8", + "ethereum-types": "^1.1.2", + "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/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')); |