@vue-solana/vue 2.1.0 → 2.3.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 (67) hide show
  1. package/README.md +177 -0
  2. package/dist/index.cjs +9 -4
  3. package/dist/index.d.cts +5 -3
  4. package/dist/index.d.mts +5 -3
  5. package/dist/index.d.ts +5 -3
  6. package/dist/index.mjs +6 -4
  7. package/dist/shared/{vue.DImwKTwJ.mjs → vue.B8VvC8d2.mjs} +18 -20
  8. package/dist/shared/{vue.B8ub540p.mjs → vue.BDNOyiGZ.mjs} +7 -7
  9. package/dist/shared/vue.BFbIDI66.cjs +121 -0
  10. package/dist/shared/vue.BSfiHqwj.mjs +34 -0
  11. package/dist/shared/{vue.B4-LEdSE.cjs → vue.BfGt94sg.cjs} +20 -2
  12. package/dist/shared/{vue.C5FVoEZT.mjs → vue.C4hGlFC8.mjs} +21 -3
  13. package/dist/shared/vue.CTqPbvz3.cjs +36 -0
  14. package/dist/shared/{vue.CogzzQXM.mjs → vue.CbJFnho-.mjs} +4 -4
  15. package/dist/shared/vue.DT4vCUa6.mjs +118 -0
  16. package/dist/shared/{vue.DtCbCcPd.cjs → vue.DxM45azl.cjs} +4 -4
  17. package/dist/shared/{vue.B8pLQ8P4.cjs → vue.ZuUCEEab.cjs} +18 -20
  18. package/dist/shared/{vue.BVj9lWBK.cjs → vue.l3UCdN7z.cjs} +7 -7
  19. package/dist/swr.cjs +3 -3
  20. package/dist/swr.mjs +3 -3
  21. package/dist/useAirdrop.cjs +14 -0
  22. package/dist/useAirdrop.d.cts +25 -0
  23. package/dist/useAirdrop.d.mts +25 -0
  24. package/dist/useAirdrop.d.ts +25 -0
  25. package/dist/useAirdrop.mjs +8 -0
  26. package/dist/useConnection.d.cts +3 -2
  27. package/dist/useConnection.d.mts +3 -2
  28. package/dist/useConnection.d.ts +3 -2
  29. package/dist/usePlanTransaction.cjs +1 -1
  30. package/dist/usePlanTransaction.d.cts +4 -0
  31. package/dist/usePlanTransaction.d.mts +4 -0
  32. package/dist/usePlanTransaction.d.ts +4 -0
  33. package/dist/usePlanTransaction.mjs +1 -1
  34. package/dist/usePlanTransactions.cjs +1 -1
  35. package/dist/usePlanTransactions.mjs +1 -1
  36. package/dist/useRequest.cjs +1 -1
  37. package/dist/useRequest.d.cts +22 -6
  38. package/dist/useRequest.d.mts +22 -6
  39. package/dist/useRequest.d.ts +22 -6
  40. package/dist/useRequest.mjs +1 -1
  41. package/dist/useRpc.d.cts +3 -2
  42. package/dist/useRpc.d.mts +3 -2
  43. package/dist/useRpc.d.ts +3 -2
  44. package/dist/useSendTransaction.cjs +14 -0
  45. package/dist/useSendTransaction.d.cts +46 -0
  46. package/dist/useSendTransaction.d.mts +46 -0
  47. package/dist/useSendTransaction.d.ts +46 -0
  48. package/dist/useSendTransaction.mjs +7 -0
  49. package/dist/useSendTransactions.cjs +13 -0
  50. package/dist/useSendTransactions.d.cts +4 -0
  51. package/dist/useSendTransactions.d.mts +4 -0
  52. package/dist/useSendTransactions.d.ts +4 -0
  53. package/dist/useSendTransactions.mjs +7 -0
  54. package/dist/useSolanaClient.d.cts +3 -2
  55. package/dist/useSolanaClient.d.mts +3 -2
  56. package/dist/useSolanaClient.d.ts +3 -2
  57. package/dist/useSubscription.cjs +1 -1
  58. package/dist/useSubscription.d.cts +15 -3
  59. package/dist/useSubscription.d.mts +15 -3
  60. package/dist/useSubscription.d.ts +15 -3
  61. package/dist/useSubscription.mjs +1 -1
  62. package/dist/useTrackedData.cjs +1 -1
  63. package/dist/useTrackedData.d.cts +15 -3
  64. package/dist/useTrackedData.d.mts +15 -3
  65. package/dist/useTrackedData.d.ts +15 -3
  66. package/dist/useTrackedData.mjs +1 -1
  67. package/package.json +17 -2
package/README.md CHANGED
@@ -116,6 +116,28 @@ import { useWallet } from "@vue-solana/vue/useWallet";
116
116
  import { useSignMessage } from "@vue-solana/vue/useSignMessage";
117
117
  ```
118
118
 
119
+ ### Client and Plugin Lifecycle
120
+
121
+ `createSolanaPlugin()` builds the Kit client once, during `install()`. Create the plugin at module scope and reuse the instance:
122
+
123
+ ```ts
124
+ // solana.ts
125
+ import { createSolanaPlugin } from "@vue-solana/vue";
126
+
127
+ export const solana = createSolanaPlugin({ cluster: "devnet" });
128
+ ```
129
+
130
+ Calling `createSolanaPlugin()` again builds a new client and context, discarding the existing wallet selection and RPC state. If your config is reactive — a cluster toggle, for example — memoize on the config so a new plugin (and client) is built only when the value actually changes, not on every render:
131
+
132
+ ```ts
133
+ import { computed, ref } from "vue";
134
+
135
+ const cluster = ref<SolanaCluster>("devnet");
136
+ const plugin = computed(() => createSolanaPlugin({ cluster: cluster.value }));
137
+ ```
138
+
139
+ A Kit client runs its `createClient().use(...)` plugins during construction. When one of those plugins is async, the client — and any context built from it — only activates after that promise resolves. Defer real RPC and wallet work to client lifecycle hooks or user actions after hydration rather than running it during setup or SSR.
140
+
119
141
  For development, use `devnet` and request free test SOL from the official faucet:
120
142
 
121
143
  ```txt
@@ -164,6 +186,22 @@ const { balance, loading, error, refresh } = useBalance(address);
164
186
  </template>
165
187
  ```
166
188
 
189
+ ### Airdrop on Test Networks
190
+
191
+ `useAirdrop()` sends SOL to an account on devnet, testnet, or a local validator. It requires an airdrop capability on the Kit client, installed with `createClient().use(solanaRpcConnection({ ... })).use(rpcAirdrop())` from `@solana/kit-plugin-rpc`.
192
+
193
+ ```ts
194
+ import { lamports } from "@solana/kit";
195
+ import { useAirdrop } from "@vue-solana/vue/useAirdrop";
196
+
197
+ const { data, status, error, dispatch } = useAirdrop();
198
+ await dispatch(address, lamports(1_000_000_000)); // 1 SOL
199
+ ```
200
+
201
+ Each `dispatch(address, amount)` runs a fresh airdrop and aborts the previous in-flight call. `data` resolves to the transaction `Signature`, or to `undefined` when the network applies the airdrop without a transaction (some local validators, e.g. LiteSVM).
202
+
203
+ Airdrops to a single address are rate-limited (public devnets commonly return HTTP 429, and 1 SOL requires enough devnet balance); wait before dispatching again or use a fresh address. Errors surface through `error` / the `error` state.
204
+
167
205
  ## Read Account Data
168
206
 
169
207
  ```ts
@@ -299,6 +337,106 @@ await confirmation.confirm(signature);
299
337
 
300
338
  `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.
301
339
 
340
+ ### Wallet Request Inputs and Returns
341
+
342
+ Wallet signing flows accept transaction input as raw `Uint8Array` wire bytes that conform to the Solana transaction schema. Build them with `@solana/kit` (or decode them from a base64/base58 RPC response); base64 strings, transaction objects, and instruction lists are not accepted here.
343
+
344
+ ```ts
345
+ import { compileTransaction, getTransactionEncoder } from "@solana/kit";
346
+
347
+ const transaction: Uint8Array = getTransactionEncoder().encode(compileTransaction(message));
348
+ await execute(transaction);
349
+ ```
350
+
351
+ `useSignMessage()` takes the raw message bytes to sign. Every wallet send request also accepts the Kit `SendTransactionOptions`:
352
+
353
+ | Option | Description |
354
+ | --------------------- | ------------------------------------------------------------------------------------------------------------- |
355
+ | `skipPreflight` | Skip preflight simulation before sending. |
356
+ | `maxRetries` | RPC node retry count (`bigint`). |
357
+ | `minContextSlot` | Slot at which any blockhash or nonce in the transaction is known to exist; sending before it can be rejected. |
358
+ | `preflightCommitment` | Commitment used for preflight simulation. |
359
+
360
+ Return shapes:
361
+
362
+ - `useSignMessage().execute(bytes)` resolves to `{ signedMessage, signature }`, both `Uint8Array`.
363
+ - `useSignTransactions().execute(transactions)` resolves to the signed `Uint8Array[]` (also exposed as `signedTransactions`); pass a single-element array for one transaction.
364
+ - `useSignAndSendTransaction().execute(transaction)` resolves to the submitted `signature` string; with `confirm: true` it also fills `confirmation`.
365
+ - `useSignAndSendTransactions().execute(transactions)` resolves to a `string[]` of signatures (also exposed as `signatures`).
366
+
367
+ A wallet may modify the message or transaction before signing — for example to add its own instruction or change the fee payer — and the Wallet Standard explicitly allows it. Re-read the returned `signedMessage` or signed transaction bytes instead of assuming they match your input byte-for-byte.
368
+
369
+ ### Sending with the Client (no wallet popup)
370
+
371
+ `useSendTransaction()` and `useSendTransactions()` send through the Kit client's transaction-sending capability (`ClientWithTransactionSending`) instead of the connected wallet. The client plans the transaction from your input, signs it with its own signers — typically the client identity or `payer` keypair, e.g. a relayer — submits it, and returns the result. There is no wallet extension and no approval popup.
372
+
373
+ **Which to use:**
374
+
375
+ | Flow | `useSendTransaction(s)` (client) | `useSignAndSendTransaction(s)` (wallet) |
376
+ | --------------------- | ------------------------------------------------------------ | ----------------------------------------- |
377
+ | Who authorizes | The client's fee payer / signer keypairs | The connected wallet (user approves) |
378
+ | Environment | Server-side, relayer, or automated flows (no browser wallet) | Browser dapps where the user must approve |
379
+ | Popup | None | Wallet approval popup / mobile handoff |
380
+ | Input | Instructions, instruction plans, transaction messages, plans | Raw transaction bytes (`Uint8Array`) |
381
+ | Multiple transactions | Yes, as a batch in one call | Yes, one or more wallet requests |
382
+
383
+ Use the client flow for automated or server-backed signing (airdrop faucet, cron jobs, relayer fees paid by your keypair), and the wallet flow when the end user must own and approve each transaction.
384
+
385
+ **Prerequisite.** Your Kit client must install a transaction planner and a transaction-sending executor, e.g. `rpcTransactionPlanner()` and `rpcTransactionPlanSendingExecutor()` from `@solana/kit-plugin-rpc`. The default client built by `createSolanaPlugin()` installs only RPC and airdrop plugins, so without a capable client both composables fail fast at setup with a clear capability error naming what to install. Plan first with `usePlanTransaction()` / `usePlanTransactions()` when you need separate planning and sending steps.
386
+
387
+ ```ts
388
+ import { useSendTransaction } from "@vue-solana/vue/useSendTransaction";
389
+ import { useSendTransactions } from "@vue-solana/vue/useSendTransactions";
390
+
391
+ const single = useSendTransaction();
392
+ const batch = useSendTransactions();
393
+ ```
394
+
395
+ `useSendTransaction().execute()` accepts flexible input and resolves to the successful transaction result:
396
+
397
+ ```ts
398
+ const { data, status, error, execute } = useSendTransaction();
399
+
400
+ // A raw list of instructions
401
+ await execute(instructions);
402
+
403
+ // A planned instruction plan or a single transaction plan
404
+ await execute(plan);
405
+
406
+ // A single transaction message
407
+ await execute(transactionMessage);
408
+
409
+ // data.context.signature is the submitted Signature
410
+ ```
411
+
412
+ `useSendTransactions().execute()` plans, signs, and sends one or more messages at once — parallel where possible, sequential where dependencies require it — and resolves to the full plan result tree:
413
+
414
+ ```ts
415
+ const { data, status, error, execute } = useSendTransactions();
416
+
417
+ // A batch of transaction messages
418
+ await execute([messageA, messageB]);
419
+
420
+ // A message, a plan, or a nested batch of messages/plans
421
+ await execute(nestedBatch);
422
+ ```
423
+
424
+ Both composables surface `status` (`idle`, `sending`, `sent`, `error`), `loading`, `error`, and `data`. Starting a new `execute()` while one is in flight aborts the previous call; the stale attempt rejects and its state is discarded. Pass an `{ abortSignal }` to additionally cancel from outside (unmounting the owning component also aborts in-flight work).
425
+
426
+ Because signing keypairs live on the client, reserve `useSendTransaction(s)` for trusted contexts (your relayer, automated flows). Do not register app-signing keypairs on a client exposed to end-user browsers, where a compromised page could spend funds.
427
+
428
+ Superseded or aborted attempts reject with a wrapped error. To tell "superseded or cancelled" apart from a real failure, inspect the rejection's `cause`:
429
+
430
+ ```ts
431
+ try {
432
+ await execute(instructions);
433
+ } catch (cause) {
434
+ if (cause?.cause instanceof DOMException && cause.cause.name === "AbortError") {
435
+ // superseded by a newer call or cancelled via abortSignal / unmount
436
+ }
437
+ }
438
+ ```
439
+
302
440
  ### Live Data
303
441
 
304
442
  `useRequest()` fetches once per change and revalidates stale data in the background. Pass a request function, a pending Kit RPC request, or a ref/computed of either:
@@ -341,6 +479,39 @@ import { useRequestSwr } from "@vue-solana/vue/swr";
341
479
  const balance = useRequestSwr(["balance", address], () => client.rpc.getBalance(address).send());
342
480
  ```
343
481
 
482
+ ### Cancellation & Timeouts
483
+
484
+ `useRequest()`, `useSubscription()`, and `useTrackedData()` accept a `getAbortSignal` option — a factory called once per attempt (request) or connection (subscription/tracked data). It is the natural place for a timeout:
485
+
486
+ ```ts
487
+ const { data, refresh } = useRequest(source, {
488
+ getAbortSignal: (attempt) => AbortSignal.timeout(10_000),
489
+ });
490
+
491
+ await refresh({ abortSignal: AbortSignal.timeout(2_000) });
492
+ ```
493
+
494
+ The factory is read fresh from the latest render on every attempt, so inline closures work without `useCallback`-style wrapping. Each manual refresh or reconnect can instead pass a single `{ abortSignal }` override that replaces the factory for that attempt; pass `AbortSignal` explicitly as `undefined` to skip caller cancellation entirely. Aborting the composed signal fails only that attempt — previous `data` is kept and `status` drops back to `error`.
495
+
496
+ To kill the data hook entirely, set its source to `null` (status becomes `disabled` and in-flight work is cancelled) or unmount the component that owns it.
497
+
498
+ ### Actions with `useAction`
499
+
500
+ `useAction()` and its derivatives (`useAirdrop()`, `useSignAndSendTransaction()` themes) manage one async action at a time:
501
+
502
+ ```ts
503
+ const { data, status, error, dispatch } = useAction(async (signal, input) => {
504
+ /* ... */
505
+ });
506
+
507
+ dispatch(inputA); // runs
508
+ await dispatch(inputB); // aborts dispatch(inputA) before starting
509
+ ```
510
+
511
+ - `useAction` keeps the handler in a ref — every `dispatch` runs the latest closure, so there is no deps array to keep in sync. In-flight calls keep running with the closure they started with.
512
+ - `dispatch` returns a `Promise<TResult>`. If a newer dispatch supersedes it, the older promise rejects with an abort error; awaiters should treat that as "superseded", not a failure, and fresh awaits win.
513
+ - Calling `dispatch` again aborts the prior in-flight call with a fresh `AbortSignal`, and resets state to `idle` before the new run starts.
514
+
344
515
  ### Sign In With Solana
345
516
 
346
517
  `useSignIn()` triggers the SIWS flow when the connected wallet supports the `solana:signIn` feature:
@@ -420,6 +591,7 @@ Docs: [Vue Solana Agent Skill](https://vue-solana-docs.vercel.app/agent-skill)
420
591
  | `useWallets()` | Returns discovered browser extension wallets, Android MWA wallets, iOS browser wallet links, and wallet selection actions. |
421
592
  | `useSignMessage()` | Signs arbitrary message bytes through the connected wallet when message signing is supported. |
422
593
  | `useBalance(address, commitment?)` | Loads lamport balance for an address string. |
594
+ | `useAirdrop()` | Airdrops SOL on devnet/testnet/localnets; `data` is the `Signature`, or `undefined` when applied directly. |
423
595
  | `useAccountInfo(address, options?)` | Loads normalized account info (executable, lamports, owner, space, data bytes). |
424
596
  | `useProgramAccounts(programId, config?)` | Loads accounts owned by a program with optional filters, commitment, and `dataSlice`. |
425
597
  | `useTransaction(handler, options?)` | Generic async transaction state helper with optional timeout settings. |
@@ -444,6 +616,8 @@ Docs: [Vue Solana Agent Skill](https://vue-solana-docs.vercel.app/agent-skill)
444
616
  | `useIdentity()` | Reactive Kit client `identity` signer ref (requires a signer plugin on the client). |
445
617
  | `usePlanTransaction()` | Plans a single transaction message from instruction inputs without signing or sending. |
446
618
  | `usePlanTransactions()` | Plans a batch of transaction messages from instruction inputs. |
619
+ | `useSendTransaction()` | Plans, signs, submits, and confirms one transaction through the client's transaction-sending capability (no wallet). |
620
+ | `useSendTransactions()` | Sends a batch of transactions (parallel or sequential) through the client's transaction-sending capability. |
447
621
 
448
622
  Direct composable subpaths:
449
623
 
@@ -452,6 +626,7 @@ Direct composable subpaths:
452
626
  - `@vue-solana/vue/useRpc`
453
627
  - `@vue-solana/vue/useConnection`
454
628
  - `@vue-solana/vue/useAccountInfo`
629
+ - `@vue-solana/vue/useAirdrop`
455
630
  - `@vue-solana/vue/useBalance`
456
631
  - `@vue-solana/vue/useProgramAccounts`
457
632
  - `@vue-solana/vue/useWallet`
@@ -476,6 +651,8 @@ Direct composable subpaths:
476
651
  - `@vue-solana/vue/useIdentity`
477
652
  - `@vue-solana/vue/usePlanTransaction`
478
653
  - `@vue-solana/vue/usePlanTransactions`
654
+ - `@vue-solana/vue/useSendTransaction`
655
+ - `@vue-solana/vue/useSendTransactions`
479
656
 
480
657
  Other direct subpaths:
481
658
 
package/dist/index.cjs CHANGED
@@ -2,15 +2,17 @@
2
2
 
3
3
  const useAccountInfo = require('./shared/vue.D-qi8PSL.cjs');
4
4
  const useAction = require('./shared/vue.CoaIWGPT.cjs');
5
+ const useAirdrop = require('./shared/vue.CTqPbvz3.cjs');
5
6
  const useBalance = require('./shared/vue.E_npPFoV.cjs');
6
7
  const useClientCapability = require('./shared/vue.BY0qpgYr.cjs');
7
8
  const useConnection = require('./shared/vue.BVaMoz9y.cjs');
8
- const usePlanTransaction = require('./shared/vue.B4-LEdSE.cjs');
9
+ const usePlanTransaction = require('./shared/vue.BfGt94sg.cjs');
9
10
  const useProgramAccounts = require('./shared/vue.Di7yjJ-R.cjs');
10
11
  const usePayer = require('./shared/vue.g8fnm_ca.cjs');
11
- const useRequest = require('./shared/vue.B8pLQ8P4.cjs');
12
+ const useRequest = require('./shared/vue.ZuUCEEab.cjs');
12
13
  const useRpc = require('./shared/vue.FiMmnMHr.cjs');
13
14
  const SelectedWalletAccountProvider = require('./shared/vue.DDbVk0Zh.cjs');
15
+ const useSendTransaction = require('./shared/vue.BFbIDI66.cjs');
14
16
  const useSignMessage = require('./shared/vue.B6ainw2G.cjs');
15
17
  const useSignAndSendTransaction = require('./shared/vue.CWZSMVnB.cjs');
16
18
  const useSignTransactions = require('./shared/vue.DFaMJLAQ.cjs');
@@ -19,10 +21,10 @@ const useSignatureStatus = require('./shared/vue.CIs8QhCw.cjs');
19
21
  const useSignIn = require('./shared/vue.9TPxZPMf.cjs');
20
22
  const useSolana = require('./shared/vue.DE3emjSF.cjs');
21
23
  const useSolanaClient = require('./shared/vue.BIxphCAq.cjs');
22
- const useSubscription = require('./shared/vue.BVj9lWBK.cjs');
24
+ const useSubscription = require('./shared/vue.l3UCdN7z.cjs');
23
25
  const useTokenAccounts = require('./shared/vue.Bwd1sGAM.cjs');
24
26
  const useTokenBalance = require('./shared/vue.DAg5wC1G.cjs');
25
- const useTrackedData = require('./shared/vue.DtCbCcPd.cjs');
27
+ const useTrackedData = require('./shared/vue.DxM45azl.cjs');
26
28
  const useTransaction = require('./shared/vue.Bk5xjlUx.cjs');
27
29
  const useTransactionConfirmation = require('./shared/vue.Sbbm9JSu.cjs');
28
30
  const useWallet = require('./shared/vue.BGxz4dru.cjs');
@@ -386,6 +388,7 @@ const VueSolana = createSolanaPlugin;
386
388
 
387
389
  exports.useAccountInfo = useAccountInfo.useAccountInfo;
388
390
  exports.useAction = useAction.useAction;
391
+ exports.useAirdrop = useAirdrop.useAirdrop;
389
392
  exports.useBalance = useBalance.useBalance;
390
393
  exports.MissingClientCapabilityError = useClientCapability.MissingClientCapabilityError;
391
394
  exports.useClientCapability = useClientCapability.useClientCapability;
@@ -402,6 +405,8 @@ exports.createSelectedWalletAccountContext = SelectedWalletAccountProvider.creat
402
405
  exports.provideSelectedWalletAccount = SelectedWalletAccountProvider.provideSelectedWalletAccount;
403
406
  exports.selectedWalletAccountInjectionKey = SelectedWalletAccountProvider.selectedWalletAccountInjectionKey;
404
407
  exports.useSelectedWalletAccount = SelectedWalletAccountProvider.useSelectedWalletAccount;
408
+ exports.useSendTransaction = useSendTransaction.useSendTransaction;
409
+ exports.useSendTransactions = useSendTransaction.useSendTransactions;
405
410
  exports.useSignMessage = useSignMessage.useSignMessage;
406
411
  exports.useSignAndSendTransaction = useSignAndSendTransaction.useSignAndSendTransaction;
407
412
  exports.useSignTransactions = useSignTransactions.useSignTransactions;
package/dist/index.d.cts CHANGED
@@ -1,14 +1,16 @@
1
1
  export { AccountInfo, UseAccountInfoOptions, useAccountInfo } from './useAccountInfo.cjs';
2
2
  export { UseActionOptions, UseActionReturn, UseActionStatus, useAction } from './useAction.cjs';
3
+ export { useAirdrop } from './useAirdrop.cjs';
3
4
  export { BalanceInput, useBalance } from './useBalance.cjs';
4
5
  export { MissingClientCapabilityError, UseClientCapabilityOptions, useClientCapability } from './useClientCapability.cjs';
5
6
  export { useConnection } from './useConnection.cjs';
6
7
  export { PlanTransactionConfig, PlanTransactionStatus, usePlanTransaction, usePlanTransactions } from './usePlanTransaction.cjs';
7
8
  export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.cjs';
8
9
  export { useIdentity, usePayer } from './usePayer.cjs';
9
- export { UseRequestOptions, UseRequestReturn, UseRequestSource, UseRequestStatus, useRequest } from './useRequest.cjs';
10
+ export { UseRequestOptions, UseRequestRefresherOptions, UseRequestReturn, UseRequestSource, UseRequestStatus, useRequest } from './useRequest.cjs';
10
11
  export { useRpc } from './useRpc.cjs';
11
12
  export { SelectedWalletAccount, SelectedWalletAccountContext, SelectedWalletAccountOptions, SelectedWalletAccountProvider, WalletAccountFilter, createSelectedWalletAccountContext, provideSelectedWalletAccount, selectedWalletAccountInjectionKey, useSelectedWalletAccount } from './useSelectedWalletAccount.cjs';
13
+ export { SendTransactionConfig, SendTransactionInput, SendTransactionStatus, SendTransactionsInput, useSendTransaction, useSendTransactions } from './useSendTransaction.cjs';
12
14
  export { SignMessageStatus, useSignMessage } from './useSignMessage.cjs';
13
15
  export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
14
16
  export { SignTransactionsStatus, useSignTransactions } from './useSignTransactions.cjs';
@@ -17,10 +19,10 @@ export { SignatureStatus, UseSignatureStatusOptions, useSignatureStatus } from '
17
19
  export { SignInStatus, useSignIn } from './useSignIn.cjs';
18
20
  export { tryUseSolana, useSolana } from './useSolana.cjs';
19
21
  export { useSolanaClient } from './useSolanaClient.cjs';
20
- export { UseSubscriptionOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus, useSubscription } from './useSubscription.cjs';
22
+ export { UseSubscriptionOptions, UseSubscriptionReconnectOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus, useSubscription } from './useSubscription.cjs';
21
23
  export { UseTokenAccountsOptions, useTokenAccounts } from './useTokenAccounts.cjs';
22
24
  export { useTokenBalance } from './useTokenBalance.cjs';
23
- export { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource, useTrackedData } from './useTrackedData.cjs';
25
+ export { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataRefresherOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource, useTrackedData } from './useTrackedData.cjs';
24
26
  export { UseTransactionOptions, useTransaction } from './useTransaction.cjs';
25
27
  export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.cjs';
26
28
  export { useWallet } from './useWallet.cjs';
package/dist/index.d.mts CHANGED
@@ -1,14 +1,16 @@
1
1
  export { AccountInfo, UseAccountInfoOptions, useAccountInfo } from './useAccountInfo.mjs';
2
2
  export { UseActionOptions, UseActionReturn, UseActionStatus, useAction } from './useAction.mjs';
3
+ export { useAirdrop } from './useAirdrop.mjs';
3
4
  export { BalanceInput, useBalance } from './useBalance.mjs';
4
5
  export { MissingClientCapabilityError, UseClientCapabilityOptions, useClientCapability } from './useClientCapability.mjs';
5
6
  export { useConnection } from './useConnection.mjs';
6
7
  export { PlanTransactionConfig, PlanTransactionStatus, usePlanTransaction, usePlanTransactions } from './usePlanTransaction.mjs';
7
8
  export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.mjs';
8
9
  export { useIdentity, usePayer } from './usePayer.mjs';
9
- export { UseRequestOptions, UseRequestReturn, UseRequestSource, UseRequestStatus, useRequest } from './useRequest.mjs';
10
+ export { UseRequestOptions, UseRequestRefresherOptions, UseRequestReturn, UseRequestSource, UseRequestStatus, useRequest } from './useRequest.mjs';
10
11
  export { useRpc } from './useRpc.mjs';
11
12
  export { SelectedWalletAccount, SelectedWalletAccountContext, SelectedWalletAccountOptions, SelectedWalletAccountProvider, WalletAccountFilter, createSelectedWalletAccountContext, provideSelectedWalletAccount, selectedWalletAccountInjectionKey, useSelectedWalletAccount } from './useSelectedWalletAccount.mjs';
13
+ export { SendTransactionConfig, SendTransactionInput, SendTransactionStatus, SendTransactionsInput, useSendTransaction, useSendTransactions } from './useSendTransaction.mjs';
12
14
  export { SignMessageStatus, useSignMessage } from './useSignMessage.mjs';
13
15
  export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
14
16
  export { SignTransactionsStatus, useSignTransactions } from './useSignTransactions.mjs';
@@ -17,10 +19,10 @@ export { SignatureStatus, UseSignatureStatusOptions, useSignatureStatus } from '
17
19
  export { SignInStatus, useSignIn } from './useSignIn.mjs';
18
20
  export { tryUseSolana, useSolana } from './useSolana.mjs';
19
21
  export { useSolanaClient } from './useSolanaClient.mjs';
20
- export { UseSubscriptionOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus, useSubscription } from './useSubscription.mjs';
22
+ export { UseSubscriptionOptions, UseSubscriptionReconnectOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus, useSubscription } from './useSubscription.mjs';
21
23
  export { UseTokenAccountsOptions, useTokenAccounts } from './useTokenAccounts.mjs';
22
24
  export { useTokenBalance } from './useTokenBalance.mjs';
23
- export { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource, useTrackedData } from './useTrackedData.mjs';
25
+ export { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataRefresherOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource, useTrackedData } from './useTrackedData.mjs';
24
26
  export { UseTransactionOptions, useTransaction } from './useTransaction.mjs';
25
27
  export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.mjs';
26
28
  export { useWallet } from './useWallet.mjs';
package/dist/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  export { AccountInfo, UseAccountInfoOptions, useAccountInfo } from './useAccountInfo.js';
2
2
  export { UseActionOptions, UseActionReturn, UseActionStatus, useAction } from './useAction.js';
3
+ export { useAirdrop } from './useAirdrop.js';
3
4
  export { BalanceInput, useBalance } from './useBalance.js';
4
5
  export { MissingClientCapabilityError, UseClientCapabilityOptions, useClientCapability } from './useClientCapability.js';
5
6
  export { useConnection } from './useConnection.js';
6
7
  export { PlanTransactionConfig, PlanTransactionStatus, usePlanTransaction, usePlanTransactions } from './usePlanTransaction.js';
7
8
  export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.js';
8
9
  export { useIdentity, usePayer } from './usePayer.js';
9
- export { UseRequestOptions, UseRequestReturn, UseRequestSource, UseRequestStatus, useRequest } from './useRequest.js';
10
+ export { UseRequestOptions, UseRequestRefresherOptions, UseRequestReturn, UseRequestSource, UseRequestStatus, useRequest } from './useRequest.js';
10
11
  export { useRpc } from './useRpc.js';
11
12
  export { SelectedWalletAccount, SelectedWalletAccountContext, SelectedWalletAccountOptions, SelectedWalletAccountProvider, WalletAccountFilter, createSelectedWalletAccountContext, provideSelectedWalletAccount, selectedWalletAccountInjectionKey, useSelectedWalletAccount } from './useSelectedWalletAccount.js';
13
+ export { SendTransactionConfig, SendTransactionInput, SendTransactionStatus, SendTransactionsInput, useSendTransaction, useSendTransactions } from './useSendTransaction.js';
12
14
  export { SignMessageStatus, useSignMessage } from './useSignMessage.js';
13
15
  export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.js';
14
16
  export { SignTransactionsStatus, useSignTransactions } from './useSignTransactions.js';
@@ -17,10 +19,10 @@ export { SignatureStatus, UseSignatureStatusOptions, useSignatureStatus } from '
17
19
  export { SignInStatus, useSignIn } from './useSignIn.js';
18
20
  export { tryUseSolana, useSolana } from './useSolana.js';
19
21
  export { useSolanaClient } from './useSolanaClient.js';
20
- export { UseSubscriptionOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus, useSubscription } from './useSubscription.js';
22
+ export { UseSubscriptionOptions, UseSubscriptionReconnectOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus, useSubscription } from './useSubscription.js';
21
23
  export { UseTokenAccountsOptions, useTokenAccounts } from './useTokenAccounts.js';
22
24
  export { useTokenBalance } from './useTokenBalance.js';
23
- export { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource, useTrackedData } from './useTrackedData.js';
25
+ export { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataRefresherOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource, useTrackedData } from './useTrackedData.js';
24
26
  export { UseTransactionOptions, useTransaction } from './useTransaction.js';
25
27
  export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.js';
26
28
  export { useWallet } from './useWallet.js';
package/dist/index.mjs CHANGED
@@ -1,14 +1,16 @@
1
1
  export { u as useAccountInfo } from './shared/vue.BQRpjwKl.mjs';
2
2
  export { u as useAction } from './shared/vue.DYk0Xfr3.mjs';
3
+ export { u as useAirdrop } from './shared/vue.BSfiHqwj.mjs';
3
4
  export { u as useBalance } from './shared/vue.BINkrA8h.mjs';
4
5
  export { M as MissingClientCapabilityError, u as useClientCapability } from './shared/vue.B8LptjZP.mjs';
5
6
  export { u as useConnection } from './shared/vue.CpkwC8Th.mjs';
6
- export { u as usePlanTransaction, a as usePlanTransactions } from './shared/vue.C5FVoEZT.mjs';
7
+ export { u as usePlanTransaction, a as usePlanTransactions } from './shared/vue.C4hGlFC8.mjs';
7
8
  export { u as useProgramAccounts } from './shared/vue.C13umiQi.mjs';
8
9
  export { u as useIdentity, a as usePayer } from './shared/vue.CATOh_9G.mjs';
9
- export { u as useRequest } from './shared/vue.DImwKTwJ.mjs';
10
+ export { u as useRequest } from './shared/vue.B8VvC8d2.mjs';
10
11
  export { u as useRpc } from './shared/vue.BsGwt78R.mjs';
11
12
  export { S as SelectedWalletAccountProvider, c as createSelectedWalletAccountContext, p as provideSelectedWalletAccount, s as selectedWalletAccountInjectionKey, u as useSelectedWalletAccount } from './shared/vue.DXQVIRZA.mjs';
13
+ export { u as useSendTransaction, a as useSendTransactions } from './shared/vue.DT4vCUa6.mjs';
12
14
  export { u as useSignMessage } from './shared/vue.JUWqu6kD.mjs';
13
15
  export { u as useSignAndSendTransaction } from './shared/vue.Dyi1OCI1.mjs';
14
16
  export { u as useSignTransactions } from './shared/vue.CMohL_Cz.mjs';
@@ -17,10 +19,10 @@ export { u as useSignatureStatus } from './shared/vue.CXB4NEMA.mjs';
17
19
  export { u as useSignIn } from './shared/vue.ByxbBC3y.mjs';
18
20
  export { t as tryUseSolana, u as useSolana } from './shared/vue.CQh3AUE8.mjs';
19
21
  export { u as useSolanaClient } from './shared/vue.Mxc8w6Qk.mjs';
20
- export { u as useSubscription } from './shared/vue.B8ub540p.mjs';
22
+ export { u as useSubscription } from './shared/vue.BDNOyiGZ.mjs';
21
23
  export { u as useTokenAccounts } from './shared/vue.BOpgWr43.mjs';
22
24
  export { u as useTokenBalance } from './shared/vue.BD6Gm1nl.mjs';
23
- export { u as useTrackedData } from './shared/vue.CogzzQXM.mjs';
25
+ export { u as useTrackedData } from './shared/vue.CbJFnho-.mjs';
24
26
  export { u as useTransaction } from './shared/vue.5euWd6-V.mjs';
25
27
  export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.D3Y0PWbF.mjs';
26
28
  export { u as useWallet } from './shared/vue.D218Ow7t.mjs';
@@ -9,24 +9,22 @@ function useRequest(source, options = {}) {
9
9
  const status = shallowRef("fetching");
10
10
  let disposed = false;
11
11
  let attempt = 0;
12
- const store = createSolanaActionStore(
13
- async (signal, resolved) => {
14
- attempt += 1;
15
- const callerSignal = options.getAbortSignal?.(attempt);
16
- const composedSignal = callerSignal ? AbortSignal.any([signal, callerSignal]) : signal;
17
- let pending;
18
- if (isSendSource(resolved)) {
19
- pending = Promise.resolve(resolved.send({ abortSignal: composedSignal }));
20
- } else if (typeof resolved === "function") {
21
- pending = Promise.resolve(resolved(composedSignal)).then(
22
- (result) => isSendSource(result) ? result.send({ abortSignal: composedSignal }) : result
23
- );
24
- } else {
25
- throw new Error("useRequest source did not resolve to a request function");
26
- }
27
- return getAbortablePromise(pending, composedSignal);
12
+ const store = createSolanaActionStore(async (signal, resolved, override) => {
13
+ attempt += 1;
14
+ const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(attempt);
15
+ const composedSignal = callerSignal ? AbortSignal.any([signal, callerSignal]) : signal;
16
+ let pending;
17
+ if (isSendSource(resolved)) {
18
+ pending = Promise.resolve(resolved.send({ abortSignal: composedSignal }));
19
+ } else if (typeof resolved === "function") {
20
+ pending = Promise.resolve(resolved(composedSignal)).then(
21
+ (result) => isSendSource(result) ? result.send({ abortSignal: composedSignal }) : result
22
+ );
23
+ } else {
24
+ throw new Error("useRequest source did not resolve to a request function");
28
25
  }
29
- );
26
+ return getAbortablePromise(pending, composedSignal);
27
+ });
30
28
  const unsubscribe = store.subscribe(() => {
31
29
  const next = store.getState();
32
30
  if (next.status === "success") {
@@ -51,7 +49,7 @@ function useRequest(source, options = {}) {
51
49
  }
52
50
  return source;
53
51
  }
54
- async function run() {
52
+ async function run(override) {
55
53
  if (disposed) {
56
54
  return void 0;
57
55
  }
@@ -65,7 +63,7 @@ function useRequest(source, options = {}) {
65
63
  }
66
64
  status.value = "fetching";
67
65
  try {
68
- return await store.dispatchAsync(resolved);
66
+ return await store.dispatchAsync(resolved, override);
69
67
  } catch (cause) {
70
68
  if (store.getState().status !== "error") {
71
69
  return void 0;
@@ -73,7 +71,7 @@ function useRequest(source, options = {}) {
73
71
  throw normalizeSolanaError(cause, "RPC_FAILURE");
74
72
  }
75
73
  }
76
- const refresh = () => run();
74
+ const refresh = (options2) => run(options2);
77
75
  watch(
78
76
  () => isRef(source) ? source.value : source,
79
77
  () => {
@@ -27,11 +27,11 @@ function useSubscription(source, options = {}) {
27
27
  status.value = "loading";
28
28
  }
29
29
  }
30
- function openConnection(store) {
30
+ function openConnection(store, override) {
31
31
  activeStore = store;
32
32
  connectionCount += 1;
33
33
  const connection = connectionCount;
34
- const callerSignal = options.getAbortSignal?.(connection);
34
+ const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(connection);
35
35
  applyState(store.getState());
36
36
  disposables.push(
37
37
  store.subscribe(() => {
@@ -59,7 +59,7 @@ function useSubscription(source, options = {}) {
59
59
  }
60
60
  activeSource = void 0;
61
61
  }
62
- function connectCurrent() {
62
+ function connectCurrent(override) {
63
63
  if (disposed) {
64
64
  return;
65
65
  }
@@ -72,12 +72,12 @@ function useSubscription(source, options = {}) {
72
72
  return;
73
73
  }
74
74
  if (activeSource === resolved && activeStore) {
75
- openConnection(activeStore);
75
+ openConnection(activeStore, override);
76
76
  return;
77
77
  }
78
78
  disconnect();
79
79
  activeSource = resolved;
80
- openConnection(resolved.reactiveStore());
80
+ openConnection(resolved.reactiveStore(), override);
81
81
  }
82
82
  watch(
83
83
  () => isRef(source) ? source.value : source,
@@ -99,8 +99,8 @@ function useSubscription(source, options = {}) {
99
99
  return {
100
100
  data: computed(() => data.value),
101
101
  error: computed(() => error.value),
102
- reconnect: () => {
103
- connectCurrent();
102
+ reconnect: (options2) => {
103
+ connectCurrent(options2);
104
104
  },
105
105
  status: computed(() => status.value)
106
106
  };