Struct WalletAdapter

Source
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

Source

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.

Source

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.

Source

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

Source

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.

Source

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

Source

pub async fn connect(&mut self, wallet: Wallet) -> WalletResult<WalletAccount>

Send a connect request to the browser wallet

Source

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

Source

pub async fn disconnect(&mut self)

Send a disconnect request to the browser wallet

Source

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

Source

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

Source

pub async fn sign_transaction( &self, transaction_bytes: &[u8], cluster: Option<Cluster>, ) -> WalletResult<Vec<Vec<u8>>>

Send a connect request to the browser wallet

Source

pub async fn sign_message<'a>( &self, message: &'a [u8], ) -> WalletResult<SignedMessageOutput<'a>>

Send a sign message request to the browser wallet

Source

pub async fn is_connected(&self) -> bool

Check if an account is connected

Source

pub async fn connection_info(&self) -> RwLockReadGuard<'_, ConnectionInfo>

Get the connected ConnectionInfo containing the account and wallet

Source

pub fn get_entry(&self, property: &str) -> Option<Object>

Get an entry in the Window object

Source

pub fn window(&self) -> &Window

Get the browser window

Source

pub fn document(&self) -> &Document

Get the browser document

Source

pub fn storage(&self) -> &WalletStorage

Get the storage where the adapter stores the registered wallets

Source

pub async fn clusters(&self) -> WalletResult<Vec<Cluster>>

Get the clusters supported by the connected wallet

Source

pub fn wallets(&self) -> Vec<Wallet>

Get the registered wallets

Source

pub fn get_wallet(&self, wallet_name: &str) -> WalletResult<Wallet>

Get a certain wallet by its name

Source

pub async fn mainnet(&self) -> WalletResult<bool>

Check if the connected wallet supports mainnet cluster

Source

pub async fn devnet(&self) -> WalletResult<bool>

Check if the connected wallet supports devnet cluster

Source

pub async fn testnet(&self) -> WalletResult<bool>

Check if the connected wallet supports testnet cluster

Source

pub async fn localnet(&self) -> WalletResult<bool>

Check if the connected wallet supports localnet cluster

Source

pub async fn standard_connect(&self) -> WalletResult<bool>

Check if the connected wallet supports standard:connect feature

Source

pub async fn standard_disconnect(&self) -> WalletResult<bool>

Check if the connected wallet supports standard:disconnect feature

Source

pub async fn standard_events(&self) -> WalletResult<bool>

Check if the connected wallet supports standard:events feature

Source

pub async fn solana_signin(&self) -> WalletResult<bool>

Check if the connected wallet supports solana:signIn feature

Source

pub async fn solana_sign_message(&self) -> WalletResult<bool>

Check if the connected wallet supports solana:signMessage feature

Source

pub async fn solana_sign_and_send_transaction(&self) -> WalletResult<bool>

Check if the connected wallet supports solana:signAndSendTransaction feature

Source

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

Source§

fn clone(&self) -> WalletAdapter

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 WalletAdapter

Source§

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

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

impl PartialEq for WalletAdapter

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for WalletAdapter

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V