aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-07-23 23:00:06 +0800
committerGitHub <noreply@github.com>2018-07-23 23:00:06 +0800
commit554b18a466d5cc65271daa61aba96138ce7408f0 (patch)
tree75976e979b713fb47c9462f1a3bc30a184cc568c /packages/contracts/src/2.0.0
parent855b6b1dc5597f360451232ff6dfc91beb3a9f50 (diff)
parentc2ae9f62a41466c714a5e2232782d08261464b9c (diff)
downloaddexon-sol-tools-554b18a466d5cc65271daa61aba96138ce7408f0.tar.gz
dexon-sol-tools-554b18a466d5cc65271daa61aba96138ce7408f0.tar.zst
dexon-sol-tools-554b18a466d5cc65271daa61aba96138ce7408f0.zip
Merge pull request #906 from 0xProject/refactor/contracts/examples
[contracts] Add `examples` directory
Diffstat (limited to 'packages/contracts/src/2.0.0')
-rw-r--r--packages/contracts/src/2.0.0/examples/ExchangeWrapper/ExchangeWrapper.sol (renamed from packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol)0
-rw-r--r--packages/contracts/src/2.0.0/examples/Validator/Validator.sol (renamed from packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol)4
-rw-r--r--packages/contracts/src/2.0.0/examples/Wallet/Wallet.sol (renamed from packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol)4
-rw-r--r--packages/contracts/src/2.0.0/examples/Whitelist/Whitelist.sol (renamed from packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol)0
-rw-r--r--packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol4
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol13
-rw-r--r--packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol5
-rw-r--r--packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol4
-rw-r--r--packages/contracts/src/2.0.0/test/TestConstants/TestConstants.sol57
9 files changed, 83 insertions, 8 deletions
diff --git a/packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol b/packages/contracts/src/2.0.0/examples/ExchangeWrapper/ExchangeWrapper.sol
index 2fa0e3c5e..2fa0e3c5e 100644
--- a/packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol
+++ b/packages/contracts/src/2.0.0/examples/ExchangeWrapper/ExchangeWrapper.sol
diff --git a/packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol b/packages/contracts/src/2.0.0/examples/Validator/Validator.sol
index 6278aede0..72ed528ba 100644
--- a/packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol
+++ b/packages/contracts/src/2.0.0/examples/Validator/Validator.sol
@@ -21,7 +21,7 @@ pragma solidity 0.4.24;
import "../../protocol/Exchange/interfaces/IValidator.sol";
-contract TestValidator is
+contract Validator is
IValidator
{
@@ -29,7 +29,7 @@ contract TestValidator is
// solhint-disable-next-line var-name-mixedcase
address internal VALID_SIGNER;
- /// @dev constructs a new `TestValidator` with a single valid signer.
+ /// @dev constructs a new `Validator` with a single valid signer.
/// @param validSigner The sole, valid signer.
constructor (address validSigner) public {
VALID_SIGNER = validSigner;
diff --git a/packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol b/packages/contracts/src/2.0.0/examples/Wallet/Wallet.sol
index 0415823e3..b75021a31 100644
--- a/packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol
+++ b/packages/contracts/src/2.0.0/examples/Wallet/Wallet.sol
@@ -22,7 +22,7 @@ import "../../protocol/Exchange/interfaces/IWallet.sol";
import "../../utils/LibBytes/LibBytes.sol";
-contract TestWallet is
+contract Wallet is
IWallet
{
using LibBytes for bytes;
@@ -31,7 +31,7 @@ contract TestWallet is
// solhint-disable-next-line var-name-mixedcase
address internal WALLET_OWNER;
- /// @dev constructs a new `TestWallet` with a single owner.
+ /// @dev constructs a new `Wallet` with a single owner.
/// @param walletOwner The owner of this wallet.
constructor (address walletOwner) public {
WALLET_OWNER = walletOwner;
diff --git a/packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol b/packages/contracts/src/2.0.0/examples/Whitelist/Whitelist.sol
index 60cac26ea..60cac26ea 100644
--- a/packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol
+++ b/packages/contracts/src/2.0.0/examples/Whitelist/Whitelist.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol
index 53f5a14e0..6a70c9f60 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol
+++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol
@@ -93,7 +93,7 @@ contract ERC721Proxy is
// | | 4 | 12 + 20 | 1. token address |
// | | 36 | | 2. tokenId |
- // We construct calldata for the `token.safeTransferFrom` ABI.
+ // We construct calldata for the `token.transferFrom` ABI.
// The layout of this calldata is in the table below.
//
// | Area | Offset | Length | Contents |
@@ -116,7 +116,7 @@ contract ERC721Proxy is
}
/////// Setup Header Area ///////
- // This area holds the 4-byte `transferFromSelector`.
+ // This area holds the 4-byte `transferFrom` selector.
// Any trailing data in transferFromSelector will be
// overwritten in the next `mstore` call.
mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol
index 6918d755e..8d2732cd3 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol
@@ -19,11 +19,23 @@
pragma solidity 0.4.24;
+// solhint-disable max-line-length
contract LibConstants {
// Asset data for ZRX token. Used for fee transfers.
// @TODO: Hardcode constant when we deploy. Currently
// not constant to make testing easier.
+
+ // The proxyId for ZRX_ASSET_DATA is bytes4(keccak256("ERC20Token(address)")) = 0xf47261b0
+
+ // Kovan ZRX address is 0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570.
+ // The ABI encoded proxyId and address is 0xf47261b00000000000000000000000006ff6c0ff1d68b964901f986d4c9fa3ac68346570
+ // bytes constant public ZRX_ASSET_DATA = "\xf4\x72\x61\xb0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6f\xf6\xc0\xff\x1d\x68\xb9\x64\x90\x1f\x98\x6d\x4c\x9f\xa3\xac\x68\x34\x65\x70";
+
+ // Mainnet ZRX address is 0xe41d2489571d322189246dafa5ebde1f4699f498.
+ // The ABI encoded proxyId and address is 0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498
+ // bytes constant public ZRX_ASSET_DATA = "\xf4\x72\x61\xb0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe4\x1d\x24\x89\x57\x1d\x32\x21\x89\x24\x6d\xaf\xa5\xeb\xde\x1f\x46\x99\xf4\x98";
+
// solhint-disable-next-line var-name-mixedcase
bytes public ZRX_ASSET_DATA;
@@ -34,3 +46,4 @@ contract LibConstants {
ZRX_ASSET_DATA = zrxAssetData;
}
}
+// solhint-enable max-line-length
diff --git a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol b/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol
index 97801166a..9272b18a8 100644
--- a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol
+++ b/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol
@@ -22,7 +22,10 @@ import "../Mintable/Mintable.sol";
import "../../utils/Ownable/Ownable.sol";
-contract DummyERC20Token is Mintable, Ownable {
+contract DummyERC20Token is
+ Mintable,
+ Ownable
+{
string public name;
string public symbol;
uint256 public decimals;
diff --git a/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol
index 07986f4bb..ad71fc9a1 100644
--- a/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol
+++ b/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol
@@ -21,7 +21,9 @@ pragma solidity 0.4.24;
import "../../protocol/Exchange/MixinAssetProxyDispatcher.sol";
-contract TestAssetProxyDispatcher is MixinAssetProxyDispatcher {
+contract TestAssetProxyDispatcher is
+ MixinAssetProxyDispatcher
+{
function publicDispatchTransferFrom(
bytes memory assetData,
address from,
diff --git a/packages/contracts/src/2.0.0/test/TestConstants/TestConstants.sol b/packages/contracts/src/2.0.0/test/TestConstants/TestConstants.sol
new file mode 100644
index 000000000..1275d007b
--- /dev/null
+++ b/packages/contracts/src/2.0.0/test/TestConstants/TestConstants.sol
@@ -0,0 +1,57 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity 0.4.24;
+
+import "../../utils/LibBytes/LibBytes.sol";
+
+
+// solhint-disable max-line-length
+contract TestConstants {
+
+ using LibBytes for bytes;
+
+ bytes4 constant internal ERC20_PROXY_ID = bytes4(keccak256("ERC20Token(address)"));
+
+ address constant internal KOVAN_ZRX_ADDRESS = 0x6Ff6C0Ff1d68b964901F986d4C9FA3ac68346570;
+ bytes constant internal KOVAN_ZRX_ASSET_DATA = "\xf4\x72\x61\xb0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6f\xf6\xc0\xff\x1d\x68\xb9\x64\x90\x1f\x98\x6d\x4c\x9f\xa3\xac\x68\x34\x65\x70";
+
+ address constant internal MAINNET_ZRX_ADDRESS = 0xE41d2489571d322189246DaFA5ebDe1F4699F498;
+ bytes constant public MAINNET_ZRX_ASSET_DATA = "\xf4\x72\x61\xb0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe4\x1d\x24\x89\x57\x1d\x32\x21\x89\x24\x6d\xaf\xa5\xeb\xde\x1f\x46\x99\xf4\x98";
+
+ function assertValidZrxAssetData()
+ public
+ pure
+ returns (bool)
+ {
+ bytes memory kovanZrxAssetData = abi.encodeWithSelector(ERC20_PROXY_ID, KOVAN_ZRX_ADDRESS);
+ require(
+ kovanZrxAssetData.equals(KOVAN_ZRX_ASSET_DATA),
+ "INVALID_KOVAN_ZRX_ASSET_DATA"
+ );
+
+ bytes memory mainetZrxAssetData = abi.encodeWithSelector(ERC20_PROXY_ID, MAINNET_ZRX_ADDRESS);
+ require(
+ mainetZrxAssetData.equals(MAINNET_ZRX_ASSET_DATA),
+ "INVALID_MAINNET_ZRX_ASSET_DATA"
+ );
+
+ return true;
+ }
+}
+// solhint-enable max-line-length \ No newline at end of file