@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,60 @@
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 useSignTransactions() {
9
+ const { wallet: wallet$1 } = useWallet.useWallet();
10
+ const signedTransactions = 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 execute(transactions) {
16
+ const currentExecutionId = ++executionId;
17
+ status.value = "signing";
18
+ loading.value = true;
19
+ error.value = null;
20
+ signedTransactions.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.assertWalletCanSignTransactions(activeWallet);
31
+ const sign = activeWallet.signTransactions ? activeWallet.signTransactions.bind(activeWallet) : activeWallet.signAllTransactions.bind(activeWallet);
32
+ const result = await sign([...transactions]);
33
+ if (currentExecutionId === executionId) {
34
+ signedTransactions.value = result;
35
+ status.value = "signed";
36
+ }
37
+ return result;
38
+ } catch (cause) {
39
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
40
+ if (currentExecutionId === executionId) {
41
+ error.value = normalizedError;
42
+ status.value = "error";
43
+ }
44
+ throw normalizedError;
45
+ } finally {
46
+ if (currentExecutionId === executionId) {
47
+ loading.value = false;
48
+ }
49
+ }
50
+ }
51
+ return {
52
+ signedTransactions,
53
+ status,
54
+ loading,
55
+ error,
56
+ execute
57
+ };
58
+ }
59
+
60
+ exports.useSignTransactions = useSignTransactions;
@@ -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 useWallets() {
6
6
  const solana = useSolana.useSolana();
@@ -0,0 +1,174 @@
1
+ import { provide, inject, ref, watch, getCurrentScope, onScopeDispose, computed, defineComponent } from 'vue';
2
+ import { s as solanaInjectionKey } from './vue.D_P5SqqD.mjs';
3
+
4
+ const SELECTED_WALLET_ACCOUNT_STORAGE_KEY = "vue-solana:selected-wallet-account";
5
+ function createLocalStorageSelectedWalletAccountStorage(storage = defaultLocalStorage()) {
6
+ return {
7
+ storeSelectedWallet(key) {
8
+ try {
9
+ storage?.setItem(SELECTED_WALLET_ACCOUNT_STORAGE_KEY, key);
10
+ } catch {
11
+ }
12
+ },
13
+ getSelectedWallet() {
14
+ try {
15
+ return storage?.getItem(SELECTED_WALLET_ACCOUNT_STORAGE_KEY) ?? null;
16
+ } catch {
17
+ return null;
18
+ }
19
+ },
20
+ deleteSelectedWallet() {
21
+ try {
22
+ storage?.removeItem(SELECTED_WALLET_ACCOUNT_STORAGE_KEY);
23
+ } catch {
24
+ }
25
+ }
26
+ };
27
+ }
28
+ function defaultLocalStorage() {
29
+ if (typeof window === "undefined") {
30
+ return null;
31
+ }
32
+ try {
33
+ return window.localStorage;
34
+ } catch {
35
+ return null;
36
+ }
37
+ }
38
+
39
+ const selectedWalletAccountInjectionKey = Symbol.for("vue-solana:selected-wallet-account");
40
+ function provideSelectedWalletAccount(options = {}) {
41
+ const context = createSelectedWalletAccountContext(options);
42
+ provide(selectedWalletAccountInjectionKey, context);
43
+ return context;
44
+ }
45
+ function createSelectedWalletAccountContext(options = {}, solanaContextOverride) {
46
+ const solanaContext = solanaContextOverride ?? inject(solanaInjectionKey, null);
47
+ const stateSync = options.stateSync === void 0 ? defaultStateSync() : options.stateSync;
48
+ const selectedWalletAccount = ref(null);
49
+ const walletsValue = () => solanaContext?.wallets.value ?? [];
50
+ let pendingKey = null;
51
+ let selectionGeneration = 0;
52
+ function findAccount(key) {
53
+ const separatorIndex = key.lastIndexOf(":");
54
+ const walletName = separatorIndex === -1 ? key : key.slice(0, separatorIndex);
55
+ const address = separatorIndex === -1 ? "" : key.slice(separatorIndex + 1);
56
+ const wallet = walletsValue().find((candidate) => candidate.name === walletName);
57
+ const account = wallet?.accounts.find((candidate) => candidate.address === address);
58
+ if (!wallet || !account) {
59
+ return null;
60
+ }
61
+ return { ...account, walletName: wallet.name };
62
+ }
63
+ function clearSelection() {
64
+ selectionGeneration += 1;
65
+ pendingKey = null;
66
+ selectedWalletAccount.value = null;
67
+ }
68
+ function applyExternalSelection(key) {
69
+ if (!key) {
70
+ clearSelection();
71
+ return;
72
+ }
73
+ const account = findAccount(key);
74
+ if (account) {
75
+ selectionGeneration += 1;
76
+ pendingKey = null;
77
+ selectedWalletAccount.value = account;
78
+ return;
79
+ }
80
+ pendingKey = key;
81
+ }
82
+ function restoreIfAvailable() {
83
+ if (!pendingKey || selectedWalletAccount.value) {
84
+ return;
85
+ }
86
+ const account = findAccount(pendingKey);
87
+ if (account) {
88
+ selectedWalletAccount.value = account;
89
+ pendingKey = null;
90
+ }
91
+ }
92
+ if (stateSync) {
93
+ const generation = selectionGeneration;
94
+ void Promise.resolve(stateSync.getSelectedWallet()).then((key) => {
95
+ if (generation !== selectionGeneration || !key || selectedWalletAccount.value) {
96
+ return;
97
+ }
98
+ pendingKey = key;
99
+ restoreIfAvailable();
100
+ }).catch(() => void 0);
101
+ }
102
+ if (solanaContext) {
103
+ watch(
104
+ () => solanaContext.wallets.value,
105
+ () => restoreIfAvailable()
106
+ );
107
+ }
108
+ if (stateSync && typeof window !== "undefined") {
109
+ const onStorage = () => {
110
+ void Promise.resolve(stateSync.getSelectedWallet()).then((key) => applyExternalSelection(key)).catch(() => void 0);
111
+ };
112
+ window.addEventListener("storage", onStorage);
113
+ if (getCurrentScope()) {
114
+ onScopeDispose(() => window.removeEventListener("storage", onStorage));
115
+ }
116
+ }
117
+ const context = {
118
+ selectedWalletAccount,
119
+ setSelectedWalletAccount(account) {
120
+ selectionGeneration += 1;
121
+ selectedWalletAccount.value = account;
122
+ pendingKey = null;
123
+ if (!stateSync) {
124
+ return;
125
+ }
126
+ const persisted = account ? stateSync.storeSelectedWallet(`${account.walletName}:${account.address}`) : stateSync.deleteSelectedWallet();
127
+ void Promise.resolve(persisted).catch(() => void 0);
128
+ },
129
+ filteredWallets: computed(() => {
130
+ const filter = options.filterWallet;
131
+ if (!filter) {
132
+ return walletsValue();
133
+ }
134
+ return walletsValue().map((wallet) => {
135
+ const accounts = wallet.accounts.filter((account) => filter(wallet.name, account));
136
+ return accounts.length === 0 ? null : { ...wallet, accounts };
137
+ }).filter((wallet) => wallet !== null);
138
+ })
139
+ };
140
+ return context;
141
+ }
142
+ function useSelectedWalletAccount() {
143
+ const context = inject(selectedWalletAccountInjectionKey, null);
144
+ if (!context) {
145
+ throw new Error("useSelectedWalletAccount must be used inside a SelectedWalletAccountProvider");
146
+ }
147
+ return [context.selectedWalletAccount, context.setSelectedWalletAccount, context.filteredWallets];
148
+ }
149
+ function defaultStateSync() {
150
+ return createLocalStorageSelectedWalletAccountStorage();
151
+ }
152
+
153
+ const SelectedWalletAccountProvider = defineComponent({
154
+ name: "SelectedWalletAccountProvider",
155
+ props: {
156
+ filterWallet: {
157
+ type: Function,
158
+ default: void 0
159
+ },
160
+ stateSync: {
161
+ type: [Object, null],
162
+ default: void 0
163
+ }
164
+ },
165
+ setup(props, { slots }) {
166
+ provideSelectedWalletAccount({
167
+ filterWallet: props.filterWallet,
168
+ stateSync: props.stateSync
169
+ });
170
+ return () => slots.default?.();
171
+ }
172
+ });
173
+
174
+ export { SelectedWalletAccountProvider as S, createSelectedWalletAccountContext as c, provideSelectedWalletAccount as p, selectedWalletAccountInjectionKey as s, useSelectedWalletAccount as u };
@@ -0,0 +1,36 @@
1
+ import { createSolanaActionStore } from '@vue-solana/core/action';
2
+ import { unref, shallowRef, onScopeDispose, computed } from 'vue';
3
+
4
+ function useAction(action, options = {}) {
5
+ const store = createSolanaActionStore(
6
+ (signal, ...args) => unref(action)(signal, ...args)
7
+ );
8
+ const state = shallowRef(store.getState());
9
+ const unsubscribe = store.subscribe(() => {
10
+ const next = store.getState();
11
+ const previous = state.value;
12
+ if (next.status === "success" && previous.status !== "success") {
13
+ options.onSuccess?.(next.data);
14
+ }
15
+ if (next.status === "error" && previous.status !== "error") {
16
+ options.onError?.(next.error);
17
+ }
18
+ state.value = next;
19
+ });
20
+ onScopeDispose(() => {
21
+ unsubscribe();
22
+ store.reset();
23
+ });
24
+ return {
25
+ data: computed(() => state.value.data),
26
+ dispatch: (...args) => store.dispatchAsync(...args),
27
+ error: computed(() => state.value.error),
28
+ isRunning: computed(() => state.value.status === "running"),
29
+ reset: () => {
30
+ store.reset();
31
+ },
32
+ status: computed(() => state.value.status)
33
+ };
34
+ }
35
+
36
+ export { useAction as u };
@@ -0,0 +1,5 @@
1
+ const solanaInjectionKey = Symbol.for(
2
+ "vue-solana:context"
3
+ );
4
+
5
+ export { solanaInjectionKey as s };
@@ -3,8 +3,8 @@
3
3
  const errors = require('@vue-solana/core/errors');
4
4
  const vue = require('vue');
5
5
  const address = require('@vue-solana/core/address');
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
  const decodeBase64 = require('./vue.DNxOpDXz.cjs');
9
9
 
10
10
  function useProgramAccounts(programId, options = {}) {
@@ -0,0 +1,173 @@
1
+ 'use strict';
2
+
3
+ const kit = require('@vue-solana/core/kit');
4
+ const errors = require('@vue-solana/core/errors');
5
+ const vue = require('vue');
6
+
7
+ function isActionSource(value) {
8
+ return typeof value === "object" && value !== null && "reactiveStore" in value && typeof value.reactiveStore === "function";
9
+ }
10
+ function useTrackedData(source, options = {}) {
11
+ const data = vue.shallowRef(void 0);
12
+ const error = vue.shallowRef(null);
13
+ const status = vue.shallowRef("loading");
14
+ const disposables = [];
15
+ let connectionCount = 0;
16
+ let disposed = false;
17
+ let activeStore;
18
+ function applyState(state) {
19
+ if (state.status === "loaded") {
20
+ data.value = state.data;
21
+ error.value = null;
22
+ status.value = "loaded";
23
+ } else if (state.status === "error") {
24
+ error.value = errors.normalizeSolanaError(state.error, "RPC_FAILURE");
25
+ status.value = "error";
26
+ options.onError?.(state.error);
27
+ } else if (state.status === "loading") {
28
+ status.value = data.value === void 0 ? "loading" : status.value;
29
+ } else if (state.status === "idle") {
30
+ error.value = null;
31
+ }
32
+ }
33
+ function buildAndConnect(override) {
34
+ if (disposed) {
35
+ return;
36
+ }
37
+ let rpcRequest = vue.unref(source.rpcRequest);
38
+ const rpcSubscriptionRequest = vue.unref(source.rpcSubscriptionRequest);
39
+ if (!rpcRequest || !rpcSubscriptionRequest) {
40
+ disconnect();
41
+ data.value = void 0;
42
+ error.value = null;
43
+ status.value = "disabled";
44
+ return;
45
+ }
46
+ if (!isActionSource(rpcRequest) && isSendSource(rpcRequest)) {
47
+ let runSend = function(abortSignal) {
48
+ controller?.abort();
49
+ controller = new AbortController();
50
+ const composed = abortSignal ? AbortSignal.any([controller.signal, abortSignal]) : controller.signal;
51
+ settle({ data: void 0, error: void 0, status: "running" });
52
+ const pending = Promise.resolve(sendSource.send({ abortSignal: composed }));
53
+ pending.then((response) => {
54
+ settle({ data: response, error: void 0, status: "success" });
55
+ }).catch((cause) => {
56
+ settle({ data: void 0, error: cause, status: "error" });
57
+ });
58
+ return kit.getAbortablePromise(pending, composed);
59
+ };
60
+ const sendSource = rpcRequest;
61
+ const listeners = /* @__PURE__ */ new Set();
62
+ let sendState = {
63
+ data: void 0,
64
+ error: void 0,
65
+ status: "idle"
66
+ };
67
+ let controller;
68
+ const emit = () => {
69
+ listeners.forEach((listener) => {
70
+ listener();
71
+ });
72
+ };
73
+ const settle = (next) => {
74
+ sendState = next;
75
+ emit();
76
+ };
77
+ rpcRequest = {
78
+ reactiveStore: () => ({
79
+ dispatch() {
80
+ void runSend().catch(() => {
81
+ });
82
+ },
83
+ dispatchAsync: () => runSend(),
84
+ getState: () => sendState,
85
+ reset() {
86
+ controller?.abort();
87
+ settle({ data: void 0, error: void 0, status: "idle" });
88
+ },
89
+ subscribe(listener) {
90
+ listeners.add(listener);
91
+ return () => {
92
+ listeners.delete(listener);
93
+ };
94
+ },
95
+ withSignal(signal) {
96
+ return {
97
+ dispatch: () => {
98
+ void runSend(signal).catch(() => {
99
+ });
100
+ },
101
+ dispatchAsync: () => runSend(signal)
102
+ };
103
+ }
104
+ })
105
+ };
106
+ }
107
+ connectionCount += 1;
108
+ const connection = connectionCount;
109
+ const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(connection);
110
+ const store = kit.createReactiveStoreWithInitialValueAndSlotTracking({
111
+ initialValueMapper: source.rpcValueMapper,
112
+ initialValueSource: rpcRequest,
113
+ streamSource: rpcSubscriptionRequest,
114
+ streamValueMapper: source.rpcSubscriptionValueMapper
115
+ });
116
+ activeStore = store;
117
+ applyState(store.getState());
118
+ disposables.push(
119
+ store.subscribe(() => {
120
+ applyState(store.getState());
121
+ })
122
+ );
123
+ if (callerSignal?.aborted) {
124
+ applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
125
+ return;
126
+ }
127
+ if (callerSignal) {
128
+ store.withSignal(callerSignal).connect();
129
+ } else {
130
+ store.connect();
131
+ }
132
+ }
133
+ function disconnect() {
134
+ disposables.forEach((dispose) => {
135
+ dispose();
136
+ });
137
+ disposables.length = 0;
138
+ if (activeStore) {
139
+ activeStore.reset();
140
+ activeStore = void 0;
141
+ }
142
+ }
143
+ vue.watch(
144
+ () => [vue.unref(source.rpcRequest), vue.unref(source.rpcSubscriptionRequest)],
145
+ () => {
146
+ buildAndConnect();
147
+ },
148
+ { flush: "post" }
149
+ );
150
+ vue.onMounted(() => {
151
+ buildAndConnect();
152
+ });
153
+ if (!vue.getCurrentInstance()) {
154
+ buildAndConnect();
155
+ }
156
+ vue.onScopeDispose(() => {
157
+ disposed = true;
158
+ disconnect();
159
+ });
160
+ return {
161
+ data: vue.computed(() => data.value),
162
+ error: vue.computed(() => error.value),
163
+ refresh: (options2) => {
164
+ buildAndConnect(options2);
165
+ },
166
+ status: vue.computed(() => status.value)
167
+ };
168
+ }
169
+ function isSendSource(value) {
170
+ return typeof value === "object" && value !== null && "send" in value && typeof value.send === "function";
171
+ }
172
+
173
+ exports.useTrackedData = useTrackedData;
@@ -3,9 +3,9 @@ import { withSolanaTimeout } from '@vue-solana/core/timeout';
3
3
  import { signAndSendTransaction, confirmTransactionSignature } from '@vue-solana/core/transaction';
4
4
  import { createNoWalletSelectedError } from '@vue-solana/core/wallet';
5
5
  import { ref } from 'vue';
6
- import { u as useConnection } from './vue.ChujsB0B.mjs';
7
- import { u as useWallet } from './vue.PJjEncbP.mjs';
8
- import { g as getConfirmedTransactionStatus } from './vue.B2sFJ1xI.mjs';
6
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
7
+ import { u as useWallet } from './vue.D218Ow7t.mjs';
8
+ import { g as getConfirmedTransactionStatus } from './vue.D3Y0PWbF.mjs';
9
9
 
10
10
  const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
11
11
  function useSignAndSendTransaction() {
@@ -3,8 +3,8 @@
3
3
  const address = require('@vue-solana/core/address');
4
4
  const errors = require('@vue-solana/core/errors');
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 useBalance(address$1, commitment) {
10
10
  const solana = useSolana.tryUseSolana();
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const vue = require('vue');
4
- const useSolana = require('./vue.BaR1VPhl.cjs');
4
+ const useSolana = require('./vue.DE3emjSF.cjs');
5
5
 
6
6
  function useRpc() {
7
7
  const solana = useSolana.useSolana();
@@ -1,7 +1,7 @@
1
1
  import { normalizeSolanaError } from '@vue-solana/core/errors';
2
2
  import { createNoWalletSelectedError, assertWalletCanSignMessage } from '@vue-solana/core/wallet';
3
3
  import { ref } from 'vue';
4
- import { u as useWallet } from './vue.PJjEncbP.mjs';
4
+ import { u as useWallet } from './vue.D218Ow7t.mjs';
5
5
 
6
6
  function useSignMessage() {
7
7
  const { wallet } = useWallet();
@@ -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 useSolanaClient() {
4
4
  const { client } = useSolana();
@@ -3,7 +3,7 @@
3
3
  const transaction = require('@vue-solana/core/transaction');
4
4
  const errors = require('@vue-solana/core/errors');
5
5
  const vue = require('vue');
6
- const useConnection = require('./vue.CZwftA0L.cjs');
6
+ const useConnection = require('./vue.BVaMoz9y.cjs');
7
7
 
8
8
  function getConfirmedTransactionStatus(confirmation) {
9
9
  if (confirmation.commitment === "finalized") {
@@ -0,0 +1,103 @@
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(async (signal, resolved, override) => {
15
+ attempt += 1;
16
+ const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(attempt);
17
+ const composedSignal = callerSignal ? AbortSignal.any([signal, callerSignal]) : signal;
18
+ let pending;
19
+ if (isSendSource(resolved)) {
20
+ pending = Promise.resolve(resolved.send({ abortSignal: composedSignal }));
21
+ } else if (typeof resolved === "function") {
22
+ pending = Promise.resolve(resolved(composedSignal)).then(
23
+ (result) => isSendSource(result) ? result.send({ abortSignal: composedSignal }) : result
24
+ );
25
+ } else {
26
+ throw new Error("useRequest source did not resolve to a request function");
27
+ }
28
+ return kit.getAbortablePromise(pending, composedSignal);
29
+ });
30
+ const unsubscribe = store.subscribe(() => {
31
+ const next = store.getState();
32
+ if (next.status === "success") {
33
+ data.value = next.data;
34
+ error.value = null;
35
+ status.value = "success";
36
+ } else if (next.status === "error") {
37
+ error.value = errors.normalizeSolanaError(next.error, "RPC_FAILURE");
38
+ status.value = "error";
39
+ } else if (next.status === "running") {
40
+ status.value = "fetching";
41
+ }
42
+ });
43
+ vue.onScopeDispose(() => {
44
+ disposed = true;
45
+ unsubscribe();
46
+ store.reset();
47
+ });
48
+ function unwrapSource() {
49
+ if (vue.isRef(source)) {
50
+ return source.value;
51
+ }
52
+ return source;
53
+ }
54
+ async function run(override) {
55
+ if (disposed) {
56
+ return void 0;
57
+ }
58
+ const resolved = unwrapSource();
59
+ if (isDisabled(resolved)) {
60
+ data.value = void 0;
61
+ error.value = null;
62
+ status.value = "disabled";
63
+ store.reset();
64
+ return void 0;
65
+ }
66
+ status.value = "fetching";
67
+ try {
68
+ return await store.dispatchAsync(resolved, override);
69
+ } catch (cause) {
70
+ if (store.getState().status !== "error") {
71
+ return void 0;
72
+ }
73
+ throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
74
+ }
75
+ }
76
+ const refresh = (options2) => run(options2);
77
+ vue.watch(
78
+ () => vue.isRef(source) ? source.value : source,
79
+ () => {
80
+ void refresh().catch(() => void 0);
81
+ }
82
+ );
83
+ vue.onMounted(() => {
84
+ void refresh().catch(() => void 0);
85
+ });
86
+ if (!vue.getCurrentInstance()) {
87
+ void refresh().catch(() => void 0);
88
+ }
89
+ return {
90
+ data: vue.computed(() => data.value),
91
+ error: vue.computed(() => error.value),
92
+ refresh,
93
+ status: vue.computed(() => status.value)
94
+ };
95
+ }
96
+ function isDisabled(resolved) {
97
+ return resolved === null || resolved === void 0;
98
+ }
99
+ function isSendSource(resolved) {
100
+ return typeof resolved === "object" && resolved !== null && "send" in resolved && typeof resolved.send === "function";
101
+ }
102
+
103
+ exports.useRequest = useRequest;
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ const vue = require('vue');
4
+ const useClientCapability = require('./vue.BY0qpgYr.cjs');
5
+ const useSolanaClient = require('./vue.BIxphCAq.cjs');
6
+
7
+ function useIdentity() {
8
+ useClientCapability.useClientCapability(["identity"], {
9
+ hookName: "useIdentity",
10
+ providerHint: "Install a signer plugin, e.g. `createClient().use(generatedIdentity())` from `@solana/kit-plugin-signer`."
11
+ });
12
+ const { client } = useSolanaClient.useSolanaClient();
13
+ const identity = vue.shallowRef(
14
+ client.identity
15
+ );
16
+ const subscribable = client;
17
+ if (typeof subscribable.subscribeToIdentity === "function") {
18
+ const unsubscribe = subscribable.subscribeToIdentity(() => {
19
+ identity.value = client.identity;
20
+ });
21
+ vue.onScopeDispose(unsubscribe);
22
+ }
23
+ return identity;
24
+ }
25
+ function usePayer() {
26
+ useClientCapability.useClientCapability(["payer"], {
27
+ hookName: "usePayer",
28
+ providerHint: "Install a signer plugin, e.g. `createClient().use(generatedPayer())` from `@solana/kit-plugin-signer`."
29
+ });
30
+ const { client } = useSolanaClient.useSolanaClient();
31
+ const payer = vue.shallowRef(
32
+ client.payer
33
+ );
34
+ const subscribable = client;
35
+ if (typeof subscribable.subscribeToPayer === "function") {
36
+ const unsubscribe = subscribable.subscribeToPayer(() => {
37
+ payer.value = client.payer;
38
+ });
39
+ vue.onScopeDispose(unsubscribe);
40
+ }
41
+ return payer;
42
+ }
43
+
44
+ exports.useIdentity = useIdentity;
45
+ exports.usePayer = usePayer;