Update Interfaces for IValidator and IWallet

This commit is contained in:
Jacob Evans
2019-08-19 11:08:06 +10:00
parent d3cdd3f235
commit bddfdacfad
6 changed files with 27 additions and 19 deletions

View File

@@ -21,7 +21,7 @@ pragma solidity ^0.5.5;
import "../src/interfaces/IValidator.sol";
contract Validator is
contract Validator is
IValidator
{
@@ -48,9 +48,11 @@ contract Validator is
)
external
view
returns (bool isValid)
returns (bytes4)
{
return (signerAddress == VALID_SIGNER);
require(signerAddress == VALID_SIGNER, "INVALID_SIGNER");
bytes4 magic_salt = bytes4(keccak256("isValidValidatorSignature(address,bytes32,address,bytes)"));
return magic_salt;
}
// solhint-enable no-unused-vars
}

View File

@@ -22,7 +22,7 @@ import "../src/interfaces/IWallet.sol";
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
contract Wallet is
contract Wallet is
IWallet
{
using LibBytes for bytes;
@@ -48,7 +48,7 @@ contract Wallet is
)
external
view
returns (bool isValid)
returns (bytes4)
{
require(
eip712Signature.length == 65,
@@ -59,7 +59,8 @@ contract Wallet is
bytes32 r = eip712Signature.readBytes32(1);
bytes32 s = eip712Signature.readBytes32(33);
address recoveredAddress = ecrecover(hash, v, r, s);
isValid = WALLET_OWNER == recoveredAddress;
return isValid;
require(WALLET_OWNER == recoveredAddress, "INVALID_SIGNATURE");
bytes4 magic_salt = bytes4(keccak256("isValidWalletSignature(bytes32,address,bytes)"));
return magic_salt;
}
}

View File

@@ -25,7 +25,8 @@ contract IValidator {
/// @param hash Message hash that is signed.
/// @param signerAddress Address that should have signed the given hash.
/// @param signature Proof of signing.
/// @return Validity of order signature.
/// @return Magic bytes4 value if the signature is valid.
/// Magic value is bytes4(keccak256("isValidValidatorSignature(address,bytes32,address,bytes)"))
function isValidSignature(
bytes32 hash,
address signerAddress,
@@ -33,5 +34,5 @@ contract IValidator {
)
external
view
returns (bool isValid);
returns (bytes4 isValid);
}

View File

@@ -24,12 +24,13 @@ contract IWallet {
/// @dev Verifies that a signature is valid.
/// @param hash Message hash that is signed.
/// @param signature Proof of signing.
/// @return Validity of order signature.
/// @return Magic bytes4 value if the signature is valid.
/// Magic value is bytes4(keccak256("isValidWalletSignature(bytes32,address,bytes)"))
function isValidSignature(
bytes32 hash,
bytes calldata signature
)
external
view
returns (bool isValid);
returns (bytes4 isValid);
}

View File

@@ -6,12 +6,12 @@
{
"constant": true,
"inputs": [
{ "name": "hash", "type": "bytes32" },
{ "name": "signerAddress", "type": "address" },
{ "name": "signature", "type": "bytes" }
{ "internalType": "bytes32", "name": "hash", "type": "bytes32" },
{ "internalType": "address", "name": "signerAddress", "type": "address" },
{ "internalType": "bytes", "name": "signature", "type": "bytes" }
],
"name": "isValidSignature",
"outputs": [{ "name": "isValid", "type": "bool" }],
"outputs": [{ "internalType": "bytes4", "name": "isValid", "type": "bytes4" }],
"payable": false,
"stateMutability": "view",
"type": "function"
@@ -26,7 +26,7 @@
"signature": "Proof of signing.",
"signerAddress": "Address that should have signed the given hash."
},
"return": "Validity of order signature."
"return": "Magic bytes4 value if the signature is valid. Magic value is bytes4(keccak256(\"isValidValidatorSignature(address,bytes32,address,bytes)\"))"
}
}
},

View File

@@ -5,9 +5,12 @@
"abi": [
{
"constant": true,
"inputs": [{ "name": "hash", "type": "bytes32" }, { "name": "signature", "type": "bytes" }],
"inputs": [
{ "internalType": "bytes32", "name": "hash", "type": "bytes32" },
{ "internalType": "bytes", "name": "signature", "type": "bytes" }
],
"name": "isValidSignature",
"outputs": [{ "name": "isValid", "type": "bool" }],
"outputs": [{ "internalType": "bytes4", "name": "isValid", "type": "bytes4" }],
"payable": false,
"stateMutability": "view",
"type": "function"
@@ -18,7 +21,7 @@
"isValidSignature(bytes32,bytes)": {
"details": "Verifies that a signature is valid.",
"params": { "hash": "Message hash that is signed.", "signature": "Proof of signing." },
"return": "Validity of order signature."
"return": "Magic bytes4 value if the signature is valid. Magic value is bytes4(keccak256(\"isValidWalletSignature(bytes32,address,bytes)\"))"
}
}
},