pub use ITIP403Registry::{
ITIP403RegistryErrors as TIP403RegistryError, ITIP403RegistryEvents as TIP403RegistryEvent,
};
crate::sol! {
#[derive(Debug, PartialEq, Eq)]
#[sol(abi)]
interface ITIP403Registry {
enum PolicyType {
WHITELIST,
BLACKLIST,
COMPOUND
}
function policyIdCounter() external view returns (uint64);
function policyExists(uint64 policyId) external view returns (bool);
function policyData(uint64 policyId) external view returns (PolicyType policyType, address admin);
function isAuthorized(uint64 policyId, address user) external view returns (bool);
function isAuthorizedSender(uint64 policyId, address user) external view returns (bool);
function isAuthorizedRecipient(uint64 policyId, address user) external view returns (bool);
function isAuthorizedMintRecipient(uint64 policyId, address user) external view returns (bool);
function compoundPolicyData(uint64 policyId) external view returns (uint64 senderPolicyId, uint64 recipientPolicyId, uint64 mintRecipientPolicyId);
function createPolicy(address admin, PolicyType policyType) external returns (uint64);
function createPolicyWithAccounts(address admin, PolicyType policyType, address[] calldata accounts) external returns (uint64);
function setPolicyAdmin(uint64 policyId, address admin) external;
function modifyPolicyWhitelist(uint64 policyId, address account, bool allowed) external;
function modifyPolicyBlacklist(uint64 policyId, address account, bool restricted) external;
function createCompoundPolicy(uint64 senderPolicyId, uint64 recipientPolicyId, uint64 mintRecipientPolicyId) external returns (uint64);
event PolicyAdminUpdated(uint64 indexed policyId, address indexed updater, address indexed admin);
event PolicyCreated(uint64 indexed policyId, address indexed updater, PolicyType policyType);
event WhitelistUpdated(uint64 indexed policyId, address indexed updater, address indexed account, bool allowed);
event BlacklistUpdated(uint64 indexed policyId, address indexed updater, address indexed account, bool restricted);
event CompoundPolicyCreated(uint64 indexed policyId, address indexed creator, uint64 senderPolicyId, uint64 recipientPolicyId, uint64 mintRecipientPolicyId);
error Unauthorized();
error PolicyNotFound();
error PolicyNotSimple();
error InvalidPolicyType();
error IncompatiblePolicyType();
error VirtualAddressNotAllowed();
}
}
impl ITIP403Registry::PolicyType {
pub const fn is_whitelist(&self) -> bool {
matches!(self, Self::WHITELIST)
}
pub const fn is_blacklist(&self) -> bool {
matches!(self, Self::BLACKLIST)
}
pub const fn is_compound(&self) -> bool {
matches!(self, Self::COMPOUND)
}
}
impl TIP403RegistryError {
pub const fn unauthorized() -> Self {
Self::Unauthorized(ITIP403Registry::Unauthorized {})
}
pub const fn invalid_policy_type() -> Self {
Self::InvalidPolicyType(ITIP403Registry::InvalidPolicyType {})
}
pub const fn incompatible_policy_type() -> Self {
Self::IncompatiblePolicyType(ITIP403Registry::IncompatiblePolicyType {})
}
pub const fn policy_not_found() -> Self {
Self::PolicyNotFound(ITIP403Registry::PolicyNotFound {})
}
pub const fn policy_not_simple() -> Self {
Self::PolicyNotSimple(ITIP403Registry::PolicyNotSimple {})
}
pub const fn virtual_address_not_allowed() -> Self {
Self::VirtualAddressNotAllowed(ITIP403Registry::VirtualAddressNotAllowed {})
}
}