aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-04-27 03:10:04 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-05-31 08:11:30 +0800
commit87d36f06fd7116afb62b65cdbc013d93a61d1969 (patch)
tree22f0fba1ebaf14422dde241d03e058031ea58b12 /packages/contracts
parent3eb05b45053748f227bc984458580a33596800d1 (diff)
downloaddexon-sol-tools-87d36f06fd7116afb62b65cdbc013d93a61d1969.tar
dexon-sol-tools-87d36f06fd7116afb62b65cdbc013d93a61d1969.tar.gz
dexon-sol-tools-87d36f06fd7116afb62b65cdbc013d93a61d1969.tar.bz2
dexon-sol-tools-87d36f06fd7116afb62b65cdbc013d93a61d1969.tar.lz
dexon-sol-tools-87d36f06fd7116afb62b65cdbc013d93a61d1969.tar.xz
dexon-sol-tools-87d36f06fd7116afb62b65cdbc013d93a61d1969.tar.zst
dexon-sol-tools-87d36f06fd7116afb62b65cdbc013d93a61d1969.zip
Add sample whitelist contract
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/compiler.json1
-rw-r--r--packages/contracts/package.json2
-rw-r--r--packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol58
3 files changed, 60 insertions, 1 deletions
diff --git a/packages/contracts/compiler.json b/packages/contracts/compiler.json
index 7d469d2c3..ed59069fe 100644
--- a/packages/contracts/compiler.json
+++ b/packages/contracts/compiler.json
@@ -33,6 +33,7 @@
"TestLibs",
"TestSignatureValidator",
"TokenRegistry",
+ "Whitelist",
"WETH9",
"ZRXToken"
]
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 037cb7a04..7bd0cf571 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -29,7 +29,7 @@
"test:circleci": "yarn test"
},
"config": {
- "abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock||TestAssetProxyDispatcher|TestLibBytes|TestLibs|TestSignatureValidator|TokenRegistry|WETH9|ZRXToken).json"
+ "abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyDispatcher|TestLibBytes|TestLibs|TestSignatureValidator|TokenRegistry|Whitelist|WETH9|ZRXToken).json"
},
"repository": {
"type": "git",
diff --git a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
new file mode 100644
index 000000000..02158485e
--- /dev/null
+++ b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
@@ -0,0 +1,58 @@
+/*
+
+ 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.21;
+pragma experimental ABIEncoderV2;
+
+import "../../protocol/Exchange/mixins/MTransactions.sol";
+import "../../protocol/Exchange/LibOrder.sol";
+import "../../utils/Ownable/Ownable.sol";
+
+contract Whitelist is Ownable {
+
+ mapping (address => bool) public isWhitelisted;
+ MTransactions EXCHANGE;
+
+ bytes txOriginSignatureType = new bytes(1);
+
+ function Whitelist(address _exchange)
+ public
+ {
+ EXCHANGE = MTransactions(_exchange);
+ txOriginSignatureType[0] = 0x04;
+ }
+
+ function updateWhitelistStatus(address target, bool isApproved)
+ external
+ onlyOwner
+ {
+ isWhitelisted[target] = isApproved;
+ }
+
+ function fillOrderIfWhitelisted(
+ LibOrder.Order memory order,
+ uint256 takerAssetFillAmount,
+ uint256 salt,
+ bytes memory signature)
+ public
+ {
+ require(isWhitelisted[msg.sender]);
+ bytes memory data = abi.encode(order, takerAssetFillAmount, signature);
+ EXCHANGE.executeTransaction(salt, msg.sender, data, txOriginSignatureType);
+ }
+} \ No newline at end of file