@vue-solana/vue 2.6.1 → 3.0.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 (188) hide show
  1. package/README.md +6 -4
  2. package/dist/index.d.mts +3 -1
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.mjs +36 -47
  5. package/dist/shared/vue.1Qwco2kv.mjs +33 -0
  6. package/dist/shared/vue.BFSboXMB.mjs +17 -0
  7. package/dist/shared/vue.BGGixph-.d.mts +5 -0
  8. package/dist/shared/vue.BGGixph-.d.ts +5 -0
  9. package/dist/shared/{vue.CbJFnho-.mjs → vue.BNJTXSnQ.mjs} +17 -70
  10. package/dist/shared/{vue.BINkrA8h.mjs → vue.BwBqla_n.mjs} +16 -26
  11. package/dist/shared/vue.BxtOHzY_.mjs +27 -0
  12. package/dist/shared/vue.C1JbUTpJ.mjs +66 -0
  13. package/dist/shared/vue.C9OOmvkD.mjs +36 -0
  14. package/dist/shared/vue.CGv0ip3w.mjs +52 -0
  15. package/dist/shared/vue.CaAgH2Xt.mjs +51 -0
  16. package/dist/shared/{vue.Dyi1OCI1.mjs → vue.CjSw0Hh1.mjs} +3 -9
  17. package/dist/shared/vue.CsFY1mfz.mjs +29 -0
  18. package/dist/shared/vue.CvenSbZZ.mjs +27 -0
  19. package/dist/shared/{vue.BDNOyiGZ.mjs → vue.D5pqR5Fa.mjs} +9 -12
  20. package/dist/shared/vue.DNKD6jqM.mjs +22 -0
  21. package/dist/shared/vue.DlihC5GG.mjs +38 -0
  22. package/dist/shared/vue.XlfH_nkc.mjs +32 -0
  23. package/dist/shared/vue.hG_FieA3.mjs +37 -0
  24. package/dist/shared/vue.o98pAmDg.mjs +40 -0
  25. package/dist/swr.mjs +22 -76
  26. package/dist/useAccountInfo.d.mts +4 -4
  27. package/dist/useAccountInfo.d.ts +4 -4
  28. package/dist/useAccountInfo.mjs +5 -4
  29. package/dist/useBalance.d.mts +4 -4
  30. package/dist/useBalance.d.ts +4 -4
  31. package/dist/useBalance.mjs +5 -4
  32. package/dist/usePlanTransaction.d.mts +12 -13
  33. package/dist/usePlanTransaction.d.ts +12 -13
  34. package/dist/usePlanTransaction.mjs +2 -1
  35. package/dist/usePlanTransactions.d.mts +2 -1
  36. package/dist/usePlanTransactions.d.ts +2 -1
  37. package/dist/usePlanTransactions.mjs +2 -1
  38. package/dist/useProgramAccounts.d.mts +5 -15
  39. package/dist/useProgramAccounts.d.ts +5 -15
  40. package/dist/useProgramAccounts.mjs +5 -4
  41. package/dist/useSendTransaction.d.mts +11 -12
  42. package/dist/useSendTransaction.d.ts +11 -12
  43. package/dist/useSendTransaction.mjs +2 -1
  44. package/dist/useSendTransactions.d.mts +2 -1
  45. package/dist/useSendTransactions.d.ts +2 -1
  46. package/dist/useSendTransactions.mjs +2 -1
  47. package/dist/useSignAndSendTransaction.d.mts +1 -1
  48. package/dist/useSignAndSendTransaction.d.ts +1 -1
  49. package/dist/useSignAndSendTransaction.mjs +3 -2
  50. package/dist/useSignAndSendTransactions.d.mts +2 -2
  51. package/dist/useSignAndSendTransactions.d.ts +2 -2
  52. package/dist/useSignAndSendTransactions.mjs +2 -1
  53. package/dist/useSignIn.d.mts +4 -4
  54. package/dist/useSignIn.d.ts +4 -4
  55. package/dist/useSignIn.mjs +3 -2
  56. package/dist/useSignMessage.d.mts +4 -4
  57. package/dist/useSignMessage.d.ts +4 -4
  58. package/dist/useSignMessage.mjs +3 -2
  59. package/dist/useSignTransactions.d.mts +4 -4
  60. package/dist/useSignTransactions.d.ts +4 -4
  61. package/dist/useSignTransactions.mjs +3 -2
  62. package/dist/useSubscription.mjs +1 -1
  63. package/dist/useTokenAccounts.d.mts +4 -4
  64. package/dist/useTokenAccounts.d.ts +4 -4
  65. package/dist/useTokenAccounts.mjs +5 -4
  66. package/dist/useTokenBalance.d.mts +9 -7
  67. package/dist/useTokenBalance.d.ts +9 -7
  68. package/dist/useTokenBalance.mjs +4 -3
  69. package/dist/useTrackedData.mjs +1 -1
  70. package/dist/useTransactionConfirmation.d.mts +4 -4
  71. package/dist/useTransactionConfirmation.d.ts +4 -4
  72. package/dist/useTransactionConfirmation.mjs +3 -2
  73. package/package.json +38 -75
  74. package/dist/buffer-polyfill.cjs +0 -8
  75. package/dist/buffer-polyfill.d.cts +0 -2
  76. package/dist/index.cjs +0 -452
  77. package/dist/index.d.cts +0 -62
  78. package/dist/kit.cjs +0 -16
  79. package/dist/kit.d.cts +0 -1
  80. package/dist/shared/vue.4C5kX4fE.cjs +0 -36
  81. package/dist/shared/vue.9TPxZPMf.cjs +0 -59
  82. package/dist/shared/vue.B4eMoJT2.cjs +0 -36
  83. package/dist/shared/vue.B6ainw2G.cjs +0 -63
  84. package/dist/shared/vue.BD6Gm1nl.mjs +0 -74
  85. package/dist/shared/vue.BGxz4dru.cjs +0 -98
  86. package/dist/shared/vue.BIxphCAq.cjs +0 -10
  87. package/dist/shared/vue.BOpgWr43.mjs +0 -70
  88. package/dist/shared/vue.BQRpjwKl.mjs +0 -80
  89. package/dist/shared/vue.BVaMoz9y.cjs +0 -9
  90. package/dist/shared/vue.Bk5xjlUx.cjs +0 -61
  91. package/dist/shared/vue.Bwd1sGAM.cjs +0 -72
  92. package/dist/shared/vue.ByxbBC3y.mjs +0 -57
  93. package/dist/shared/vue.C13umiQi.mjs +0 -85
  94. package/dist/shared/vue.CIs8QhCw.cjs +0 -132
  95. package/dist/shared/vue.CMohL_Cz.mjs +0 -58
  96. package/dist/shared/vue.CWZSMVnB.cjs +0 -84
  97. package/dist/shared/vue.Co5rj-I6.mjs +0 -118
  98. package/dist/shared/vue.CoaIWGPT.cjs +0 -38
  99. package/dist/shared/vue.CrkK_T15.cjs +0 -86
  100. package/dist/shared/vue.D-qi8PSL.cjs +0 -82
  101. package/dist/shared/vue.D3Y0PWbF.mjs +0 -71
  102. package/dist/shared/vue.D5U1yLG3.mjs +0 -83
  103. package/dist/shared/vue.DAg5wC1G.cjs +0 -76
  104. package/dist/shared/vue.DAthhH4D.mjs +0 -118
  105. package/dist/shared/vue.DDbVk0Zh.cjs +0 -180
  106. package/dist/shared/vue.DE3emjSF.cjs +0 -48
  107. package/dist/shared/vue.DEHxNvUX.cjs +0 -7
  108. package/dist/shared/vue.DFaMJLAQ.cjs +0 -60
  109. package/dist/shared/vue.DKoM8jIV.cjs +0 -121
  110. package/dist/shared/vue.DKyQ7J67.cjs +0 -15
  111. package/dist/shared/vue.DL3z5PxP.d.cts +0 -21
  112. package/dist/shared/vue.DNxOpDXz.cjs +0 -12
  113. package/dist/shared/vue.Di7yjJ-R.cjs +0 -87
  114. package/dist/shared/vue.Dn3KLJZH.cjs +0 -121
  115. package/dist/shared/vue.DxM45azl.cjs +0 -173
  116. package/dist/shared/vue.E_npPFoV.cjs +0 -67
  117. package/dist/shared/vue.FiMmnMHr.cjs +0 -20
  118. package/dist/shared/vue.JUWqu6kD.mjs +0 -61
  119. package/dist/shared/vue.Sbbm9JSu.cjs +0 -74
  120. package/dist/shared/vue.ZuUCEEab.cjs +0 -103
  121. package/dist/shared/vue.l3UCdN7z.cjs +0 -111
  122. package/dist/shared/vue.ldvmk9NM.cjs +0 -45
  123. package/dist/swr.cjs +0 -136
  124. package/dist/swr.d.cts +0 -41
  125. package/dist/useAccountInfo.cjs +0 -15
  126. package/dist/useAccountInfo.d.cts +0 -24
  127. package/dist/useAction.cjs +0 -9
  128. package/dist/useAction.d.cts +0 -45
  129. package/dist/useAirdrop.cjs +0 -14
  130. package/dist/useAirdrop.d.cts +0 -27
  131. package/dist/useBalance.cjs +0 -14
  132. package/dist/useBalance.d.cts +0 -15
  133. package/dist/useClientCapability.cjs +0 -12
  134. package/dist/useClientCapability.d.cts +0 -39
  135. package/dist/useConnection.cjs +0 -11
  136. package/dist/useConnection.d.cts +0 -46
  137. package/dist/useIdentity.cjs +0 -12
  138. package/dist/useIdentity.d.cts +0 -3
  139. package/dist/usePayer.cjs +0 -13
  140. package/dist/usePayer.d.cts +0 -18
  141. package/dist/usePlanTransaction.cjs +0 -14
  142. package/dist/usePlanTransaction.d.cts +0 -45
  143. package/dist/usePlanTransactions.cjs +0 -13
  144. package/dist/usePlanTransactions.d.cts +0 -4
  145. package/dist/useProgramAccounts.cjs +0 -15
  146. package/dist/useProgramAccounts.d.cts +0 -55
  147. package/dist/useRequest.cjs +0 -11
  148. package/dist/useRequest.d.cts +0 -73
  149. package/dist/useRpc.cjs +0 -10
  150. package/dist/useRpc.d.cts +0 -55
  151. package/dist/useSelectedWalletAccount.cjs +0 -13
  152. package/dist/useSelectedWalletAccount.d.cts +0 -117
  153. package/dist/useSendTransaction.cjs +0 -14
  154. package/dist/useSendTransaction.d.cts +0 -51
  155. package/dist/useSendTransactions.cjs +0 -13
  156. package/dist/useSendTransactions.d.cts +0 -4
  157. package/dist/useSignAndSendTransaction.cjs +0 -18
  158. package/dist/useSignAndSendTransaction.d.cts +0 -40
  159. package/dist/useSignAndSendTransactions.cjs +0 -15
  160. package/dist/useSignAndSendTransactions.d.cts +0 -35
  161. package/dist/useSignIn.cjs +0 -13
  162. package/dist/useSignIn.d.cts +0 -23
  163. package/dist/useSignMessage.cjs +0 -13
  164. package/dist/useSignMessage.d.cts +0 -236
  165. package/dist/useSignTransactions.cjs +0 -13
  166. package/dist/useSignTransactions.d.cts +0 -24
  167. package/dist/useSignatureStatus.cjs +0 -14
  168. package/dist/useSignatureStatus.d.cts +0 -26
  169. package/dist/useSolana.cjs +0 -10
  170. package/dist/useSolana.d.cts +0 -9
  171. package/dist/useSolanaClient.cjs +0 -10
  172. package/dist/useSolanaClient.d.cts +0 -45
  173. package/dist/useSubscription.cjs +0 -9
  174. package/dist/useSubscription.d.cts +0 -70
  175. package/dist/useTokenAccounts.cjs +0 -15
  176. package/dist/useTokenAccounts.d.cts +0 -19
  177. package/dist/useTokenBalance.cjs +0 -15
  178. package/dist/useTokenBalance.d.cts +0 -15
  179. package/dist/useTrackedData.cjs +0 -10
  180. package/dist/useTrackedData.d.cts +0 -98
  181. package/dist/useTransaction.cjs +0 -11
  182. package/dist/useTransaction.d.cts +0 -27
  183. package/dist/useTransactionConfirmation.cjs +0 -15
  184. package/dist/useTransactionConfirmation.d.cts +0 -38
  185. package/dist/useWallet.cjs +0 -12
  186. package/dist/useWallet.d.cts +0 -31
  187. package/dist/useWallets.cjs +0 -10
  188. package/dist/useWallets.d.cts +0 -11
@@ -0,0 +1,51 @@
1
+ import { confirmTransactionSignature } from '@vue-solana/core/transaction';
2
+ import { ref } from 'vue';
3
+ import { u as useExecution } from './vue.DlihC5GG.mjs';
4
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
5
+
6
+ function getConfirmedTransactionStatus(confirmation) {
7
+ if (confirmation.commitment === "finalized") {
8
+ return "finalized";
9
+ }
10
+ return confirmation.commitment === "processed" ? "processed" : "confirmed";
11
+ }
12
+ function useTransactionConfirmation(defaultOptions = {}) {
13
+ const client = useConnection();
14
+ const signature = ref(null);
15
+ const confirmation = ref(null);
16
+ const {
17
+ status,
18
+ loading,
19
+ error,
20
+ execute,
21
+ reset: resetExecution
22
+ } = useExecution("confirming");
23
+ function confirm(nextSignature, options = {}) {
24
+ const confirmationOptions = { ...defaultOptions, ...options };
25
+ signature.value = nextSignature;
26
+ confirmation.value = null;
27
+ return execute(
28
+ () => confirmTransactionSignature(client, nextSignature, confirmationOptions),
29
+ (nextConfirmation) => {
30
+ confirmation.value = nextConfirmation;
31
+ return getConfirmedTransactionStatus(nextConfirmation);
32
+ }
33
+ );
34
+ }
35
+ function reset() {
36
+ resetExecution();
37
+ signature.value = null;
38
+ confirmation.value = null;
39
+ }
40
+ return {
41
+ signature,
42
+ confirmation,
43
+ status,
44
+ loading,
45
+ error,
46
+ confirm,
47
+ reset
48
+ };
49
+ }
50
+
51
+ export { getConfirmedTransactionStatus as g, useTransactionConfirmation as u };
@@ -2,10 +2,10 @@ import { normalizeSolanaError } from '@vue-solana/core/errors';
2
2
  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
- import { ref } from 'vue';
5
+ import { ref, computed } from 'vue';
6
6
  import { u as useConnection } from './vue.CpkwC8Th.mjs';
7
7
  import { u as useWallet } from './vue.D218Ow7t.mjs';
8
- import { g as getConfirmedTransactionStatus } from './vue.D3Y0PWbF.mjs';
8
+ import { g as getConfirmedTransactionStatus } from './vue.CaAgH2Xt.mjs';
9
9
 
10
10
  const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
11
11
  function useSignAndSendTransaction() {
@@ -14,7 +14,7 @@ function useSignAndSendTransaction() {
14
14
  const signature = ref(null);
15
15
  const confirmation = ref(null);
16
16
  const status = ref("idle");
17
- const loading = ref(false);
17
+ const loading = computed(() => status.value === "sending" || status.value === "confirming");
18
18
  const error = ref(null);
19
19
  let executionId = 0;
20
20
  async function execute(transaction, options) {
@@ -22,7 +22,6 @@ function useSignAndSendTransaction() {
22
22
  const { confirm, confirmation: confirmationOptions, ...sendOptions } = options ?? {};
23
23
  const transactionOptions = Object.keys(sendOptions).length > 0 ? sendOptions : void 0;
24
24
  status.value = "sending";
25
- loading.value = true;
26
25
  error.value = null;
27
26
  confirmation.value = null;
28
27
  const activeWallet = wallet.value;
@@ -30,7 +29,6 @@ function useSignAndSendTransaction() {
30
29
  const normalizedError = createNoWalletSelectedError();
31
30
  error.value = normalizedError;
32
31
  status.value = "error";
33
- loading.value = false;
34
32
  throw normalizedError;
35
33
  }
36
34
  try {
@@ -63,10 +61,6 @@ function useSignAndSendTransaction() {
63
61
  status.value = "error";
64
62
  }
65
63
  throw normalizedError;
66
- } finally {
67
- if (currentExecutionId === executionId) {
68
- loading.value = false;
69
- }
70
64
  }
71
65
  }
72
66
  return {
@@ -0,0 +1,29 @@
1
+ import { u as useClientAction } from './vue.CGv0ip3w.mjs';
2
+
3
+ const PLANNING_PROVIDER_HINT = "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`, and plan with a client that has a `payer` signer \u2014 Kit reads `client.payer` to set the fee payer.";
4
+ const PLAN_STATUSES = {
5
+ error: "error",
6
+ idle: "idle",
7
+ success: "planned",
8
+ working: "planning"
9
+ };
10
+ function usePlanTransaction() {
11
+ const { data: transactionMessage, ...rest } = useClientAction({
12
+ capability: "planTransaction",
13
+ hookName: "usePlanTransaction",
14
+ providerHint: PLANNING_PROVIDER_HINT,
15
+ statuses: PLAN_STATUSES
16
+ });
17
+ return { transactionMessage, ...rest };
18
+ }
19
+ function usePlanTransactions() {
20
+ const { data: transactionPlan, ...rest } = useClientAction({
21
+ capability: "planTransactions",
22
+ hookName: "usePlanTransactions",
23
+ providerHint: PLANNING_PROVIDER_HINT,
24
+ statuses: PLAN_STATUSES
25
+ });
26
+ return { transactionPlan, ...rest };
27
+ }
28
+
29
+ export { usePlanTransactions as a, usePlanTransaction as u };
@@ -0,0 +1,27 @@
1
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
2
+ import { u as useAddressRead } from './vue.BwBqla_n.mjs';
3
+ import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
4
+ import { d as decodeBase64 } from './vue.Bfu1dCKe.mjs';
5
+
6
+ function useAccountInfo(address, options = {}) {
7
+ const solana = tryUseSolana();
8
+ const client = solana?.client ?? useConnection();
9
+ const { data: accountInfo, ...rest } = useAddressRead(
10
+ [address],
11
+ async (key) => (await client.rpc.getAccountInfo(key, { encoding: "base64", commitment: options.commitment }).send()).value,
12
+ (account) => account ? normalizeAccountInfo(account) : null,
13
+ null
14
+ );
15
+ return { accountInfo, ...rest };
16
+ }
17
+ function normalizeAccountInfo(account) {
18
+ return {
19
+ executable: account.executable,
20
+ lamports: Number(account.lamports),
21
+ owner: account.owner,
22
+ space: Number(account.space),
23
+ data: decodeBase64(account.data[0])
24
+ };
25
+ }
26
+
27
+ export { useAccountInfo as u };
@@ -5,7 +5,7 @@ function useSubscription(source, options = {}) {
5
5
  const data = shallowRef(void 0);
6
6
  const error = shallowRef(null);
7
7
  const status = shallowRef("loading");
8
- const disposables = [];
8
+ let disposeActive;
9
9
  let connectionCount = 0;
10
10
  let disposed = false;
11
11
  let activeSource;
@@ -19,8 +19,8 @@ function useSubscription(source, options = {}) {
19
19
  error.value = normalizeSolanaError(state.error, "RPC_FAILURE");
20
20
  status.value = "error";
21
21
  options.onError?.(state.error);
22
- } else if (state.status === "loading") {
23
- status.value = data.value === void 0 ? "loading" : status.value;
22
+ } else if (state.status === "loading" && data.value === void 0) {
23
+ status.value = "loading";
24
24
  } else if (state.status === "idle") {
25
25
  data.value = void 0;
26
26
  error.value = null;
@@ -33,11 +33,10 @@ function useSubscription(source, options = {}) {
33
33
  const connection = connectionCount;
34
34
  const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(connection);
35
35
  applyState(store.getState());
36
- disposables.push(
37
- store.subscribe(() => {
38
- applyState(store.getState());
39
- })
40
- );
36
+ disposeActive?.();
37
+ disposeActive = store.subscribe(() => {
38
+ applyState(store.getState());
39
+ });
41
40
  if (callerSignal?.aborted) {
42
41
  applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
43
42
  return;
@@ -49,10 +48,8 @@ function useSubscription(source, options = {}) {
49
48
  }
50
49
  }
51
50
  function disconnect() {
52
- disposables.forEach((dispose) => {
53
- dispose();
54
- });
55
- disposables.length = 0;
51
+ disposeActive?.();
52
+ disposeActive = void 0;
56
53
  if (activeStore) {
57
54
  activeStore.reset();
58
55
  activeStore = void 0;
@@ -0,0 +1,22 @@
1
+ import { getTokenAccountsByOwner } from '@vue-solana/core/token-accounts';
2
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
3
+ import { u as useAddressRead } from './vue.BwBqla_n.mjs';
4
+ import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
5
+
6
+ function useTokenAccounts(owner, options) {
7
+ const empty = [];
8
+ const solana = tryUseSolana();
9
+ const client = solana?.client ?? useConnection();
10
+ const { data: tokenAccounts, ...rest } = useAddressRead(
11
+ [owner],
12
+ (key) => getTokenAccountsByOwner(client, key, {
13
+ commitment: options?.commitment,
14
+ programId: options?.programId
15
+ }),
16
+ (accounts) => accounts,
17
+ empty
18
+ );
19
+ return { tokenAccounts, ...rest };
20
+ }
21
+
22
+ export { useTokenAccounts as u };
@@ -0,0 +1,38 @@
1
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
2
+ import { shallowRef, onScopeDispose, computed } from 'vue';
3
+
4
+ function useExecution(busy) {
5
+ const status = shallowRef("idle");
6
+ const error = shallowRef(null);
7
+ let id = 0;
8
+ async function execute(run, settled) {
9
+ const currentId = ++id;
10
+ status.value = busy;
11
+ error.value = null;
12
+ try {
13
+ const result = await run();
14
+ if (currentId === id) {
15
+ status.value = settled(result);
16
+ }
17
+ return result;
18
+ } catch (cause) {
19
+ const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
20
+ if (currentId === id) {
21
+ error.value = normalizedError;
22
+ status.value = "error";
23
+ }
24
+ throw normalizedError;
25
+ }
26
+ }
27
+ function reset() {
28
+ id += 1;
29
+ status.value = "idle";
30
+ error.value = null;
31
+ }
32
+ onScopeDispose(() => {
33
+ id += 1;
34
+ });
35
+ return { status, error, loading: computed(() => status.value === busy), execute, reset };
36
+ }
37
+
38
+ export { useExecution as u };
@@ -0,0 +1,32 @@
1
+ import { getTokenBalance } from '@vue-solana/core/token-accounts';
2
+ import { computed } from 'vue';
3
+ import { u as useConnection } from './vue.CpkwC8Th.mjs';
4
+ import { u as useAddressRead } from './vue.BwBqla_n.mjs';
5
+ import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
6
+
7
+ function useTokenBalance(mint, owner, commitment) {
8
+ const empty = {
9
+ balance: null,
10
+ decimals: null
11
+ };
12
+ const solana = tryUseSolana();
13
+ const client = solana?.client ?? useConnection();
14
+ const read = useAddressRead(
15
+ [mint, owner],
16
+ (mintKey, ownerKey) => getTokenBalance(client, mintKey, ownerKey, commitment),
17
+ (result) => ({
18
+ balance: result?.amount ?? null,
19
+ decimals: result?.decimals ?? null
20
+ }),
21
+ empty
22
+ );
23
+ return {
24
+ balance: computed(() => read.data.value.balance),
25
+ decimals: computed(() => read.data.value.decimals),
26
+ loading: read.loading,
27
+ error: read.error,
28
+ refresh: read.refresh
29
+ };
30
+ }
31
+
32
+ export { useTokenBalance as u };
@@ -0,0 +1,37 @@
1
+ import { createNoWalletSelectedError, assertWalletCanSignTransactions } from '@vue-solana/core/wallet';
2
+ import { shallowRef } from 'vue';
3
+ import { u as useExecution } from './vue.DlihC5GG.mjs';
4
+ import { u as useWallet } from './vue.D218Ow7t.mjs';
5
+
6
+ function useSignTransactions() {
7
+ const { wallet } = useWallet();
8
+ const signedTransactions = shallowRef(null);
9
+ const { status, loading, error, execute } = useExecution("signing");
10
+ function sign(transactions) {
11
+ signedTransactions.value = null;
12
+ return execute(
13
+ async () => {
14
+ const activeWallet = wallet.value;
15
+ if (!activeWallet) {
16
+ throw createNoWalletSelectedError();
17
+ }
18
+ assertWalletCanSignTransactions(activeWallet);
19
+ const sign2 = activeWallet.signTransactions ? activeWallet.signTransactions.bind(activeWallet) : activeWallet.signAllTransactions.bind(activeWallet);
20
+ return sign2([...transactions]);
21
+ },
22
+ (result) => {
23
+ signedTransactions.value = result;
24
+ return "signed";
25
+ }
26
+ );
27
+ }
28
+ return {
29
+ signedTransactions,
30
+ status,
31
+ loading,
32
+ error,
33
+ execute: sign
34
+ };
35
+ }
36
+
37
+ export { useSignTransactions as u };
@@ -0,0 +1,40 @@
1
+ import { createNoWalletSelectedError, assertWalletCanSignMessage } from '@vue-solana/core/wallet';
2
+ import { ref } from 'vue';
3
+ import { u as useExecution } from './vue.DlihC5GG.mjs';
4
+ import { u as useWallet } from './vue.D218Ow7t.mjs';
5
+
6
+ function useSignMessage() {
7
+ const { wallet } = useWallet();
8
+ const signedMessage = ref(null);
9
+ const signature = ref(null);
10
+ const { status, loading, error, execute } = useExecution("signing");
11
+ function sign(message) {
12
+ signedMessage.value = null;
13
+ signature.value = null;
14
+ return execute(
15
+ async () => {
16
+ const activeWallet = wallet.value;
17
+ if (!activeWallet) {
18
+ throw createNoWalletSelectedError();
19
+ }
20
+ assertWalletCanSignMessage(activeWallet);
21
+ return activeWallet.signMessage(message);
22
+ },
23
+ (result) => {
24
+ signedMessage.value = result.signedMessage;
25
+ signature.value = result.signature;
26
+ return "signed";
27
+ }
28
+ );
29
+ }
30
+ return {
31
+ signedMessage,
32
+ signature,
33
+ status,
34
+ loading,
35
+ error,
36
+ execute: sign
37
+ };
38
+ }
39
+
40
+ export { useSignMessage as u };
package/dist/swr.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { watch, computed } from 'vue';
2
2
  import { u as useRequest } from './shared/vue.B8VvC8d2.mjs';
3
- import { u as useSubscription } from './shared/vue.BDNOyiGZ.mjs';
4
- import { u as useTrackedData } from './shared/vue.CbJFnho-.mjs';
3
+ import { u as useSubscription } from './shared/vue.D5pqR5Fa.mjs';
4
+ import { u as useTrackedData } from './shared/vue.BNJTXSnQ.mjs';
5
5
  import '@vue-solana/core/action';
6
6
  import '@vue-solana/core/kit';
7
7
  import '@vue-solana/core/errors';
@@ -13,25 +13,16 @@ const swrCache = /* @__PURE__ */ new Map();
13
13
  function clearSwrCache() {
14
14
  swrCache.clear();
15
15
  }
16
- function readSwrCache(key) {
17
- return swrCache.get(key);
18
- }
19
- function writeSwrCache(key, entry) {
20
- swrCache.set(key, entry);
21
- }
22
- function deleteSwrCache(key) {
23
- swrCache.delete(key);
24
- }
25
16
  function isPendingStatus(status) {
26
17
  return status === "fetching" || status === "loading";
27
18
  }
28
19
  function writeSwrResult(key, data, error, status) {
29
20
  if (status === "disabled") {
30
- deleteSwrCache(key);
21
+ swrCache.delete(key);
31
22
  return;
32
23
  }
33
- const previous = readSwrCache(key);
34
- writeSwrCache(key, {
24
+ const previous = swrCache.get(key);
25
+ swrCache.set(key, {
35
26
  data: data !== void 0 ? data : previous?.data,
36
27
  error,
37
28
  status
@@ -43,16 +34,15 @@ function swrError(error, status, seed) {
43
34
  }
44
35
  return error ?? (isPendingStatus(status) ? seed?.error ?? null : null);
45
36
  }
46
- function useRequestSwr(key, source, options = {}) {
47
- const cacheKey = `${PREFIX_REQUEST}${key}`;
48
- const seed = readSwrCache(cacheKey);
49
- const result = useRequest(source, options);
37
+ function useSwrKeyed(prefix, key, result) {
38
+ const cacheKey = `${prefix}${key}`;
39
+ const seed = swrCache.get(cacheKey);
50
40
  if (result.status.value === "disabled") {
51
- deleteSwrCache(cacheKey);
41
+ swrCache.delete(cacheKey);
52
42
  }
53
43
  watch(
54
44
  [result.data, result.error, result.status],
55
- ([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
45
+ ([data2, error, status]) => writeSwrResult(cacheKey, data2, error, status),
56
46
  { flush: "sync" }
57
47
  );
58
48
  const data = computed(() => {
@@ -61,71 +51,27 @@ function useRequestSwr(key, source, options = {}) {
61
51
  }
62
52
  return result.data.value !== void 0 ? result.data.value : seed?.data;
63
53
  });
64
- const error = computed(
65
- () => swrError(result.error.value, result.status.value, seed)
66
- );
67
54
  return {
68
55
  data,
69
- error,
70
- refresh: result.refresh,
71
- status: result.status
56
+ error: computed(
57
+ () => swrError(result.error.value, result.status.value, seed)
58
+ )
72
59
  };
73
60
  }
61
+ function useRequestSwr(key, source, options = {}) {
62
+ const result = useRequest(source, options);
63
+ const swr = useSwrKeyed(PREFIX_REQUEST, key, result);
64
+ return { ...swr, refresh: result.refresh, status: result.status };
65
+ }
74
66
  function useSubscriptionSwr(key, source, options = {}) {
75
- const cacheKey = `${PREFIX_SUBSCRIPTION}${key}`;
76
- const seed = readSwrCache(cacheKey);
77
67
  const result = useSubscription(source, options);
78
- if (result.status.value === "disabled") {
79
- deleteSwrCache(cacheKey);
80
- }
81
- watch(
82
- [result.data, result.error, result.status],
83
- ([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
84
- { flush: "sync" }
85
- );
86
- const data = computed(() => {
87
- if (result.status.value === "disabled") {
88
- return void 0;
89
- }
90
- return result.data.value !== void 0 ? result.data.value : seed?.data;
91
- });
92
- const error = computed(
93
- () => swrError(result.error.value, result.status.value, seed)
94
- );
95
- return {
96
- data,
97
- error,
98
- reconnect: result.reconnect,
99
- status: result.status
100
- };
68
+ const swr = useSwrKeyed(PREFIX_SUBSCRIPTION, key, result);
69
+ return { ...swr, reconnect: result.reconnect, status: result.status };
101
70
  }
102
71
  function useTrackedDataSwr(key, source, options = {}) {
103
- const cacheKey = `${PREFIX_TRACKED}${key}`;
104
- const seed = readSwrCache(cacheKey);
105
72
  const result = useTrackedData(source, options);
106
- if (result.status.value === "disabled") {
107
- deleteSwrCache(cacheKey);
108
- }
109
- watch(
110
- [result.data, result.error, result.status],
111
- ([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
112
- { flush: "sync" }
113
- );
114
- const data = computed(() => {
115
- if (result.status.value === "disabled") {
116
- return void 0;
117
- }
118
- return result.data.value ?? seed?.data;
119
- });
120
- const error = computed(
121
- () => swrError(result.error.value, result.status.value, seed)
122
- );
123
- return {
124
- data,
125
- error,
126
- refresh: result.refresh,
127
- status: result.status
128
- };
73
+ const swr = useSwrKeyed(PREFIX_TRACKED, key, result);
74
+ return { ...swr, refresh: result.refresh, status: result.status };
129
75
  }
130
76
 
131
77
  export { clearSwrCache, useRequestSwr, useSubscriptionSwr, useTrackedDataSwr };
@@ -1,7 +1,7 @@
1
1
  import * as vue from 'vue';
2
2
  import { MaybeRefOrGetter } from 'vue';
3
+ import * as _vue_solana_core_errors from '@vue-solana/core/errors';
3
4
  import { Commitment } from '@vue-solana/core/kit';
4
- import { SolanaError } from '@vue-solana/core/errors';
5
5
 
6
6
  interface UseAccountInfoOptions {
7
7
  commitment?: Commitment;
@@ -14,10 +14,10 @@ interface AccountInfo {
14
14
  data: Uint8Array;
15
15
  }
16
16
  declare function useAccountInfo(address: MaybeRefOrGetter<string | null | undefined>, options?: UseAccountInfoOptions): {
17
- accountInfo: vue.ShallowRef<AccountInfo | null, AccountInfo | null>;
18
- loading: vue.ShallowRef<boolean, boolean>;
19
- error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
17
+ error: vue.ShallowRef<_vue_solana_core_errors.SolanaError | null>;
18
+ loading: vue.ShallowRef<boolean>;
20
19
  refresh: () => Promise<AccountInfo | null>;
20
+ accountInfo: vue.ShallowRef<AccountInfo | null>;
21
21
  };
22
22
 
23
23
  export { useAccountInfo };
@@ -1,7 +1,7 @@
1
1
  import * as vue from 'vue';
2
2
  import { MaybeRefOrGetter } from 'vue';
3
+ import * as _vue_solana_core_errors from '@vue-solana/core/errors';
3
4
  import { Commitment } from '@vue-solana/core/kit';
4
- import { SolanaError } from '@vue-solana/core/errors';
5
5
 
6
6
  interface UseAccountInfoOptions {
7
7
  commitment?: Commitment;
@@ -14,10 +14,10 @@ interface AccountInfo {
14
14
  data: Uint8Array;
15
15
  }
16
16
  declare function useAccountInfo(address: MaybeRefOrGetter<string | null | undefined>, options?: UseAccountInfoOptions): {
17
- accountInfo: vue.ShallowRef<AccountInfo | null, AccountInfo | null>;
18
- loading: vue.ShallowRef<boolean, boolean>;
19
- error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
17
+ error: vue.ShallowRef<_vue_solana_core_errors.SolanaError | null>;
18
+ loading: vue.ShallowRef<boolean>;
20
19
  refresh: () => Promise<AccountInfo | null>;
20
+ accountInfo: vue.ShallowRef<AccountInfo | null>;
21
21
  };
22
22
 
23
23
  export { useAccountInfo };
@@ -1,9 +1,10 @@
1
- export { u as useAccountInfo } from './shared/vue.BQRpjwKl.mjs';
2
- import '@vue-solana/core/errors';
3
- import 'vue';
4
- import '@vue-solana/core/address';
1
+ export { u as useAccountInfo } from './shared/vue.CvenSbZZ.mjs';
5
2
  import './shared/vue.CpkwC8Th.mjs';
6
3
  import './shared/vue.Mxc8w6Qk.mjs';
7
4
  import './shared/vue.CQh3AUE8.mjs';
5
+ import 'vue';
8
6
  import './shared/vue.D_P5SqqD.mjs';
7
+ import './shared/vue.BwBqla_n.mjs';
8
+ import '@vue-solana/core/address';
9
+ import '@vue-solana/core/errors';
9
10
  import './shared/vue.Bfu1dCKe.mjs';
@@ -1,14 +1,14 @@
1
1
  import * as vue from 'vue';
2
2
  import { MaybeRefOrGetter } from 'vue';
3
+ import * as _vue_solana_core_errors from '@vue-solana/core/errors';
3
4
  import { Commitment } from '@vue-solana/core/kit';
4
- import { SolanaError } from '@vue-solana/core/errors';
5
5
 
6
6
  type BalanceInput = string | null | undefined;
7
7
  declare function useBalance(address: MaybeRefOrGetter<BalanceInput>, commitment?: Commitment): {
8
- balance: vue.ShallowRef<number | null, number | null>;
9
- loading: vue.ShallowRef<boolean, boolean>;
10
- error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
8
+ error: vue.ShallowRef<_vue_solana_core_errors.SolanaError | null>;
9
+ loading: vue.ShallowRef<boolean>;
11
10
  refresh: () => Promise<number | null>;
11
+ balance: vue.ShallowRef<number | null>;
12
12
  };
13
13
 
14
14
  export { useBalance };
@@ -1,14 +1,14 @@
1
1
  import * as vue from 'vue';
2
2
  import { MaybeRefOrGetter } from 'vue';
3
+ import * as _vue_solana_core_errors from '@vue-solana/core/errors';
3
4
  import { Commitment } from '@vue-solana/core/kit';
4
- import { SolanaError } from '@vue-solana/core/errors';
5
5
 
6
6
  type BalanceInput = string | null | undefined;
7
7
  declare function useBalance(address: MaybeRefOrGetter<BalanceInput>, commitment?: Commitment): {
8
- balance: vue.ShallowRef<number | null, number | null>;
9
- loading: vue.ShallowRef<boolean, boolean>;
10
- error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
8
+ error: vue.ShallowRef<_vue_solana_core_errors.SolanaError | null>;
9
+ loading: vue.ShallowRef<boolean>;
11
10
  refresh: () => Promise<number | null>;
11
+ balance: vue.ShallowRef<number | null>;
12
12
  };
13
13
 
14
14
  export { useBalance };
@@ -1,8 +1,9 @@
1
- export { u as useBalance } from './shared/vue.BINkrA8h.mjs';
2
- import '@vue-solana/core/address';
3
- import '@vue-solana/core/errors';
4
- import 'vue';
1
+ export { u as useBalance } from './shared/vue.BFSboXMB.mjs';
5
2
  import './shared/vue.CpkwC8Th.mjs';
6
3
  import './shared/vue.Mxc8w6Qk.mjs';
7
4
  import './shared/vue.CQh3AUE8.mjs';
5
+ import 'vue';
8
6
  import './shared/vue.D_P5SqqD.mjs';
7
+ import './shared/vue.BwBqla_n.mjs';
8
+ import '@vue-solana/core/address';
9
+ import '@vue-solana/core/errors';