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§disabled: bool§public_key: Vec<u8>§chain_data: HashMap<u64, UserChainData>Implementations§
Source§impl UserAccountData
impl UserAccountData
Sourcepub fn new(public_key: Vec<u8>, name: String) -> Self
pub fn new(public_key: Vec<u8>, name: String) -> Self
Creates a new AccountData with the given name and public_key.
Sourcepub fn update(
&mut self,
args: UserAccountArgs,
) -> Result<UserAccountArgs, UserStateError>
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.
Sourcepub fn get_chain(&self, chain_id: u64) -> Result<&UserChainData, UserStateError>
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.
Sourcepub fn add_transaction(
&mut self,
chain_id: u64,
nonce: u64,
transaction: UserTransactionData,
) -> Result<&UserChainData, UserStateError>
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.
Sourcepub fn get_transactions(
&self,
chain_id: u64,
) -> Result<&UserChainData, UserStateError>
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.
Sourcepub fn clear_transactions(
&mut self,
chain_id: u64,
) -> Result<&UserChainData, UserStateError>
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.
Sourcepub fn add_chain(
&mut self,
chain_id: u64,
chain_data: UserChainData,
) -> Result<&UserChainData, UserStateError>
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.
Sourcepub fn remove_chain(
&mut self,
chain_id: u64,
) -> Result<UserChainData, UserStateError>
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.
Sourcepub fn chain_count(&self) -> usize
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.
Sourcepub fn transaction_count(&self) -> usize
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.
Sourcepub fn chain_transaction_count(&self, chain_id: u64) -> usize
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.
Sourcepub fn set_nonce(
&mut self,
chain_id: u64,
nonce: u64,
) -> Result<&UserChainData, UserStateError>
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.
Sourcepub fn get_nonce(&self, chain_id: u64) -> Result<u64, UserStateError>
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.
Sourcepub fn get_transaction(
&self,
chain_id: u64,
index: usize,
) -> Result<&UserTransactionData, UserStateError>
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
impl CandidType for UserAccountData
Source§impl Clone for UserAccountData
impl Clone for UserAccountData
Source§fn clone(&self) -> UserAccountData
fn clone(&self) -> UserAccountData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more