aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts')
-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
}