@vue-solana/core 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -95,7 +95,7 @@ Direct subpaths:
95
95
  - `isWalletConnected(wallet)`: checks whether a wallet is connected and has a public key.
96
96
  - `assertWalletConnected(wallet)`: throws if the wallet is not connected.
97
97
  - `assertWalletCanSign(wallet)`: throws if the wallet cannot sign transactions.
98
- - `signAndSendTransaction(connection, wallet, transaction, options?)`: signs and sends a transaction using a configured wallet.
98
+ - `signAndSendTransaction(connection, wallet, transaction, options?)`: signs and sends a transaction using a configured wallet. Android Mobile Wallet Adapter wallets prefer `signTransaction` plus app-side RPC submission when available so the app can reliably return the submitted signature.
99
99
 
100
100
  ## Wallet Interface
101
101
 
@@ -4,14 +4,24 @@ const wallet = require('./wallet.cjs');
4
4
 
5
5
  async function signAndSendTransaction(connection, wallet$1, transaction, options) {
6
6
  wallet.assertWalletConnected(wallet$1);
7
+ if (isMobileWalletAdapterWallet(wallet$1) && wallet$1.signTransaction) {
8
+ wallet.assertWalletCanSign(wallet$1);
9
+ return signAndSendRawTransaction(connection, wallet$1, transaction, options);
10
+ }
7
11
  if (wallet$1.signAndSendTransaction) {
8
12
  const result = await wallet$1.signAndSendTransaction(transaction, options);
9
13
  return result.signature;
10
14
  }
11
15
  wallet.assertWalletCanSign(wallet$1);
12
- const signedTransaction = await wallet$1.signTransaction(transaction);
16
+ return signAndSendRawTransaction(connection, wallet$1, transaction, options);
17
+ }
18
+ async function signAndSendRawTransaction(connection, wallet, transaction, options) {
19
+ const signedTransaction = await wallet.signTransaction(transaction);
13
20
  const rawTransaction = signedTransaction.serialize();
14
21
  return connection.sendRawTransaction(rawTransaction, options);
15
22
  }
23
+ function isMobileWalletAdapterWallet(wallet) {
24
+ return wallet.source === "mobile-wallet-adapter";
25
+ }
16
26
 
17
27
  exports.signAndSendTransaction = signAndSendTransaction;
@@ -2,14 +2,24 @@ import { assertWalletConnected, assertWalletCanSign } from './wallet.mjs';
2
2
 
3
3
  async function signAndSendTransaction(connection, wallet, transaction, options) {
4
4
  assertWalletConnected(wallet);
5
+ if (isMobileWalletAdapterWallet(wallet) && wallet.signTransaction) {
6
+ assertWalletCanSign(wallet);
7
+ return signAndSendRawTransaction(connection, wallet, transaction, options);
8
+ }
5
9
  if (wallet.signAndSendTransaction) {
6
10
  const result = await wallet.signAndSendTransaction(transaction, options);
7
11
  return result.signature;
8
12
  }
9
13
  assertWalletCanSign(wallet);
14
+ return signAndSendRawTransaction(connection, wallet, transaction, options);
15
+ }
16
+ async function signAndSendRawTransaction(connection, wallet, transaction, options) {
10
17
  const signedTransaction = await wallet.signTransaction(transaction);
11
18
  const rawTransaction = signedTransaction.serialize();
12
19
  return connection.sendRawTransaction(rawTransaction, options);
13
20
  }
21
+ function isMobileWalletAdapterWallet(wallet) {
22
+ return wallet.source === "mobile-wallet-adapter";
23
+ }
14
24
 
15
25
  export { signAndSendTransaction };
package/dist/types.d.cts CHANGED
@@ -21,6 +21,8 @@ interface SolanaWallet {
21
21
  connected: boolean;
22
22
  connecting?: boolean;
23
23
  disconnecting?: boolean;
24
+ platform?: SolanaWalletInfo["platform"];
25
+ source?: SolanaWalletInfo["source"];
24
26
  connect: () => Promise<void>;
25
27
  disconnect: () => Promise<void>;
26
28
  signTransaction?: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
package/dist/types.d.mts CHANGED
@@ -21,6 +21,8 @@ interface SolanaWallet {
21
21
  connected: boolean;
22
22
  connecting?: boolean;
23
23
  disconnecting?: boolean;
24
+ platform?: SolanaWalletInfo["platform"];
25
+ source?: SolanaWalletInfo["source"];
24
26
  connect: () => Promise<void>;
25
27
  disconnect: () => Promise<void>;
26
28
  signTransaction?: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
package/dist/types.d.ts CHANGED
@@ -21,6 +21,8 @@ interface SolanaWallet {
21
21
  connected: boolean;
22
22
  connecting?: boolean;
23
23
  disconnecting?: boolean;
24
+ platform?: SolanaWalletInfo["platform"];
25
+ source?: SolanaWalletInfo["source"];
24
26
  connect: () => Promise<void>;
25
27
  disconnect: () => Promise<void>;
26
28
  signTransaction?: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
@@ -62,6 +62,8 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
62
62
  }
63
63
  });
64
64
  return {
65
+ platform: walletInfo.platform,
66
+ source: walletInfo.source,
65
67
  get publicKey() {
66
68
  return account ? new web3Compat.PublicKey(account.publicKey) : null;
67
69
  },
@@ -56,6 +56,8 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
56
56
  }
57
57
  });
58
58
  return {
59
+ platform: walletInfo.platform,
60
+ source: walletInfo.source,
59
61
  get publicKey() {
60
62
  return account ? new PublicKey(account.publicKey) : null;
61
63
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-solana/core",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Framework-agnostic primitives for Vue Solana libraries.",
5
5
  "license": "MIT",
6
6
  "keywords": [