File tree 4 files changed +21
-6
lines changed 4 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
pragma solidity ^ 0.8.0 ;
4
4
5
- import "../utils/draft-EIP712.sol " ;
5
+ import "../utils/cryptography/ draft-EIP712.sol " ;
6
6
import "../utils/cryptography/ECDSA.sol " ;
7
7
8
8
contract EIP712External is EIP712 {
Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ pragma solidity ^0.8.0;
4
4
5
5
import "./draft-IERC20Permit.sol " ;
6
6
import "../ERC20.sol " ;
7
+ import "../../../utils/cryptography/draft-EIP712.sol " ;
7
8
import "../../../utils/cryptography/ECDSA.sol " ;
8
9
import "../../../utils/Counters.sol " ;
9
- import "../../../utils/draft-EIP712.sol " ;
10
10
11
11
/**
12
12
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
Original file line number Diff line number Diff line change @@ -72,9 +72,9 @@ library ECDSA {
72
72
73
73
/**
74
74
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
75
- * replicates the behavior of the
76
- * https://github.com/ethereum/ wiki/wiki/JSON-RPC #eth_sign[`eth_sign`]
77
- * JSON-RPC method.
75
+ * produces hash corresponding to the one signed with the
76
+ * https://eth. wiki/json-rpc/API #eth_sign[`eth_sign`]
77
+ * JSON-RPC method as part of EIP-191 .
78
78
*
79
79
* See {recover}.
80
80
*/
@@ -83,4 +83,17 @@ library ECDSA {
83
83
// enforced by the type signature above
84
84
return keccak256 (abi.encodePacked ("\x19Ethereum Signed Message:\n32 " , hash));
85
85
}
86
+
87
+ /**
88
+ * @dev Returns an Ethereum Signed Typed Data, created from a
89
+ * `domainSeparator` and a `structHash`. This produces hash corresponding
90
+ * to the one signed with the
91
+ * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
92
+ * JSON-RPC method as part of EIP-712.
93
+ *
94
+ * See {recover}.
95
+ */
96
+ function toTypedDataHash (bytes32 domainSeparator , bytes32 structHash ) internal pure returns (bytes32 ) {
97
+ return keccak256 (abi.encodePacked ("\x19\x01 " , domainSeparator, structHash));
98
+ }
86
99
}
Original file line number Diff line number Diff line change 2
2
3
3
pragma solidity ^ 0.8.0 ;
4
4
5
+ import "./ECDSA.sol " ;
6
+
5
7
/**
6
8
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
7
9
*
@@ -95,6 +97,6 @@ abstract contract EIP712 {
95
97
* ```
96
98
*/
97
99
function _hashTypedDataV4 (bytes32 structHash ) internal view virtual returns (bytes32 ) {
98
- return keccak256 ( abi.encodePacked ( " \x19\x01 " , _domainSeparatorV4 (), structHash) );
100
+ return ECDSA. toTypedDataHash ( _domainSeparatorV4 (), structHash);
99
101
}
100
102
}
You can’t perform that action at this time.
0 commit comments