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§
type Wallet: WalletInfo
type Account: WalletAccountInfo
Required Methods§
Sourcefn wallet(&self) -> Self::Wallet
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.
Sourcefn wallet_account(&self) -> Option<Self::Account>
fn wallet_account(&self) -> Option<Self::Account>
Returns the currently connected account, if any.
If no account is connected, this returns None.
Provided Methods§
Sourcefn name(&self) -> String
fn name(&self) -> String
Returns the name of the wallet.
This is a convenience method that delegates to wallet().name().
Sourcefn icon(&self) -> String
fn icon(&self) -> String
Returns the icon of the wallet.
This is a convenience method that delegates to wallet().icon().
Sourcefn connected(&self) -> bool
fn connected(&self) -> bool
Returns whether the wallet is connected.
A wallet is considered connected if it has a current account.
Sourcefn try_public_key(&self) -> Option<Vec<u8>>
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.