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 }
48}
49
50impl ITIP403Registry::PolicyType {
51 pub const fn is_whitelist(&self) -> bool {
53 matches!(self, Self::WHITELIST)
54 }
55
56 pub const fn is_blacklist(&self) -> bool {
58 matches!(self, Self::BLACKLIST)
59 }
60
61 pub const fn is_compound(&self) -> bool {
63 matches!(self, Self::COMPOUND)
64 }
65}
66
67impl TIP403RegistryError {
68 pub const fn unauthorized() -> Self {
70 Self::Unauthorized(ITIP403Registry::Unauthorized {})
71 }
72
73 pub const fn invalid_policy_type() -> Self {
75 Self::InvalidPolicyType(ITIP403Registry::InvalidPolicyType {})
76 }
77
78 pub const fn incompatible_policy_type() -> Self {
80 Self::IncompatiblePolicyType(ITIP403Registry::IncompatiblePolicyType {})
81 }
82
83 pub const fn policy_not_found() -> Self {
85 Self::PolicyNotFound(ITIP403Registry::PolicyNotFound {})
86 }
87
88 pub const fn policy_not_simple() -> Self {
89 Self::PolicyNotSimple(ITIP403Registry::PolicyNotSimple {})
90 }
91}