Wallet

Trait Wallet 

Source
pub trait Wallet {
    type Wallet: WalletInfo;
    type Account: WalletAccountInfo;

    // Required methods
    fn wallet(&self) -> Self::Wallet;
    fn wallet_account(&self) -> Option<Self::Account>;

    // Provided methods
    fn name(&self) -> String { ... }
    fn icon(&self) -> String { ... }
    fn connected(&self) -> bool { ... }
    fn try_public_key(&self) -> Option<Vec<u8>> { ... }
    fn public_key(&self) -> Vec<u8>  { ... }
}
Expand description

The core trait for wallet implementations.

This trait provides access to wallet information and the currently connected account. It serves as the foundation for all wallet functionality and is extended by other traits like WalletStandardConnect and WalletStandardDisconnect.

§Example

struct MyWallet {
    wallet_info: MyWalletInfo,
    current_account: Option<MyAccount>,
}

impl Wallet for MyWallet {
    type Wallet = MyWalletInfo;
    type Account = MyAccount;

    fn wallet(&self) -> Self::Wallet {
        self.wallet_info.clone()
    }

    fn wallet_account(&self) -> Option<Self::Account> {
        self.current_account.clone()
    }
}

Required Associated Types§

Required Methods§

Source

fn wallet(&self) -> Self::Wallet

Returns the wallet information.

This provides access to metadata about the wallet, such as its name, icon, supported chains, and features.

Source

fn wallet_account(&self) -> Option<Self::Account>

Returns the currently connected account, if any.

If no account is connected, this returns None.

Provided Methods§

Source

fn name(&self) -> String

Returns the name of the wallet.

This is a convenience method that delegates to wallet().name().

Source

fn icon(&self) -> String

Returns the icon of the wallet.

This is a convenience method that delegates to wallet().icon().

Source

fn connected(&self) -> bool

Returns whether the wallet is connected.

A wallet is considered connected if it has a current account.

Source

fn try_public_key(&self) -> Option<Vec<u8>>

Returns the public key of the currently connected account, if any.

If no account is connected, this returns None.

Source

fn public_key(&self) -> Vec<u8>

Returns the public key of the currently connected account.

§Panics

This method will panic if no account is connected. Use try_public_key() if you want to handle the case where no account is connected.

Implementors§