@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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { confirmTransactionSignature } from '@vue-solana/core/transaction';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { u as useExecution } from './vue.DlihC5GG.mjs';
|
|
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 {
|
|
17
|
+
status,
|
|
18
|
+
loading,
|
|
19
|
+
error,
|
|
20
|
+
execute,
|
|
21
|
+
reset: resetExecution
|
|
22
|
+
} = useExecution("confirming");
|
|
23
|
+
function confirm(nextSignature, options = {}) {
|
|
24
|
+
const confirmationOptions = { ...defaultOptions, ...options };
|
|
25
|
+
signature.value = nextSignature;
|
|
26
|
+
confirmation.value = null;
|
|
27
|
+
return execute(
|
|
28
|
+
() => confirmTransactionSignature(client, nextSignature, confirmationOptions),
|
|
29
|
+
(nextConfirmation) => {
|
|
30
|
+
confirmation.value = nextConfirmation;
|
|
31
|
+
return getConfirmedTransactionStatus(nextConfirmation);
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function reset() {
|
|
36
|
+
resetExecution();
|
|
37
|
+
signature.value = null;
|
|
38
|
+
confirmation.value = null;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
signature,
|
|
42
|
+
confirmation,
|
|
43
|
+
status,
|
|
44
|
+
loading,
|
|
45
|
+
error,
|
|
46
|
+
confirm,
|
|
47
|
+
reset
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { getConfirmedTransactionStatus as g, useTransactionConfirmation as u };
|
|
@@ -2,10 +2,10 @@ import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
|
2
2
|
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
|
-
import { ref } from 'vue';
|
|
5
|
+
import { ref, computed } from 'vue';
|
|
6
6
|
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
7
7
|
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
8
|
-
import { g as getConfirmedTransactionStatus } from './vue.
|
|
8
|
+
import { g as getConfirmedTransactionStatus } from './vue.CaAgH2Xt.mjs';
|
|
9
9
|
|
|
10
10
|
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
11
11
|
function useSignAndSendTransaction() {
|
|
@@ -14,7 +14,7 @@ function useSignAndSendTransaction() {
|
|
|
14
14
|
const signature = ref(null);
|
|
15
15
|
const confirmation = ref(null);
|
|
16
16
|
const status = ref("idle");
|
|
17
|
-
const loading =
|
|
17
|
+
const loading = computed(() => status.value === "sending" || status.value === "confirming");
|
|
18
18
|
const error = ref(null);
|
|
19
19
|
let executionId = 0;
|
|
20
20
|
async function execute(transaction, options) {
|
|
@@ -22,7 +22,6 @@ function useSignAndSendTransaction() {
|
|
|
22
22
|
const { confirm, confirmation: confirmationOptions, ...sendOptions } = options ?? {};
|
|
23
23
|
const transactionOptions = Object.keys(sendOptions).length > 0 ? sendOptions : void 0;
|
|
24
24
|
status.value = "sending";
|
|
25
|
-
loading.value = true;
|
|
26
25
|
error.value = null;
|
|
27
26
|
confirmation.value = null;
|
|
28
27
|
const activeWallet = wallet.value;
|
|
@@ -30,7 +29,6 @@ function useSignAndSendTransaction() {
|
|
|
30
29
|
const normalizedError = createNoWalletSelectedError();
|
|
31
30
|
error.value = normalizedError;
|
|
32
31
|
status.value = "error";
|
|
33
|
-
loading.value = false;
|
|
34
32
|
throw normalizedError;
|
|
35
33
|
}
|
|
36
34
|
try {
|
|
@@ -63,10 +61,6 @@ function useSignAndSendTransaction() {
|
|
|
63
61
|
status.value = "error";
|
|
64
62
|
}
|
|
65
63
|
throw normalizedError;
|
|
66
|
-
} finally {
|
|
67
|
-
if (currentExecutionId === executionId) {
|
|
68
|
-
loading.value = false;
|
|
69
|
-
}
|
|
70
64
|
}
|
|
71
65
|
}
|
|
72
66
|
return {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { u as useClientAction } from './vue.CGv0ip3w.mjs';
|
|
2
|
+
|
|
3
|
+
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.";
|
|
4
|
+
const PLAN_STATUSES = {
|
|
5
|
+
error: "error",
|
|
6
|
+
idle: "idle",
|
|
7
|
+
success: "planned",
|
|
8
|
+
working: "planning"
|
|
9
|
+
};
|
|
10
|
+
function usePlanTransaction() {
|
|
11
|
+
const { data: transactionMessage, ...rest } = useClientAction({
|
|
12
|
+
capability: "planTransaction",
|
|
13
|
+
hookName: "usePlanTransaction",
|
|
14
|
+
providerHint: PLANNING_PROVIDER_HINT,
|
|
15
|
+
statuses: PLAN_STATUSES
|
|
16
|
+
});
|
|
17
|
+
return { transactionMessage, ...rest };
|
|
18
|
+
}
|
|
19
|
+
function usePlanTransactions() {
|
|
20
|
+
const { data: transactionPlan, ...rest } = useClientAction({
|
|
21
|
+
capability: "planTransactions",
|
|
22
|
+
hookName: "usePlanTransactions",
|
|
23
|
+
providerHint: PLANNING_PROVIDER_HINT,
|
|
24
|
+
statuses: PLAN_STATUSES
|
|
25
|
+
});
|
|
26
|
+
return { transactionPlan, ...rest };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { usePlanTransactions as a, usePlanTransaction as u };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
2
|
+
import { u as useAddressRead } from './vue.BwBqla_n.mjs';
|
|
3
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
4
|
+
import { d as decodeBase64 } from './vue.Bfu1dCKe.mjs';
|
|
5
|
+
|
|
6
|
+
function useAccountInfo(address, options = {}) {
|
|
7
|
+
const solana = tryUseSolana();
|
|
8
|
+
const client = solana?.client ?? useConnection();
|
|
9
|
+
const { data: accountInfo, ...rest } = useAddressRead(
|
|
10
|
+
[address],
|
|
11
|
+
async (key) => (await client.rpc.getAccountInfo(key, { encoding: "base64", commitment: options.commitment }).send()).value,
|
|
12
|
+
(account) => account ? normalizeAccountInfo(account) : null,
|
|
13
|
+
null
|
|
14
|
+
);
|
|
15
|
+
return { accountInfo, ...rest };
|
|
16
|
+
}
|
|
17
|
+
function normalizeAccountInfo(account) {
|
|
18
|
+
return {
|
|
19
|
+
executable: account.executable,
|
|
20
|
+
lamports: Number(account.lamports),
|
|
21
|
+
owner: account.owner,
|
|
22
|
+
space: Number(account.space),
|
|
23
|
+
data: decodeBase64(account.data[0])
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useAccountInfo as u };
|
|
@@ -5,7 +5,7 @@ function useSubscription(source, options = {}) {
|
|
|
5
5
|
const data = shallowRef(void 0);
|
|
6
6
|
const error = shallowRef(null);
|
|
7
7
|
const status = shallowRef("loading");
|
|
8
|
-
|
|
8
|
+
let disposeActive;
|
|
9
9
|
let connectionCount = 0;
|
|
10
10
|
let disposed = false;
|
|
11
11
|
let activeSource;
|
|
@@ -19,8 +19,8 @@ function useSubscription(source, options = {}) {
|
|
|
19
19
|
error.value = normalizeSolanaError(state.error, "RPC_FAILURE");
|
|
20
20
|
status.value = "error";
|
|
21
21
|
options.onError?.(state.error);
|
|
22
|
-
} else if (state.status === "loading") {
|
|
23
|
-
status.value =
|
|
22
|
+
} else if (state.status === "loading" && data.value === void 0) {
|
|
23
|
+
status.value = "loading";
|
|
24
24
|
} else if (state.status === "idle") {
|
|
25
25
|
data.value = void 0;
|
|
26
26
|
error.value = null;
|
|
@@ -33,11 +33,10 @@ function useSubscription(source, options = {}) {
|
|
|
33
33
|
const connection = connectionCount;
|
|
34
34
|
const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(connection);
|
|
35
35
|
applyState(store.getState());
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
);
|
|
36
|
+
disposeActive?.();
|
|
37
|
+
disposeActive = store.subscribe(() => {
|
|
38
|
+
applyState(store.getState());
|
|
39
|
+
});
|
|
41
40
|
if (callerSignal?.aborted) {
|
|
42
41
|
applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
|
|
43
42
|
return;
|
|
@@ -49,10 +48,8 @@ function useSubscription(source, options = {}) {
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
function disconnect() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
disposables.length = 0;
|
|
51
|
+
disposeActive?.();
|
|
52
|
+
disposeActive = void 0;
|
|
56
53
|
if (activeStore) {
|
|
57
54
|
activeStore.reset();
|
|
58
55
|
activeStore = void 0;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getTokenAccountsByOwner } from '@vue-solana/core/token-accounts';
|
|
2
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
3
|
+
import { u as useAddressRead } from './vue.BwBqla_n.mjs';
|
|
4
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
5
|
+
|
|
6
|
+
function useTokenAccounts(owner, options) {
|
|
7
|
+
const empty = [];
|
|
8
|
+
const solana = tryUseSolana();
|
|
9
|
+
const client = solana?.client ?? useConnection();
|
|
10
|
+
const { data: tokenAccounts, ...rest } = useAddressRead(
|
|
11
|
+
[owner],
|
|
12
|
+
(key) => getTokenAccountsByOwner(client, key, {
|
|
13
|
+
commitment: options?.commitment,
|
|
14
|
+
programId: options?.programId
|
|
15
|
+
}),
|
|
16
|
+
(accounts) => accounts,
|
|
17
|
+
empty
|
|
18
|
+
);
|
|
19
|
+
return { tokenAccounts, ...rest };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { useTokenAccounts as u };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { shallowRef, onScopeDispose, computed } from 'vue';
|
|
3
|
+
|
|
4
|
+
function useExecution(busy) {
|
|
5
|
+
const status = shallowRef("idle");
|
|
6
|
+
const error = shallowRef(null);
|
|
7
|
+
let id = 0;
|
|
8
|
+
async function execute(run, settled) {
|
|
9
|
+
const currentId = ++id;
|
|
10
|
+
status.value = busy;
|
|
11
|
+
error.value = null;
|
|
12
|
+
try {
|
|
13
|
+
const result = await run();
|
|
14
|
+
if (currentId === id) {
|
|
15
|
+
status.value = settled(result);
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
} catch (cause) {
|
|
19
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
20
|
+
if (currentId === id) {
|
|
21
|
+
error.value = normalizedError;
|
|
22
|
+
status.value = "error";
|
|
23
|
+
}
|
|
24
|
+
throw normalizedError;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function reset() {
|
|
28
|
+
id += 1;
|
|
29
|
+
status.value = "idle";
|
|
30
|
+
error.value = null;
|
|
31
|
+
}
|
|
32
|
+
onScopeDispose(() => {
|
|
33
|
+
id += 1;
|
|
34
|
+
});
|
|
35
|
+
return { status, error, loading: computed(() => status.value === busy), execute, reset };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { useExecution as u };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getTokenBalance } from '@vue-solana/core/token-accounts';
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
4
|
+
import { u as useAddressRead } from './vue.BwBqla_n.mjs';
|
|
5
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
6
|
+
|
|
7
|
+
function useTokenBalance(mint, owner, commitment) {
|
|
8
|
+
const empty = {
|
|
9
|
+
balance: null,
|
|
10
|
+
decimals: null
|
|
11
|
+
};
|
|
12
|
+
const solana = tryUseSolana();
|
|
13
|
+
const client = solana?.client ?? useConnection();
|
|
14
|
+
const read = useAddressRead(
|
|
15
|
+
[mint, owner],
|
|
16
|
+
(mintKey, ownerKey) => getTokenBalance(client, mintKey, ownerKey, commitment),
|
|
17
|
+
(result) => ({
|
|
18
|
+
balance: result?.amount ?? null,
|
|
19
|
+
decimals: result?.decimals ?? null
|
|
20
|
+
}),
|
|
21
|
+
empty
|
|
22
|
+
);
|
|
23
|
+
return {
|
|
24
|
+
balance: computed(() => read.data.value.balance),
|
|
25
|
+
decimals: computed(() => read.data.value.decimals),
|
|
26
|
+
loading: read.loading,
|
|
27
|
+
error: read.error,
|
|
28
|
+
refresh: read.refresh
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { useTokenBalance as u };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createNoWalletSelectedError, assertWalletCanSignTransactions } from '@vue-solana/core/wallet';
|
|
2
|
+
import { shallowRef } from 'vue';
|
|
3
|
+
import { u as useExecution } from './vue.DlihC5GG.mjs';
|
|
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, loading, error, execute } = useExecution("signing");
|
|
10
|
+
function sign(transactions) {
|
|
11
|
+
signedTransactions.value = null;
|
|
12
|
+
return execute(
|
|
13
|
+
async () => {
|
|
14
|
+
const activeWallet = wallet.value;
|
|
15
|
+
if (!activeWallet) {
|
|
16
|
+
throw createNoWalletSelectedError();
|
|
17
|
+
}
|
|
18
|
+
assertWalletCanSignTransactions(activeWallet);
|
|
19
|
+
const sign2 = activeWallet.signTransactions ? activeWallet.signTransactions.bind(activeWallet) : activeWallet.signAllTransactions.bind(activeWallet);
|
|
20
|
+
return sign2([...transactions]);
|
|
21
|
+
},
|
|
22
|
+
(result) => {
|
|
23
|
+
signedTransactions.value = result;
|
|
24
|
+
return "signed";
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
signedTransactions,
|
|
30
|
+
status,
|
|
31
|
+
loading,
|
|
32
|
+
error,
|
|
33
|
+
execute: sign
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { useSignTransactions as u };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createNoWalletSelectedError, assertWalletCanSignMessage } from '@vue-solana/core/wallet';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { u as useExecution } from './vue.DlihC5GG.mjs';
|
|
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, loading, error, execute } = useExecution("signing");
|
|
11
|
+
function sign(message) {
|
|
12
|
+
signedMessage.value = null;
|
|
13
|
+
signature.value = null;
|
|
14
|
+
return execute(
|
|
15
|
+
async () => {
|
|
16
|
+
const activeWallet = wallet.value;
|
|
17
|
+
if (!activeWallet) {
|
|
18
|
+
throw createNoWalletSelectedError();
|
|
19
|
+
}
|
|
20
|
+
assertWalletCanSignMessage(activeWallet);
|
|
21
|
+
return activeWallet.signMessage(message);
|
|
22
|
+
},
|
|
23
|
+
(result) => {
|
|
24
|
+
signedMessage.value = result.signedMessage;
|
|
25
|
+
signature.value = result.signature;
|
|
26
|
+
return "signed";
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
signedMessage,
|
|
32
|
+
signature,
|
|
33
|
+
status,
|
|
34
|
+
loading,
|
|
35
|
+
error,
|
|
36
|
+
execute: sign
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { useSignMessage as u };
|
package/dist/swr.mjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { watch, computed } from 'vue';
|
|
2
2
|
import { u as useRequest } from './shared/vue.B8VvC8d2.mjs';
|
|
3
|
-
import { u as useSubscription } from './shared/vue.
|
|
4
|
-
import { u as useTrackedData } from './shared/vue.
|
|
5
|
-
import '@vue-solana/core/action';
|
|
6
|
-
import '@vue-solana/core/kit';
|
|
7
|
-
import '@vue-solana/core/errors';
|
|
3
|
+
import { u as useSubscription } from './shared/vue.D5pqR5Fa.mjs';
|
|
4
|
+
import { u as useTrackedData } from './shared/vue.BNJTXSnQ.mjs';
|
|
8
5
|
|
|
9
6
|
const PREFIX_REQUEST = "request:";
|
|
10
7
|
const PREFIX_SUBSCRIPTION = "subscription:";
|
|
@@ -13,25 +10,16 @@ const swrCache = /* @__PURE__ */ new Map();
|
|
|
13
10
|
function clearSwrCache() {
|
|
14
11
|
swrCache.clear();
|
|
15
12
|
}
|
|
16
|
-
function readSwrCache(key) {
|
|
17
|
-
return swrCache.get(key);
|
|
18
|
-
}
|
|
19
|
-
function writeSwrCache(key, entry) {
|
|
20
|
-
swrCache.set(key, entry);
|
|
21
|
-
}
|
|
22
|
-
function deleteSwrCache(key) {
|
|
23
|
-
swrCache.delete(key);
|
|
24
|
-
}
|
|
25
13
|
function isPendingStatus(status) {
|
|
26
14
|
return status === "fetching" || status === "loading";
|
|
27
15
|
}
|
|
28
16
|
function writeSwrResult(key, data, error, status) {
|
|
29
17
|
if (status === "disabled") {
|
|
30
|
-
|
|
18
|
+
swrCache.delete(key);
|
|
31
19
|
return;
|
|
32
20
|
}
|
|
33
|
-
const previous =
|
|
34
|
-
|
|
21
|
+
const previous = swrCache.get(key);
|
|
22
|
+
swrCache.set(key, {
|
|
35
23
|
data: data !== void 0 ? data : previous?.data,
|
|
36
24
|
error,
|
|
37
25
|
status
|
|
@@ -43,16 +31,15 @@ function swrError(error, status, seed) {
|
|
|
43
31
|
}
|
|
44
32
|
return error ?? (isPendingStatus(status) ? seed?.error ?? null : null);
|
|
45
33
|
}
|
|
46
|
-
function
|
|
47
|
-
const cacheKey = `${
|
|
48
|
-
const seed =
|
|
49
|
-
const result = useRequest(source, options);
|
|
34
|
+
function useSwrKeyed(prefix, key, result) {
|
|
35
|
+
const cacheKey = `${prefix}${key}`;
|
|
36
|
+
const seed = swrCache.get(cacheKey);
|
|
50
37
|
if (result.status.value === "disabled") {
|
|
51
|
-
|
|
38
|
+
swrCache.delete(cacheKey);
|
|
52
39
|
}
|
|
53
40
|
watch(
|
|
54
41
|
[result.data, result.error, result.status],
|
|
55
|
-
([data2,
|
|
42
|
+
([data2, error, status]) => writeSwrResult(cacheKey, data2, error, status),
|
|
56
43
|
{ flush: "sync" }
|
|
57
44
|
);
|
|
58
45
|
const data = computed(() => {
|
|
@@ -61,71 +48,27 @@ function useRequestSwr(key, source, options = {}) {
|
|
|
61
48
|
}
|
|
62
49
|
return result.data.value !== void 0 ? result.data.value : seed?.data;
|
|
63
50
|
});
|
|
64
|
-
const error = computed(
|
|
65
|
-
() => swrError(result.error.value, result.status.value, seed)
|
|
66
|
-
);
|
|
67
51
|
return {
|
|
68
52
|
data,
|
|
69
|
-
error
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
error: computed(
|
|
54
|
+
() => swrError(result.error.value, result.status.value, seed)
|
|
55
|
+
)
|
|
72
56
|
};
|
|
73
57
|
}
|
|
58
|
+
function useRequestSwr(key, source, options = {}) {
|
|
59
|
+
const result = useRequest(source, options);
|
|
60
|
+
const swr = useSwrKeyed(PREFIX_REQUEST, key, result);
|
|
61
|
+
return { ...swr, refresh: result.refresh, status: result.status };
|
|
62
|
+
}
|
|
74
63
|
function useSubscriptionSwr(key, source, options = {}) {
|
|
75
|
-
const cacheKey = `${PREFIX_SUBSCRIPTION}${key}`;
|
|
76
|
-
const seed = readSwrCache(cacheKey);
|
|
77
64
|
const result = useSubscription(source, options);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
watch(
|
|
82
|
-
[result.data, result.error, result.status],
|
|
83
|
-
([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
|
|
84
|
-
{ flush: "sync" }
|
|
85
|
-
);
|
|
86
|
-
const data = computed(() => {
|
|
87
|
-
if (result.status.value === "disabled") {
|
|
88
|
-
return void 0;
|
|
89
|
-
}
|
|
90
|
-
return result.data.value !== void 0 ? result.data.value : seed?.data;
|
|
91
|
-
});
|
|
92
|
-
const error = computed(
|
|
93
|
-
() => swrError(result.error.value, result.status.value, seed)
|
|
94
|
-
);
|
|
95
|
-
return {
|
|
96
|
-
data,
|
|
97
|
-
error,
|
|
98
|
-
reconnect: result.reconnect,
|
|
99
|
-
status: result.status
|
|
100
|
-
};
|
|
65
|
+
const swr = useSwrKeyed(PREFIX_SUBSCRIPTION, key, result);
|
|
66
|
+
return { ...swr, reconnect: result.reconnect, status: result.status };
|
|
101
67
|
}
|
|
102
68
|
function useTrackedDataSwr(key, source, options = {}) {
|
|
103
|
-
const cacheKey = `${PREFIX_TRACKED}${key}`;
|
|
104
|
-
const seed = readSwrCache(cacheKey);
|
|
105
69
|
const result = useTrackedData(source, options);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
watch(
|
|
110
|
-
[result.data, result.error, result.status],
|
|
111
|
-
([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
|
|
112
|
-
{ flush: "sync" }
|
|
113
|
-
);
|
|
114
|
-
const data = computed(() => {
|
|
115
|
-
if (result.status.value === "disabled") {
|
|
116
|
-
return void 0;
|
|
117
|
-
}
|
|
118
|
-
return result.data.value ?? seed?.data;
|
|
119
|
-
});
|
|
120
|
-
const error = computed(
|
|
121
|
-
() => swrError(result.error.value, result.status.value, seed)
|
|
122
|
-
);
|
|
123
|
-
return {
|
|
124
|
-
data,
|
|
125
|
-
error,
|
|
126
|
-
refresh: result.refresh,
|
|
127
|
-
status: result.status
|
|
128
|
-
};
|
|
70
|
+
const swr = useSwrKeyed(PREFIX_TRACKED, key, result);
|
|
71
|
+
return { ...swr, refresh: result.refresh, status: result.status };
|
|
129
72
|
}
|
|
130
73
|
|
|
131
74
|
export { clearSwrCache, useRequestSwr, useSubscriptionSwr, useTrackedDataSwr };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
import * as _vue_solana_core_errors from '@vue-solana/core/errors';
|
|
3
4
|
import { Commitment } from '@vue-solana/core/kit';
|
|
4
|
-
import { SolanaError } from '@vue-solana/core/errors';
|
|
5
5
|
|
|
6
6
|
interface UseAccountInfoOptions {
|
|
7
7
|
commitment?: Commitment;
|
|
@@ -14,10 +14,10 @@ interface AccountInfo {
|
|
|
14
14
|
data: Uint8Array;
|
|
15
15
|
}
|
|
16
16
|
declare function useAccountInfo(address: MaybeRefOrGetter<string | null | undefined>, options?: UseAccountInfoOptions): {
|
|
17
|
-
|
|
18
|
-
loading: vue.ShallowRef<boolean
|
|
19
|
-
error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
|
|
17
|
+
error: vue.ShallowRef<_vue_solana_core_errors.SolanaError | null>;
|
|
18
|
+
loading: vue.ShallowRef<boolean>;
|
|
20
19
|
refresh: () => Promise<AccountInfo | null>;
|
|
20
|
+
accountInfo: vue.ShallowRef<AccountInfo | null>;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export { useAccountInfo };
|
package/dist/useAccountInfo.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
import * as _vue_solana_core_errors from '@vue-solana/core/errors';
|
|
3
4
|
import { Commitment } from '@vue-solana/core/kit';
|
|
4
|
-
import { SolanaError } from '@vue-solana/core/errors';
|
|
5
5
|
|
|
6
6
|
interface UseAccountInfoOptions {
|
|
7
7
|
commitment?: Commitment;
|
|
@@ -14,10 +14,10 @@ interface AccountInfo {
|
|
|
14
14
|
data: Uint8Array;
|
|
15
15
|
}
|
|
16
16
|
declare function useAccountInfo(address: MaybeRefOrGetter<string | null | undefined>, options?: UseAccountInfoOptions): {
|
|
17
|
-
|
|
18
|
-
loading: vue.ShallowRef<boolean
|
|
19
|
-
error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
|
|
17
|
+
error: vue.ShallowRef<_vue_solana_core_errors.SolanaError | null>;
|
|
18
|
+
loading: vue.ShallowRef<boolean>;
|
|
20
19
|
refresh: () => Promise<AccountInfo | null>;
|
|
20
|
+
accountInfo: vue.ShallowRef<AccountInfo | null>;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export { useAccountInfo };
|
package/dist/useAccountInfo.mjs
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export { u as useAccountInfo } from './shared/vue.
|
|
2
|
-
import '@vue-solana/core/errors';
|
|
3
|
-
import 'vue';
|
|
4
|
-
import '@vue-solana/core/address';
|
|
5
|
-
import './shared/vue.CpkwC8Th.mjs';
|
|
6
|
-
import './shared/vue.Mxc8w6Qk.mjs';
|
|
7
|
-
import './shared/vue.CQh3AUE8.mjs';
|
|
8
|
-
import './shared/vue.D_P5SqqD.mjs';
|
|
9
|
-
import './shared/vue.Bfu1dCKe.mjs';
|
|
1
|
+
export { u as useAccountInfo } from './shared/vue.CvenSbZZ.mjs';
|
package/dist/useAction.mjs
CHANGED
package/dist/useAirdrop.mjs
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
1
|
export { u as useAirdrop } from './shared/vue.DDQxNX5q.mjs';
|
|
2
|
-
import './shared/vue.DYk0Xfr3.mjs';
|
|
3
|
-
import '@vue-solana/core/action';
|
|
4
|
-
import 'vue';
|
|
5
|
-
import './shared/vue.B9uRpSDJ.mjs';
|
|
6
|
-
import './shared/vue.Mxc8w6Qk.mjs';
|
|
7
|
-
import './shared/vue.CQh3AUE8.mjs';
|
|
8
|
-
import './shared/vue.D_P5SqqD.mjs';
|
package/dist/useBalance.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
import * as _vue_solana_core_errors from '@vue-solana/core/errors';
|
|
3
4
|
import { Commitment } from '@vue-solana/core/kit';
|
|
4
|
-
import { SolanaError } from '@vue-solana/core/errors';
|
|
5
5
|
|
|
6
6
|
type BalanceInput = string | null | undefined;
|
|
7
7
|
declare function useBalance(address: MaybeRefOrGetter<BalanceInput>, commitment?: Commitment): {
|
|
8
|
-
|
|
9
|
-
loading: vue.ShallowRef<boolean
|
|
10
|
-
error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
|
|
8
|
+
error: vue.ShallowRef<_vue_solana_core_errors.SolanaError | null>;
|
|
9
|
+
loading: vue.ShallowRef<boolean>;
|
|
11
10
|
refresh: () => Promise<number | null>;
|
|
11
|
+
balance: vue.ShallowRef<number | null>;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export { useBalance };
|
package/dist/useBalance.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
import * as _vue_solana_core_errors from '@vue-solana/core/errors';
|
|
3
4
|
import { Commitment } from '@vue-solana/core/kit';
|
|
4
|
-
import { SolanaError } from '@vue-solana/core/errors';
|
|
5
5
|
|
|
6
6
|
type BalanceInput = string | null | undefined;
|
|
7
7
|
declare function useBalance(address: MaybeRefOrGetter<BalanceInput>, commitment?: Commitment): {
|
|
8
|
-
|
|
9
|
-
loading: vue.ShallowRef<boolean
|
|
10
|
-
error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
|
|
8
|
+
error: vue.ShallowRef<_vue_solana_core_errors.SolanaError | null>;
|
|
9
|
+
loading: vue.ShallowRef<boolean>;
|
|
11
10
|
refresh: () => Promise<number | null>;
|
|
11
|
+
balance: vue.ShallowRef<number | null>;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export { useBalance };
|
package/dist/useBalance.mjs
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export { u as useBalance } from './shared/vue.
|
|
2
|
-
import '@vue-solana/core/address';
|
|
3
|
-
import '@vue-solana/core/errors';
|
|
4
|
-
import 'vue';
|
|
5
|
-
import './shared/vue.CpkwC8Th.mjs';
|
|
6
|
-
import './shared/vue.Mxc8w6Qk.mjs';
|
|
7
|
-
import './shared/vue.CQh3AUE8.mjs';
|
|
8
|
-
import './shared/vue.D_P5SqqD.mjs';
|
|
1
|
+
export { u as useBalance } from './shared/vue.BFSboXMB.mjs';
|