@vue-solana/vue 2.6.1 → 3.0.1

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 (209) 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 +35 -55
  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 -79
  26. package/dist/useAccountInfo.d.mts +4 -4
  27. package/dist/useAccountInfo.d.ts +4 -4
  28. package/dist/useAccountInfo.mjs +1 -9
  29. package/dist/useAction.mjs +0 -2
  30. package/dist/useAirdrop.mjs +0 -7
  31. package/dist/useBalance.d.mts +4 -4
  32. package/dist/useBalance.d.ts +4 -4
  33. package/dist/useBalance.mjs +1 -8
  34. package/dist/useClientCapability.mjs +0 -4
  35. package/dist/useConnection.d.mts +6 -6
  36. package/dist/useConnection.d.ts +6 -6
  37. package/dist/useConnection.mjs +0 -4
  38. package/dist/useIdentity.mjs +0 -5
  39. package/dist/usePayer.mjs +0 -5
  40. package/dist/usePlanTransaction.d.mts +12 -13
  41. package/dist/usePlanTransaction.d.ts +12 -13
  42. package/dist/usePlanTransaction.mjs +1 -7
  43. package/dist/usePlanTransactions.d.mts +2 -1
  44. package/dist/usePlanTransactions.d.ts +2 -1
  45. package/dist/usePlanTransactions.mjs +1 -7
  46. package/dist/useProgramAccounts.d.mts +5 -15
  47. package/dist/useProgramAccounts.d.ts +5 -15
  48. package/dist/useProgramAccounts.mjs +1 -9
  49. package/dist/useRequest.mjs +0 -4
  50. package/dist/useRpc.d.mts +6 -6
  51. package/dist/useRpc.d.ts +6 -6
  52. package/dist/useRpc.mjs +0 -3
  53. package/dist/useSelectedWalletAccount.mjs +0 -2
  54. package/dist/useSendTransaction.d.mts +11 -12
  55. package/dist/useSendTransaction.d.ts +11 -12
  56. package/dist/useSendTransaction.mjs +1 -7
  57. package/dist/useSendTransactions.d.mts +2 -1
  58. package/dist/useSendTransactions.d.ts +2 -1
  59. package/dist/useSendTransactions.mjs +1 -7
  60. package/dist/useSignAndSendTransaction.d.mts +1 -1
  61. package/dist/useSignAndSendTransaction.d.ts +1 -1
  62. package/dist/useSignAndSendTransaction.mjs +1 -12
  63. package/dist/useSignAndSendTransactions.d.mts +2 -2
  64. package/dist/useSignAndSendTransactions.d.ts +2 -2
  65. package/dist/useSignAndSendTransactions.mjs +1 -8
  66. package/dist/useSignIn.d.mts +4 -4
  67. package/dist/useSignIn.d.ts +4 -4
  68. package/dist/useSignIn.mjs +1 -7
  69. package/dist/useSignMessage.d.mts +4 -4
  70. package/dist/useSignMessage.d.ts +4 -4
  71. package/dist/useSignMessage.mjs +1 -7
  72. package/dist/useSignTransactions.d.mts +4 -4
  73. package/dist/useSignTransactions.d.ts +4 -4
  74. package/dist/useSignTransactions.mjs +1 -7
  75. package/dist/useSignatureStatus.mjs +0 -7
  76. package/dist/useSolana.mjs +0 -2
  77. package/dist/useSolanaClient.d.mts +6 -6
  78. package/dist/useSolanaClient.d.ts +6 -6
  79. package/dist/useSolanaClient.mjs +0 -3
  80. package/dist/useSubscription.mjs +1 -3
  81. package/dist/useTokenAccounts.d.mts +4 -4
  82. package/dist/useTokenAccounts.d.ts +4 -4
  83. package/dist/useTokenAccounts.mjs +1 -9
  84. package/dist/useTokenBalance.d.mts +9 -7
  85. package/dist/useTokenBalance.d.ts +9 -7
  86. package/dist/useTokenBalance.mjs +1 -9
  87. package/dist/useTrackedData.mjs +1 -4
  88. package/dist/useTransaction.mjs +0 -4
  89. package/dist/useTransactionConfirmation.d.mts +4 -4
  90. package/dist/useTransactionConfirmation.d.ts +4 -4
  91. package/dist/useTransactionConfirmation.mjs +1 -8
  92. package/dist/useWallet.mjs +0 -5
  93. package/dist/useWallets.mjs +0 -3
  94. package/package.json +38 -75
  95. package/dist/buffer-polyfill.cjs +0 -8
  96. package/dist/buffer-polyfill.d.cts +0 -2
  97. package/dist/index.cjs +0 -452
  98. package/dist/index.d.cts +0 -62
  99. package/dist/kit.cjs +0 -16
  100. package/dist/kit.d.cts +0 -1
  101. package/dist/shared/vue.4C5kX4fE.cjs +0 -36
  102. package/dist/shared/vue.9TPxZPMf.cjs +0 -59
  103. package/dist/shared/vue.B4eMoJT2.cjs +0 -36
  104. package/dist/shared/vue.B6ainw2G.cjs +0 -63
  105. package/dist/shared/vue.BD6Gm1nl.mjs +0 -74
  106. package/dist/shared/vue.BGxz4dru.cjs +0 -98
  107. package/dist/shared/vue.BIxphCAq.cjs +0 -10
  108. package/dist/shared/vue.BOpgWr43.mjs +0 -70
  109. package/dist/shared/vue.BQRpjwKl.mjs +0 -80
  110. package/dist/shared/vue.BVaMoz9y.cjs +0 -9
  111. package/dist/shared/vue.Bk5xjlUx.cjs +0 -61
  112. package/dist/shared/vue.Bwd1sGAM.cjs +0 -72
  113. package/dist/shared/vue.ByxbBC3y.mjs +0 -57
  114. package/dist/shared/vue.C13umiQi.mjs +0 -85
  115. package/dist/shared/vue.CIs8QhCw.cjs +0 -132
  116. package/dist/shared/vue.CMohL_Cz.mjs +0 -58
  117. package/dist/shared/vue.CWZSMVnB.cjs +0 -84
  118. package/dist/shared/vue.Co5rj-I6.mjs +0 -118
  119. package/dist/shared/vue.CoaIWGPT.cjs +0 -38
  120. package/dist/shared/vue.CrkK_T15.cjs +0 -86
  121. package/dist/shared/vue.D-qi8PSL.cjs +0 -82
  122. package/dist/shared/vue.D3Y0PWbF.mjs +0 -71
  123. package/dist/shared/vue.D5U1yLG3.mjs +0 -83
  124. package/dist/shared/vue.DAg5wC1G.cjs +0 -76
  125. package/dist/shared/vue.DAthhH4D.mjs +0 -118
  126. package/dist/shared/vue.DDbVk0Zh.cjs +0 -180
  127. package/dist/shared/vue.DE3emjSF.cjs +0 -48
  128. package/dist/shared/vue.DEHxNvUX.cjs +0 -7
  129. package/dist/shared/vue.DFaMJLAQ.cjs +0 -60
  130. package/dist/shared/vue.DKoM8jIV.cjs +0 -121
  131. package/dist/shared/vue.DKyQ7J67.cjs +0 -15
  132. package/dist/shared/vue.DL3z5PxP.d.cts +0 -21
  133. package/dist/shared/vue.DNxOpDXz.cjs +0 -12
  134. package/dist/shared/vue.Di7yjJ-R.cjs +0 -87
  135. package/dist/shared/vue.Dn3KLJZH.cjs +0 -121
  136. package/dist/shared/vue.DxM45azl.cjs +0 -173
  137. package/dist/shared/vue.E_npPFoV.cjs +0 -67
  138. package/dist/shared/vue.FiMmnMHr.cjs +0 -20
  139. package/dist/shared/vue.JUWqu6kD.mjs +0 -61
  140. package/dist/shared/vue.Sbbm9JSu.cjs +0 -74
  141. package/dist/shared/vue.ZuUCEEab.cjs +0 -103
  142. package/dist/shared/vue.l3UCdN7z.cjs +0 -111
  143. package/dist/shared/vue.ldvmk9NM.cjs +0 -45
  144. package/dist/swr.cjs +0 -136
  145. package/dist/swr.d.cts +0 -41
  146. package/dist/useAccountInfo.cjs +0 -15
  147. package/dist/useAccountInfo.d.cts +0 -24
  148. package/dist/useAction.cjs +0 -9
  149. package/dist/useAction.d.cts +0 -45
  150. package/dist/useAirdrop.cjs +0 -14
  151. package/dist/useAirdrop.d.cts +0 -27
  152. package/dist/useBalance.cjs +0 -14
  153. package/dist/useBalance.d.cts +0 -15
  154. package/dist/useClientCapability.cjs +0 -12
  155. package/dist/useClientCapability.d.cts +0 -39
  156. package/dist/useConnection.cjs +0 -11
  157. package/dist/useConnection.d.cts +0 -46
  158. package/dist/useIdentity.cjs +0 -12
  159. package/dist/useIdentity.d.cts +0 -3
  160. package/dist/usePayer.cjs +0 -13
  161. package/dist/usePayer.d.cts +0 -18
  162. package/dist/usePlanTransaction.cjs +0 -14
  163. package/dist/usePlanTransaction.d.cts +0 -45
  164. package/dist/usePlanTransactions.cjs +0 -13
  165. package/dist/usePlanTransactions.d.cts +0 -4
  166. package/dist/useProgramAccounts.cjs +0 -15
  167. package/dist/useProgramAccounts.d.cts +0 -55
  168. package/dist/useRequest.cjs +0 -11
  169. package/dist/useRequest.d.cts +0 -73
  170. package/dist/useRpc.cjs +0 -10
  171. package/dist/useRpc.d.cts +0 -55
  172. package/dist/useSelectedWalletAccount.cjs +0 -13
  173. package/dist/useSelectedWalletAccount.d.cts +0 -117
  174. package/dist/useSendTransaction.cjs +0 -14
  175. package/dist/useSendTransaction.d.cts +0 -51
  176. package/dist/useSendTransactions.cjs +0 -13
  177. package/dist/useSendTransactions.d.cts +0 -4
  178. package/dist/useSignAndSendTransaction.cjs +0 -18
  179. package/dist/useSignAndSendTransaction.d.cts +0 -40
  180. package/dist/useSignAndSendTransactions.cjs +0 -15
  181. package/dist/useSignAndSendTransactions.d.cts +0 -35
  182. package/dist/useSignIn.cjs +0 -13
  183. package/dist/useSignIn.d.cts +0 -23
  184. package/dist/useSignMessage.cjs +0 -13
  185. package/dist/useSignMessage.d.cts +0 -236
  186. package/dist/useSignTransactions.cjs +0 -13
  187. package/dist/useSignTransactions.d.cts +0 -24
  188. package/dist/useSignatureStatus.cjs +0 -14
  189. package/dist/useSignatureStatus.d.cts +0 -26
  190. package/dist/useSolana.cjs +0 -10
  191. package/dist/useSolana.d.cts +0 -9
  192. package/dist/useSolanaClient.cjs +0 -10
  193. package/dist/useSolanaClient.d.cts +0 -45
  194. package/dist/useSubscription.cjs +0 -9
  195. package/dist/useSubscription.d.cts +0 -70
  196. package/dist/useTokenAccounts.cjs +0 -15
  197. package/dist/useTokenAccounts.d.cts +0 -19
  198. package/dist/useTokenBalance.cjs +0 -15
  199. package/dist/useTokenBalance.d.cts +0 -15
  200. package/dist/useTrackedData.cjs +0 -10
  201. package/dist/useTrackedData.d.cts +0 -98
  202. package/dist/useTransaction.cjs +0 -11
  203. package/dist/useTransaction.d.cts +0 -27
  204. package/dist/useTransactionConfirmation.cjs +0 -15
  205. package/dist/useTransactionConfirmation.d.cts +0 -38
  206. package/dist/useWallet.cjs +0 -12
  207. package/dist/useWallet.d.cts +0 -31
  208. package/dist/useWallets.cjs +0 -10
  209. package/dist/useWallets.d.cts +0 -11
@@ -1,83 +0,0 @@
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,76 +0,0 @@
1
- 'use strict';
2
-
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
- const vue = require('vue');
7
- const useConnection = require('./vue.BVaMoz9y.cjs');
8
- const useSolana = require('./vue.DE3emjSF.cjs');
9
-
10
- function useTokenBalance(mint, owner, commitment) {
11
- const solana = useSolana.tryUseSolana();
12
- const client = solana?.client ?? useConnection.useConnection();
13
- const balance = vue.shallowRef(null);
14
- const decimals = vue.shallowRef(null);
15
- const loading = vue.shallowRef(false);
16
- const error = vue.shallowRef(null);
17
- let refreshId = 0;
18
- async function refresh() {
19
- const requestId = ++refreshId;
20
- const mintValue = vue.toValue(mint);
21
- const ownerValue = vue.toValue(owner);
22
- if (!mintValue || !ownerValue || !solana) {
23
- balance.value = null;
24
- decimals.value = null;
25
- loading.value = false;
26
- error.value = null;
27
- return null;
28
- }
29
- loading.value = true;
30
- error.value = null;
31
- try {
32
- const mintKey = address.parseAddress(mintValue);
33
- const ownerKey = address.parseAddress(ownerValue);
34
- if (!mintKey || !ownerKey) {
35
- balance.value = null;
36
- decimals.value = null;
37
- loading.value = false;
38
- return null;
39
- }
40
- const nextBalance = await tokenAccounts.getTokenBalance(client, mintKey, ownerKey, commitment);
41
- if (requestId === refreshId) {
42
- balance.value = nextBalance?.amount ?? null;
43
- decimals.value = nextBalance?.decimals ?? null;
44
- }
45
- return nextBalance;
46
- } catch (cause) {
47
- const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
48
- if (requestId === refreshId) {
49
- error.value = normalizedError;
50
- }
51
- throw normalizedError;
52
- } finally {
53
- if (requestId === refreshId) {
54
- loading.value = false;
55
- }
56
- }
57
- }
58
- vue.onMounted(() => {
59
- void refresh().catch(() => void 0);
60
- });
61
- vue.watch(
62
- () => [vue.toValue(mint), vue.toValue(owner)],
63
- () => {
64
- void refresh().catch(() => void 0);
65
- }
66
- );
67
- return {
68
- balance,
69
- decimals,
70
- loading,
71
- error,
72
- refresh
73
- };
74
- }
75
-
76
- exports.useTokenBalance = useTokenBalance;
@@ -1,118 +0,0 @@
1
- import { normalizeSolanaError } from '@vue-solana/core/errors';
2
- import { shallowRef, ref, onScopeDispose } from 'vue';
3
- import { u as useClientCapability } from './vue.B9uRpSDJ.mjs';
4
- import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
5
-
6
- const SENDING_PROVIDER_HINT = "Use a client created by `createSolanaClient({ payer })` \u2014 or any client with a `payer` signer. Kit reads `client.payer` when it plans a transaction from an instruction plan.";
7
- function useSendTransaction() {
8
- useClientCapability(["sendTransaction", "payer"], {
9
- hookName: "useSendTransaction",
10
- providerHint: SENDING_PROVIDER_HINT
11
- });
12
- const { client } = useSolanaClient();
13
- const data = shallowRef(null);
14
- const status = ref("idle");
15
- const loading = ref(false);
16
- const error = ref(null);
17
- let executionId = 0;
18
- let abortController;
19
- onScopeDispose(() => {
20
- abortController?.abort();
21
- executionId++;
22
- });
23
- async function execute(input, config) {
24
- abortController?.abort();
25
- const controller = new AbortController();
26
- abortController = controller;
27
- const currentExecutionId = ++executionId;
28
- const sender = client;
29
- status.value = "sending";
30
- loading.value = true;
31
- error.value = null;
32
- data.value = null;
33
- try {
34
- const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
35
- const result = await sender.sendTransaction(input, { abortSignal });
36
- if (currentExecutionId === executionId) {
37
- data.value = result;
38
- status.value = "sent";
39
- }
40
- return result;
41
- } catch (cause) {
42
- const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
43
- if (currentExecutionId === executionId) {
44
- error.value = normalizedError;
45
- status.value = "error";
46
- }
47
- throw normalizedError;
48
- } finally {
49
- if (currentExecutionId === executionId) {
50
- loading.value = false;
51
- }
52
- }
53
- }
54
- return {
55
- data,
56
- status,
57
- loading,
58
- error,
59
- execute
60
- };
61
- }
62
- function useSendTransactions() {
63
- useClientCapability(["sendTransactions", "payer"], {
64
- hookName: "useSendTransactions",
65
- providerHint: SENDING_PROVIDER_HINT
66
- });
67
- const { client } = useSolanaClient();
68
- const data = shallowRef(null);
69
- const status = ref("idle");
70
- const loading = ref(false);
71
- const error = ref(null);
72
- let executionId = 0;
73
- let abortController;
74
- onScopeDispose(() => {
75
- abortController?.abort();
76
- executionId++;
77
- });
78
- async function execute(input, config) {
79
- abortController?.abort();
80
- const controller = new AbortController();
81
- abortController = controller;
82
- const currentExecutionId = ++executionId;
83
- const sender = client;
84
- status.value = "sending";
85
- loading.value = true;
86
- error.value = null;
87
- data.value = null;
88
- try {
89
- const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
90
- const result = await sender.sendTransactions(input, { abortSignal });
91
- if (currentExecutionId === executionId) {
92
- data.value = result;
93
- status.value = "sent";
94
- }
95
- return result;
96
- } catch (cause) {
97
- const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
98
- if (currentExecutionId === executionId) {
99
- error.value = normalizedError;
100
- status.value = "error";
101
- }
102
- throw normalizedError;
103
- } finally {
104
- if (currentExecutionId === executionId) {
105
- loading.value = false;
106
- }
107
- }
108
- }
109
- return {
110
- data,
111
- status,
112
- loading,
113
- error,
114
- execute
115
- };
116
- }
117
-
118
- export { useSendTransactions as a, useSendTransaction as u };
@@ -1,180 +0,0 @@
1
- 'use strict';
2
-
3
- const vue = require('vue');
4
- const injection = require('./vue.DEHxNvUX.cjs');
5
-
6
- const SELECTED_WALLET_ACCOUNT_STORAGE_KEY = "vue-solana:selected-wallet-account";
7
- function createLocalStorageSelectedWalletAccountStorage(storage = defaultLocalStorage()) {
8
- return {
9
- storeSelectedWallet(key) {
10
- try {
11
- storage?.setItem(SELECTED_WALLET_ACCOUNT_STORAGE_KEY, key);
12
- } catch {
13
- }
14
- },
15
- getSelectedWallet() {
16
- try {
17
- return storage?.getItem(SELECTED_WALLET_ACCOUNT_STORAGE_KEY) ?? null;
18
- } catch {
19
- return null;
20
- }
21
- },
22
- deleteSelectedWallet() {
23
- try {
24
- storage?.removeItem(SELECTED_WALLET_ACCOUNT_STORAGE_KEY);
25
- } catch {
26
- }
27
- }
28
- };
29
- }
30
- function defaultLocalStorage() {
31
- if (typeof window === "undefined") {
32
- return null;
33
- }
34
- try {
35
- return window.localStorage;
36
- } catch {
37
- return null;
38
- }
39
- }
40
-
41
- const selectedWalletAccountInjectionKey = Symbol.for("vue-solana:selected-wallet-account");
42
- function provideSelectedWalletAccount(options = {}) {
43
- const context = createSelectedWalletAccountContext(options);
44
- vue.provide(selectedWalletAccountInjectionKey, context);
45
- return context;
46
- }
47
- function createSelectedWalletAccountContext(options = {}, solanaContextOverride) {
48
- const solanaContext = solanaContextOverride ?? vue.inject(injection.solanaInjectionKey, null);
49
- const stateSync = options.stateSync === void 0 ? defaultStateSync() : options.stateSync;
50
- const selectedWalletAccount = vue.ref(null);
51
- const walletsValue = () => solanaContext?.wallets.value ?? [];
52
- let pendingKey = null;
53
- let selectionGeneration = 0;
54
- function findAccount(key) {
55
- const separatorIndex = key.lastIndexOf(":");
56
- const walletName = separatorIndex === -1 ? key : key.slice(0, separatorIndex);
57
- const address = separatorIndex === -1 ? "" : key.slice(separatorIndex + 1);
58
- const wallet = walletsValue().find((candidate) => candidate.name === walletName);
59
- const account = wallet?.accounts.find((candidate) => candidate.address === address);
60
- if (!wallet || !account) {
61
- return null;
62
- }
63
- return { ...account, walletName: wallet.name };
64
- }
65
- function clearSelection() {
66
- selectionGeneration += 1;
67
- pendingKey = null;
68
- selectedWalletAccount.value = null;
69
- }
70
- function applyExternalSelection(key) {
71
- if (!key) {
72
- clearSelection();
73
- return;
74
- }
75
- const account = findAccount(key);
76
- if (account) {
77
- selectionGeneration += 1;
78
- pendingKey = null;
79
- selectedWalletAccount.value = account;
80
- return;
81
- }
82
- pendingKey = key;
83
- }
84
- function restoreIfAvailable() {
85
- if (!pendingKey || selectedWalletAccount.value) {
86
- return;
87
- }
88
- const account = findAccount(pendingKey);
89
- if (account) {
90
- selectedWalletAccount.value = account;
91
- pendingKey = null;
92
- }
93
- }
94
- if (stateSync) {
95
- const generation = selectionGeneration;
96
- void Promise.resolve(stateSync.getSelectedWallet()).then((key) => {
97
- if (generation !== selectionGeneration || !key || selectedWalletAccount.value) {
98
- return;
99
- }
100
- pendingKey = key;
101
- restoreIfAvailable();
102
- }).catch(() => void 0);
103
- }
104
- if (solanaContext) {
105
- vue.watch(
106
- () => solanaContext.wallets.value,
107
- () => restoreIfAvailable()
108
- );
109
- }
110
- if (stateSync && typeof window !== "undefined") {
111
- const onStorage = () => {
112
- void Promise.resolve(stateSync.getSelectedWallet()).then((key) => applyExternalSelection(key)).catch(() => void 0);
113
- };
114
- window.addEventListener("storage", onStorage);
115
- if (vue.getCurrentScope()) {
116
- vue.onScopeDispose(() => window.removeEventListener("storage", onStorage));
117
- }
118
- }
119
- const context = {
120
- selectedWalletAccount,
121
- setSelectedWalletAccount(account) {
122
- selectionGeneration += 1;
123
- selectedWalletAccount.value = account;
124
- pendingKey = null;
125
- if (!stateSync) {
126
- return;
127
- }
128
- const persisted = account ? stateSync.storeSelectedWallet(`${account.walletName}:${account.address}`) : stateSync.deleteSelectedWallet();
129
- void Promise.resolve(persisted).catch(() => void 0);
130
- },
131
- filteredWallets: vue.computed(() => {
132
- const filter = options.filterWallet;
133
- if (!filter) {
134
- return walletsValue();
135
- }
136
- return walletsValue().map((wallet) => {
137
- const accounts = wallet.accounts.filter((account) => filter(wallet.name, account));
138
- return accounts.length === 0 ? null : { ...wallet, accounts };
139
- }).filter((wallet) => wallet !== null);
140
- })
141
- };
142
- return context;
143
- }
144
- function useSelectedWalletAccount() {
145
- const context = vue.inject(selectedWalletAccountInjectionKey, null);
146
- if (!context) {
147
- throw new Error("useSelectedWalletAccount must be used inside a SelectedWalletAccountProvider");
148
- }
149
- return [context.selectedWalletAccount, context.setSelectedWalletAccount, context.filteredWallets];
150
- }
151
- function defaultStateSync() {
152
- return createLocalStorageSelectedWalletAccountStorage();
153
- }
154
-
155
- const SelectedWalletAccountProvider = vue.defineComponent({
156
- name: "SelectedWalletAccountProvider",
157
- props: {
158
- filterWallet: {
159
- type: Function,
160
- default: void 0
161
- },
162
- stateSync: {
163
- type: [Object, null],
164
- default: void 0
165
- }
166
- },
167
- setup(props, { slots }) {
168
- provideSelectedWalletAccount({
169
- filterWallet: props.filterWallet,
170
- stateSync: props.stateSync
171
- });
172
- return () => slots.default?.();
173
- }
174
- });
175
-
176
- exports.SelectedWalletAccountProvider = SelectedWalletAccountProvider;
177
- exports.createSelectedWalletAccountContext = createSelectedWalletAccountContext;
178
- exports.provideSelectedWalletAccount = provideSelectedWalletAccount;
179
- exports.selectedWalletAccountInjectionKey = selectedWalletAccountInjectionKey;
180
- exports.useSelectedWalletAccount = useSelectedWalletAccount;
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- const vue = require('vue');
4
- const injection = require('./vue.DEHxNvUX.cjs');
5
-
6
- let ssrContext;
7
- function tryUseSolana() {
8
- return vue.inject(injection.solanaInjectionKey, null);
9
- }
10
- function useSolana() {
11
- return tryUseSolana() ?? getSsrContext();
12
- }
13
- function getSsrContext() {
14
- ssrContext ??= {
15
- cluster: "devnet",
16
- endpoint: "",
17
- wsEndpoint: "",
18
- client: createUnavailableProxy(),
19
- wallet: vue.shallowRef(null),
20
- status: vue.ref("idle"),
21
- error: vue.ref(null),
22
- latestBlockhash: vue.ref(null),
23
- wallets: vue.shallowRef([]),
24
- selectedWallet: vue.shallowRef(null),
25
- async checkConnection() {
26
- },
27
- setWallet() {
28
- },
29
- refreshWallets() {
30
- },
31
- selectWallet() {
32
- }
33
- };
34
- return ssrContext;
35
- }
36
- function createUnavailableProxy() {
37
- return new Proxy(
38
- {},
39
- {
40
- get() {
41
- throw new Error("Vue Solana plugin is not installed");
42
- }
43
- }
44
- );
45
- }
46
-
47
- exports.tryUseSolana = tryUseSolana;
48
- exports.useSolana = useSolana;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- const solanaInjectionKey = Symbol.for(
4
- "vue-solana:context"
5
- );
6
-
7
- exports.solanaInjectionKey = solanaInjectionKey;
@@ -1,60 +0,0 @@
1
- 'use strict';
2
-
3
- const errors = require('@vue-solana/core/errors');
4
- const wallet = require('@vue-solana/core/wallet');
5
- const vue = require('vue');
6
- const useWallet = require('./vue.BGxz4dru.cjs');
7
-
8
- function useSignTransactions() {
9
- const { wallet: wallet$1 } = useWallet.useWallet();
10
- const signedTransactions = vue.shallowRef(null);
11
- const status = vue.ref("idle");
12
- const loading = vue.ref(false);
13
- const error = vue.ref(null);
14
- let executionId = 0;
15
- async function execute(transactions) {
16
- const currentExecutionId = ++executionId;
17
- status.value = "signing";
18
- loading.value = true;
19
- error.value = null;
20
- signedTransactions.value = null;
21
- const activeWallet = wallet$1.value;
22
- if (!activeWallet) {
23
- const normalizedError = wallet.createNoWalletSelectedError();
24
- error.value = normalizedError;
25
- status.value = "error";
26
- loading.value = false;
27
- throw normalizedError;
28
- }
29
- try {
30
- wallet.assertWalletCanSignTransactions(activeWallet);
31
- const sign = activeWallet.signTransactions ? activeWallet.signTransactions.bind(activeWallet) : activeWallet.signAllTransactions.bind(activeWallet);
32
- const result = await sign([...transactions]);
33
- if (currentExecutionId === executionId) {
34
- signedTransactions.value = result;
35
- status.value = "signed";
36
- }
37
- return result;
38
- } catch (cause) {
39
- const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
40
- if (currentExecutionId === executionId) {
41
- error.value = normalizedError;
42
- status.value = "error";
43
- }
44
- throw normalizedError;
45
- } finally {
46
- if (currentExecutionId === executionId) {
47
- loading.value = false;
48
- }
49
- }
50
- }
51
- return {
52
- signedTransactions,
53
- status,
54
- loading,
55
- error,
56
- execute
57
- };
58
- }
59
-
60
- exports.useSignTransactions = useSignTransactions;
@@ -1,121 +0,0 @@
1
- 'use strict';
2
-
3
- const errors = require('@vue-solana/core/errors');
4
- const vue = require('vue');
5
- const useClientCapability = require('./vue.4C5kX4fE.cjs');
6
- const useSolanaClient = require('./vue.BIxphCAq.cjs');
7
-
8
- const SENDING_PROVIDER_HINT = "Use a client created by `createSolanaClient({ payer })` \u2014 or any client with a `payer` signer. Kit reads `client.payer` when it plans a transaction from an instruction plan.";
9
- function useSendTransaction() {
10
- useClientCapability.useClientCapability(["sendTransaction", "payer"], {
11
- hookName: "useSendTransaction",
12
- providerHint: SENDING_PROVIDER_HINT
13
- });
14
- const { client } = useSolanaClient.useSolanaClient();
15
- const data = vue.shallowRef(null);
16
- const status = vue.ref("idle");
17
- const loading = vue.ref(false);
18
- const error = vue.ref(null);
19
- let executionId = 0;
20
- let abortController;
21
- vue.onScopeDispose(() => {
22
- abortController?.abort();
23
- executionId++;
24
- });
25
- async function execute(input, config) {
26
- abortController?.abort();
27
- const controller = new AbortController();
28
- abortController = controller;
29
- const currentExecutionId = ++executionId;
30
- const sender = client;
31
- status.value = "sending";
32
- loading.value = true;
33
- error.value = null;
34
- data.value = null;
35
- try {
36
- const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
37
- const result = await sender.sendTransaction(input, { abortSignal });
38
- if (currentExecutionId === executionId) {
39
- data.value = result;
40
- status.value = "sent";
41
- }
42
- return result;
43
- } catch (cause) {
44
- const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
45
- if (currentExecutionId === executionId) {
46
- error.value = normalizedError;
47
- status.value = "error";
48
- }
49
- throw normalizedError;
50
- } finally {
51
- if (currentExecutionId === executionId) {
52
- loading.value = false;
53
- }
54
- }
55
- }
56
- return {
57
- data,
58
- status,
59
- loading,
60
- error,
61
- execute
62
- };
63
- }
64
- function useSendTransactions() {
65
- useClientCapability.useClientCapability(["sendTransactions", "payer"], {
66
- hookName: "useSendTransactions",
67
- providerHint: SENDING_PROVIDER_HINT
68
- });
69
- const { client } = useSolanaClient.useSolanaClient();
70
- const data = vue.shallowRef(null);
71
- const status = vue.ref("idle");
72
- const loading = vue.ref(false);
73
- const error = vue.ref(null);
74
- let executionId = 0;
75
- let abortController;
76
- vue.onScopeDispose(() => {
77
- abortController?.abort();
78
- executionId++;
79
- });
80
- async function execute(input, config) {
81
- abortController?.abort();
82
- const controller = new AbortController();
83
- abortController = controller;
84
- const currentExecutionId = ++executionId;
85
- const sender = client;
86
- status.value = "sending";
87
- loading.value = true;
88
- error.value = null;
89
- data.value = null;
90
- try {
91
- const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
92
- const result = await sender.sendTransactions(input, { abortSignal });
93
- if (currentExecutionId === executionId) {
94
- data.value = result;
95
- status.value = "sent";
96
- }
97
- return result;
98
- } catch (cause) {
99
- const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
100
- if (currentExecutionId === executionId) {
101
- error.value = normalizedError;
102
- status.value = "error";
103
- }
104
- throw normalizedError;
105
- } finally {
106
- if (currentExecutionId === executionId) {
107
- loading.value = false;
108
- }
109
- }
110
- }
111
- return {
112
- data,
113
- status,
114
- loading,
115
- error,
116
- execute
117
- };
118
- }
119
-
120
- exports.useSendTransaction = useSendTransaction;
121
- exports.useSendTransactions = useSendTransactions;