@vue-solana/vue 2.0.0 → 2.1.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 (170) hide show
  1. package/README.md +159 -21
  2. package/dist/index.cjs +58 -20
  3. package/dist/index.d.cts +25 -5
  4. package/dist/index.d.mts +25 -5
  5. package/dist/index.d.ts +25 -5
  6. package/dist/index.mjs +37 -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.B8pLQ8P4.cjs +105 -0
  13. package/dist/shared/vue.B8ub540p.mjs +109 -0
  14. package/dist/shared/{vue.DP7qY8Rk.mjs → vue.BD6Gm1nl.mjs} +2 -2
  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.CZwftA0L.cjs → vue.BVaMoz9y.cjs} +1 -1
  21. package/dist/shared/vue.BVj9lWBK.cjs +111 -0
  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.CSJSK0Nq.cjs → vue.CWZSMVnB.cjs} +3 -3
  34. package/dist/shared/{vue.DL-yMCNc.mjs → vue.CXB4NEMA.mjs} +2 -2
  35. package/dist/shared/{vue.D7xFeC2m.mjs → vue.C_4qJDiF.mjs} +1 -1
  36. package/dist/shared/vue.CoaIWGPT.cjs +38 -0
  37. package/dist/shared/vue.CogzzQXM.mjs +171 -0
  38. package/dist/shared/{vue.ChujsB0B.mjs → vue.CpkwC8Th.mjs} +1 -1
  39. package/dist/shared/vue.CrkK_T15.cjs +86 -0
  40. package/dist/shared/{vue.BMencBpI.cjs → vue.D-qi8PSL.cjs} +2 -2
  41. package/dist/shared/{vue.PJjEncbP.mjs → vue.D218Ow7t.mjs} +6 -2
  42. package/dist/shared/{vue.B2sFJ1xI.mjs → vue.D3Y0PWbF.mjs} +1 -1
  43. package/dist/shared/vue.D5U1yLG3.mjs +83 -0
  44. package/dist/shared/{vue.CXHYdyKZ.cjs → vue.DAg5wC1G.cjs} +2 -2
  45. package/dist/shared/vue.DDbVk0Zh.cjs +180 -0
  46. package/dist/shared/{vue.BaR1VPhl.cjs → vue.DE3emjSF.cjs} +2 -6
  47. package/dist/shared/vue.DEHxNvUX.cjs +7 -0
  48. package/dist/shared/vue.DFaMJLAQ.cjs +60 -0
  49. package/dist/shared/vue.DImwKTwJ.mjs +103 -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.DtCbCcPd.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.g8fnm_ca.cjs +45 -0
  63. package/dist/swr.cjs +136 -0
  64. package/dist/swr.d.cts +41 -0
  65. package/dist/swr.d.mts +41 -0
  66. package/dist/swr.d.ts +41 -0
  67. package/dist/swr.mjs +131 -0
  68. package/dist/useAccountInfo.cjs +5 -4
  69. package/dist/useAccountInfo.mjs +5 -4
  70. package/dist/useAction.cjs +9 -0
  71. package/dist/useAction.d.cts +45 -0
  72. package/dist/useAction.d.mts +45 -0
  73. package/dist/useAction.d.ts +45 -0
  74. package/dist/useAction.mjs +3 -0
  75. package/dist/useBalance.cjs +5 -4
  76. package/dist/useBalance.mjs +5 -4
  77. package/dist/useClientCapability.cjs +12 -0
  78. package/dist/useClientCapability.d.cts +39 -0
  79. package/dist/useClientCapability.d.mts +39 -0
  80. package/dist/useClientCapability.d.ts +39 -0
  81. package/dist/useClientCapability.mjs +5 -0
  82. package/dist/useConnection.cjs +4 -3
  83. package/dist/useConnection.mjs +4 -3
  84. package/dist/useIdentity.cjs +12 -0
  85. package/dist/useIdentity.d.cts +3 -0
  86. package/dist/useIdentity.d.mts +3 -0
  87. package/dist/useIdentity.d.ts +3 -0
  88. package/dist/useIdentity.mjs +6 -0
  89. package/dist/usePayer.cjs +13 -0
  90. package/dist/usePayer.d.cts +18 -0
  91. package/dist/usePayer.d.mts +18 -0
  92. package/dist/usePayer.d.ts +18 -0
  93. package/dist/usePayer.mjs +6 -0
  94. package/dist/usePlanTransaction.cjs +14 -0
  95. package/dist/usePlanTransaction.d.cts +37 -0
  96. package/dist/usePlanTransaction.d.mts +37 -0
  97. package/dist/usePlanTransaction.d.ts +37 -0
  98. package/dist/usePlanTransaction.mjs +7 -0
  99. package/dist/usePlanTransactions.cjs +13 -0
  100. package/dist/usePlanTransactions.d.cts +4 -0
  101. package/dist/usePlanTransactions.d.mts +4 -0
  102. package/dist/usePlanTransactions.d.ts +4 -0
  103. package/dist/usePlanTransactions.mjs +7 -0
  104. package/dist/useProgramAccounts.cjs +5 -4
  105. package/dist/useProgramAccounts.mjs +5 -4
  106. package/dist/useRequest.cjs +11 -0
  107. package/dist/useRequest.d.cts +57 -0
  108. package/dist/useRequest.d.mts +57 -0
  109. package/dist/useRequest.d.ts +57 -0
  110. package/dist/useRequest.mjs +5 -0
  111. package/dist/useRpc.cjs +3 -2
  112. package/dist/useRpc.mjs +3 -2
  113. package/dist/useSelectedWalletAccount.cjs +13 -0
  114. package/dist/useSelectedWalletAccount.d.cts +117 -0
  115. package/dist/useSelectedWalletAccount.d.mts +117 -0
  116. package/dist/useSelectedWalletAccount.d.ts +117 -0
  117. package/dist/useSelectedWalletAccount.mjs +3 -0
  118. package/dist/useSignAndSendTransaction.cjs +7 -6
  119. package/dist/useSignAndSendTransaction.mjs +7 -6
  120. package/dist/useSignAndSendTransactions.cjs +15 -0
  121. package/dist/useSignAndSendTransactions.d.cts +35 -0
  122. package/dist/useSignAndSendTransactions.d.mts +35 -0
  123. package/dist/useSignAndSendTransactions.d.ts +35 -0
  124. package/dist/useSignAndSendTransactions.mjs +8 -0
  125. package/dist/useSignIn.cjs +13 -0
  126. package/dist/useSignIn.d.cts +23 -0
  127. package/dist/useSignIn.d.mts +23 -0
  128. package/dist/useSignIn.d.ts +23 -0
  129. package/dist/useSignIn.mjs +7 -0
  130. package/dist/useSignMessage.cjs +4 -3
  131. package/dist/useSignMessage.mjs +4 -3
  132. package/dist/useSignTransactions.cjs +13 -0
  133. package/dist/useSignTransactions.d.cts +24 -0
  134. package/dist/useSignTransactions.d.mts +24 -0
  135. package/dist/useSignTransactions.d.ts +24 -0
  136. package/dist/useSignTransactions.mjs +7 -0
  137. package/dist/useSignatureStatus.cjs +5 -4
  138. package/dist/useSignatureStatus.mjs +5 -4
  139. package/dist/useSolana.cjs +2 -1
  140. package/dist/useSolana.mjs +2 -1
  141. package/dist/useSolanaClient.cjs +3 -2
  142. package/dist/useSolanaClient.mjs +3 -2
  143. package/dist/useSubscription.cjs +9 -0
  144. package/dist/useSubscription.d.cts +58 -0
  145. package/dist/useSubscription.d.mts +58 -0
  146. package/dist/useSubscription.d.ts +58 -0
  147. package/dist/useSubscription.mjs +3 -0
  148. package/dist/useTokenAccounts.cjs +5 -4
  149. package/dist/useTokenAccounts.mjs +5 -4
  150. package/dist/useTokenBalance.cjs +5 -4
  151. package/dist/useTokenBalance.mjs +5 -4
  152. package/dist/useTrackedData.cjs +10 -0
  153. package/dist/useTrackedData.d.cts +86 -0
  154. package/dist/useTrackedData.d.mts +86 -0
  155. package/dist/useTrackedData.d.ts +86 -0
  156. package/dist/useTrackedData.mjs +4 -0
  157. package/dist/useTransaction.cjs +2 -1
  158. package/dist/useTransaction.d.cts +12 -1
  159. package/dist/useTransaction.d.mts +12 -1
  160. package/dist/useTransaction.d.ts +12 -1
  161. package/dist/useTransaction.mjs +2 -1
  162. package/dist/useTransactionConfirmation.cjs +5 -4
  163. package/dist/useTransactionConfirmation.mjs +5 -4
  164. package/dist/useWallet.cjs +3 -2
  165. package/dist/useWallet.mjs +3 -2
  166. package/dist/useWallets.cjs +3 -2
  167. package/dist/useWallets.mjs +3 -2
  168. package/package.json +73 -3
  169. package/dist/shared/vue.C4d2JA8U.mjs +0 -44
  170. package/dist/shared/vue.CE5i8KZZ.cjs +0 -46
package/dist/index.mjs CHANGED
@@ -1,20 +1,31 @@
1
- export { u as useAccountInfo } from './shared/vue.dPRo2X5y.mjs';
2
- export { u as useBalance } from './shared/vue.stUBDBI9.mjs';
3
- export { u as useConnection } from './shared/vue.ChujsB0B.mjs';
4
- export { u as useProgramAccounts } from './shared/vue.BbMPRDeO.mjs';
5
- export { u as useRpc } from './shared/vue.3VLZmw05.mjs';
6
- export { u as useSignMessage } from './shared/vue.CZO8TwJP.mjs';
7
- export { u as useSignAndSendTransaction } from './shared/vue.WugzPOca.mjs';
8
- export { u as useSignatureStatus } from './shared/vue.DL-yMCNc.mjs';
9
- import { s as solanaInjectionKey } from './shared/vue.CnUlZSe8.mjs';
10
- export { t as tryUseSolana, u as useSolana } from './shared/vue.CnUlZSe8.mjs';
11
- export { u as useSolanaClient } from './shared/vue.BaFrF2PF.mjs';
12
- export { u as useTokenAccounts } from './shared/vue.yQcL1yMv.mjs';
13
- export { u as useTokenBalance } from './shared/vue.DP7qY8Rk.mjs';
14
- export { u as useTransaction } from './shared/vue.C4d2JA8U.mjs';
15
- export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.B2sFJ1xI.mjs';
16
- export { u as useWallet } from './shared/vue.PJjEncbP.mjs';
17
- export { u as useWallets } from './shared/vue.D7xFeC2m.mjs';
1
+ export { u as useAccountInfo } from './shared/vue.BQRpjwKl.mjs';
2
+ export { u as useAction } from './shared/vue.DYk0Xfr3.mjs';
3
+ export { u as useBalance } from './shared/vue.BINkrA8h.mjs';
4
+ export { M as MissingClientCapabilityError, u as useClientCapability } from './shared/vue.B8LptjZP.mjs';
5
+ 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 useProgramAccounts } from './shared/vue.C13umiQi.mjs';
8
+ 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 useRpc } from './shared/vue.BsGwt78R.mjs';
11
+ export { S as SelectedWalletAccountProvider, c as createSelectedWalletAccountContext, p as provideSelectedWalletAccount, s as selectedWalletAccountInjectionKey, u as useSelectedWalletAccount } from './shared/vue.DXQVIRZA.mjs';
12
+ export { u as useSignMessage } from './shared/vue.JUWqu6kD.mjs';
13
+ export { u as useSignAndSendTransaction } from './shared/vue.Dyi1OCI1.mjs';
14
+ export { u as useSignTransactions } from './shared/vue.CMohL_Cz.mjs';
15
+ export { P as PartialSignAndSendError, u as useSignAndSendTransactions } from './shared/vue.D5U1yLG3.mjs';
16
+ export { u as useSignatureStatus } from './shared/vue.CXB4NEMA.mjs';
17
+ export { u as useSignIn } from './shared/vue.ByxbBC3y.mjs';
18
+ export { t as tryUseSolana, u as useSolana } from './shared/vue.CQh3AUE8.mjs';
19
+ export { u as useSolanaClient } from './shared/vue.Mxc8w6Qk.mjs';
20
+ export { u as useSubscription } from './shared/vue.B8ub540p.mjs';
21
+ export { u as useTokenAccounts } from './shared/vue.BOpgWr43.mjs';
22
+ export { u as useTokenBalance } from './shared/vue.BD6Gm1nl.mjs';
23
+ export { u as useTrackedData } from './shared/vue.CogzzQXM.mjs';
24
+ export { u as useTransaction } from './shared/vue.5euWd6-V.mjs';
25
+ export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.D3Y0PWbF.mjs';
26
+ export { u as useWallet } from './shared/vue.D218Ow7t.mjs';
27
+ export { u as useWallets } from './shared/vue.C_4qJDiF.mjs';
28
+ import { s as solanaInjectionKey } from './shared/vue.D_P5SqqD.mjs';
18
29
  export { address, createSolanaClient, lamports } from '@vue-solana/core/kit';
19
30
  import { createSolanaError, normalizeSolanaError } from '@vue-solana/core/errors';
20
31
  import { createSolanaContext } from '@vue-solana/core/rpc';
@@ -24,6 +35,7 @@ import { shallowRef, ref, triggerRef } from 'vue';
24
35
  import { handleSolanaIosWalletCallback, getSolanaIosWallets, isSolanaIosWalletInfo, adaptSolanaIosWallet } from '@vue-solana/core/ios-wallet';
25
36
  import '@vue-solana/core/address';
26
37
  import './shared/vue.Bfu1dCKe.mjs';
38
+ import '@vue-solana/core/action';
27
39
  import '@vue-solana/core/wallet';
28
40
  import '@vue-solana/core/transaction';
29
41
  import 'bs58';
@@ -154,7 +166,10 @@ function createSolanaWalletRegistry(options) {
154
166
  signMessage: adaptedWallet.signMessage?.bind(adaptedWallet),
155
167
  signTransaction: adaptedWallet.signTransaction?.bind(adaptedWallet),
156
168
  signAllTransactions: adaptedWallet.signAllTransactions?.bind(adaptedWallet),
157
- signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet)
169
+ signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet),
170
+ signIn: adaptedWallet.signIn?.bind(adaptedWallet),
171
+ signTransactions: adaptedWallet.signTransactions?.bind(adaptedWallet),
172
+ signAndSendTransactions: adaptedWallet.signAndSendTransactions?.bind(adaptedWallet)
158
173
  };
159
174
  adaptedWallets.set(walletInfo.wallet, cachedAdapter);
160
175
  return cachedAdapter;
@@ -198,7 +213,8 @@ function isObject(value) {
198
213
 
199
214
  const RPC_CHECK_TIMEOUT_MS = 1e4;
200
215
  function createSolanaPlugin(options = {}) {
201
- return {
216
+ const plugin = {
217
+ context: null,
202
218
  install(app) {
203
219
  const context = createSolanaContext(options);
204
220
  const wallet = shallowRef(options.wallet ?? null);
@@ -346,6 +362,7 @@ function createSolanaPlugin(options = {}) {
346
362
  }
347
363
  };
348
364
  app.provide(solanaInjectionKey, vueContext);
365
+ plugin.context = vueContext;
349
366
  if (typeof window !== "undefined") {
350
367
  window.setTimeout(() => {
351
368
  try {
@@ -358,6 +375,7 @@ function createSolanaPlugin(options = {}) {
358
375
  }
359
376
  }
360
377
  };
378
+ return plugin;
361
379
  }
362
380
  function isSameWallet(wallet, selectedWallet) {
363
381
  return wallet.name === selectedWallet?.name && wallet.source === selectedWallet.source && wallet.platform === selectedWallet.platform;
@@ -0,0 +1,59 @@
1
+ import { createSolanaActionStore, isSolanaActionAborted } from '@vue-solana/core/action';
2
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
3
+ import { withSolanaTimeout } from '@vue-solana/core/timeout';
4
+ import { shallowRef, ref, getCurrentScope, onScopeDispose } from 'vue';
5
+
6
+ const DEFAULT_TIMEOUT_MESSAGE = "Transaction did not return a result before timing out.";
7
+ function useTransaction(handler, options = {}) {
8
+ const signature = shallowRef(null);
9
+ const loading = ref(false);
10
+ const error = ref(null);
11
+ const store = createSolanaActionStore(async (_signal, ...args) => {
12
+ const attempt = withSolanaTimeout(
13
+ handler(...args),
14
+ options.timeoutMs,
15
+ options.timeoutMessage ?? DEFAULT_TIMEOUT_MESSAGE
16
+ );
17
+ attempt.catch(() => void 0);
18
+ return attempt;
19
+ });
20
+ const unsubscribe = store.subscribe(() => {
21
+ const state = store.getState();
22
+ if (state.status === "running") {
23
+ loading.value = true;
24
+ } else if (state.status === "success") {
25
+ signature.value = state.data;
26
+ loading.value = false;
27
+ error.value = null;
28
+ } else if (state.status === "error") {
29
+ error.value = normalizeSolanaError(state.error, "RPC_FAILURE");
30
+ loading.value = false;
31
+ }
32
+ });
33
+ if (getCurrentScope()) {
34
+ onScopeDispose(() => {
35
+ unsubscribe();
36
+ store.reset();
37
+ });
38
+ }
39
+ async function execute(...args) {
40
+ loading.value = true;
41
+ error.value = null;
42
+ try {
43
+ return await store.dispatchAsync(...args);
44
+ } catch (cause) {
45
+ if (isSolanaActionAborted(cause)) {
46
+ throw cause;
47
+ }
48
+ throw normalizeSolanaError(cause, "RPC_FAILURE");
49
+ }
50
+ }
51
+ return {
52
+ signature,
53
+ loading,
54
+ error,
55
+ execute
56
+ };
57
+ }
58
+
59
+ export { useTransaction as u };
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ const errors = require('@vue-solana/core/errors');
4
+ const wallet = require('@vue-solana/core/wallet');
5
+ const vue = require('vue');
6
+ const useWallet = require('./vue.BGxz4dru.cjs');
7
+
8
+ function useSignIn() {
9
+ const { wallet: wallet$1 } = useWallet.useWallet();
10
+ const signInResult = vue.shallowRef(null);
11
+ const status = vue.ref("idle");
12
+ const loading = vue.ref(false);
13
+ const error = vue.ref(null);
14
+ let executionId = 0;
15
+ async function signIn(input) {
16
+ const currentExecutionId = ++executionId;
17
+ status.value = "signing-in";
18
+ loading.value = true;
19
+ error.value = null;
20
+ signInResult.value = null;
21
+ const activeWallet = wallet$1.value;
22
+ if (!activeWallet) {
23
+ const normalizedError = wallet.createNoWalletSelectedError();
24
+ error.value = normalizedError;
25
+ status.value = "error";
26
+ loading.value = false;
27
+ throw normalizedError;
28
+ }
29
+ try {
30
+ wallet.assertWalletCanSignIn(activeWallet);
31
+ const result = await activeWallet.signIn(input);
32
+ if (currentExecutionId === executionId) {
33
+ signInResult.value = result;
34
+ status.value = "signed-in";
35
+ }
36
+ return result;
37
+ } catch (cause) {
38
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
39
+ if (currentExecutionId === executionId) {
40
+ error.value = normalizedError;
41
+ status.value = "error";
42
+ }
43
+ throw normalizedError;
44
+ } finally {
45
+ if (currentExecutionId === executionId) {
46
+ loading.value = false;
47
+ }
48
+ }
49
+ }
50
+ return {
51
+ signInResult,
52
+ status,
53
+ loading,
54
+ error,
55
+ signIn
56
+ };
57
+ }
58
+
59
+ exports.useSignIn = useSignIn;
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ const errors = require('@vue-solana/core/errors');
4
+ const vue = require('vue');
5
+ const useClientCapability = require('./vue.BY0qpgYr.cjs');
6
+ const useSolanaClient = require('./vue.BIxphCAq.cjs');
7
+
8
+ function usePlanTransaction() {
9
+ useClientCapability.useClientCapability(["planTransaction"], {
10
+ hookName: "usePlanTransaction",
11
+ providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
12
+ });
13
+ const { client } = useSolanaClient.useSolanaClient();
14
+ const transactionMessage = vue.shallowRef(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(input, config) {
20
+ const currentExecutionId = ++executionId;
21
+ const planner = client;
22
+ status.value = "planning";
23
+ loading.value = true;
24
+ error.value = null;
25
+ transactionMessage.value = null;
26
+ try {
27
+ const message = await planner.planTransaction(input, config);
28
+ if (currentExecutionId === executionId) {
29
+ transactionMessage.value = message;
30
+ status.value = "planned";
31
+ }
32
+ return message;
33
+ } catch (cause) {
34
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
35
+ if (currentExecutionId === executionId) {
36
+ error.value = normalizedError;
37
+ status.value = "error";
38
+ }
39
+ throw normalizedError;
40
+ } finally {
41
+ if (currentExecutionId === executionId) {
42
+ loading.value = false;
43
+ }
44
+ }
45
+ }
46
+ return {
47
+ transactionMessage,
48
+ status,
49
+ loading,
50
+ error,
51
+ execute
52
+ };
53
+ }
54
+ function usePlanTransactions() {
55
+ useClientCapability.useClientCapability(["planTransactions"], {
56
+ hookName: "usePlanTransactions",
57
+ providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
58
+ });
59
+ const { client } = useSolanaClient.useSolanaClient();
60
+ const transactionPlan = vue.shallowRef(null);
61
+ const status = vue.ref("idle");
62
+ const loading = vue.ref(false);
63
+ const error = vue.ref(null);
64
+ let executionId = 0;
65
+ async function execute(input, config) {
66
+ const currentExecutionId = ++executionId;
67
+ const planner = client;
68
+ status.value = "planning";
69
+ loading.value = true;
70
+ error.value = null;
71
+ transactionPlan.value = null;
72
+ try {
73
+ const plan = await planner.planTransactions(input, config);
74
+ if (currentExecutionId === executionId) {
75
+ transactionPlan.value = plan;
76
+ status.value = "planned";
77
+ }
78
+ return plan;
79
+ } catch (cause) {
80
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
81
+ if (currentExecutionId === executionId) {
82
+ error.value = normalizedError;
83
+ status.value = "error";
84
+ }
85
+ throw normalizedError;
86
+ } finally {
87
+ if (currentExecutionId === executionId) {
88
+ loading.value = false;
89
+ }
90
+ }
91
+ }
92
+ return {
93
+ transactionPlan,
94
+ status,
95
+ loading,
96
+ error,
97
+ execute
98
+ };
99
+ }
100
+
101
+ exports.usePlanTransaction = usePlanTransaction;
102
+ exports.usePlanTransactions = usePlanTransactions;
@@ -3,7 +3,7 @@
3
3
  const errors = require('@vue-solana/core/errors');
4
4
  const wallet = require('@vue-solana/core/wallet');
5
5
  const vue = require('vue');
6
- const useWallet = require('./vue.BAlo-tIh.cjs');
6
+ const useWallet = require('./vue.BGxz4dru.cjs');
7
7
 
8
8
  function useSignMessage() {
9
9
  const { wallet: wallet$1 } = useWallet.useWallet();
@@ -0,0 +1,32 @@
1
+ import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
2
+
3
+ class MissingClientCapabilityError extends Error {
4
+ /** Name of the hook that requested the capability, e.g. `usePayer`. */
5
+ hookName;
6
+ /** Human guidance for installing the capability on the client. */
7
+ providerHint;
8
+ /** The missing capability name(s). */
9
+ capabilities;
10
+ constructor(hookName, capabilities, providerHint) {
11
+ super(
12
+ `${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
13
+ );
14
+ this.name = "MissingClientCapabilityError";
15
+ this.hookName = hookName;
16
+ this.capabilities = capabilities;
17
+ this.providerHint = providerHint;
18
+ }
19
+ }
20
+ function useClientCapability(capability, options = {}) {
21
+ const capabilities = Array.isArray(capability) ? [...capability] : [capability];
22
+ const hookName = options.hookName ?? "useClientCapability";
23
+ const providerHint = options.providerHint ?? "Install it by adding the corresponding @solana/kit plugin with `createClient().use(...)`.";
24
+ const { client } = useSolanaClient();
25
+ for (const name of capabilities) {
26
+ if (typeof client[name] === "undefined") {
27
+ throw new MissingClientCapabilityError(hookName, [name], providerHint);
28
+ }
29
+ }
30
+ }
31
+
32
+ export { MissingClientCapabilityError as M, useClientCapability as u };
@@ -0,0 +1,105 @@
1
+ 'use strict';
2
+
3
+ const action = require('@vue-solana/core/action');
4
+ const kit = require('@vue-solana/core/kit');
5
+ const errors = require('@vue-solana/core/errors');
6
+ const vue = require('vue');
7
+
8
+ function useRequest(source, options = {}) {
9
+ const data = vue.shallowRef(void 0);
10
+ const error = vue.shallowRef(null);
11
+ const status = vue.shallowRef("fetching");
12
+ let disposed = false;
13
+ let attempt = 0;
14
+ const store = action.createSolanaActionStore(
15
+ async (signal, resolved) => {
16
+ attempt += 1;
17
+ const callerSignal = options.getAbortSignal?.(attempt);
18
+ const composedSignal = callerSignal ? AbortSignal.any([signal, callerSignal]) : signal;
19
+ let pending;
20
+ if (isSendSource(resolved)) {
21
+ pending = Promise.resolve(resolved.send({ abortSignal: composedSignal }));
22
+ } else if (typeof resolved === "function") {
23
+ pending = Promise.resolve(resolved(composedSignal)).then(
24
+ (result) => isSendSource(result) ? result.send({ abortSignal: composedSignal }) : result
25
+ );
26
+ } else {
27
+ throw new Error("useRequest source did not resolve to a request function");
28
+ }
29
+ return kit.getAbortablePromise(pending, composedSignal);
30
+ }
31
+ );
32
+ const unsubscribe = store.subscribe(() => {
33
+ const next = store.getState();
34
+ if (next.status === "success") {
35
+ data.value = next.data;
36
+ error.value = null;
37
+ status.value = "success";
38
+ } else if (next.status === "error") {
39
+ error.value = errors.normalizeSolanaError(next.error, "RPC_FAILURE");
40
+ status.value = "error";
41
+ } else if (next.status === "running") {
42
+ status.value = "fetching";
43
+ }
44
+ });
45
+ vue.onScopeDispose(() => {
46
+ disposed = true;
47
+ unsubscribe();
48
+ store.reset();
49
+ });
50
+ function unwrapSource() {
51
+ if (vue.isRef(source)) {
52
+ return source.value;
53
+ }
54
+ return source;
55
+ }
56
+ async function run() {
57
+ if (disposed) {
58
+ return void 0;
59
+ }
60
+ const resolved = unwrapSource();
61
+ if (isDisabled(resolved)) {
62
+ data.value = void 0;
63
+ error.value = null;
64
+ status.value = "disabled";
65
+ store.reset();
66
+ return void 0;
67
+ }
68
+ status.value = "fetching";
69
+ try {
70
+ return await store.dispatchAsync(resolved);
71
+ } catch (cause) {
72
+ if (store.getState().status !== "error") {
73
+ return void 0;
74
+ }
75
+ throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
76
+ }
77
+ }
78
+ const refresh = () => run();
79
+ vue.watch(
80
+ () => vue.isRef(source) ? source.value : source,
81
+ () => {
82
+ void refresh().catch(() => void 0);
83
+ }
84
+ );
85
+ vue.onMounted(() => {
86
+ void refresh().catch(() => void 0);
87
+ });
88
+ if (!vue.getCurrentInstance()) {
89
+ void refresh().catch(() => void 0);
90
+ }
91
+ return {
92
+ data: vue.computed(() => data.value),
93
+ error: vue.computed(() => error.value),
94
+ refresh,
95
+ status: vue.computed(() => status.value)
96
+ };
97
+ }
98
+ function isDisabled(resolved) {
99
+ return resolved === null || resolved === void 0;
100
+ }
101
+ function isSendSource(resolved) {
102
+ return typeof resolved === "object" && resolved !== null && "send" in resolved && typeof resolved.send === "function";
103
+ }
104
+
105
+ exports.useRequest = useRequest;
@@ -0,0 +1,109 @@
1
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
2
+ import { shallowRef, watch, isRef, onMounted, getCurrentInstance, onScopeDispose, computed } from 'vue';
3
+
4
+ function useSubscription(source, options = {}) {
5
+ const data = shallowRef(void 0);
6
+ const error = shallowRef(null);
7
+ const status = shallowRef("loading");
8
+ const disposables = [];
9
+ let connectionCount = 0;
10
+ let disposed = false;
11
+ let activeSource;
12
+ let activeStore;
13
+ function applyState(state) {
14
+ if (state.status === "loaded") {
15
+ data.value = state.data;
16
+ error.value = null;
17
+ status.value = "loaded";
18
+ } else if (state.status === "error") {
19
+ error.value = normalizeSolanaError(state.error, "RPC_FAILURE");
20
+ status.value = "error";
21
+ options.onError?.(state.error);
22
+ } else if (state.status === "loading") {
23
+ status.value = data.value === void 0 ? "loading" : status.value;
24
+ } else if (state.status === "idle") {
25
+ data.value = void 0;
26
+ error.value = null;
27
+ status.value = "loading";
28
+ }
29
+ }
30
+ function openConnection(store) {
31
+ activeStore = store;
32
+ connectionCount += 1;
33
+ const connection = connectionCount;
34
+ const callerSignal = options.getAbortSignal?.(connection);
35
+ applyState(store.getState());
36
+ disposables.push(
37
+ store.subscribe(() => {
38
+ applyState(store.getState());
39
+ })
40
+ );
41
+ if (callerSignal?.aborted) {
42
+ applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
43
+ return;
44
+ }
45
+ if (callerSignal) {
46
+ store.withSignal(callerSignal).connect();
47
+ } else {
48
+ store.connect();
49
+ }
50
+ }
51
+ function disconnect() {
52
+ disposables.forEach((dispose) => {
53
+ dispose();
54
+ });
55
+ disposables.length = 0;
56
+ if (activeStore) {
57
+ activeStore.reset();
58
+ activeStore = void 0;
59
+ }
60
+ activeSource = void 0;
61
+ }
62
+ function connectCurrent() {
63
+ if (disposed) {
64
+ return;
65
+ }
66
+ const resolved = isRef(source) ? source.value : source;
67
+ if (resolved === null || resolved === void 0) {
68
+ disconnect();
69
+ data.value = void 0;
70
+ error.value = null;
71
+ status.value = "disabled";
72
+ return;
73
+ }
74
+ if (activeSource === resolved && activeStore) {
75
+ openConnection(activeStore);
76
+ return;
77
+ }
78
+ disconnect();
79
+ activeSource = resolved;
80
+ openConnection(resolved.reactiveStore());
81
+ }
82
+ watch(
83
+ () => isRef(source) ? source.value : source,
84
+ () => {
85
+ connectCurrent();
86
+ },
87
+ { flush: "sync" }
88
+ );
89
+ onMounted(() => {
90
+ connectCurrent();
91
+ });
92
+ if (!getCurrentInstance()) {
93
+ connectCurrent();
94
+ }
95
+ onScopeDispose(() => {
96
+ disposed = true;
97
+ disconnect();
98
+ });
99
+ return {
100
+ data: computed(() => data.value),
101
+ error: computed(() => error.value),
102
+ reconnect: () => {
103
+ connectCurrent();
104
+ },
105
+ status: computed(() => status.value)
106
+ };
107
+ }
108
+
109
+ export { useSubscription as u };
@@ -2,8 +2,8 @@ import { getTokenBalance } from '@vue-solana/core/token-accounts';
2
2
  import { normalizeSolanaError } from '@vue-solana/core/errors';
3
3
  import { parseAddress } from '@vue-solana/core/address';
4
4
  import { shallowRef, onMounted, watch, toValue } from 'vue';
5
- import { u as useConnection } from './vue.ChujsB0B.mjs';
6
- import { t as tryUseSolana } from './vue.CnUlZSe8.mjs';
5
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
6
+ import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
7
7
 
8
8
  function useTokenBalance(mint, owner, commitment) {
9
9
  const solana = tryUseSolana();
@@ -3,7 +3,7 @@
3
3
  const errors = require('@vue-solana/core/errors');
4
4
  const wallet = require('@vue-solana/core/wallet');
5
5
  const vue = require('vue');
6
- const useSolana = require('./vue.BaR1VPhl.cjs');
6
+ const useSolana = require('./vue.DE3emjSF.cjs');
7
7
 
8
8
  function useWallet() {
9
9
  const solana = useSolana.useSolana();
@@ -11,6 +11,9 @@ function useWallet() {
11
11
  const connecting = vue.ref(false);
12
12
  const disconnecting = vue.ref(false);
13
13
  async function connect() {
14
+ if (connecting.value || wallet$1.value?.connecting) {
15
+ return;
16
+ }
14
17
  const activeWallet = wallet$1.value;
15
18
  if (!activeWallet) {
16
19
  throw wallet.createNoWalletSelectedError();
@@ -20,6 +23,7 @@ function useWallet() {
20
23
  const connection = activeWallet.connect();
21
24
  vue.triggerRef(wallet$1);
22
25
  await connection;
26
+ wallet.assertWalletConnected(activeWallet);
23
27
  vue.triggerRef(wallet$1);
24
28
  console.info("[Vue Solana] Wallet connected", {
25
29
  publicKey: activeWallet.publicKey ?? null
@@ -1,8 +1,8 @@
1
1
  import { parseAddress } from '@vue-solana/core/address';
2
2
  import { normalizeSolanaError } from '@vue-solana/core/errors';
3
3
  import { shallowRef, onMounted, 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 useBalance(address, commitment) {
8
8
  const solana = tryUseSolana();
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const useSolana = require('./vue.BaR1VPhl.cjs');
3
+ const useSolana = require('./vue.DE3emjSF.cjs');
4
4
 
5
5
  function useSolanaClient() {
6
6
  const { client } = useSolana.useSolana();
@@ -2,8 +2,8 @@ import { getTokenAccountsByOwner } from '@vue-solana/core/token-accounts';
2
2
  import { normalizeSolanaError } from '@vue-solana/core/errors';
3
3
  import { parseAddress } from '@vue-solana/core/address';
4
4
  import { shallowRef, onMounted, watch, toValue } from 'vue';
5
- import { u as useConnection } from './vue.ChujsB0B.mjs';
6
- import { t as tryUseSolana } from './vue.CnUlZSe8.mjs';
5
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
6
+ import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
7
7
 
8
8
  function useTokenAccounts(owner, options) {
9
9
  const solana = tryUseSolana();
@@ -1,8 +1,8 @@
1
1
  import { normalizeSolanaError } from '@vue-solana/core/errors';
2
2
  import { shallowRef, onMounted, 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 useAccountInfo(address, options = {}) {
@@ -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;