@vue-solana/vue 1.2.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 +162 -23
- package/dist/buffer-polyfill.d.cts +0 -1
- package/dist/buffer-polyfill.d.mts +0 -1
- package/dist/buffer-polyfill.d.ts +0 -1
- package/dist/index.cjs +62 -22
- package/dist/index.d.cts +29 -13
- package/dist/index.d.mts +29 -13
- package/dist/index.d.ts +29 -13
- package/dist/index.mjs +41 -21
- package/dist/kit.d.cts +1 -1
- package/dist/kit.d.mts +1 -1
- package/dist/kit.d.ts +1 -1
- 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.C0uCLjJ6.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.D0ycWj82.mjs → vue.BD6Gm1nl.mjs} +9 -9
- package/dist/shared/{vue.BEesxsrA.cjs → vue.BGxz4dru.cjs} +7 -3
- package/dist/shared/{vue.DDxhSi72.mjs → vue.BINkrA8h.mjs} +9 -9
- package/dist/shared/{vue.COPnX5fq.cjs → vue.BIxphCAq.cjs} +1 -1
- package/dist/shared/{vue.CKTUFwSI.mjs → vue.BOpgWr43.mjs} +9 -10
- package/dist/shared/vue.BQRpjwKl.mjs +80 -0
- package/dist/shared/vue.BVaMoz9y.cjs +9 -0
- package/dist/shared/vue.BVj9lWBK.cjs +111 -0
- package/dist/shared/vue.BY0qpgYr.cjs +35 -0
- package/dist/shared/vue.Bfu1dCKe.mjs +10 -0
- package/dist/shared/vue.Bk5xjlUx.cjs +61 -0
- package/dist/shared/{vue.BtUKvuQw.mjs → vue.BsGwt78R.mjs} +2 -2
- package/dist/shared/{vue.BbX3ePDY.cjs → vue.Bwd1sGAM.cjs} +9 -10
- package/dist/shared/vue.ByxbBC3y.mjs +57 -0
- package/dist/shared/{vue.CPjEwHSg.mjs → vue.C13umiQi.mjs} +20 -8
- package/dist/shared/vue.C5FVoEZT.mjs +99 -0
- package/dist/shared/vue.CATOh_9G.mjs +42 -0
- package/dist/shared/{vue.Bhdhmz8d.cjs → vue.CIs8QhCw.cjs} +18 -74
- package/dist/shared/vue.CMohL_Cz.mjs +58 -0
- package/dist/shared/{vue.CYKT65tB.mjs → vue.CQh3AUE8.mjs} +2 -6
- package/dist/shared/{vue.DzKfcfpX.cjs → vue.CWZSMVnB.cjs} +6 -6
- package/dist/shared/{vue.B12Pt1PQ.mjs → vue.CXB4NEMA.mjs} +18 -74
- package/dist/shared/{vue.DFbay4mm.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.CpkwC8Th.mjs +7 -0
- package/dist/shared/vue.CrkK_T15.cjs +86 -0
- package/dist/shared/vue.D-qi8PSL.cjs +82 -0
- package/dist/shared/{vue.B2AQR2bE.mjs → vue.D218Ow7t.mjs} +8 -4
- package/dist/shared/{vue.QHAHFnw8.mjs → vue.D3Y0PWbF.mjs} +3 -3
- package/dist/shared/vue.D5U1yLG3.mjs +83 -0
- package/dist/shared/{vue.j1vB3h1n.cjs → vue.DAg5wC1G.cjs} +9 -9
- package/dist/shared/vue.DDbVk0Zh.cjs +180 -0
- package/dist/shared/{vue.BE4KHksm.cjs → vue.DE3emjSF.cjs} +2 -7
- 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.G9t8pE0J.cjs → vue.DKyQ7J67.cjs} +1 -1
- package/dist/shared/vue.DNxOpDXz.cjs +12 -0
- 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.B14U1xmP.cjs → vue.Di7yjJ-R.cjs} +20 -8
- package/dist/shared/vue.DtCbCcPd.cjs +173 -0
- package/dist/shared/{vue.CM_uqVc0.mjs → vue.Dyi1OCI1.mjs} +6 -6
- package/dist/shared/{vue.BsD6AAmO.cjs → vue.E_npPFoV.cjs} +8 -8
- package/dist/shared/{vue.LNhX07HB.cjs → vue.FiMmnMHr.cjs} +2 -2
- package/dist/shared/{vue.CSzg70vB.mjs → vue.JUWqu6kD.mjs} +1 -1
- package/dist/shared/{vue.By1CUlOU.mjs → vue.Mxc8w6Qk.mjs} +1 -1
- package/dist/shared/{vue.ByUemLSf.cjs → vue.Sbbm9JSu.cjs} +3 -3
- 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 +7 -5
- package/dist/useAccountInfo.d.cts +12 -8
- package/dist/useAccountInfo.d.mts +12 -8
- package/dist/useAccountInfo.d.ts +12 -8
- package/dist/useAccountInfo.mjs +7 -5
- 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.d.cts +4 -2
- package/dist/useBalance.d.mts +4 -2
- package/dist/useBalance.d.ts +4 -2
- 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 +9 -2
- package/dist/useConnection.d.mts +9 -2
- package/dist/useConnection.d.ts +9 -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 +7 -5
- package/dist/useProgramAccounts.d.cts +24 -9
- package/dist/useProgramAccounts.d.mts +24 -9
- package/dist/useProgramAccounts.d.ts +24 -9
- package/dist/useProgramAccounts.mjs +7 -5
- 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.d.cts +5 -2
- package/dist/useRpc.d.mts +5 -2
- package/dist/useRpc.d.ts +5 -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.d.cts +18 -24
- package/dist/useSignAndSendTransaction.d.mts +18 -24
- package/dist/useSignAndSendTransaction.d.ts +18 -24
- 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.d.cts +9 -5
- package/dist/useSignatureStatus.d.mts +9 -5
- package/dist/useSignatureStatus.d.ts +9 -5
- 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 +7 -6
- package/dist/useTokenAccounts.d.cts +6 -6
- package/dist/useTokenAccounts.d.mts +6 -6
- package/dist/useTokenAccounts.d.ts +6 -6
- package/dist/useTokenAccounts.mjs +7 -6
- package/dist/useTokenBalance.cjs +7 -6
- package/dist/useTokenBalance.d.cts +2 -2
- package/dist/useTokenBalance.d.mts +2 -2
- package/dist/useTokenBalance.d.ts +2 -2
- package/dist/useTokenBalance.mjs +7 -6
- 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 +13 -3
- package/dist/useTransaction.d.mts +13 -3
- package/dist/useTransaction.d.ts +13 -3
- package/dist/useTransaction.mjs +2 -1
- package/dist/useTransactionConfirmation.cjs +5 -4
- package/dist/useTransactionConfirmation.d.cts +18 -24
- package/dist/useTransactionConfirmation.d.mts +18 -24
- package/dist/useTransactionConfirmation.d.ts +18 -24
- package/dist/useTransactionConfirmation.mjs +5 -4
- package/dist/useWallet.cjs +3 -2
- package/dist/useWallet.d.cts +2 -2
- package/dist/useWallet.d.mts +2 -2
- package/dist/useWallet.d.ts +2 -2
- package/dist/useWallet.mjs +3 -2
- package/dist/useWallets.cjs +3 -2
- package/dist/useWallets.mjs +3 -2
- package/package.json +73 -9
- package/dist/shared/vue.C4d2JA8U.mjs +0 -44
- package/dist/shared/vue.CE5i8KZZ.cjs +0 -46
- package/dist/shared/vue.CfrVAzEf.mjs +0 -129
- package/dist/shared/vue.DCgByzxg.cjs +0 -9
- package/dist/shared/vue.DiNn3XHm.mjs +0 -7
- package/dist/shared/vue._CAClzAz.cjs +0 -131
- package/dist/web3.cjs +0 -13
- package/dist/web3.d.cts +0 -1
- package/dist/web3.d.mts +0 -1
- package/dist/web3.d.ts +0 -1
- package/dist/web3.mjs +0 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const kit = require('@vue-solana/core/kit');
|
|
4
|
+
const errors = require('@vue-solana/core/errors');
|
|
5
|
+
const vue = require('vue');
|
|
6
|
+
|
|
7
|
+
function isActionSource(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && "reactiveStore" in value && typeof value.reactiveStore === "function";
|
|
9
|
+
}
|
|
10
|
+
function useTrackedData(source, options = {}) {
|
|
11
|
+
const data = vue.shallowRef(void 0);
|
|
12
|
+
const error = vue.shallowRef(null);
|
|
13
|
+
const status = vue.shallowRef("loading");
|
|
14
|
+
const disposables = [];
|
|
15
|
+
let connectionCount = 0;
|
|
16
|
+
let disposed = false;
|
|
17
|
+
let activeStore;
|
|
18
|
+
function applyState(state) {
|
|
19
|
+
if (state.status === "loaded") {
|
|
20
|
+
data.value = state.data;
|
|
21
|
+
error.value = null;
|
|
22
|
+
status.value = "loaded";
|
|
23
|
+
} else if (state.status === "error") {
|
|
24
|
+
error.value = errors.normalizeSolanaError(state.error, "RPC_FAILURE");
|
|
25
|
+
status.value = "error";
|
|
26
|
+
options.onError?.(state.error);
|
|
27
|
+
} else if (state.status === "loading") {
|
|
28
|
+
status.value = data.value === void 0 ? "loading" : status.value;
|
|
29
|
+
} else if (state.status === "idle") {
|
|
30
|
+
error.value = null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function buildAndConnect() {
|
|
34
|
+
if (disposed) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let rpcRequest = vue.unref(source.rpcRequest);
|
|
38
|
+
const rpcSubscriptionRequest = vue.unref(source.rpcSubscriptionRequest);
|
|
39
|
+
if (!rpcRequest || !rpcSubscriptionRequest) {
|
|
40
|
+
disconnect();
|
|
41
|
+
data.value = void 0;
|
|
42
|
+
error.value = null;
|
|
43
|
+
status.value = "disabled";
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!isActionSource(rpcRequest) && isSendSource(rpcRequest)) {
|
|
47
|
+
let runSend = function(abortSignal) {
|
|
48
|
+
controller?.abort();
|
|
49
|
+
controller = new AbortController();
|
|
50
|
+
const composed = abortSignal ? AbortSignal.any([controller.signal, abortSignal]) : controller.signal;
|
|
51
|
+
settle({ data: void 0, error: void 0, status: "running" });
|
|
52
|
+
const pending = Promise.resolve(sendSource.send({ abortSignal: composed }));
|
|
53
|
+
pending.then((response) => {
|
|
54
|
+
settle({ data: response, error: void 0, status: "success" });
|
|
55
|
+
}).catch((cause) => {
|
|
56
|
+
settle({ data: void 0, error: cause, status: "error" });
|
|
57
|
+
});
|
|
58
|
+
return kit.getAbortablePromise(pending, composed);
|
|
59
|
+
};
|
|
60
|
+
const sendSource = rpcRequest;
|
|
61
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
62
|
+
let sendState = {
|
|
63
|
+
data: void 0,
|
|
64
|
+
error: void 0,
|
|
65
|
+
status: "idle"
|
|
66
|
+
};
|
|
67
|
+
let controller;
|
|
68
|
+
const emit = () => {
|
|
69
|
+
listeners.forEach((listener) => {
|
|
70
|
+
listener();
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const settle = (next) => {
|
|
74
|
+
sendState = next;
|
|
75
|
+
emit();
|
|
76
|
+
};
|
|
77
|
+
rpcRequest = {
|
|
78
|
+
reactiveStore: () => ({
|
|
79
|
+
dispatch() {
|
|
80
|
+
void runSend().catch(() => {
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
dispatchAsync: () => runSend(),
|
|
84
|
+
getState: () => sendState,
|
|
85
|
+
reset() {
|
|
86
|
+
controller?.abort();
|
|
87
|
+
settle({ data: void 0, error: void 0, status: "idle" });
|
|
88
|
+
},
|
|
89
|
+
subscribe(listener) {
|
|
90
|
+
listeners.add(listener);
|
|
91
|
+
return () => {
|
|
92
|
+
listeners.delete(listener);
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
withSignal(signal) {
|
|
96
|
+
return {
|
|
97
|
+
dispatch: () => {
|
|
98
|
+
void runSend(signal).catch(() => {
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
dispatchAsync: () => runSend(signal)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
connectionCount += 1;
|
|
108
|
+
const connection = connectionCount;
|
|
109
|
+
const callerSignal = options.getAbortSignal?.(connection);
|
|
110
|
+
const store = kit.createReactiveStoreWithInitialValueAndSlotTracking({
|
|
111
|
+
initialValueMapper: source.rpcValueMapper,
|
|
112
|
+
initialValueSource: rpcRequest,
|
|
113
|
+
streamSource: rpcSubscriptionRequest,
|
|
114
|
+
streamValueMapper: source.rpcSubscriptionValueMapper
|
|
115
|
+
});
|
|
116
|
+
activeStore = store;
|
|
117
|
+
applyState(store.getState());
|
|
118
|
+
disposables.push(
|
|
119
|
+
store.subscribe(() => {
|
|
120
|
+
applyState(store.getState());
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
if (callerSignal?.aborted) {
|
|
124
|
+
applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (callerSignal) {
|
|
128
|
+
store.withSignal(callerSignal).connect();
|
|
129
|
+
} else {
|
|
130
|
+
store.connect();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function disconnect() {
|
|
134
|
+
disposables.forEach((dispose) => {
|
|
135
|
+
dispose();
|
|
136
|
+
});
|
|
137
|
+
disposables.length = 0;
|
|
138
|
+
if (activeStore) {
|
|
139
|
+
activeStore.reset();
|
|
140
|
+
activeStore = void 0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
vue.watch(
|
|
144
|
+
() => [vue.unref(source.rpcRequest), vue.unref(source.rpcSubscriptionRequest)],
|
|
145
|
+
() => {
|
|
146
|
+
buildAndConnect();
|
|
147
|
+
},
|
|
148
|
+
{ flush: "post" }
|
|
149
|
+
);
|
|
150
|
+
vue.onMounted(() => {
|
|
151
|
+
buildAndConnect();
|
|
152
|
+
});
|
|
153
|
+
if (!vue.getCurrentInstance()) {
|
|
154
|
+
buildAndConnect();
|
|
155
|
+
}
|
|
156
|
+
vue.onScopeDispose(() => {
|
|
157
|
+
disposed = true;
|
|
158
|
+
disconnect();
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
data: vue.computed(() => data.value),
|
|
162
|
+
error: vue.computed(() => error.value),
|
|
163
|
+
refresh: () => {
|
|
164
|
+
buildAndConnect();
|
|
165
|
+
},
|
|
166
|
+
status: vue.computed(() => status.value)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function isSendSource(value) {
|
|
170
|
+
return typeof value === "object" && value !== null && "send" in value && typeof value.send === "function";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
exports.useTrackedData = useTrackedData;
|
|
@@ -3,13 +3,13 @@ import { withSolanaTimeout } from '@vue-solana/core/timeout';
|
|
|
3
3
|
import { signAndSendTransaction, confirmTransactionSignature } from '@vue-solana/core/transaction';
|
|
4
4
|
import { createNoWalletSelectedError } from '@vue-solana/core/wallet';
|
|
5
5
|
import { ref } from 'vue';
|
|
6
|
-
import { u as useConnection } from './vue.
|
|
7
|
-
import { u as useWallet } from './vue.
|
|
8
|
-
import { g as getConfirmedTransactionStatus } from './vue.
|
|
6
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
7
|
+
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
8
|
+
import { g as getConfirmedTransactionStatus } from './vue.D3Y0PWbF.mjs';
|
|
9
9
|
|
|
10
10
|
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
11
11
|
function useSignAndSendTransaction() {
|
|
12
|
-
const
|
|
12
|
+
const client = useConnection();
|
|
13
13
|
const { wallet } = useWallet();
|
|
14
14
|
const signature = ref(null);
|
|
15
15
|
const confirmation = ref(null);
|
|
@@ -35,7 +35,7 @@ function useSignAndSendTransaction() {
|
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
37
|
const nextSignature = await withSolanaTimeout(
|
|
38
|
-
signAndSendTransaction(
|
|
38
|
+
signAndSendTransaction(client, activeWallet, transaction, transactionOptions),
|
|
39
39
|
SIGN_AND_SEND_TIMEOUT_MS,
|
|
40
40
|
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
41
41
|
);
|
|
@@ -47,7 +47,7 @@ function useSignAndSendTransaction() {
|
|
|
47
47
|
return nextSignature;
|
|
48
48
|
}
|
|
49
49
|
const nextConfirmation = await confirmTransactionSignature(
|
|
50
|
-
|
|
50
|
+
client,
|
|
51
51
|
nextSignature,
|
|
52
52
|
confirmationOptions
|
|
53
53
|
);
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
const address = require('@vue-solana/core/address');
|
|
4
4
|
const errors = require('@vue-solana/core/errors');
|
|
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 useBalance(address$1, commitment) {
|
|
10
10
|
const solana = useSolana.tryUseSolana();
|
|
11
|
-
const
|
|
11
|
+
const client = solana?.client ?? useConnection.useConnection();
|
|
12
12
|
const balance = vue.shallowRef(null);
|
|
13
13
|
const loading = vue.shallowRef(false);
|
|
14
14
|
const error = vue.shallowRef(null);
|
|
@@ -25,16 +25,16 @@ function useBalance(address$1, commitment) {
|
|
|
25
25
|
loading.value = true;
|
|
26
26
|
error.value = null;
|
|
27
27
|
try {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
28
|
+
const parsedAddress = address.parseAddress(value);
|
|
29
|
+
if (!parsedAddress) {
|
|
30
30
|
balance.value = null;
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
|
-
const
|
|
33
|
+
const { value: lamports } = await client.rpc.getBalance(parsedAddress, commitment ? { commitment } : void 0).send();
|
|
34
34
|
if (requestId === refreshId) {
|
|
35
|
-
balance.value =
|
|
35
|
+
balance.value = Number(lamports);
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return Number(lamports);
|
|
38
38
|
} catch (cause) {
|
|
39
39
|
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
40
40
|
if (requestId === refreshId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
|
-
const useSolana = require('./vue.
|
|
4
|
+
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
5
5
|
|
|
6
6
|
function useRpc() {
|
|
7
7
|
const solana = useSolana.useSolana();
|
|
@@ -13,7 +13,7 @@ function useRpc() {
|
|
|
13
13
|
error: solana.error,
|
|
14
14
|
latestBlockhash: solana.latestBlockhash,
|
|
15
15
|
checkConnection: solana.checkConnection,
|
|
16
|
-
|
|
16
|
+
client: solana.client
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
2
|
import { createNoWalletSelectedError, assertWalletCanSignMessage } from '@vue-solana/core/wallet';
|
|
3
3
|
import { ref } from 'vue';
|
|
4
|
-
import { u as useWallet } from './vue.
|
|
4
|
+
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
5
5
|
|
|
6
6
|
function useSignMessage() {
|
|
7
7
|
const { wallet } = useWallet();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const transaction = require('@vue-solana/core/transaction');
|
|
4
4
|
const errors = require('@vue-solana/core/errors');
|
|
5
5
|
const vue = require('vue');
|
|
6
|
-
const useConnection = require('./vue.
|
|
6
|
+
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
7
7
|
|
|
8
8
|
function getConfirmedTransactionStatus(confirmation) {
|
|
9
9
|
if (confirmation.commitment === "finalized") {
|
|
@@ -12,7 +12,7 @@ function getConfirmedTransactionStatus(confirmation) {
|
|
|
12
12
|
return confirmation.commitment === "processed" ? "processed" : "confirmed";
|
|
13
13
|
}
|
|
14
14
|
function useTransactionConfirmation(defaultOptions = {}) {
|
|
15
|
-
const
|
|
15
|
+
const client = useConnection.useConnection();
|
|
16
16
|
const signature = vue.ref(null);
|
|
17
17
|
const confirmation = vue.ref(null);
|
|
18
18
|
const status = vue.ref("idle");
|
|
@@ -29,7 +29,7 @@ function useTransactionConfirmation(defaultOptions = {}) {
|
|
|
29
29
|
error.value = null;
|
|
30
30
|
try {
|
|
31
31
|
const nextConfirmation = await transaction.confirmTransactionSignature(
|
|
32
|
-
|
|
32
|
+
client,
|
|
33
33
|
nextSignature,
|
|
34
34
|
confirmationOptions
|
|
35
35
|
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const useClientCapability = require('./vue.BY0qpgYr.cjs');
|
|
5
|
+
const useSolanaClient = require('./vue.BIxphCAq.cjs');
|
|
6
|
+
|
|
7
|
+
function useIdentity() {
|
|
8
|
+
useClientCapability.useClientCapability(["identity"], {
|
|
9
|
+
hookName: "useIdentity",
|
|
10
|
+
providerHint: "Install a signer plugin, e.g. `createClient().use(generatedIdentity())` from `@solana/kit-plugin-signer`."
|
|
11
|
+
});
|
|
12
|
+
const { client } = useSolanaClient.useSolanaClient();
|
|
13
|
+
const identity = vue.shallowRef(
|
|
14
|
+
client.identity
|
|
15
|
+
);
|
|
16
|
+
const subscribable = client;
|
|
17
|
+
if (typeof subscribable.subscribeToIdentity === "function") {
|
|
18
|
+
const unsubscribe = subscribable.subscribeToIdentity(() => {
|
|
19
|
+
identity.value = client.identity;
|
|
20
|
+
});
|
|
21
|
+
vue.onScopeDispose(unsubscribe);
|
|
22
|
+
}
|
|
23
|
+
return identity;
|
|
24
|
+
}
|
|
25
|
+
function usePayer() {
|
|
26
|
+
useClientCapability.useClientCapability(["payer"], {
|
|
27
|
+
hookName: "usePayer",
|
|
28
|
+
providerHint: "Install a signer plugin, e.g. `createClient().use(generatedPayer())` from `@solana/kit-plugin-signer`."
|
|
29
|
+
});
|
|
30
|
+
const { client } = useSolanaClient.useSolanaClient();
|
|
31
|
+
const payer = vue.shallowRef(
|
|
32
|
+
client.payer
|
|
33
|
+
);
|
|
34
|
+
const subscribable = client;
|
|
35
|
+
if (typeof subscribable.subscribeToPayer === "function") {
|
|
36
|
+
const unsubscribe = subscribable.subscribeToPayer(() => {
|
|
37
|
+
payer.value = client.payer;
|
|
38
|
+
});
|
|
39
|
+
vue.onScopeDispose(unsubscribe);
|
|
40
|
+
}
|
|
41
|
+
return payer;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.useIdentity = useIdentity;
|
|
45
|
+
exports.usePayer = usePayer;
|
package/dist/swr.cjs
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const useRequest = require('./shared/vue.B8pLQ8P4.cjs');
|
|
5
|
+
const useSubscription = require('./shared/vue.BVj9lWBK.cjs');
|
|
6
|
+
const useTrackedData = require('./shared/vue.DtCbCcPd.cjs');
|
|
7
|
+
require('@vue-solana/core/action');
|
|
8
|
+
require('@vue-solana/core/kit');
|
|
9
|
+
require('@vue-solana/core/errors');
|
|
10
|
+
|
|
11
|
+
const PREFIX_REQUEST = "request:";
|
|
12
|
+
const PREFIX_SUBSCRIPTION = "subscription:";
|
|
13
|
+
const PREFIX_TRACKED = "tracked:";
|
|
14
|
+
const swrCache = /* @__PURE__ */ new Map();
|
|
15
|
+
function clearSwrCache() {
|
|
16
|
+
swrCache.clear();
|
|
17
|
+
}
|
|
18
|
+
function readSwrCache(key) {
|
|
19
|
+
return swrCache.get(key);
|
|
20
|
+
}
|
|
21
|
+
function writeSwrCache(key, entry) {
|
|
22
|
+
swrCache.set(key, entry);
|
|
23
|
+
}
|
|
24
|
+
function deleteSwrCache(key) {
|
|
25
|
+
swrCache.delete(key);
|
|
26
|
+
}
|
|
27
|
+
function isPendingStatus(status) {
|
|
28
|
+
return status === "fetching" || status === "loading";
|
|
29
|
+
}
|
|
30
|
+
function writeSwrResult(key, data, error, status) {
|
|
31
|
+
if (status === "disabled") {
|
|
32
|
+
deleteSwrCache(key);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const previous = readSwrCache(key);
|
|
36
|
+
writeSwrCache(key, {
|
|
37
|
+
data: data !== void 0 ? data : previous?.data,
|
|
38
|
+
error,
|
|
39
|
+
status
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function swrError(error, status, seed) {
|
|
43
|
+
if (status === "disabled") {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return error ?? (isPendingStatus(status) ? seed?.error ?? null : null);
|
|
47
|
+
}
|
|
48
|
+
function useRequestSwr(key, source, options = {}) {
|
|
49
|
+
const cacheKey = `${PREFIX_REQUEST}${key}`;
|
|
50
|
+
const seed = readSwrCache(cacheKey);
|
|
51
|
+
const result = useRequest.useRequest(source, options);
|
|
52
|
+
if (result.status.value === "disabled") {
|
|
53
|
+
deleteSwrCache(cacheKey);
|
|
54
|
+
}
|
|
55
|
+
vue.watch(
|
|
56
|
+
[result.data, result.error, result.status],
|
|
57
|
+
([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
|
|
58
|
+
{ flush: "sync" }
|
|
59
|
+
);
|
|
60
|
+
const data = vue.computed(() => {
|
|
61
|
+
if (result.status.value === "disabled") {
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
return result.data.value !== void 0 ? result.data.value : seed?.data;
|
|
65
|
+
});
|
|
66
|
+
const error = vue.computed(
|
|
67
|
+
() => swrError(result.error.value, result.status.value, seed)
|
|
68
|
+
);
|
|
69
|
+
return {
|
|
70
|
+
data,
|
|
71
|
+
error,
|
|
72
|
+
refresh: result.refresh,
|
|
73
|
+
status: result.status
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function useSubscriptionSwr(key, source, options = {}) {
|
|
77
|
+
const cacheKey = `${PREFIX_SUBSCRIPTION}${key}`;
|
|
78
|
+
const seed = readSwrCache(cacheKey);
|
|
79
|
+
const result = useSubscription.useSubscription(source, options);
|
|
80
|
+
if (result.status.value === "disabled") {
|
|
81
|
+
deleteSwrCache(cacheKey);
|
|
82
|
+
}
|
|
83
|
+
vue.watch(
|
|
84
|
+
[result.data, result.error, result.status],
|
|
85
|
+
([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
|
|
86
|
+
{ flush: "sync" }
|
|
87
|
+
);
|
|
88
|
+
const data = vue.computed(() => {
|
|
89
|
+
if (result.status.value === "disabled") {
|
|
90
|
+
return void 0;
|
|
91
|
+
}
|
|
92
|
+
return result.data.value !== void 0 ? result.data.value : seed?.data;
|
|
93
|
+
});
|
|
94
|
+
const error = vue.computed(
|
|
95
|
+
() => swrError(result.error.value, result.status.value, seed)
|
|
96
|
+
);
|
|
97
|
+
return {
|
|
98
|
+
data,
|
|
99
|
+
error,
|
|
100
|
+
reconnect: result.reconnect,
|
|
101
|
+
status: result.status
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function useTrackedDataSwr(key, source, options = {}) {
|
|
105
|
+
const cacheKey = `${PREFIX_TRACKED}${key}`;
|
|
106
|
+
const seed = readSwrCache(cacheKey);
|
|
107
|
+
const result = useTrackedData.useTrackedData(source, options);
|
|
108
|
+
if (result.status.value === "disabled") {
|
|
109
|
+
deleteSwrCache(cacheKey);
|
|
110
|
+
}
|
|
111
|
+
vue.watch(
|
|
112
|
+
[result.data, result.error, result.status],
|
|
113
|
+
([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
|
|
114
|
+
{ flush: "sync" }
|
|
115
|
+
);
|
|
116
|
+
const data = vue.computed(() => {
|
|
117
|
+
if (result.status.value === "disabled") {
|
|
118
|
+
return void 0;
|
|
119
|
+
}
|
|
120
|
+
return result.data.value ?? seed?.data;
|
|
121
|
+
});
|
|
122
|
+
const error = vue.computed(
|
|
123
|
+
() => swrError(result.error.value, result.status.value, seed)
|
|
124
|
+
);
|
|
125
|
+
return {
|
|
126
|
+
data,
|
|
127
|
+
error,
|
|
128
|
+
refresh: result.refresh,
|
|
129
|
+
status: result.status
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
exports.clearSwrCache = clearSwrCache;
|
|
134
|
+
exports.useRequestSwr = useRequestSwr;
|
|
135
|
+
exports.useSubscriptionSwr = useSubscriptionSwr;
|
|
136
|
+
exports.useTrackedDataSwr = useTrackedDataSwr;
|
package/dist/swr.d.cts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useRequest, UseRequestOptions, UseRequestReturn } from './useRequest.cjs';
|
|
2
|
+
import { UseSubscriptionSource, UseSubscriptionOptions, UseSubscriptionReturn } from './useSubscription.cjs';
|
|
3
|
+
import { UseTrackedDataSource, UseTrackedDataOptions, UseTrackedDataReturn } from './useTrackedData.cjs';
|
|
4
|
+
import '@vue-solana/core/errors';
|
|
5
|
+
import 'vue';
|
|
6
|
+
import '@vue-solana/core/kit';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Remove every cached SWR entry (all adapters). Useful between test cases
|
|
10
|
+
* and to reset server-side caches per request.
|
|
11
|
+
*/
|
|
12
|
+
declare function clearSwrCache(): void;
|
|
13
|
+
/**
|
|
14
|
+
* `useRequest` with cache keying. A component mounting with a key that
|
|
15
|
+
* already holds data shows it immediately (stale) while its own request
|
|
16
|
+
* revalidates; results are written back for the next mount.
|
|
17
|
+
*
|
|
18
|
+
* A `null`/`undefined` source disables the request and **clears** the
|
|
19
|
+
* cached entry for the key — including when the component mounts with the
|
|
20
|
+
* source already disabled.
|
|
21
|
+
*/
|
|
22
|
+
declare function useRequestSwr<TResult>(key: string, source: Parameters<typeof useRequest<TResult>>[0], options?: UseRequestOptions): UseRequestReturn<TResult>;
|
|
23
|
+
/**
|
|
24
|
+
* `useSubscription` with cache keying — a freshly mounted component seeds
|
|
25
|
+
* from the last-known stream value while its own subscription connects.
|
|
26
|
+
*
|
|
27
|
+
* A `null`/`undefined` source disables the subscription and **clears** the
|
|
28
|
+
* cached entry for the key.
|
|
29
|
+
*/
|
|
30
|
+
declare function useSubscriptionSwr<TResult>(key: string, source: UseSubscriptionSource<TResult>, options?: UseSubscriptionOptions): UseSubscriptionReturn<TResult>;
|
|
31
|
+
/**
|
|
32
|
+
* `useTrackedData` with cache keying — seeds from the last-known
|
|
33
|
+
* {@link SolanaRpcResponse} envelope (data **and** slot context) while the
|
|
34
|
+
* fetch + subscription pair revalidates.
|
|
35
|
+
*
|
|
36
|
+
* A `null`/`undefined` source disables the composable and **clears** the
|
|
37
|
+
* cached entry for the key.
|
|
38
|
+
*/
|
|
39
|
+
declare function useTrackedDataSwr<TInitialValue, TStreamValue, TItem>(key: string, source: UseTrackedDataSource<TInitialValue, TStreamValue, TItem>, options?: UseTrackedDataOptions): UseTrackedDataReturn<TItem>;
|
|
40
|
+
|
|
41
|
+
export { clearSwrCache, useRequestSwr, useSubscriptionSwr, useTrackedDataSwr };
|
package/dist/swr.d.mts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useRequest, UseRequestOptions, UseRequestReturn } from './useRequest.mjs';
|
|
2
|
+
import { UseSubscriptionSource, UseSubscriptionOptions, UseSubscriptionReturn } from './useSubscription.mjs';
|
|
3
|
+
import { UseTrackedDataSource, UseTrackedDataOptions, UseTrackedDataReturn } from './useTrackedData.mjs';
|
|
4
|
+
import '@vue-solana/core/errors';
|
|
5
|
+
import 'vue';
|
|
6
|
+
import '@vue-solana/core/kit';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Remove every cached SWR entry (all adapters). Useful between test cases
|
|
10
|
+
* and to reset server-side caches per request.
|
|
11
|
+
*/
|
|
12
|
+
declare function clearSwrCache(): void;
|
|
13
|
+
/**
|
|
14
|
+
* `useRequest` with cache keying. A component mounting with a key that
|
|
15
|
+
* already holds data shows it immediately (stale) while its own request
|
|
16
|
+
* revalidates; results are written back for the next mount.
|
|
17
|
+
*
|
|
18
|
+
* A `null`/`undefined` source disables the request and **clears** the
|
|
19
|
+
* cached entry for the key — including when the component mounts with the
|
|
20
|
+
* source already disabled.
|
|
21
|
+
*/
|
|
22
|
+
declare function useRequestSwr<TResult>(key: string, source: Parameters<typeof useRequest<TResult>>[0], options?: UseRequestOptions): UseRequestReturn<TResult>;
|
|
23
|
+
/**
|
|
24
|
+
* `useSubscription` with cache keying — a freshly mounted component seeds
|
|
25
|
+
* from the last-known stream value while its own subscription connects.
|
|
26
|
+
*
|
|
27
|
+
* A `null`/`undefined` source disables the subscription and **clears** the
|
|
28
|
+
* cached entry for the key.
|
|
29
|
+
*/
|
|
30
|
+
declare function useSubscriptionSwr<TResult>(key: string, source: UseSubscriptionSource<TResult>, options?: UseSubscriptionOptions): UseSubscriptionReturn<TResult>;
|
|
31
|
+
/**
|
|
32
|
+
* `useTrackedData` with cache keying — seeds from the last-known
|
|
33
|
+
* {@link SolanaRpcResponse} envelope (data **and** slot context) while the
|
|
34
|
+
* fetch + subscription pair revalidates.
|
|
35
|
+
*
|
|
36
|
+
* A `null`/`undefined` source disables the composable and **clears** the
|
|
37
|
+
* cached entry for the key.
|
|
38
|
+
*/
|
|
39
|
+
declare function useTrackedDataSwr<TInitialValue, TStreamValue, TItem>(key: string, source: UseTrackedDataSource<TInitialValue, TStreamValue, TItem>, options?: UseTrackedDataOptions): UseTrackedDataReturn<TItem>;
|
|
40
|
+
|
|
41
|
+
export { clearSwrCache, useRequestSwr, useSubscriptionSwr, useTrackedDataSwr };
|
package/dist/swr.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useRequest, UseRequestOptions, UseRequestReturn } from './useRequest.js';
|
|
2
|
+
import { UseSubscriptionSource, UseSubscriptionOptions, UseSubscriptionReturn } from './useSubscription.js';
|
|
3
|
+
import { UseTrackedDataSource, UseTrackedDataOptions, UseTrackedDataReturn } from './useTrackedData.js';
|
|
4
|
+
import '@vue-solana/core/errors';
|
|
5
|
+
import 'vue';
|
|
6
|
+
import '@vue-solana/core/kit';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Remove every cached SWR entry (all adapters). Useful between test cases
|
|
10
|
+
* and to reset server-side caches per request.
|
|
11
|
+
*/
|
|
12
|
+
declare function clearSwrCache(): void;
|
|
13
|
+
/**
|
|
14
|
+
* `useRequest` with cache keying. A component mounting with a key that
|
|
15
|
+
* already holds data shows it immediately (stale) while its own request
|
|
16
|
+
* revalidates; results are written back for the next mount.
|
|
17
|
+
*
|
|
18
|
+
* A `null`/`undefined` source disables the request and **clears** the
|
|
19
|
+
* cached entry for the key — including when the component mounts with the
|
|
20
|
+
* source already disabled.
|
|
21
|
+
*/
|
|
22
|
+
declare function useRequestSwr<TResult>(key: string, source: Parameters<typeof useRequest<TResult>>[0], options?: UseRequestOptions): UseRequestReturn<TResult>;
|
|
23
|
+
/**
|
|
24
|
+
* `useSubscription` with cache keying — a freshly mounted component seeds
|
|
25
|
+
* from the last-known stream value while its own subscription connects.
|
|
26
|
+
*
|
|
27
|
+
* A `null`/`undefined` source disables the subscription and **clears** the
|
|
28
|
+
* cached entry for the key.
|
|
29
|
+
*/
|
|
30
|
+
declare function useSubscriptionSwr<TResult>(key: string, source: UseSubscriptionSource<TResult>, options?: UseSubscriptionOptions): UseSubscriptionReturn<TResult>;
|
|
31
|
+
/**
|
|
32
|
+
* `useTrackedData` with cache keying — seeds from the last-known
|
|
33
|
+
* {@link SolanaRpcResponse} envelope (data **and** slot context) while the
|
|
34
|
+
* fetch + subscription pair revalidates.
|
|
35
|
+
*
|
|
36
|
+
* A `null`/`undefined` source disables the composable and **clears** the
|
|
37
|
+
* cached entry for the key.
|
|
38
|
+
*/
|
|
39
|
+
declare function useTrackedDataSwr<TInitialValue, TStreamValue, TItem>(key: string, source: UseTrackedDataSource<TInitialValue, TStreamValue, TItem>, options?: UseTrackedDataOptions): UseTrackedDataReturn<TItem>;
|
|
40
|
+
|
|
41
|
+
export { clearSwrCache, useRequestSwr, useSubscriptionSwr, useTrackedDataSwr };
|