tempo_contracts/precompiles/
tip403_registry.rs1use alloy::sol;
2
3pub use ITIP403Registry::{
4 ITIP403RegistryErrors as TIP403RegistryError, ITIP403RegistryEvents as TIP403RegistryEvent,
5};
6
7sol! {
8 #[derive(Debug, PartialEq, Eq)]
9 #[sol(rpc, abi)]
10 interface ITIP403Registry {
11 enum PolicyType {
13 WHITELIST,
14 BLACKLIST
15 }
16
17 function policyIdCounter() external view returns (uint64);
19 function policyData(uint64 policyId) external view returns (PolicyType policyType, address admin);
20 function isAuthorized(uint64 policyId, address user) external view returns (bool);
21
22 function createPolicy(address admin, PolicyType policyType) external returns (uint64);
24 function createPolicyWithAccounts(address admin, PolicyType policyType, address[] calldata accounts) external returns (uint64);
25 function setPolicyAdmin(uint64 policyId, address admin) external;
26 function modifyPolicyWhitelist(uint64 policyId, address account, bool allowed) external;
27 function modifyPolicyBlacklist(uint64 policyId, address account, bool restricted) external;
28
29 event PolicyAdminUpdated(uint64 indexed policyId, address indexed updater, address indexed admin);
31 event PolicyCreated(uint64 indexed policyId, address indexed updater, PolicyType policyType);
32 event WhitelistUpdated(uint64 indexed policyId, address indexed updater, address indexed account, bool allowed);
33 event BlacklistUpdated(uint64 indexed policyId, address indexed updater, address indexed account, bool restricted);
34
35 error Unauthorized();
37 error IncompatiblePolicyType();
38 }
39}
40
41impl TIP403RegistryError {
42 pub const fn unauthorized() -> Self {
44 Self::Unauthorized(ITIP403Registry::Unauthorized {})
45 }
46
47 pub const fn incompatible_policy_type() -> Self {
49 Self::IncompatiblePolicyType(ITIP403Registry::IncompatiblePolicyType {})
50 }
51}