@vue-solana/vue 0.2.2 → 0.2.3

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 (66) hide show
  1. package/README.md +25 -4
  2. package/dist/index.cjs +83 -194
  3. package/dist/index.d.cts +14 -77
  4. package/dist/index.d.mts +14 -77
  5. package/dist/index.d.ts +14 -77
  6. package/dist/index.mjs +71 -182
  7. package/dist/shared/vue.1M_c5FWA.mjs +46 -0
  8. package/dist/shared/vue.BMUEDN2t.mjs +28 -0
  9. package/dist/shared/vue.BSVxQ9Yi.cjs +30 -0
  10. package/dist/shared/vue.BqDzSepb.mjs +18 -0
  11. package/dist/shared/vue.C4tLiG3R.cjs +50 -0
  12. package/dist/shared/vue.COyyrsQU.cjs +20 -0
  13. package/dist/shared/vue.CTM6XQ47.cjs +19 -0
  14. package/dist/shared/vue.CjKm-Cw1.cjs +47 -0
  15. package/dist/shared/vue.CwPjPFN6.cjs +69 -0
  16. package/dist/shared/vue.CwhEmATP.cjs +9 -0
  17. package/dist/shared/vue.D81obqiN.mjs +45 -0
  18. package/dist/shared/vue.DGhodYJh.d.cts +20 -0
  19. package/dist/shared/vue.DGhodYJh.d.mts +20 -0
  20. package/dist/shared/vue.DGhodYJh.d.ts +20 -0
  21. package/dist/shared/vue.DYf_CRDv.mjs +67 -0
  22. package/dist/shared/vue.DlEAL2G8.mjs +7 -0
  23. package/dist/shared/vue.P9tgeC5S.cjs +15 -0
  24. package/dist/shared/vue.PoQ8Vpmy.mjs +17 -0
  25. package/dist/shared/vue.h-uS8MXN.mjs +13 -0
  26. package/dist/useBalance.cjs +11 -0
  27. package/dist/useBalance.d.cts +12 -0
  28. package/dist/useBalance.d.mts +12 -0
  29. package/dist/useBalance.d.ts +12 -0
  30. package/dist/useBalance.mjs +5 -0
  31. package/dist/useConnection.cjs +10 -0
  32. package/dist/useConnection.d.cts +3 -0
  33. package/dist/useConnection.d.mts +3 -0
  34. package/dist/useConnection.d.ts +3 -0
  35. package/dist/useConnection.mjs +4 -0
  36. package/dist/useRpc.cjs +9 -0
  37. package/dist/useRpc.d.cts +16 -0
  38. package/dist/useRpc.d.mts +16 -0
  39. package/dist/useRpc.d.ts +16 -0
  40. package/dist/useRpc.mjs +3 -0
  41. package/dist/useSignAndSendTransaction.cjs +14 -0
  42. package/dist/useSignAndSendTransaction.d.cts +11 -0
  43. package/dist/useSignAndSendTransaction.d.mts +11 -0
  44. package/dist/useSignAndSendTransaction.d.ts +11 -0
  45. package/dist/useSignAndSendTransaction.mjs +8 -0
  46. package/dist/useSolana.cjs +9 -0
  47. package/dist/useSolana.d.cts +8 -0
  48. package/dist/useSolana.d.mts +8 -0
  49. package/dist/useSolana.d.ts +8 -0
  50. package/dist/useSolana.mjs +2 -0
  51. package/dist/useTransaction.cjs +8 -0
  52. package/dist/useTransaction.d.cts +11 -0
  53. package/dist/useTransaction.d.mts +11 -0
  54. package/dist/useTransaction.d.ts +11 -0
  55. package/dist/useTransaction.mjs +2 -0
  56. package/dist/useWallet.cjs +9 -0
  57. package/dist/useWallet.d.cts +16 -0
  58. package/dist/useWallet.d.mts +16 -0
  59. package/dist/useWallet.d.ts +16 -0
  60. package/dist/useWallet.mjs +3 -0
  61. package/dist/useWallets.cjs +9 -0
  62. package/dist/useWallets.d.cts +11 -0
  63. package/dist/useWallets.d.mts +11 -0
  64. package/dist/useWallets.d.ts +11 -0
  65. package/dist/useWallets.mjs +3 -0
  66. package/package.json +41 -1
package/README.md CHANGED
@@ -53,6 +53,13 @@ createApp(App).use(
53
53
 
54
54
  Supported clusters are `mainnet-beta`, `devnet`, `testnet`, and `localnet`. Use `mainnet-beta` for Solana mainnet; this is Solana's official cluster name.
55
55
 
56
+ The root export remains supported. For composables, prefer direct subpath imports in new code so bundlers can avoid evaluating unrelated package entry code:
57
+
58
+ ```ts
59
+ import { useRpc } from "@vue-solana/vue/useRpc";
60
+ import { useWallet } from "@vue-solana/vue/useWallet";
61
+ ```
62
+
56
63
  For development, use `devnet` and request free test SOL from the official faucet:
57
64
 
58
65
  ```txt
@@ -63,7 +70,7 @@ https://faucet.solana.com
63
70
 
64
71
  ```vue
65
72
  <script setup lang="ts">
66
- import { useRpc } from "@vue-solana/vue";
73
+ import { useRpc } from "@vue-solana/vue/useRpc";
67
74
 
68
75
  const { cluster, endpoint, status, error, latestBlockhash, checkConnection } = useRpc();
69
76
  </script>
@@ -85,7 +92,7 @@ const { cluster, endpoint, status, error, latestBlockhash, checkConnection } = u
85
92
  ```vue
86
93
  <script setup lang="ts">
87
94
  import { ref } from "vue";
88
- import { useBalance } from "@vue-solana/vue";
95
+ import { useBalance } from "@vue-solana/vue/useBalance";
89
96
 
90
97
  const address = ref("PASTE_A_SOLANA_ADDRESS");
91
98
  const { balance, loading, error, refresh } = useBalance(address);
@@ -105,7 +112,8 @@ const { balance, loading, error, refresh } = useBalance(address);
105
112
 
106
113
  ```vue
107
114
  <script setup lang="ts">
108
- import { useWallet, useWallets } from "@vue-solana/vue";
115
+ import { useWallet } from "@vue-solana/vue/useWallet";
116
+ import { useWallets } from "@vue-solana/vue/useWallets";
109
117
 
110
118
  const { wallets, selectedWallet, selectWallet, refreshWallets } = useWallets();
111
119
  const { publicKey, connected, connecting, connect, disconnect } = useWallet();
@@ -136,10 +144,12 @@ const { publicKey, connected, connecting, connect, disconnect } = useWallet();
136
144
 
137
145
  Browser wallets are discovered through the Solana Wallet Standard. `connect()` works after selecting a discovered wallet or configuring a custom `SolanaWallet`.
138
146
 
147
+ Composables return inert SSR-safe state when no plugin context is available. Real RPC and wallet operations still require the plugin-provided client context.
148
+
139
149
  ## Transaction State
140
150
 
141
151
  ```ts
142
- import { useSignAndSendTransaction } from "@vue-solana/vue";
152
+ import { useSignAndSendTransaction } from "@vue-solana/vue/useSignAndSendTransaction";
143
153
 
144
154
  const { signature, loading, error, execute } = useSignAndSendTransaction();
145
155
 
@@ -174,6 +184,17 @@ Live demo: [vue-solana-docs.vercel.app/demo](https://vue-solana-docs.vercel.app/
174
184
  - `useTransaction(handler)`: generic async transaction state helper.
175
185
  - `useSignAndSendTransaction()`: signs and sends a transaction through the configured wallet.
176
186
 
187
+ Direct composable subpaths:
188
+
189
+ - `@vue-solana/vue/useSolana`
190
+ - `@vue-solana/vue/useRpc`
191
+ - `@vue-solana/vue/useConnection`
192
+ - `@vue-solana/vue/useBalance`
193
+ - `@vue-solana/vue/useWallet`
194
+ - `@vue-solana/vue/useWallets`
195
+ - `@vue-solana/vue/useTransaction`
196
+ - `@vue-solana/vue/useSignAndSendTransaction`
197
+
177
198
  ## Known TypeScript Issue
178
199
 
179
200
  `@solana/web3-compat@0.0.21` currently has broken TypeScript metadata. Runtime imports still use the real package, but TypeScript consumers may need a local declaration shim.
package/dist/index.cjs CHANGED
@@ -1,196 +1,30 @@
1
1
  'use strict';
2
2
 
3
- const web3Compat = require('@solana/web3-compat');
3
+ const useBalance = require('./shared/vue.CjKm-Cw1.cjs');
4
+ const useConnection = require('./shared/vue.CwhEmATP.cjs');
5
+ const useRpc = require('./shared/vue.COyyrsQU.cjs');
6
+ const useSignAndSendTransaction = require('./shared/vue.CTM6XQ47.cjs');
7
+ const useSolana = require('./shared/vue.C4tLiG3R.cjs');
8
+ const useTransaction = require('./shared/vue.BSVxQ9Yi.cjs');
9
+ const useWallet = require('./shared/vue.CwPjPFN6.cjs');
10
+ const useWallets = require('./shared/vue.P9tgeC5S.cjs');
11
+ const walletStandard = require('@vue-solana/core/wallet-standard');
12
+ const rpc = require('@vue-solana/core/rpc');
4
13
  const vue = require('vue');
5
- const core = require('@vue-solana/core');
6
-
7
- const solanaInjectionKey = Symbol("VueSolana");
8
-
9
- function useSolana() {
10
- const context = vue.inject(solanaInjectionKey);
11
- if (!context) {
12
- throw new Error("Vue Solana plugin is not installed");
13
- }
14
- return context;
15
- }
16
-
17
- function useRpc() {
18
- const solana = useSolana();
19
- return {
20
- cluster: vue.computed(() => solana.cluster),
21
- endpoint: vue.computed(() => solana.endpoint),
22
- wsEndpoint: vue.computed(() => solana.wsEndpoint),
23
- status: solana.status,
24
- error: solana.error,
25
- latestBlockhash: solana.latestBlockhash,
26
- checkConnection: solana.checkConnection,
27
- connection: solana.connection
28
- };
29
- }
30
-
31
- function useConnection() {
32
- return useRpc().connection;
33
- }
34
-
35
- function useBalance(address, commitment) {
36
- const connection = useConnection();
37
- const balance = vue.ref(null);
38
- const loading = vue.ref(false);
39
- const error = vue.ref(null);
40
- async function refresh() {
41
- const value = vue.toValue(address);
42
- if (!value) {
43
- balance.value = null;
44
- return null;
45
- }
46
- loading.value = true;
47
- error.value = null;
48
- try {
49
- const publicKey = typeof value === "string" ? new web3Compat.PublicKey(value) : value;
50
- balance.value = await connection.getBalance(publicKey, commitment);
51
- return balance.value;
52
- } catch (cause) {
53
- error.value = cause;
54
- throw cause;
55
- } finally {
56
- loading.value = false;
57
- }
58
- }
59
- vue.watch(
60
- () => vue.toValue(address),
61
- () => {
62
- void refresh().catch(() => void 0);
63
- },
64
- { immediate: true }
65
- );
66
- return {
67
- balance,
68
- loading,
69
- error,
70
- refresh
71
- };
72
- }
73
-
74
- function useWallet() {
75
- const solana = useSolana();
76
- const wallet = solana.wallet;
77
- const connecting = vue.ref(false);
78
- const disconnecting = vue.ref(false);
79
- async function connect() {
80
- const activeWallet = wallet.value;
81
- if (!activeWallet) {
82
- throw new Error("No Solana wallet is configured");
83
- }
84
- connecting.value = true;
85
- try {
86
- const connection = activeWallet.connect();
87
- vue.triggerRef(wallet);
88
- await connection;
89
- vue.triggerRef(wallet);
90
- console.info("[Vue Solana] Wallet connected", {
91
- publicKey: activeWallet.publicKey?.toBase58() ?? null
92
- });
93
- } catch (error) {
94
- vue.triggerRef(wallet);
95
- console.error("[Vue Solana] Wallet connection failed", error);
96
- throw error;
97
- } finally {
98
- connecting.value = false;
99
- }
100
- }
101
- async function disconnect() {
102
- const activeWallet = wallet.value;
103
- if (!activeWallet) {
104
- return;
105
- }
106
- const publicKey = activeWallet.publicKey?.toBase58() ?? null;
107
- disconnecting.value = true;
108
- try {
109
- await activeWallet.disconnect();
110
- vue.triggerRef(wallet);
111
- console.info("[Vue Solana] Wallet disconnected", { publicKey });
112
- } catch (error) {
113
- vue.triggerRef(wallet);
114
- console.error("[Vue Solana] Wallet disconnection failed", error);
115
- throw error;
116
- } finally {
117
- disconnecting.value = false;
118
- }
119
- }
120
- const isConnecting = vue.computed(() => Boolean(connecting.value || wallet.value?.connecting));
121
- const isDisconnecting = vue.computed(
122
- () => Boolean(disconnecting.value || wallet.value?.disconnecting)
123
- );
124
- return {
125
- wallet,
126
- publicKey: vue.computed(() => wallet.value?.publicKey ?? null),
127
- connected: vue.computed(() => Boolean(wallet.value?.connected && wallet.value.publicKey)),
128
- connecting: isConnecting,
129
- disconnecting: isDisconnecting,
130
- loading: vue.computed(() => isConnecting.value || isDisconnecting.value),
131
- setWallet: solana.setWallet,
132
- connect,
133
- disconnect
134
- };
135
- }
136
-
137
- function useTransaction(handler) {
138
- const signature = vue.ref(null);
139
- const loading = vue.ref(false);
140
- const error = vue.ref(null);
141
- async function execute(...args) {
142
- loading.value = true;
143
- error.value = null;
144
- try {
145
- signature.value = await handler(...args);
146
- return signature.value;
147
- } catch (cause) {
148
- error.value = cause;
149
- throw cause;
150
- } finally {
151
- loading.value = false;
152
- }
153
- }
154
- return {
155
- signature,
156
- loading,
157
- error,
158
- execute
159
- };
160
- }
161
-
162
- function useSignAndSendTransaction() {
163
- const connection = useConnection();
164
- const { wallet } = useWallet();
165
- return useTransaction((transaction, options) => {
166
- if (!wallet.value) {
167
- return Promise.reject(new Error("No Solana wallet is configured"));
168
- }
169
- return core.signAndSendTransaction(connection, wallet.value, transaction, options);
170
- });
171
- }
172
-
173
- function useWallets() {
174
- const solana = useSolana();
175
- return {
176
- wallets: solana.wallets,
177
- selectedWallet: solana.selectedWallet,
178
- refreshWallets: solana.refreshWallets,
179
- selectWallet: solana.selectWallet
180
- };
181
- }
14
+ require('@vue-solana/core/transaction');
182
15
 
183
16
  const RPC_CHECK_TIMEOUT_MS = 1e4;
184
17
  function createSolanaPlugin(options = {}) {
185
18
  return {
186
19
  install(app) {
187
- const context = core.createSolanaContext(options);
20
+ const context = rpc.createSolanaContext(options);
188
21
  const wallet = vue.shallowRef(options.wallet ?? null);
189
22
  const wallets = vue.shallowRef([]);
190
23
  const selectedWallet = vue.shallowRef(null);
191
24
  const status = vue.ref("idle");
192
25
  const error = vue.ref(null);
193
26
  const latestBlockhash = vue.ref(null);
27
+ const adaptedWallets = /* @__PURE__ */ new WeakMap();
194
28
  let unsubscribeWallets = null;
195
29
  let rpcCheckId = 0;
196
30
  async function checkConnection() {
@@ -229,8 +63,8 @@ function createSolanaPlugin(options = {}) {
229
63
  }
230
64
  }
231
65
  function refreshWallets() {
232
- unsubscribeWallets ??= core.subscribeSolanaWallets(refreshWallets);
233
- wallets.value = core.getRegisteredSolanaWallets();
66
+ unsubscribeWallets ??= walletStandard.subscribeSolanaWallets(refreshWallets);
67
+ wallets.value = walletStandard.getRegisteredSolanaWallets();
234
68
  if (selectedWallet.value) {
235
69
  selectedWallet.value = wallets.value.find((nextWallet) => nextWallet.name === selectedWallet.value?.name) ?? null;
236
70
  if (!selectedWallet.value) {
@@ -240,10 +74,61 @@ function createSolanaPlugin(options = {}) {
240
74
  }
241
75
  function selectWallet(nextWallet) {
242
76
  selectedWallet.value = nextWallet;
243
- wallet.value = nextWallet ? core.adaptSolanaStandardWallet(nextWallet, {
244
- chain: core.getSolanaChain(context.cluster),
77
+ wallet.value = nextWallet ? getAdaptedWallet(nextWallet) : options.wallet ?? null;
78
+ }
79
+ function getAdaptedWallet(walletInfo) {
80
+ if (!isObject(walletInfo.wallet)) {
81
+ return walletStandard.adaptSolanaStandardWallet(walletInfo, {
82
+ chain: walletStandard.getSolanaChain(context.cluster),
83
+ onChange: () => vue.triggerRef(wallet)
84
+ });
85
+ }
86
+ const cachedWallet = adaptedWallets.get(walletInfo.wallet);
87
+ if (cachedWallet) {
88
+ return cachedWallet;
89
+ }
90
+ const adaptedWallet = walletStandard.adaptSolanaStandardWallet(walletInfo, {
91
+ chain: walletStandard.getSolanaChain(context.cluster),
245
92
  onChange: () => vue.triggerRef(wallet)
246
- }) : options.wallet ?? null;
93
+ });
94
+ const cachedAdapter = {
95
+ get publicKey() {
96
+ return adaptedWallet.publicKey;
97
+ },
98
+ get connected() {
99
+ return adaptedWallet.connected;
100
+ },
101
+ get connecting() {
102
+ return adaptedWallet.connecting;
103
+ },
104
+ get disconnecting() {
105
+ return adaptedWallet.disconnecting;
106
+ },
107
+ async connect() {
108
+ await adaptedWallet.connect();
109
+ await Promise.all(
110
+ Array.from(getCachedWallets()).map(
111
+ (otherWallet) => otherWallet !== cachedAdapter && otherWallet.connected ? otherWallet.disconnect() : void 0
112
+ )
113
+ );
114
+ },
115
+ disconnect: () => adaptedWallet.disconnect(),
116
+ signTransaction: adaptedWallet.signTransaction?.bind(adaptedWallet),
117
+ signAllTransactions: adaptedWallet.signAllTransactions?.bind(adaptedWallet),
118
+ signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet)
119
+ };
120
+ adaptedWallets.set(walletInfo.wallet, cachedAdapter);
121
+ return cachedAdapter;
122
+ }
123
+ function* getCachedWallets() {
124
+ for (const walletInfo of wallets.value) {
125
+ if (isObject(walletInfo.wallet)) {
126
+ const cachedWallet = adaptedWallets.get(walletInfo.wallet);
127
+ if (cachedWallet) {
128
+ yield cachedWallet;
129
+ }
130
+ }
131
+ }
247
132
  }
248
133
  const vueContext = {
249
134
  ...context,
@@ -261,13 +146,16 @@ function createSolanaPlugin(options = {}) {
261
146
  wallet.value = nextWallet;
262
147
  }
263
148
  };
264
- app.provide(solanaInjectionKey, vueContext);
149
+ app.provide(useSolana.solanaInjectionKey, vueContext);
265
150
  if (typeof window !== "undefined") {
266
151
  void checkConnection();
267
152
  }
268
153
  }
269
154
  };
270
155
  }
156
+ function isObject(value) {
157
+ return typeof value === "object" && value !== null || typeof value === "function";
158
+ }
271
159
  const VueSolana = createSolanaPlugin;
272
160
  function withTimeout(promise, timeoutMs, message) {
273
161
  let timeoutId;
@@ -283,14 +171,15 @@ function withTimeout(promise, timeoutMs, message) {
283
171
  });
284
172
  }
285
173
 
174
+ exports.useBalance = useBalance.useBalance;
175
+ exports.useConnection = useConnection.useConnection;
176
+ exports.useRpc = useRpc.useRpc;
177
+ exports.useSignAndSendTransaction = useSignAndSendTransaction.useSignAndSendTransaction;
178
+ exports.solanaInjectionKey = useSolana.solanaInjectionKey;
179
+ exports.tryUseSolana = useSolana.tryUseSolana;
180
+ exports.useSolana = useSolana.useSolana;
181
+ exports.useTransaction = useTransaction.useTransaction;
182
+ exports.useWallet = useWallet.useWallet;
183
+ exports.useWallets = useWallets.useWallets;
286
184
  exports.VueSolana = VueSolana;
287
185
  exports.createSolanaPlugin = createSolanaPlugin;
288
- exports.solanaInjectionKey = solanaInjectionKey;
289
- exports.useBalance = useBalance;
290
- exports.useConnection = useConnection;
291
- exports.useRpc = useRpc;
292
- exports.useSignAndSendTransaction = useSignAndSendTransaction;
293
- exports.useSolana = useSolana;
294
- exports.useTransaction = useTransaction;
295
- exports.useWallet = useWallet;
296
- exports.useWallets = useWallets;
package/dist/index.d.cts CHANGED
@@ -1,78 +1,15 @@
1
- import * as vue from 'vue';
2
- import { MaybeRefOrGetter, Ref, InjectionKey, App } from 'vue';
3
- import { PublicKey, Commitment, TransactionSignature } from '@solana/web3-compat';
4
- import * as _vue_solana_core from '@vue-solana/core';
5
- import { SendTransactionOptions, SolanaContext, SolanaWallet, SolanaWalletInfo, SolanaConfig } from '@vue-solana/core';
6
-
7
- declare function useBalance(address: MaybeRefOrGetter<PublicKey | string | null | undefined>, commitment?: Commitment): {
8
- balance: vue.Ref<number | null, number | null>;
9
- loading: vue.Ref<boolean, boolean>;
10
- error: vue.Ref<unknown, unknown>;
11
- refresh: () => Promise<number | null>;
12
- };
13
-
14
- declare function useConnection(): Connection;
15
-
16
- declare function useRpc(): {
17
- cluster: vue.ComputedRef<_vue_solana_core.SolanaCluster>;
18
- endpoint: vue.ComputedRef<string>;
19
- wsEndpoint: vue.ComputedRef<string>;
20
- status: vue.Ref<SolanaConnectionStatus, SolanaConnectionStatus>;
21
- error: vue.Ref<string | null, string | null>;
22
- latestBlockhash: vue.Ref<string | null, string | null>;
23
- checkConnection: () => Promise<void>;
24
- connection: Connection;
25
- };
26
-
27
- declare function useSignAndSendTransaction(): {
28
- signature: any;
29
- loading: vue.Ref<boolean, boolean>;
30
- error: vue.Ref<unknown, unknown>;
31
- execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<any>;
32
- };
33
-
34
- declare function useSolana(): VueSolanaContext;
35
-
36
- declare function useTransaction<TArgs extends unknown[]>(handler: (...args: TArgs) => Promise<TransactionSignature>): {
37
- signature: any;
38
- loading: vue.Ref<boolean, boolean>;
39
- error: vue.Ref<unknown, unknown>;
40
- execute: (...args: TArgs) => Promise<any>;
41
- };
42
-
43
- declare function useWallet(): {
44
- wallet: vue.Ref<_vue_solana_core.SolanaWallet | null, _vue_solana_core.SolanaWallet | null>;
45
- publicKey: vue.ComputedRef<any>;
46
- connected: vue.ComputedRef<boolean>;
47
- connecting: vue.ComputedRef<boolean>;
48
- disconnecting: vue.ComputedRef<boolean>;
49
- loading: vue.ComputedRef<boolean>;
50
- setWallet: (wallet: _vue_solana_core.SolanaWallet | null) => void;
51
- connect: () => Promise<void>;
52
- disconnect: () => Promise<void>;
53
- };
54
-
55
- declare function useWallets(): {
56
- wallets: vue.Ref<_vue_solana_core.SolanaWalletInfo[], _vue_solana_core.SolanaWalletInfo[]>;
57
- selectedWallet: vue.Ref<_vue_solana_core.SolanaWalletInfo | null, _vue_solana_core.SolanaWalletInfo | null>;
58
- refreshWallets: () => void;
59
- selectWallet: (wallet: _vue_solana_core.SolanaWalletInfo | null) => void;
60
- };
61
-
62
- type SolanaConnectionStatus = "idle" | "checking" | "connected" | "error";
63
- interface VueSolanaContext extends SolanaContext {
64
- wallet: Ref<SolanaWallet | null>;
65
- status: Ref<SolanaConnectionStatus>;
66
- error: Ref<string | null>;
67
- latestBlockhash: Ref<string | null>;
68
- wallets: Ref<SolanaWalletInfo[]>;
69
- selectedWallet: Ref<SolanaWalletInfo | null>;
70
- checkConnection: () => Promise<void>;
71
- setWallet: (wallet: SolanaWallet | null) => void;
72
- refreshWallets: () => void;
73
- selectWallet: (wallet: SolanaWalletInfo | null) => void;
74
- }
75
- declare const solanaInjectionKey: InjectionKey<VueSolanaContext>;
1
+ export { useBalance } from './useBalance.cjs';
2
+ export { useConnection } from './useConnection.cjs';
3
+ export { useRpc } from './useRpc.cjs';
4
+ export { useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
5
+ export { tryUseSolana, useSolana } from './useSolana.cjs';
6
+ export { useTransaction } from './useTransaction.cjs';
7
+ export { useWallet } from './useWallet.cjs';
8
+ export { useWallets } from './useWallets.cjs';
9
+ export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.cjs';
10
+ import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
11
+ import { App } from 'vue';
12
+ import '@solana/web3-compat';
76
13
 
77
14
  interface VueSolanaPluginOptions extends SolanaConfig {
78
15
  wallet?: SolanaWallet | null;
@@ -82,5 +19,5 @@ declare function createSolanaPlugin(options?: VueSolanaPluginOptions): {
82
19
  };
83
20
  declare const VueSolana: typeof createSolanaPlugin;
84
21
 
85
- export { VueSolana, createSolanaPlugin, solanaInjectionKey, useBalance, useConnection, useRpc, useSignAndSendTransaction, useSolana, useTransaction, useWallet, useWallets };
86
- export type { SolanaConnectionStatus, VueSolanaContext, VueSolanaPluginOptions };
22
+ export { VueSolana, createSolanaPlugin };
23
+ export type { VueSolanaPluginOptions };
package/dist/index.d.mts CHANGED
@@ -1,78 +1,15 @@
1
- import * as vue from 'vue';
2
- import { MaybeRefOrGetter, Ref, InjectionKey, App } from 'vue';
3
- import { PublicKey, Commitment, TransactionSignature } from '@solana/web3-compat';
4
- import * as _vue_solana_core from '@vue-solana/core';
5
- import { SendTransactionOptions, SolanaContext, SolanaWallet, SolanaWalletInfo, SolanaConfig } from '@vue-solana/core';
6
-
7
- declare function useBalance(address: MaybeRefOrGetter<PublicKey | string | null | undefined>, commitment?: Commitment): {
8
- balance: vue.Ref<number | null, number | null>;
9
- loading: vue.Ref<boolean, boolean>;
10
- error: vue.Ref<unknown, unknown>;
11
- refresh: () => Promise<number | null>;
12
- };
13
-
14
- declare function useConnection(): Connection;
15
-
16
- declare function useRpc(): {
17
- cluster: vue.ComputedRef<_vue_solana_core.SolanaCluster>;
18
- endpoint: vue.ComputedRef<string>;
19
- wsEndpoint: vue.ComputedRef<string>;
20
- status: vue.Ref<SolanaConnectionStatus, SolanaConnectionStatus>;
21
- error: vue.Ref<string | null, string | null>;
22
- latestBlockhash: vue.Ref<string | null, string | null>;
23
- checkConnection: () => Promise<void>;
24
- connection: Connection;
25
- };
26
-
27
- declare function useSignAndSendTransaction(): {
28
- signature: any;
29
- loading: vue.Ref<boolean, boolean>;
30
- error: vue.Ref<unknown, unknown>;
31
- execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<any>;
32
- };
33
-
34
- declare function useSolana(): VueSolanaContext;
35
-
36
- declare function useTransaction<TArgs extends unknown[]>(handler: (...args: TArgs) => Promise<TransactionSignature>): {
37
- signature: any;
38
- loading: vue.Ref<boolean, boolean>;
39
- error: vue.Ref<unknown, unknown>;
40
- execute: (...args: TArgs) => Promise<any>;
41
- };
42
-
43
- declare function useWallet(): {
44
- wallet: vue.Ref<_vue_solana_core.SolanaWallet | null, _vue_solana_core.SolanaWallet | null>;
45
- publicKey: vue.ComputedRef<any>;
46
- connected: vue.ComputedRef<boolean>;
47
- connecting: vue.ComputedRef<boolean>;
48
- disconnecting: vue.ComputedRef<boolean>;
49
- loading: vue.ComputedRef<boolean>;
50
- setWallet: (wallet: _vue_solana_core.SolanaWallet | null) => void;
51
- connect: () => Promise<void>;
52
- disconnect: () => Promise<void>;
53
- };
54
-
55
- declare function useWallets(): {
56
- wallets: vue.Ref<_vue_solana_core.SolanaWalletInfo[], _vue_solana_core.SolanaWalletInfo[]>;
57
- selectedWallet: vue.Ref<_vue_solana_core.SolanaWalletInfo | null, _vue_solana_core.SolanaWalletInfo | null>;
58
- refreshWallets: () => void;
59
- selectWallet: (wallet: _vue_solana_core.SolanaWalletInfo | null) => void;
60
- };
61
-
62
- type SolanaConnectionStatus = "idle" | "checking" | "connected" | "error";
63
- interface VueSolanaContext extends SolanaContext {
64
- wallet: Ref<SolanaWallet | null>;
65
- status: Ref<SolanaConnectionStatus>;
66
- error: Ref<string | null>;
67
- latestBlockhash: Ref<string | null>;
68
- wallets: Ref<SolanaWalletInfo[]>;
69
- selectedWallet: Ref<SolanaWalletInfo | null>;
70
- checkConnection: () => Promise<void>;
71
- setWallet: (wallet: SolanaWallet | null) => void;
72
- refreshWallets: () => void;
73
- selectWallet: (wallet: SolanaWalletInfo | null) => void;
74
- }
75
- declare const solanaInjectionKey: InjectionKey<VueSolanaContext>;
1
+ export { useBalance } from './useBalance.mjs';
2
+ export { useConnection } from './useConnection.mjs';
3
+ export { useRpc } from './useRpc.mjs';
4
+ export { useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
5
+ export { tryUseSolana, useSolana } from './useSolana.mjs';
6
+ export { useTransaction } from './useTransaction.mjs';
7
+ export { useWallet } from './useWallet.mjs';
8
+ export { useWallets } from './useWallets.mjs';
9
+ export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.mjs';
10
+ import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
11
+ import { App } from 'vue';
12
+ import '@solana/web3-compat';
76
13
 
77
14
  interface VueSolanaPluginOptions extends SolanaConfig {
78
15
  wallet?: SolanaWallet | null;
@@ -82,5 +19,5 @@ declare function createSolanaPlugin(options?: VueSolanaPluginOptions): {
82
19
  };
83
20
  declare const VueSolana: typeof createSolanaPlugin;
84
21
 
85
- export { VueSolana, createSolanaPlugin, solanaInjectionKey, useBalance, useConnection, useRpc, useSignAndSendTransaction, useSolana, useTransaction, useWallet, useWallets };
86
- export type { SolanaConnectionStatus, VueSolanaContext, VueSolanaPluginOptions };
22
+ export { VueSolana, createSolanaPlugin };
23
+ export type { VueSolanaPluginOptions };