@vue-solana/vue 0.5.0 → 0.6.1

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 (44) hide show
  1. package/README.md +56 -4
  2. package/dist/index.cjs +12 -1
  3. package/dist/index.d.cts +6 -1
  4. package/dist/index.d.mts +6 -1
  5. package/dist/index.d.ts +6 -1
  6. package/dist/index.mjs +7 -1
  7. package/dist/shared/vue.7TzeDJZX.mjs +127 -0
  8. package/dist/shared/vue.BPnK_lsh.cjs +129 -0
  9. package/dist/shared/vue.CUTLu1Gf.mjs +71 -0
  10. package/dist/shared/vue.DEQJ23UM.cjs +92 -0
  11. package/dist/shared/vue.DHVYJk8P.cjs +72 -0
  12. package/dist/shared/vue.DUufwq8y.cjs +186 -0
  13. package/dist/shared/vue.JC5FdU2O.mjs +180 -0
  14. package/dist/shared/vue.RQ9fETnm.mjs +90 -0
  15. package/dist/shared/vue.dmuispJ3.cjs +73 -0
  16. package/dist/shared/vue.jOsz34kz.mjs +69 -0
  17. package/dist/useAccountInfo.cjs +12 -0
  18. package/dist/useAccountInfo.d.cts +19 -0
  19. package/dist/useAccountInfo.d.mts +19 -0
  20. package/dist/useAccountInfo.d.ts +19 -0
  21. package/dist/useAccountInfo.mjs +6 -0
  22. package/dist/useProgramAccounts.cjs +12 -0
  23. package/dist/useProgramAccounts.d.cts +39 -0
  24. package/dist/useProgramAccounts.d.mts +39 -0
  25. package/dist/useProgramAccounts.d.ts +39 -0
  26. package/dist/useProgramAccounts.mjs +6 -0
  27. package/dist/useSignAndSendTransaction.cjs +3 -3
  28. package/dist/useSignAndSendTransaction.d.cts +19 -2
  29. package/dist/useSignAndSendTransaction.d.mts +19 -2
  30. package/dist/useSignAndSendTransaction.d.ts +19 -2
  31. package/dist/useSignAndSendTransaction.mjs +3 -3
  32. package/dist/useSignatureStatus.cjs +12 -0
  33. package/dist/useSignatureStatus.d.cts +21 -0
  34. package/dist/useSignatureStatus.d.mts +21 -0
  35. package/dist/useSignatureStatus.d.ts +21 -0
  36. package/dist/useSignatureStatus.mjs +6 -0
  37. package/dist/useTransactionConfirmation.cjs +13 -0
  38. package/dist/useTransactionConfirmation.d.cts +26 -0
  39. package/dist/useTransactionConfirmation.d.mts +26 -0
  40. package/dist/useTransactionConfirmation.d.ts +26 -0
  41. package/dist/useTransactionConfirmation.mjs +6 -0
  42. package/package.json +23 -2
  43. package/dist/shared/vue.DJ42Zrow.mjs +0 -24
  44. package/dist/shared/vue.DQmAPXVB.cjs +0 -26
package/README.md CHANGED
@@ -118,6 +118,26 @@ const { balance, loading, error, refresh } = useBalance(address);
118
118
  </template>
119
119
  ```
120
120
 
121
+ ## Read Account Data
122
+
123
+ ```ts
124
+ import { useAccountInfo } from "@vue-solana/vue/useAccountInfo";
125
+ import { useProgramAccounts } from "@vue-solana/vue/useProgramAccounts";
126
+ import { useSignatureStatus } from "@vue-solana/vue/useSignatureStatus";
127
+
128
+ const account = useAccountInfo(address, { watch: true });
129
+ const programAccounts = useProgramAccounts(programId, {
130
+ dataSlice: { offset: 0, length: 32 },
131
+ filters: [{ dataSize: 165 }],
132
+ });
133
+ const signatureStatus = useSignatureStatus(signature, {
134
+ pollIntervalMs: 2_000,
135
+ searchTransactionHistory: true,
136
+ });
137
+ ```
138
+
139
+ `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.
140
+
121
141
  ## Wallet State
122
142
 
123
143
  ```vue
@@ -165,14 +185,30 @@ Composables return inert SSR-safe state when no plugin context is available. Rea
165
185
  ```ts
166
186
  import { useSignAndSendTransaction } from "@vue-solana/vue/useSignAndSendTransaction";
167
187
 
168
- const { signature, loading, error, execute } = useSignAndSendTransaction();
188
+ const { signature, confirmation, status, loading, error, execute } = useSignAndSendTransaction();
169
189
 
170
190
  await execute(transaction, {
191
+ confirm: true,
192
+ confirmation: { commitment: "confirmed" },
171
193
  skipPreflight: false,
172
194
  });
173
195
  ```
174
196
 
175
- The current wallet must be connected and support either `signAndSendTransaction` or `signTransaction`. Android Mobile Wallet Adapter wallets prefer `signTransaction` plus app-side RPC submission when available. `loading` is also cleared if a wallet adapter never returns a result; in that stale case, check the wallet or an explorer before retrying because chain status may be unknown.
197
+ The current wallet must be connected and support either `signAndSendTransaction` or `signTransaction`. Android Mobile Wallet Adapter wallets prefer `signTransaction` plus app-side RPC submission when available. This avoids a mobile handoff edge case where the wallet sends successfully but the browser page does not receive the wallet adapter's returned signature.
198
+
199
+ Without `confirm: true`, `execute()` returns after submission and sets `status` to `sent`. With confirmation enabled, status moves through `sending`, `confirming`, and then `processed`, `confirmed`, or `finalized` to match the requested commitment. If confirmation times out or fails, the submitted `signature` remains available so the app can link to an explorer.
200
+
201
+ Use `useTransactionConfirmation()` when you already have a submitted signature and want to wait for confirmation separately:
202
+
203
+ ```ts
204
+ import { useTransactionConfirmation } from "@vue-solana/vue/useTransactionConfirmation";
205
+
206
+ const confirmation = useTransactionConfirmation({ commitment: "finalized" });
207
+
208
+ await confirmation.confirm(signature);
209
+ ```
210
+
211
+ `useSignAndSendTransaction()` also clears `loading` if a wallet adapter never returns a result. In that stale case, `error` is set and the chain status may be unknown, so check the connected wallet or an explorer before retrying.
176
212
 
177
213
  ## Example App
178
214
 
@@ -206,18 +242,26 @@ Docs: [Vue Solana Agent Skill](https://vue-solana-docs.vercel.app/agent-skill)
206
242
  - `useWallet()`: returns wallet refs, computed connection state, and wallet actions.
207
243
  - `useWallets()`: returns discovered browser extension wallets, Android Mobile Wallet Adapter wallets, iOS browser wallet links, and wallet selection actions.
208
244
  - `useBalance(address, commitment?)`: loads lamport balance for a `PublicKey` or address string.
245
+ - `useAccountInfo(address, options?)`: loads account info and can subscribe to account changes with `watch: true`.
246
+ - `useProgramAccounts(programId, config?)`: loads accounts owned by a program with optional filters, commitment, and `dataSlice`.
209
247
  - `useTransaction(handler, options?)`: generic async transaction state helper with optional timeout settings.
210
- - `useSignAndSendTransaction()`: signs and sends a transaction through the configured wallet.
248
+ - `useTransactionConfirmation(options?)`: confirms a submitted signature with reactive status and timeout/error state.
249
+ - `useSignatureStatus(signature, options?)`: reads a transaction signature status with optional polling or websocket subscription.
250
+ - `useSignAndSendTransaction()`: signs and sends a transaction through the configured wallet, with optional confirmation waiting.
211
251
 
212
252
  Direct composable subpaths:
213
253
 
214
254
  - `@vue-solana/vue/useSolana`
215
255
  - `@vue-solana/vue/useRpc`
216
256
  - `@vue-solana/vue/useConnection`
257
+ - `@vue-solana/vue/useAccountInfo`
217
258
  - `@vue-solana/vue/useBalance`
259
+ - `@vue-solana/vue/useProgramAccounts`
218
260
  - `@vue-solana/vue/useWallet`
219
261
  - `@vue-solana/vue/useWallets`
220
262
  - `@vue-solana/vue/useTransaction`
263
+ - `@vue-solana/vue/useTransactionConfirmation`
264
+ - `@vue-solana/vue/useSignatureStatus`
221
265
  - `@vue-solana/vue/useSignAndSendTransaction`
222
266
 
223
267
  ## Known TypeScript Issue
@@ -228,7 +272,15 @@ If TypeScript cannot resolve `@solana/web3-compat`, add `types/web3-compat.d.ts`
228
272
 
229
273
  ```ts
230
274
  declare module "@solana/web3-compat" {
231
- export type { Commitment, SendOptions, TransactionSignature } from "@solana/web3.js";
275
+ export type {
276
+ AccountInfo,
277
+ Commitment,
278
+ RpcResponseAndContext,
279
+ SendOptions,
280
+ SignatureResult,
281
+ SignatureStatus,
282
+ TransactionSignature,
283
+ } from "@solana/web3.js";
232
284
  export {
233
285
  Connection,
234
286
  Keypair,
package/dist/index.cjs CHANGED
@@ -1,19 +1,25 @@
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.DQmAPXVB.cjs');
8
+ const useSignAndSendTransaction = require('./shared/vue.DEQJ23UM.cjs');
9
+ const useSignatureStatus = require('./shared/vue.DUufwq8y.cjs');
7
10
  const useSolana = require('./shared/vue.C4tLiG3R.cjs');
8
11
  const useTransaction = require('./shared/vue.DQi38JeF.cjs');
12
+ const useTransactionConfirmation = require('./shared/vue.DHVYJk8P.cjs');
9
13
  const useWallet = require('./shared/vue.CwPjPFN6.cjs');
10
14
  const useWallets = require('./shared/vue.P9tgeC5S.cjs');
11
15
  const rpc = require('@vue-solana/core/rpc');
12
16
  const walletStandard = require('@vue-solana/core/wallet-standard');
13
17
  const vue = require('vue');
14
18
  const iosWallet = require('@vue-solana/core/ios-wallet');
19
+ require('@vue-solana/core/address');
15
20
  require('@solana/web3-compat');
16
21
  require('@vue-solana/core/transaction');
22
+ require('bs58');
17
23
 
18
24
  const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
19
25
  function readSelectedWallet() {
@@ -315,14 +321,19 @@ function isSameWallet(wallet, selectedWallet) {
315
321
  }
316
322
  const VueSolana = createSolanaPlugin;
317
323
 
324
+ exports.useAccountInfo = useAccountInfo.useAccountInfo;
318
325
  exports.useBalance = useBalance.useBalance;
319
326
  exports.useConnection = useConnection.useConnection;
327
+ exports.useProgramAccounts = useProgramAccounts.useProgramAccounts;
320
328
  exports.useRpc = useRpc.useRpc;
321
329
  exports.useSignAndSendTransaction = useSignAndSendTransaction.useSignAndSendTransaction;
330
+ exports.useSignatureStatus = useSignatureStatus.useSignatureStatus;
322
331
  exports.solanaInjectionKey = useSolana.solanaInjectionKey;
323
332
  exports.tryUseSolana = useSolana.tryUseSolana;
324
333
  exports.useSolana = useSolana.useSolana;
325
334
  exports.useTransaction = useTransaction.useTransaction;
335
+ exports.getConfirmedTransactionStatus = useTransactionConfirmation.getConfirmedTransactionStatus;
336
+ exports.useTransactionConfirmation = useTransactionConfirmation.useTransactionConfirmation;
326
337
  exports.useWallet = useWallet.useWallet;
327
338
  exports.useWallets = useWallets.useWallets;
328
339
  exports.VueSolana = VueSolana;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,13 @@
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';
4
- export { useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
6
+ export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
7
+ export { UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.cjs';
5
8
  export { tryUseSolana, useSolana } from './useSolana.cjs';
6
9
  export { UseTransactionOptions, useTransaction } from './useTransaction.cjs';
10
+ export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.cjs';
7
11
  export { useWallet } from './useWallet.cjs';
8
12
  export { useWallets } from './useWallets.cjs';
9
13
  export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.cjs';
@@ -11,6 +15,7 @@ import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
11
15
  import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
12
16
  import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
13
17
  import { App } from 'vue';
18
+ import '@vue-solana/core/address';
14
19
  import '@solana/web3-compat';
15
20
 
16
21
  interface VueSolanaPluginOptions extends SolanaConfig {
package/dist/index.d.mts CHANGED
@@ -1,9 +1,13 @@
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';
4
- export { useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
6
+ export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
7
+ export { UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.mjs';
5
8
  export { tryUseSolana, useSolana } from './useSolana.mjs';
6
9
  export { UseTransactionOptions, useTransaction } from './useTransaction.mjs';
10
+ export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.mjs';
7
11
  export { useWallet } from './useWallet.mjs';
8
12
  export { useWallets } from './useWallets.mjs';
9
13
  export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.mjs';
@@ -11,6 +15,7 @@ import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
11
15
  import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
12
16
  import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
13
17
  import { App } from 'vue';
18
+ import '@vue-solana/core/address';
14
19
  import '@solana/web3-compat';
15
20
 
16
21
  interface VueSolanaPluginOptions extends SolanaConfig {
package/dist/index.d.ts CHANGED
@@ -1,9 +1,13 @@
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';
4
- export { useSignAndSendTransaction } from './useSignAndSendTransaction.js';
6
+ export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.js';
7
+ export { UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.js';
5
8
  export { tryUseSolana, useSolana } from './useSolana.js';
6
9
  export { UseTransactionOptions, useTransaction } from './useTransaction.js';
10
+ export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.js';
7
11
  export { useWallet } from './useWallet.js';
8
12
  export { useWallets } from './useWallets.js';
9
13
  export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.js';
@@ -11,6 +15,7 @@ import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
11
15
  import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
12
16
  import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
13
17
  import { App } from 'vue';
18
+ import '@vue-solana/core/address';
14
19
  import '@solana/web3-compat';
15
20
 
16
21
  interface VueSolanaPluginOptions extends SolanaConfig {
package/dist/index.mjs CHANGED
@@ -1,19 +1,25 @@
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.DJ42Zrow.mjs';
6
+ export { u as useSignAndSendTransaction } from './shared/vue.RQ9fETnm.mjs';
7
+ export { u as useSignatureStatus } from './shared/vue.JC5FdU2O.mjs';
5
8
  import { s as solanaInjectionKey } from './shared/vue.1M_c5FWA.mjs';
6
9
  export { t as tryUseSolana, u as useSolana } from './shared/vue.1M_c5FWA.mjs';
7
10
  import { w as withTimeout } from './shared/vue.gLqkzJY4.mjs';
8
11
  export { u as useTransaction } from './shared/vue.gLqkzJY4.mjs';
12
+ export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.jOsz34kz.mjs';
9
13
  export { u as useWallet } from './shared/vue.DYf_CRDv.mjs';
10
14
  export { u as useWallets } from './shared/vue.h-uS8MXN.mjs';
11
15
  import { createSolanaContext } from '@vue-solana/core/rpc';
12
16
  import { getRegisteredSolanaWallets, getSolanaChain, adaptSolanaStandardWallet, subscribeSolanaWallets } from '@vue-solana/core/wallet-standard';
13
17
  import { shallowRef, ref, triggerRef } from 'vue';
14
18
  import { handleSolanaIosWalletCallback, getSolanaIosWallets, isSolanaIosWalletInfo, adaptSolanaIosWallet } from '@vue-solana/core/ios-wallet';
19
+ import '@vue-solana/core/address';
15
20
  import '@solana/web3-compat';
16
21
  import '@vue-solana/core/transaction';
22
+ import 'bs58';
17
23
 
18
24
  const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
19
25
  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,71 @@
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 useProgramAccounts(programId, options = {}) {
7
+ const solana = tryUseSolana();
8
+ const connection = solana?.connection ?? useConnection();
9
+ const accounts = shallowRef([]);
10
+ const loading = shallowRef(false);
11
+ const error = shallowRef(null);
12
+ let refreshId = 0;
13
+ async function refresh() {
14
+ const requestId = ++refreshId;
15
+ const value = toValue(programId);
16
+ if (!value || !solana) {
17
+ accounts.value = [];
18
+ loading.value = false;
19
+ error.value = null;
20
+ return [];
21
+ }
22
+ loading.value = true;
23
+ error.value = null;
24
+ try {
25
+ const publicKey = parsePublicKey(value);
26
+ if (!publicKey) {
27
+ accounts.value = [];
28
+ return [];
29
+ }
30
+ const nextAccounts = await connection.getProgramAccounts(publicKey, {
31
+ commitment: options.commitment,
32
+ dataSlice: options.dataSlice,
33
+ filters: options.filters
34
+ });
35
+ if (requestId === refreshId) {
36
+ accounts.value = nextAccounts;
37
+ }
38
+ return nextAccounts;
39
+ } catch (cause) {
40
+ if (requestId === refreshId) {
41
+ accounts.value = [];
42
+ error.value = cause;
43
+ }
44
+ throw cause;
45
+ } finally {
46
+ if (requestId === refreshId) {
47
+ loading.value = false;
48
+ }
49
+ }
50
+ }
51
+ onMounted(() => {
52
+ void refresh().catch(() => void 0);
53
+ });
54
+ onUnmounted(() => {
55
+ refreshId += 1;
56
+ });
57
+ watch(
58
+ () => toValue(programId),
59
+ () => {
60
+ void refresh().catch(() => void 0);
61
+ }
62
+ );
63
+ return {
64
+ accounts,
65
+ loading,
66
+ error,
67
+ refresh
68
+ };
69
+ }
70
+
71
+ export { useProgramAccounts as u };
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ const transaction = require('@vue-solana/core/transaction');
4
+ const vue = require('vue');
5
+ const useConnection = require('./vue.CwhEmATP.cjs');
6
+ const useWallet = require('./vue.CwPjPFN6.cjs');
7
+ const useTransactionConfirmation = require('./vue.DHVYJk8P.cjs');
8
+
9
+ const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
10
+ function useSignAndSendTransaction() {
11
+ const connection = useConnection.useConnection();
12
+ const { wallet } = useWallet.useWallet();
13
+ const signature = vue.ref(null);
14
+ const confirmation = vue.ref(null);
15
+ const status = vue.ref("idle");
16
+ const loading = vue.ref(false);
17
+ const error = vue.ref(null);
18
+ let executionId = 0;
19
+ async function execute(transaction$1, options) {
20
+ const currentExecutionId = ++executionId;
21
+ const { confirm, confirmation: confirmationOptions, ...sendOptions } = options ?? {};
22
+ const transactionOptions = Object.keys(sendOptions).length > 0 ? sendOptions : void 0;
23
+ status.value = "sending";
24
+ loading.value = true;
25
+ error.value = null;
26
+ confirmation.value = null;
27
+ try {
28
+ if (!wallet.value) {
29
+ throw new Error("No Solana wallet is configured");
30
+ }
31
+ const nextSignature = await withWalletTransactionTimeout(
32
+ transaction.signAndSendTransaction(connection, wallet.value, transaction$1, transactionOptions)
33
+ );
34
+ if (currentExecutionId === executionId) {
35
+ signature.value = nextSignature;
36
+ status.value = confirm ? "confirming" : "sent";
37
+ }
38
+ if (!confirm) {
39
+ return nextSignature;
40
+ }
41
+ const nextConfirmation = await transaction.confirmTransactionSignature(
42
+ connection,
43
+ nextSignature,
44
+ confirmationOptions
45
+ );
46
+ if (currentExecutionId === executionId) {
47
+ confirmation.value = nextConfirmation;
48
+ status.value = useTransactionConfirmation.getConfirmedTransactionStatus(nextConfirmation);
49
+ }
50
+ return nextSignature;
51
+ } catch (cause) {
52
+ if (currentExecutionId === executionId) {
53
+ error.value = cause;
54
+ status.value = "error";
55
+ }
56
+ throw cause;
57
+ } finally {
58
+ if (currentExecutionId === executionId) {
59
+ loading.value = false;
60
+ }
61
+ }
62
+ }
63
+ return {
64
+ signature,
65
+ confirmation,
66
+ status,
67
+ loading,
68
+ error,
69
+ execute
70
+ };
71
+ }
72
+ async function withWalletTransactionTimeout(promise) {
73
+ let timeoutId;
74
+ try {
75
+ const timeout = new Promise((_, reject) => {
76
+ timeoutId = setTimeout(() => {
77
+ reject(
78
+ new Error(
79
+ "Wallet transaction did not return a result. Check your wallet or explorer for the final status."
80
+ )
81
+ );
82
+ }, SIGN_AND_SEND_TIMEOUT_MS);
83
+ });
84
+ return await Promise.race([promise, timeout]);
85
+ } finally {
86
+ if (timeoutId) {
87
+ clearTimeout(timeoutId);
88
+ }
89
+ }
90
+ }
91
+
92
+ exports.useSignAndSendTransaction = useSignAndSendTransaction;