@vue-solana/vue 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -21
- package/dist/index.cjs +58 -20
- package/dist/index.d.cts +25 -5
- package/dist/index.d.mts +25 -5
- package/dist/index.d.ts +25 -5
- package/dist/index.mjs +37 -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.B8pLQ8P4.cjs +105 -0
- package/dist/shared/vue.B8ub540p.mjs +109 -0
- package/dist/shared/{vue.DP7qY8Rk.mjs → vue.BD6Gm1nl.mjs} +2 -2
- 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.CZwftA0L.cjs → vue.BVaMoz9y.cjs} +1 -1
- package/dist/shared/vue.BVj9lWBK.cjs +111 -0
- 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.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.CoaIWGPT.cjs +38 -0
- package/dist/shared/vue.CogzzQXM.mjs +171 -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.DImwKTwJ.mjs +103 -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.DtCbCcPd.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.g8fnm_ca.cjs +45 -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/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.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 +57 -0
- package/dist/useRequest.d.mts +57 -0
- package/dist/useRequest.d.ts +57 -0
- package/dist/useRequest.mjs +5 -0
- package/dist/useRpc.cjs +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.mjs +3 -2
- package/dist/useSubscription.cjs +9 -0
- package/dist/useSubscription.d.cts +58 -0
- package/dist/useSubscription.d.mts +58 -0
- package/dist/useSubscription.d.ts +58 -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 +86 -0
- package/dist/useTrackedData.d.mts +86 -0
- package/dist/useTrackedData.d.ts +86 -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 +73 -3
- package/dist/shared/vue.C4d2JA8U.mjs +0 -44
- package/dist/shared/vue.CE5i8KZZ.cjs +0 -46
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const errors = require('@vue-solana/core/errors');
|
|
4
|
+
const vue = require('vue');
|
|
5
|
+
|
|
6
|
+
function useSubscription(source, options = {}) {
|
|
7
|
+
const data = vue.shallowRef(void 0);
|
|
8
|
+
const error = vue.shallowRef(null);
|
|
9
|
+
const status = vue.shallowRef("loading");
|
|
10
|
+
const disposables = [];
|
|
11
|
+
let connectionCount = 0;
|
|
12
|
+
let disposed = false;
|
|
13
|
+
let activeSource;
|
|
14
|
+
let activeStore;
|
|
15
|
+
function applyState(state) {
|
|
16
|
+
if (state.status === "loaded") {
|
|
17
|
+
data.value = state.data;
|
|
18
|
+
error.value = null;
|
|
19
|
+
status.value = "loaded";
|
|
20
|
+
} else if (state.status === "error") {
|
|
21
|
+
error.value = errors.normalizeSolanaError(state.error, "RPC_FAILURE");
|
|
22
|
+
status.value = "error";
|
|
23
|
+
options.onError?.(state.error);
|
|
24
|
+
} else if (state.status === "loading") {
|
|
25
|
+
status.value = data.value === void 0 ? "loading" : status.value;
|
|
26
|
+
} else if (state.status === "idle") {
|
|
27
|
+
data.value = void 0;
|
|
28
|
+
error.value = null;
|
|
29
|
+
status.value = "loading";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function openConnection(store) {
|
|
33
|
+
activeStore = store;
|
|
34
|
+
connectionCount += 1;
|
|
35
|
+
const connection = connectionCount;
|
|
36
|
+
const callerSignal = options.getAbortSignal?.(connection);
|
|
37
|
+
applyState(store.getState());
|
|
38
|
+
disposables.push(
|
|
39
|
+
store.subscribe(() => {
|
|
40
|
+
applyState(store.getState());
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
if (callerSignal?.aborted) {
|
|
44
|
+
applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (callerSignal) {
|
|
48
|
+
store.withSignal(callerSignal).connect();
|
|
49
|
+
} else {
|
|
50
|
+
store.connect();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function disconnect() {
|
|
54
|
+
disposables.forEach((dispose) => {
|
|
55
|
+
dispose();
|
|
56
|
+
});
|
|
57
|
+
disposables.length = 0;
|
|
58
|
+
if (activeStore) {
|
|
59
|
+
activeStore.reset();
|
|
60
|
+
activeStore = void 0;
|
|
61
|
+
}
|
|
62
|
+
activeSource = void 0;
|
|
63
|
+
}
|
|
64
|
+
function connectCurrent() {
|
|
65
|
+
if (disposed) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const resolved = vue.isRef(source) ? source.value : source;
|
|
69
|
+
if (resolved === null || resolved === void 0) {
|
|
70
|
+
disconnect();
|
|
71
|
+
data.value = void 0;
|
|
72
|
+
error.value = null;
|
|
73
|
+
status.value = "disabled";
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (activeSource === resolved && activeStore) {
|
|
77
|
+
openConnection(activeStore);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
disconnect();
|
|
81
|
+
activeSource = resolved;
|
|
82
|
+
openConnection(resolved.reactiveStore());
|
|
83
|
+
}
|
|
84
|
+
vue.watch(
|
|
85
|
+
() => vue.isRef(source) ? source.value : source,
|
|
86
|
+
() => {
|
|
87
|
+
connectCurrent();
|
|
88
|
+
},
|
|
89
|
+
{ flush: "sync" }
|
|
90
|
+
);
|
|
91
|
+
vue.onMounted(() => {
|
|
92
|
+
connectCurrent();
|
|
93
|
+
});
|
|
94
|
+
if (!vue.getCurrentInstance()) {
|
|
95
|
+
connectCurrent();
|
|
96
|
+
}
|
|
97
|
+
vue.onScopeDispose(() => {
|
|
98
|
+
disposed = true;
|
|
99
|
+
disconnect();
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
data: vue.computed(() => data.value),
|
|
103
|
+
error: vue.computed(() => error.value),
|
|
104
|
+
reconnect: () => {
|
|
105
|
+
connectCurrent();
|
|
106
|
+
},
|
|
107
|
+
status: vue.computed(() => status.value)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
exports.useSubscription = useSubscription;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const useSolanaClient = require('./vue.BIxphCAq.cjs');
|
|
4
|
+
|
|
5
|
+
class MissingClientCapabilityError extends Error {
|
|
6
|
+
/** Name of the hook that requested the capability, e.g. `usePayer`. */
|
|
7
|
+
hookName;
|
|
8
|
+
/** Human guidance for installing the capability on the client. */
|
|
9
|
+
providerHint;
|
|
10
|
+
/** The missing capability name(s). */
|
|
11
|
+
capabilities;
|
|
12
|
+
constructor(hookName, capabilities, providerHint) {
|
|
13
|
+
super(
|
|
14
|
+
`${hookName} requires the ${capabilities.map((capability) => `\`${capability}\``).join(" and ")} capabilit${capabilities.length === 1 ? "y" : "ies"} on the Solana client, but none ${capabilities.length === 1 ? "was" : "were"} found. ` + providerHint
|
|
15
|
+
);
|
|
16
|
+
this.name = "MissingClientCapabilityError";
|
|
17
|
+
this.hookName = hookName;
|
|
18
|
+
this.capabilities = capabilities;
|
|
19
|
+
this.providerHint = providerHint;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function useClientCapability(capability, options = {}) {
|
|
23
|
+
const capabilities = Array.isArray(capability) ? [...capability] : [capability];
|
|
24
|
+
const hookName = options.hookName ?? "useClientCapability";
|
|
25
|
+
const providerHint = options.providerHint ?? "Install it by adding the corresponding @solana/kit plugin with `createClient().use(...)`.";
|
|
26
|
+
const { client } = useSolanaClient.useSolanaClient();
|
|
27
|
+
for (const name of capabilities) {
|
|
28
|
+
if (typeof client[name] === "undefined") {
|
|
29
|
+
throw new MissingClientCapabilityError(hookName, [name], providerHint);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.MissingClientCapabilityError = MissingClientCapabilityError;
|
|
35
|
+
exports.useClientCapability = useClientCapability;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const action = require('@vue-solana/core/action');
|
|
4
|
+
const errors = require('@vue-solana/core/errors');
|
|
5
|
+
const timeout = require('@vue-solana/core/timeout');
|
|
6
|
+
const vue = require('vue');
|
|
7
|
+
|
|
8
|
+
const DEFAULT_TIMEOUT_MESSAGE = "Transaction did not return a result before timing out.";
|
|
9
|
+
function useTransaction(handler, options = {}) {
|
|
10
|
+
const signature = vue.shallowRef(null);
|
|
11
|
+
const loading = vue.ref(false);
|
|
12
|
+
const error = vue.ref(null);
|
|
13
|
+
const store = action.createSolanaActionStore(async (_signal, ...args) => {
|
|
14
|
+
const attempt = timeout.withSolanaTimeout(
|
|
15
|
+
handler(...args),
|
|
16
|
+
options.timeoutMs,
|
|
17
|
+
options.timeoutMessage ?? DEFAULT_TIMEOUT_MESSAGE
|
|
18
|
+
);
|
|
19
|
+
attempt.catch(() => void 0);
|
|
20
|
+
return attempt;
|
|
21
|
+
});
|
|
22
|
+
const unsubscribe = store.subscribe(() => {
|
|
23
|
+
const state = store.getState();
|
|
24
|
+
if (state.status === "running") {
|
|
25
|
+
loading.value = true;
|
|
26
|
+
} else if (state.status === "success") {
|
|
27
|
+
signature.value = state.data;
|
|
28
|
+
loading.value = false;
|
|
29
|
+
error.value = null;
|
|
30
|
+
} else if (state.status === "error") {
|
|
31
|
+
error.value = errors.normalizeSolanaError(state.error, "RPC_FAILURE");
|
|
32
|
+
loading.value = false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (vue.getCurrentScope()) {
|
|
36
|
+
vue.onScopeDispose(() => {
|
|
37
|
+
unsubscribe();
|
|
38
|
+
store.reset();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async function execute(...args) {
|
|
42
|
+
loading.value = true;
|
|
43
|
+
error.value = null;
|
|
44
|
+
try {
|
|
45
|
+
return await store.dispatchAsync(...args);
|
|
46
|
+
} catch (cause) {
|
|
47
|
+
if (action.isSolanaActionAborted(cause)) {
|
|
48
|
+
throw cause;
|
|
49
|
+
}
|
|
50
|
+
throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
signature,
|
|
55
|
+
loading,
|
|
56
|
+
error,
|
|
57
|
+
execute
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.useTransaction = useTransaction;
|
|
@@ -4,8 +4,8 @@ const tokenAccounts = require('@vue-solana/core/token-accounts');
|
|
|
4
4
|
const errors = require('@vue-solana/core/errors');
|
|
5
5
|
const address = require('@vue-solana/core/address');
|
|
6
6
|
const vue = require('vue');
|
|
7
|
-
const useConnection = require('./vue.
|
|
8
|
-
const useSolana = require('./vue.
|
|
7
|
+
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
8
|
+
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
9
9
|
|
|
10
10
|
function useTokenAccounts(owner, options) {
|
|
11
11
|
const solana = useSolana.tryUseSolana();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { createNoWalletSelectedError, assertWalletCanSignIn } from '@vue-solana/core/wallet';
|
|
3
|
+
import { shallowRef, ref } from 'vue';
|
|
4
|
+
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
5
|
+
|
|
6
|
+
function useSignIn() {
|
|
7
|
+
const { wallet } = useWallet();
|
|
8
|
+
const signInResult = shallowRef(null);
|
|
9
|
+
const status = ref("idle");
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
let executionId = 0;
|
|
13
|
+
async function signIn(input) {
|
|
14
|
+
const currentExecutionId = ++executionId;
|
|
15
|
+
status.value = "signing-in";
|
|
16
|
+
loading.value = true;
|
|
17
|
+
error.value = null;
|
|
18
|
+
signInResult.value = null;
|
|
19
|
+
const activeWallet = wallet.value;
|
|
20
|
+
if (!activeWallet) {
|
|
21
|
+
const normalizedError = createNoWalletSelectedError();
|
|
22
|
+
error.value = normalizedError;
|
|
23
|
+
status.value = "error";
|
|
24
|
+
loading.value = false;
|
|
25
|
+
throw normalizedError;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
assertWalletCanSignIn(activeWallet);
|
|
29
|
+
const result = await activeWallet.signIn(input);
|
|
30
|
+
if (currentExecutionId === executionId) {
|
|
31
|
+
signInResult.value = result;
|
|
32
|
+
status.value = "signed-in";
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
} catch (cause) {
|
|
36
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
37
|
+
if (currentExecutionId === executionId) {
|
|
38
|
+
error.value = normalizedError;
|
|
39
|
+
status.value = "error";
|
|
40
|
+
}
|
|
41
|
+
throw normalizedError;
|
|
42
|
+
} finally {
|
|
43
|
+
if (currentExecutionId === executionId) {
|
|
44
|
+
loading.value = false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
signInResult,
|
|
50
|
+
status,
|
|
51
|
+
loading,
|
|
52
|
+
error,
|
|
53
|
+
signIn
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { useSignIn as u };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
2
|
import { shallowRef, onMounted, onUnmounted, 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 useProgramAccounts(programId, options = {}) {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { shallowRef, ref } from 'vue';
|
|
3
|
+
import { u as useClientCapability } from './vue.B8LptjZP.mjs';
|
|
4
|
+
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
5
|
+
|
|
6
|
+
function usePlanTransaction() {
|
|
7
|
+
useClientCapability(["planTransaction"], {
|
|
8
|
+
hookName: "usePlanTransaction",
|
|
9
|
+
providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
|
|
10
|
+
});
|
|
11
|
+
const { client } = useSolanaClient();
|
|
12
|
+
const transactionMessage = shallowRef(null);
|
|
13
|
+
const status = ref("idle");
|
|
14
|
+
const loading = ref(false);
|
|
15
|
+
const error = ref(null);
|
|
16
|
+
let executionId = 0;
|
|
17
|
+
async function execute(input, config) {
|
|
18
|
+
const currentExecutionId = ++executionId;
|
|
19
|
+
const planner = client;
|
|
20
|
+
status.value = "planning";
|
|
21
|
+
loading.value = true;
|
|
22
|
+
error.value = null;
|
|
23
|
+
transactionMessage.value = null;
|
|
24
|
+
try {
|
|
25
|
+
const message = await planner.planTransaction(input, config);
|
|
26
|
+
if (currentExecutionId === executionId) {
|
|
27
|
+
transactionMessage.value = message;
|
|
28
|
+
status.value = "planned";
|
|
29
|
+
}
|
|
30
|
+
return message;
|
|
31
|
+
} catch (cause) {
|
|
32
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
33
|
+
if (currentExecutionId === executionId) {
|
|
34
|
+
error.value = normalizedError;
|
|
35
|
+
status.value = "error";
|
|
36
|
+
}
|
|
37
|
+
throw normalizedError;
|
|
38
|
+
} finally {
|
|
39
|
+
if (currentExecutionId === executionId) {
|
|
40
|
+
loading.value = false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
transactionMessage,
|
|
46
|
+
status,
|
|
47
|
+
loading,
|
|
48
|
+
error,
|
|
49
|
+
execute
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function usePlanTransactions() {
|
|
53
|
+
useClientCapability(["planTransactions"], {
|
|
54
|
+
hookName: "usePlanTransactions",
|
|
55
|
+
providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
|
|
56
|
+
});
|
|
57
|
+
const { client } = useSolanaClient();
|
|
58
|
+
const transactionPlan = shallowRef(null);
|
|
59
|
+
const status = ref("idle");
|
|
60
|
+
const loading = ref(false);
|
|
61
|
+
const error = ref(null);
|
|
62
|
+
let executionId = 0;
|
|
63
|
+
async function execute(input, config) {
|
|
64
|
+
const currentExecutionId = ++executionId;
|
|
65
|
+
const planner = client;
|
|
66
|
+
status.value = "planning";
|
|
67
|
+
loading.value = true;
|
|
68
|
+
error.value = null;
|
|
69
|
+
transactionPlan.value = null;
|
|
70
|
+
try {
|
|
71
|
+
const plan = await planner.planTransactions(input, config);
|
|
72
|
+
if (currentExecutionId === executionId) {
|
|
73
|
+
transactionPlan.value = plan;
|
|
74
|
+
status.value = "planned";
|
|
75
|
+
}
|
|
76
|
+
return plan;
|
|
77
|
+
} catch (cause) {
|
|
78
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
79
|
+
if (currentExecutionId === executionId) {
|
|
80
|
+
error.value = normalizedError;
|
|
81
|
+
status.value = "error";
|
|
82
|
+
}
|
|
83
|
+
throw normalizedError;
|
|
84
|
+
} finally {
|
|
85
|
+
if (currentExecutionId === executionId) {
|
|
86
|
+
loading.value = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
transactionPlan,
|
|
92
|
+
status,
|
|
93
|
+
loading,
|
|
94
|
+
error,
|
|
95
|
+
execute
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { usePlanTransactions as a, usePlanTransaction as u };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { shallowRef, onScopeDispose } from 'vue';
|
|
2
|
+
import { u as useClientCapability } from './vue.B8LptjZP.mjs';
|
|
3
|
+
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
4
|
+
|
|
5
|
+
function useIdentity() {
|
|
6
|
+
useClientCapability(["identity"], {
|
|
7
|
+
hookName: "useIdentity",
|
|
8
|
+
providerHint: "Install a signer plugin, e.g. `createClient().use(generatedIdentity())` from `@solana/kit-plugin-signer`."
|
|
9
|
+
});
|
|
10
|
+
const { client } = useSolanaClient();
|
|
11
|
+
const identity = shallowRef(
|
|
12
|
+
client.identity
|
|
13
|
+
);
|
|
14
|
+
const subscribable = client;
|
|
15
|
+
if (typeof subscribable.subscribeToIdentity === "function") {
|
|
16
|
+
const unsubscribe = subscribable.subscribeToIdentity(() => {
|
|
17
|
+
identity.value = client.identity;
|
|
18
|
+
});
|
|
19
|
+
onScopeDispose(unsubscribe);
|
|
20
|
+
}
|
|
21
|
+
return identity;
|
|
22
|
+
}
|
|
23
|
+
function usePayer() {
|
|
24
|
+
useClientCapability(["payer"], {
|
|
25
|
+
hookName: "usePayer",
|
|
26
|
+
providerHint: "Install a signer plugin, e.g. `createClient().use(generatedPayer())` from `@solana/kit-plugin-signer`."
|
|
27
|
+
});
|
|
28
|
+
const { client } = useSolanaClient();
|
|
29
|
+
const payer = shallowRef(
|
|
30
|
+
client.payer
|
|
31
|
+
);
|
|
32
|
+
const subscribable = client;
|
|
33
|
+
if (typeof subscribable.subscribeToPayer === "function") {
|
|
34
|
+
const unsubscribe = subscribable.subscribeToPayer(() => {
|
|
35
|
+
payer.value = client.payer;
|
|
36
|
+
});
|
|
37
|
+
onScopeDispose(unsubscribe);
|
|
38
|
+
}
|
|
39
|
+
return payer;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { usePayer as a, useIdentity as u };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const errors = require('@vue-solana/core/errors');
|
|
4
4
|
const bs58 = require('bs58');
|
|
5
5
|
const vue = require('vue');
|
|
6
|
-
const useConnection = require('./vue.
|
|
7
|
-
const useSolana = require('./vue.
|
|
6
|
+
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
7
|
+
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
10
10
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { createNoWalletSelectedError, assertWalletCanSignTransactions } from '@vue-solana/core/wallet';
|
|
3
|
+
import { shallowRef, ref } from 'vue';
|
|
4
|
+
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
5
|
+
|
|
6
|
+
function useSignTransactions() {
|
|
7
|
+
const { wallet } = useWallet();
|
|
8
|
+
const signedTransactions = shallowRef(null);
|
|
9
|
+
const status = ref("idle");
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
let executionId = 0;
|
|
13
|
+
async function execute(transactions) {
|
|
14
|
+
const currentExecutionId = ++executionId;
|
|
15
|
+
status.value = "signing";
|
|
16
|
+
loading.value = true;
|
|
17
|
+
error.value = null;
|
|
18
|
+
signedTransactions.value = null;
|
|
19
|
+
const activeWallet = wallet.value;
|
|
20
|
+
if (!activeWallet) {
|
|
21
|
+
const normalizedError = createNoWalletSelectedError();
|
|
22
|
+
error.value = normalizedError;
|
|
23
|
+
status.value = "error";
|
|
24
|
+
loading.value = false;
|
|
25
|
+
throw normalizedError;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
assertWalletCanSignTransactions(activeWallet);
|
|
29
|
+
const sign = activeWallet.signTransactions ? activeWallet.signTransactions.bind(activeWallet) : activeWallet.signAllTransactions.bind(activeWallet);
|
|
30
|
+
const result = await sign([...transactions]);
|
|
31
|
+
if (currentExecutionId === executionId) {
|
|
32
|
+
signedTransactions.value = result;
|
|
33
|
+
status.value = "signed";
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
} catch (cause) {
|
|
37
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
38
|
+
if (currentExecutionId === executionId) {
|
|
39
|
+
error.value = normalizedError;
|
|
40
|
+
status.value = "error";
|
|
41
|
+
}
|
|
42
|
+
throw normalizedError;
|
|
43
|
+
} finally {
|
|
44
|
+
if (currentExecutionId === executionId) {
|
|
45
|
+
loading.value = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
signedTransactions,
|
|
51
|
+
status,
|
|
52
|
+
loading,
|
|
53
|
+
error,
|
|
54
|
+
execute
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { useSignTransactions as u };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { inject, shallowRef, ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
const solanaInjectionKey = Symbol.for(
|
|
4
|
-
"vue-solana:context"
|
|
5
|
-
);
|
|
2
|
+
import { s as solanaInjectionKey } from './vue.D_P5SqqD.mjs';
|
|
6
3
|
|
|
7
4
|
let ssrContext;
|
|
8
5
|
function tryUseSolana() {
|
|
@@ -45,4 +42,4 @@ function createUnavailableProxy() {
|
|
|
45
42
|
);
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
export {
|
|
45
|
+
export { tryUseSolana as t, useSolana as u };
|
|
@@ -5,9 +5,9 @@ const timeout = require('@vue-solana/core/timeout');
|
|
|
5
5
|
const transaction = require('@vue-solana/core/transaction');
|
|
6
6
|
const wallet = require('@vue-solana/core/wallet');
|
|
7
7
|
const vue = require('vue');
|
|
8
|
-
const useConnection = require('./vue.
|
|
9
|
-
const useWallet = require('./vue.
|
|
10
|
-
const useTransactionConfirmation = require('./vue.
|
|
8
|
+
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
9
|
+
const useWallet = require('./vue.BGxz4dru.cjs');
|
|
10
|
+
const useTransactionConfirmation = require('./vue.Sbbm9JSu.cjs');
|
|
11
11
|
|
|
12
12
|
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
13
13
|
function useSignAndSendTransaction() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { normalizeSolanaError, createSolanaError } from '@vue-solana/core/errors';
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
3
|
import { shallowRef, onMounted, onUnmounted, 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 useSignatureStatus(signature, options = {}) {
|
|
8
8
|
const solana = tryUseSolana();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const action = require('@vue-solana/core/action');
|
|
4
|
+
const vue = require('vue');
|
|
5
|
+
|
|
6
|
+
function useAction(action$1, options = {}) {
|
|
7
|
+
const store = action.createSolanaActionStore(
|
|
8
|
+
(signal, ...args) => vue.unref(action$1)(signal, ...args)
|
|
9
|
+
);
|
|
10
|
+
const state = vue.shallowRef(store.getState());
|
|
11
|
+
const unsubscribe = store.subscribe(() => {
|
|
12
|
+
const next = store.getState();
|
|
13
|
+
const previous = state.value;
|
|
14
|
+
if (next.status === "success" && previous.status !== "success") {
|
|
15
|
+
options.onSuccess?.(next.data);
|
|
16
|
+
}
|
|
17
|
+
if (next.status === "error" && previous.status !== "error") {
|
|
18
|
+
options.onError?.(next.error);
|
|
19
|
+
}
|
|
20
|
+
state.value = next;
|
|
21
|
+
});
|
|
22
|
+
vue.onScopeDispose(() => {
|
|
23
|
+
unsubscribe();
|
|
24
|
+
store.reset();
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
data: vue.computed(() => state.value.data),
|
|
28
|
+
dispatch: (...args) => store.dispatchAsync(...args),
|
|
29
|
+
error: vue.computed(() => state.value.error),
|
|
30
|
+
isRunning: vue.computed(() => state.value.status === "running"),
|
|
31
|
+
reset: () => {
|
|
32
|
+
store.reset();
|
|
33
|
+
},
|
|
34
|
+
status: vue.computed(() => state.value.status)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.useAction = useAction;
|