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 function policyIdCounter() external view returns (uint64);
18 function policyExists(uint64 policyId) external view returns (bool);
19 function policyData(uint64 policyId) external view returns (PolicyType policyType, address admin);
20 function isAuthorized(uint64 policyId, address user) external view returns (bool);
21 function isAuthorizedSender(uint64 policyId, address user) external view returns (bool);
22 function isAuthorizedRecipient(uint64 policyId, address user) external view returns (bool);
23 function isAuthorizedMintRecipient(uint64 policyId, address user) external view returns (bool);
24 function compoundPolicyData(uint64 policyId) external view returns (uint64 senderPolicyId, uint64 recipientPolicyId, uint64 mintRecipientPolicyId);
25
26 function createPolicy(address admin, PolicyType policyType) external returns (uint64);
28 function createPolicyWithAccounts(address admin, PolicyType policyType, address[] calldata accounts) external returns (uint64);
29 function setPolicyAdmin(uint64 policyId, address admin) external;
30 function modifyPolicyWhitelist(uint64 policyId, address account, bool allowed) external;
31 function modifyPolicyBlacklist(uint64 policyId, address account, bool restricted) external;
32 function createCompoundPolicy(uint64 senderPolicyId, uint64 recipientPolicyId, uint64 mintRecipientPolicyId) external returns (uint64);
33
34 event PolicyAdminUpdated(uint64 indexed policyId, address indexed updater, address indexed admin);
36 event PolicyCreated(uint64 indexed policyId, address indexed updater, PolicyType policyType);
37 event WhitelistUpdated(uint64 indexed policyId, address indexed updater, address indexed account, bool allowed);
38 event BlacklistUpdated(uint64 indexed policyId, address indexed updater, address indexed account, bool restricted);
39 event CompoundPolicyCreated(uint64 indexed policyId, address indexed creator, uint64 senderPolicyId, uint64 recipientPolicyId, uint64 mintRecipientPolicyId);
40
41 error Unauthorized();
43 error PolicyNotFound();
44 error PolicyNotSimple();
45 error InvalidPolicyType();
46 error IncompatiblePolicyType();
47 error VirtualAddressNotAllowed();
48 }
49}
50
51impl ITIP403Registry::PolicyType {
52 pub const fn is_whitelist(&self) -> bool {
54 matches!(self, Self::WHITELIST)
55 }
56
57 pub const fn is_blacklist(&self) -> bool {
59 matches!(self, Self::BLACKLIST)
60 }
61
62 pub const fn is_compound(&self) -> bool {
64 matches!(self, Self::COMPOUND)
65 }
66}
67
68impl TIP403RegistryError {
69 pub const fn unauthorized() -> Self {
71 Self::Unauthorized(ITIP403Registry::Unauthorized {})
72 }
73
74 pub const fn invalid_policy_type() -> Self {
76 Self::InvalidPolicyType(ITIP403Registry::InvalidPolicyType {})
77 }
78
79 pub const fn incompatible_policy_type() -> Self {
81 Self::IncompatiblePolicyType(ITIP403Registry::IncompatiblePolicyType {})
82 }
83
84 pub const fn policy_not_found() -> Self {
86 Self::PolicyNotFound(ITIP403Registry::PolicyNotFound {})
87 }
88
89 pub const fn policy_not_simple() -> Self {
90 Self::PolicyNotSimple(ITIP403Registry::PolicyNotSimple {})
91 }
92
93 pub const fn virtual_address_not_allowed() -> Self {
95 Self::VirtualAddressNotAllowed(ITIP403Registry::VirtualAddressNotAllowed {})
96 }
97}