aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-05-21 11:33:41 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-05-31 08:11:30 +0800
commit0789c6a3d893eb1b1d9636a2d10e8d495b0aa13b (patch)
treee0e313944970c18c90b23865aba73099edb272e0 /packages/contracts/src
parentb587f076fe02a21274c91d35b6a18a7ba86e3b58 (diff)
downloaddexon-0x-contracts-0789c6a3d893eb1b1d9636a2d10e8d495b0aa13b.tar.gz
dexon-0x-contracts-0789c6a3d893eb1b1d9636a2d10e8d495b0aa13b.tar.zst
dexon-0x-contracts-0789c6a3d893eb1b1d9636a2d10e8d495b0aa13b.zip
Add approveValidator function
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol17
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol2
2 files changed, 17 insertions, 2 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol
index 2a54da90f..76de961bc 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol
@@ -33,6 +33,9 @@ contract MixinSignatureValidator is
// Mapping of hash => signer => signed
mapping(bytes32 => mapping(address => bool)) preSigned;
+ // Mapping of signer => validator => approved
+ mapping(address => mapping (address => bool)) allowedValidators;
+
/// @dev Approves a hash on-chain using any valid signature type.
/// After presigning a hash, the preSign signature type will become valid for that hash and signer.
/// @param signer Address that should have signed the given hash.
@@ -50,6 +53,15 @@ contract MixinSignatureValidator is
preSigned[hash][signer] = true;
}
+ /// @dev Approves a Validator contract to verify signatures on signer's behalf.
+ /// @param validator Address of Validator contract.
+ /// @param approval Approval or disapproval of Validator contract.
+ function approveSignatureValidator(address validator, bool approval)
+ external
+ {
+ allowedValidators[msg.sender][validator] = approval;
+ }
+
/// @dev Verifies that a hash has been signed by the given signer.
/// @param hash Any 32 byte hash.
/// @param signer Address that should have signed the given hash.
@@ -172,7 +184,7 @@ contract MixinSignatureValidator is
// Signature verified by signer contract.
// If used with an order, the maker of the order is the signer contract.
- } else if (signatureType == SignatureType.Contract) {
+ } else if (signatureType == SignatureType.Signer) {
// Pass in signature without signature type.
bytes memory signatureWithoutType = deepCopyBytes(
signature,
@@ -191,6 +203,9 @@ contract MixinSignatureValidator is
// | 0x15 | ** | Signature to validate |
} else if (signatureType == SignatureType.Validator) {
address validator = readAddress(signature, 1);
+ if (!allowedValidators[signer][validator]) {
+ return false;
+ }
// Pass in signature without type or validator address.
bytes memory signatureWithoutTypeOrAddress = deepCopyBytes(
signature,
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol
index 083fa89d7..33424ff84 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol
@@ -31,7 +31,7 @@ contract MSignatureValidator is
Ecrecover,
EIP712,
Trezor,
- Contract,
+ Signer,
Validator,
PreSigned
}