@vue-solana/vue 0.6.0 → 0.7.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 (46) hide show
  1. package/README.md +67 -3
  2. package/dist/index.cjs +13 -2
  3. package/dist/index.d.cts +5 -0
  4. package/dist/index.d.mts +5 -0
  5. package/dist/index.d.ts +5 -0
  6. package/dist/index.mjs +9 -2
  7. package/dist/shared/vue.7TzeDJZX.mjs +127 -0
  8. package/dist/shared/vue.BPnK_lsh.cjs +129 -0
  9. package/dist/shared/vue.BeuIPLGM.mjs +63 -0
  10. package/dist/shared/{vue.CwPjPFN6.cjs → vue.BwipRa1w.cjs} +21 -0
  11. package/dist/shared/{vue.DYf_CRDv.mjs → vue.CGVdFmYI.mjs} +21 -0
  12. package/dist/shared/{vue.RQ9fETnm.mjs → vue.CM6qb_s8.mjs} +10 -5
  13. package/dist/shared/vue.CUTLu1Gf.mjs +71 -0
  14. package/dist/shared/vue.D1knFN3X.cjs +65 -0
  15. package/dist/shared/vue.DUufwq8y.cjs +186 -0
  16. package/dist/shared/{vue.DEQJ23UM.cjs → vue.DWiQYhb8.cjs} +10 -5
  17. package/dist/shared/vue.JC5FdU2O.mjs +180 -0
  18. package/dist/shared/vue.dmuispJ3.cjs +73 -0
  19. package/dist/useAccountInfo.cjs +12 -0
  20. package/dist/useAccountInfo.d.cts +19 -0
  21. package/dist/useAccountInfo.d.mts +19 -0
  22. package/dist/useAccountInfo.d.ts +19 -0
  23. package/dist/useAccountInfo.mjs +6 -0
  24. package/dist/useProgramAccounts.cjs +12 -0
  25. package/dist/useProgramAccounts.d.cts +39 -0
  26. package/dist/useProgramAccounts.d.mts +39 -0
  27. package/dist/useProgramAccounts.d.ts +39 -0
  28. package/dist/useProgramAccounts.mjs +6 -0
  29. package/dist/useSignAndSendTransaction.cjs +2 -2
  30. package/dist/useSignAndSendTransaction.mjs +2 -2
  31. package/dist/useSignMessage.cjs +11 -0
  32. package/dist/useSignMessage.d.cts +235 -0
  33. package/dist/useSignMessage.d.mts +235 -0
  34. package/dist/useSignMessage.d.ts +235 -0
  35. package/dist/useSignMessage.mjs +5 -0
  36. package/dist/useSignatureStatus.cjs +12 -0
  37. package/dist/useSignatureStatus.d.cts +21 -0
  38. package/dist/useSignatureStatus.d.mts +21 -0
  39. package/dist/useSignatureStatus.d.ts +21 -0
  40. package/dist/useSignatureStatus.mjs +6 -0
  41. package/dist/useWallet.cjs +1 -1
  42. package/dist/useWallet.d.cts +14 -0
  43. package/dist/useWallet.d.mts +14 -0
  44. package/dist/useWallet.d.ts +14 -0
  45. package/dist/useWallet.mjs +1 -1
  46. package/package.json +23 -2
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:
@@ -118,6 +119,26 @@ const { balance, loading, error, refresh } = useBalance(address);
118
119
  </template>
119
120
  ```
120
121
 
122
+ ## Read Account Data
123
+
124
+ ```ts
125
+ import { useAccountInfo } from "@vue-solana/vue/useAccountInfo";
126
+ import { useProgramAccounts } from "@vue-solana/vue/useProgramAccounts";
127
+ import { useSignatureStatus } from "@vue-solana/vue/useSignatureStatus";
128
+
129
+ const account = useAccountInfo(address, { watch: true });
130
+ const programAccounts = useProgramAccounts(programId, {
131
+ dataSlice: { offset: 0, length: 32 },
132
+ filters: [{ dataSize: 165 }],
133
+ });
134
+ const signatureStatus = useSignatureStatus(signature, {
135
+ pollIntervalMs: 2_000,
136
+ searchTransactionHistory: true,
137
+ });
138
+ ```
139
+
140
+ `useProgramAccounts()` can be expensive on public RPC nodes. Prefer narrow `filters`, use `dataSlice` when you only need part of account data, and avoid polling broad program scans.
141
+
121
142
  ## Wallet State
122
143
 
123
144
  ```vue
@@ -126,7 +147,7 @@ import { useWallet } from "@vue-solana/vue/useWallet";
126
147
  import { useWallets } from "@vue-solana/vue/useWallets";
127
148
 
128
149
  const { wallets, selectedWallet, selectWallet, refreshWallets } = useWallets();
129
- const { publicKey, connected, connecting, connect, disconnect } = useWallet();
150
+ const { publicKey, connected, connecting, canSignMessage, connect, disconnect } = useWallet();
130
151
  </script>
131
152
 
132
153
  <template>
@@ -143,6 +164,7 @@ const { publicKey, connected, connecting, connect, disconnect } = useWallet();
143
164
  <p>Selected: {{ selectedWallet?.name ?? "None" }}</p>
144
165
  <p>Connected: {{ connected }}</p>
145
166
  <p>Public key: {{ publicKey?.toBase58() }}</p>
167
+ <p>Can sign messages: {{ canSignMessage }}</p>
146
168
  <p v-if="connecting">Connecting...</p>
147
169
  <button type="button" :disabled="!selectedWallet || connected || connecting" @click="connect">
148
170
  Connect
@@ -160,6 +182,38 @@ Desktop native app wallet adapters are planned but not implemented yet.
160
182
 
161
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.
162
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
+
163
217
  ## Transaction State
164
218
 
165
219
  ```ts
@@ -221,9 +275,13 @@ Docs: [Vue Solana Agent Skill](https://vue-solana-docs.vercel.app/agent-skill)
221
275
  - `useConnection()`: returns the Solana `Connection`.
222
276
  - `useWallet()`: returns wallet refs, computed connection state, and wallet actions.
223
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.
224
279
  - `useBalance(address, commitment?)`: loads lamport balance for a `PublicKey` or address string.
280
+ - `useAccountInfo(address, options?)`: loads account info and can subscribe to account changes with `watch: true`.
281
+ - `useProgramAccounts(programId, config?)`: loads accounts owned by a program with optional filters, commitment, and `dataSlice`.
225
282
  - `useTransaction(handler, options?)`: generic async transaction state helper with optional timeout settings.
226
283
  - `useTransactionConfirmation(options?)`: confirms a submitted signature with reactive status and timeout/error state.
284
+ - `useSignatureStatus(signature, options?)`: reads a transaction signature status with optional polling or websocket subscription.
227
285
  - `useSignAndSendTransaction()`: signs and sends a transaction through the configured wallet, with optional confirmation waiting.
228
286
 
229
287
  Direct composable subpaths:
@@ -231,11 +289,15 @@ Direct composable subpaths:
231
289
  - `@vue-solana/vue/useSolana`
232
290
  - `@vue-solana/vue/useRpc`
233
291
  - `@vue-solana/vue/useConnection`
292
+ - `@vue-solana/vue/useAccountInfo`
234
293
  - `@vue-solana/vue/useBalance`
294
+ - `@vue-solana/vue/useProgramAccounts`
235
295
  - `@vue-solana/vue/useWallet`
236
296
  - `@vue-solana/vue/useWallets`
297
+ - `@vue-solana/vue/useSignMessage`
237
298
  - `@vue-solana/vue/useTransaction`
238
299
  - `@vue-solana/vue/useTransactionConfirmation`
300
+ - `@vue-solana/vue/useSignatureStatus`
239
301
  - `@vue-solana/vue/useSignAndSendTransaction`
240
302
 
241
303
  ## Known TypeScript Issue
@@ -247,10 +309,12 @@ If TypeScript cannot resolve `@solana/web3-compat`, add `types/web3-compat.d.ts`
247
309
  ```ts
248
310
  declare module "@solana/web3-compat" {
249
311
  export type {
312
+ AccountInfo,
250
313
  Commitment,
251
314
  RpcResponseAndContext,
252
315
  SendOptions,
253
316
  SignatureResult,
317
+ SignatureStatus,
254
318
  TransactionSignature,
255
319
  } from "@solana/web3.js";
256
320
  export {
@@ -269,4 +333,4 @@ Make sure your `tsconfig.json` includes `types/**/*.d.ts` or another pattern tha
269
333
 
270
334
  ## Status
271
335
 
272
- 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,20 +1,27 @@
1
1
  'use strict';
2
2
 
3
+ const useAccountInfo = require('./shared/vue.BPnK_lsh.cjs');
3
4
  const useBalance = require('./shared/vue.D_AM1Nl8.cjs');
4
5
  const useConnection = require('./shared/vue.CwhEmATP.cjs');
6
+ const useProgramAccounts = require('./shared/vue.dmuispJ3.cjs');
5
7
  const useRpc = require('./shared/vue.COyyrsQU.cjs');
6
- const useSignAndSendTransaction = require('./shared/vue.DEQJ23UM.cjs');
8
+ const useSignMessage = require('./shared/vue.D1knFN3X.cjs');
9
+ const useSignAndSendTransaction = require('./shared/vue.DWiQYhb8.cjs');
10
+ const useSignatureStatus = require('./shared/vue.DUufwq8y.cjs');
7
11
  const useSolana = require('./shared/vue.C4tLiG3R.cjs');
8
12
  const useTransaction = require('./shared/vue.DQi38JeF.cjs');
9
13
  const useTransactionConfirmation = require('./shared/vue.DHVYJk8P.cjs');
10
- const useWallet = require('./shared/vue.CwPjPFN6.cjs');
14
+ const useWallet = require('./shared/vue.BwipRa1w.cjs');
11
15
  const useWallets = require('./shared/vue.P9tgeC5S.cjs');
12
16
  const rpc = require('@vue-solana/core/rpc');
13
17
  const walletStandard = require('@vue-solana/core/wallet-standard');
14
18
  const vue = require('vue');
15
19
  const iosWallet = require('@vue-solana/core/ios-wallet');
20
+ require('@vue-solana/core/address');
16
21
  require('@solana/web3-compat');
22
+ require('@vue-solana/core/wallet');
17
23
  require('@vue-solana/core/transaction');
24
+ require('bs58');
18
25
 
19
26
  const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
20
27
  function readSelectedWallet() {
@@ -316,10 +323,14 @@ function isSameWallet(wallet, selectedWallet) {
316
323
  }
317
324
  const VueSolana = createSolanaPlugin;
318
325
 
326
+ exports.useAccountInfo = useAccountInfo.useAccountInfo;
319
327
  exports.useBalance = useBalance.useBalance;
320
328
  exports.useConnection = useConnection.useConnection;
329
+ exports.useProgramAccounts = useProgramAccounts.useProgramAccounts;
321
330
  exports.useRpc = useRpc.useRpc;
331
+ exports.useSignMessage = useSignMessage.useSignMessage;
322
332
  exports.useSignAndSendTransaction = useSignAndSendTransaction.useSignAndSendTransaction;
333
+ exports.useSignatureStatus = useSignatureStatus.useSignatureStatus;
323
334
  exports.solanaInjectionKey = useSolana.solanaInjectionKey;
324
335
  exports.tryUseSolana = useSolana.tryUseSolana;
325
336
  exports.useSolana = useSolana.useSolana;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,11 @@
1
+ export { UseAccountInfoOptions, useAccountInfo } from './useAccountInfo.cjs';
1
2
  export { useBalance } from './useBalance.cjs';
2
3
  export { useConnection } from './useConnection.cjs';
4
+ export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.cjs';
3
5
  export { useRpc } from './useRpc.cjs';
6
+ export { SignMessageStatus, useSignMessage } from './useSignMessage.cjs';
4
7
  export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
8
+ export { UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.cjs';
5
9
  export { tryUseSolana, useSolana } from './useSolana.cjs';
6
10
  export { UseTransactionOptions, useTransaction } from './useTransaction.cjs';
7
11
  export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.cjs';
@@ -12,6 +16,7 @@ import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
12
16
  import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
13
17
  import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
14
18
  import { App } from 'vue';
19
+ import '@vue-solana/core/address';
15
20
  import '@solana/web3-compat';
16
21
 
17
22
  interface VueSolanaPluginOptions extends SolanaConfig {
package/dist/index.d.mts CHANGED
@@ -1,7 +1,11 @@
1
+ export { UseAccountInfoOptions, useAccountInfo } from './useAccountInfo.mjs';
1
2
  export { useBalance } from './useBalance.mjs';
2
3
  export { useConnection } from './useConnection.mjs';
4
+ export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.mjs';
3
5
  export { useRpc } from './useRpc.mjs';
6
+ export { SignMessageStatus, useSignMessage } from './useSignMessage.mjs';
4
7
  export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
8
+ export { UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.mjs';
5
9
  export { tryUseSolana, useSolana } from './useSolana.mjs';
6
10
  export { UseTransactionOptions, useTransaction } from './useTransaction.mjs';
7
11
  export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.mjs';
@@ -12,6 +16,7 @@ import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
12
16
  import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
13
17
  import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
14
18
  import { App } from 'vue';
19
+ import '@vue-solana/core/address';
15
20
  import '@solana/web3-compat';
16
21
 
17
22
  interface VueSolanaPluginOptions extends SolanaConfig {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
+ export { UseAccountInfoOptions, useAccountInfo } from './useAccountInfo.js';
1
2
  export { useBalance } from './useBalance.js';
2
3
  export { useConnection } from './useConnection.js';
4
+ export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.js';
3
5
  export { useRpc } from './useRpc.js';
6
+ export { SignMessageStatus, useSignMessage } from './useSignMessage.js';
4
7
  export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.js';
8
+ export { UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.js';
5
9
  export { tryUseSolana, useSolana } from './useSolana.js';
6
10
  export { UseTransactionOptions, useTransaction } from './useTransaction.js';
7
11
  export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.js';
@@ -12,6 +16,7 @@ import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
12
16
  import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
13
17
  import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
14
18
  import { App } from 'vue';
19
+ import '@vue-solana/core/address';
15
20
  import '@solana/web3-compat';
16
21
 
17
22
  interface VueSolanaPluginOptions extends SolanaConfig {
package/dist/index.mjs CHANGED
@@ -1,20 +1,27 @@
1
+ export { u as useAccountInfo } from './shared/vue.7TzeDJZX.mjs';
1
2
  export { u as useBalance } from './shared/vue.DQhHHVu6.mjs';
2
3
  export { u as useConnection } from './shared/vue.DlEAL2G8.mjs';
4
+ export { u as useProgramAccounts } from './shared/vue.CUTLu1Gf.mjs';
3
5
  export { u as useRpc } from './shared/vue.BqDzSepb.mjs';
4
- export { u as useSignAndSendTransaction } from './shared/vue.RQ9fETnm.mjs';
6
+ export { u as useSignMessage } from './shared/vue.BeuIPLGM.mjs';
7
+ export { u as useSignAndSendTransaction } from './shared/vue.CM6qb_s8.mjs';
8
+ export { u as useSignatureStatus } from './shared/vue.JC5FdU2O.mjs';
5
9
  import { s as solanaInjectionKey } from './shared/vue.1M_c5FWA.mjs';
6
10
  export { t as tryUseSolana, u as useSolana } from './shared/vue.1M_c5FWA.mjs';
7
11
  import { w as withTimeout } from './shared/vue.gLqkzJY4.mjs';
8
12
  export { u as useTransaction } from './shared/vue.gLqkzJY4.mjs';
9
13
  export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.jOsz34kz.mjs';
10
- export { u as useWallet } from './shared/vue.DYf_CRDv.mjs';
14
+ export { u as useWallet } from './shared/vue.CGVdFmYI.mjs';
11
15
  export { u as useWallets } from './shared/vue.h-uS8MXN.mjs';
12
16
  import { createSolanaContext } from '@vue-solana/core/rpc';
13
17
  import { getRegisteredSolanaWallets, getSolanaChain, adaptSolanaStandardWallet, subscribeSolanaWallets } from '@vue-solana/core/wallet-standard';
14
18
  import { shallowRef, ref, triggerRef } from 'vue';
15
19
  import { handleSolanaIosWalletCallback, getSolanaIosWallets, isSolanaIosWalletInfo, adaptSolanaIosWallet } from '@vue-solana/core/ios-wallet';
20
+ import '@vue-solana/core/address';
16
21
  import '@solana/web3-compat';
22
+ import '@vue-solana/core/wallet';
17
23
  import '@vue-solana/core/transaction';
24
+ import 'bs58';
18
25
 
19
26
  const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
20
27
  function readSelectedWallet() {
@@ -0,0 +1,127 @@
1
+ import { parsePublicKey } from '@vue-solana/core/address';
2
+ import { shallowRef, onMounted, onUnmounted, watch, toValue } from 'vue';
3
+ import { u as useConnection } from './vue.DlEAL2G8.mjs';
4
+ import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
5
+
6
+ function useAccountInfo(address, options = {}) {
7
+ const solana = tryUseSolana();
8
+ const connection = solana?.connection ?? useConnection();
9
+ const accountInfo = shallowRef(null);
10
+ const loading = shallowRef(false);
11
+ const error = shallowRef(null);
12
+ let refreshId = 0;
13
+ let watchId = 0;
14
+ let subscriptionId = null;
15
+ let manuallyStopped = false;
16
+ async function refresh() {
17
+ const requestId = ++refreshId;
18
+ const value = toValue(address);
19
+ if (!value || !solana) {
20
+ accountInfo.value = null;
21
+ loading.value = false;
22
+ error.value = null;
23
+ return null;
24
+ }
25
+ loading.value = true;
26
+ error.value = null;
27
+ try {
28
+ const publicKey = parsePublicKey(value);
29
+ if (!publicKey) {
30
+ accountInfo.value = null;
31
+ return null;
32
+ }
33
+ const nextAccountInfo = await connection.getAccountInfo(publicKey, options.commitment);
34
+ if (requestId === refreshId) {
35
+ accountInfo.value = nextAccountInfo;
36
+ }
37
+ return nextAccountInfo;
38
+ } catch (cause) {
39
+ if (requestId === refreshId) {
40
+ accountInfo.value = null;
41
+ error.value = cause;
42
+ }
43
+ throw cause;
44
+ } finally {
45
+ if (requestId === refreshId) {
46
+ loading.value = false;
47
+ }
48
+ }
49
+ }
50
+ async function stopWatching() {
51
+ manuallyStopped = true;
52
+ watchId += 1;
53
+ await stopCurrentWatcher();
54
+ }
55
+ async function stopCurrentWatcher() {
56
+ if (subscriptionId === null) {
57
+ return;
58
+ }
59
+ const currentSubscriptionId = subscriptionId;
60
+ subscriptionId = null;
61
+ try {
62
+ await connection.removeAccountChangeListener(currentSubscriptionId);
63
+ } catch (cause) {
64
+ error.value = cause;
65
+ }
66
+ }
67
+ async function startWatching() {
68
+ const requestId = ++watchId;
69
+ await stopCurrentWatcher();
70
+ if (requestId !== watchId) {
71
+ return;
72
+ }
73
+ if (manuallyStopped || !options.watch || !solana) {
74
+ return;
75
+ }
76
+ try {
77
+ const publicKey = parsePublicKey(toValue(address));
78
+ if (!publicKey) {
79
+ return;
80
+ }
81
+ const nextSubscriptionId = connection.onAccountChange(
82
+ publicKey,
83
+ (nextAccountInfo) => {
84
+ if (requestId !== watchId) {
85
+ return;
86
+ }
87
+ accountInfo.value = nextAccountInfo;
88
+ error.value = null;
89
+ },
90
+ options.commitment
91
+ );
92
+ if (requestId !== watchId) {
93
+ await connection.removeAccountChangeListener(nextSubscriptionId);
94
+ return;
95
+ }
96
+ subscriptionId = nextSubscriptionId;
97
+ } catch (cause) {
98
+ if (requestId === watchId) {
99
+ error.value = cause;
100
+ }
101
+ }
102
+ }
103
+ onMounted(() => {
104
+ void refresh().catch(() => void 0);
105
+ void startWatching();
106
+ });
107
+ onUnmounted(() => {
108
+ refreshId += 1;
109
+ void stopWatching();
110
+ });
111
+ watch(
112
+ () => toValue(address),
113
+ () => {
114
+ void refresh().catch(() => void 0);
115
+ void startWatching();
116
+ }
117
+ );
118
+ return {
119
+ accountInfo,
120
+ loading,
121
+ error,
122
+ refresh,
123
+ stopWatching
124
+ };
125
+ }
126
+
127
+ export { useAccountInfo as u };
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+
3
+ const address = require('@vue-solana/core/address');
4
+ const vue = require('vue');
5
+ const useConnection = require('./vue.CwhEmATP.cjs');
6
+ const useSolana = require('./vue.C4tLiG3R.cjs');
7
+
8
+ function useAccountInfo(address$1, options = {}) {
9
+ const solana = useSolana.tryUseSolana();
10
+ const connection = solana?.connection ?? useConnection.useConnection();
11
+ const accountInfo = vue.shallowRef(null);
12
+ const loading = vue.shallowRef(false);
13
+ const error = vue.shallowRef(null);
14
+ let refreshId = 0;
15
+ let watchId = 0;
16
+ let subscriptionId = null;
17
+ let manuallyStopped = false;
18
+ async function refresh() {
19
+ const requestId = ++refreshId;
20
+ const value = vue.toValue(address$1);
21
+ if (!value || !solana) {
22
+ accountInfo.value = null;
23
+ loading.value = false;
24
+ error.value = null;
25
+ return null;
26
+ }
27
+ loading.value = true;
28
+ error.value = null;
29
+ try {
30
+ const publicKey = address.parsePublicKey(value);
31
+ if (!publicKey) {
32
+ accountInfo.value = null;
33
+ return null;
34
+ }
35
+ const nextAccountInfo = await connection.getAccountInfo(publicKey, options.commitment);
36
+ if (requestId === refreshId) {
37
+ accountInfo.value = nextAccountInfo;
38
+ }
39
+ return nextAccountInfo;
40
+ } catch (cause) {
41
+ if (requestId === refreshId) {
42
+ accountInfo.value = null;
43
+ error.value = cause;
44
+ }
45
+ throw cause;
46
+ } finally {
47
+ if (requestId === refreshId) {
48
+ loading.value = false;
49
+ }
50
+ }
51
+ }
52
+ async function stopWatching() {
53
+ manuallyStopped = true;
54
+ watchId += 1;
55
+ await stopCurrentWatcher();
56
+ }
57
+ async function stopCurrentWatcher() {
58
+ if (subscriptionId === null) {
59
+ return;
60
+ }
61
+ const currentSubscriptionId = subscriptionId;
62
+ subscriptionId = null;
63
+ try {
64
+ await connection.removeAccountChangeListener(currentSubscriptionId);
65
+ } catch (cause) {
66
+ error.value = cause;
67
+ }
68
+ }
69
+ async function startWatching() {
70
+ const requestId = ++watchId;
71
+ await stopCurrentWatcher();
72
+ if (requestId !== watchId) {
73
+ return;
74
+ }
75
+ if (manuallyStopped || !options.watch || !solana) {
76
+ return;
77
+ }
78
+ try {
79
+ const publicKey = address.parsePublicKey(vue.toValue(address$1));
80
+ if (!publicKey) {
81
+ return;
82
+ }
83
+ const nextSubscriptionId = connection.onAccountChange(
84
+ publicKey,
85
+ (nextAccountInfo) => {
86
+ if (requestId !== watchId) {
87
+ return;
88
+ }
89
+ accountInfo.value = nextAccountInfo;
90
+ error.value = null;
91
+ },
92
+ options.commitment
93
+ );
94
+ if (requestId !== watchId) {
95
+ await connection.removeAccountChangeListener(nextSubscriptionId);
96
+ return;
97
+ }
98
+ subscriptionId = nextSubscriptionId;
99
+ } catch (cause) {
100
+ if (requestId === watchId) {
101
+ error.value = cause;
102
+ }
103
+ }
104
+ }
105
+ vue.onMounted(() => {
106
+ void refresh().catch(() => void 0);
107
+ void startWatching();
108
+ });
109
+ vue.onUnmounted(() => {
110
+ refreshId += 1;
111
+ void stopWatching();
112
+ });
113
+ vue.watch(
114
+ () => vue.toValue(address$1),
115
+ () => {
116
+ void refresh().catch(() => void 0);
117
+ void startWatching();
118
+ }
119
+ );
120
+ return {
121
+ accountInfo,
122
+ loading,
123
+ error,
124
+ refresh,
125
+ stopWatching
126
+ };
127
+ }
128
+
129
+ exports.useAccountInfo = useAccountInfo;
@@ -0,0 +1,63 @@
1
+ import { assertWalletCanSignMessage } from '@vue-solana/core/wallet';
2
+ import { ref } from 'vue';
3
+ import { u as useWallet } from './vue.CGVdFmYI.mjs';
4
+
5
+ function useSignMessage() {
6
+ const { wallet } = useWallet();
7
+ const signedMessage = ref(null);
8
+ const signature = ref(null);
9
+ const status = ref("idle");
10
+ const loading = ref(false);
11
+ const error = ref(null);
12
+ let executionId = 0;
13
+ async function execute(message) {
14
+ const currentExecutionId = ++executionId;
15
+ status.value = "signing";
16
+ loading.value = true;
17
+ error.value = null;
18
+ signedMessage.value = null;
19
+ signature.value = null;
20
+ const activeWallet = wallet.value;
21
+ if (!activeWallet) {
22
+ const cause = new Error("No Solana wallet is configured");
23
+ error.value = cause;
24
+ status.value = "error";
25
+ loading.value = false;
26
+ throw cause;
27
+ }
28
+ try {
29
+ assertWalletCanSignMessage(activeWallet);
30
+ const result = await activeWallet.signMessage(message);
31
+ if (currentExecutionId === executionId) {
32
+ signedMessage.value = result.signedMessage;
33
+ signature.value = result.signature;
34
+ status.value = "signed";
35
+ }
36
+ return result;
37
+ } catch (cause) {
38
+ const normalizedError = normalizeError(cause);
39
+ if (currentExecutionId === executionId) {
40
+ error.value = normalizedError;
41
+ status.value = "error";
42
+ }
43
+ throw normalizedError;
44
+ } finally {
45
+ if (currentExecutionId === executionId) {
46
+ loading.value = false;
47
+ }
48
+ }
49
+ }
50
+ return {
51
+ signedMessage,
52
+ signature,
53
+ status,
54
+ loading,
55
+ error,
56
+ execute
57
+ };
58
+ }
59
+ function normalizeError(cause) {
60
+ return cause instanceof Error ? cause : new Error(String(cause));
61
+ }
62
+
63
+ export { useSignMessage as u };
@@ -53,6 +53,20 @@ function useWallet() {
53
53
  const isDisconnecting = vue.computed(
54
54
  () => Boolean(disconnecting.value || wallet.value?.disconnecting)
55
55
  );
56
+ const canConnect = vue.computed(() => Boolean(wallet.value?.connect));
57
+ const canDisconnect = vue.computed(() => Boolean(wallet.value?.disconnect));
58
+ const canSignMessage = vue.computed(() => Boolean(wallet.value?.signMessage));
59
+ const canSignTransaction = vue.computed(() => Boolean(wallet.value?.signTransaction));
60
+ const canSignAllTransactions = vue.computed(() => Boolean(wallet.value?.signAllTransactions));
61
+ const canSignAndSendTransaction = vue.computed(() => Boolean(wallet.value?.signAndSendTransaction));
62
+ const capabilities = vue.computed(() => ({
63
+ connect: canConnect.value,
64
+ disconnect: canDisconnect.value,
65
+ signMessage: canSignMessage.value,
66
+ signTransaction: canSignTransaction.value,
67
+ signAllTransactions: canSignAllTransactions.value,
68
+ signAndSendTransaction: canSignAndSendTransaction.value
69
+ }));
56
70
  return {
57
71
  wallet,
58
72
  publicKey: vue.computed(() => wallet.value?.publicKey ?? null),
@@ -60,6 +74,13 @@ function useWallet() {
60
74
  connecting: isConnecting,
61
75
  disconnecting: isDisconnecting,
62
76
  loading: vue.computed(() => isConnecting.value || isDisconnecting.value),
77
+ capabilities,
78
+ canConnect,
79
+ canDisconnect,
80
+ canSignMessage,
81
+ canSignTransaction,
82
+ canSignAllTransactions,
83
+ canSignAndSendTransaction,
63
84
  setWallet: solana.setWallet,
64
85
  connect,
65
86
  disconnect
@@ -51,6 +51,20 @@ function useWallet() {
51
51
  const isDisconnecting = computed(
52
52
  () => Boolean(disconnecting.value || wallet.value?.disconnecting)
53
53
  );
54
+ const canConnect = computed(() => Boolean(wallet.value?.connect));
55
+ const canDisconnect = computed(() => Boolean(wallet.value?.disconnect));
56
+ const canSignMessage = computed(() => Boolean(wallet.value?.signMessage));
57
+ const canSignTransaction = computed(() => Boolean(wallet.value?.signTransaction));
58
+ const canSignAllTransactions = computed(() => Boolean(wallet.value?.signAllTransactions));
59
+ const canSignAndSendTransaction = computed(() => Boolean(wallet.value?.signAndSendTransaction));
60
+ const capabilities = computed(() => ({
61
+ connect: canConnect.value,
62
+ disconnect: canDisconnect.value,
63
+ signMessage: canSignMessage.value,
64
+ signTransaction: canSignTransaction.value,
65
+ signAllTransactions: canSignAllTransactions.value,
66
+ signAndSendTransaction: canSignAndSendTransaction.value
67
+ }));
54
68
  return {
55
69
  wallet,
56
70
  publicKey: computed(() => wallet.value?.publicKey ?? null),
@@ -58,6 +72,13 @@ function useWallet() {
58
72
  connecting: isConnecting,
59
73
  disconnecting: isDisconnecting,
60
74
  loading: computed(() => isConnecting.value || isDisconnecting.value),
75
+ capabilities,
76
+ canConnect,
77
+ canDisconnect,
78
+ canSignMessage,
79
+ canSignTransaction,
80
+ canSignAllTransactions,
81
+ canSignAndSendTransaction,
61
82
  setWallet: solana.setWallet,
62
83
  connect,
63
84
  disconnect