-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathIReceivePolicyGuard.sol
More file actions
109 lines (97 loc) · 4.19 KB
/
IReceivePolicyGuard.sol
File metadata and controls
109 lines (97 loc) · 4.19 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.13 <0.9.0;
/// @title The interface for the TIP-1028 receive policy guard
/// @notice Tracks blocked inbound TIP-20 transfers and mints until claimed or burned
interface IReceivePolicyGuard {
/// @notice The kind of inbound operation that was blocked
/// @param TRANSFER A regular TIP-20 transfer
/// @param MINT A TIP-20 mint
enum InboundKind {
TRANSFER,
MINT
}
/// @notice V1 claim receipt encoding for a blocked inbound
/// @param version The receipt encoding version
/// @param token The TIP-20 token address
/// @param recoveryAuthority The recovery authority assigned to the blocked receipt
/// @param originator The original sender (transfer) or issuer (mint)
/// @param recipient The intended recipient of the blocked inbound
/// @param blockedAt The block timestamp at which the inbound was blocked
/// @param blockedNonce The guard-scoped nonce assigned to this blocked receipt
/// @param blockedReason The reason the inbound was blocked
/// @param kind Whether the blocked inbound was a transfer or mint
/// @param memo Application-specific memo attached to the inbound
struct ClaimReceiptV1 {
uint8 version;
address token;
address recoveryAuthority;
address originator;
address recipient;
uint64 blockedAt;
uint64 blockedNonce;
uint8 blockedReason;
InboundKind kind;
bytes32 memo;
}
/// @notice Returns the blocked balance for an encoded receipt
/// @param receipt The ABI-encoded claim receipt
/// @return amount The blocked balance for the receipt
function balanceOf(bytes calldata receipt) external view returns (uint256 amount);
/// @notice Claims a blocked receipt, releasing funds to the specified address
/// @param to The address to release the blocked funds to
/// @param receipt The ABI-encoded claim receipt
function claim(address to, bytes calldata receipt) external;
/// @notice Burns the funds backing a blocked receipt
/// @param receipt The ABI-encoded claim receipt
function burnBlockedReceipt(bytes calldata receipt) external;
/// @notice Emitted when an inbound TIP-20 transfer or mint is blocked and funds are redirected
/// @param token TIP-20 token whose funds are held by the guard
/// @param receiver Resolved account where funds would settle; for virtual recipients its their master
/// @param blockedNonce Guard nonce assigned to the blocked operation
/// @param amount Amount of blocked funds held by the guard
/// @param receiptVersion Claim receipt layout version
/// @param receipt ABI-encoded receipt witness that can be passed to `claim`
event TransferBlocked(
address indexed token,
address indexed receiver,
uint64 indexed blockedNonce,
uint256 amount,
uint8 receiptVersion,
bytes receipt
);
/// @notice Emitted when blocked funds are claimed with a valid receipt
event ReceiptClaimed(
address indexed token,
address indexed receiver,
uint64 indexed blockedNonce,
uint64 blockedAt,
uint8 receiptVersion,
address originator,
address recipient,
address recoveryAuthority,
address caller,
address to,
uint256 amount
);
/// @notice Emitted when blocked funds are burned with a valid receipt
event ReceiptBurned(
address indexed token,
address indexed receiver,
uint64 indexed blockedNonce,
uint64 blockedAt,
uint8 receiptVersion,
address originator,
address recipient,
address recoveryAuthority,
address caller,
uint256 amount
);
/// @notice Error when the claim receipt is invalid or does not match any blocked receipt
error InvalidReceipt();
/// @notice Error when the claim destination address is invalid
error InvalidClaimAddress();
/// @notice Error when the caller is not authorized to claim the blocked receipt
error UnauthorizedClaimer();
/// @notice Error when a reserved address is used where it should not be
error AddressReserved();
}