@vue-solana/vue 2.0.0 → 2.2.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.
- package/README.md +210 -21
- package/dist/index.cjs +60 -20
- package/dist/index.d.cts +26 -5
- package/dist/index.d.mts +26 -5
- package/dist/index.d.ts +26 -5
- package/dist/index.mjs +38 -19
- package/dist/shared/vue.5euWd6-V.mjs +59 -0
- package/dist/shared/vue.9TPxZPMf.cjs +59 -0
- package/dist/shared/vue.B4-LEdSE.cjs +102 -0
- package/dist/shared/{vue.CP1DPDX9.cjs → vue.B6ainw2G.cjs} +1 -1
- package/dist/shared/vue.B8LptjZP.mjs +32 -0
- package/dist/shared/vue.B8VvC8d2.mjs +101 -0
- package/dist/shared/{vue.DP7qY8Rk.mjs → vue.BD6Gm1nl.mjs} +2 -2
- package/dist/shared/vue.BDNOyiGZ.mjs +109 -0
- package/dist/shared/{vue.BAlo-tIh.cjs → vue.BGxz4dru.cjs} +5 -1
- package/dist/shared/{vue.stUBDBI9.mjs → vue.BINkrA8h.mjs} +2 -2
- package/dist/shared/{vue.k9Q6aN-0.cjs → vue.BIxphCAq.cjs} +1 -1
- package/dist/shared/{vue.yQcL1yMv.mjs → vue.BOpgWr43.mjs} +2 -2
- package/dist/shared/{vue.dPRo2X5y.mjs → vue.BQRpjwKl.mjs} +2 -2
- package/dist/shared/vue.BSfiHqwj.mjs +34 -0
- package/dist/shared/{vue.CZwftA0L.cjs → vue.BVaMoz9y.cjs} +1 -1
- package/dist/shared/vue.BY0qpgYr.cjs +35 -0
- package/dist/shared/vue.Bk5xjlUx.cjs +61 -0
- package/dist/shared/{vue.3VLZmw05.mjs → vue.BsGwt78R.mjs} +1 -1
- package/dist/shared/{vue.B_LRH8SM.cjs → vue.Bwd1sGAM.cjs} +2 -2
- package/dist/shared/vue.ByxbBC3y.mjs +57 -0
- package/dist/shared/{vue.BbMPRDeO.mjs → vue.C13umiQi.mjs} +2 -2
- package/dist/shared/vue.C5FVoEZT.mjs +99 -0
- package/dist/shared/vue.CATOh_9G.mjs +42 -0
- package/dist/shared/{vue.XQFqlMId.cjs → vue.CIs8QhCw.cjs} +2 -2
- package/dist/shared/vue.CMohL_Cz.mjs +58 -0
- package/dist/shared/{vue.CnUlZSe8.mjs → vue.CQh3AUE8.mjs} +2 -5
- package/dist/shared/vue.CTqPbvz3.cjs +36 -0
- package/dist/shared/{vue.CSJSK0Nq.cjs → vue.CWZSMVnB.cjs} +3 -3
- package/dist/shared/{vue.DL-yMCNc.mjs → vue.CXB4NEMA.mjs} +2 -2
- package/dist/shared/{vue.D7xFeC2m.mjs → vue.C_4qJDiF.mjs} +1 -1
- package/dist/shared/vue.CbJFnho-.mjs +171 -0
- package/dist/shared/vue.CoaIWGPT.cjs +38 -0
- package/dist/shared/{vue.ChujsB0B.mjs → vue.CpkwC8Th.mjs} +1 -1
- package/dist/shared/vue.CrkK_T15.cjs +86 -0
- package/dist/shared/{vue.BMencBpI.cjs → vue.D-qi8PSL.cjs} +2 -2
- package/dist/shared/{vue.PJjEncbP.mjs → vue.D218Ow7t.mjs} +6 -2
- package/dist/shared/{vue.B2sFJ1xI.mjs → vue.D3Y0PWbF.mjs} +1 -1
- package/dist/shared/vue.D5U1yLG3.mjs +83 -0
- package/dist/shared/{vue.CXHYdyKZ.cjs → vue.DAg5wC1G.cjs} +2 -2
- package/dist/shared/vue.DDbVk0Zh.cjs +180 -0
- package/dist/shared/{vue.BaR1VPhl.cjs → vue.DE3emjSF.cjs} +2 -6
- package/dist/shared/vue.DEHxNvUX.cjs +7 -0
- package/dist/shared/vue.DFaMJLAQ.cjs +60 -0
- package/dist/shared/{vue.DgCmU1RR.cjs → vue.DKyQ7J67.cjs} +1 -1
- package/dist/shared/vue.DXQVIRZA.mjs +174 -0
- package/dist/shared/vue.DYk0Xfr3.mjs +36 -0
- package/dist/shared/vue.D_P5SqqD.mjs +5 -0
- package/dist/shared/{vue.C7yR7Cs0.cjs → vue.Di7yjJ-R.cjs} +2 -2
- package/dist/shared/vue.DxM45azl.cjs +173 -0
- package/dist/shared/{vue.WugzPOca.mjs → vue.Dyi1OCI1.mjs} +3 -3
- package/dist/shared/{vue.CEn2purG.cjs → vue.E_npPFoV.cjs} +2 -2
- package/dist/shared/{vue.__r7YYZE.cjs → vue.FiMmnMHr.cjs} +1 -1
- package/dist/shared/{vue.CZO8TwJP.mjs → vue.JUWqu6kD.mjs} +1 -1
- package/dist/shared/{vue.BaFrF2PF.mjs → vue.Mxc8w6Qk.mjs} +1 -1
- package/dist/shared/{vue.C32ozdA1.cjs → vue.Sbbm9JSu.cjs} +1 -1
- package/dist/shared/vue.ZuUCEEab.cjs +103 -0
- package/dist/shared/vue.g8fnm_ca.cjs +45 -0
- package/dist/shared/vue.l3UCdN7z.cjs +111 -0
- package/dist/swr.cjs +136 -0
- package/dist/swr.d.cts +41 -0
- package/dist/swr.d.mts +41 -0
- package/dist/swr.d.ts +41 -0
- package/dist/swr.mjs +131 -0
- package/dist/useAccountInfo.cjs +5 -4
- package/dist/useAccountInfo.mjs +5 -4
- package/dist/useAction.cjs +9 -0
- package/dist/useAction.d.cts +45 -0
- package/dist/useAction.d.mts +45 -0
- package/dist/useAction.d.ts +45 -0
- package/dist/useAction.mjs +3 -0
- package/dist/useAirdrop.cjs +14 -0
- package/dist/useAirdrop.d.cts +25 -0
- package/dist/useAirdrop.d.mts +25 -0
- package/dist/useAirdrop.d.ts +25 -0
- package/dist/useAirdrop.mjs +8 -0
- package/dist/useBalance.cjs +5 -4
- package/dist/useBalance.mjs +5 -4
- package/dist/useClientCapability.cjs +12 -0
- package/dist/useClientCapability.d.cts +39 -0
- package/dist/useClientCapability.d.mts +39 -0
- package/dist/useClientCapability.d.ts +39 -0
- package/dist/useClientCapability.mjs +5 -0
- package/dist/useConnection.cjs +4 -3
- package/dist/useConnection.d.cts +3 -2
- package/dist/useConnection.d.mts +3 -2
- package/dist/useConnection.d.ts +3 -2
- package/dist/useConnection.mjs +4 -3
- package/dist/useIdentity.cjs +12 -0
- package/dist/useIdentity.d.cts +3 -0
- package/dist/useIdentity.d.mts +3 -0
- package/dist/useIdentity.d.ts +3 -0
- package/dist/useIdentity.mjs +6 -0
- package/dist/usePayer.cjs +13 -0
- package/dist/usePayer.d.cts +18 -0
- package/dist/usePayer.d.mts +18 -0
- package/dist/usePayer.d.ts +18 -0
- package/dist/usePayer.mjs +6 -0
- package/dist/usePlanTransaction.cjs +14 -0
- package/dist/usePlanTransaction.d.cts +37 -0
- package/dist/usePlanTransaction.d.mts +37 -0
- package/dist/usePlanTransaction.d.ts +37 -0
- package/dist/usePlanTransaction.mjs +7 -0
- package/dist/usePlanTransactions.cjs +13 -0
- package/dist/usePlanTransactions.d.cts +4 -0
- package/dist/usePlanTransactions.d.mts +4 -0
- package/dist/usePlanTransactions.d.ts +4 -0
- package/dist/usePlanTransactions.mjs +7 -0
- package/dist/useProgramAccounts.cjs +5 -4
- package/dist/useProgramAccounts.mjs +5 -4
- package/dist/useRequest.cjs +11 -0
- package/dist/useRequest.d.cts +73 -0
- package/dist/useRequest.d.mts +73 -0
- package/dist/useRequest.d.ts +73 -0
- package/dist/useRequest.mjs +5 -0
- package/dist/useRpc.cjs +3 -2
- package/dist/useRpc.d.cts +3 -2
- package/dist/useRpc.d.mts +3 -2
- package/dist/useRpc.d.ts +3 -2
- package/dist/useRpc.mjs +3 -2
- package/dist/useSelectedWalletAccount.cjs +13 -0
- package/dist/useSelectedWalletAccount.d.cts +117 -0
- package/dist/useSelectedWalletAccount.d.mts +117 -0
- package/dist/useSelectedWalletAccount.d.ts +117 -0
- package/dist/useSelectedWalletAccount.mjs +3 -0
- package/dist/useSignAndSendTransaction.cjs +7 -6
- package/dist/useSignAndSendTransaction.mjs +7 -6
- package/dist/useSignAndSendTransactions.cjs +15 -0
- package/dist/useSignAndSendTransactions.d.cts +35 -0
- package/dist/useSignAndSendTransactions.d.mts +35 -0
- package/dist/useSignAndSendTransactions.d.ts +35 -0
- package/dist/useSignAndSendTransactions.mjs +8 -0
- package/dist/useSignIn.cjs +13 -0
- package/dist/useSignIn.d.cts +23 -0
- package/dist/useSignIn.d.mts +23 -0
- package/dist/useSignIn.d.ts +23 -0
- package/dist/useSignIn.mjs +7 -0
- package/dist/useSignMessage.cjs +4 -3
- package/dist/useSignMessage.mjs +4 -3
- package/dist/useSignTransactions.cjs +13 -0
- package/dist/useSignTransactions.d.cts +24 -0
- package/dist/useSignTransactions.d.mts +24 -0
- package/dist/useSignTransactions.d.ts +24 -0
- package/dist/useSignTransactions.mjs +7 -0
- package/dist/useSignatureStatus.cjs +5 -4
- package/dist/useSignatureStatus.mjs +5 -4
- package/dist/useSolana.cjs +2 -1
- package/dist/useSolana.mjs +2 -1
- package/dist/useSolanaClient.cjs +3 -2
- package/dist/useSolanaClient.d.cts +3 -2
- package/dist/useSolanaClient.d.mts +3 -2
- package/dist/useSolanaClient.d.ts +3 -2
- package/dist/useSolanaClient.mjs +3 -2
- package/dist/useSubscription.cjs +9 -0
- package/dist/useSubscription.d.cts +70 -0
- package/dist/useSubscription.d.mts +70 -0
- package/dist/useSubscription.d.ts +70 -0
- package/dist/useSubscription.mjs +3 -0
- package/dist/useTokenAccounts.cjs +5 -4
- package/dist/useTokenAccounts.mjs +5 -4
- package/dist/useTokenBalance.cjs +5 -4
- package/dist/useTokenBalance.mjs +5 -4
- package/dist/useTrackedData.cjs +10 -0
- package/dist/useTrackedData.d.cts +98 -0
- package/dist/useTrackedData.d.mts +98 -0
- package/dist/useTrackedData.d.ts +98 -0
- package/dist/useTrackedData.mjs +4 -0
- package/dist/useTransaction.cjs +2 -1
- package/dist/useTransaction.d.cts +12 -1
- package/dist/useTransaction.d.mts +12 -1
- package/dist/useTransaction.d.ts +12 -1
- package/dist/useTransaction.mjs +2 -1
- package/dist/useTransactionConfirmation.cjs +5 -4
- package/dist/useTransactionConfirmation.mjs +5 -4
- package/dist/useWallet.cjs +3 -2
- package/dist/useWallet.mjs +3 -2
- package/dist/useWallets.cjs +3 -2
- package/dist/useWallets.mjs +3 -2
- package/package.json +78 -3
- package/dist/shared/vue.C4d2JA8U.mjs +0 -44
- package/dist/shared/vue.CE5i8KZZ.cjs +0 -46
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
|
-
export { u as useAccountInfo } from './shared/vue.
|
|
2
|
-
export { u as
|
|
3
|
-
export { u as
|
|
4
|
-
export { u as
|
|
5
|
-
export { u as
|
|
6
|
-
export { u as
|
|
7
|
-
export { u as
|
|
8
|
-
export { u as
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
export { u as
|
|
12
|
-
export { u as
|
|
13
|
-
export { u as
|
|
14
|
-
export { u as
|
|
15
|
-
export {
|
|
16
|
-
export { u as
|
|
17
|
-
export { u as
|
|
1
|
+
export { u as useAccountInfo } from './shared/vue.BQRpjwKl.mjs';
|
|
2
|
+
export { u as useAction } from './shared/vue.DYk0Xfr3.mjs';
|
|
3
|
+
export { u as useAirdrop } from './shared/vue.BSfiHqwj.mjs';
|
|
4
|
+
export { u as useBalance } from './shared/vue.BINkrA8h.mjs';
|
|
5
|
+
export { M as MissingClientCapabilityError, u as useClientCapability } from './shared/vue.B8LptjZP.mjs';
|
|
6
|
+
export { u as useConnection } from './shared/vue.CpkwC8Th.mjs';
|
|
7
|
+
export { u as usePlanTransaction, a as usePlanTransactions } from './shared/vue.C5FVoEZT.mjs';
|
|
8
|
+
export { u as useProgramAccounts } from './shared/vue.C13umiQi.mjs';
|
|
9
|
+
export { u as useIdentity, a as usePayer } from './shared/vue.CATOh_9G.mjs';
|
|
10
|
+
export { u as useRequest } from './shared/vue.B8VvC8d2.mjs';
|
|
11
|
+
export { u as useRpc } from './shared/vue.BsGwt78R.mjs';
|
|
12
|
+
export { S as SelectedWalletAccountProvider, c as createSelectedWalletAccountContext, p as provideSelectedWalletAccount, s as selectedWalletAccountInjectionKey, u as useSelectedWalletAccount } from './shared/vue.DXQVIRZA.mjs';
|
|
13
|
+
export { u as useSignMessage } from './shared/vue.JUWqu6kD.mjs';
|
|
14
|
+
export { u as useSignAndSendTransaction } from './shared/vue.Dyi1OCI1.mjs';
|
|
15
|
+
export { u as useSignTransactions } from './shared/vue.CMohL_Cz.mjs';
|
|
16
|
+
export { P as PartialSignAndSendError, u as useSignAndSendTransactions } from './shared/vue.D5U1yLG3.mjs';
|
|
17
|
+
export { u as useSignatureStatus } from './shared/vue.CXB4NEMA.mjs';
|
|
18
|
+
export { u as useSignIn } from './shared/vue.ByxbBC3y.mjs';
|
|
19
|
+
export { t as tryUseSolana, u as useSolana } from './shared/vue.CQh3AUE8.mjs';
|
|
20
|
+
export { u as useSolanaClient } from './shared/vue.Mxc8w6Qk.mjs';
|
|
21
|
+
export { u as useSubscription } from './shared/vue.BDNOyiGZ.mjs';
|
|
22
|
+
export { u as useTokenAccounts } from './shared/vue.BOpgWr43.mjs';
|
|
23
|
+
export { u as useTokenBalance } from './shared/vue.BD6Gm1nl.mjs';
|
|
24
|
+
export { u as useTrackedData } from './shared/vue.CbJFnho-.mjs';
|
|
25
|
+
export { u as useTransaction } from './shared/vue.5euWd6-V.mjs';
|
|
26
|
+
export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.D3Y0PWbF.mjs';
|
|
27
|
+
export { u as useWallet } from './shared/vue.D218Ow7t.mjs';
|
|
28
|
+
export { u as useWallets } from './shared/vue.C_4qJDiF.mjs';
|
|
29
|
+
import { s as solanaInjectionKey } from './shared/vue.D_P5SqqD.mjs';
|
|
18
30
|
export { address, createSolanaClient, lamports } from '@vue-solana/core/kit';
|
|
19
31
|
import { createSolanaError, normalizeSolanaError } from '@vue-solana/core/errors';
|
|
20
32
|
import { createSolanaContext } from '@vue-solana/core/rpc';
|
|
@@ -24,6 +36,7 @@ import { shallowRef, ref, triggerRef } from 'vue';
|
|
|
24
36
|
import { handleSolanaIosWalletCallback, getSolanaIosWallets, isSolanaIosWalletInfo, adaptSolanaIosWallet } from '@vue-solana/core/ios-wallet';
|
|
25
37
|
import '@vue-solana/core/address';
|
|
26
38
|
import './shared/vue.Bfu1dCKe.mjs';
|
|
39
|
+
import '@vue-solana/core/action';
|
|
27
40
|
import '@vue-solana/core/wallet';
|
|
28
41
|
import '@vue-solana/core/transaction';
|
|
29
42
|
import 'bs58';
|
|
@@ -154,7 +167,10 @@ function createSolanaWalletRegistry(options) {
|
|
|
154
167
|
signMessage: adaptedWallet.signMessage?.bind(adaptedWallet),
|
|
155
168
|
signTransaction: adaptedWallet.signTransaction?.bind(adaptedWallet),
|
|
156
169
|
signAllTransactions: adaptedWallet.signAllTransactions?.bind(adaptedWallet),
|
|
157
|
-
signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet)
|
|
170
|
+
signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet),
|
|
171
|
+
signIn: adaptedWallet.signIn?.bind(adaptedWallet),
|
|
172
|
+
signTransactions: adaptedWallet.signTransactions?.bind(adaptedWallet),
|
|
173
|
+
signAndSendTransactions: adaptedWallet.signAndSendTransactions?.bind(adaptedWallet)
|
|
158
174
|
};
|
|
159
175
|
adaptedWallets.set(walletInfo.wallet, cachedAdapter);
|
|
160
176
|
return cachedAdapter;
|
|
@@ -198,7 +214,8 @@ function isObject(value) {
|
|
|
198
214
|
|
|
199
215
|
const RPC_CHECK_TIMEOUT_MS = 1e4;
|
|
200
216
|
function createSolanaPlugin(options = {}) {
|
|
201
|
-
|
|
217
|
+
const plugin = {
|
|
218
|
+
context: null,
|
|
202
219
|
install(app) {
|
|
203
220
|
const context = createSolanaContext(options);
|
|
204
221
|
const wallet = shallowRef(options.wallet ?? null);
|
|
@@ -346,6 +363,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
346
363
|
}
|
|
347
364
|
};
|
|
348
365
|
app.provide(solanaInjectionKey, vueContext);
|
|
366
|
+
plugin.context = vueContext;
|
|
349
367
|
if (typeof window !== "undefined") {
|
|
350
368
|
window.setTimeout(() => {
|
|
351
369
|
try {
|
|
@@ -358,6 +376,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
358
376
|
}
|
|
359
377
|
}
|
|
360
378
|
};
|
|
379
|
+
return plugin;
|
|
361
380
|
}
|
|
362
381
|
function isSameWallet(wallet, selectedWallet) {
|
|
363
382
|
return wallet.name === selectedWallet?.name && wallet.source === selectedWallet.source && wallet.platform === selectedWallet.platform;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createSolanaActionStore, isSolanaActionAborted } from '@vue-solana/core/action';
|
|
2
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
|
+
import { withSolanaTimeout } from '@vue-solana/core/timeout';
|
|
4
|
+
import { shallowRef, ref, getCurrentScope, onScopeDispose } from 'vue';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_TIMEOUT_MESSAGE = "Transaction did not return a result before timing out.";
|
|
7
|
+
function useTransaction(handler, options = {}) {
|
|
8
|
+
const signature = shallowRef(null);
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const store = createSolanaActionStore(async (_signal, ...args) => {
|
|
12
|
+
const attempt = withSolanaTimeout(
|
|
13
|
+
handler(...args),
|
|
14
|
+
options.timeoutMs,
|
|
15
|
+
options.timeoutMessage ?? DEFAULT_TIMEOUT_MESSAGE
|
|
16
|
+
);
|
|
17
|
+
attempt.catch(() => void 0);
|
|
18
|
+
return attempt;
|
|
19
|
+
});
|
|
20
|
+
const unsubscribe = store.subscribe(() => {
|
|
21
|
+
const state = store.getState();
|
|
22
|
+
if (state.status === "running") {
|
|
23
|
+
loading.value = true;
|
|
24
|
+
} else if (state.status === "success") {
|
|
25
|
+
signature.value = state.data;
|
|
26
|
+
loading.value = false;
|
|
27
|
+
error.value = null;
|
|
28
|
+
} else if (state.status === "error") {
|
|
29
|
+
error.value = normalizeSolanaError(state.error, "RPC_FAILURE");
|
|
30
|
+
loading.value = false;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (getCurrentScope()) {
|
|
34
|
+
onScopeDispose(() => {
|
|
35
|
+
unsubscribe();
|
|
36
|
+
store.reset();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function execute(...args) {
|
|
40
|
+
loading.value = true;
|
|
41
|
+
error.value = null;
|
|
42
|
+
try {
|
|
43
|
+
return await store.dispatchAsync(...args);
|
|
44
|
+
} catch (cause) {
|
|
45
|
+
if (isSolanaActionAborted(cause)) {
|
|
46
|
+
throw cause;
|
|
47
|
+
}
|
|
48
|
+
throw normalizeSolanaError(cause, "RPC_FAILURE");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
signature,
|
|
53
|
+
loading,
|
|
54
|
+
error,
|
|
55
|
+
execute
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { useTransaction as u };
|
|
@@ -0,0 +1,59 @@
|
|
|
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 useSignIn() {
|
|
9
|
+
const { wallet: wallet$1 } = useWallet.useWallet();
|
|
10
|
+
const signInResult = 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 signIn(input) {
|
|
16
|
+
const currentExecutionId = ++executionId;
|
|
17
|
+
status.value = "signing-in";
|
|
18
|
+
loading.value = true;
|
|
19
|
+
error.value = null;
|
|
20
|
+
signInResult.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.assertWalletCanSignIn(activeWallet);
|
|
31
|
+
const result = await activeWallet.signIn(input);
|
|
32
|
+
if (currentExecutionId === executionId) {
|
|
33
|
+
signInResult.value = result;
|
|
34
|
+
status.value = "signed-in";
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
} catch (cause) {
|
|
38
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
39
|
+
if (currentExecutionId === executionId) {
|
|
40
|
+
error.value = normalizedError;
|
|
41
|
+
status.value = "error";
|
|
42
|
+
}
|
|
43
|
+
throw normalizedError;
|
|
44
|
+
} finally {
|
|
45
|
+
if (currentExecutionId === executionId) {
|
|
46
|
+
loading.value = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
signInResult,
|
|
52
|
+
status,
|
|
53
|
+
loading,
|
|
54
|
+
error,
|
|
55
|
+
signIn
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.useSignIn = useSignIn;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const errors = require('@vue-solana/core/errors');
|
|
4
|
+
const vue = require('vue');
|
|
5
|
+
const useClientCapability = require('./vue.BY0qpgYr.cjs');
|
|
6
|
+
const useSolanaClient = require('./vue.BIxphCAq.cjs');
|
|
7
|
+
|
|
8
|
+
function usePlanTransaction() {
|
|
9
|
+
useClientCapability.useClientCapability(["planTransaction"], {
|
|
10
|
+
hookName: "usePlanTransaction",
|
|
11
|
+
providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
|
|
12
|
+
});
|
|
13
|
+
const { client } = useSolanaClient.useSolanaClient();
|
|
14
|
+
const transactionMessage = vue.shallowRef(null);
|
|
15
|
+
const status = vue.ref("idle");
|
|
16
|
+
const loading = vue.ref(false);
|
|
17
|
+
const error = vue.ref(null);
|
|
18
|
+
let executionId = 0;
|
|
19
|
+
async function execute(input, config) {
|
|
20
|
+
const currentExecutionId = ++executionId;
|
|
21
|
+
const planner = client;
|
|
22
|
+
status.value = "planning";
|
|
23
|
+
loading.value = true;
|
|
24
|
+
error.value = null;
|
|
25
|
+
transactionMessage.value = null;
|
|
26
|
+
try {
|
|
27
|
+
const message = await planner.planTransaction(input, config);
|
|
28
|
+
if (currentExecutionId === executionId) {
|
|
29
|
+
transactionMessage.value = message;
|
|
30
|
+
status.value = "planned";
|
|
31
|
+
}
|
|
32
|
+
return message;
|
|
33
|
+
} catch (cause) {
|
|
34
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
35
|
+
if (currentExecutionId === executionId) {
|
|
36
|
+
error.value = normalizedError;
|
|
37
|
+
status.value = "error";
|
|
38
|
+
}
|
|
39
|
+
throw normalizedError;
|
|
40
|
+
} finally {
|
|
41
|
+
if (currentExecutionId === executionId) {
|
|
42
|
+
loading.value = false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
transactionMessage,
|
|
48
|
+
status,
|
|
49
|
+
loading,
|
|
50
|
+
error,
|
|
51
|
+
execute
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function usePlanTransactions() {
|
|
55
|
+
useClientCapability.useClientCapability(["planTransactions"], {
|
|
56
|
+
hookName: "usePlanTransactions",
|
|
57
|
+
providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
|
|
58
|
+
});
|
|
59
|
+
const { client } = useSolanaClient.useSolanaClient();
|
|
60
|
+
const transactionPlan = vue.shallowRef(null);
|
|
61
|
+
const status = vue.ref("idle");
|
|
62
|
+
const loading = vue.ref(false);
|
|
63
|
+
const error = vue.ref(null);
|
|
64
|
+
let executionId = 0;
|
|
65
|
+
async function execute(input, config) {
|
|
66
|
+
const currentExecutionId = ++executionId;
|
|
67
|
+
const planner = client;
|
|
68
|
+
status.value = "planning";
|
|
69
|
+
loading.value = true;
|
|
70
|
+
error.value = null;
|
|
71
|
+
transactionPlan.value = null;
|
|
72
|
+
try {
|
|
73
|
+
const plan = await planner.planTransactions(input, config);
|
|
74
|
+
if (currentExecutionId === executionId) {
|
|
75
|
+
transactionPlan.value = plan;
|
|
76
|
+
status.value = "planned";
|
|
77
|
+
}
|
|
78
|
+
return plan;
|
|
79
|
+
} catch (cause) {
|
|
80
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
81
|
+
if (currentExecutionId === executionId) {
|
|
82
|
+
error.value = normalizedError;
|
|
83
|
+
status.value = "error";
|
|
84
|
+
}
|
|
85
|
+
throw normalizedError;
|
|
86
|
+
} finally {
|
|
87
|
+
if (currentExecutionId === executionId) {
|
|
88
|
+
loading.value = false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
transactionPlan,
|
|
94
|
+
status,
|
|
95
|
+
loading,
|
|
96
|
+
error,
|
|
97
|
+
execute
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
exports.usePlanTransaction = usePlanTransaction;
|
|
102
|
+
exports.usePlanTransactions = usePlanTransactions;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const errors = require('@vue-solana/core/errors');
|
|
4
4
|
const wallet = require('@vue-solana/core/wallet');
|
|
5
5
|
const vue = require('vue');
|
|
6
|
-
const useWallet = require('./vue.
|
|
6
|
+
const useWallet = require('./vue.BGxz4dru.cjs');
|
|
7
7
|
|
|
8
8
|
function useSignMessage() {
|
|
9
9
|
const { wallet: wallet$1 } = useWallet.useWallet();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
2
|
+
|
|
3
|
+
class MissingClientCapabilityError extends Error {
|
|
4
|
+
/** Name of the hook that requested the capability, e.g. `usePayer`. */
|
|
5
|
+
hookName;
|
|
6
|
+
/** Human guidance for installing the capability on the client. */
|
|
7
|
+
providerHint;
|
|
8
|
+
/** The missing capability name(s). */
|
|
9
|
+
capabilities;
|
|
10
|
+
constructor(hookName, capabilities, providerHint) {
|
|
11
|
+
super(
|
|
12
|
+
`${hookName} requires the ${capabilities.map((capability) => `\`${capability}\``).join(" and ")} capabilit${capabilities.length === 1 ? "y" : "ies"} on the Solana client, but none ${capabilities.length === 1 ? "was" : "were"} found. ` + providerHint
|
|
13
|
+
);
|
|
14
|
+
this.name = "MissingClientCapabilityError";
|
|
15
|
+
this.hookName = hookName;
|
|
16
|
+
this.capabilities = capabilities;
|
|
17
|
+
this.providerHint = providerHint;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function useClientCapability(capability, options = {}) {
|
|
21
|
+
const capabilities = Array.isArray(capability) ? [...capability] : [capability];
|
|
22
|
+
const hookName = options.hookName ?? "useClientCapability";
|
|
23
|
+
const providerHint = options.providerHint ?? "Install it by adding the corresponding @solana/kit plugin with `createClient().use(...)`.";
|
|
24
|
+
const { client } = useSolanaClient();
|
|
25
|
+
for (const name of capabilities) {
|
|
26
|
+
if (typeof client[name] === "undefined") {
|
|
27
|
+
throw new MissingClientCapabilityError(hookName, [name], providerHint);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { MissingClientCapabilityError as M, useClientCapability as u };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createSolanaActionStore } from '@vue-solana/core/action';
|
|
2
|
+
import { getAbortablePromise } from '@vue-solana/core/kit';
|
|
3
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
4
|
+
import { shallowRef, onScopeDispose, watch, isRef, onMounted, getCurrentInstance, computed } from 'vue';
|
|
5
|
+
|
|
6
|
+
function useRequest(source, options = {}) {
|
|
7
|
+
const data = shallowRef(void 0);
|
|
8
|
+
const error = shallowRef(null);
|
|
9
|
+
const status = shallowRef("fetching");
|
|
10
|
+
let disposed = false;
|
|
11
|
+
let attempt = 0;
|
|
12
|
+
const store = createSolanaActionStore(async (signal, resolved, override) => {
|
|
13
|
+
attempt += 1;
|
|
14
|
+
const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(attempt);
|
|
15
|
+
const composedSignal = callerSignal ? AbortSignal.any([signal, callerSignal]) : signal;
|
|
16
|
+
let pending;
|
|
17
|
+
if (isSendSource(resolved)) {
|
|
18
|
+
pending = Promise.resolve(resolved.send({ abortSignal: composedSignal }));
|
|
19
|
+
} else if (typeof resolved === "function") {
|
|
20
|
+
pending = Promise.resolve(resolved(composedSignal)).then(
|
|
21
|
+
(result) => isSendSource(result) ? result.send({ abortSignal: composedSignal }) : result
|
|
22
|
+
);
|
|
23
|
+
} else {
|
|
24
|
+
throw new Error("useRequest source did not resolve to a request function");
|
|
25
|
+
}
|
|
26
|
+
return getAbortablePromise(pending, composedSignal);
|
|
27
|
+
});
|
|
28
|
+
const unsubscribe = store.subscribe(() => {
|
|
29
|
+
const next = store.getState();
|
|
30
|
+
if (next.status === "success") {
|
|
31
|
+
data.value = next.data;
|
|
32
|
+
error.value = null;
|
|
33
|
+
status.value = "success";
|
|
34
|
+
} else if (next.status === "error") {
|
|
35
|
+
error.value = normalizeSolanaError(next.error, "RPC_FAILURE");
|
|
36
|
+
status.value = "error";
|
|
37
|
+
} else if (next.status === "running") {
|
|
38
|
+
status.value = "fetching";
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
onScopeDispose(() => {
|
|
42
|
+
disposed = true;
|
|
43
|
+
unsubscribe();
|
|
44
|
+
store.reset();
|
|
45
|
+
});
|
|
46
|
+
function unwrapSource() {
|
|
47
|
+
if (isRef(source)) {
|
|
48
|
+
return source.value;
|
|
49
|
+
}
|
|
50
|
+
return source;
|
|
51
|
+
}
|
|
52
|
+
async function run(override) {
|
|
53
|
+
if (disposed) {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
const resolved = unwrapSource();
|
|
57
|
+
if (isDisabled(resolved)) {
|
|
58
|
+
data.value = void 0;
|
|
59
|
+
error.value = null;
|
|
60
|
+
status.value = "disabled";
|
|
61
|
+
store.reset();
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
status.value = "fetching";
|
|
65
|
+
try {
|
|
66
|
+
return await store.dispatchAsync(resolved, override);
|
|
67
|
+
} catch (cause) {
|
|
68
|
+
if (store.getState().status !== "error") {
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
throw normalizeSolanaError(cause, "RPC_FAILURE");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const refresh = (options2) => run(options2);
|
|
75
|
+
watch(
|
|
76
|
+
() => isRef(source) ? source.value : source,
|
|
77
|
+
() => {
|
|
78
|
+
void refresh().catch(() => void 0);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
onMounted(() => {
|
|
82
|
+
void refresh().catch(() => void 0);
|
|
83
|
+
});
|
|
84
|
+
if (!getCurrentInstance()) {
|
|
85
|
+
void refresh().catch(() => void 0);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
data: computed(() => data.value),
|
|
89
|
+
error: computed(() => error.value),
|
|
90
|
+
refresh,
|
|
91
|
+
status: computed(() => status.value)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function isDisabled(resolved) {
|
|
95
|
+
return resolved === null || resolved === void 0;
|
|
96
|
+
}
|
|
97
|
+
function isSendSource(resolved) {
|
|
98
|
+
return typeof resolved === "object" && resolved !== null && "send" in resolved && typeof resolved.send === "function";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { useRequest as u };
|
|
@@ -2,8 +2,8 @@ import { getTokenBalance } from '@vue-solana/core/token-accounts';
|
|
|
2
2
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
3
|
import { parseAddress } from '@vue-solana/core/address';
|
|
4
4
|
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
5
|
-
import { u as useConnection } from './vue.
|
|
6
|
-
import { t as tryUseSolana } from './vue.
|
|
5
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
6
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
7
7
|
|
|
8
8
|
function useTokenBalance(mint, owner, commitment) {
|
|
9
9
|
const solana = tryUseSolana();
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { shallowRef, watch, isRef, onMounted, getCurrentInstance, onScopeDispose, computed } from 'vue';
|
|
3
|
+
|
|
4
|
+
function useSubscription(source, options = {}) {
|
|
5
|
+
const data = shallowRef(void 0);
|
|
6
|
+
const error = shallowRef(null);
|
|
7
|
+
const status = shallowRef("loading");
|
|
8
|
+
const disposables = [];
|
|
9
|
+
let connectionCount = 0;
|
|
10
|
+
let disposed = false;
|
|
11
|
+
let activeSource;
|
|
12
|
+
let activeStore;
|
|
13
|
+
function applyState(state) {
|
|
14
|
+
if (state.status === "loaded") {
|
|
15
|
+
data.value = state.data;
|
|
16
|
+
error.value = null;
|
|
17
|
+
status.value = "loaded";
|
|
18
|
+
} else if (state.status === "error") {
|
|
19
|
+
error.value = normalizeSolanaError(state.error, "RPC_FAILURE");
|
|
20
|
+
status.value = "error";
|
|
21
|
+
options.onError?.(state.error);
|
|
22
|
+
} else if (state.status === "loading") {
|
|
23
|
+
status.value = data.value === void 0 ? "loading" : status.value;
|
|
24
|
+
} else if (state.status === "idle") {
|
|
25
|
+
data.value = void 0;
|
|
26
|
+
error.value = null;
|
|
27
|
+
status.value = "loading";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function openConnection(store, override) {
|
|
31
|
+
activeStore = store;
|
|
32
|
+
connectionCount += 1;
|
|
33
|
+
const connection = connectionCount;
|
|
34
|
+
const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(connection);
|
|
35
|
+
applyState(store.getState());
|
|
36
|
+
disposables.push(
|
|
37
|
+
store.subscribe(() => {
|
|
38
|
+
applyState(store.getState());
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
if (callerSignal?.aborted) {
|
|
42
|
+
applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (callerSignal) {
|
|
46
|
+
store.withSignal(callerSignal).connect();
|
|
47
|
+
} else {
|
|
48
|
+
store.connect();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function disconnect() {
|
|
52
|
+
disposables.forEach((dispose) => {
|
|
53
|
+
dispose();
|
|
54
|
+
});
|
|
55
|
+
disposables.length = 0;
|
|
56
|
+
if (activeStore) {
|
|
57
|
+
activeStore.reset();
|
|
58
|
+
activeStore = void 0;
|
|
59
|
+
}
|
|
60
|
+
activeSource = void 0;
|
|
61
|
+
}
|
|
62
|
+
function connectCurrent(override) {
|
|
63
|
+
if (disposed) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const resolved = isRef(source) ? source.value : source;
|
|
67
|
+
if (resolved === null || resolved === void 0) {
|
|
68
|
+
disconnect();
|
|
69
|
+
data.value = void 0;
|
|
70
|
+
error.value = null;
|
|
71
|
+
status.value = "disabled";
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (activeSource === resolved && activeStore) {
|
|
75
|
+
openConnection(activeStore, override);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
disconnect();
|
|
79
|
+
activeSource = resolved;
|
|
80
|
+
openConnection(resolved.reactiveStore(), override);
|
|
81
|
+
}
|
|
82
|
+
watch(
|
|
83
|
+
() => isRef(source) ? source.value : source,
|
|
84
|
+
() => {
|
|
85
|
+
connectCurrent();
|
|
86
|
+
},
|
|
87
|
+
{ flush: "sync" }
|
|
88
|
+
);
|
|
89
|
+
onMounted(() => {
|
|
90
|
+
connectCurrent();
|
|
91
|
+
});
|
|
92
|
+
if (!getCurrentInstance()) {
|
|
93
|
+
connectCurrent();
|
|
94
|
+
}
|
|
95
|
+
onScopeDispose(() => {
|
|
96
|
+
disposed = true;
|
|
97
|
+
disconnect();
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
data: computed(() => data.value),
|
|
101
|
+
error: computed(() => error.value),
|
|
102
|
+
reconnect: (options2) => {
|
|
103
|
+
connectCurrent(options2);
|
|
104
|
+
},
|
|
105
|
+
status: computed(() => status.value)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { useSubscription as u };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const errors = require('@vue-solana/core/errors');
|
|
4
4
|
const wallet = require('@vue-solana/core/wallet');
|
|
5
5
|
const vue = require('vue');
|
|
6
|
-
const useSolana = require('./vue.
|
|
6
|
+
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
7
7
|
|
|
8
8
|
function useWallet() {
|
|
9
9
|
const solana = useSolana.useSolana();
|
|
@@ -11,6 +11,9 @@ function useWallet() {
|
|
|
11
11
|
const connecting = vue.ref(false);
|
|
12
12
|
const disconnecting = vue.ref(false);
|
|
13
13
|
async function connect() {
|
|
14
|
+
if (connecting.value || wallet$1.value?.connecting) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
14
17
|
const activeWallet = wallet$1.value;
|
|
15
18
|
if (!activeWallet) {
|
|
16
19
|
throw wallet.createNoWalletSelectedError();
|
|
@@ -20,6 +23,7 @@ function useWallet() {
|
|
|
20
23
|
const connection = activeWallet.connect();
|
|
21
24
|
vue.triggerRef(wallet$1);
|
|
22
25
|
await connection;
|
|
26
|
+
wallet.assertWalletConnected(activeWallet);
|
|
23
27
|
vue.triggerRef(wallet$1);
|
|
24
28
|
console.info("[Vue Solana] Wallet connected", {
|
|
25
29
|
publicKey: activeWallet.publicKey ?? null
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseAddress } from '@vue-solana/core/address';
|
|
2
2
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
3
|
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
4
|
-
import { u as useConnection } from './vue.
|
|
5
|
-
import { t as tryUseSolana } from './vue.
|
|
4
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
5
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
6
6
|
|
|
7
7
|
function useBalance(address, commitment) {
|
|
8
8
|
const solana = tryUseSolana();
|
|
@@ -2,8 +2,8 @@ import { getTokenAccountsByOwner } from '@vue-solana/core/token-accounts';
|
|
|
2
2
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
3
|
import { parseAddress } from '@vue-solana/core/address';
|
|
4
4
|
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
5
|
-
import { u as useConnection } from './vue.
|
|
6
|
-
import { t as tryUseSolana } from './vue.
|
|
5
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
6
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
7
7
|
|
|
8
8
|
function useTokenAccounts(owner, options) {
|
|
9
9
|
const solana = tryUseSolana();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
2
|
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
3
3
|
import { parseAddress } from '@vue-solana/core/address';
|
|
4
|
-
import { u as useConnection } from './vue.
|
|
5
|
-
import { t as tryUseSolana } from './vue.
|
|
4
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
5
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
6
6
|
import { d as decodeBase64 } from './vue.Bfu1dCKe.mjs';
|
|
7
7
|
|
|
8
8
|
function useAccountInfo(address, options = {}) {
|