Struct casper_types::account::Account
source · pub struct Account { /* private fields */ }
Expand description
Represents an Account in the global state.
Implementations§
source§impl Account
impl Account
sourcepub fn new(
account_hash: AccountHash,
named_keys: NamedKeys,
main_purse: URef,
associated_keys: AssociatedKeys,
action_thresholds: ActionThresholds
) -> Self
pub fn new( account_hash: AccountHash, named_keys: NamedKeys, main_purse: URef, associated_keys: AssociatedKeys, action_thresholds: ActionThresholds ) -> Self
Creates a new account.
sourcepub fn create(
account: AccountHash,
named_keys: NamedKeys,
main_purse: URef
) -> Self
pub fn create( account: AccountHash, named_keys: NamedKeys, main_purse: URef ) -> Self
An Account constructor with presets for associated_keys and action_thresholds.
An account created with this method is valid and can be used as the target of a transaction.
It will be created with an AssociatedKeys
with a Weight
of 1, and a default
ActionThresholds
.
sourcepub fn extract_access_rights(&self) -> ContextAccessRights
pub fn extract_access_rights(&self) -> ContextAccessRights
Extracts the access rights from the named keys and main purse of the account.
sourcepub fn named_keys_append(&mut self, keys: &mut NamedKeys)
pub fn named_keys_append(&mut self, keys: &mut NamedKeys)
Appends named keys to an account’s named_keys field.
sourcepub fn named_keys(&self) -> &NamedKeys
pub fn named_keys(&self) -> &NamedKeys
Returns named keys.
sourcepub fn named_keys_mut(&mut self) -> &mut NamedKeys
pub fn named_keys_mut(&mut self) -> &mut NamedKeys
Returns a mutable reference to named keys.
sourcepub fn account_hash(&self) -> AccountHash
pub fn account_hash(&self) -> AccountHash
Returns account hash.
sourcepub fn main_purse(&self) -> URef
pub fn main_purse(&self) -> URef
Returns main purse.
sourcepub fn main_purse_add_only(&self) -> URef
pub fn main_purse_add_only(&self) -> URef
Returns an AccessRights::ADD
-only version of the main purse’s URef
.
sourcepub fn associated_keys(&self) -> &AssociatedKeys
pub fn associated_keys(&self) -> &AssociatedKeys
Returns associated keys.
sourcepub fn action_thresholds(&self) -> &ActionThresholds
pub fn action_thresholds(&self) -> &ActionThresholds
Returns action thresholds.
sourcepub fn add_associated_key(
&mut self,
account_hash: AccountHash,
weight: Weight
) -> Result<(), AddKeyFailure>
pub fn add_associated_key( &mut self, account_hash: AccountHash, weight: Weight ) -> Result<(), AddKeyFailure>
Adds an associated key to an account.
sourcepub fn remove_associated_key(
&mut self,
account_hash: AccountHash
) -> Result<(), RemoveKeyFailure>
pub fn remove_associated_key( &mut self, account_hash: AccountHash ) -> Result<(), RemoveKeyFailure>
Removes an associated key from an account.
Verifies that removing the key will not cause the remaining weight to fall below any action thresholds.
sourcepub fn update_associated_key(
&mut self,
account_hash: AccountHash,
weight: Weight
) -> Result<(), UpdateKeyFailure>
pub fn update_associated_key( &mut self, account_hash: AccountHash, weight: Weight ) -> Result<(), UpdateKeyFailure>
Updates an associated key.
Returns an error if the update would result in a violation of the key management thresholds.
sourcepub fn set_action_threshold(
&mut self,
action_type: ActionType,
weight: Weight
) -> Result<(), SetThresholdFailure>
pub fn set_action_threshold( &mut self, action_type: ActionType, weight: Weight ) -> Result<(), SetThresholdFailure>
Sets a new action threshold for a given action type for the account.
Returns an error if the new action threshold weight is greater than the total weight of the account’s associated keys.
sourcepub fn can_set_threshold(
&self,
new_threshold: Weight
) -> Result<(), SetThresholdFailure>
pub fn can_set_threshold( &self, new_threshold: Weight ) -> Result<(), SetThresholdFailure>
Verifies if user can set action threshold.
sourcepub fn set_action_threshold_unchecked(
&mut self,
action_type: ActionType,
threshold: Weight
) -> Result<(), SetThresholdFailure>
pub fn set_action_threshold_unchecked( &mut self, action_type: ActionType, threshold: Weight ) -> Result<(), SetThresholdFailure>
Sets a new action threshold for a given action type for the account without checking against the total weight of the associated keys.
This should only be called when authorized by an administrator account.
Returns an error if setting the action would cause the ActionType::Deployment
threshold to
be greater than any of the other action types.
Checks whether all authorization keys are associated with this account.
sourcepub fn can_deploy_with(
&self,
authorization_keys: &BTreeSet<AccountHash>
) -> bool
pub fn can_deploy_with( &self, authorization_keys: &BTreeSet<AccountHash> ) -> bool
Checks whether the sum of the weights of all authorization keys is greater or equal to deploy threshold.
sourcepub fn can_manage_keys_with(
&self,
authorization_keys: &BTreeSet<AccountHash>
) -> bool
pub fn can_manage_keys_with( &self, authorization_keys: &BTreeSet<AccountHash> ) -> bool
Checks whether the sum of the weights of all authorization keys is greater or equal to key management threshold.
Trait Implementations§
source§impl From<Account> for StoredValue
impl From<Account> for StoredValue
source§fn from(value: Account) -> StoredValue
fn from(value: Account) -> StoredValue
source§impl PartialEq for Account
impl PartialEq for Account
source§impl ToBytes for Account
impl ToBytes for Account
source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Vec<u8>
which would be returned from a successful call to
to_bytes()
or into_bytes()
. The data is not actually serialized, so this call is
relatively cheap.