|
| 1 | +// SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | +pragma solidity >=0.8.13 <0.9.0; |
| 3 | + |
| 4 | +import {ITIP403Registry} from "./ITIP403Registry.sol"; |
| 5 | + |
| 6 | +/// @title The interface for TIP-1028 escrow |
| 7 | +/// @notice Escrow holding blocked inbound TIP-20 transfers and mints until claimed |
| 8 | +interface ITIP1028Escrow { |
| 9 | + /// @notice The kind of inbound operation that was blocked |
| 10 | + /// @param TRANSFER A regular TIP-20 transfer |
| 11 | + /// @param MINT A TIP-20 mint |
| 12 | + enum InboundKind { |
| 13 | + TRANSFER, |
| 14 | + MINT |
| 15 | + } |
| 16 | + |
| 17 | + /// @notice V1 claim receipt encoding for a blocked inbound |
| 18 | + /// @param originator The original sender (transfer) or issuer (mint) |
| 19 | + /// @param recipient The intended recipient of the blocked inbound |
| 20 | + /// @param blockedAt The block number at which the inbound was blocked |
| 21 | + /// @param blockedNonce The escrow-scoped nonce assigned to this blocked receipt |
| 22 | + /// @param blockedReason The reason the inbound was blocked |
| 23 | + /// @param kind Whether the blocked inbound was a transfer or mint |
| 24 | + /// @param memo Application-specific memo attached to the inbound |
| 25 | + struct ClaimReceiptV1 { |
| 26 | + address originator; |
| 27 | + address recipient; |
| 28 | + uint64 blockedAt; |
| 29 | + uint64 blockedNonce; |
| 30 | + ITIP403Registry.BlockedReason blockedReason; |
| 31 | + InboundKind kind; |
| 32 | + bytes32 memo; |
| 33 | + } |
| 34 | + |
| 35 | + /// @notice Returns the escrowed balance for a specific blocked receipt |
| 36 | + /// @param token The TIP-20 token address |
| 37 | + /// @param recoveryAuthority The recovery authority that was assigned to the blocked receipt |
| 38 | + /// @param receiptVersion The version of the claim receipt encoding |
| 39 | + /// @param receipt The ABI-encoded claim receipt |
| 40 | + /// @return amount The escrowed balance for the receipt |
| 41 | + function blockedReceiptBalance( |
| 42 | + address token, |
| 43 | + address recoveryAuthority, |
| 44 | + uint8 receiptVersion, |
| 45 | + bytes calldata receipt |
| 46 | + ) external view returns (uint256 amount); |
| 47 | + |
| 48 | + /// @notice Claims a blocked receipt, releasing escrowed funds to the specified address |
| 49 | + /// @param token The TIP-20 token address |
| 50 | + /// @param recoveryAuthority The recovery authority that was assigned to the blocked receipt |
| 51 | + /// @param receiptVersion The version of the claim receipt encoding |
| 52 | + /// @param receipt The ABI-encoded claim receipt |
| 53 | + /// @param to The address to release the escrowed funds to |
| 54 | + function claim(address token, address recoveryAuthority, uint8 receiptVersion, bytes calldata receipt, address to) |
| 55 | + external; |
| 56 | + |
| 57 | + /// @notice Emitted when an inbound transfer or mint is blocked by a receive policy |
| 58 | + /// @param token The TIP-20 token address |
| 59 | + /// @param from The sender of the blocked inbound |
| 60 | + /// @param receiver The receiver whose receive policy blocked the inbound |
| 61 | + /// @param receiptVersion The version of the claim receipt encoding |
| 62 | + /// @param blockedNonce The escrow-scoped nonce assigned to this blocked receipt |
| 63 | + /// @param blockedAt The block number at which the inbound was blocked |
| 64 | + /// @param recipient The intended recipient of the blocked inbound |
| 65 | + /// @param amount The amount of tokens blocked |
| 66 | + /// @param blockedReason The reason the inbound was blocked |
| 67 | + /// @param recoveryAuthority The recovery authority assigned to the blocked receipt |
| 68 | + /// @param memo Application-specific memo attached to the inbound |
| 69 | + event TransferBlocked( |
| 70 | + address indexed token, |
| 71 | + address indexed from, |
| 72 | + address indexed receiver, |
| 73 | + uint8 receiptVersion, |
| 74 | + uint64 blockedNonce, |
| 75 | + uint64 blockedAt, |
| 76 | + address recipient, |
| 77 | + uint256 amount, |
| 78 | + ITIP403Registry.BlockedReason blockedReason, |
| 79 | + address recoveryAuthority, |
| 80 | + bytes32 memo |
| 81 | + ); |
| 82 | + |
| 83 | + /// @notice Emitted when a blocked receipt is claimed |
| 84 | + /// @param token The TIP-20 token address |
| 85 | + /// @param receiver The receiver whose escrow held the blocked funds |
| 86 | + /// @param receiptVersion The version of the claim receipt encoding |
| 87 | + /// @param blockedNonce The escrow-scoped nonce of the claimed receipt |
| 88 | + /// @param blockedAt The block number at which the inbound was originally blocked |
| 89 | + /// @param originator The original sender of the blocked inbound |
| 90 | + /// @param recipient The intended recipient of the blocked inbound |
| 91 | + /// @param recoveryAuthority The recovery authority that authorized the claim |
| 92 | + /// @param caller The address that called claim |
| 93 | + /// @param to The address that received the released funds |
| 94 | + /// @param amount The amount of tokens released |
| 95 | + event BlockedReceiptClaimed( |
| 96 | + address indexed token, |
| 97 | + address indexed receiver, |
| 98 | + uint8 receiptVersion, |
| 99 | + uint64 indexed blockedNonce, |
| 100 | + uint64 blockedAt, |
| 101 | + address originator, |
| 102 | + address recipient, |
| 103 | + address recoveryAuthority, |
| 104 | + address caller, |
| 105 | + address to, |
| 106 | + uint256 amount |
| 107 | + ); |
| 108 | + |
| 109 | + /// @notice Error when the caller is not authorized to claim the blocked receipt |
| 110 | + error UnauthorizedClaimer(); |
| 111 | + |
| 112 | + /// @notice Error when the claim receipt is invalid or does not match any blocked receipt |
| 113 | + error InvalidReceiptClaim(); |
| 114 | + |
| 115 | + /// @notice Error when the escrow balance is insufficient (already claimed or zero) |
| 116 | + error InsufficientEscrowBalance(); |
| 117 | + |
| 118 | + /// @notice Error when the escrow address itself is used where it should not be |
| 119 | + error EscrowAddressReserved(); |
| 120 | + |
| 121 | + /// @notice Error when the claim destination address is invalid |
| 122 | + error InvalidClaimAddress(); |
| 123 | + |
| 124 | + /// @notice Error when the token address is invalid |
| 125 | + error InvalidToken(); |
| 126 | +} |
0 commit comments