@@ -62,14 +62,30 @@ contract SignedAllowance {
6262 uint256 nonce ,
6363 bytes memory signature
6464 ) public view returns (bytes32 ) {
65+ return
66+ _validateSignature (account, nonce, signature, allowancesSigner ());
67+ }
68+
69+ /// @dev It ensures that signer signed a message containing (account, nonce, address(this))
70+ /// and that this message was not already used
71+ /// @param account the account the allowance is associated to
72+ /// @param nonce the nonce associated to this allowance
73+ /// @param signature the signature by the allowance signer wallet
74+ /// @param signer the signer
75+ /// @return the message to mark as used
76+ function _validateSignature (
77+ address account ,
78+ uint256 nonce ,
79+ bytes memory signature ,
80+ address signer
81+ ) internal view returns (bytes32 ) {
6582 bytes32 message = createMessage (account, nonce)
6683 .toEthSignedMessageHash ();
6784
68- // verifies that the sha3(account, nonce, address(this)) has been signed by _allowancesSigner
69- require (
70- message.recover (signature) == allowancesSigner (),
71- '!INVALID_SIGNATURE! '
72- );
85+ // verifies that the sha3(account, nonce, address(this)) has been signed by signer
86+ require (message.recover (signature) == signer, '!INVALID_SIGNATURE! ' );
87+
88+ // verifies that the allowances was not already used
7389 require (usedAllowances[message] == false , '!ALREADY_USED! ' );
7490
7591 return message;
0 commit comments