@vue-solana/vue 0.6.1 → 0.8.0

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.
Files changed (80) hide show
  1. package/README.md +39 -3
  2. package/dist/index.cjs +71 -34
  3. package/dist/index.d.cts +3 -1
  4. package/dist/index.d.mts +3 -1
  5. package/dist/index.d.ts +3 -1
  6. package/dist/index.mjs +69 -34
  7. package/dist/shared/{vue.DYf_CRDv.mjs → vue.5sF8eKgx.mjs} +30 -5
  8. package/dist/shared/{vue.BPnK_lsh.cjs → vue.BBoDTIfF.cjs} +6 -4
  9. package/dist/shared/{vue.DQhHHVu6.mjs → vue.BDl2vVkp.mjs} +10 -4
  10. package/dist/shared/{vue.DHVYJk8P.cjs → vue.BeA8WQ2g.cjs} +4 -2
  11. package/dist/shared/{vue.RQ9fETnm.mjs → vue.BlfFUgC-.mjs} +20 -28
  12. package/dist/shared/{vue.DEQJ23UM.cjs → vue.BnSjOzvb.cjs} +21 -29
  13. package/dist/shared/{vue.JC5FdU2O.mjs → vue.BzopW_4m.mjs} +8 -6
  14. package/dist/shared/{vue.gLqkzJY4.mjs → vue.C4d2JA8U.mjs} +7 -23
  15. package/dist/shared/{vue.DQi38JeF.cjs → vue.CE5i8KZZ.cjs} +6 -23
  16. package/dist/shared/{vue.7TzeDJZX.mjs → vue.Cl3hXlXK.mjs} +6 -4
  17. package/dist/shared/{vue.jOsz34kz.mjs → vue.CxMrojxC.mjs} +4 -2
  18. package/dist/shared/{vue.CUTLu1Gf.mjs → vue.CzTu_DPr.mjs} +4 -2
  19. package/dist/shared/{vue.dmuispJ3.cjs → vue.D1JtJ2lD.cjs} +4 -2
  20. package/dist/shared/{vue.DGhodYJh.d.cts → vue.DL3z5PxP.d.cts} +2 -1
  21. package/dist/shared/{vue.DGhodYJh.d.mts → vue.DL3z5PxP.d.mts} +2 -1
  22. package/dist/shared/{vue.DGhodYJh.d.ts → vue.DL3z5PxP.d.ts} +2 -1
  23. package/dist/shared/{vue.DUufwq8y.cjs → vue.DRlaqQCL.cjs} +8 -6
  24. package/dist/shared/vue.DfeKj9vL.cjs +94 -0
  25. package/dist/shared/vue.DuI_Jm5P.cjs +63 -0
  26. package/dist/shared/{vue.D_AM1Nl8.cjs → vue.NFoc_-Kt.cjs} +13 -7
  27. package/dist/shared/vue.PTQ2iRAi.mjs +61 -0
  28. package/dist/useAccountInfo.cjs +2 -1
  29. package/dist/useAccountInfo.d.cts +2 -1
  30. package/dist/useAccountInfo.d.mts +2 -1
  31. package/dist/useAccountInfo.d.ts +2 -1
  32. package/dist/useAccountInfo.mjs +2 -1
  33. package/dist/useBalance.cjs +3 -2
  34. package/dist/useBalance.d.cts +2 -1
  35. package/dist/useBalance.d.mts +2 -1
  36. package/dist/useBalance.d.ts +2 -1
  37. package/dist/useBalance.mjs +3 -2
  38. package/dist/useProgramAccounts.cjs +2 -1
  39. package/dist/useProgramAccounts.d.cts +2 -1
  40. package/dist/useProgramAccounts.d.mts +2 -1
  41. package/dist/useProgramAccounts.d.ts +2 -1
  42. package/dist/useProgramAccounts.mjs +2 -1
  43. package/dist/useRpc.d.cts +3 -2
  44. package/dist/useRpc.d.mts +3 -2
  45. package/dist/useRpc.d.ts +3 -2
  46. package/dist/useSignAndSendTransaction.cjs +6 -3
  47. package/dist/useSignAndSendTransaction.d.cts +2 -1
  48. package/dist/useSignAndSendTransaction.d.mts +2 -1
  49. package/dist/useSignAndSendTransaction.d.ts +2 -1
  50. package/dist/useSignAndSendTransaction.mjs +6 -3
  51. package/dist/useSignMessage.cjs +12 -0
  52. package/dist/useSignMessage.d.cts +236 -0
  53. package/dist/useSignMessage.d.mts +236 -0
  54. package/dist/useSignMessage.d.ts +236 -0
  55. package/dist/useSignMessage.mjs +6 -0
  56. package/dist/useSignatureStatus.cjs +2 -1
  57. package/dist/useSignatureStatus.d.cts +2 -1
  58. package/dist/useSignatureStatus.d.mts +2 -1
  59. package/dist/useSignatureStatus.d.ts +2 -1
  60. package/dist/useSignatureStatus.mjs +2 -1
  61. package/dist/useSolana.d.cts +2 -1
  62. package/dist/useSolana.d.mts +2 -1
  63. package/dist/useSolana.d.ts +2 -1
  64. package/dist/useTransaction.cjs +3 -1
  65. package/dist/useTransaction.d.cts +2 -1
  66. package/dist/useTransaction.d.mts +2 -1
  67. package/dist/useTransaction.d.ts +2 -1
  68. package/dist/useTransaction.mjs +3 -1
  69. package/dist/useTransactionConfirmation.cjs +2 -1
  70. package/dist/useTransactionConfirmation.d.cts +2 -1
  71. package/dist/useTransactionConfirmation.d.mts +2 -1
  72. package/dist/useTransactionConfirmation.d.ts +2 -1
  73. package/dist/useTransactionConfirmation.mjs +2 -1
  74. package/dist/useWallet.cjs +3 -1
  75. package/dist/useWallet.d.cts +14 -0
  76. package/dist/useWallet.d.mts +14 -0
  77. package/dist/useWallet.d.ts +14 -0
  78. package/dist/useWallet.mjs +3 -1
  79. package/package.json +7 -2
  80. package/dist/shared/vue.CwPjPFN6.cjs +0 -69
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Vue plugin and composables for Solana applications.
4
4
 
5
- Use this package in Vue 3 apps that need Solana RPC access, balance reads, wallet state, and transaction helper state.
5
+ Use this package in Vue 3 apps that need Solana RPC access, balance reads, wallet state, message signing, and transaction helper state.
6
6
 
7
7
  New to Solana? Start with the official docs and the project concepts guide:
8
8
 
@@ -68,6 +68,7 @@ The root export remains supported. For composables, prefer direct subpath import
68
68
  ```ts
69
69
  import { useRpc } from "@vue-solana/vue/useRpc";
70
70
  import { useWallet } from "@vue-solana/vue/useWallet";
71
+ import { useSignMessage } from "@vue-solana/vue/useSignMessage";
71
72
  ```
72
73
 
73
74
  For development, use `devnet` and request free test SOL from the official faucet:
@@ -146,7 +147,7 @@ import { useWallet } from "@vue-solana/vue/useWallet";
146
147
  import { useWallets } from "@vue-solana/vue/useWallets";
147
148
 
148
149
  const { wallets, selectedWallet, selectWallet, refreshWallets } = useWallets();
149
- const { publicKey, connected, connecting, connect, disconnect } = useWallet();
150
+ const { publicKey, connected, connecting, canSignMessage, connect, disconnect } = useWallet();
150
151
  </script>
151
152
 
152
153
  <template>
@@ -163,6 +164,7 @@ const { publicKey, connected, connecting, connect, disconnect } = useWallet();
163
164
  <p>Selected: {{ selectedWallet?.name ?? "None" }}</p>
164
165
  <p>Connected: {{ connected }}</p>
165
166
  <p>Public key: {{ publicKey?.toBase58() }}</p>
167
+ <p>Can sign messages: {{ canSignMessage }}</p>
166
168
  <p v-if="connecting">Connecting...</p>
167
169
  <button type="button" :disabled="!selectedWallet || connected || connecting" @click="connect">
168
170
  Connect
@@ -180,6 +182,38 @@ Desktop native app wallet adapters are planned but not implemented yet.
180
182
 
181
183
  Composables return inert SSR-safe state when no plugin context is available. Real RPC and wallet operations still require the plugin-provided client context.
182
184
 
185
+ ## Message Signing
186
+
187
+ ```vue
188
+ <script setup lang="ts">
189
+ import { computed } from "vue";
190
+ import { useSignMessage } from "@vue-solana/vue/useSignMessage";
191
+ import { useWallet } from "@vue-solana/vue/useWallet";
192
+
193
+ const { connected, canSignMessage } = useWallet();
194
+ const { signature, status, error, execute } = useSignMessage();
195
+
196
+ const message = computed(() => new TextEncoder().encode("Sign in to My Vue Solana App"));
197
+
198
+ async function signIn() {
199
+ await execute(message.value);
200
+ }
201
+ </script>
202
+
203
+ <template>
204
+ <section>
205
+ <button type="button" :disabled="!connected || !canSignMessage" @click="signIn">
206
+ Sign message
207
+ </button>
208
+ <p>Status: {{ status }}</p>
209
+ <p v-if="signature">Signature bytes: {{ signature.length }}</p>
210
+ <pre v-if="error">{{ error.message }}</pre>
211
+ </section>
212
+ </template>
213
+ ```
214
+
215
+ Message signing proves wallet ownership for flows like authentication challenges. It does not sign, submit, or authorize Solana transactions. For authentication, issue a server-generated nonce, include domain and expiration details in the message, and verify the returned signature server-side.
216
+
183
217
  ## Transaction State
184
218
 
185
219
  ```ts
@@ -241,6 +275,7 @@ Docs: [Vue Solana Agent Skill](https://vue-solana-docs.vercel.app/agent-skill)
241
275
  - `useConnection()`: returns the Solana `Connection`.
242
276
  - `useWallet()`: returns wallet refs, computed connection state, and wallet actions.
243
277
  - `useWallets()`: returns discovered browser extension wallets, Android Mobile Wallet Adapter wallets, iOS browser wallet links, and wallet selection actions.
278
+ - `useSignMessage()`: signs arbitrary message bytes through the connected wallet when message signing is supported.
244
279
  - `useBalance(address, commitment?)`: loads lamport balance for a `PublicKey` or address string.
245
280
  - `useAccountInfo(address, options?)`: loads account info and can subscribe to account changes with `watch: true`.
246
281
  - `useProgramAccounts(programId, config?)`: loads accounts owned by a program with optional filters, commitment, and `dataSlice`.
@@ -259,6 +294,7 @@ Direct composable subpaths:
259
294
  - `@vue-solana/vue/useProgramAccounts`
260
295
  - `@vue-solana/vue/useWallet`
261
296
  - `@vue-solana/vue/useWallets`
297
+ - `@vue-solana/vue/useSignMessage`
262
298
  - `@vue-solana/vue/useTransaction`
263
299
  - `@vue-solana/vue/useTransactionConfirmation`
264
300
  - `@vue-solana/vue/useSignatureStatus`
@@ -297,4 +333,4 @@ Make sure your `tsconfig.json` includes `types/**/*.d.ts` or another pattern tha
297
333
 
298
334
  ## Status
299
335
 
300
- This package is early-stage. RPC, balance, browser extension wallet, Android mobile wallet, and transaction composables are usable.
336
+ This package is early-stage. RPC, balance, browser extension wallet, Android mobile wallet, iOS browser wallet, message signing, and transaction composables are usable.
package/dist/index.cjs CHANGED
@@ -1,51 +1,62 @@
1
1
  'use strict';
2
2
 
3
- const useAccountInfo = require('./shared/vue.BPnK_lsh.cjs');
4
- const useBalance = require('./shared/vue.D_AM1Nl8.cjs');
3
+ const useAccountInfo = require('./shared/vue.BBoDTIfF.cjs');
4
+ const useBalance = require('./shared/vue.NFoc_-Kt.cjs');
5
5
  const useConnection = require('./shared/vue.CwhEmATP.cjs');
6
- const useProgramAccounts = require('./shared/vue.dmuispJ3.cjs');
6
+ const useProgramAccounts = require('./shared/vue.D1JtJ2lD.cjs');
7
7
  const useRpc = require('./shared/vue.COyyrsQU.cjs');
8
- const useSignAndSendTransaction = require('./shared/vue.DEQJ23UM.cjs');
9
- const useSignatureStatus = require('./shared/vue.DUufwq8y.cjs');
8
+ const useSignMessage = require('./shared/vue.DuI_Jm5P.cjs');
9
+ const useSignAndSendTransaction = require('./shared/vue.BnSjOzvb.cjs');
10
+ const useSignatureStatus = require('./shared/vue.DRlaqQCL.cjs');
10
11
  const useSolana = require('./shared/vue.C4tLiG3R.cjs');
11
- const useTransaction = require('./shared/vue.DQi38JeF.cjs');
12
- const useTransactionConfirmation = require('./shared/vue.DHVYJk8P.cjs');
13
- const useWallet = require('./shared/vue.CwPjPFN6.cjs');
12
+ const useTransaction = require('./shared/vue.CE5i8KZZ.cjs');
13
+ const useTransactionConfirmation = require('./shared/vue.BeA8WQ2g.cjs');
14
+ const useWallet = require('./shared/vue.DfeKj9vL.cjs');
14
15
  const useWallets = require('./shared/vue.P9tgeC5S.cjs');
16
+ const errors = require('@vue-solana/core/errors');
15
17
  const rpc = require('@vue-solana/core/rpc');
18
+ const timeout = require('@vue-solana/core/timeout');
16
19
  const walletStandard = require('@vue-solana/core/wallet-standard');
17
20
  const vue = require('vue');
18
21
  const iosWallet = require('@vue-solana/core/ios-wallet');
19
22
  require('@vue-solana/core/address');
20
- require('@solana/web3-compat');
23
+ require('@vue-solana/core/wallet');
21
24
  require('@vue-solana/core/transaction');
22
25
  require('bs58');
23
26
 
24
27
  const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
25
28
  function readSelectedWallet() {
26
- const storage = getLocalStorage();
27
- if (!storage) {
28
- return null;
29
+ const { storage, error } = getLocalStorage();
30
+ if (error || !storage) {
31
+ return { wallet: null, error };
29
32
  }
30
33
  try {
31
34
  const value = storage.getItem(SELECTED_WALLET_STORAGE_KEY);
32
35
  if (!value) {
33
- return null;
36
+ return { wallet: null, error: null };
34
37
  }
35
38
  const wallet = JSON.parse(value);
36
- return typeof wallet.name === "string" ? {
37
- name: wallet.name,
38
- platform: wallet.platform,
39
- source: wallet.source
40
- } : null;
41
- } catch {
42
- return null;
39
+ return {
40
+ wallet: typeof wallet.name === "string" ? {
41
+ name: wallet.name,
42
+ platform: wallet.platform,
43
+ source: wallet.source
44
+ } : null,
45
+ error: null
46
+ };
47
+ } catch (cause) {
48
+ return {
49
+ wallet: null,
50
+ error: errors.createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
51
+ cause
52
+ })
53
+ };
43
54
  }
44
55
  }
45
56
  function writeSelectedWallet(wallet) {
46
- const storage = getLocalStorage();
47
- if (!storage) {
48
- return;
57
+ const { storage, error } = getLocalStorage();
58
+ if (error || !storage) {
59
+ return error;
49
60
  }
50
61
  try {
51
62
  if (wallet) {
@@ -53,7 +64,11 @@ function writeSelectedWallet(wallet) {
53
64
  } else {
54
65
  storage.removeItem(SELECTED_WALLET_STORAGE_KEY);
55
66
  }
56
- } catch {
67
+ return null;
68
+ } catch (cause) {
69
+ return errors.createSolanaError("STORAGE_FAILURE", "Unable to persist the selected Solana wallet", {
70
+ cause
71
+ });
57
72
  }
58
73
  }
59
74
  function stringifySelectedWallet(wallet) {
@@ -68,12 +83,17 @@ function stringifySelectedWallet(wallet) {
68
83
  }
69
84
  function getLocalStorage() {
70
85
  if (typeof window === "undefined") {
71
- return null;
86
+ return { storage: null, error: null };
72
87
  }
73
88
  try {
74
- return window.localStorage;
75
- } catch {
76
- return null;
89
+ return { storage: window.localStorage, error: null };
90
+ } catch (cause) {
91
+ return {
92
+ storage: null,
93
+ error: errors.createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
94
+ cause
95
+ })
96
+ };
77
97
  }
78
98
  }
79
99
 
@@ -201,10 +221,12 @@ function createSolanaPlugin(options = {}) {
201
221
  wsEndpoint: context.wsEndpoint
202
222
  });
203
223
  try {
204
- const blockhash = await useTransaction.withTimeout(
224
+ const blockhash = await timeout.withTimeout(
205
225
  context.connection.getLatestBlockhash(),
206
226
  RPC_CHECK_TIMEOUT_MS,
207
- `RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
227
+ () => new Error(
228
+ `RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
229
+ )
208
230
  );
209
231
  if (checkId !== rpcCheckId) {
210
232
  return;
@@ -222,7 +244,7 @@ function createSolanaPlugin(options = {}) {
222
244
  return;
223
245
  }
224
246
  status.value = "error";
225
- error.value = cause instanceof Error ? cause.message : String(cause);
247
+ error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
226
248
  console.error("[Vue Solana] Connection failed", cause);
227
249
  }
228
250
  }
@@ -238,7 +260,13 @@ function createSolanaPlugin(options = {}) {
238
260
  }
239
261
  } else if (!options.wallet) {
240
262
  const persistedWallet = readSelectedWallet();
241
- restoredWallet = persistedWallet ? wallets.value.find((nextWallet) => isSameWallet(nextWallet, persistedWallet)) ?? null : null;
263
+ if (persistedWallet.error) {
264
+ error.value = persistedWallet.error;
265
+ console.error("[Vue Solana] Selected wallet restoration failed", persistedWallet.error);
266
+ }
267
+ restoredWallet = persistedWallet.wallet ? wallets.value.find(
268
+ (nextWallet) => isSameWallet(nextWallet, persistedWallet.wallet)
269
+ ) ?? null : null;
242
270
  if (restoredWallet) {
243
271
  selectedWallet.value = restoredWallet;
244
272
  wallet.value = walletRegistry.getAdaptedWallet(restoredWallet);
@@ -267,7 +295,11 @@ function createSolanaPlugin(options = {}) {
267
295
  function selectWallet(nextWallet) {
268
296
  selectedWallet.value = nextWallet;
269
297
  wallet.value = nextWallet ? walletRegistry.getAdaptedWallet(nextWallet) : options.wallet ?? null;
270
- writeSelectedWallet(nextWallet);
298
+ const storageError = writeSelectedWallet(nextWallet);
299
+ if (storageError) {
300
+ error.value = storageError;
301
+ console.error("[Vue Solana] Selected wallet persistence failed", storageError);
302
+ }
271
303
  }
272
304
  function autoConnectWallet(walletInfo) {
273
305
  if (!options.autoConnect) {
@@ -299,7 +331,11 @@ function createSolanaPlugin(options = {}) {
299
331
  setWallet(nextWallet) {
300
332
  selectedWallet.value = null;
301
333
  wallet.value = nextWallet;
302
- writeSelectedWallet(null);
334
+ const storageError = writeSelectedWallet(null);
335
+ if (storageError) {
336
+ error.value = storageError;
337
+ console.error("[Vue Solana] Selected wallet persistence failed", storageError);
338
+ }
303
339
  }
304
340
  };
305
341
  app.provide(useSolana.solanaInjectionKey, vueContext);
@@ -326,6 +362,7 @@ exports.useBalance = useBalance.useBalance;
326
362
  exports.useConnection = useConnection.useConnection;
327
363
  exports.useProgramAccounts = useProgramAccounts.useProgramAccounts;
328
364
  exports.useRpc = useRpc.useRpc;
365
+ exports.useSignMessage = useSignMessage.useSignMessage;
329
366
  exports.useSignAndSendTransaction = useSignAndSendTransaction.useSignAndSendTransaction;
330
367
  exports.useSignatureStatus = useSignatureStatus.useSignatureStatus;
331
368
  exports.solanaInjectionKey = useSolana.solanaInjectionKey;
package/dist/index.d.cts CHANGED
@@ -3,6 +3,7 @@ export { useBalance } from './useBalance.cjs';
3
3
  export { useConnection } from './useConnection.cjs';
4
4
  export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.cjs';
5
5
  export { useRpc } from './useRpc.cjs';
6
+ export { SignMessageStatus, useSignMessage } from './useSignMessage.cjs';
6
7
  export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
7
8
  export { UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.cjs';
8
9
  export { tryUseSolana, useSolana } from './useSolana.cjs';
@@ -10,12 +11,13 @@ export { UseTransactionOptions, useTransaction } from './useTransaction.cjs';
10
11
  export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.cjs';
11
12
  export { useWallet } from './useWallet.cjs';
12
13
  export { useWallets } from './useWallets.cjs';
13
- export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.cjs';
14
+ export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DL3z5PxP.cjs';
14
15
  import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
15
16
  import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
16
17
  import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
17
18
  import { App } from 'vue';
18
19
  import '@vue-solana/core/address';
20
+ import '@vue-solana/core/errors';
19
21
  import '@solana/web3-compat';
20
22
 
21
23
  interface VueSolanaPluginOptions extends SolanaConfig {
package/dist/index.d.mts CHANGED
@@ -3,6 +3,7 @@ export { useBalance } from './useBalance.mjs';
3
3
  export { useConnection } from './useConnection.mjs';
4
4
  export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.mjs';
5
5
  export { useRpc } from './useRpc.mjs';
6
+ export { SignMessageStatus, useSignMessage } from './useSignMessage.mjs';
6
7
  export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
7
8
  export { UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.mjs';
8
9
  export { tryUseSolana, useSolana } from './useSolana.mjs';
@@ -10,12 +11,13 @@ export { UseTransactionOptions, useTransaction } from './useTransaction.mjs';
10
11
  export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.mjs';
11
12
  export { useWallet } from './useWallet.mjs';
12
13
  export { useWallets } from './useWallets.mjs';
13
- export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.mjs';
14
+ export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DL3z5PxP.mjs';
14
15
  import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
15
16
  import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
16
17
  import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
17
18
  import { App } from 'vue';
18
19
  import '@vue-solana/core/address';
20
+ import '@vue-solana/core/errors';
19
21
  import '@solana/web3-compat';
20
22
 
21
23
  interface VueSolanaPluginOptions extends SolanaConfig {
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { useBalance } from './useBalance.js';
3
3
  export { useConnection } from './useConnection.js';
4
4
  export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.js';
5
5
  export { useRpc } from './useRpc.js';
6
+ export { SignMessageStatus, useSignMessage } from './useSignMessage.js';
6
7
  export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.js';
7
8
  export { UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.js';
8
9
  export { tryUseSolana, useSolana } from './useSolana.js';
@@ -10,12 +11,13 @@ export { UseTransactionOptions, useTransaction } from './useTransaction.js';
10
11
  export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.js';
11
12
  export { useWallet } from './useWallet.js';
12
13
  export { useWallets } from './useWallets.js';
13
- export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.js';
14
+ export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DL3z5PxP.js';
14
15
  import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
15
16
  import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
16
17
  import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
17
18
  import { App } from 'vue';
18
19
  import '@vue-solana/core/address';
20
+ import '@vue-solana/core/errors';
19
21
  import '@solana/web3-compat';
20
22
 
21
23
  interface VueSolanaPluginOptions extends SolanaConfig {
package/dist/index.mjs CHANGED
@@ -1,51 +1,61 @@
1
- export { u as useAccountInfo } from './shared/vue.7TzeDJZX.mjs';
2
- export { u as useBalance } from './shared/vue.DQhHHVu6.mjs';
1
+ export { u as useAccountInfo } from './shared/vue.Cl3hXlXK.mjs';
2
+ export { u as useBalance } from './shared/vue.BDl2vVkp.mjs';
3
3
  export { u as useConnection } from './shared/vue.DlEAL2G8.mjs';
4
- export { u as useProgramAccounts } from './shared/vue.CUTLu1Gf.mjs';
4
+ export { u as useProgramAccounts } from './shared/vue.CzTu_DPr.mjs';
5
5
  export { u as useRpc } from './shared/vue.BqDzSepb.mjs';
6
- export { u as useSignAndSendTransaction } from './shared/vue.RQ9fETnm.mjs';
7
- export { u as useSignatureStatus } from './shared/vue.JC5FdU2O.mjs';
6
+ export { u as useSignMessage } from './shared/vue.PTQ2iRAi.mjs';
7
+ export { u as useSignAndSendTransaction } from './shared/vue.BlfFUgC-.mjs';
8
+ export { u as useSignatureStatus } from './shared/vue.BzopW_4m.mjs';
8
9
  import { s as solanaInjectionKey } from './shared/vue.1M_c5FWA.mjs';
9
10
  export { t as tryUseSolana, u as useSolana } from './shared/vue.1M_c5FWA.mjs';
10
- import { w as withTimeout } from './shared/vue.gLqkzJY4.mjs';
11
- export { u as useTransaction } from './shared/vue.gLqkzJY4.mjs';
12
- export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.jOsz34kz.mjs';
13
- export { u as useWallet } from './shared/vue.DYf_CRDv.mjs';
11
+ export { u as useTransaction } from './shared/vue.C4d2JA8U.mjs';
12
+ export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.CxMrojxC.mjs';
13
+ export { u as useWallet } from './shared/vue.5sF8eKgx.mjs';
14
14
  export { u as useWallets } from './shared/vue.h-uS8MXN.mjs';
15
+ import { createSolanaError, normalizeSolanaError } from '@vue-solana/core/errors';
15
16
  import { createSolanaContext } from '@vue-solana/core/rpc';
17
+ import { withTimeout } from '@vue-solana/core/timeout';
16
18
  import { getRegisteredSolanaWallets, getSolanaChain, adaptSolanaStandardWallet, subscribeSolanaWallets } from '@vue-solana/core/wallet-standard';
17
19
  import { shallowRef, ref, triggerRef } from 'vue';
18
20
  import { handleSolanaIosWalletCallback, getSolanaIosWallets, isSolanaIosWalletInfo, adaptSolanaIosWallet } from '@vue-solana/core/ios-wallet';
19
21
  import '@vue-solana/core/address';
20
- import '@solana/web3-compat';
22
+ import '@vue-solana/core/wallet';
21
23
  import '@vue-solana/core/transaction';
22
24
  import 'bs58';
23
25
 
24
26
  const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
25
27
  function readSelectedWallet() {
26
- const storage = getLocalStorage();
27
- if (!storage) {
28
- return null;
28
+ const { storage, error } = getLocalStorage();
29
+ if (error || !storage) {
30
+ return { wallet: null, error };
29
31
  }
30
32
  try {
31
33
  const value = storage.getItem(SELECTED_WALLET_STORAGE_KEY);
32
34
  if (!value) {
33
- return null;
35
+ return { wallet: null, error: null };
34
36
  }
35
37
  const wallet = JSON.parse(value);
36
- return typeof wallet.name === "string" ? {
37
- name: wallet.name,
38
- platform: wallet.platform,
39
- source: wallet.source
40
- } : null;
41
- } catch {
42
- return null;
38
+ return {
39
+ wallet: typeof wallet.name === "string" ? {
40
+ name: wallet.name,
41
+ platform: wallet.platform,
42
+ source: wallet.source
43
+ } : null,
44
+ error: null
45
+ };
46
+ } catch (cause) {
47
+ return {
48
+ wallet: null,
49
+ error: createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
50
+ cause
51
+ })
52
+ };
43
53
  }
44
54
  }
45
55
  function writeSelectedWallet(wallet) {
46
- const storage = getLocalStorage();
47
- if (!storage) {
48
- return;
56
+ const { storage, error } = getLocalStorage();
57
+ if (error || !storage) {
58
+ return error;
49
59
  }
50
60
  try {
51
61
  if (wallet) {
@@ -53,7 +63,11 @@ function writeSelectedWallet(wallet) {
53
63
  } else {
54
64
  storage.removeItem(SELECTED_WALLET_STORAGE_KEY);
55
65
  }
56
- } catch {
66
+ return null;
67
+ } catch (cause) {
68
+ return createSolanaError("STORAGE_FAILURE", "Unable to persist the selected Solana wallet", {
69
+ cause
70
+ });
57
71
  }
58
72
  }
59
73
  function stringifySelectedWallet(wallet) {
@@ -68,12 +82,17 @@ function stringifySelectedWallet(wallet) {
68
82
  }
69
83
  function getLocalStorage() {
70
84
  if (typeof window === "undefined") {
71
- return null;
85
+ return { storage: null, error: null };
72
86
  }
73
87
  try {
74
- return window.localStorage;
75
- } catch {
76
- return null;
88
+ return { storage: window.localStorage, error: null };
89
+ } catch (cause) {
90
+ return {
91
+ storage: null,
92
+ error: createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
93
+ cause
94
+ })
95
+ };
77
96
  }
78
97
  }
79
98
 
@@ -204,7 +223,9 @@ function createSolanaPlugin(options = {}) {
204
223
  const blockhash = await withTimeout(
205
224
  context.connection.getLatestBlockhash(),
206
225
  RPC_CHECK_TIMEOUT_MS,
207
- `RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
226
+ () => new Error(
227
+ `RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
228
+ )
208
229
  );
209
230
  if (checkId !== rpcCheckId) {
210
231
  return;
@@ -222,7 +243,7 @@ function createSolanaPlugin(options = {}) {
222
243
  return;
223
244
  }
224
245
  status.value = "error";
225
- error.value = cause instanceof Error ? cause.message : String(cause);
246
+ error.value = normalizeSolanaError(cause, "RPC_FAILURE");
226
247
  console.error("[Vue Solana] Connection failed", cause);
227
248
  }
228
249
  }
@@ -238,7 +259,13 @@ function createSolanaPlugin(options = {}) {
238
259
  }
239
260
  } else if (!options.wallet) {
240
261
  const persistedWallet = readSelectedWallet();
241
- restoredWallet = persistedWallet ? wallets.value.find((nextWallet) => isSameWallet(nextWallet, persistedWallet)) ?? null : null;
262
+ if (persistedWallet.error) {
263
+ error.value = persistedWallet.error;
264
+ console.error("[Vue Solana] Selected wallet restoration failed", persistedWallet.error);
265
+ }
266
+ restoredWallet = persistedWallet.wallet ? wallets.value.find(
267
+ (nextWallet) => isSameWallet(nextWallet, persistedWallet.wallet)
268
+ ) ?? null : null;
242
269
  if (restoredWallet) {
243
270
  selectedWallet.value = restoredWallet;
244
271
  wallet.value = walletRegistry.getAdaptedWallet(restoredWallet);
@@ -267,7 +294,11 @@ function createSolanaPlugin(options = {}) {
267
294
  function selectWallet(nextWallet) {
268
295
  selectedWallet.value = nextWallet;
269
296
  wallet.value = nextWallet ? walletRegistry.getAdaptedWallet(nextWallet) : options.wallet ?? null;
270
- writeSelectedWallet(nextWallet);
297
+ const storageError = writeSelectedWallet(nextWallet);
298
+ if (storageError) {
299
+ error.value = storageError;
300
+ console.error("[Vue Solana] Selected wallet persistence failed", storageError);
301
+ }
271
302
  }
272
303
  function autoConnectWallet(walletInfo) {
273
304
  if (!options.autoConnect) {
@@ -299,7 +330,11 @@ function createSolanaPlugin(options = {}) {
299
330
  setWallet(nextWallet) {
300
331
  selectedWallet.value = null;
301
332
  wallet.value = nextWallet;
302
- writeSelectedWallet(null);
333
+ const storageError = writeSelectedWallet(null);
334
+ if (storageError) {
335
+ error.value = storageError;
336
+ console.error("[Vue Solana] Selected wallet persistence failed", storageError);
337
+ }
303
338
  }
304
339
  };
305
340
  app.provide(solanaInjectionKey, vueContext);
@@ -1,3 +1,5 @@
1
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
2
+ import { createNoWalletSelectedError } from '@vue-solana/core/wallet';
1
3
  import { ref, computed, triggerRef } from 'vue';
2
4
  import { u as useSolana } from './vue.1M_c5FWA.mjs';
3
5
 
@@ -9,7 +11,7 @@ function useWallet() {
9
11
  async function connect() {
10
12
  const activeWallet = wallet.value;
11
13
  if (!activeWallet) {
12
- throw new Error("No Solana wallet is configured");
14
+ throw createNoWalletSelectedError();
13
15
  }
14
16
  connecting.value = true;
15
17
  try {
@@ -21,9 +23,10 @@ function useWallet() {
21
23
  publicKey: activeWallet.publicKey?.toBase58() ?? null
22
24
  });
23
25
  } catch (error) {
26
+ const normalizedError = normalizeSolanaError(error, "RPC_FAILURE");
24
27
  triggerRef(wallet);
25
- console.error("[Vue Solana] Wallet connection failed", error);
26
- throw error;
28
+ console.error("[Vue Solana] Wallet connection failed", normalizedError);
29
+ throw normalizedError;
27
30
  } finally {
28
31
  connecting.value = false;
29
32
  }
@@ -40,9 +43,10 @@ function useWallet() {
40
43
  triggerRef(wallet);
41
44
  console.info("[Vue Solana] Wallet disconnected", { publicKey });
42
45
  } catch (error) {
46
+ const normalizedError = normalizeSolanaError(error, "RPC_FAILURE");
43
47
  triggerRef(wallet);
44
- console.error("[Vue Solana] Wallet disconnection failed", error);
45
- throw error;
48
+ console.error("[Vue Solana] Wallet disconnection failed", normalizedError);
49
+ throw normalizedError;
46
50
  } finally {
47
51
  disconnecting.value = false;
48
52
  }
@@ -51,6 +55,20 @@ function useWallet() {
51
55
  const isDisconnecting = computed(
52
56
  () => Boolean(disconnecting.value || wallet.value?.disconnecting)
53
57
  );
58
+ const canConnect = computed(() => Boolean(wallet.value?.connect));
59
+ const canDisconnect = computed(() => Boolean(wallet.value?.disconnect));
60
+ const canSignMessage = computed(() => Boolean(wallet.value?.signMessage));
61
+ const canSignTransaction = computed(() => Boolean(wallet.value?.signTransaction));
62
+ const canSignAllTransactions = computed(() => Boolean(wallet.value?.signAllTransactions));
63
+ const canSignAndSendTransaction = computed(() => Boolean(wallet.value?.signAndSendTransaction));
64
+ const capabilities = computed(() => ({
65
+ connect: canConnect.value,
66
+ disconnect: canDisconnect.value,
67
+ signMessage: canSignMessage.value,
68
+ signTransaction: canSignTransaction.value,
69
+ signAllTransactions: canSignAllTransactions.value,
70
+ signAndSendTransaction: canSignAndSendTransaction.value
71
+ }));
54
72
  return {
55
73
  wallet,
56
74
  publicKey: computed(() => wallet.value?.publicKey ?? null),
@@ -58,6 +76,13 @@ function useWallet() {
58
76
  connecting: isConnecting,
59
77
  disconnecting: isDisconnecting,
60
78
  loading: computed(() => isConnecting.value || isDisconnecting.value),
79
+ capabilities,
80
+ canConnect,
81
+ canDisconnect,
82
+ canSignMessage,
83
+ canSignTransaction,
84
+ canSignAllTransactions,
85
+ canSignAndSendTransaction,
61
86
  setWallet: solana.setWallet,
62
87
  connect,
63
88
  disconnect
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const address = require('@vue-solana/core/address');
4
+ const errors = require('@vue-solana/core/errors');
4
5
  const vue = require('vue');
5
6
  const useConnection = require('./vue.CwhEmATP.cjs');
6
7
  const useSolana = require('./vue.C4tLiG3R.cjs');
@@ -38,11 +39,12 @@ function useAccountInfo(address$1, options = {}) {
38
39
  }
39
40
  return nextAccountInfo;
40
41
  } catch (cause) {
42
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
41
43
  if (requestId === refreshId) {
42
44
  accountInfo.value = null;
43
- error.value = cause;
45
+ error.value = normalizedError;
44
46
  }
45
- throw cause;
47
+ throw normalizedError;
46
48
  } finally {
47
49
  if (requestId === refreshId) {
48
50
  loading.value = false;
@@ -63,7 +65,7 @@ function useAccountInfo(address$1, options = {}) {
63
65
  try {
64
66
  await connection.removeAccountChangeListener(currentSubscriptionId);
65
67
  } catch (cause) {
66
- error.value = cause;
68
+ error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
67
69
  }
68
70
  }
69
71
  async function startWatching() {
@@ -98,7 +100,7 @@ function useAccountInfo(address$1, options = {}) {
98
100
  subscriptionId = nextSubscriptionId;
99
101
  } catch (cause) {
100
102
  if (requestId === watchId) {
101
- error.value = cause;
103
+ error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
102
104
  }
103
105
  }
104
106
  }