|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity ^0.8.4; |
| 3 | + |
| 4 | +import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; |
| 5 | + |
| 6 | +/// @notice Defines the ERC-7943 interface, the uRWA. |
| 7 | +/// When interacting with specific token standards: |
| 8 | +/// - For ERC-721 like (non-fungible) tokens 'amount' parameters typically represent a single token (i.e., 1). |
| 9 | +/// - For ERC-20 like (fungible) tokens, 'tokenId' parameters are generally not applicable and should be set to 0. |
| 10 | +interface IERC7943 is IERC165 { |
| 11 | + /// @notice Emitted when tokens are taken from one address and transferred to another. |
| 12 | + /// @param from The address from which tokens were taken. |
| 13 | + /// @param to The address to which seized tokens were transferred. |
| 14 | + /// @param tokenId The ID of the token being transferred. |
| 15 | + /// @param amount The amount seized. |
| 16 | + event ForcedTransfer(address indexed from, address indexed to, uint256 tokenId, uint256 amount); |
| 17 | + |
| 18 | + /// @notice Emitted when `setFrozen` is called, changing the frozen `amount` of `tokenId` tokens for `user`. |
| 19 | + /// @param user The address of the user whose tokens are being frozen. |
| 20 | + /// @param tokenId The ID of the token being frozen. |
| 21 | + /// @param amount The amount of tokens frozen after the change. |
| 22 | + event Frozen(address indexed user, uint256 indexed tokenId, uint256 amount); |
| 23 | + |
| 24 | + /// @notice Error reverted when a user is not allowed to interact. |
| 25 | + /// @param account The address of the user which is not allowed for interactions. |
| 26 | + error ERC7943NotAllowedUser(address account); |
| 27 | + |
| 28 | + /// @notice Error reverted when a transfer is not allowed due to restrictions in place. |
| 29 | + /// @param from The address from which tokens are being transferred. |
| 30 | + /// @param to The address to which tokens are being transferred. |
| 31 | + /// @param tokenId The ID of the token being transferred. |
| 32 | + /// @param amount The amount being transferred. |
| 33 | + error ERC7943NotAllowedTransfer(address from, address to, uint256 tokenId, uint256 amount); |
| 34 | + |
| 35 | + /// @notice Error reverted when a transfer is attempted from `user` with an `amount` of `tokenId` less or equal than its balance, but greater than its unfrozen balance. |
| 36 | + /// @param user The address holding the tokens. |
| 37 | + /// @param tokenId The ID of the token being transferred. |
| 38 | + /// @param amount The amount being transferred. |
| 39 | + /// @param unfrozen The amount of tokens that are unfrozen and available to transfer. |
| 40 | + error ERC7943InsufficientUnfrozenBalance(address user, uint256 tokenId, uint256 amount, uint256 unfrozen); |
| 41 | + |
| 42 | + /// @notice Takes tokens from one address and transfers them to another. |
| 43 | + /// @dev Requires specific authorization. Used for regulatory compliance or recovery scenarios. |
| 44 | + /// @param from The address from which `amount` is taken. |
| 45 | + /// @param to The address that receives `amount`. |
| 46 | + /// @param tokenId The ID of the token being transferred. |
| 47 | + /// @param amount The amount to force transfer. |
| 48 | + function forceTransfer(address from, address to, uint256 tokenId, uint256 amount) external; |
| 49 | + |
| 50 | + /// @notice Changes the frozen status of `amount` of `tokenId` tokens belonging to an `user`. |
| 51 | + /// This overwrites the current value, similar to an `approve` function. |
| 52 | + /// @dev Requires specific authorization. Frozen tokens cannot be transferred by the user. |
| 53 | + /// @param user The address of the user whose tokens are to be frozen/unfrozen. |
| 54 | + /// @param tokenId The ID of the token to freeze/unfreeze. |
| 55 | + /// @param amount The amount of tokens to freeze/unfreeze. |
| 56 | + function setFrozen(address user, uint256 tokenId, uint256 amount) external; |
| 57 | + |
| 58 | + /// @notice Checks the frozen status/amount of a specific `tokenId`. |
| 59 | + /// @param user The address of the user. |
| 60 | + /// @param tokenId The ID of the token. |
| 61 | + /// @return amount The amount of `tokenId` tokens currently frozen for `user`. |
| 62 | + function getFrozen(address user, uint256 tokenId) external view returns (uint256 amount); |
| 63 | + |
| 64 | + /// @notice Checks if a transfer is currently possible according to token rules. It enforces validations on the frozen tokens. |
| 65 | + /// @dev This may involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. |
| 66 | + /// @param from The address sending tokens. |
| 67 | + /// @param to The address receiving tokens. |
| 68 | + /// @param tokenId The ID of the token being transferred. |
| 69 | + /// @param amount The amount being transferred. |
| 70 | + /// @return allowed True if the transfer is allowed, false otherwise. |
| 71 | + function isTransferAllowed( |
| 72 | + address from, |
| 73 | + address to, |
| 74 | + uint256 tokenId, |
| 75 | + uint256 amount |
| 76 | + ) external view returns (bool allowed); |
| 77 | + |
| 78 | + /// @notice Checks if a specific user is allowed to interact according to token rules. |
| 79 | + /// @dev This is often used for allowlist/KYC/KYB/AML checks. |
| 80 | + /// @param user The address to check. |
| 81 | + /// @return allowed True if the user is allowed, false otherwise. |
| 82 | + function isUserAllowed(address user) external view returns (bool allowed); |
| 83 | +} |
0 commit comments