pub trait Whitelist {
type Address: AsRef<[u8]> + Zero;
// Required methods
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);
}
Expand description
Trait that implements temporary and permanent whitelists for multiple services identified with a hash
This trait implements two kinds of whitelisting: (1) Temporary, ends when the expiration timestamp is in the past (2) Indefinite, ends when the indefinite whitelist count is zero Multiple senders can indefinitely whitelist/unwhitelist independently. The user will be considered whitelisted as long as there is at least one active indefinite whitelisting.
The interface of this contract is not implemented. It should be inherited and its functions should be exposed with a sort of an authorization scheme.
Required Associated Types§
Required Methods§
Sourcefn user_is_whitelisted(
&self,
service_id: &Bytes32,
user: &Self::Address,
) -> bool
fn user_is_whitelisted( &self, service_id: &Bytes32, user: &Self::Address, ) -> bool
Returns if the user is whitelised to use the service
§Argument
service_id
Service IDuser
User address
Sourcefn extend_whitelist_expiration(
&mut self,
service_id: &Bytes32,
user: &Self::Address,
expiration_timestamp: u64,
)
fn extend_whitelist_expiration( &mut self, service_id: &Bytes32, user: &Self::Address, expiration_timestamp: u64, )
Extends the expiration of the temporary whitelist of the user for the service
§Argument
service_id
Service IDuser
User addressexpiration_timestamp
Timestamp at which the temporary whitelist will expire
Sourcefn set_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, )
Sets the expiration of the temporary whitelist of user
to be
able to use the service with serviceId
if the sender has the
whitelist expiration setter role
§Argument
service_id
Service IDuser
User addressexpiration_timestamp
Timestamp at which the temporary whitelist will expire
Sourcefn set_indefinite_whitelist_status(
&mut self,
service_id: &Bytes32,
user: &Self::Address,
status: bool,
) -> U256
fn set_indefinite_whitelist_status( &mut self, service_id: &Bytes32, user: &Self::Address, status: bool, ) -> U256
Sets the indefinite whitelist status of user
to be able to
use the service with serviceId
if the sender has the indefinite
whitelister role
§Argument
service_id
Service ID
user
User address
status
Indefinite whitelist status
Sourcefn revoke_indefinite_whitelist_status(
&mut self,
service_id: &Bytes32,
user: &Self::Address,
setter: &Self::Address,
) -> (bool, U256)
fn revoke_indefinite_whitelist_status( &mut self, service_id: &Bytes32, user: &Self::Address, setter: &Self::Address, ) -> (bool, U256)
Revokes the indefinite whitelist status granted to the user for the service by a specific account
§Argument
service_id
Service ID
user
User address
setter
Setter of the indefinite whitelist status