Struct dao::core_contracts::VariableRepositoryContract
source · pub struct VariableRepositoryContract {
pub access_control: AccessControl,
pub repository: Repository,
}
Expand description
Variable Repository Contract.
Fields§
§access_control: AccessControl
§repository: Repository
Implementations§
source§impl VariableRepositoryContract
impl VariableRepositoryContract
sourcepub fn init(
&mut self,
fiat_conversion: Address,
bid_escrow_wallet: Address,
voting_ids: Address
)
pub fn init( &mut self, fiat_conversion: Address, bid_escrow_wallet: Address, voting_ids: Address )
Constructor function.
§Note
Initializes contract elements:
- Sets the default configuration of the
Repository
- Sets [
caller
] as the owner of the contract. - Adds [
caller
] to the whitelist.
§Events
OwnerChanged
,AddedToWhitelist
,- multiple
ValueUpdated
events, one per value of the default repository configuration.
sourcepub fn update_at(
&mut self,
key: String,
value: Bytes,
activation_time: Option<u64>
)
pub fn update_at( &mut self, key: String, value: Bytes, activation_time: Option<u64> )
Inserts or updates the value under the given key.
§Note
- The activation time is represented as a unix timestamp.
- If the activation time is
None
the value is updated immediately. - If some future time in the future is passed as an argument, the
Self::get
function returns the previously set value.
§Events
§Errors
NotWhitelisted
if the caller is not a whitelisted user.ActivationTimeInPast
if the activation time has passed already.
sourcepub fn get(&self, key: String) -> Option<Bytes>
pub fn get(&self, key: String) -> Option<Bytes>
Returns the value stored under the given key.
If the key does not exist, the None
value is returned.
sourcepub fn get_full_value(&self, key: String) -> Option<Record>
pub fn get_full_value(&self, key: String) -> Option<Record>
Returns the full (current and future) value stored under the given key.
See Record
.
If the key does not exist, the None
value is returned.
sourcepub fn get_key_at(&self, index: u32) -> Option<String>
pub fn get_key_at(&self, index: u32) -> Option<String>
Returns the value stored under the given index.
Every freshly added key has the previous key index increased by 1. The index range is 0 to #keys-1.
If the given index exceeds #keys-1 the None
value is returned.
sourcepub fn keys_count(&self) -> u32
pub fn keys_count(&self) -> u32
Returns the number of existing keys in the Repository
.
sourcepub fn all_variables(&self) -> BTreeMap<String, Bytes>
pub fn all_variables(&self) -> BTreeMap<String, Bytes>
Reads all the stored variables and returns a map key to value.
sourcepub fn is_whitelisted(&self, address: Address) -> bool
pub fn is_whitelisted(&self, address: Address) -> bool
Checks whether the given address is added to the whitelist.
Read more
.
sourcepub fn get_owner(&self) -> Option<Address>
pub fn get_owner(&self) -> Option<Address>
Returns the address of the current owner.
Read more
.
sourcepub fn propose_new_owner(&mut self, owner: Address)
pub fn propose_new_owner(&mut self, owner: Address)
Changes the ownership of the contract. Transfers ownership to the owner
.
Only the current owner is permitted to call this method.
Read more
sourcepub fn accept_new_owner(&mut self)
pub fn accept_new_owner(&mut self)
Accepts the new owner proposition. This can be called only by the proposed owner.
Read more
sourcepub fn add_to_whitelist(&mut self, address: Address)
pub fn add_to_whitelist(&mut self, address: Address)
Adds a new address to the whitelist.
Read more
sourcepub fn remove_from_whitelist(&mut self, address: Address)
pub fn remove_from_whitelist(&mut self, address: Address)
Remove address from the whitelist.
Read more
Trait Implementations§
source§impl Clone for VariableRepositoryContract
impl Clone for VariableRepositoryContract
source§fn clone(&self) -> VariableRepositoryContract
fn clone(&self) -> VariableRepositoryContract
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more