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 named_keys_append(&mut self, keys: NamedKeys)
pub fn named_keys_append(&mut self, keys: 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 remove_named_key(&mut self, name: &str) -> Option<Key>
pub fn remove_named_key(&mut self, name: &str) -> Option<Key>
Removes the key under the given name from 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_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.
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.
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 DataSize for Account
impl DataSize for Account
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
true, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
IS_DYNAMIC is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Source§impl<'de> Deserialize<'de> for Account
impl<'de> Deserialize<'de> for Account
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<Account> for AddressableEntity
impl From<Account> for AddressableEntity
Source§impl From<Account> for StoredValue
impl From<Account> for StoredValue
Source§fn from(value: Account) -> StoredValue
fn from(value: Account) -> StoredValue
Source§impl JsonSchema for Account
impl JsonSchema for Account
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§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
Source§type Error = TypeMismatch
type Error = TypeMismatch
impl Eq for Account
impl StructuralPartialEq for Account
Auto Trait Implementations§
impl Freeze for Account
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more