solana_web3_sys/
wallet.rs

1//!
2//! `WalletAdapter` class bindings.
3//!
4
5use crate::imports::*;
6use crate::prelude::Connection;
7use crate::transaction::*;
8
9#[wasm_bindgen]
10extern "C" {
11    #[wasm_bindgen(js_namespace=solanaWeb3, js_name = PhantomWalletAdapter)]
12    #[derive(Debug, Clone)]
13    /// WalletAdapter
14    ///
15    pub type WalletAdapter;
16
17    #[wasm_bindgen(getter, method, js_namespace=solanaWeb3, js_name = "publicKey")]
18    /// get pubKey
19    ///
20    pub fn pubkey(this: &WalletAdapter) -> JsValue;
21
22    #[wasm_bindgen(method, catch, js_namespace=solanaWeb3, js_name = "signTransaction")]
23    /// sign transaction
24    ///
25    pub async fn sign_transaction_impl(this: &WalletAdapter, tx: Transaction) -> Result<JsValue>;
26
27    #[wasm_bindgen(method, catch, js_namespace=solanaWeb3, js_name = "signAndSendTransaction")]
28    /// sign and send transaction
29    ///
30    pub async fn sign_and_send_transaction(
31        this: &WalletAdapter,
32        tx: Transaction,
33    ) -> Result<JsValue>;
34
35    #[wasm_bindgen(method, catch, js_namespace=solanaWeb3, js_name = "sendTransaction")]
36    /// send transaction
37    ///
38    pub async fn send_transaction(
39        this: &WalletAdapter,
40        tx: Transaction,
41        con: Connection,
42    ) -> Result<JsValue>;
43}
44
45impl WalletAdapter {
46    pub async fn sign_transaction(&self, tx: &Transaction) -> Result<JsValue> {
47        self.sign_transaction_impl(tx.clone()).await
48    }
49}