pub struct WalletAdapter { /* private fields */ }
Expand description
Operations on a browser window.
Window
and Document
object must be present otherwise
an error is thrown.
Implementations§
Source§impl WalletAdapter
impl WalletAdapter
Sourcepub fn init() -> WalletResult<Self>
pub fn init() -> WalletResult<Self>
Get the Window
and Document
object in the current browser window,
initialize the AppReady
and Register
events of the wallet standard
and creates a bounded channel with capacity default of 5 messages before capacity is filled.
Use WalletAdapter::init_with_channel_capacity to initialize with a desired channel capacity.
Sourcepub fn init_with_channel_capacity(capacity: usize) -> WalletResult<Self>
pub fn init_with_channel_capacity(capacity: usize) -> WalletResult<Self>
Get the Window
and Document
object in the current browser window,
initialize the AppReady
and Register
events of the wallet standard
and creates a bounded channel with user-specified capacity.
Sourcepub fn init_with_channel_capacity_window_and_document(
capacity: usize,
window: Window,
document: Document,
) -> WalletResult<Self>
pub fn init_with_channel_capacity_window_and_document( capacity: usize, window: Window, document: Document, ) -> WalletResult<Self>
Same as WalletAdapter::init but a capacity
value
can be passed to create an channel with a desired capacity
Sourcepub fn init_custom(window: Window, document: Document) -> WalletResult<Self>
pub fn init_custom(window: Window, document: Document) -> WalletResult<Self>
Initializes with a web_sys::Window and web_sys::Document that have been initialized elsewhere. For example some Rust frontend frameworks already expose the window and document objects, you could pass them here.
Sourcepub fn events(&self) -> WalletEventReceiver
pub fn events(&self) -> WalletEventReceiver
Listen for WalletEvent to be notified when a wallet
receives connected
, disconnected
and accountChanged
events triggered
when the change
event is dispatched by a connected browser extension
Sourcepub async fn connect(&mut self, wallet: Wallet) -> WalletResult<WalletAccount>
pub async fn connect(&mut self, wallet: Wallet) -> WalletResult<WalletAccount>
Send a connect request to the browser wallet
Sourcepub async fn connect_by_name(
&mut self,
wallet_name: &str,
) -> WalletResult<WalletAccount>
pub async fn connect_by_name( &mut self, wallet_name: &str, ) -> WalletResult<WalletAccount>
Lookup a wallet entry by name from the registered wallets and then send a connect request to the browser extension wallet
Sourcepub async fn disconnect(&mut self)
pub async fn disconnect(&mut self)
Send a disconnect request to the browser wallet
Sourcepub async fn sign_in(
&self,
signin_input: &SigninInput,
public_key: [u8; 32],
) -> WalletResult<SignInOutput>
pub async fn sign_in( &self, signin_input: &SigninInput, public_key: [u8; 32], ) -> WalletResult<SignInOutput>
Send a sign in request to the browser wallet to Sign In With Solana
Sourcepub async fn sign_and_send_transaction(
&self,
transaction_bytes: &[u8],
cluster: Cluster,
options: SendOptions,
) -> WalletResult<Signature>
pub async fn sign_and_send_transaction( &self, transaction_bytes: &[u8], cluster: Cluster, options: SendOptions, ) -> WalletResult<Signature>
Send a sign and send transaction request to the browser wallet
Sourcepub async fn sign_transaction(
&self,
transaction_bytes: &[u8],
cluster: Option<Cluster>,
) -> WalletResult<Vec<Vec<u8>>>
pub async fn sign_transaction( &self, transaction_bytes: &[u8], cluster: Option<Cluster>, ) -> WalletResult<Vec<Vec<u8>>>
Send a connect request to the browser wallet
Sourcepub async fn sign_message<'a>(
&self,
message: &'a [u8],
) -> WalletResult<SignedMessageOutput<'a>>
pub async fn sign_message<'a>( &self, message: &'a [u8], ) -> WalletResult<SignedMessageOutput<'a>>
Send a sign message request to the browser wallet
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if an account is connected
Sourcepub async fn connection_info(&self) -> RwLockReadGuard<'_, ConnectionInfo>
pub async fn connection_info(&self) -> RwLockReadGuard<'_, ConnectionInfo>
Get the connected ConnectionInfo containing the account and wallet
Sourcepub fn storage(&self) -> &WalletStorage
pub fn storage(&self) -> &WalletStorage
Get the storage where the adapter stores the registered wallets
Sourcepub async fn clusters(&self) -> WalletResult<Vec<Cluster>>
pub async fn clusters(&self) -> WalletResult<Vec<Cluster>>
Get the clusters supported by the connected wallet
Sourcepub fn get_wallet(&self, wallet_name: &str) -> WalletResult<Wallet>
pub fn get_wallet(&self, wallet_name: &str) -> WalletResult<Wallet>
Get a certain wallet by its name
Sourcepub async fn mainnet(&self) -> WalletResult<bool>
pub async fn mainnet(&self) -> WalletResult<bool>
Check if the connected wallet supports mainnet cluster
Sourcepub async fn devnet(&self) -> WalletResult<bool>
pub async fn devnet(&self) -> WalletResult<bool>
Check if the connected wallet supports devnet cluster
Sourcepub async fn testnet(&self) -> WalletResult<bool>
pub async fn testnet(&self) -> WalletResult<bool>
Check if the connected wallet supports testnet cluster
Sourcepub async fn localnet(&self) -> WalletResult<bool>
pub async fn localnet(&self) -> WalletResult<bool>
Check if the connected wallet supports localnet cluster
Sourcepub async fn standard_connect(&self) -> WalletResult<bool>
pub async fn standard_connect(&self) -> WalletResult<bool>
Check if the connected wallet supports standard:connect
feature
Sourcepub async fn standard_disconnect(&self) -> WalletResult<bool>
pub async fn standard_disconnect(&self) -> WalletResult<bool>
Check if the connected wallet supports standard:disconnect
feature
Sourcepub async fn standard_events(&self) -> WalletResult<bool>
pub async fn standard_events(&self) -> WalletResult<bool>
Check if the connected wallet supports standard:events
feature
Sourcepub async fn solana_signin(&self) -> WalletResult<bool>
pub async fn solana_signin(&self) -> WalletResult<bool>
Check if the connected wallet supports solana:signIn
feature
Sourcepub async fn solana_sign_message(&self) -> WalletResult<bool>
pub async fn solana_sign_message(&self) -> WalletResult<bool>
Check if the connected wallet supports solana:signMessage
feature
Sourcepub async fn solana_sign_and_send_transaction(&self) -> WalletResult<bool>
pub async fn solana_sign_and_send_transaction(&self) -> WalletResult<bool>
Check if the connected wallet supports solana:signAndSendTransaction
feature
Sourcepub async fn solana_sign_transaction(&self) -> WalletResult<bool>
pub async fn solana_sign_transaction(&self) -> WalletResult<bool>
Check if the connected wallet supports solana:signTransaction
feature
Trait Implementations§
Source§impl Clone for WalletAdapter
impl Clone for WalletAdapter
Source§fn clone(&self) -> WalletAdapter
fn clone(&self) -> WalletAdapter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more