@vue-solana/vue 2.6.1 → 3.0.1
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 +35 -55
- 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 -79
- package/dist/useAccountInfo.d.mts +4 -4
- package/dist/useAccountInfo.d.ts +4 -4
- package/dist/useAccountInfo.mjs +1 -9
- package/dist/useAction.mjs +0 -2
- package/dist/useAirdrop.mjs +0 -7
- package/dist/useBalance.d.mts +4 -4
- package/dist/useBalance.d.ts +4 -4
- package/dist/useBalance.mjs +1 -8
- package/dist/useClientCapability.mjs +0 -4
- package/dist/useConnection.d.mts +6 -6
- package/dist/useConnection.d.ts +6 -6
- package/dist/useConnection.mjs +0 -4
- package/dist/useIdentity.mjs +0 -5
- package/dist/usePayer.mjs +0 -5
- package/dist/usePlanTransaction.d.mts +12 -13
- package/dist/usePlanTransaction.d.ts +12 -13
- package/dist/usePlanTransaction.mjs +1 -7
- package/dist/usePlanTransactions.d.mts +2 -1
- package/dist/usePlanTransactions.d.ts +2 -1
- package/dist/usePlanTransactions.mjs +1 -7
- package/dist/useProgramAccounts.d.mts +5 -15
- package/dist/useProgramAccounts.d.ts +5 -15
- package/dist/useProgramAccounts.mjs +1 -9
- package/dist/useRequest.mjs +0 -4
- package/dist/useRpc.d.mts +6 -6
- package/dist/useRpc.d.ts +6 -6
- package/dist/useRpc.mjs +0 -3
- package/dist/useSelectedWalletAccount.mjs +0 -2
- package/dist/useSendTransaction.d.mts +11 -12
- package/dist/useSendTransaction.d.ts +11 -12
- package/dist/useSendTransaction.mjs +1 -7
- package/dist/useSendTransactions.d.mts +2 -1
- package/dist/useSendTransactions.d.ts +2 -1
- package/dist/useSendTransactions.mjs +1 -7
- package/dist/useSignAndSendTransaction.d.mts +1 -1
- package/dist/useSignAndSendTransaction.d.ts +1 -1
- package/dist/useSignAndSendTransaction.mjs +1 -12
- package/dist/useSignAndSendTransactions.d.mts +2 -2
- package/dist/useSignAndSendTransactions.d.ts +2 -2
- package/dist/useSignAndSendTransactions.mjs +1 -8
- package/dist/useSignIn.d.mts +4 -4
- package/dist/useSignIn.d.ts +4 -4
- package/dist/useSignIn.mjs +1 -7
- package/dist/useSignMessage.d.mts +4 -4
- package/dist/useSignMessage.d.ts +4 -4
- package/dist/useSignMessage.mjs +1 -7
- package/dist/useSignTransactions.d.mts +4 -4
- package/dist/useSignTransactions.d.ts +4 -4
- package/dist/useSignTransactions.mjs +1 -7
- package/dist/useSignatureStatus.mjs +0 -7
- package/dist/useSolana.mjs +0 -2
- package/dist/useSolanaClient.d.mts +6 -6
- package/dist/useSolanaClient.d.ts +6 -6
- package/dist/useSolanaClient.mjs +0 -3
- package/dist/useSubscription.mjs +1 -3
- package/dist/useTokenAccounts.d.mts +4 -4
- package/dist/useTokenAccounts.d.ts +4 -4
- package/dist/useTokenAccounts.mjs +1 -9
- package/dist/useTokenBalance.d.mts +9 -7
- package/dist/useTokenBalance.d.ts +9 -7
- package/dist/useTokenBalance.mjs +1 -9
- package/dist/useTrackedData.mjs +1 -4
- package/dist/useTransaction.mjs +0 -4
- package/dist/useTransactionConfirmation.d.mts +4 -4
- package/dist/useTransactionConfirmation.d.ts +4 -4
- package/dist/useTransactionConfirmation.mjs +1 -8
- package/dist/useWallet.mjs +0 -5
- package/dist/useWallets.mjs +0 -3
- 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,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
4
|
-
|
|
5
|
-
function useWallets() {
|
|
6
|
-
const solana = useSolana.useSolana();
|
|
7
|
-
return {
|
|
8
|
-
wallets: solana.wallets,
|
|
9
|
-
selectedWallet: solana.selectedWallet,
|
|
10
|
-
refreshWallets: solana.refreshWallets,
|
|
11
|
-
selectWallet: solana.selectWallet
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.useWallets = useWallets;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { SolanaError } from '@vue-solana/core/errors';
|
|
2
|
-
import { SolanaContext, SolanaWallet, SolanaWalletInfo } from '@vue-solana/core/types';
|
|
3
|
-
import { Ref, InjectionKey } from 'vue';
|
|
4
|
-
|
|
5
|
-
type SolanaConnectionStatus = "idle" | "checking" | "connected" | "error";
|
|
6
|
-
interface VueSolanaContext extends SolanaContext {
|
|
7
|
-
wallet: Ref<SolanaWallet | null>;
|
|
8
|
-
status: Ref<SolanaConnectionStatus>;
|
|
9
|
-
error: Ref<SolanaError | null>;
|
|
10
|
-
latestBlockhash: Ref<string | null>;
|
|
11
|
-
wallets: Ref<SolanaWalletInfo[]>;
|
|
12
|
-
selectedWallet: Ref<SolanaWalletInfo | null>;
|
|
13
|
-
checkConnection: () => Promise<void>;
|
|
14
|
-
setWallet: (wallet: SolanaWallet | null) => void;
|
|
15
|
-
refreshWallets: () => void;
|
|
16
|
-
selectWallet: (wallet: SolanaWalletInfo | null) => void;
|
|
17
|
-
}
|
|
18
|
-
declare const solanaInjectionKey: InjectionKey<VueSolanaContext>;
|
|
19
|
-
|
|
20
|
-
export { solanaInjectionKey as s };
|
|
21
|
-
export type { SolanaConnectionStatus as S, VueSolanaContext as V };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function decodeBase64(value) {
|
|
4
|
-
const binary = atob(value);
|
|
5
|
-
const bytes = new Uint8Array(binary.length);
|
|
6
|
-
for (let index = 0; index < binary.length; index += 1) {
|
|
7
|
-
bytes[index] = binary.charCodeAt(index);
|
|
8
|
-
}
|
|
9
|
-
return bytes;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
exports.decodeBase64 = decodeBase64;
|
|
@@ -1,87 +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 useProgramAccounts(programId, options = {}) {
|
|
11
|
-
const solana = useSolana.tryUseSolana();
|
|
12
|
-
const client = solana?.client ?? useConnection.useConnection();
|
|
13
|
-
const accounts = vue.shallowRef([]);
|
|
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(programId);
|
|
20
|
-
if (!value || !solana) {
|
|
21
|
-
accounts.value = [];
|
|
22
|
-
loading.value = false;
|
|
23
|
-
error.value = null;
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
loading.value = true;
|
|
27
|
-
error.value = null;
|
|
28
|
-
try {
|
|
29
|
-
const parsedAddress = address.parseAddress(value);
|
|
30
|
-
if (!parsedAddress) {
|
|
31
|
-
accounts.value = [];
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
34
|
-
const { value: response } = await client.rpc.getProgramAccounts(parsedAddress, {
|
|
35
|
-
encoding: "base64",
|
|
36
|
-
commitment: options.commitment,
|
|
37
|
-
dataSlice: options.dataSlice,
|
|
38
|
-
filters: options.filters
|
|
39
|
-
}).send();
|
|
40
|
-
const nextAccounts = response.map(({ pubkey, account }) => ({
|
|
41
|
-
pubkey,
|
|
42
|
-
account: {
|
|
43
|
-
executable: account.executable,
|
|
44
|
-
lamports: Number(account.lamports),
|
|
45
|
-
owner: account.owner,
|
|
46
|
-
space: Number(account.space),
|
|
47
|
-
data: decodeBase64.decodeBase64(account.data[0])
|
|
48
|
-
}
|
|
49
|
-
}));
|
|
50
|
-
if (requestId === refreshId) {
|
|
51
|
-
accounts.value = nextAccounts;
|
|
52
|
-
}
|
|
53
|
-
return nextAccounts;
|
|
54
|
-
} catch (cause) {
|
|
55
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
56
|
-
if (requestId === refreshId) {
|
|
57
|
-
accounts.value = [];
|
|
58
|
-
error.value = normalizedError;
|
|
59
|
-
}
|
|
60
|
-
throw normalizedError;
|
|
61
|
-
} finally {
|
|
62
|
-
if (requestId === refreshId) {
|
|
63
|
-
loading.value = false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
vue.onMounted(() => {
|
|
68
|
-
void refresh().catch(() => void 0);
|
|
69
|
-
});
|
|
70
|
-
vue.onUnmounted(() => {
|
|
71
|
-
refreshId += 1;
|
|
72
|
-
});
|
|
73
|
-
vue.watch(
|
|
74
|
-
() => vue.toValue(programId),
|
|
75
|
-
() => {
|
|
76
|
-
void refresh().catch(() => void 0);
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
return {
|
|
80
|
-
accounts,
|
|
81
|
-
loading,
|
|
82
|
-
error,
|
|
83
|
-
refresh
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
exports.useProgramAccounts = useProgramAccounts;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const errors = require('@vue-solana/core/errors');
|
|
4
|
-
const vue = require('vue');
|
|
5
|
-
const useClientCapability = require('./vue.4C5kX4fE.cjs');
|
|
6
|
-
const useSolanaClient = require('./vue.BIxphCAq.cjs');
|
|
7
|
-
|
|
8
|
-
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.";
|
|
9
|
-
function usePlanTransaction() {
|
|
10
|
-
useClientCapability.useClientCapability(["planTransaction", "payer"], {
|
|
11
|
-
hookName: "usePlanTransaction",
|
|
12
|
-
providerHint: PLANNING_PROVIDER_HINT
|
|
13
|
-
});
|
|
14
|
-
const { client } = useSolanaClient.useSolanaClient();
|
|
15
|
-
const transactionMessage = vue.shallowRef(null);
|
|
16
|
-
const status = vue.ref("idle");
|
|
17
|
-
const loading = vue.ref(false);
|
|
18
|
-
const error = vue.ref(null);
|
|
19
|
-
let executionId = 0;
|
|
20
|
-
let abortController;
|
|
21
|
-
vue.onScopeDispose(() => {
|
|
22
|
-
abortController?.abort();
|
|
23
|
-
executionId++;
|
|
24
|
-
});
|
|
25
|
-
async function execute(input, config) {
|
|
26
|
-
abortController?.abort();
|
|
27
|
-
const controller = new AbortController();
|
|
28
|
-
abortController = controller;
|
|
29
|
-
const currentExecutionId = ++executionId;
|
|
30
|
-
const planner = client;
|
|
31
|
-
status.value = "planning";
|
|
32
|
-
loading.value = true;
|
|
33
|
-
error.value = null;
|
|
34
|
-
transactionMessage.value = null;
|
|
35
|
-
try {
|
|
36
|
-
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
37
|
-
const message = await planner.planTransaction(input, { abortSignal });
|
|
38
|
-
if (currentExecutionId === executionId) {
|
|
39
|
-
transactionMessage.value = message;
|
|
40
|
-
status.value = "planned";
|
|
41
|
-
}
|
|
42
|
-
return message;
|
|
43
|
-
} catch (cause) {
|
|
44
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
45
|
-
if (currentExecutionId === executionId) {
|
|
46
|
-
error.value = normalizedError;
|
|
47
|
-
status.value = "error";
|
|
48
|
-
}
|
|
49
|
-
throw normalizedError;
|
|
50
|
-
} finally {
|
|
51
|
-
if (currentExecutionId === executionId) {
|
|
52
|
-
loading.value = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
transactionMessage,
|
|
58
|
-
status,
|
|
59
|
-
loading,
|
|
60
|
-
error,
|
|
61
|
-
execute
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function usePlanTransactions() {
|
|
65
|
-
useClientCapability.useClientCapability(["planTransactions", "payer"], {
|
|
66
|
-
hookName: "usePlanTransactions",
|
|
67
|
-
providerHint: PLANNING_PROVIDER_HINT
|
|
68
|
-
});
|
|
69
|
-
const { client } = useSolanaClient.useSolanaClient();
|
|
70
|
-
const transactionPlan = vue.shallowRef(null);
|
|
71
|
-
const status = vue.ref("idle");
|
|
72
|
-
const loading = vue.ref(false);
|
|
73
|
-
const error = vue.ref(null);
|
|
74
|
-
let executionId = 0;
|
|
75
|
-
let abortController;
|
|
76
|
-
vue.onScopeDispose(() => {
|
|
77
|
-
abortController?.abort();
|
|
78
|
-
executionId++;
|
|
79
|
-
});
|
|
80
|
-
async function execute(input, config) {
|
|
81
|
-
abortController?.abort();
|
|
82
|
-
const controller = new AbortController();
|
|
83
|
-
abortController = controller;
|
|
84
|
-
const currentExecutionId = ++executionId;
|
|
85
|
-
const planner = client;
|
|
86
|
-
status.value = "planning";
|
|
87
|
-
loading.value = true;
|
|
88
|
-
error.value = null;
|
|
89
|
-
transactionPlan.value = null;
|
|
90
|
-
try {
|
|
91
|
-
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
92
|
-
const plan = await planner.planTransactions(input, { abortSignal });
|
|
93
|
-
if (currentExecutionId === executionId) {
|
|
94
|
-
transactionPlan.value = plan;
|
|
95
|
-
status.value = "planned";
|
|
96
|
-
}
|
|
97
|
-
return plan;
|
|
98
|
-
} catch (cause) {
|
|
99
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
100
|
-
if (currentExecutionId === executionId) {
|
|
101
|
-
error.value = normalizedError;
|
|
102
|
-
status.value = "error";
|
|
103
|
-
}
|
|
104
|
-
throw normalizedError;
|
|
105
|
-
} finally {
|
|
106
|
-
if (currentExecutionId === executionId) {
|
|
107
|
-
loading.value = false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
transactionPlan,
|
|
113
|
-
status,
|
|
114
|
-
loading,
|
|
115
|
-
error,
|
|
116
|
-
execute
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
exports.usePlanTransaction = usePlanTransaction;
|
|
121
|
-
exports.usePlanTransactions = usePlanTransactions;
|
|
@@ -1,173 +0,0 @@
|
|
|
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(override) {
|
|
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 = override ? override.abortSignal : 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: (options2) => {
|
|
164
|
-
buildAndConnect(options2);
|
|
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;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const address = require('@vue-solana/core/address');
|
|
4
|
-
const errors = require('@vue-solana/core/errors');
|
|
5
|
-
const vue = require('vue');
|
|
6
|
-
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
7
|
-
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
8
|
-
|
|
9
|
-
function useBalance(address$1, commitment) {
|
|
10
|
-
const solana = useSolana.tryUseSolana();
|
|
11
|
-
const client = solana?.client ?? useConnection.useConnection();
|
|
12
|
-
const balance = vue.shallowRef(null);
|
|
13
|
-
const loading = vue.shallowRef(false);
|
|
14
|
-
const error = vue.shallowRef(null);
|
|
15
|
-
let refreshId = 0;
|
|
16
|
-
async function refresh() {
|
|
17
|
-
const requestId = ++refreshId;
|
|
18
|
-
const value = vue.toValue(address$1);
|
|
19
|
-
if (!value || !solana) {
|
|
20
|
-
balance.value = null;
|
|
21
|
-
loading.value = false;
|
|
22
|
-
error.value = null;
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
loading.value = true;
|
|
26
|
-
error.value = null;
|
|
27
|
-
try {
|
|
28
|
-
const parsedAddress = address.parseAddress(value);
|
|
29
|
-
if (!parsedAddress) {
|
|
30
|
-
balance.value = null;
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const { value: lamports } = await client.rpc.getBalance(parsedAddress, commitment ? { commitment } : void 0).send();
|
|
34
|
-
if (requestId === refreshId) {
|
|
35
|
-
balance.value = Number(lamports);
|
|
36
|
-
}
|
|
37
|
-
return Number(lamports);
|
|
38
|
-
} catch (cause) {
|
|
39
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
40
|
-
if (requestId === refreshId) {
|
|
41
|
-
error.value = normalizedError;
|
|
42
|
-
}
|
|
43
|
-
throw normalizedError;
|
|
44
|
-
} finally {
|
|
45
|
-
if (requestId === refreshId) {
|
|
46
|
-
loading.value = false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
vue.onMounted(() => {
|
|
51
|
-
void refresh().catch(() => void 0);
|
|
52
|
-
});
|
|
53
|
-
vue.watch(
|
|
54
|
-
() => vue.toValue(address$1),
|
|
55
|
-
() => {
|
|
56
|
-
void refresh().catch(() => void 0);
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
return {
|
|
60
|
-
balance,
|
|
61
|
-
loading,
|
|
62
|
-
error,
|
|
63
|
-
refresh
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
exports.useBalance = useBalance;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const vue = require('vue');
|
|
4
|
-
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
5
|
-
|
|
6
|
-
function useRpc() {
|
|
7
|
-
const solana = useSolana.useSolana();
|
|
8
|
-
return {
|
|
9
|
-
cluster: vue.computed(() => solana.cluster),
|
|
10
|
-
endpoint: vue.computed(() => solana.endpoint),
|
|
11
|
-
wsEndpoint: vue.computed(() => solana.wsEndpoint),
|
|
12
|
-
status: solana.status,
|
|
13
|
-
error: solana.error,
|
|
14
|
-
latestBlockhash: solana.latestBlockhash,
|
|
15
|
-
checkConnection: solana.checkConnection,
|
|
16
|
-
client: solana.client
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.useRpc = useRpc;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
-
import { createNoWalletSelectedError, assertWalletCanSignMessage } from '@vue-solana/core/wallet';
|
|
3
|
-
import { ref } from 'vue';
|
|
4
|
-
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
5
|
-
|
|
6
|
-
function useSignMessage() {
|
|
7
|
-
const { wallet } = useWallet();
|
|
8
|
-
const signedMessage = ref(null);
|
|
9
|
-
const signature = ref(null);
|
|
10
|
-
const status = ref("idle");
|
|
11
|
-
const loading = ref(false);
|
|
12
|
-
const error = ref(null);
|
|
13
|
-
let executionId = 0;
|
|
14
|
-
async function execute(message) {
|
|
15
|
-
const currentExecutionId = ++executionId;
|
|
16
|
-
status.value = "signing";
|
|
17
|
-
loading.value = true;
|
|
18
|
-
error.value = null;
|
|
19
|
-
signedMessage.value = null;
|
|
20
|
-
signature.value = null;
|
|
21
|
-
const activeWallet = wallet.value;
|
|
22
|
-
if (!activeWallet) {
|
|
23
|
-
const normalizedError = createNoWalletSelectedError();
|
|
24
|
-
error.value = normalizedError;
|
|
25
|
-
status.value = "error";
|
|
26
|
-
loading.value = false;
|
|
27
|
-
throw normalizedError;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
assertWalletCanSignMessage(activeWallet);
|
|
31
|
-
const result = await activeWallet.signMessage(message);
|
|
32
|
-
if (currentExecutionId === executionId) {
|
|
33
|
-
signedMessage.value = result.signedMessage;
|
|
34
|
-
signature.value = result.signature;
|
|
35
|
-
status.value = "signed";
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
} catch (cause) {
|
|
39
|
-
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
40
|
-
if (currentExecutionId === executionId) {
|
|
41
|
-
error.value = normalizedError;
|
|
42
|
-
status.value = "error";
|
|
43
|
-
}
|
|
44
|
-
throw normalizedError;
|
|
45
|
-
} finally {
|
|
46
|
-
if (currentExecutionId === executionId) {
|
|
47
|
-
loading.value = false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
signedMessage,
|
|
53
|
-
signature,
|
|
54
|
-
status,
|
|
55
|
-
loading,
|
|
56
|
-
error,
|
|
57
|
-
execute
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { useSignMessage as u };
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const transaction = require('@vue-solana/core/transaction');
|
|
4
|
-
const errors = require('@vue-solana/core/errors');
|
|
5
|
-
const vue = require('vue');
|
|
6
|
-
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
7
|
-
|
|
8
|
-
function getConfirmedTransactionStatus(confirmation) {
|
|
9
|
-
if (confirmation.commitment === "finalized") {
|
|
10
|
-
return "finalized";
|
|
11
|
-
}
|
|
12
|
-
return confirmation.commitment === "processed" ? "processed" : "confirmed";
|
|
13
|
-
}
|
|
14
|
-
function useTransactionConfirmation(defaultOptions = {}) {
|
|
15
|
-
const client = useConnection.useConnection();
|
|
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 confirm(nextSignature, options = {}) {
|
|
23
|
-
const currentExecutionId = ++executionId;
|
|
24
|
-
const confirmationOptions = { ...defaultOptions, ...options };
|
|
25
|
-
signature.value = nextSignature;
|
|
26
|
-
confirmation.value = null;
|
|
27
|
-
status.value = "confirming";
|
|
28
|
-
loading.value = true;
|
|
29
|
-
error.value = null;
|
|
30
|
-
try {
|
|
31
|
-
const nextConfirmation = await transaction.confirmTransactionSignature(
|
|
32
|
-
client,
|
|
33
|
-
nextSignature,
|
|
34
|
-
confirmationOptions
|
|
35
|
-
);
|
|
36
|
-
if (currentExecutionId === executionId) {
|
|
37
|
-
confirmation.value = nextConfirmation;
|
|
38
|
-
status.value = getConfirmedTransactionStatus(nextConfirmation);
|
|
39
|
-
}
|
|
40
|
-
return nextConfirmation;
|
|
41
|
-
} catch (cause) {
|
|
42
|
-
const normalizedError = errors.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
|
-
function reset() {
|
|
55
|
-
executionId += 1;
|
|
56
|
-
signature.value = null;
|
|
57
|
-
confirmation.value = null;
|
|
58
|
-
status.value = "idle";
|
|
59
|
-
loading.value = false;
|
|
60
|
-
error.value = null;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
signature,
|
|
64
|
-
confirmation,
|
|
65
|
-
status,
|
|
66
|
-
loading,
|
|
67
|
-
error,
|
|
68
|
-
confirm,
|
|
69
|
-
reset
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
exports.getConfirmedTransactionStatus = getConfirmedTransactionStatus;
|
|
74
|
-
exports.useTransactionConfirmation = useTransactionConfirmation;
|