UserAccountData

Struct UserAccountData 

Source
pub struct UserAccountData {
    pub name: String,
    pub hidden: bool,
    pub disabled: bool,
    pub public_key: Vec<u8>,
    pub chain_data: HashMap<u64, UserChainData>,
}
Expand description

Represents the user account data structure, including the chain_data.

Fields§

§name: String§hidden: bool§disabled: bool§public_key: Vec<u8>§chain_data: HashMap<u64, UserChainData>

Implementations§

Source§

impl UserAccountData

Source

pub fn new(public_key: Vec<u8>, name: String) -> Self

Creates a new AccountData with the given name and public_key.

Source

pub fn update( &mut self, args: UserAccountArgs, ) -> Result<UserAccountArgs, UserStateError>

Update the account data with the given args. Returns an error if the public_key does not match.

Source

pub fn get_chain(&self, chain_id: u64) -> Result<&UserChainData, UserStateError>

Gets the ChainData for a specific chain_id. Returns an error if the chain_id is not found.

Source

pub fn add_transaction( &mut self, chain_id: u64, nonce: u64, transaction: UserTransactionData, ) -> Result<&UserChainData, UserStateError>

Adds a transaction to the specified chain and updates the ChainData. Returns an error if the chain_id is not found.

Source

pub fn get_transactions( &self, chain_id: u64, ) -> Result<&UserChainData, UserStateError>

Gets the transactions for a specific chain_id. Returns an error if the chain_id is not found.

Source

pub fn clear_transactions( &mut self, chain_id: u64, ) -> Result<&UserChainData, UserStateError>

Clears the transactions vector for the specified chain. Returns an error if the chain_id is not found.

Source

pub fn add_chain( &mut self, chain_id: u64, chain_data: UserChainData, ) -> Result<&UserChainData, UserStateError>

Adds a new chain to the account data. Returns an error if the chain_id is already in use.

Source

pub fn remove_chain( &mut self, chain_id: u64, ) -> Result<UserChainData, UserStateError>

Removes a chain from the account data. Returns an error if the chain_id is not found.

Source

pub fn chain_count(&self) -> usize

Returns the number of chains for the account. This is used for the UI to determine if the account is empty.

Source

pub fn transaction_count(&self) -> usize

Returns the number of transactions for the account. This is used for the UI to determine if the account is empty.

Source

pub fn chain_transaction_count(&self, chain_id: u64) -> usize

Returns the number of transactions for the specified chain. This is used for the UI to determine if the chain is empty.

Source

pub fn set_nonce( &mut self, chain_id: u64, nonce: u64, ) -> Result<&UserChainData, UserStateError>

Set Nonce for a specific chain_id. Returns an error if the chain_id is not found.

Source

pub fn get_nonce(&self, chain_id: u64) -> Result<u64, UserStateError>

Get Nonce for a specific chain_id. Returns an error if the chain_id is not found.

Source

pub fn get_transaction( &self, chain_id: u64, index: usize, ) -> Result<&UserTransactionData, UserStateError>

Get Transaction for a specific chain_id and index. Returns an error if the chain_id is not found.

Trait Implementations§

Source§

impl CandidType for UserAccountData

Source§

fn _ty() -> Type

Source§

fn id() -> TypeId

Source§

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

Source§

fn ty() -> Type

Source§

impl Clone for UserAccountData

Source§

fn clone(&self) -> UserAccountData

Returns a duplicate 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 UserAccountData

Source§

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

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

impl<'de> Deserialize<'de> for UserAccountData

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,