Struct b3_users::data::address::UserAddressData
source · pub struct UserAddressData {
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 address data structure, including the chain_data.
Fields§
§name: String§disabled: bool§public_key: Vec<u8>§chain_data: HashMap<u64, UserChainData>Implementations§
source§impl UserAddressData
impl UserAddressData
sourcepub fn new(public_key: Vec<u8>, name: String) -> Self
pub fn new(public_key: Vec<u8>, name: String) -> Self
Creates a new AddressData with the given name and public_key.
pub fn get_chain(&self, chain_id: u64) -> Result<&UserChainData, UserStateError>
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 ChainData for a specific chain_id.
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 address 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 address 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 address. This is used for the UI to determine if the address is empty.
sourcepub fn transaction_count(&self) -> usize
pub fn transaction_count(&self) -> usize
Returns the number of transactions for the address. This is used for the UI to determine if the address 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 UserAddressData
impl CandidType for UserAddressData
source§impl Clone for UserAddressData
impl Clone for UserAddressData
source§fn clone(&self) -> UserAddressData
fn clone(&self) -> UserAddressData
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more