-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Expand file tree
/
Copy pathdraft-IERC3009.sol
More file actions
84 lines (77 loc) · 2.59 KB
/
draft-IERC3009.sol
File metadata and controls
84 lines (77 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-3009 standard as defined in https://eips.ethereum.org/EIPS/eip-3009[ERC-3009].
*/
interface IERC3009 {
/// @dev Emitted when an authorization is used.
event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce);
/**
* @dev Returns the state of an authorization.
*
* Nonces are randomly generated 32-byte values unique to the authorizer's address.
*/
function authorizationState(address authorizer, bytes32 nonce) external view returns (bool);
/**
* @dev Executes a transfer with a signed authorization.
*
* Requirements:
*
* * `validAfter` must be less than the current block timestamp.
* * `validBefore` must be greater than the current block timestamp.
* * `nonce` must not have been used by the `from` account.
* * the signature must be valid for the authorization.
*/
function transferWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Receives a transfer with a signed authorization from the payer.
*
* Includes an additional check to ensure that the payee's address (`to`) matches the caller
* to prevent front-running attacks.
*
* Requirements:
*
* * `to` must be the caller of this function.
* * `validAfter` must be less than the current block timestamp.
* * `validBefore` must be greater than the current block timestamp.
* * `nonce` must not have been used by the `from` account.
* * the signature must be valid for the authorization.
*/
function receiveWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) external;
}
/**
* @dev Extension of {IERC3009} that adds the ability to cancel authorizations.
*/
interface IERC3009Cancel {
/// @dev Emitted when an authorization is canceled.
event AuthorizationCanceled(address indexed authorizer, bytes32 indexed nonce);
/**
* @dev Cancels an authorization.
*
* Requirements:
*
* * `nonce` must not have been used by the `authorizer` account.
* * the signature must be valid for the cancellation.
*/
function cancelAuthorization(address authorizer, bytes32 nonce, uint8 v, bytes32 r, bytes32 s) external;
}