tempo_contracts/precompiles/
tip403_registry.rs

1use 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        // Enums
12        enum PolicyType {
13            WHITELIST,
14            BLACKLIST
15        }
16
17        // View Functions
18        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        // State-Changing Functions
23        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        // Events
30        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        // Errors
36        error Unauthorized();
37        error IncompatiblePolicyType();
38    }
39}
40
41impl TIP403RegistryError {
42    /// Creates an error for unauthorized calls
43    pub const fn unauthorized() -> Self {
44        Self::Unauthorized(ITIP403Registry::Unauthorized {})
45    }
46
47    /// Creates an error for incompatible policy types
48    pub const fn incompatible_policy_type() -> Self {
49        Self::IncompatiblePolicyType(ITIP403Registry::IncompatiblePolicyType {})
50    }
51}