@vue-solana/vue 2.6.1 → 3.0.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 +6 -4
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +36 -47
- package/dist/shared/vue.1Qwco2kv.mjs +33 -0
- package/dist/shared/vue.BFSboXMB.mjs +17 -0
- package/dist/shared/vue.BGGixph-.d.mts +5 -0
- package/dist/shared/vue.BGGixph-.d.ts +5 -0
- package/dist/shared/{vue.CbJFnho-.mjs → vue.BNJTXSnQ.mjs} +17 -70
- package/dist/shared/{vue.BINkrA8h.mjs → vue.BwBqla_n.mjs} +16 -26
- package/dist/shared/vue.BxtOHzY_.mjs +27 -0
- package/dist/shared/vue.C1JbUTpJ.mjs +66 -0
- package/dist/shared/vue.C9OOmvkD.mjs +36 -0
- package/dist/shared/vue.CGv0ip3w.mjs +52 -0
- package/dist/shared/vue.CaAgH2Xt.mjs +51 -0
- package/dist/shared/{vue.Dyi1OCI1.mjs → vue.CjSw0Hh1.mjs} +3 -9
- package/dist/shared/vue.CsFY1mfz.mjs +29 -0
- package/dist/shared/vue.CvenSbZZ.mjs +27 -0
- package/dist/shared/{vue.BDNOyiGZ.mjs → vue.D5pqR5Fa.mjs} +9 -12
- package/dist/shared/vue.DNKD6jqM.mjs +22 -0
- package/dist/shared/vue.DlihC5GG.mjs +38 -0
- package/dist/shared/vue.XlfH_nkc.mjs +32 -0
- package/dist/shared/vue.hG_FieA3.mjs +37 -0
- package/dist/shared/vue.o98pAmDg.mjs +40 -0
- package/dist/swr.mjs +22 -76
- package/dist/useAccountInfo.d.mts +4 -4
- package/dist/useAccountInfo.d.ts +4 -4
- package/dist/useAccountInfo.mjs +5 -4
- package/dist/useBalance.d.mts +4 -4
- package/dist/useBalance.d.ts +4 -4
- package/dist/useBalance.mjs +5 -4
- package/dist/usePlanTransaction.d.mts +12 -13
- package/dist/usePlanTransaction.d.ts +12 -13
- package/dist/usePlanTransaction.mjs +2 -1
- package/dist/usePlanTransactions.d.mts +2 -1
- package/dist/usePlanTransactions.d.ts +2 -1
- package/dist/usePlanTransactions.mjs +2 -1
- package/dist/useProgramAccounts.d.mts +5 -15
- package/dist/useProgramAccounts.d.ts +5 -15
- package/dist/useProgramAccounts.mjs +5 -4
- package/dist/useSendTransaction.d.mts +11 -12
- package/dist/useSendTransaction.d.ts +11 -12
- package/dist/useSendTransaction.mjs +2 -1
- package/dist/useSendTransactions.d.mts +2 -1
- package/dist/useSendTransactions.d.ts +2 -1
- package/dist/useSendTransactions.mjs +2 -1
- package/dist/useSignAndSendTransaction.d.mts +1 -1
- package/dist/useSignAndSendTransaction.d.ts +1 -1
- package/dist/useSignAndSendTransaction.mjs +3 -2
- package/dist/useSignAndSendTransactions.d.mts +2 -2
- package/dist/useSignAndSendTransactions.d.ts +2 -2
- package/dist/useSignAndSendTransactions.mjs +2 -1
- package/dist/useSignIn.d.mts +4 -4
- package/dist/useSignIn.d.ts +4 -4
- package/dist/useSignIn.mjs +3 -2
- package/dist/useSignMessage.d.mts +4 -4
- package/dist/useSignMessage.d.ts +4 -4
- package/dist/useSignMessage.mjs +3 -2
- package/dist/useSignTransactions.d.mts +4 -4
- package/dist/useSignTransactions.d.ts +4 -4
- package/dist/useSignTransactions.mjs +3 -2
- package/dist/useSubscription.mjs +1 -1
- package/dist/useTokenAccounts.d.mts +4 -4
- package/dist/useTokenAccounts.d.ts +4 -4
- package/dist/useTokenAccounts.mjs +5 -4
- package/dist/useTokenBalance.d.mts +9 -7
- package/dist/useTokenBalance.d.ts +9 -7
- package/dist/useTokenBalance.mjs +4 -3
- package/dist/useTrackedData.mjs +1 -1
- package/dist/useTransactionConfirmation.d.mts +4 -4
- package/dist/useTransactionConfirmation.d.ts +4 -4
- package/dist/useTransactionConfirmation.mjs +3 -2
- package/package.json +38 -75
- package/dist/buffer-polyfill.cjs +0 -8
- package/dist/buffer-polyfill.d.cts +0 -2
- package/dist/index.cjs +0 -452
- package/dist/index.d.cts +0 -62
- package/dist/kit.cjs +0 -16
- package/dist/kit.d.cts +0 -1
- package/dist/shared/vue.4C5kX4fE.cjs +0 -36
- package/dist/shared/vue.9TPxZPMf.cjs +0 -59
- package/dist/shared/vue.B4eMoJT2.cjs +0 -36
- package/dist/shared/vue.B6ainw2G.cjs +0 -63
- package/dist/shared/vue.BD6Gm1nl.mjs +0 -74
- package/dist/shared/vue.BGxz4dru.cjs +0 -98
- package/dist/shared/vue.BIxphCAq.cjs +0 -10
- package/dist/shared/vue.BOpgWr43.mjs +0 -70
- package/dist/shared/vue.BQRpjwKl.mjs +0 -80
- package/dist/shared/vue.BVaMoz9y.cjs +0 -9
- package/dist/shared/vue.Bk5xjlUx.cjs +0 -61
- package/dist/shared/vue.Bwd1sGAM.cjs +0 -72
- package/dist/shared/vue.ByxbBC3y.mjs +0 -57
- package/dist/shared/vue.C13umiQi.mjs +0 -85
- package/dist/shared/vue.CIs8QhCw.cjs +0 -132
- package/dist/shared/vue.CMohL_Cz.mjs +0 -58
- package/dist/shared/vue.CWZSMVnB.cjs +0 -84
- package/dist/shared/vue.Co5rj-I6.mjs +0 -118
- package/dist/shared/vue.CoaIWGPT.cjs +0 -38
- package/dist/shared/vue.CrkK_T15.cjs +0 -86
- package/dist/shared/vue.D-qi8PSL.cjs +0 -82
- package/dist/shared/vue.D3Y0PWbF.mjs +0 -71
- package/dist/shared/vue.D5U1yLG3.mjs +0 -83
- package/dist/shared/vue.DAg5wC1G.cjs +0 -76
- package/dist/shared/vue.DAthhH4D.mjs +0 -118
- package/dist/shared/vue.DDbVk0Zh.cjs +0 -180
- package/dist/shared/vue.DE3emjSF.cjs +0 -48
- package/dist/shared/vue.DEHxNvUX.cjs +0 -7
- package/dist/shared/vue.DFaMJLAQ.cjs +0 -60
- package/dist/shared/vue.DKoM8jIV.cjs +0 -121
- package/dist/shared/vue.DKyQ7J67.cjs +0 -15
- package/dist/shared/vue.DL3z5PxP.d.cts +0 -21
- package/dist/shared/vue.DNxOpDXz.cjs +0 -12
- package/dist/shared/vue.Di7yjJ-R.cjs +0 -87
- package/dist/shared/vue.Dn3KLJZH.cjs +0 -121
- package/dist/shared/vue.DxM45azl.cjs +0 -173
- package/dist/shared/vue.E_npPFoV.cjs +0 -67
- package/dist/shared/vue.FiMmnMHr.cjs +0 -20
- package/dist/shared/vue.JUWqu6kD.mjs +0 -61
- package/dist/shared/vue.Sbbm9JSu.cjs +0 -74
- package/dist/shared/vue.ZuUCEEab.cjs +0 -103
- package/dist/shared/vue.l3UCdN7z.cjs +0 -111
- package/dist/shared/vue.ldvmk9NM.cjs +0 -45
- package/dist/swr.cjs +0 -136
- package/dist/swr.d.cts +0 -41
- package/dist/useAccountInfo.cjs +0 -15
- package/dist/useAccountInfo.d.cts +0 -24
- package/dist/useAction.cjs +0 -9
- package/dist/useAction.d.cts +0 -45
- package/dist/useAirdrop.cjs +0 -14
- package/dist/useAirdrop.d.cts +0 -27
- package/dist/useBalance.cjs +0 -14
- package/dist/useBalance.d.cts +0 -15
- package/dist/useClientCapability.cjs +0 -12
- package/dist/useClientCapability.d.cts +0 -39
- package/dist/useConnection.cjs +0 -11
- package/dist/useConnection.d.cts +0 -46
- package/dist/useIdentity.cjs +0 -12
- package/dist/useIdentity.d.cts +0 -3
- package/dist/usePayer.cjs +0 -13
- package/dist/usePayer.d.cts +0 -18
- package/dist/usePlanTransaction.cjs +0 -14
- package/dist/usePlanTransaction.d.cts +0 -45
- package/dist/usePlanTransactions.cjs +0 -13
- package/dist/usePlanTransactions.d.cts +0 -4
- package/dist/useProgramAccounts.cjs +0 -15
- package/dist/useProgramAccounts.d.cts +0 -55
- package/dist/useRequest.cjs +0 -11
- package/dist/useRequest.d.cts +0 -73
- package/dist/useRpc.cjs +0 -10
- package/dist/useRpc.d.cts +0 -55
- package/dist/useSelectedWalletAccount.cjs +0 -13
- package/dist/useSelectedWalletAccount.d.cts +0 -117
- package/dist/useSendTransaction.cjs +0 -14
- package/dist/useSendTransaction.d.cts +0 -51
- package/dist/useSendTransactions.cjs +0 -13
- package/dist/useSendTransactions.d.cts +0 -4
- package/dist/useSignAndSendTransaction.cjs +0 -18
- package/dist/useSignAndSendTransaction.d.cts +0 -40
- package/dist/useSignAndSendTransactions.cjs +0 -15
- package/dist/useSignAndSendTransactions.d.cts +0 -35
- package/dist/useSignIn.cjs +0 -13
- package/dist/useSignIn.d.cts +0 -23
- package/dist/useSignMessage.cjs +0 -13
- package/dist/useSignMessage.d.cts +0 -236
- package/dist/useSignTransactions.cjs +0 -13
- package/dist/useSignTransactions.d.cts +0 -24
- package/dist/useSignatureStatus.cjs +0 -14
- package/dist/useSignatureStatus.d.cts +0 -26
- package/dist/useSolana.cjs +0 -10
- package/dist/useSolana.d.cts +0 -9
- package/dist/useSolanaClient.cjs +0 -10
- package/dist/useSolanaClient.d.cts +0 -45
- package/dist/useSubscription.cjs +0 -9
- package/dist/useSubscription.d.cts +0 -70
- package/dist/useTokenAccounts.cjs +0 -15
- package/dist/useTokenAccounts.d.cts +0 -19
- package/dist/useTokenBalance.cjs +0 -15
- package/dist/useTokenBalance.d.cts +0 -15
- package/dist/useTrackedData.cjs +0 -10
- package/dist/useTrackedData.d.cts +0 -98
- package/dist/useTransaction.cjs +0 -11
- package/dist/useTransaction.d.cts +0 -27
- package/dist/useTransactionConfirmation.cjs +0 -15
- package/dist/useTransactionConfirmation.d.cts +0 -38
- package/dist/useWallet.cjs +0 -12
- package/dist/useWallet.d.cts +0 -31
- package/dist/useWallets.cjs +0 -10
- package/dist/useWallets.d.cts +0 -11
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const errors = require('@vue-solana/core/errors');
|
|
4
|
-
const bs58 = require('bs58');
|
|
5
|
-
const vue = require('vue');
|
|
6
|
-
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
7
|
-
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
10
|
-
|
|
11
|
-
const bs58__default = /*#__PURE__*/_interopDefaultCompat(bs58);
|
|
12
|
-
|
|
13
|
-
function useSignatureStatus(signature, options = {}) {
|
|
14
|
-
const solana = useSolana.tryUseSolana();
|
|
15
|
-
const client = solana?.client ?? useConnection.useConnection();
|
|
16
|
-
const status = vue.shallowRef(null);
|
|
17
|
-
const loading = vue.shallowRef(false);
|
|
18
|
-
const error = vue.shallowRef(null);
|
|
19
|
-
let refreshId = 0;
|
|
20
|
-
let pollId = null;
|
|
21
|
-
let manuallyStoppedPolling = false;
|
|
22
|
-
async function refresh() {
|
|
23
|
-
const requestId = ++refreshId;
|
|
24
|
-
const value = vue.toValue(signature);
|
|
25
|
-
if (!value || !solana) {
|
|
26
|
-
status.value = null;
|
|
27
|
-
loading.value = false;
|
|
28
|
-
error.value = null;
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
loading.value = true;
|
|
32
|
-
error.value = null;
|
|
33
|
-
try {
|
|
34
|
-
const validSignature = parseTransactionSignature(value);
|
|
35
|
-
const response = await client.rpc.getSignatureStatuses([validSignature], {
|
|
36
|
-
searchTransactionHistory: options.searchTransactionHistory
|
|
37
|
-
}).send();
|
|
38
|
-
const nextRawStatus = response.value[0] ?? null;
|
|
39
|
-
const nextStatus = nextRawStatus ? normalizeSignatureStatus(nextRawStatus) : null;
|
|
40
|
-
if (requestId === refreshId) {
|
|
41
|
-
status.value = nextStatus;
|
|
42
|
-
}
|
|
43
|
-
return nextStatus;
|
|
44
|
-
} catch (cause) {
|
|
45
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
46
|
-
if (requestId === refreshId) {
|
|
47
|
-
status.value = null;
|
|
48
|
-
error.value = normalizedError;
|
|
49
|
-
}
|
|
50
|
-
throw normalizedError;
|
|
51
|
-
} finally {
|
|
52
|
-
if (requestId === refreshId) {
|
|
53
|
-
loading.value = false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function stopPolling() {
|
|
58
|
-
manuallyStoppedPolling = true;
|
|
59
|
-
stopCurrentPolling();
|
|
60
|
-
}
|
|
61
|
-
function stopCurrentPolling() {
|
|
62
|
-
if (pollId === null) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
clearInterval(pollId);
|
|
66
|
-
pollId = null;
|
|
67
|
-
}
|
|
68
|
-
function startPolling() {
|
|
69
|
-
stopCurrentPolling();
|
|
70
|
-
const value = vue.toValue(signature);
|
|
71
|
-
if (manuallyStoppedPolling || !options.pollIntervalMs || !value || !solana) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (options.pollIntervalMs <= 0) {
|
|
75
|
-
error.value = errors.createSolanaError("RPC_FAILURE", "pollIntervalMs must be greater than 0");
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
parseTransactionSignature(value);
|
|
80
|
-
} catch (cause) {
|
|
81
|
-
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
pollId = setInterval(() => {
|
|
85
|
-
void refresh().catch(() => void 0);
|
|
86
|
-
}, options.pollIntervalMs);
|
|
87
|
-
}
|
|
88
|
-
vue.onMounted(() => {
|
|
89
|
-
void refresh().catch(() => void 0);
|
|
90
|
-
startPolling();
|
|
91
|
-
});
|
|
92
|
-
vue.onUnmounted(() => {
|
|
93
|
-
refreshId += 1;
|
|
94
|
-
stopPolling();
|
|
95
|
-
});
|
|
96
|
-
vue.watch(
|
|
97
|
-
() => vue.toValue(signature),
|
|
98
|
-
() => {
|
|
99
|
-
void refresh().catch(() => void 0);
|
|
100
|
-
startPolling();
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
return {
|
|
104
|
-
status,
|
|
105
|
-
loading,
|
|
106
|
-
error,
|
|
107
|
-
refresh,
|
|
108
|
-
stopPolling
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function parseTransactionSignature(signature) {
|
|
112
|
-
let decodedSignature;
|
|
113
|
-
try {
|
|
114
|
-
decodedSignature = bs58__default.decode(signature);
|
|
115
|
-
} catch (cause) {
|
|
116
|
-
throw new TypeError("Invalid Solana transaction signature", { cause });
|
|
117
|
-
}
|
|
118
|
-
if (decodedSignature.length !== 64) {
|
|
119
|
-
throw new TypeError("Invalid Solana transaction signature");
|
|
120
|
-
}
|
|
121
|
-
return signature;
|
|
122
|
-
}
|
|
123
|
-
function normalizeSignatureStatus(status) {
|
|
124
|
-
return {
|
|
125
|
-
slot: Number(status.slot),
|
|
126
|
-
confirmations: status.confirmations === null ? null : Number(status.confirmations),
|
|
127
|
-
err: status.err,
|
|
128
|
-
confirmationStatus: status.confirmationStatus
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
exports.useSignatureStatus = useSignatureStatus;
|
|
@@ -1,58 +0,0 @@
|
|
|
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,84 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const errors = require('@vue-solana/core/errors');
|
|
4
|
-
const timeout = require('@vue-solana/core/timeout');
|
|
5
|
-
const transaction = require('@vue-solana/core/transaction');
|
|
6
|
-
const wallet = require('@vue-solana/core/wallet');
|
|
7
|
-
const vue = require('vue');
|
|
8
|
-
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
9
|
-
const useWallet = require('./vue.BGxz4dru.cjs');
|
|
10
|
-
const useTransactionConfirmation = require('./vue.Sbbm9JSu.cjs');
|
|
11
|
-
|
|
12
|
-
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
13
|
-
function useSignAndSendTransaction() {
|
|
14
|
-
const client = useConnection.useConnection();
|
|
15
|
-
const { wallet: wallet$1 } = useWallet.useWallet();
|
|
16
|
-
const signature = vue.ref(null);
|
|
17
|
-
const confirmation = vue.ref(null);
|
|
18
|
-
const status = vue.ref("idle");
|
|
19
|
-
const loading = vue.ref(false);
|
|
20
|
-
const error = vue.ref(null);
|
|
21
|
-
let executionId = 0;
|
|
22
|
-
async function execute(transaction$1, options) {
|
|
23
|
-
const currentExecutionId = ++executionId;
|
|
24
|
-
const { confirm, confirmation: confirmationOptions, ...sendOptions } = options ?? {};
|
|
25
|
-
const transactionOptions = Object.keys(sendOptions).length > 0 ? sendOptions : void 0;
|
|
26
|
-
status.value = "sending";
|
|
27
|
-
loading.value = true;
|
|
28
|
-
error.value = null;
|
|
29
|
-
confirmation.value = null;
|
|
30
|
-
const activeWallet = wallet$1.value;
|
|
31
|
-
if (!activeWallet) {
|
|
32
|
-
const normalizedError = wallet.createNoWalletSelectedError();
|
|
33
|
-
error.value = normalizedError;
|
|
34
|
-
status.value = "error";
|
|
35
|
-
loading.value = false;
|
|
36
|
-
throw normalizedError;
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
const nextSignature = await timeout.withSolanaTimeout(
|
|
40
|
-
transaction.signAndSendTransaction(client, activeWallet, transaction$1, transactionOptions),
|
|
41
|
-
SIGN_AND_SEND_TIMEOUT_MS,
|
|
42
|
-
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
43
|
-
);
|
|
44
|
-
if (currentExecutionId === executionId) {
|
|
45
|
-
signature.value = nextSignature;
|
|
46
|
-
status.value = confirm ? "confirming" : "sent";
|
|
47
|
-
}
|
|
48
|
-
if (!confirm) {
|
|
49
|
-
return nextSignature;
|
|
50
|
-
}
|
|
51
|
-
const nextConfirmation = await transaction.confirmTransactionSignature(
|
|
52
|
-
client,
|
|
53
|
-
nextSignature,
|
|
54
|
-
confirmationOptions
|
|
55
|
-
);
|
|
56
|
-
if (currentExecutionId === executionId) {
|
|
57
|
-
confirmation.value = nextConfirmation;
|
|
58
|
-
status.value = useTransactionConfirmation.getConfirmedTransactionStatus(nextConfirmation);
|
|
59
|
-
}
|
|
60
|
-
return nextSignature;
|
|
61
|
-
} catch (cause) {
|
|
62
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
63
|
-
if (currentExecutionId === executionId) {
|
|
64
|
-
error.value = normalizedError;
|
|
65
|
-
status.value = "error";
|
|
66
|
-
}
|
|
67
|
-
throw normalizedError;
|
|
68
|
-
} finally {
|
|
69
|
-
if (currentExecutionId === executionId) {
|
|
70
|
-
loading.value = false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
signature,
|
|
76
|
-
confirmation,
|
|
77
|
-
status,
|
|
78
|
-
loading,
|
|
79
|
-
error,
|
|
80
|
-
execute
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
exports.useSignAndSendTransaction = useSignAndSendTransaction;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
-
import { shallowRef, ref, onScopeDispose } from 'vue';
|
|
3
|
-
import { u as useClientCapability } from './vue.B9uRpSDJ.mjs';
|
|
4
|
-
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
5
|
-
|
|
6
|
-
const PLANNING_PROVIDER_HINT = "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`, and plan with a client that has a `payer` signer \u2014 Kit reads `client.payer` to set the fee payer.";
|
|
7
|
-
function usePlanTransaction() {
|
|
8
|
-
useClientCapability(["planTransaction", "payer"], {
|
|
9
|
-
hookName: "usePlanTransaction",
|
|
10
|
-
providerHint: PLANNING_PROVIDER_HINT
|
|
11
|
-
});
|
|
12
|
-
const { client } = useSolanaClient();
|
|
13
|
-
const transactionMessage = shallowRef(null);
|
|
14
|
-
const status = ref("idle");
|
|
15
|
-
const loading = ref(false);
|
|
16
|
-
const error = ref(null);
|
|
17
|
-
let executionId = 0;
|
|
18
|
-
let abortController;
|
|
19
|
-
onScopeDispose(() => {
|
|
20
|
-
abortController?.abort();
|
|
21
|
-
executionId++;
|
|
22
|
-
});
|
|
23
|
-
async function execute(input, config) {
|
|
24
|
-
abortController?.abort();
|
|
25
|
-
const controller = new AbortController();
|
|
26
|
-
abortController = controller;
|
|
27
|
-
const currentExecutionId = ++executionId;
|
|
28
|
-
const planner = client;
|
|
29
|
-
status.value = "planning";
|
|
30
|
-
loading.value = true;
|
|
31
|
-
error.value = null;
|
|
32
|
-
transactionMessage.value = null;
|
|
33
|
-
try {
|
|
34
|
-
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
35
|
-
const message = await planner.planTransaction(input, { abortSignal });
|
|
36
|
-
if (currentExecutionId === executionId) {
|
|
37
|
-
transactionMessage.value = message;
|
|
38
|
-
status.value = "planned";
|
|
39
|
-
}
|
|
40
|
-
return message;
|
|
41
|
-
} catch (cause) {
|
|
42
|
-
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
43
|
-
if (currentExecutionId === executionId) {
|
|
44
|
-
error.value = normalizedError;
|
|
45
|
-
status.value = "error";
|
|
46
|
-
}
|
|
47
|
-
throw normalizedError;
|
|
48
|
-
} finally {
|
|
49
|
-
if (currentExecutionId === executionId) {
|
|
50
|
-
loading.value = false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
transactionMessage,
|
|
56
|
-
status,
|
|
57
|
-
loading,
|
|
58
|
-
error,
|
|
59
|
-
execute
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function usePlanTransactions() {
|
|
63
|
-
useClientCapability(["planTransactions", "payer"], {
|
|
64
|
-
hookName: "usePlanTransactions",
|
|
65
|
-
providerHint: PLANNING_PROVIDER_HINT
|
|
66
|
-
});
|
|
67
|
-
const { client } = useSolanaClient();
|
|
68
|
-
const transactionPlan = shallowRef(null);
|
|
69
|
-
const status = ref("idle");
|
|
70
|
-
const loading = ref(false);
|
|
71
|
-
const error = ref(null);
|
|
72
|
-
let executionId = 0;
|
|
73
|
-
let abortController;
|
|
74
|
-
onScopeDispose(() => {
|
|
75
|
-
abortController?.abort();
|
|
76
|
-
executionId++;
|
|
77
|
-
});
|
|
78
|
-
async function execute(input, config) {
|
|
79
|
-
abortController?.abort();
|
|
80
|
-
const controller = new AbortController();
|
|
81
|
-
abortController = controller;
|
|
82
|
-
const currentExecutionId = ++executionId;
|
|
83
|
-
const planner = client;
|
|
84
|
-
status.value = "planning";
|
|
85
|
-
loading.value = true;
|
|
86
|
-
error.value = null;
|
|
87
|
-
transactionPlan.value = null;
|
|
88
|
-
try {
|
|
89
|
-
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
90
|
-
const plan = await planner.planTransactions(input, { abortSignal });
|
|
91
|
-
if (currentExecutionId === executionId) {
|
|
92
|
-
transactionPlan.value = plan;
|
|
93
|
-
status.value = "planned";
|
|
94
|
-
}
|
|
95
|
-
return plan;
|
|
96
|
-
} catch (cause) {
|
|
97
|
-
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
98
|
-
if (currentExecutionId === executionId) {
|
|
99
|
-
error.value = normalizedError;
|
|
100
|
-
status.value = "error";
|
|
101
|
-
}
|
|
102
|
-
throw normalizedError;
|
|
103
|
-
} finally {
|
|
104
|
-
if (currentExecutionId === executionId) {
|
|
105
|
-
loading.value = false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
transactionPlan,
|
|
111
|
-
status,
|
|
112
|
-
loading,
|
|
113
|
-
error,
|
|
114
|
-
execute
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export { usePlanTransactions as a, usePlanTransaction as u };
|
|
@@ -1,38 +0,0 @@
|
|
|
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;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const errors = require('@vue-solana/core/errors');
|
|
4
|
-
const timeout = require('@vue-solana/core/timeout');
|
|
5
|
-
const wallet = require('@vue-solana/core/wallet');
|
|
6
|
-
const vue = require('vue');
|
|
7
|
-
const useWallet = require('./vue.BGxz4dru.cjs');
|
|
8
|
-
|
|
9
|
-
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
10
|
-
class PartialSignAndSendError extends errors.SolanaError {
|
|
11
|
-
constructor(cause, signatures) {
|
|
12
|
-
super(cause.code, cause.message, { cause: cause.cause, feature: cause.feature });
|
|
13
|
-
this.signatures = signatures;
|
|
14
|
-
this.name = "PartialSignAndSendError";
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function useSignAndSendTransactions() {
|
|
18
|
-
const { wallet: wallet$1 } = useWallet.useWallet();
|
|
19
|
-
const signatures = vue.shallowRef(null);
|
|
20
|
-
const status = vue.ref("idle");
|
|
21
|
-
const loading = vue.ref(false);
|
|
22
|
-
const error = vue.ref(null);
|
|
23
|
-
let executionId = 0;
|
|
24
|
-
async function execute(transactions, options) {
|
|
25
|
-
const currentExecutionId = ++executionId;
|
|
26
|
-
status.value = "sending";
|
|
27
|
-
loading.value = true;
|
|
28
|
-
error.value = null;
|
|
29
|
-
signatures.value = null;
|
|
30
|
-
const activeWallet = wallet$1.value;
|
|
31
|
-
if (!activeWallet) {
|
|
32
|
-
const normalizedError = wallet.createNoWalletSelectedError();
|
|
33
|
-
error.value = normalizedError;
|
|
34
|
-
status.value = "error";
|
|
35
|
-
loading.value = false;
|
|
36
|
-
throw normalizedError;
|
|
37
|
-
}
|
|
38
|
-
const sendSingularSequentially = async () => {
|
|
39
|
-
const collected = [];
|
|
40
|
-
for (const transaction of transactions) {
|
|
41
|
-
try {
|
|
42
|
-
const result = await activeWallet.signAndSendTransaction(transaction, options);
|
|
43
|
-
collected.push(result.signature);
|
|
44
|
-
} catch (cause) {
|
|
45
|
-
throw new PartialSignAndSendError(errors.normalizeSolanaError(cause, "RPC_FAILURE"), collected);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return collected;
|
|
49
|
-
};
|
|
50
|
-
try {
|
|
51
|
-
wallet.assertWalletCanSignAndSendTransactions(activeWallet);
|
|
52
|
-
const send = timeout.withSolanaTimeout(
|
|
53
|
-
activeWallet.signAndSendTransactions ? activeWallet.signAndSendTransactions(transactions, options) : sendSingularSequentially(),
|
|
54
|
-
SIGN_AND_SEND_TIMEOUT_MS,
|
|
55
|
-
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
56
|
-
);
|
|
57
|
-
const result = await send;
|
|
58
|
-
if (currentExecutionId === executionId) {
|
|
59
|
-
signatures.value = result;
|
|
60
|
-
status.value = "sent";
|
|
61
|
-
}
|
|
62
|
-
return result;
|
|
63
|
-
} catch (cause) {
|
|
64
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
65
|
-
if (currentExecutionId === executionId) {
|
|
66
|
-
error.value = normalizedError;
|
|
67
|
-
status.value = "error";
|
|
68
|
-
}
|
|
69
|
-
throw normalizedError;
|
|
70
|
-
} finally {
|
|
71
|
-
if (currentExecutionId === executionId) {
|
|
72
|
-
loading.value = false;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
signatures,
|
|
78
|
-
status,
|
|
79
|
-
loading,
|
|
80
|
-
error,
|
|
81
|
-
execute
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
exports.PartialSignAndSendError = PartialSignAndSendError;
|
|
86
|
-
exports.useSignAndSendTransactions = useSignAndSendTransactions;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const errors = require('@vue-solana/core/errors');
|
|
4
|
-
const vue = require('vue');
|
|
5
|
-
const address = require('@vue-solana/core/address');
|
|
6
|
-
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
7
|
-
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
8
|
-
const decodeBase64 = require('./vue.DNxOpDXz.cjs');
|
|
9
|
-
|
|
10
|
-
function useAccountInfo(address$1, options = {}) {
|
|
11
|
-
const solana = useSolana.tryUseSolana();
|
|
12
|
-
const client = solana?.client ?? useConnection.useConnection();
|
|
13
|
-
const accountInfo = vue.shallowRef(null);
|
|
14
|
-
const loading = vue.shallowRef(false);
|
|
15
|
-
const error = vue.shallowRef(null);
|
|
16
|
-
let refreshId = 0;
|
|
17
|
-
async function refresh() {
|
|
18
|
-
const requestId = ++refreshId;
|
|
19
|
-
const value = vue.toValue(address$1);
|
|
20
|
-
if (!value || !solana) {
|
|
21
|
-
accountInfo.value = null;
|
|
22
|
-
loading.value = false;
|
|
23
|
-
error.value = null;
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
loading.value = true;
|
|
27
|
-
error.value = null;
|
|
28
|
-
try {
|
|
29
|
-
const parsedAddress = address.parseAddress(value);
|
|
30
|
-
if (!parsedAddress) {
|
|
31
|
-
accountInfo.value = null;
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
const { value: account } = await client.rpc.getAccountInfo(parsedAddress, {
|
|
35
|
-
encoding: "base64",
|
|
36
|
-
commitment: options.commitment
|
|
37
|
-
}).send();
|
|
38
|
-
const nextAccountInfo = account ? normalizeAccountInfo(account) : null;
|
|
39
|
-
if (requestId === refreshId) {
|
|
40
|
-
accountInfo.value = nextAccountInfo;
|
|
41
|
-
}
|
|
42
|
-
return nextAccountInfo;
|
|
43
|
-
} catch (cause) {
|
|
44
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
45
|
-
if (requestId === refreshId) {
|
|
46
|
-
accountInfo.value = null;
|
|
47
|
-
error.value = normalizedError;
|
|
48
|
-
}
|
|
49
|
-
throw normalizedError;
|
|
50
|
-
} finally {
|
|
51
|
-
if (requestId === refreshId) {
|
|
52
|
-
loading.value = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
vue.onMounted(() => {
|
|
57
|
-
void refresh().catch(() => void 0);
|
|
58
|
-
});
|
|
59
|
-
vue.watch(
|
|
60
|
-
() => vue.toValue(address$1),
|
|
61
|
-
() => {
|
|
62
|
-
void refresh().catch(() => void 0);
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
return {
|
|
66
|
-
accountInfo,
|
|
67
|
-
loading,
|
|
68
|
-
error,
|
|
69
|
-
refresh
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function normalizeAccountInfo(account) {
|
|
73
|
-
return {
|
|
74
|
-
executable: account.executable,
|
|
75
|
-
lamports: Number(account.lamports),
|
|
76
|
-
owner: account.owner,
|
|
77
|
-
space: Number(account.space),
|
|
78
|
-
data: decodeBase64.decodeBase64(account.data[0])
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
exports.useAccountInfo = useAccountInfo;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { confirmTransactionSignature } from '@vue-solana/core/transaction';
|
|
2
|
-
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
|
-
import { ref } from 'vue';
|
|
4
|
-
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
5
|
-
|
|
6
|
-
function getConfirmedTransactionStatus(confirmation) {
|
|
7
|
-
if (confirmation.commitment === "finalized") {
|
|
8
|
-
return "finalized";
|
|
9
|
-
}
|
|
10
|
-
return confirmation.commitment === "processed" ? "processed" : "confirmed";
|
|
11
|
-
}
|
|
12
|
-
function useTransactionConfirmation(defaultOptions = {}) {
|
|
13
|
-
const client = useConnection();
|
|
14
|
-
const signature = ref(null);
|
|
15
|
-
const confirmation = ref(null);
|
|
16
|
-
const status = ref("idle");
|
|
17
|
-
const loading = ref(false);
|
|
18
|
-
const error = ref(null);
|
|
19
|
-
let executionId = 0;
|
|
20
|
-
async function confirm(nextSignature, options = {}) {
|
|
21
|
-
const currentExecutionId = ++executionId;
|
|
22
|
-
const confirmationOptions = { ...defaultOptions, ...options };
|
|
23
|
-
signature.value = nextSignature;
|
|
24
|
-
confirmation.value = null;
|
|
25
|
-
status.value = "confirming";
|
|
26
|
-
loading.value = true;
|
|
27
|
-
error.value = null;
|
|
28
|
-
try {
|
|
29
|
-
const nextConfirmation = await confirmTransactionSignature(
|
|
30
|
-
client,
|
|
31
|
-
nextSignature,
|
|
32
|
-
confirmationOptions
|
|
33
|
-
);
|
|
34
|
-
if (currentExecutionId === executionId) {
|
|
35
|
-
confirmation.value = nextConfirmation;
|
|
36
|
-
status.value = getConfirmedTransactionStatus(nextConfirmation);
|
|
37
|
-
}
|
|
38
|
-
return nextConfirmation;
|
|
39
|
-
} catch (cause) {
|
|
40
|
-
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
41
|
-
if (currentExecutionId === executionId) {
|
|
42
|
-
error.value = normalizedError;
|
|
43
|
-
status.value = "error";
|
|
44
|
-
}
|
|
45
|
-
throw normalizedError;
|
|
46
|
-
} finally {
|
|
47
|
-
if (currentExecutionId === executionId) {
|
|
48
|
-
loading.value = false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function reset() {
|
|
53
|
-
executionId += 1;
|
|
54
|
-
signature.value = null;
|
|
55
|
-
confirmation.value = null;
|
|
56
|
-
status.value = "idle";
|
|
57
|
-
loading.value = false;
|
|
58
|
-
error.value = null;
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
signature,
|
|
62
|
-
confirmation,
|
|
63
|
-
status,
|
|
64
|
-
loading,
|
|
65
|
-
error,
|
|
66
|
-
confirm,
|
|
67
|
-
reset
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { getConfirmedTransactionStatus as g, useTransactionConfirmation as u };
|