t-isol 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,7 +11,7 @@ interface ITransferAuthorize {
|
|
|
11
11
|
event AuthorizeUsed(address indexed authorizer, bytes32 indexed nonce);
|
|
12
12
|
|
|
13
13
|
/// @notice Emitted when a transfer with authorization is executed
|
|
14
|
-
event TransferWithAuthorize(address indexed from, address indexed to, uint256 value, uint256
|
|
14
|
+
event TransferWithAuthorize(address indexed from, address indexed to, uint256 value, uint256 timeMFG, uint256 timeEXP, bytes32 indexed nonce, bytes auth);
|
|
15
15
|
|
|
16
16
|
/// @notice Emitted when a transferFrom with authorization is executed
|
|
17
17
|
event TransferFromWithAuthorize(address indexed from, address indexed to, uint256 value, uint256 validAfter, uint256 validBefore, bytes32 indexed nonce);
|
|
@@ -36,10 +36,10 @@ interface ITransferAuthorize {
|
|
|
36
36
|
address from,
|
|
37
37
|
address to,
|
|
38
38
|
uint256 value,
|
|
39
|
-
uint256
|
|
40
|
-
uint256
|
|
39
|
+
uint256 timeMFG,
|
|
40
|
+
uint256 timeEXP,
|
|
41
41
|
bytes32 nonce,
|
|
42
|
-
bytes calldata
|
|
42
|
+
bytes calldata auth
|
|
43
43
|
) external;
|
|
44
44
|
|
|
45
45
|
// ++
|
|
@@ -15,7 +15,7 @@ abstract contract TransferAuthorize is ITransferAuthorize, EIP712 {
|
|
|
15
15
|
mapping(address => mapping(bytes32 => bool)) private _authorizeState;
|
|
16
16
|
|
|
17
17
|
bytes32 public constant TRANSFER_TYPEHASH =
|
|
18
|
-
keccak256("TransferWithAuthorize(address from,address to,uint256 value,uint256
|
|
18
|
+
keccak256("TransferWithAuthorize(address from,address to,uint256 value,uint256 timeMFG,uint256 timeEXP,bytes32 nonce)");
|
|
19
19
|
|
|
20
20
|
bytes32 public constant TRANSFERFROM_TYPEHASH =
|
|
21
21
|
keccak256("TransferFromWithAuthorize(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)");
|
|
@@ -52,30 +52,30 @@ abstract contract TransferAuthorize is ITransferAuthorize, EIP712 {
|
|
|
52
52
|
emit AuthorizeUsed(authorizer, nonce);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/// @dev Verify an EIP-712 typed signature for TransferWithAuthorize and return the recovered signer
|
|
55
|
+
/// @dev Verify an EIP-712 typed signature (auth) for TransferWithAuthorize and return the recovered signer
|
|
56
56
|
function _verifyTransfer(
|
|
57
57
|
address from,
|
|
58
58
|
address to,
|
|
59
59
|
uint256 value,
|
|
60
|
-
uint256
|
|
61
|
-
uint256
|
|
60
|
+
uint256 timeMFG,
|
|
61
|
+
uint256 timeEXP,
|
|
62
62
|
bytes32 nonce,
|
|
63
|
-
bytes calldata
|
|
63
|
+
bytes calldata auth
|
|
64
64
|
) internal view returns (address signer) {
|
|
65
|
-
require(block.timestamp >=
|
|
66
|
-
require(block.timestamp <=
|
|
65
|
+
require(block.timestamp >= timeMFG, "TransferAuthorize: not yet valid");
|
|
66
|
+
require(block.timestamp <= timeEXP, "TransferAuthorize: expired");
|
|
67
67
|
bytes32 structHash = keccak256(
|
|
68
68
|
abi.encode(
|
|
69
69
|
TRANSFER_TYPEHASH,
|
|
70
70
|
from,
|
|
71
71
|
to,
|
|
72
72
|
value,
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
timeMFG,
|
|
74
|
+
timeEXP,
|
|
75
75
|
nonce
|
|
76
76
|
)
|
|
77
77
|
);
|
|
78
|
-
signer = ECDSA.recover(_hashTypedDataV4(structHash),
|
|
78
|
+
signer = ECDSA.recover(_hashTypedDataV4(structHash), auth);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/// @dev Verify an EIP-712 typed signature for TransferFromWithAuthorize and return the recovered signer
|
|
@@ -31,24 +31,24 @@ abstract contract ERC20xTransferWithAuthorize is ERC20, TransferAuthorize, Reent
|
|
|
31
31
|
address from,
|
|
32
32
|
address to,
|
|
33
33
|
uint256 value,
|
|
34
|
-
uint256
|
|
35
|
-
uint256
|
|
34
|
+
uint256 timeMFG,
|
|
35
|
+
uint256 timeEXP,
|
|
36
36
|
bytes32 nonce,
|
|
37
|
-
bytes calldata
|
|
37
|
+
bytes calldata auth
|
|
38
38
|
) external override nonReentrant {
|
|
39
39
|
address signer = _verifyTransfer(
|
|
40
40
|
from,
|
|
41
41
|
to,
|
|
42
42
|
value,
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
timeMFG,
|
|
44
|
+
timeEXP,
|
|
45
45
|
nonce,
|
|
46
|
-
|
|
46
|
+
auth
|
|
47
47
|
);
|
|
48
48
|
require(signer == from, "ERC20TransferAuthorize: invalid signature");
|
|
49
49
|
_useAuthorize(from, nonce);
|
|
50
50
|
_transfer(from, to, value);
|
|
51
|
-
emit TransferWithAuthorize(from, to, value,
|
|
51
|
+
emit TransferWithAuthorize(from, to, value, timeMFG, timeEXP, nonce, auth);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/// @notice Relayer-triggered transfer using an off-chain signature by `from`.
|