#![allow(unused)]
use crate::abi::{Token, U256};
use crate::Error;
use crate::{ensure, keccak_packed, AccessControlRegistryAdminnedWithManager, RoleDeriver};
use crate::{Bytes32, Zero};
pub trait Whitelist {
type Address: AsRef<[u8]> + Zero;
fn user_is_whitelisted(&self, service_id: &Bytes32, user: &Self::Address) -> bool;
fn extend_whitelist_expiration(
&mut self,
service_id: &Bytes32,
user: &Self::Address,
expiration_timestamp: u64,
);
fn set_whitelist_expiration(
&mut self,
service_id: &Bytes32,
user: &Self::Address,
expiration_timestamp: u64,
);
fn set_indefinite_whitelist_status(
&mut self,
service_id: &Bytes32,
user: &Self::Address,
status: bool,
) -> U256;
fn revoke_indefinite_whitelist_status(
&mut self,
service_id: &Bytes32,
user: &Self::Address,
setter: &Self::Address,
) -> (bool, U256);
}
pub trait WhitelistRoles {
fn whitelist_expiration_extender_role_description() -> String {
String::from("Whitelist expiration extender")
}
fn whitelist_expiration_setter_role_description() -> String {
String::from("Whitelist expiration setter")
}
fn indefinite_whitelister_role_description() -> String {
String::from("Indefinite whitelister")
}
}
pub trait WhitelistRolesWithManager:
WhitelistRoles + AccessControlRegistryAdminnedWithManager
{
fn has_whitelist_expiration_extender_role_or_is_manager(&self, account: &Self::Address) -> bool;
fn has_indefinite_whitelister_role_or_is_manager(&self, account: &Self::Address) -> bool;
fn has_whitelist_expiration_setter_role_or_is_manager(&self, account: &Self::Address) -> bool;
fn whitelist_expiration_extender_role(&self) -> Bytes32 {
RoleDeriver::derive_role(
self.admin_role(),
Self::whitelist_expiration_extender_role_description(),
)
}
fn whitelist_expiration_setter_role(&self) -> Bytes32 {
RoleDeriver::derive_role(
self.admin_role(),
Self::whitelist_expiration_setter_role_description(),
)
}
fn indefinite_whitelister_role(&self) -> Bytes32 {
RoleDeriver::derive_role(
self.admin_role(),
Self::indefinite_whitelister_role_description(),
)
}
}
pub trait WhitelistWithManager: Whitelist + WhitelistRolesWithManager {
fn extend_whitelist_expiration(
&mut self,
service_id: &Bytes32,
user: &<Self as Whitelist>::Address,
expiration_timestamp: u64,
);
fn set_whitelist_expiration(
&mut self,
service_id: &Bytes32,
user: &<Self as Whitelist>::Address,
expiration_timestamp: u64,
);
fn set_indefinite_whitelist_status(
&mut self,
service_id: &Bytes32,
user: &<Self as Whitelist>::Address,
status: bool,
) -> U256;
fn revoke_indefinite_whitelist_status(
&mut self,
service_id: &Bytes32,
user: &<Self as Whitelist>::Address,
setter: &<Self as Whitelist>::Address,
) -> (bool, U256);
}