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§hidden: bool§disabled: bool§public_key: Vec<u8>§chain_data: HashMap<u64, UserChainData>

Implementations§

source§

impl UserAddressData

source

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

Creates a new AddressData with the given name and public_key.

source

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

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 ChainData for a specific chain_id.

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 address 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 address 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 address. This is used for the UI to determine if the address is empty.

source

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.

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 UserAddressData

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 UserAddressData

source§

fn clone(&self) -> UserAddressData

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 UserAddressData

source§

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

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

impl<'de> Deserialize<'de> for UserAddressData

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 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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<T> 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.
source§

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