tempo_contracts/precompiles/
tip403_registry.rs1pub use ITIP403Registry::{
2 ITIP403RegistryErrors as TIP403RegistryError, ITIP403RegistryEvents as TIP403RegistryEvent,
3};
4
5crate::sol! {
6 #[derive(Debug, PartialEq, Eq)]
7 #[sol(abi)]
8 interface ITIP403Registry {
9 enum PolicyType {
11 WHITELIST,
12 BLACKLIST,
13 COMPOUND
14 }
15
16 enum BlockedReason {
17 NONE,
18 TOKEN_FILTER,
19 RECEIVE_POLICY
20 }
21
22 function policyIdCounter() external view returns (uint64);
24 function policyExists(uint64 policyId) external view returns (bool);
25 function policyData(uint64 policyId) external view returns (PolicyType policyType, address admin);
26 function isAuthorized(uint64 policyId, address user) external view returns (bool);
27 function isAuthorizedSender(uint64 policyId, address user) external view returns (bool);
28 function isAuthorizedRecipient(uint64 policyId, address user) external view returns (bool);
29 function isAuthorizedMintRecipient(uint64 policyId, address user) external view returns (bool);
30 function compoundPolicyData(uint64 policyId) external view returns (uint64 senderPolicyId, uint64 recipientPolicyId, uint64 mintRecipientPolicyId);
31 function receivePolicy(address account) external view returns (bool hasReceivePolicy, uint64 senderPolicyId, PolicyType senderPolicyType, uint64 tokenFilterId, PolicyType tokenFilterType, address recoveryAuthority);
32 function validateReceivePolicy(address token, address sender, address receiver) external view returns (bool authorized, BlockedReason blockedReason);
33
34 function createPolicy(address admin, PolicyType policyType) external returns (uint64);
36 function createPolicyWithAccounts(address admin, PolicyType policyType, address[] calldata accounts) external returns (uint64);
37 function setPolicyAdmin(uint64 policyId, address admin) external;
38 function modifyPolicyWhitelist(uint64 policyId, address account, bool allowed) external;
39 function modifyPolicyBlacklist(uint64 policyId, address account, bool restricted) external;
40 function createCompoundPolicy(uint64 senderPolicyId, uint64 recipientPolicyId, uint64 mintRecipientPolicyId) external returns (uint64);
41 function setReceivePolicy(uint64 senderPolicyId, uint64 tokenFilterId, address recoveryAuthority) external;
42
43 event PolicyAdminUpdated(uint64 indexed policyId, address indexed updater, address indexed admin);
45 event PolicyCreated(uint64 indexed policyId, address indexed updater, PolicyType policyType);
46 event WhitelistUpdated(uint64 indexed policyId, address indexed updater, address indexed account, bool allowed);
47 event BlacklistUpdated(uint64 indexed policyId, address indexed updater, address indexed account, bool restricted);
48 event CompoundPolicyCreated(uint64 indexed policyId, address indexed creator, uint64 senderPolicyId, uint64 recipientPolicyId, uint64 mintRecipientPolicyId);
49 event ReceivePolicyUpdated(address indexed account, uint64 senderPolicyId, uint64 tokenFilterId, address recoveryAuthority);
50
51 error Unauthorized();
53 error PolicyNotFound();
54 error PolicyNotSimple();
55 error InvalidPolicyType();
56 error IncompatiblePolicyType();
57 error VirtualAddressNotAllowed();
58 error InvalidReceivePolicyType();
59 error InvalidRecoveryAuthority();
60 }
61}
62
63impl ITIP403Registry::PolicyType {
64 pub const fn is_whitelist(&self) -> bool {
66 matches!(self, Self::WHITELIST)
67 }
68
69 pub const fn is_blacklist(&self) -> bool {
71 matches!(self, Self::BLACKLIST)
72 }
73
74 pub const fn is_compound(&self) -> bool {
76 matches!(self, Self::COMPOUND)
77 }
78}