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 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.
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<Account> for Account
impl PartialEq<Account> 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.source§impl TryFrom<StoredValue> for Account
impl TryFrom<StoredValue> for Account
§type Error = TypeMismatch
type Error = TypeMismatch
impl Eq for Account
impl StructuralEq for Account
impl StructuralPartialEq for Account
Auto Trait Implementations§
impl RefUnwindSafe for Account
impl Send for Account
impl Sync for Account
impl Unpin for Account
impl UnwindSafe for Account
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§impl<T> Pipe for T
impl<T> Pipe for T
§impl<T> PipeAsRef for T
impl<T> PipeAsRef for T
§impl<T> PipeBorrow for T
impl<T> PipeBorrow for T
§impl<T> PipeDeref for T
impl<T> PipeDeref for T
§impl<T> PipeRef for T
impl<T> PipeRef for T
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
§fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
fn tap<F, R>(self, func: F) -> Selfwhere F: FnOnce(&Self) -> R,
§fn tap_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Selfwhere F: FnOnce(&Self) -> R,
tap in debug builds, and does nothing in release builds.§fn tap_mut<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Selfwhere F: FnOnce(&mut Self) -> R,
§fn tap_mut_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Selfwhere F: FnOnce(&mut Self) -> R,
tap_mut in debug builds, and does nothing in release builds.§impl<T, U> TapAsRef<U> for Twhere
U: ?Sized,
impl<T, U> TapAsRef<U> for Twhere U: ?Sized,
§fn tap_ref<F, R>(self, func: F) -> Selfwhere
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref<F, R>(self, func: F) -> Selfwhere Self: AsRef<T>, F: FnOnce(&T) -> R,
§fn tap_ref_dbg<F, R>(self, func: F) -> Selfwhere
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref_dbg<F, R>(self, func: F) -> Selfwhere Self: AsRef<T>, F: FnOnce(&T) -> R,
tap_ref in debug builds, and does nothing in release builds.§fn tap_ref_mut<F, R>(self, func: F) -> Selfwhere
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut<F, R>(self, func: F) -> Selfwhere Self: AsMut<T>, F: FnOnce(&mut T) -> R,
§fn tap_ref_mut_dbg<F, R>(self, func: F) -> Selfwhere
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Selfwhere Self: AsMut<T>, F: FnOnce(&mut T) -> R,
tap_ref_mut in debug builds, and does nothing in release builds.§impl<T, U> TapBorrow<U> for Twhere
U: ?Sized,
impl<T, U> TapBorrow<U> for Twhere U: ?Sized,
§fn tap_borrow<F, R>(self, func: F) -> Selfwhere
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow<F, R>(self, func: F) -> Selfwhere Self: Borrow<T>, F: FnOnce(&T) -> R,
§fn tap_borrow_dbg<F, R>(self, func: F) -> Selfwhere
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow_dbg<F, R>(self, func: F) -> Selfwhere Self: Borrow<T>, F: FnOnce(&T) -> R,
tap_borrow in debug builds, and does nothing in release builds.§fn tap_borrow_mut<F, R>(self, func: F) -> Selfwhere
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Selfwhere Self: BorrowMut<T>, F: FnOnce(&mut T) -> R,
§fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Selfwhere
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Selfwhere Self: BorrowMut<T>, F: FnOnce(&mut T) -> R,
tap_borrow_mut in debug builds, and does nothing in release
builds.§impl<T> TapDeref for T
impl<T> TapDeref for T
§fn tap_deref<F, R>(self, func: F) -> Selfwhere
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref<F, R>(self, func: F) -> Selfwhere Self: Deref, F: FnOnce(&Self::Target) -> R,
self for inspection.§fn tap_deref_dbg<F, R>(self, func: F) -> Selfwhere
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Selfwhere Self: Deref, F: FnOnce(&Self::Target) -> R,
tap_deref in debug builds, and does nothing in release builds.§fn tap_deref_mut<F, R>(self, func: F) -> Selfwhere
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Selfwhere Self: DerefMut, F: FnOnce(&mut Self::Target) -> R,
self for modification.§fn tap_deref_mut_dbg<F, R>(self, func: F) -> Selfwhere
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Selfwhere Self: DerefMut, F: FnOnce(&mut Self::Target) -> R,
tap_deref_mut in debug builds, and does nothing in release
builds.