aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol')
-rw-r--r--packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol47
1 files changed, 36 insertions, 11 deletions
diff --git a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
index c53856602..4a2e9a931 100644
--- a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
+++ b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
@@ -23,22 +23,30 @@ import "../../protocol/Exchange/interfaces/IExchange.sol";
import "../../protocol/Exchange/libs/LibOrder.sol";
import "../../utils/Ownable/Ownable.sol";
-contract Whitelist is Ownable {
+contract Whitelist is
+ Ownable
+{
+ // Revert reasons
+ string constant ADDRESS_NOT_WHITELISTED = "Address not whitelisted.";
+ // Mapping of address => whitelist status.
mapping (address => bool) public isWhitelisted;
+
+ // Exchange contract.
IExchange EXCHANGE;
- bytes txOriginSignature = new bytes(1);
- bytes4 fillOrderFunctionSelector;
+ // TxOrigin signature type is the 5th value in enum SignatureType and has a length of 1.
+ bytes constant TX_ORIGIN_SIGNATURE = "\x04";
- function Whitelist(address _exchange)
+ constructor (address _exchange)
public
{
EXCHANGE = IExchange(_exchange);
- txOriginSignature[0] = 0x04;
- fillOrderFunctionSelector = EXCHANGE.fillOrder.selector;
}
+ /// @dev Adds or removes an address from the whitelist.
+ /// @param target Address to add or remove from whitelist.
+ /// @param isApproved Whitelist status to assign to address.
function updateWhitelistStatus(address target, bool isApproved)
external
onlyOwner
@@ -46,6 +54,14 @@ contract Whitelist is Ownable {
isWhitelisted[target] = isApproved;
}
+ /// @dev Fills an order using `msg.sender` as the taker.
+ /// The transaction will revert if both the maker and taker are not whitelisted.
+ /// Orders should specify this contract as the `senderAddress` in order to gaurantee
+ /// that both maker and taker have been whitelisted.
+ /// @param order Order struct containing order specifications.
+ /// @param takerAssetFillAmount Desired amount of takerAsset to sell.
+ /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash.
+ /// @param orderSignature Proof that order has been created by maker.
function fillOrderIfWhitelisted(
LibOrder.Order memory order,
uint256 takerAssetFillAmount,
@@ -58,23 +74,32 @@ contract Whitelist is Ownable {
// This contract must be the entry point for the transaction.
require(takerAddress == tx.origin);
- // Check if sender is on the whitelist.
- require(isWhitelisted[takerAddress]);
+ // Check if maker is on the whitelist
+ require(
+ isWhitelisted[order.makerAddress],
+ ADDRESS_NOT_WHITELISTED
+ );
+
+ // Check if taker is on the whitelist.
+ require(
+ isWhitelisted[takerAddress],
+ ADDRESS_NOT_WHITELISTED
+ );
// Encode arguments into byte array.
bytes memory data = abi.encodeWithSelector(
- fillOrderFunctionSelector,
+ EXCHANGE.fillOrder.selector,
order,
takerAssetFillAmount,
orderSignature
);
- // Call `fillOrder`via `executeTransaction`.
+ // Call `fillOrder` via `executeTransaction`.
EXCHANGE.executeTransaction(
salt,
takerAddress,
data,
- txOriginSignature
+ TX_ORIGIN_SIGNATURE
);
}
} \ No newline at end of file