@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,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 };
@@ -1,13 +1,13 @@
1
- import { parsePublicKey } from '@vue-solana/core/address';
2
- import { normalizeSolanaError } from '@vue-solana/core/errors';
3
1
  import { getTokenBalance } from '@vue-solana/core/token-accounts';
2
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
3
+ import { parseAddress } from '@vue-solana/core/address';
4
4
  import { shallowRef, onMounted, watch, toValue } from 'vue';
5
- import { u as useConnection } from './vue.DiNn3XHm.mjs';
6
- import { t as tryUseSolana } from './vue.CYKT65tB.mjs';
5
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
6
+ import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
7
7
 
8
- function useTokenBalance(mint, owner) {
8
+ function useTokenBalance(mint, owner, commitment) {
9
9
  const solana = tryUseSolana();
10
- const connection = solana?.connection ?? useConnection();
10
+ const client = solana?.client ?? useConnection();
11
11
  const balance = shallowRef(null);
12
12
  const decimals = shallowRef(null);
13
13
  const loading = shallowRef(false);
@@ -27,15 +27,15 @@ function useTokenBalance(mint, owner) {
27
27
  loading.value = true;
28
28
  error.value = null;
29
29
  try {
30
- const mintKey = parsePublicKey(mintValue);
31
- const ownerKey = parsePublicKey(ownerValue);
30
+ const mintKey = parseAddress(mintValue);
31
+ const ownerKey = parseAddress(ownerValue);
32
32
  if (!mintKey || !ownerKey) {
33
33
  balance.value = null;
34
34
  decimals.value = null;
35
35
  loading.value = false;
36
36
  return null;
37
37
  }
38
- const nextBalance = await getTokenBalance(connection, mintKey, ownerKey);
38
+ const nextBalance = await getTokenBalance(client, mintKey, ownerKey, commitment);
39
39
  if (requestId === refreshId) {
40
40
  balance.value = nextBalance?.amount ?? null;
41
41
  decimals.value = nextBalance?.decimals ?? null;
@@ -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.BE4KHksm.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,9 +23,10 @@ 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
- publicKey: activeWallet.publicKey?.toBase58() ?? null
29
+ publicKey: activeWallet.publicKey ?? null
26
30
  });
27
31
  } catch (error) {
28
32
  const normalizedError = errors.normalizeSolanaError(error, "RPC_FAILURE");
@@ -38,7 +42,7 @@ function useWallet() {
38
42
  if (!activeWallet) {
39
43
  return;
40
44
  }
41
- const publicKey = activeWallet.publicKey?.toBase58() ?? null;
45
+ const publicKey = activeWallet.publicKey ?? null;
42
46
  disconnecting.value = true;
43
47
  try {
44
48
  await activeWallet.disconnect();
@@ -1,12 +1,12 @@
1
- import { parsePublicKey } from '@vue-solana/core/address';
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.DiNn3XHm.mjs';
5
- import { t as tryUseSolana } from './vue.CYKT65tB.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();
9
- const connection = solana?.connection ?? useConnection();
9
+ const client = solana?.client ?? useConnection();
10
10
  const balance = shallowRef(null);
11
11
  const loading = shallowRef(false);
12
12
  const error = shallowRef(null);
@@ -23,16 +23,16 @@ function useBalance(address, commitment) {
23
23
  loading.value = true;
24
24
  error.value = null;
25
25
  try {
26
- const publicKey = parsePublicKey(value);
27
- if (!publicKey) {
26
+ const parsedAddress = parseAddress(value);
27
+ if (!parsedAddress) {
28
28
  balance.value = null;
29
29
  return null;
30
30
  }
31
- const nextBalance = await connection.getBalance(publicKey, commitment);
31
+ const { value: lamports } = await client.rpc.getBalance(parsedAddress, commitment ? { commitment } : void 0).send();
32
32
  if (requestId === refreshId) {
33
- balance.value = nextBalance;
33
+ balance.value = Number(lamports);
34
34
  }
35
- return nextBalance;
35
+ return Number(lamports);
36
36
  } catch (cause) {
37
37
  const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
38
38
  if (requestId === refreshId) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const useSolana = require('./vue.BE4KHksm.cjs');
3
+ const useSolana = require('./vue.DE3emjSF.cjs');
4
4
 
5
5
  function useSolanaClient() {
6
6
  const { client } = useSolana.useSolana();
@@ -1,13 +1,13 @@
1
- import { parsePublicKey } from '@vue-solana/core/address';
2
- import { normalizeSolanaError } from '@vue-solana/core/errors';
3
1
  import { getTokenAccountsByOwner } from '@vue-solana/core/token-accounts';
2
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
3
+ import { parseAddress } from '@vue-solana/core/address';
4
4
  import { shallowRef, onMounted, watch, toValue } from 'vue';
5
- import { u as useConnection } from './vue.DiNn3XHm.mjs';
6
- import { t as tryUseSolana } from './vue.CYKT65tB.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();
10
- const connection = solana?.connection ?? useConnection();
10
+ const client = solana?.client ?? useConnection();
11
11
  const tokenAccounts = shallowRef([]);
12
12
  const loading = shallowRef(false);
13
13
  const error = shallowRef(null);
@@ -24,17 +24,16 @@ function useTokenAccounts(owner, options) {
24
24
  loading.value = true;
25
25
  error.value = null;
26
26
  try {
27
- const publicKey = parsePublicKey(value);
28
- if (!publicKey) {
27
+ const parsedAddress = parseAddress(value);
28
+ if (!parsedAddress) {
29
29
  tokenAccounts.value = [];
30
30
  loading.value = false;
31
31
  return [];
32
32
  }
33
- const opts = {
33
+ const nextAccounts = await getTokenAccountsByOwner(client, parsedAddress, {
34
34
  commitment: options?.commitment,
35
35
  programId: options?.programId
36
- };
37
- const nextAccounts = await getTokenAccountsByOwner(connection, publicKey, opts);
36
+ });
38
37
  if (requestId === refreshId) {
39
38
  tokenAccounts.value = nextAccounts;
40
39
  }
@@ -0,0 +1,80 @@
1
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
2
+ import { shallowRef, onMounted, watch, toValue } from 'vue';
3
+ import { parseAddress } from '@vue-solana/core/address';
4
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
5
+ import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
6
+ import { d as decodeBase64 } from './vue.Bfu1dCKe.mjs';
7
+
8
+ function useAccountInfo(address, options = {}) {
9
+ const solana = tryUseSolana();
10
+ const client = solana?.client ?? useConnection();
11
+ const accountInfo = shallowRef(null);
12
+ const loading = shallowRef(false);
13
+ const error = shallowRef(null);
14
+ let refreshId = 0;
15
+ async function refresh() {
16
+ const requestId = ++refreshId;
17
+ const value = toValue(address);
18
+ if (!value || !solana) {
19
+ accountInfo.value = null;
20
+ loading.value = false;
21
+ error.value = null;
22
+ return null;
23
+ }
24
+ loading.value = true;
25
+ error.value = null;
26
+ try {
27
+ const parsedAddress = parseAddress(value);
28
+ if (!parsedAddress) {
29
+ accountInfo.value = null;
30
+ return null;
31
+ }
32
+ const { value: account } = await client.rpc.getAccountInfo(parsedAddress, {
33
+ encoding: "base64",
34
+ commitment: options.commitment
35
+ }).send();
36
+ const nextAccountInfo = account ? normalizeAccountInfo(account) : null;
37
+ if (requestId === refreshId) {
38
+ accountInfo.value = nextAccountInfo;
39
+ }
40
+ return nextAccountInfo;
41
+ } catch (cause) {
42
+ const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
43
+ if (requestId === refreshId) {
44
+ accountInfo.value = null;
45
+ error.value = normalizedError;
46
+ }
47
+ throw normalizedError;
48
+ } finally {
49
+ if (requestId === refreshId) {
50
+ loading.value = false;
51
+ }
52
+ }
53
+ }
54
+ onMounted(() => {
55
+ void refresh().catch(() => void 0);
56
+ });
57
+ watch(
58
+ () => toValue(address),
59
+ () => {
60
+ void refresh().catch(() => void 0);
61
+ }
62
+ );
63
+ return {
64
+ accountInfo,
65
+ loading,
66
+ error,
67
+ refresh
68
+ };
69
+ }
70
+ function normalizeAccountInfo(account) {
71
+ return {
72
+ executable: account.executable,
73
+ lamports: Number(account.lamports),
74
+ owner: account.owner,
75
+ space: Number(account.space),
76
+ data: decodeBase64(account.data[0])
77
+ };
78
+ }
79
+
80
+ export { useAccountInfo as u };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ const useSolanaClient = require('./vue.BIxphCAq.cjs');
4
+
5
+ function useConnection() {
6
+ return useSolanaClient.useSolanaClient().client;
7
+ }
8
+
9
+ exports.useConnection = useConnection;
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ const errors = require('@vue-solana/core/errors');
4
+ const vue = require('vue');
5
+
6
+ function useSubscription(source, options = {}) {
7
+ const data = vue.shallowRef(void 0);
8
+ const error = vue.shallowRef(null);
9
+ const status = vue.shallowRef("loading");
10
+ const disposables = [];
11
+ let connectionCount = 0;
12
+ let disposed = false;
13
+ let activeSource;
14
+ let activeStore;
15
+ function applyState(state) {
16
+ if (state.status === "loaded") {
17
+ data.value = state.data;
18
+ error.value = null;
19
+ status.value = "loaded";
20
+ } else if (state.status === "error") {
21
+ error.value = errors.normalizeSolanaError(state.error, "RPC_FAILURE");
22
+ status.value = "error";
23
+ options.onError?.(state.error);
24
+ } else if (state.status === "loading") {
25
+ status.value = data.value === void 0 ? "loading" : status.value;
26
+ } else if (state.status === "idle") {
27
+ data.value = void 0;
28
+ error.value = null;
29
+ status.value = "loading";
30
+ }
31
+ }
32
+ function openConnection(store) {
33
+ activeStore = store;
34
+ connectionCount += 1;
35
+ const connection = connectionCount;
36
+ const callerSignal = options.getAbortSignal?.(connection);
37
+ applyState(store.getState());
38
+ disposables.push(
39
+ store.subscribe(() => {
40
+ applyState(store.getState());
41
+ })
42
+ );
43
+ if (callerSignal?.aborted) {
44
+ applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
45
+ return;
46
+ }
47
+ if (callerSignal) {
48
+ store.withSignal(callerSignal).connect();
49
+ } else {
50
+ store.connect();
51
+ }
52
+ }
53
+ function disconnect() {
54
+ disposables.forEach((dispose) => {
55
+ dispose();
56
+ });
57
+ disposables.length = 0;
58
+ if (activeStore) {
59
+ activeStore.reset();
60
+ activeStore = void 0;
61
+ }
62
+ activeSource = void 0;
63
+ }
64
+ function connectCurrent() {
65
+ if (disposed) {
66
+ return;
67
+ }
68
+ const resolved = vue.isRef(source) ? source.value : source;
69
+ if (resolved === null || resolved === void 0) {
70
+ disconnect();
71
+ data.value = void 0;
72
+ error.value = null;
73
+ status.value = "disabled";
74
+ return;
75
+ }
76
+ if (activeSource === resolved && activeStore) {
77
+ openConnection(activeStore);
78
+ return;
79
+ }
80
+ disconnect();
81
+ activeSource = resolved;
82
+ openConnection(resolved.reactiveStore());
83
+ }
84
+ vue.watch(
85
+ () => vue.isRef(source) ? source.value : source,
86
+ () => {
87
+ connectCurrent();
88
+ },
89
+ { flush: "sync" }
90
+ );
91
+ vue.onMounted(() => {
92
+ connectCurrent();
93
+ });
94
+ if (!vue.getCurrentInstance()) {
95
+ connectCurrent();
96
+ }
97
+ vue.onScopeDispose(() => {
98
+ disposed = true;
99
+ disconnect();
100
+ });
101
+ return {
102
+ data: vue.computed(() => data.value),
103
+ error: vue.computed(() => error.value),
104
+ reconnect: () => {
105
+ connectCurrent();
106
+ },
107
+ status: vue.computed(() => status.value)
108
+ };
109
+ }
110
+
111
+ exports.useSubscription = useSubscription;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ const useSolanaClient = require('./vue.BIxphCAq.cjs');
4
+
5
+ class MissingClientCapabilityError extends Error {
6
+ /** Name of the hook that requested the capability, e.g. `usePayer`. */
7
+ hookName;
8
+ /** Human guidance for installing the capability on the client. */
9
+ providerHint;
10
+ /** The missing capability name(s). */
11
+ capabilities;
12
+ constructor(hookName, capabilities, providerHint) {
13
+ super(
14
+ `${hookName} requires the ${capabilities.map((capability) => `\`${capability}\``).join(" and ")} capabilit${capabilities.length === 1 ? "y" : "ies"} on the Solana client, but none ${capabilities.length === 1 ? "was" : "were"} found. ` + providerHint
15
+ );
16
+ this.name = "MissingClientCapabilityError";
17
+ this.hookName = hookName;
18
+ this.capabilities = capabilities;
19
+ this.providerHint = providerHint;
20
+ }
21
+ }
22
+ function useClientCapability(capability, options = {}) {
23
+ const capabilities = Array.isArray(capability) ? [...capability] : [capability];
24
+ const hookName = options.hookName ?? "useClientCapability";
25
+ const providerHint = options.providerHint ?? "Install it by adding the corresponding @solana/kit plugin with `createClient().use(...)`.";
26
+ const { client } = useSolanaClient.useSolanaClient();
27
+ for (const name of capabilities) {
28
+ if (typeof client[name] === "undefined") {
29
+ throw new MissingClientCapabilityError(hookName, [name], providerHint);
30
+ }
31
+ }
32
+ }
33
+
34
+ exports.MissingClientCapabilityError = MissingClientCapabilityError;
35
+ exports.useClientCapability = useClientCapability;
@@ -0,0 +1,10 @@
1
+ function decodeBase64(value) {
2
+ const binary = atob(value);
3
+ const bytes = new Uint8Array(binary.length);
4
+ for (let index = 0; index < binary.length; index += 1) {
5
+ bytes[index] = binary.charCodeAt(index);
6
+ }
7
+ return bytes;
8
+ }
9
+
10
+ export { decodeBase64 as d };
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ const action = require('@vue-solana/core/action');
4
+ const errors = require('@vue-solana/core/errors');
5
+ const timeout = require('@vue-solana/core/timeout');
6
+ const vue = require('vue');
7
+
8
+ const DEFAULT_TIMEOUT_MESSAGE = "Transaction did not return a result before timing out.";
9
+ function useTransaction(handler, options = {}) {
10
+ const signature = vue.shallowRef(null);
11
+ const loading = vue.ref(false);
12
+ const error = vue.ref(null);
13
+ const store = action.createSolanaActionStore(async (_signal, ...args) => {
14
+ const attempt = timeout.withSolanaTimeout(
15
+ handler(...args),
16
+ options.timeoutMs,
17
+ options.timeoutMessage ?? DEFAULT_TIMEOUT_MESSAGE
18
+ );
19
+ attempt.catch(() => void 0);
20
+ return attempt;
21
+ });
22
+ const unsubscribe = store.subscribe(() => {
23
+ const state = store.getState();
24
+ if (state.status === "running") {
25
+ loading.value = true;
26
+ } else if (state.status === "success") {
27
+ signature.value = state.data;
28
+ loading.value = false;
29
+ error.value = null;
30
+ } else if (state.status === "error") {
31
+ error.value = errors.normalizeSolanaError(state.error, "RPC_FAILURE");
32
+ loading.value = false;
33
+ }
34
+ });
35
+ if (vue.getCurrentScope()) {
36
+ vue.onScopeDispose(() => {
37
+ unsubscribe();
38
+ store.reset();
39
+ });
40
+ }
41
+ async function execute(...args) {
42
+ loading.value = true;
43
+ error.value = null;
44
+ try {
45
+ return await store.dispatchAsync(...args);
46
+ } catch (cause) {
47
+ if (action.isSolanaActionAborted(cause)) {
48
+ throw cause;
49
+ }
50
+ throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
51
+ }
52
+ }
53
+ return {
54
+ signature,
55
+ loading,
56
+ error,
57
+ execute
58
+ };
59
+ }
60
+
61
+ exports.useTransaction = useTransaction;
@@ -1,5 +1,5 @@
1
1
  import { computed } from 'vue';
2
- import { u as useSolana } from './vue.CYKT65tB.mjs';
2
+ import { u as useSolana } from './vue.CQh3AUE8.mjs';
3
3
 
4
4
  function useRpc() {
5
5
  const solana = useSolana();
@@ -11,7 +11,7 @@ function useRpc() {
11
11
  error: solana.error,
12
12
  latestBlockhash: solana.latestBlockhash,
13
13
  checkConnection: solana.checkConnection,
14
- connection: solana.connection
14
+ client: solana.client
15
15
  };
16
16
  }
17
17
 
@@ -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
10
  function useTokenAccounts(owner, options) {
11
11
  const solana = useSolana.tryUseSolana();
12
- const connection = solana?.connection ?? useConnection.useConnection();
12
+ const client = solana?.client ?? useConnection.useConnection();
13
13
  const tokenAccounts$1 = vue.shallowRef([]);
14
14
  const loading = vue.shallowRef(false);
15
15
  const error = vue.shallowRef(null);
@@ -26,17 +26,16 @@ function useTokenAccounts(owner, options) {
26
26
  loading.value = true;
27
27
  error.value = null;
28
28
  try {
29
- const publicKey = address.parsePublicKey(value);
30
- if (!publicKey) {
29
+ const parsedAddress = address.parseAddress(value);
30
+ if (!parsedAddress) {
31
31
  tokenAccounts$1.value = [];
32
32
  loading.value = false;
33
33
  return [];
34
34
  }
35
- const opts = {
35
+ const nextAccounts = await tokenAccounts.getTokenAccountsByOwner(client, parsedAddress, {
36
36
  commitment: options?.commitment,
37
37
  programId: options?.programId
38
- };
39
- const nextAccounts = await tokenAccounts.getTokenAccountsByOwner(connection, publicKey, opts);
38
+ });
40
39
  if (requestId === refreshId) {
41
40
  tokenAccounts$1.value = nextAccounts;
42
41
  }