@vue-solana/vue 2.0.0 → 2.2.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 (186) hide show
  1. package/README.md +210 -21
  2. package/dist/index.cjs +60 -20
  3. package/dist/index.d.cts +26 -5
  4. package/dist/index.d.mts +26 -5
  5. package/dist/index.d.ts +26 -5
  6. package/dist/index.mjs +38 -19
  7. package/dist/shared/vue.5euWd6-V.mjs +59 -0
  8. package/dist/shared/vue.9TPxZPMf.cjs +59 -0
  9. package/dist/shared/vue.B4-LEdSE.cjs +102 -0
  10. package/dist/shared/{vue.CP1DPDX9.cjs → vue.B6ainw2G.cjs} +1 -1
  11. package/dist/shared/vue.B8LptjZP.mjs +32 -0
  12. package/dist/shared/vue.B8VvC8d2.mjs +101 -0
  13. package/dist/shared/{vue.DP7qY8Rk.mjs → vue.BD6Gm1nl.mjs} +2 -2
  14. package/dist/shared/vue.BDNOyiGZ.mjs +109 -0
  15. package/dist/shared/{vue.BAlo-tIh.cjs → vue.BGxz4dru.cjs} +5 -1
  16. package/dist/shared/{vue.stUBDBI9.mjs → vue.BINkrA8h.mjs} +2 -2
  17. package/dist/shared/{vue.k9Q6aN-0.cjs → vue.BIxphCAq.cjs} +1 -1
  18. package/dist/shared/{vue.yQcL1yMv.mjs → vue.BOpgWr43.mjs} +2 -2
  19. package/dist/shared/{vue.dPRo2X5y.mjs → vue.BQRpjwKl.mjs} +2 -2
  20. package/dist/shared/vue.BSfiHqwj.mjs +34 -0
  21. package/dist/shared/{vue.CZwftA0L.cjs → vue.BVaMoz9y.cjs} +1 -1
  22. package/dist/shared/vue.BY0qpgYr.cjs +35 -0
  23. package/dist/shared/vue.Bk5xjlUx.cjs +61 -0
  24. package/dist/shared/{vue.3VLZmw05.mjs → vue.BsGwt78R.mjs} +1 -1
  25. package/dist/shared/{vue.B_LRH8SM.cjs → vue.Bwd1sGAM.cjs} +2 -2
  26. package/dist/shared/vue.ByxbBC3y.mjs +57 -0
  27. package/dist/shared/{vue.BbMPRDeO.mjs → vue.C13umiQi.mjs} +2 -2
  28. package/dist/shared/vue.C5FVoEZT.mjs +99 -0
  29. package/dist/shared/vue.CATOh_9G.mjs +42 -0
  30. package/dist/shared/{vue.XQFqlMId.cjs → vue.CIs8QhCw.cjs} +2 -2
  31. package/dist/shared/vue.CMohL_Cz.mjs +58 -0
  32. package/dist/shared/{vue.CnUlZSe8.mjs → vue.CQh3AUE8.mjs} +2 -5
  33. package/dist/shared/vue.CTqPbvz3.cjs +36 -0
  34. package/dist/shared/{vue.CSJSK0Nq.cjs → vue.CWZSMVnB.cjs} +3 -3
  35. package/dist/shared/{vue.DL-yMCNc.mjs → vue.CXB4NEMA.mjs} +2 -2
  36. package/dist/shared/{vue.D7xFeC2m.mjs → vue.C_4qJDiF.mjs} +1 -1
  37. package/dist/shared/vue.CbJFnho-.mjs +171 -0
  38. package/dist/shared/vue.CoaIWGPT.cjs +38 -0
  39. package/dist/shared/{vue.ChujsB0B.mjs → vue.CpkwC8Th.mjs} +1 -1
  40. package/dist/shared/vue.CrkK_T15.cjs +86 -0
  41. package/dist/shared/{vue.BMencBpI.cjs → vue.D-qi8PSL.cjs} +2 -2
  42. package/dist/shared/{vue.PJjEncbP.mjs → vue.D218Ow7t.mjs} +6 -2
  43. package/dist/shared/{vue.B2sFJ1xI.mjs → vue.D3Y0PWbF.mjs} +1 -1
  44. package/dist/shared/vue.D5U1yLG3.mjs +83 -0
  45. package/dist/shared/{vue.CXHYdyKZ.cjs → vue.DAg5wC1G.cjs} +2 -2
  46. package/dist/shared/vue.DDbVk0Zh.cjs +180 -0
  47. package/dist/shared/{vue.BaR1VPhl.cjs → vue.DE3emjSF.cjs} +2 -6
  48. package/dist/shared/vue.DEHxNvUX.cjs +7 -0
  49. package/dist/shared/vue.DFaMJLAQ.cjs +60 -0
  50. package/dist/shared/{vue.DgCmU1RR.cjs → vue.DKyQ7J67.cjs} +1 -1
  51. package/dist/shared/vue.DXQVIRZA.mjs +174 -0
  52. package/dist/shared/vue.DYk0Xfr3.mjs +36 -0
  53. package/dist/shared/vue.D_P5SqqD.mjs +5 -0
  54. package/dist/shared/{vue.C7yR7Cs0.cjs → vue.Di7yjJ-R.cjs} +2 -2
  55. package/dist/shared/vue.DxM45azl.cjs +173 -0
  56. package/dist/shared/{vue.WugzPOca.mjs → vue.Dyi1OCI1.mjs} +3 -3
  57. package/dist/shared/{vue.CEn2purG.cjs → vue.E_npPFoV.cjs} +2 -2
  58. package/dist/shared/{vue.__r7YYZE.cjs → vue.FiMmnMHr.cjs} +1 -1
  59. package/dist/shared/{vue.CZO8TwJP.mjs → vue.JUWqu6kD.mjs} +1 -1
  60. package/dist/shared/{vue.BaFrF2PF.mjs → vue.Mxc8w6Qk.mjs} +1 -1
  61. package/dist/shared/{vue.C32ozdA1.cjs → vue.Sbbm9JSu.cjs} +1 -1
  62. package/dist/shared/vue.ZuUCEEab.cjs +103 -0
  63. package/dist/shared/vue.g8fnm_ca.cjs +45 -0
  64. package/dist/shared/vue.l3UCdN7z.cjs +111 -0
  65. package/dist/swr.cjs +136 -0
  66. package/dist/swr.d.cts +41 -0
  67. package/dist/swr.d.mts +41 -0
  68. package/dist/swr.d.ts +41 -0
  69. package/dist/swr.mjs +131 -0
  70. package/dist/useAccountInfo.cjs +5 -4
  71. package/dist/useAccountInfo.mjs +5 -4
  72. package/dist/useAction.cjs +9 -0
  73. package/dist/useAction.d.cts +45 -0
  74. package/dist/useAction.d.mts +45 -0
  75. package/dist/useAction.d.ts +45 -0
  76. package/dist/useAction.mjs +3 -0
  77. package/dist/useAirdrop.cjs +14 -0
  78. package/dist/useAirdrop.d.cts +25 -0
  79. package/dist/useAirdrop.d.mts +25 -0
  80. package/dist/useAirdrop.d.ts +25 -0
  81. package/dist/useAirdrop.mjs +8 -0
  82. package/dist/useBalance.cjs +5 -4
  83. package/dist/useBalance.mjs +5 -4
  84. package/dist/useClientCapability.cjs +12 -0
  85. package/dist/useClientCapability.d.cts +39 -0
  86. package/dist/useClientCapability.d.mts +39 -0
  87. package/dist/useClientCapability.d.ts +39 -0
  88. package/dist/useClientCapability.mjs +5 -0
  89. package/dist/useConnection.cjs +4 -3
  90. package/dist/useConnection.d.cts +3 -2
  91. package/dist/useConnection.d.mts +3 -2
  92. package/dist/useConnection.d.ts +3 -2
  93. package/dist/useConnection.mjs +4 -3
  94. package/dist/useIdentity.cjs +12 -0
  95. package/dist/useIdentity.d.cts +3 -0
  96. package/dist/useIdentity.d.mts +3 -0
  97. package/dist/useIdentity.d.ts +3 -0
  98. package/dist/useIdentity.mjs +6 -0
  99. package/dist/usePayer.cjs +13 -0
  100. package/dist/usePayer.d.cts +18 -0
  101. package/dist/usePayer.d.mts +18 -0
  102. package/dist/usePayer.d.ts +18 -0
  103. package/dist/usePayer.mjs +6 -0
  104. package/dist/usePlanTransaction.cjs +14 -0
  105. package/dist/usePlanTransaction.d.cts +37 -0
  106. package/dist/usePlanTransaction.d.mts +37 -0
  107. package/dist/usePlanTransaction.d.ts +37 -0
  108. package/dist/usePlanTransaction.mjs +7 -0
  109. package/dist/usePlanTransactions.cjs +13 -0
  110. package/dist/usePlanTransactions.d.cts +4 -0
  111. package/dist/usePlanTransactions.d.mts +4 -0
  112. package/dist/usePlanTransactions.d.ts +4 -0
  113. package/dist/usePlanTransactions.mjs +7 -0
  114. package/dist/useProgramAccounts.cjs +5 -4
  115. package/dist/useProgramAccounts.mjs +5 -4
  116. package/dist/useRequest.cjs +11 -0
  117. package/dist/useRequest.d.cts +73 -0
  118. package/dist/useRequest.d.mts +73 -0
  119. package/dist/useRequest.d.ts +73 -0
  120. package/dist/useRequest.mjs +5 -0
  121. package/dist/useRpc.cjs +3 -2
  122. package/dist/useRpc.d.cts +3 -2
  123. package/dist/useRpc.d.mts +3 -2
  124. package/dist/useRpc.d.ts +3 -2
  125. package/dist/useRpc.mjs +3 -2
  126. package/dist/useSelectedWalletAccount.cjs +13 -0
  127. package/dist/useSelectedWalletAccount.d.cts +117 -0
  128. package/dist/useSelectedWalletAccount.d.mts +117 -0
  129. package/dist/useSelectedWalletAccount.d.ts +117 -0
  130. package/dist/useSelectedWalletAccount.mjs +3 -0
  131. package/dist/useSignAndSendTransaction.cjs +7 -6
  132. package/dist/useSignAndSendTransaction.mjs +7 -6
  133. package/dist/useSignAndSendTransactions.cjs +15 -0
  134. package/dist/useSignAndSendTransactions.d.cts +35 -0
  135. package/dist/useSignAndSendTransactions.d.mts +35 -0
  136. package/dist/useSignAndSendTransactions.d.ts +35 -0
  137. package/dist/useSignAndSendTransactions.mjs +8 -0
  138. package/dist/useSignIn.cjs +13 -0
  139. package/dist/useSignIn.d.cts +23 -0
  140. package/dist/useSignIn.d.mts +23 -0
  141. package/dist/useSignIn.d.ts +23 -0
  142. package/dist/useSignIn.mjs +7 -0
  143. package/dist/useSignMessage.cjs +4 -3
  144. package/dist/useSignMessage.mjs +4 -3
  145. package/dist/useSignTransactions.cjs +13 -0
  146. package/dist/useSignTransactions.d.cts +24 -0
  147. package/dist/useSignTransactions.d.mts +24 -0
  148. package/dist/useSignTransactions.d.ts +24 -0
  149. package/dist/useSignTransactions.mjs +7 -0
  150. package/dist/useSignatureStatus.cjs +5 -4
  151. package/dist/useSignatureStatus.mjs +5 -4
  152. package/dist/useSolana.cjs +2 -1
  153. package/dist/useSolana.mjs +2 -1
  154. package/dist/useSolanaClient.cjs +3 -2
  155. package/dist/useSolanaClient.d.cts +3 -2
  156. package/dist/useSolanaClient.d.mts +3 -2
  157. package/dist/useSolanaClient.d.ts +3 -2
  158. package/dist/useSolanaClient.mjs +3 -2
  159. package/dist/useSubscription.cjs +9 -0
  160. package/dist/useSubscription.d.cts +70 -0
  161. package/dist/useSubscription.d.mts +70 -0
  162. package/dist/useSubscription.d.ts +70 -0
  163. package/dist/useSubscription.mjs +3 -0
  164. package/dist/useTokenAccounts.cjs +5 -4
  165. package/dist/useTokenAccounts.mjs +5 -4
  166. package/dist/useTokenBalance.cjs +5 -4
  167. package/dist/useTokenBalance.mjs +5 -4
  168. package/dist/useTrackedData.cjs +10 -0
  169. package/dist/useTrackedData.d.cts +98 -0
  170. package/dist/useTrackedData.d.mts +98 -0
  171. package/dist/useTrackedData.d.ts +98 -0
  172. package/dist/useTrackedData.mjs +4 -0
  173. package/dist/useTransaction.cjs +2 -1
  174. package/dist/useTransaction.d.cts +12 -1
  175. package/dist/useTransaction.d.mts +12 -1
  176. package/dist/useTransaction.d.ts +12 -1
  177. package/dist/useTransaction.mjs +2 -1
  178. package/dist/useTransactionConfirmation.cjs +5 -4
  179. package/dist/useTransactionConfirmation.mjs +5 -4
  180. package/dist/useWallet.cjs +3 -2
  181. package/dist/useWallet.mjs +3 -2
  182. package/dist/useWallets.cjs +3 -2
  183. package/dist/useWallets.mjs +3 -2
  184. package/package.json +78 -3
  185. package/dist/shared/vue.C4d2JA8U.mjs +0 -44
  186. package/dist/shared/vue.CE5i8KZZ.cjs +0 -46
@@ -0,0 +1,34 @@
1
+ import { u as useAction } from './vue.DYk0Xfr3.mjs';
2
+ import { u as useClientCapability } from './vue.B8LptjZP.mjs';
3
+ import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
4
+
5
+ function toReadableAirdropError(error) {
6
+ if (error instanceof Error) {
7
+ const httpStatus = error.context?.statusCode;
8
+ const isThrottled = httpStatus === 429 || error.message.startsWith("JSON-RPC error: Internal JSON-RPC error (Internal error)");
9
+ if (!isThrottled) {
10
+ throw error;
11
+ }
12
+ throw new Error(
13
+ `${error.message} This likely means the network's airdrop faucet is rate-limited or out of test SOL. Retry later, use https://faucet.solana.com, or point the client at a local validator.`,
14
+ { cause: error }
15
+ );
16
+ }
17
+ throw new Error(`Airdrop failed: ${String(error)}`);
18
+ }
19
+ function useAirdrop() {
20
+ useClientCapability("airdrop", {
21
+ hookName: "useAirdrop",
22
+ providerHint: "Install it by adding the airdrop capability with `createClient().use(solanaRpcConnection({ ... })).use(rpcAirdrop())` from `@solana/kit-plugin-rpc`."
23
+ });
24
+ const { client } = useSolanaClient();
25
+ return useAction((abortSignal, address, amount) => {
26
+ const airdrop = client.airdrop;
27
+ if (!airdrop) {
28
+ throw new Error("useAirdrop requires the `airdrop` capability on the Solana client.");
29
+ }
30
+ return airdrop(address, amount, abortSignal).catch(toReadableAirdropError);
31
+ });
32
+ }
33
+
34
+ export { useAirdrop as u };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const useSolanaClient = require('./vue.k9Q6aN-0.cjs');
3
+ const useSolanaClient = require('./vue.BIxphCAq.cjs');
4
4
 
5
5
  function useConnection() {
6
6
  return useSolanaClient.useSolanaClient().client;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ const useSolanaClient = require('./vue.BIxphCAq.cjs');
4
+
5
+ class MissingClientCapabilityError extends Error {
6
+ /** Name of the hook that requested the capability, e.g. `usePayer`. */
7
+ hookName;
8
+ /** Human guidance for installing the capability on the client. */
9
+ providerHint;
10
+ /** The missing capability name(s). */
11
+ capabilities;
12
+ constructor(hookName, capabilities, providerHint) {
13
+ super(
14
+ `${hookName} requires the ${capabilities.map((capability) => `\`${capability}\``).join(" and ")} capabilit${capabilities.length === 1 ? "y" : "ies"} on the Solana client, but none ${capabilities.length === 1 ? "was" : "were"} found. ` + providerHint
15
+ );
16
+ this.name = "MissingClientCapabilityError";
17
+ this.hookName = hookName;
18
+ this.capabilities = capabilities;
19
+ this.providerHint = providerHint;
20
+ }
21
+ }
22
+ function useClientCapability(capability, options = {}) {
23
+ const capabilities = Array.isArray(capability) ? [...capability] : [capability];
24
+ const hookName = options.hookName ?? "useClientCapability";
25
+ const providerHint = options.providerHint ?? "Install it by adding the corresponding @solana/kit plugin with `createClient().use(...)`.";
26
+ const { client } = useSolanaClient.useSolanaClient();
27
+ for (const name of capabilities) {
28
+ if (typeof client[name] === "undefined") {
29
+ throw new MissingClientCapabilityError(hookName, [name], providerHint);
30
+ }
31
+ }
32
+ }
33
+
34
+ exports.MissingClientCapabilityError = MissingClientCapabilityError;
35
+ exports.useClientCapability = useClientCapability;
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ const action = require('@vue-solana/core/action');
4
+ const errors = require('@vue-solana/core/errors');
5
+ const timeout = require('@vue-solana/core/timeout');
6
+ const vue = require('vue');
7
+
8
+ const DEFAULT_TIMEOUT_MESSAGE = "Transaction did not return a result before timing out.";
9
+ function useTransaction(handler, options = {}) {
10
+ const signature = vue.shallowRef(null);
11
+ const loading = vue.ref(false);
12
+ const error = vue.ref(null);
13
+ const store = action.createSolanaActionStore(async (_signal, ...args) => {
14
+ const attempt = timeout.withSolanaTimeout(
15
+ handler(...args),
16
+ options.timeoutMs,
17
+ options.timeoutMessage ?? DEFAULT_TIMEOUT_MESSAGE
18
+ );
19
+ attempt.catch(() => void 0);
20
+ return attempt;
21
+ });
22
+ const unsubscribe = store.subscribe(() => {
23
+ const state = store.getState();
24
+ if (state.status === "running") {
25
+ loading.value = true;
26
+ } else if (state.status === "success") {
27
+ signature.value = state.data;
28
+ loading.value = false;
29
+ error.value = null;
30
+ } else if (state.status === "error") {
31
+ error.value = errors.normalizeSolanaError(state.error, "RPC_FAILURE");
32
+ loading.value = false;
33
+ }
34
+ });
35
+ if (vue.getCurrentScope()) {
36
+ vue.onScopeDispose(() => {
37
+ unsubscribe();
38
+ store.reset();
39
+ });
40
+ }
41
+ async function execute(...args) {
42
+ loading.value = true;
43
+ error.value = null;
44
+ try {
45
+ return await store.dispatchAsync(...args);
46
+ } catch (cause) {
47
+ if (action.isSolanaActionAborted(cause)) {
48
+ throw cause;
49
+ }
50
+ throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
51
+ }
52
+ }
53
+ return {
54
+ signature,
55
+ loading,
56
+ error,
57
+ execute
58
+ };
59
+ }
60
+
61
+ exports.useTransaction = useTransaction;
@@ -1,5 +1,5 @@
1
1
  import { computed } from 'vue';
2
- import { u as useSolana } from './vue.CnUlZSe8.mjs';
2
+ import { u as useSolana } from './vue.CQh3AUE8.mjs';
3
3
 
4
4
  function useRpc() {
5
5
  const solana = useSolana();
@@ -4,8 +4,8 @@ const tokenAccounts = require('@vue-solana/core/token-accounts');
4
4
  const errors = require('@vue-solana/core/errors');
5
5
  const address = require('@vue-solana/core/address');
6
6
  const vue = require('vue');
7
- const useConnection = require('./vue.CZwftA0L.cjs');
8
- const useSolana = require('./vue.BaR1VPhl.cjs');
7
+ const useConnection = require('./vue.BVaMoz9y.cjs');
8
+ const useSolana = require('./vue.DE3emjSF.cjs');
9
9
 
10
10
  function useTokenAccounts(owner, options) {
11
11
  const solana = useSolana.tryUseSolana();
@@ -0,0 +1,57 @@
1
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
2
+ import { createNoWalletSelectedError, assertWalletCanSignIn } from '@vue-solana/core/wallet';
3
+ import { shallowRef, ref } from 'vue';
4
+ import { u as useWallet } from './vue.D218Ow7t.mjs';
5
+
6
+ function useSignIn() {
7
+ const { wallet } = useWallet();
8
+ const signInResult = shallowRef(null);
9
+ const status = ref("idle");
10
+ const loading = ref(false);
11
+ const error = ref(null);
12
+ let executionId = 0;
13
+ async function signIn(input) {
14
+ const currentExecutionId = ++executionId;
15
+ status.value = "signing-in";
16
+ loading.value = true;
17
+ error.value = null;
18
+ signInResult.value = null;
19
+ const activeWallet = wallet.value;
20
+ if (!activeWallet) {
21
+ const normalizedError = createNoWalletSelectedError();
22
+ error.value = normalizedError;
23
+ status.value = "error";
24
+ loading.value = false;
25
+ throw normalizedError;
26
+ }
27
+ try {
28
+ assertWalletCanSignIn(activeWallet);
29
+ const result = await activeWallet.signIn(input);
30
+ if (currentExecutionId === executionId) {
31
+ signInResult.value = result;
32
+ status.value = "signed-in";
33
+ }
34
+ return result;
35
+ } catch (cause) {
36
+ const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
37
+ if (currentExecutionId === executionId) {
38
+ error.value = normalizedError;
39
+ status.value = "error";
40
+ }
41
+ throw normalizedError;
42
+ } finally {
43
+ if (currentExecutionId === executionId) {
44
+ loading.value = false;
45
+ }
46
+ }
47
+ }
48
+ return {
49
+ signInResult,
50
+ status,
51
+ loading,
52
+ error,
53
+ signIn
54
+ };
55
+ }
56
+
57
+ export { useSignIn as u };
@@ -1,8 +1,8 @@
1
1
  import { normalizeSolanaError } from '@vue-solana/core/errors';
2
2
  import { shallowRef, onMounted, onUnmounted, watch, toValue } from 'vue';
3
3
  import { parseAddress } from '@vue-solana/core/address';
4
- import { u as useConnection } from './vue.ChujsB0B.mjs';
5
- import { t as tryUseSolana } from './vue.CnUlZSe8.mjs';
4
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
5
+ import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
6
6
  import { d as decodeBase64 } from './vue.Bfu1dCKe.mjs';
7
7
 
8
8
  function useProgramAccounts(programId, options = {}) {
@@ -0,0 +1,99 @@
1
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
2
+ import { shallowRef, ref } from 'vue';
3
+ import { u as useClientCapability } from './vue.B8LptjZP.mjs';
4
+ import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
5
+
6
+ function usePlanTransaction() {
7
+ useClientCapability(["planTransaction"], {
8
+ hookName: "usePlanTransaction",
9
+ providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
10
+ });
11
+ const { client } = useSolanaClient();
12
+ const transactionMessage = shallowRef(null);
13
+ const status = ref("idle");
14
+ const loading = ref(false);
15
+ const error = ref(null);
16
+ let executionId = 0;
17
+ async function execute(input, config) {
18
+ const currentExecutionId = ++executionId;
19
+ const planner = client;
20
+ status.value = "planning";
21
+ loading.value = true;
22
+ error.value = null;
23
+ transactionMessage.value = null;
24
+ try {
25
+ const message = await planner.planTransaction(input, config);
26
+ if (currentExecutionId === executionId) {
27
+ transactionMessage.value = message;
28
+ status.value = "planned";
29
+ }
30
+ return message;
31
+ } catch (cause) {
32
+ const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
33
+ if (currentExecutionId === executionId) {
34
+ error.value = normalizedError;
35
+ status.value = "error";
36
+ }
37
+ throw normalizedError;
38
+ } finally {
39
+ if (currentExecutionId === executionId) {
40
+ loading.value = false;
41
+ }
42
+ }
43
+ }
44
+ return {
45
+ transactionMessage,
46
+ status,
47
+ loading,
48
+ error,
49
+ execute
50
+ };
51
+ }
52
+ function usePlanTransactions() {
53
+ useClientCapability(["planTransactions"], {
54
+ hookName: "usePlanTransactions",
55
+ providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
56
+ });
57
+ const { client } = useSolanaClient();
58
+ const transactionPlan = shallowRef(null);
59
+ const status = ref("idle");
60
+ const loading = ref(false);
61
+ const error = ref(null);
62
+ let executionId = 0;
63
+ async function execute(input, config) {
64
+ const currentExecutionId = ++executionId;
65
+ const planner = client;
66
+ status.value = "planning";
67
+ loading.value = true;
68
+ error.value = null;
69
+ transactionPlan.value = null;
70
+ try {
71
+ const plan = await planner.planTransactions(input, config);
72
+ if (currentExecutionId === executionId) {
73
+ transactionPlan.value = plan;
74
+ status.value = "planned";
75
+ }
76
+ return plan;
77
+ } catch (cause) {
78
+ const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
79
+ if (currentExecutionId === executionId) {
80
+ error.value = normalizedError;
81
+ status.value = "error";
82
+ }
83
+ throw normalizedError;
84
+ } finally {
85
+ if (currentExecutionId === executionId) {
86
+ loading.value = false;
87
+ }
88
+ }
89
+ }
90
+ return {
91
+ transactionPlan,
92
+ status,
93
+ loading,
94
+ error,
95
+ execute
96
+ };
97
+ }
98
+
99
+ export { usePlanTransactions as a, usePlanTransaction as u };
@@ -0,0 +1,42 @@
1
+ import { shallowRef, onScopeDispose } from 'vue';
2
+ import { u as useClientCapability } from './vue.B8LptjZP.mjs';
3
+ import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
4
+
5
+ function useIdentity() {
6
+ useClientCapability(["identity"], {
7
+ hookName: "useIdentity",
8
+ providerHint: "Install a signer plugin, e.g. `createClient().use(generatedIdentity())` from `@solana/kit-plugin-signer`."
9
+ });
10
+ const { client } = useSolanaClient();
11
+ const identity = shallowRef(
12
+ client.identity
13
+ );
14
+ const subscribable = client;
15
+ if (typeof subscribable.subscribeToIdentity === "function") {
16
+ const unsubscribe = subscribable.subscribeToIdentity(() => {
17
+ identity.value = client.identity;
18
+ });
19
+ onScopeDispose(unsubscribe);
20
+ }
21
+ return identity;
22
+ }
23
+ function usePayer() {
24
+ useClientCapability(["payer"], {
25
+ hookName: "usePayer",
26
+ providerHint: "Install a signer plugin, e.g. `createClient().use(generatedPayer())` from `@solana/kit-plugin-signer`."
27
+ });
28
+ const { client } = useSolanaClient();
29
+ const payer = shallowRef(
30
+ client.payer
31
+ );
32
+ const subscribable = client;
33
+ if (typeof subscribable.subscribeToPayer === "function") {
34
+ const unsubscribe = subscribable.subscribeToPayer(() => {
35
+ payer.value = client.payer;
36
+ });
37
+ onScopeDispose(unsubscribe);
38
+ }
39
+ return payer;
40
+ }
41
+
42
+ export { usePayer as a, useIdentity as u };
@@ -3,8 +3,8 @@
3
3
  const errors = require('@vue-solana/core/errors');
4
4
  const bs58 = require('bs58');
5
5
  const vue = require('vue');
6
- const useConnection = require('./vue.CZwftA0L.cjs');
7
- const useSolana = require('./vue.BaR1VPhl.cjs');
6
+ const useConnection = require('./vue.BVaMoz9y.cjs');
7
+ const useSolana = require('./vue.DE3emjSF.cjs');
8
8
 
9
9
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
10
 
@@ -0,0 +1,58 @@
1
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
2
+ import { createNoWalletSelectedError, assertWalletCanSignTransactions } from '@vue-solana/core/wallet';
3
+ import { shallowRef, ref } from 'vue';
4
+ import { u as useWallet } from './vue.D218Ow7t.mjs';
5
+
6
+ function useSignTransactions() {
7
+ const { wallet } = useWallet();
8
+ const signedTransactions = shallowRef(null);
9
+ const status = ref("idle");
10
+ const loading = ref(false);
11
+ const error = ref(null);
12
+ let executionId = 0;
13
+ async function execute(transactions) {
14
+ const currentExecutionId = ++executionId;
15
+ status.value = "signing";
16
+ loading.value = true;
17
+ error.value = null;
18
+ signedTransactions.value = null;
19
+ const activeWallet = wallet.value;
20
+ if (!activeWallet) {
21
+ const normalizedError = createNoWalletSelectedError();
22
+ error.value = normalizedError;
23
+ status.value = "error";
24
+ loading.value = false;
25
+ throw normalizedError;
26
+ }
27
+ try {
28
+ assertWalletCanSignTransactions(activeWallet);
29
+ const sign = activeWallet.signTransactions ? activeWallet.signTransactions.bind(activeWallet) : activeWallet.signAllTransactions.bind(activeWallet);
30
+ const result = await sign([...transactions]);
31
+ if (currentExecutionId === executionId) {
32
+ signedTransactions.value = result;
33
+ status.value = "signed";
34
+ }
35
+ return result;
36
+ } catch (cause) {
37
+ const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
38
+ if (currentExecutionId === executionId) {
39
+ error.value = normalizedError;
40
+ status.value = "error";
41
+ }
42
+ throw normalizedError;
43
+ } finally {
44
+ if (currentExecutionId === executionId) {
45
+ loading.value = false;
46
+ }
47
+ }
48
+ }
49
+ return {
50
+ signedTransactions,
51
+ status,
52
+ loading,
53
+ error,
54
+ execute
55
+ };
56
+ }
57
+
58
+ export { useSignTransactions as u };
@@ -1,8 +1,5 @@
1
1
  import { inject, shallowRef, ref } from 'vue';
2
-
3
- const solanaInjectionKey = Symbol.for(
4
- "vue-solana:context"
5
- );
2
+ import { s as solanaInjectionKey } from './vue.D_P5SqqD.mjs';
6
3
 
7
4
  let ssrContext;
8
5
  function tryUseSolana() {
@@ -45,4 +42,4 @@ function createUnavailableProxy() {
45
42
  );
46
43
  }
47
44
 
48
- export { solanaInjectionKey as s, tryUseSolana as t, useSolana as u };
45
+ export { tryUseSolana as t, useSolana as u };
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const useAction = require('./vue.CoaIWGPT.cjs');
4
+ const useClientCapability = require('./vue.BY0qpgYr.cjs');
5
+ const useSolanaClient = require('./vue.BIxphCAq.cjs');
6
+
7
+ function toReadableAirdropError(error) {
8
+ if (error instanceof Error) {
9
+ const httpStatus = error.context?.statusCode;
10
+ const isThrottled = httpStatus === 429 || error.message.startsWith("JSON-RPC error: Internal JSON-RPC error (Internal error)");
11
+ if (!isThrottled) {
12
+ throw error;
13
+ }
14
+ throw new Error(
15
+ `${error.message} This likely means the network's airdrop faucet is rate-limited or out of test SOL. Retry later, use https://faucet.solana.com, or point the client at a local validator.`,
16
+ { cause: error }
17
+ );
18
+ }
19
+ throw new Error(`Airdrop failed: ${String(error)}`);
20
+ }
21
+ function useAirdrop() {
22
+ useClientCapability.useClientCapability("airdrop", {
23
+ hookName: "useAirdrop",
24
+ providerHint: "Install it by adding the airdrop capability with `createClient().use(solanaRpcConnection({ ... })).use(rpcAirdrop())` from `@solana/kit-plugin-rpc`."
25
+ });
26
+ const { client } = useSolanaClient.useSolanaClient();
27
+ return useAction.useAction((abortSignal, address, amount) => {
28
+ const airdrop = client.airdrop;
29
+ if (!airdrop) {
30
+ throw new Error("useAirdrop requires the `airdrop` capability on the Solana client.");
31
+ }
32
+ return airdrop(address, amount, abortSignal).catch(toReadableAirdropError);
33
+ });
34
+ }
35
+
36
+ exports.useAirdrop = useAirdrop;
@@ -5,9 +5,9 @@ const timeout = require('@vue-solana/core/timeout');
5
5
  const transaction = require('@vue-solana/core/transaction');
6
6
  const wallet = require('@vue-solana/core/wallet');
7
7
  const vue = require('vue');
8
- const useConnection = require('./vue.CZwftA0L.cjs');
9
- const useWallet = require('./vue.BAlo-tIh.cjs');
10
- const useTransactionConfirmation = require('./vue.C32ozdA1.cjs');
8
+ const useConnection = require('./vue.BVaMoz9y.cjs');
9
+ const useWallet = require('./vue.BGxz4dru.cjs');
10
+ const useTransactionConfirmation = require('./vue.Sbbm9JSu.cjs');
11
11
 
12
12
  const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
13
13
  function useSignAndSendTransaction() {
@@ -1,8 +1,8 @@
1
1
  import { normalizeSolanaError, createSolanaError } from '@vue-solana/core/errors';
2
2
  import bs58 from 'bs58';
3
3
  import { shallowRef, onMounted, onUnmounted, watch, toValue } from 'vue';
4
- import { u as useConnection } from './vue.ChujsB0B.mjs';
5
- import { t as tryUseSolana } from './vue.CnUlZSe8.mjs';
4
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
5
+ import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
6
6
 
7
7
  function useSignatureStatus(signature, options = {}) {
8
8
  const solana = tryUseSolana();
@@ -1,4 +1,4 @@
1
- import { u as useSolana } from './vue.CnUlZSe8.mjs';
1
+ import { u as useSolana } from './vue.CQh3AUE8.mjs';
2
2
 
3
3
  function useWallets() {
4
4
  const solana = useSolana();