pub struct Account { /* private fields */ }
Expand description

Represents an Account in the global state.

Implementations§

source§

impl Account

source

pub fn new( account_hash: AccountHash, named_keys: NamedKeys, main_purse: URef, associated_keys: AssociatedKeys, action_thresholds: ActionThresholds ) -> Self

Creates a new account.

source

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.

source

pub fn extract_access_rights(&self) -> ContextAccessRights

Extracts the access rights from the named keys and main purse of the account.

source

pub fn named_keys_append(&mut self, keys: &mut NamedKeys)

Appends named keys to an account’s named_keys field.

source

pub fn named_keys(&self) -> &NamedKeys

Returns named keys.

source

pub fn named_keys_mut(&mut self) -> &mut NamedKeys

Returns a mutable reference to named keys.

source

pub fn account_hash(&self) -> AccountHash

Returns account hash.

source

pub fn main_purse(&self) -> URef

Returns main purse.

source

pub fn main_purse_add_only(&self) -> URef

Returns an AccessRights::ADD-only version of the main purse’s URef.

source

pub fn associated_keys(&self) -> &AssociatedKeys

Returns associated keys.

source

pub fn action_thresholds(&self) -> &ActionThresholds

Returns action thresholds.

source

pub fn add_associated_key( &mut self, account_hash: AccountHash, weight: Weight ) -> Result<(), AddKeyFailure>

Adds an associated key to an account.

source

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.

source

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.

source

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.

source

pub fn can_set_threshold( &self, new_threshold: Weight ) -> Result<(), SetThresholdFailure>

Verifies if user can set action threshold.

source

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.

source

pub fn can_authorize(&self, authorization_keys: &BTreeSet<AccountHash>) -> bool

Checks whether all authorization keys are associated with this account.

source

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.

source

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 Clone for Account

source§

fn clone(&self) -> Account

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Account

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Account> for StoredValue

source§

fn from(value: Account) -> StoredValue

Converts to this type from the input type.
source§

impl FromBytes for Account

source§

fn from_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

Deserializes the slice into Self.
source§

fn from_vec(bytes: Vec<u8>) -> Result<(Self, Vec<u8>), Error>

Deserializes the Vec<u8> into Self.
source§

impl PartialEq for Account

source§

fn eq(&self, other: &Account) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Account

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ToBytes for Account

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

Serializes &self to a Vec<u8>.
source§

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.
source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

Writes &self into a mutable writer.
source§

fn into_bytes(self) -> Result<Vec<u8>, Error>where Self: Sized,

Consumes self and serializes to a Vec<u8>.
source§

impl TryFrom<StoredValue> for Account

§

type Error = TypeMismatch

The type returned in the event of a conversion error.
source§

fn try_from(stored_value: StoredValue) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Account

source§

impl StructuralEq for Account

source§

impl StructuralPartialEq for Account

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.