@vue-solana/vue 1.2.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 (220) hide show
  1. package/README.md +162 -23
  2. package/dist/buffer-polyfill.d.cts +0 -1
  3. package/dist/buffer-polyfill.d.mts +0 -1
  4. package/dist/buffer-polyfill.d.ts +0 -1
  5. package/dist/index.cjs +62 -22
  6. package/dist/index.d.cts +29 -13
  7. package/dist/index.d.mts +29 -13
  8. package/dist/index.d.ts +29 -13
  9. package/dist/index.mjs +41 -21
  10. package/dist/kit.d.cts +1 -1
  11. package/dist/kit.d.mts +1 -1
  12. package/dist/kit.d.ts +1 -1
  13. package/dist/shared/vue.5euWd6-V.mjs +59 -0
  14. package/dist/shared/vue.9TPxZPMf.cjs +59 -0
  15. package/dist/shared/vue.B4-LEdSE.cjs +102 -0
  16. package/dist/shared/{vue.C0uCLjJ6.cjs → vue.B6ainw2G.cjs} +1 -1
  17. package/dist/shared/vue.B8LptjZP.mjs +32 -0
  18. package/dist/shared/vue.B8pLQ8P4.cjs +105 -0
  19. package/dist/shared/vue.B8ub540p.mjs +109 -0
  20. package/dist/shared/{vue.D0ycWj82.mjs → vue.BD6Gm1nl.mjs} +9 -9
  21. package/dist/shared/{vue.BEesxsrA.cjs → vue.BGxz4dru.cjs} +7 -3
  22. package/dist/shared/{vue.DDxhSi72.mjs → vue.BINkrA8h.mjs} +9 -9
  23. package/dist/shared/{vue.COPnX5fq.cjs → vue.BIxphCAq.cjs} +1 -1
  24. package/dist/shared/{vue.CKTUFwSI.mjs → vue.BOpgWr43.mjs} +9 -10
  25. package/dist/shared/vue.BQRpjwKl.mjs +80 -0
  26. package/dist/shared/vue.BVaMoz9y.cjs +9 -0
  27. package/dist/shared/vue.BVj9lWBK.cjs +111 -0
  28. package/dist/shared/vue.BY0qpgYr.cjs +35 -0
  29. package/dist/shared/vue.Bfu1dCKe.mjs +10 -0
  30. package/dist/shared/vue.Bk5xjlUx.cjs +61 -0
  31. package/dist/shared/{vue.BtUKvuQw.mjs → vue.BsGwt78R.mjs} +2 -2
  32. package/dist/shared/{vue.BbX3ePDY.cjs → vue.Bwd1sGAM.cjs} +9 -10
  33. package/dist/shared/vue.ByxbBC3y.mjs +57 -0
  34. package/dist/shared/{vue.CPjEwHSg.mjs → vue.C13umiQi.mjs} +20 -8
  35. package/dist/shared/vue.C5FVoEZT.mjs +99 -0
  36. package/dist/shared/vue.CATOh_9G.mjs +42 -0
  37. package/dist/shared/{vue.Bhdhmz8d.cjs → vue.CIs8QhCw.cjs} +18 -74
  38. package/dist/shared/vue.CMohL_Cz.mjs +58 -0
  39. package/dist/shared/{vue.CYKT65tB.mjs → vue.CQh3AUE8.mjs} +2 -6
  40. package/dist/shared/{vue.DzKfcfpX.cjs → vue.CWZSMVnB.cjs} +6 -6
  41. package/dist/shared/{vue.B12Pt1PQ.mjs → vue.CXB4NEMA.mjs} +18 -74
  42. package/dist/shared/{vue.DFbay4mm.mjs → vue.C_4qJDiF.mjs} +1 -1
  43. package/dist/shared/vue.CoaIWGPT.cjs +38 -0
  44. package/dist/shared/vue.CogzzQXM.mjs +171 -0
  45. package/dist/shared/vue.CpkwC8Th.mjs +7 -0
  46. package/dist/shared/vue.CrkK_T15.cjs +86 -0
  47. package/dist/shared/vue.D-qi8PSL.cjs +82 -0
  48. package/dist/shared/{vue.B2AQR2bE.mjs → vue.D218Ow7t.mjs} +8 -4
  49. package/dist/shared/{vue.QHAHFnw8.mjs → vue.D3Y0PWbF.mjs} +3 -3
  50. package/dist/shared/vue.D5U1yLG3.mjs +83 -0
  51. package/dist/shared/{vue.j1vB3h1n.cjs → vue.DAg5wC1G.cjs} +9 -9
  52. package/dist/shared/vue.DDbVk0Zh.cjs +180 -0
  53. package/dist/shared/{vue.BE4KHksm.cjs → vue.DE3emjSF.cjs} +2 -7
  54. package/dist/shared/vue.DEHxNvUX.cjs +7 -0
  55. package/dist/shared/vue.DFaMJLAQ.cjs +60 -0
  56. package/dist/shared/vue.DImwKTwJ.mjs +103 -0
  57. package/dist/shared/{vue.G9t8pE0J.cjs → vue.DKyQ7J67.cjs} +1 -1
  58. package/dist/shared/vue.DNxOpDXz.cjs +12 -0
  59. package/dist/shared/vue.DXQVIRZA.mjs +174 -0
  60. package/dist/shared/vue.DYk0Xfr3.mjs +36 -0
  61. package/dist/shared/vue.D_P5SqqD.mjs +5 -0
  62. package/dist/shared/{vue.B14U1xmP.cjs → vue.Di7yjJ-R.cjs} +20 -8
  63. package/dist/shared/vue.DtCbCcPd.cjs +173 -0
  64. package/dist/shared/{vue.CM_uqVc0.mjs → vue.Dyi1OCI1.mjs} +6 -6
  65. package/dist/shared/{vue.BsD6AAmO.cjs → vue.E_npPFoV.cjs} +8 -8
  66. package/dist/shared/{vue.LNhX07HB.cjs → vue.FiMmnMHr.cjs} +2 -2
  67. package/dist/shared/{vue.CSzg70vB.mjs → vue.JUWqu6kD.mjs} +1 -1
  68. package/dist/shared/{vue.By1CUlOU.mjs → vue.Mxc8w6Qk.mjs} +1 -1
  69. package/dist/shared/{vue.ByUemLSf.cjs → vue.Sbbm9JSu.cjs} +3 -3
  70. package/dist/shared/vue.g8fnm_ca.cjs +45 -0
  71. package/dist/swr.cjs +136 -0
  72. package/dist/swr.d.cts +41 -0
  73. package/dist/swr.d.mts +41 -0
  74. package/dist/swr.d.ts +41 -0
  75. package/dist/swr.mjs +131 -0
  76. package/dist/useAccountInfo.cjs +7 -5
  77. package/dist/useAccountInfo.d.cts +12 -8
  78. package/dist/useAccountInfo.d.mts +12 -8
  79. package/dist/useAccountInfo.d.ts +12 -8
  80. package/dist/useAccountInfo.mjs +7 -5
  81. package/dist/useAction.cjs +9 -0
  82. package/dist/useAction.d.cts +45 -0
  83. package/dist/useAction.d.mts +45 -0
  84. package/dist/useAction.d.ts +45 -0
  85. package/dist/useAction.mjs +3 -0
  86. package/dist/useBalance.cjs +5 -4
  87. package/dist/useBalance.d.cts +4 -2
  88. package/dist/useBalance.d.mts +4 -2
  89. package/dist/useBalance.d.ts +4 -2
  90. package/dist/useBalance.mjs +5 -4
  91. package/dist/useClientCapability.cjs +12 -0
  92. package/dist/useClientCapability.d.cts +39 -0
  93. package/dist/useClientCapability.d.mts +39 -0
  94. package/dist/useClientCapability.d.ts +39 -0
  95. package/dist/useClientCapability.mjs +5 -0
  96. package/dist/useConnection.cjs +4 -3
  97. package/dist/useConnection.d.cts +9 -2
  98. package/dist/useConnection.d.mts +9 -2
  99. package/dist/useConnection.d.ts +9 -2
  100. package/dist/useConnection.mjs +4 -3
  101. package/dist/useIdentity.cjs +12 -0
  102. package/dist/useIdentity.d.cts +3 -0
  103. package/dist/useIdentity.d.mts +3 -0
  104. package/dist/useIdentity.d.ts +3 -0
  105. package/dist/useIdentity.mjs +6 -0
  106. package/dist/usePayer.cjs +13 -0
  107. package/dist/usePayer.d.cts +18 -0
  108. package/dist/usePayer.d.mts +18 -0
  109. package/dist/usePayer.d.ts +18 -0
  110. package/dist/usePayer.mjs +6 -0
  111. package/dist/usePlanTransaction.cjs +14 -0
  112. package/dist/usePlanTransaction.d.cts +37 -0
  113. package/dist/usePlanTransaction.d.mts +37 -0
  114. package/dist/usePlanTransaction.d.ts +37 -0
  115. package/dist/usePlanTransaction.mjs +7 -0
  116. package/dist/usePlanTransactions.cjs +13 -0
  117. package/dist/usePlanTransactions.d.cts +4 -0
  118. package/dist/usePlanTransactions.d.mts +4 -0
  119. package/dist/usePlanTransactions.d.ts +4 -0
  120. package/dist/usePlanTransactions.mjs +7 -0
  121. package/dist/useProgramAccounts.cjs +7 -5
  122. package/dist/useProgramAccounts.d.cts +24 -9
  123. package/dist/useProgramAccounts.d.mts +24 -9
  124. package/dist/useProgramAccounts.d.ts +24 -9
  125. package/dist/useProgramAccounts.mjs +7 -5
  126. package/dist/useRequest.cjs +11 -0
  127. package/dist/useRequest.d.cts +57 -0
  128. package/dist/useRequest.d.mts +57 -0
  129. package/dist/useRequest.d.ts +57 -0
  130. package/dist/useRequest.mjs +5 -0
  131. package/dist/useRpc.cjs +3 -2
  132. package/dist/useRpc.d.cts +5 -2
  133. package/dist/useRpc.d.mts +5 -2
  134. package/dist/useRpc.d.ts +5 -2
  135. package/dist/useRpc.mjs +3 -2
  136. package/dist/useSelectedWalletAccount.cjs +13 -0
  137. package/dist/useSelectedWalletAccount.d.cts +117 -0
  138. package/dist/useSelectedWalletAccount.d.mts +117 -0
  139. package/dist/useSelectedWalletAccount.d.ts +117 -0
  140. package/dist/useSelectedWalletAccount.mjs +3 -0
  141. package/dist/useSignAndSendTransaction.cjs +7 -6
  142. package/dist/useSignAndSendTransaction.d.cts +18 -24
  143. package/dist/useSignAndSendTransaction.d.mts +18 -24
  144. package/dist/useSignAndSendTransaction.d.ts +18 -24
  145. package/dist/useSignAndSendTransaction.mjs +7 -6
  146. package/dist/useSignAndSendTransactions.cjs +15 -0
  147. package/dist/useSignAndSendTransactions.d.cts +35 -0
  148. package/dist/useSignAndSendTransactions.d.mts +35 -0
  149. package/dist/useSignAndSendTransactions.d.ts +35 -0
  150. package/dist/useSignAndSendTransactions.mjs +8 -0
  151. package/dist/useSignIn.cjs +13 -0
  152. package/dist/useSignIn.d.cts +23 -0
  153. package/dist/useSignIn.d.mts +23 -0
  154. package/dist/useSignIn.d.ts +23 -0
  155. package/dist/useSignIn.mjs +7 -0
  156. package/dist/useSignMessage.cjs +4 -3
  157. package/dist/useSignMessage.mjs +4 -3
  158. package/dist/useSignTransactions.cjs +13 -0
  159. package/dist/useSignTransactions.d.cts +24 -0
  160. package/dist/useSignTransactions.d.mts +24 -0
  161. package/dist/useSignTransactions.d.ts +24 -0
  162. package/dist/useSignTransactions.mjs +7 -0
  163. package/dist/useSignatureStatus.cjs +5 -4
  164. package/dist/useSignatureStatus.d.cts +9 -5
  165. package/dist/useSignatureStatus.d.mts +9 -5
  166. package/dist/useSignatureStatus.d.ts +9 -5
  167. package/dist/useSignatureStatus.mjs +5 -4
  168. package/dist/useSolana.cjs +2 -1
  169. package/dist/useSolana.mjs +2 -1
  170. package/dist/useSolanaClient.cjs +3 -2
  171. package/dist/useSolanaClient.mjs +3 -2
  172. package/dist/useSubscription.cjs +9 -0
  173. package/dist/useSubscription.d.cts +58 -0
  174. package/dist/useSubscription.d.mts +58 -0
  175. package/dist/useSubscription.d.ts +58 -0
  176. package/dist/useSubscription.mjs +3 -0
  177. package/dist/useTokenAccounts.cjs +7 -6
  178. package/dist/useTokenAccounts.d.cts +6 -6
  179. package/dist/useTokenAccounts.d.mts +6 -6
  180. package/dist/useTokenAccounts.d.ts +6 -6
  181. package/dist/useTokenAccounts.mjs +7 -6
  182. package/dist/useTokenBalance.cjs +7 -6
  183. package/dist/useTokenBalance.d.cts +2 -2
  184. package/dist/useTokenBalance.d.mts +2 -2
  185. package/dist/useTokenBalance.d.ts +2 -2
  186. package/dist/useTokenBalance.mjs +7 -6
  187. package/dist/useTrackedData.cjs +10 -0
  188. package/dist/useTrackedData.d.cts +86 -0
  189. package/dist/useTrackedData.d.mts +86 -0
  190. package/dist/useTrackedData.d.ts +86 -0
  191. package/dist/useTrackedData.mjs +4 -0
  192. package/dist/useTransaction.cjs +2 -1
  193. package/dist/useTransaction.d.cts +13 -3
  194. package/dist/useTransaction.d.mts +13 -3
  195. package/dist/useTransaction.d.ts +13 -3
  196. package/dist/useTransaction.mjs +2 -1
  197. package/dist/useTransactionConfirmation.cjs +5 -4
  198. package/dist/useTransactionConfirmation.d.cts +18 -24
  199. package/dist/useTransactionConfirmation.d.mts +18 -24
  200. package/dist/useTransactionConfirmation.d.ts +18 -24
  201. package/dist/useTransactionConfirmation.mjs +5 -4
  202. package/dist/useWallet.cjs +3 -2
  203. package/dist/useWallet.d.cts +2 -2
  204. package/dist/useWallet.d.mts +2 -2
  205. package/dist/useWallet.d.ts +2 -2
  206. package/dist/useWallet.mjs +3 -2
  207. package/dist/useWallets.cjs +3 -2
  208. package/dist/useWallets.mjs +3 -2
  209. package/package.json +73 -9
  210. package/dist/shared/vue.C4d2JA8U.mjs +0 -44
  211. package/dist/shared/vue.CE5i8KZZ.cjs +0 -46
  212. package/dist/shared/vue.CfrVAzEf.mjs +0 -129
  213. package/dist/shared/vue.DCgByzxg.cjs +0 -9
  214. package/dist/shared/vue.DiNn3XHm.mjs +0 -7
  215. package/dist/shared/vue._CAClzAz.cjs +0 -131
  216. package/dist/web3.cjs +0 -13
  217. package/dist/web3.d.cts +0 -1
  218. package/dist/web3.d.mts +0 -1
  219. package/dist/web3.d.ts +0 -1
  220. package/dist/web3.mjs +0 -1
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ const action = require('@vue-solana/core/action');
4
+ const vue = require('vue');
5
+
6
+ function useAction(action$1, options = {}) {
7
+ const store = action.createSolanaActionStore(
8
+ (signal, ...args) => vue.unref(action$1)(signal, ...args)
9
+ );
10
+ const state = vue.shallowRef(store.getState());
11
+ const unsubscribe = store.subscribe(() => {
12
+ const next = store.getState();
13
+ const previous = state.value;
14
+ if (next.status === "success" && previous.status !== "success") {
15
+ options.onSuccess?.(next.data);
16
+ }
17
+ if (next.status === "error" && previous.status !== "error") {
18
+ options.onError?.(next.error);
19
+ }
20
+ state.value = next;
21
+ });
22
+ vue.onScopeDispose(() => {
23
+ unsubscribe();
24
+ store.reset();
25
+ });
26
+ return {
27
+ data: vue.computed(() => state.value.data),
28
+ dispatch: (...args) => store.dispatchAsync(...args),
29
+ error: vue.computed(() => state.value.error),
30
+ isRunning: vue.computed(() => state.value.status === "running"),
31
+ reset: () => {
32
+ store.reset();
33
+ },
34
+ status: vue.computed(() => state.value.status)
35
+ };
36
+ }
37
+
38
+ exports.useAction = useAction;
@@ -0,0 +1,171 @@
1
+ import { createReactiveStoreWithInitialValueAndSlotTracking, getAbortablePromise } from '@vue-solana/core/kit';
2
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
3
+ import { shallowRef, watch, unref, onMounted, getCurrentInstance, onScopeDispose, computed } from 'vue';
4
+
5
+ function isActionSource(value) {
6
+ return typeof value === "object" && value !== null && "reactiveStore" in value && typeof value.reactiveStore === "function";
7
+ }
8
+ function useTrackedData(source, options = {}) {
9
+ const data = shallowRef(void 0);
10
+ const error = shallowRef(null);
11
+ const status = shallowRef("loading");
12
+ const disposables = [];
13
+ let connectionCount = 0;
14
+ let disposed = false;
15
+ let activeStore;
16
+ function applyState(state) {
17
+ if (state.status === "loaded") {
18
+ data.value = state.data;
19
+ error.value = null;
20
+ status.value = "loaded";
21
+ } else if (state.status === "error") {
22
+ error.value = normalizeSolanaError(state.error, "RPC_FAILURE");
23
+ status.value = "error";
24
+ options.onError?.(state.error);
25
+ } else if (state.status === "loading") {
26
+ status.value = data.value === void 0 ? "loading" : status.value;
27
+ } else if (state.status === "idle") {
28
+ error.value = null;
29
+ }
30
+ }
31
+ function buildAndConnect() {
32
+ if (disposed) {
33
+ return;
34
+ }
35
+ let rpcRequest = unref(source.rpcRequest);
36
+ const rpcSubscriptionRequest = unref(source.rpcSubscriptionRequest);
37
+ if (!rpcRequest || !rpcSubscriptionRequest) {
38
+ disconnect();
39
+ data.value = void 0;
40
+ error.value = null;
41
+ status.value = "disabled";
42
+ return;
43
+ }
44
+ if (!isActionSource(rpcRequest) && isSendSource(rpcRequest)) {
45
+ let runSend = function(abortSignal) {
46
+ controller?.abort();
47
+ controller = new AbortController();
48
+ const composed = abortSignal ? AbortSignal.any([controller.signal, abortSignal]) : controller.signal;
49
+ settle({ data: void 0, error: void 0, status: "running" });
50
+ const pending = Promise.resolve(sendSource.send({ abortSignal: composed }));
51
+ pending.then((response) => {
52
+ settle({ data: response, error: void 0, status: "success" });
53
+ }).catch((cause) => {
54
+ settle({ data: void 0, error: cause, status: "error" });
55
+ });
56
+ return getAbortablePromise(pending, composed);
57
+ };
58
+ const sendSource = rpcRequest;
59
+ const listeners = /* @__PURE__ */ new Set();
60
+ let sendState = {
61
+ data: void 0,
62
+ error: void 0,
63
+ status: "idle"
64
+ };
65
+ let controller;
66
+ const emit = () => {
67
+ listeners.forEach((listener) => {
68
+ listener();
69
+ });
70
+ };
71
+ const settle = (next) => {
72
+ sendState = next;
73
+ emit();
74
+ };
75
+ rpcRequest = {
76
+ reactiveStore: () => ({
77
+ dispatch() {
78
+ void runSend().catch(() => {
79
+ });
80
+ },
81
+ dispatchAsync: () => runSend(),
82
+ getState: () => sendState,
83
+ reset() {
84
+ controller?.abort();
85
+ settle({ data: void 0, error: void 0, status: "idle" });
86
+ },
87
+ subscribe(listener) {
88
+ listeners.add(listener);
89
+ return () => {
90
+ listeners.delete(listener);
91
+ };
92
+ },
93
+ withSignal(signal) {
94
+ return {
95
+ dispatch: () => {
96
+ void runSend(signal).catch(() => {
97
+ });
98
+ },
99
+ dispatchAsync: () => runSend(signal)
100
+ };
101
+ }
102
+ })
103
+ };
104
+ }
105
+ connectionCount += 1;
106
+ const connection = connectionCount;
107
+ const callerSignal = options.getAbortSignal?.(connection);
108
+ const store = createReactiveStoreWithInitialValueAndSlotTracking({
109
+ initialValueMapper: source.rpcValueMapper,
110
+ initialValueSource: rpcRequest,
111
+ streamSource: rpcSubscriptionRequest,
112
+ streamValueMapper: source.rpcSubscriptionValueMapper
113
+ });
114
+ activeStore = store;
115
+ applyState(store.getState());
116
+ disposables.push(
117
+ store.subscribe(() => {
118
+ applyState(store.getState());
119
+ })
120
+ );
121
+ if (callerSignal?.aborted) {
122
+ applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
123
+ return;
124
+ }
125
+ if (callerSignal) {
126
+ store.withSignal(callerSignal).connect();
127
+ } else {
128
+ store.connect();
129
+ }
130
+ }
131
+ function disconnect() {
132
+ disposables.forEach((dispose) => {
133
+ dispose();
134
+ });
135
+ disposables.length = 0;
136
+ if (activeStore) {
137
+ activeStore.reset();
138
+ activeStore = void 0;
139
+ }
140
+ }
141
+ watch(
142
+ () => [unref(source.rpcRequest), unref(source.rpcSubscriptionRequest)],
143
+ () => {
144
+ buildAndConnect();
145
+ },
146
+ { flush: "post" }
147
+ );
148
+ onMounted(() => {
149
+ buildAndConnect();
150
+ });
151
+ if (!getCurrentInstance()) {
152
+ buildAndConnect();
153
+ }
154
+ onScopeDispose(() => {
155
+ disposed = true;
156
+ disconnect();
157
+ });
158
+ return {
159
+ data: computed(() => data.value),
160
+ error: computed(() => error.value),
161
+ refresh: () => {
162
+ buildAndConnect();
163
+ },
164
+ status: computed(() => status.value)
165
+ };
166
+ }
167
+ function isSendSource(value) {
168
+ return typeof value === "object" && value !== null && "send" in value && typeof value.send === "function";
169
+ }
170
+
171
+ export { useTrackedData as u };
@@ -0,0 +1,7 @@
1
+ import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
2
+
3
+ function useConnection() {
4
+ return useSolanaClient().client;
5
+ }
6
+
7
+ export { useConnection as u };
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ const errors = require('@vue-solana/core/errors');
4
+ const timeout = require('@vue-solana/core/timeout');
5
+ const wallet = require('@vue-solana/core/wallet');
6
+ const vue = require('vue');
7
+ const useWallet = require('./vue.BGxz4dru.cjs');
8
+
9
+ const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
10
+ class PartialSignAndSendError extends errors.SolanaError {
11
+ constructor(cause, signatures) {
12
+ super(cause.code, cause.message, { cause: cause.cause, feature: cause.feature });
13
+ this.signatures = signatures;
14
+ this.name = "PartialSignAndSendError";
15
+ }
16
+ }
17
+ function useSignAndSendTransactions() {
18
+ const { wallet: wallet$1 } = useWallet.useWallet();
19
+ const signatures = vue.shallowRef(null);
20
+ const status = vue.ref("idle");
21
+ const loading = vue.ref(false);
22
+ const error = vue.ref(null);
23
+ let executionId = 0;
24
+ async function execute(transactions, options) {
25
+ const currentExecutionId = ++executionId;
26
+ status.value = "sending";
27
+ loading.value = true;
28
+ error.value = null;
29
+ signatures.value = null;
30
+ const activeWallet = wallet$1.value;
31
+ if (!activeWallet) {
32
+ const normalizedError = wallet.createNoWalletSelectedError();
33
+ error.value = normalizedError;
34
+ status.value = "error";
35
+ loading.value = false;
36
+ throw normalizedError;
37
+ }
38
+ const sendSingularSequentially = async () => {
39
+ const collected = [];
40
+ for (const transaction of transactions) {
41
+ try {
42
+ const result = await activeWallet.signAndSendTransaction(transaction, options);
43
+ collected.push(result.signature);
44
+ } catch (cause) {
45
+ throw new PartialSignAndSendError(errors.normalizeSolanaError(cause, "RPC_FAILURE"), collected);
46
+ }
47
+ }
48
+ return collected;
49
+ };
50
+ try {
51
+ wallet.assertWalletCanSignAndSendTransactions(activeWallet);
52
+ const send = timeout.withSolanaTimeout(
53
+ activeWallet.signAndSendTransactions ? activeWallet.signAndSendTransactions(transactions, options) : sendSingularSequentially(),
54
+ SIGN_AND_SEND_TIMEOUT_MS,
55
+ "Wallet transaction did not return a result. Check your wallet or explorer for the final status."
56
+ );
57
+ const result = await send;
58
+ if (currentExecutionId === executionId) {
59
+ signatures.value = result;
60
+ status.value = "sent";
61
+ }
62
+ return result;
63
+ } catch (cause) {
64
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
65
+ if (currentExecutionId === executionId) {
66
+ error.value = normalizedError;
67
+ status.value = "error";
68
+ }
69
+ throw normalizedError;
70
+ } finally {
71
+ if (currentExecutionId === executionId) {
72
+ loading.value = false;
73
+ }
74
+ }
75
+ }
76
+ return {
77
+ signatures,
78
+ status,
79
+ loading,
80
+ error,
81
+ execute
82
+ };
83
+ }
84
+
85
+ exports.PartialSignAndSendError = PartialSignAndSendError;
86
+ exports.useSignAndSendTransactions = useSignAndSendTransactions;
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ const errors = require('@vue-solana/core/errors');
4
+ const vue = require('vue');
5
+ const address = require('@vue-solana/core/address');
6
+ const useConnection = require('./vue.BVaMoz9y.cjs');
7
+ const useSolana = require('./vue.DE3emjSF.cjs');
8
+ const decodeBase64 = require('./vue.DNxOpDXz.cjs');
9
+
10
+ function useAccountInfo(address$1, options = {}) {
11
+ const solana = useSolana.tryUseSolana();
12
+ const client = solana?.client ?? useConnection.useConnection();
13
+ const accountInfo = vue.shallowRef(null);
14
+ const loading = vue.shallowRef(false);
15
+ const error = vue.shallowRef(null);
16
+ let refreshId = 0;
17
+ async function refresh() {
18
+ const requestId = ++refreshId;
19
+ const value = vue.toValue(address$1);
20
+ if (!value || !solana) {
21
+ accountInfo.value = null;
22
+ loading.value = false;
23
+ error.value = null;
24
+ return null;
25
+ }
26
+ loading.value = true;
27
+ error.value = null;
28
+ try {
29
+ const parsedAddress = address.parseAddress(value);
30
+ if (!parsedAddress) {
31
+ accountInfo.value = null;
32
+ return null;
33
+ }
34
+ const { value: account } = await client.rpc.getAccountInfo(parsedAddress, {
35
+ encoding: "base64",
36
+ commitment: options.commitment
37
+ }).send();
38
+ const nextAccountInfo = account ? normalizeAccountInfo(account) : null;
39
+ if (requestId === refreshId) {
40
+ accountInfo.value = nextAccountInfo;
41
+ }
42
+ return nextAccountInfo;
43
+ } catch (cause) {
44
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
45
+ if (requestId === refreshId) {
46
+ accountInfo.value = null;
47
+ error.value = normalizedError;
48
+ }
49
+ throw normalizedError;
50
+ } finally {
51
+ if (requestId === refreshId) {
52
+ loading.value = false;
53
+ }
54
+ }
55
+ }
56
+ vue.onMounted(() => {
57
+ void refresh().catch(() => void 0);
58
+ });
59
+ vue.watch(
60
+ () => vue.toValue(address$1),
61
+ () => {
62
+ void refresh().catch(() => void 0);
63
+ }
64
+ );
65
+ return {
66
+ accountInfo,
67
+ loading,
68
+ error,
69
+ refresh
70
+ };
71
+ }
72
+ function normalizeAccountInfo(account) {
73
+ return {
74
+ executable: account.executable,
75
+ lamports: Number(account.lamports),
76
+ owner: account.owner,
77
+ space: Number(account.space),
78
+ data: decodeBase64.decodeBase64(account.data[0])
79
+ };
80
+ }
81
+
82
+ exports.useAccountInfo = useAccountInfo;
@@ -1,7 +1,7 @@
1
1
  import { normalizeSolanaError } from '@vue-solana/core/errors';
2
- import { createNoWalletSelectedError } from '@vue-solana/core/wallet';
2
+ import { createNoWalletSelectedError, assertWalletConnected } from '@vue-solana/core/wallet';
3
3
  import { ref, computed, triggerRef } from 'vue';
4
- import { u as useSolana } from './vue.CYKT65tB.mjs';
4
+ import { u as useSolana } from './vue.CQh3AUE8.mjs';
5
5
 
6
6
  function useWallet() {
7
7
  const solana = useSolana();
@@ -9,6 +9,9 @@ function useWallet() {
9
9
  const connecting = ref(false);
10
10
  const disconnecting = ref(false);
11
11
  async function connect() {
12
+ if (connecting.value || wallet.value?.connecting) {
13
+ return;
14
+ }
12
15
  const activeWallet = wallet.value;
13
16
  if (!activeWallet) {
14
17
  throw createNoWalletSelectedError();
@@ -18,9 +21,10 @@ function useWallet() {
18
21
  const connection = activeWallet.connect();
19
22
  triggerRef(wallet);
20
23
  await connection;
24
+ assertWalletConnected(activeWallet);
21
25
  triggerRef(wallet);
22
26
  console.info("[Vue Solana] Wallet connected", {
23
- publicKey: activeWallet.publicKey?.toBase58() ?? null
27
+ publicKey: activeWallet.publicKey ?? null
24
28
  });
25
29
  } catch (error) {
26
30
  const normalizedError = normalizeSolanaError(error, "RPC_FAILURE");
@@ -36,7 +40,7 @@ function useWallet() {
36
40
  if (!activeWallet) {
37
41
  return;
38
42
  }
39
- const publicKey = activeWallet.publicKey?.toBase58() ?? null;
43
+ const publicKey = activeWallet.publicKey ?? null;
40
44
  disconnecting.value = true;
41
45
  try {
42
46
  await activeWallet.disconnect();
@@ -1,7 +1,7 @@
1
1
  import { confirmTransactionSignature } from '@vue-solana/core/transaction';
2
2
  import { normalizeSolanaError } from '@vue-solana/core/errors';
3
3
  import { ref } from 'vue';
4
- import { u as useConnection } from './vue.DiNn3XHm.mjs';
4
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
5
5
 
6
6
  function getConfirmedTransactionStatus(confirmation) {
7
7
  if (confirmation.commitment === "finalized") {
@@ -10,7 +10,7 @@ function getConfirmedTransactionStatus(confirmation) {
10
10
  return confirmation.commitment === "processed" ? "processed" : "confirmed";
11
11
  }
12
12
  function useTransactionConfirmation(defaultOptions = {}) {
13
- const connection = useConnection();
13
+ const client = useConnection();
14
14
  const signature = ref(null);
15
15
  const confirmation = ref(null);
16
16
  const status = ref("idle");
@@ -27,7 +27,7 @@ function useTransactionConfirmation(defaultOptions = {}) {
27
27
  error.value = null;
28
28
  try {
29
29
  const nextConfirmation = await confirmTransactionSignature(
30
- connection,
30
+ client,
31
31
  nextSignature,
32
32
  confirmationOptions
33
33
  );
@@ -0,0 +1,83 @@
1
+ import { SolanaError, normalizeSolanaError } from '@vue-solana/core/errors';
2
+ import { withSolanaTimeout } from '@vue-solana/core/timeout';
3
+ import { createNoWalletSelectedError, assertWalletCanSignAndSendTransactions } from '@vue-solana/core/wallet';
4
+ import { shallowRef, ref } from 'vue';
5
+ import { u as useWallet } from './vue.D218Ow7t.mjs';
6
+
7
+ const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
8
+ class PartialSignAndSendError extends SolanaError {
9
+ constructor(cause, signatures) {
10
+ super(cause.code, cause.message, { cause: cause.cause, feature: cause.feature });
11
+ this.signatures = signatures;
12
+ this.name = "PartialSignAndSendError";
13
+ }
14
+ }
15
+ function useSignAndSendTransactions() {
16
+ const { wallet } = useWallet();
17
+ const signatures = shallowRef(null);
18
+ const status = ref("idle");
19
+ const loading = ref(false);
20
+ const error = ref(null);
21
+ let executionId = 0;
22
+ async function execute(transactions, options) {
23
+ const currentExecutionId = ++executionId;
24
+ status.value = "sending";
25
+ loading.value = true;
26
+ error.value = null;
27
+ signatures.value = null;
28
+ const activeWallet = wallet.value;
29
+ if (!activeWallet) {
30
+ const normalizedError = createNoWalletSelectedError();
31
+ error.value = normalizedError;
32
+ status.value = "error";
33
+ loading.value = false;
34
+ throw normalizedError;
35
+ }
36
+ const sendSingularSequentially = async () => {
37
+ const collected = [];
38
+ for (const transaction of transactions) {
39
+ try {
40
+ const result = await activeWallet.signAndSendTransaction(transaction, options);
41
+ collected.push(result.signature);
42
+ } catch (cause) {
43
+ throw new PartialSignAndSendError(normalizeSolanaError(cause, "RPC_FAILURE"), collected);
44
+ }
45
+ }
46
+ return collected;
47
+ };
48
+ try {
49
+ assertWalletCanSignAndSendTransactions(activeWallet);
50
+ const send = withSolanaTimeout(
51
+ activeWallet.signAndSendTransactions ? activeWallet.signAndSendTransactions(transactions, options) : sendSingularSequentially(),
52
+ SIGN_AND_SEND_TIMEOUT_MS,
53
+ "Wallet transaction did not return a result. Check your wallet or explorer for the final status."
54
+ );
55
+ const result = await send;
56
+ if (currentExecutionId === executionId) {
57
+ signatures.value = result;
58
+ status.value = "sent";
59
+ }
60
+ return result;
61
+ } catch (cause) {
62
+ const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
63
+ if (currentExecutionId === executionId) {
64
+ error.value = normalizedError;
65
+ status.value = "error";
66
+ }
67
+ throw normalizedError;
68
+ } finally {
69
+ if (currentExecutionId === executionId) {
70
+ loading.value = false;
71
+ }
72
+ }
73
+ }
74
+ return {
75
+ signatures,
76
+ status,
77
+ loading,
78
+ error,
79
+ execute
80
+ };
81
+ }
82
+
83
+ export { PartialSignAndSendError as P, useSignAndSendTransactions as u };
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- const address = require('@vue-solana/core/address');
4
- const errors = require('@vue-solana/core/errors');
5
3
  const tokenAccounts = require('@vue-solana/core/token-accounts');
4
+ const errors = require('@vue-solana/core/errors');
5
+ const address = require('@vue-solana/core/address');
6
6
  const vue = require('vue');
7
- const useConnection = require('./vue.DCgByzxg.cjs');
8
- const useSolana = require('./vue.BE4KHksm.cjs');
7
+ const useConnection = require('./vue.BVaMoz9y.cjs');
8
+ const useSolana = require('./vue.DE3emjSF.cjs');
9
9
 
10
- function useTokenBalance(mint, owner) {
10
+ function useTokenBalance(mint, owner, commitment) {
11
11
  const solana = useSolana.tryUseSolana();
12
- const connection = solana?.connection ?? useConnection.useConnection();
12
+ const client = solana?.client ?? useConnection.useConnection();
13
13
  const balance = vue.shallowRef(null);
14
14
  const decimals = vue.shallowRef(null);
15
15
  const loading = vue.shallowRef(false);
@@ -29,15 +29,15 @@ function useTokenBalance(mint, owner) {
29
29
  loading.value = true;
30
30
  error.value = null;
31
31
  try {
32
- const mintKey = address.parsePublicKey(mintValue);
33
- const ownerKey = address.parsePublicKey(ownerValue);
32
+ const mintKey = address.parseAddress(mintValue);
33
+ const ownerKey = address.parseAddress(ownerValue);
34
34
  if (!mintKey || !ownerKey) {
35
35
  balance.value = null;
36
36
  decimals.value = null;
37
37
  loading.value = false;
38
38
  return null;
39
39
  }
40
- const nextBalance = await tokenAccounts.getTokenBalance(connection, mintKey, ownerKey);
40
+ const nextBalance = await tokenAccounts.getTokenBalance(client, mintKey, ownerKey, commitment);
41
41
  if (requestId === refreshId) {
42
42
  balance.value = nextBalance?.amount ?? null;
43
43
  decimals.value = nextBalance?.decimals ?? null;