Struct casper_types::account::Account
source · [−]pub struct Account { /* private fields */ }
Expand description
Represents an Account in the global state.
Implementations
sourceimpl 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
sourceimpl From<Account> for StoredValue
impl From<Account> for StoredValue
sourcefn from(value: Account) -> StoredValue
fn from(value: Account) -> StoredValue
Converts to this type from the input type.
sourceimpl ToBytes for Account
impl ToBytes for Account
sourcefn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Returns the length of the 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. Read more
sourceimpl TryFrom<StoredValue> for Account
impl TryFrom<StoredValue> for Account
type Error = TypeMismatch
type Error = TypeMismatch
The type returned in the event of a conversion error.
sourcefn try_from(stored_value: StoredValue) -> Result<Self, Self::Error>
fn try_from(stored_value: StoredValue) -> Result<Self, Self::Error>
Performs the conversion.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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,
Causes 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,
Causes self
to use its Display
implementation when
Debug
-formatted. Read more
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Causes self
to use its LowerExp
implementation when
Debug
-formatted. Read more
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Causes self
to use its LowerHex
implementation when
Debug
-formatted. Read more
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Causes 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,
Causes self
to use its Pointer
implementation when
Debug
-formatted. Read more
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Causes self
to use its UpperExp
implementation when
Debug
-formatted. Read more
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Causes self
to use its UpperHex
implementation when
Debug
-formatted. Read more
impl<T> PipeAsRef for T
impl<T> PipeAsRef for T
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more
impl<T> PipeBorrow for T
impl<T> PipeBorrow for T
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more
impl<T> PipeDeref for T
impl<T> PipeDeref for T
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
Pipes a dereference into a function that cannot normally be called in suffix position. Read more
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more
impl<T> PipeRef for T
impl<T> PipeRef for T
impl<T> Tap for T
impl<T> Tap for T
fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
Provides immutable access for inspection. Read more
fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
Calls tap
in debug builds, and does nothing in release builds.
fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
Provides mutable access for modification. Read more
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
Calls tap_mut
in debug builds, and does nothing in release builds.
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
fn tap_ref<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Provides immutable access to the reference for inspection.
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Calls tap_ref
in debug builds, and does nothing in release builds.
fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the reference for modification.
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Calls tap_ref_mut
in debug builds, and does nothing in release builds.
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Provides immutable access to the borrow for inspection. Read more
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Calls tap_borrow
in debug builds, and does nothing in release builds.
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the borrow for modification.
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Calls tap_borrow_mut
in debug builds, and does nothing in release
builds. Read more
impl<T> TapDeref for T
impl<T> TapDeref for T
fn tap_deref<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Immutably dereferences self
for inspection.
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Calls tap_deref
in debug builds, and does nothing in release builds.
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Mutably dereferences self
for modification.
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Calls tap_deref_mut
in debug builds, and does nothing in release
builds. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more