@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,63 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const errors = require('@vue-solana/core/errors');
|
|
4
|
-
const wallet = require('@vue-solana/core/wallet');
|
|
5
|
-
const vue = require('vue');
|
|
6
|
-
const useWallet = require('./vue.BGxz4dru.cjs');
|
|
7
|
-
|
|
8
|
-
function useSignMessage() {
|
|
9
|
-
const { wallet: wallet$1 } = useWallet.useWallet();
|
|
10
|
-
const signedMessage = vue.ref(null);
|
|
11
|
-
const signature = vue.ref(null);
|
|
12
|
-
const status = vue.ref("idle");
|
|
13
|
-
const loading = vue.ref(false);
|
|
14
|
-
const error = vue.ref(null);
|
|
15
|
-
let executionId = 0;
|
|
16
|
-
async function execute(message) {
|
|
17
|
-
const currentExecutionId = ++executionId;
|
|
18
|
-
status.value = "signing";
|
|
19
|
-
loading.value = true;
|
|
20
|
-
error.value = null;
|
|
21
|
-
signedMessage.value = null;
|
|
22
|
-
signature.value = null;
|
|
23
|
-
const activeWallet = wallet$1.value;
|
|
24
|
-
if (!activeWallet) {
|
|
25
|
-
const normalizedError = wallet.createNoWalletSelectedError();
|
|
26
|
-
error.value = normalizedError;
|
|
27
|
-
status.value = "error";
|
|
28
|
-
loading.value = false;
|
|
29
|
-
throw normalizedError;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
wallet.assertWalletCanSignMessage(activeWallet);
|
|
33
|
-
const result = await activeWallet.signMessage(message);
|
|
34
|
-
if (currentExecutionId === executionId) {
|
|
35
|
-
signedMessage.value = result.signedMessage;
|
|
36
|
-
signature.value = result.signature;
|
|
37
|
-
status.value = "signed";
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
} catch (cause) {
|
|
41
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
42
|
-
if (currentExecutionId === executionId) {
|
|
43
|
-
error.value = normalizedError;
|
|
44
|
-
status.value = "error";
|
|
45
|
-
}
|
|
46
|
-
throw normalizedError;
|
|
47
|
-
} finally {
|
|
48
|
-
if (currentExecutionId === executionId) {
|
|
49
|
-
loading.value = false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
signedMessage,
|
|
55
|
-
signature,
|
|
56
|
-
status,
|
|
57
|
-
loading,
|
|
58
|
-
error,
|
|
59
|
-
execute
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
exports.useSignMessage = useSignMessage;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { getTokenBalance } from '@vue-solana/core/token-accounts';
|
|
2
|
-
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
|
-
import { parseAddress } from '@vue-solana/core/address';
|
|
4
|
-
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
5
|
-
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
6
|
-
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
7
|
-
|
|
8
|
-
function useTokenBalance(mint, owner, commitment) {
|
|
9
|
-
const solana = tryUseSolana();
|
|
10
|
-
const client = solana?.client ?? useConnection();
|
|
11
|
-
const balance = shallowRef(null);
|
|
12
|
-
const decimals = shallowRef(null);
|
|
13
|
-
const loading = shallowRef(false);
|
|
14
|
-
const error = shallowRef(null);
|
|
15
|
-
let refreshId = 0;
|
|
16
|
-
async function refresh() {
|
|
17
|
-
const requestId = ++refreshId;
|
|
18
|
-
const mintValue = toValue(mint);
|
|
19
|
-
const ownerValue = toValue(owner);
|
|
20
|
-
if (!mintValue || !ownerValue || !solana) {
|
|
21
|
-
balance.value = null;
|
|
22
|
-
decimals.value = null;
|
|
23
|
-
loading.value = false;
|
|
24
|
-
error.value = null;
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
loading.value = true;
|
|
28
|
-
error.value = null;
|
|
29
|
-
try {
|
|
30
|
-
const mintKey = parseAddress(mintValue);
|
|
31
|
-
const ownerKey = parseAddress(ownerValue);
|
|
32
|
-
if (!mintKey || !ownerKey) {
|
|
33
|
-
balance.value = null;
|
|
34
|
-
decimals.value = null;
|
|
35
|
-
loading.value = false;
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
const nextBalance = await getTokenBalance(client, mintKey, ownerKey, commitment);
|
|
39
|
-
if (requestId === refreshId) {
|
|
40
|
-
balance.value = nextBalance?.amount ?? null;
|
|
41
|
-
decimals.value = nextBalance?.decimals ?? null;
|
|
42
|
-
}
|
|
43
|
-
return nextBalance;
|
|
44
|
-
} catch (cause) {
|
|
45
|
-
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
46
|
-
if (requestId === refreshId) {
|
|
47
|
-
error.value = normalizedError;
|
|
48
|
-
}
|
|
49
|
-
throw normalizedError;
|
|
50
|
-
} finally {
|
|
51
|
-
if (requestId === refreshId) {
|
|
52
|
-
loading.value = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
onMounted(() => {
|
|
57
|
-
void refresh().catch(() => void 0);
|
|
58
|
-
});
|
|
59
|
-
watch(
|
|
60
|
-
() => [toValue(mint), toValue(owner)],
|
|
61
|
-
() => {
|
|
62
|
-
void refresh().catch(() => void 0);
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
return {
|
|
66
|
-
balance,
|
|
67
|
-
decimals,
|
|
68
|
-
loading,
|
|
69
|
-
error,
|
|
70
|
-
refresh
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export { useTokenBalance as u };
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const errors = require('@vue-solana/core/errors');
|
|
4
|
-
const wallet = require('@vue-solana/core/wallet');
|
|
5
|
-
const vue = require('vue');
|
|
6
|
-
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
7
|
-
|
|
8
|
-
function useWallet() {
|
|
9
|
-
const solana = useSolana.useSolana();
|
|
10
|
-
const wallet$1 = solana.wallet;
|
|
11
|
-
const connecting = vue.ref(false);
|
|
12
|
-
const disconnecting = vue.ref(false);
|
|
13
|
-
async function connect() {
|
|
14
|
-
if (connecting.value || wallet$1.value?.connecting) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const activeWallet = wallet$1.value;
|
|
18
|
-
if (!activeWallet) {
|
|
19
|
-
throw wallet.createNoWalletSelectedError();
|
|
20
|
-
}
|
|
21
|
-
connecting.value = true;
|
|
22
|
-
try {
|
|
23
|
-
const connection = activeWallet.connect();
|
|
24
|
-
vue.triggerRef(wallet$1);
|
|
25
|
-
await connection;
|
|
26
|
-
wallet.assertWalletConnected(activeWallet);
|
|
27
|
-
vue.triggerRef(wallet$1);
|
|
28
|
-
console.info("[Vue Solana] Wallet connected", {
|
|
29
|
-
publicKey: activeWallet.publicKey ?? null
|
|
30
|
-
});
|
|
31
|
-
} catch (error) {
|
|
32
|
-
const normalizedError = errors.normalizeSolanaError(error, "RPC_FAILURE");
|
|
33
|
-
vue.triggerRef(wallet$1);
|
|
34
|
-
console.error("[Vue Solana] Wallet connection failed", normalizedError);
|
|
35
|
-
throw normalizedError;
|
|
36
|
-
} finally {
|
|
37
|
-
connecting.value = false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async function disconnect() {
|
|
41
|
-
const activeWallet = wallet$1.value;
|
|
42
|
-
if (!activeWallet) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const publicKey = activeWallet.publicKey ?? null;
|
|
46
|
-
disconnecting.value = true;
|
|
47
|
-
try {
|
|
48
|
-
await activeWallet.disconnect();
|
|
49
|
-
vue.triggerRef(wallet$1);
|
|
50
|
-
console.info("[Vue Solana] Wallet disconnected", { publicKey });
|
|
51
|
-
} catch (error) {
|
|
52
|
-
const normalizedError = errors.normalizeSolanaError(error, "RPC_FAILURE");
|
|
53
|
-
vue.triggerRef(wallet$1);
|
|
54
|
-
console.error("[Vue Solana] Wallet disconnection failed", normalizedError);
|
|
55
|
-
throw normalizedError;
|
|
56
|
-
} finally {
|
|
57
|
-
disconnecting.value = false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const isConnecting = vue.computed(() => Boolean(connecting.value || wallet$1.value?.connecting));
|
|
61
|
-
const isDisconnecting = vue.computed(
|
|
62
|
-
() => Boolean(disconnecting.value || wallet$1.value?.disconnecting)
|
|
63
|
-
);
|
|
64
|
-
const canConnect = vue.computed(() => Boolean(wallet$1.value?.connect));
|
|
65
|
-
const canDisconnect = vue.computed(() => Boolean(wallet$1.value?.disconnect));
|
|
66
|
-
const canSignMessage = vue.computed(() => Boolean(wallet$1.value?.signMessage));
|
|
67
|
-
const canSignTransaction = vue.computed(() => Boolean(wallet$1.value?.signTransaction));
|
|
68
|
-
const canSignAllTransactions = vue.computed(() => Boolean(wallet$1.value?.signAllTransactions));
|
|
69
|
-
const canSignAndSendTransaction = vue.computed(() => Boolean(wallet$1.value?.signAndSendTransaction));
|
|
70
|
-
const capabilities = vue.computed(() => ({
|
|
71
|
-
connect: canConnect.value,
|
|
72
|
-
disconnect: canDisconnect.value,
|
|
73
|
-
signMessage: canSignMessage.value,
|
|
74
|
-
signTransaction: canSignTransaction.value,
|
|
75
|
-
signAllTransactions: canSignAllTransactions.value,
|
|
76
|
-
signAndSendTransaction: canSignAndSendTransaction.value
|
|
77
|
-
}));
|
|
78
|
-
return {
|
|
79
|
-
wallet: wallet$1,
|
|
80
|
-
publicKey: vue.computed(() => wallet$1.value?.publicKey ?? null),
|
|
81
|
-
connected: vue.computed(() => Boolean(wallet$1.value?.connected && wallet$1.value.publicKey)),
|
|
82
|
-
connecting: isConnecting,
|
|
83
|
-
disconnecting: isDisconnecting,
|
|
84
|
-
loading: vue.computed(() => isConnecting.value || isDisconnecting.value),
|
|
85
|
-
capabilities,
|
|
86
|
-
canConnect,
|
|
87
|
-
canDisconnect,
|
|
88
|
-
canSignMessage,
|
|
89
|
-
canSignTransaction,
|
|
90
|
-
canSignAllTransactions,
|
|
91
|
-
canSignAndSendTransaction,
|
|
92
|
-
setWallet: solana.setWallet,
|
|
93
|
-
connect,
|
|
94
|
-
disconnect
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
exports.useWallet = useWallet;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { getTokenAccountsByOwner } from '@vue-solana/core/token-accounts';
|
|
2
|
-
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
|
-
import { parseAddress } from '@vue-solana/core/address';
|
|
4
|
-
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
5
|
-
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
6
|
-
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
7
|
-
|
|
8
|
-
function useTokenAccounts(owner, options) {
|
|
9
|
-
const solana = tryUseSolana();
|
|
10
|
-
const client = solana?.client ?? useConnection();
|
|
11
|
-
const tokenAccounts = shallowRef([]);
|
|
12
|
-
const loading = shallowRef(false);
|
|
13
|
-
const error = shallowRef(null);
|
|
14
|
-
let refreshId = 0;
|
|
15
|
-
async function refresh() {
|
|
16
|
-
const requestId = ++refreshId;
|
|
17
|
-
const value = toValue(owner);
|
|
18
|
-
if (!value || !solana) {
|
|
19
|
-
tokenAccounts.value = [];
|
|
20
|
-
loading.value = false;
|
|
21
|
-
error.value = null;
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
loading.value = true;
|
|
25
|
-
error.value = null;
|
|
26
|
-
try {
|
|
27
|
-
const parsedAddress = parseAddress(value);
|
|
28
|
-
if (!parsedAddress) {
|
|
29
|
-
tokenAccounts.value = [];
|
|
30
|
-
loading.value = false;
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
const nextAccounts = await getTokenAccountsByOwner(client, parsedAddress, {
|
|
34
|
-
commitment: options?.commitment,
|
|
35
|
-
programId: options?.programId
|
|
36
|
-
});
|
|
37
|
-
if (requestId === refreshId) {
|
|
38
|
-
tokenAccounts.value = nextAccounts;
|
|
39
|
-
}
|
|
40
|
-
return nextAccounts;
|
|
41
|
-
} catch (cause) {
|
|
42
|
-
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
43
|
-
if (requestId === refreshId) {
|
|
44
|
-
error.value = normalizedError;
|
|
45
|
-
}
|
|
46
|
-
throw normalizedError;
|
|
47
|
-
} finally {
|
|
48
|
-
if (requestId === refreshId) {
|
|
49
|
-
loading.value = false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
onMounted(() => {
|
|
54
|
-
void refresh().catch(() => void 0);
|
|
55
|
-
});
|
|
56
|
-
watch(
|
|
57
|
-
() => toValue(owner),
|
|
58
|
-
() => {
|
|
59
|
-
void refresh().catch(() => void 0);
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
return {
|
|
63
|
-
tokenAccounts,
|
|
64
|
-
loading,
|
|
65
|
-
error,
|
|
66
|
-
refresh
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export { useTokenAccounts as u };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
-
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
3
|
-
import { parseAddress } from '@vue-solana/core/address';
|
|
4
|
-
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
5
|
-
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
6
|
-
import { d as decodeBase64 } from './vue.Bfu1dCKe.mjs';
|
|
7
|
-
|
|
8
|
-
function useAccountInfo(address, options = {}) {
|
|
9
|
-
const solana = tryUseSolana();
|
|
10
|
-
const client = solana?.client ?? useConnection();
|
|
11
|
-
const accountInfo = shallowRef(null);
|
|
12
|
-
const loading = shallowRef(false);
|
|
13
|
-
const error = shallowRef(null);
|
|
14
|
-
let refreshId = 0;
|
|
15
|
-
async function refresh() {
|
|
16
|
-
const requestId = ++refreshId;
|
|
17
|
-
const value = toValue(address);
|
|
18
|
-
if (!value || !solana) {
|
|
19
|
-
accountInfo.value = null;
|
|
20
|
-
loading.value = false;
|
|
21
|
-
error.value = null;
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
loading.value = true;
|
|
25
|
-
error.value = null;
|
|
26
|
-
try {
|
|
27
|
-
const parsedAddress = parseAddress(value);
|
|
28
|
-
if (!parsedAddress) {
|
|
29
|
-
accountInfo.value = null;
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const { value: account } = await client.rpc.getAccountInfo(parsedAddress, {
|
|
33
|
-
encoding: "base64",
|
|
34
|
-
commitment: options.commitment
|
|
35
|
-
}).send();
|
|
36
|
-
const nextAccountInfo = account ? normalizeAccountInfo(account) : null;
|
|
37
|
-
if (requestId === refreshId) {
|
|
38
|
-
accountInfo.value = nextAccountInfo;
|
|
39
|
-
}
|
|
40
|
-
return nextAccountInfo;
|
|
41
|
-
} catch (cause) {
|
|
42
|
-
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
43
|
-
if (requestId === refreshId) {
|
|
44
|
-
accountInfo.value = null;
|
|
45
|
-
error.value = normalizedError;
|
|
46
|
-
}
|
|
47
|
-
throw normalizedError;
|
|
48
|
-
} finally {
|
|
49
|
-
if (requestId === refreshId) {
|
|
50
|
-
loading.value = false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
onMounted(() => {
|
|
55
|
-
void refresh().catch(() => void 0);
|
|
56
|
-
});
|
|
57
|
-
watch(
|
|
58
|
-
() => toValue(address),
|
|
59
|
-
() => {
|
|
60
|
-
void refresh().catch(() => void 0);
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
return {
|
|
64
|
-
accountInfo,
|
|
65
|
-
loading,
|
|
66
|
-
error,
|
|
67
|
-
refresh
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function normalizeAccountInfo(account) {
|
|
71
|
-
return {
|
|
72
|
-
executable: account.executable,
|
|
73
|
-
lamports: Number(account.lamports),
|
|
74
|
-
owner: account.owner,
|
|
75
|
-
space: Number(account.space),
|
|
76
|
-
data: decodeBase64(account.data[0])
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export { useAccountInfo as u };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const action = require('@vue-solana/core/action');
|
|
4
|
-
const errors = require('@vue-solana/core/errors');
|
|
5
|
-
const timeout = require('@vue-solana/core/timeout');
|
|
6
|
-
const vue = require('vue');
|
|
7
|
-
|
|
8
|
-
const DEFAULT_TIMEOUT_MESSAGE = "Transaction did not return a result before timing out.";
|
|
9
|
-
function useTransaction(handler, options = {}) {
|
|
10
|
-
const signature = vue.shallowRef(null);
|
|
11
|
-
const loading = vue.ref(false);
|
|
12
|
-
const error = vue.ref(null);
|
|
13
|
-
const store = action.createSolanaActionStore(async (_signal, ...args) => {
|
|
14
|
-
const attempt = timeout.withSolanaTimeout(
|
|
15
|
-
handler(...args),
|
|
16
|
-
options.timeoutMs,
|
|
17
|
-
options.timeoutMessage ?? DEFAULT_TIMEOUT_MESSAGE
|
|
18
|
-
);
|
|
19
|
-
attempt.catch(() => void 0);
|
|
20
|
-
return attempt;
|
|
21
|
-
});
|
|
22
|
-
const unsubscribe = store.subscribe(() => {
|
|
23
|
-
const state = store.getState();
|
|
24
|
-
if (state.status === "running") {
|
|
25
|
-
loading.value = true;
|
|
26
|
-
} else if (state.status === "success") {
|
|
27
|
-
signature.value = state.data;
|
|
28
|
-
loading.value = false;
|
|
29
|
-
error.value = null;
|
|
30
|
-
} else if (state.status === "error") {
|
|
31
|
-
error.value = errors.normalizeSolanaError(state.error, "RPC_FAILURE");
|
|
32
|
-
loading.value = false;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
if (vue.getCurrentScope()) {
|
|
36
|
-
vue.onScopeDispose(() => {
|
|
37
|
-
unsubscribe();
|
|
38
|
-
store.reset();
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async function execute(...args) {
|
|
42
|
-
loading.value = true;
|
|
43
|
-
error.value = null;
|
|
44
|
-
try {
|
|
45
|
-
return await store.dispatchAsync(...args);
|
|
46
|
-
} catch (cause) {
|
|
47
|
-
if (action.isSolanaActionAborted(cause)) {
|
|
48
|
-
throw cause;
|
|
49
|
-
}
|
|
50
|
-
throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
signature,
|
|
55
|
-
loading,
|
|
56
|
-
error,
|
|
57
|
-
execute
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
exports.useTransaction = useTransaction;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const tokenAccounts = require('@vue-solana/core/token-accounts');
|
|
4
|
-
const errors = require('@vue-solana/core/errors');
|
|
5
|
-
const address = require('@vue-solana/core/address');
|
|
6
|
-
const vue = require('vue');
|
|
7
|
-
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
8
|
-
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
9
|
-
|
|
10
|
-
function useTokenAccounts(owner, options) {
|
|
11
|
-
const solana = useSolana.tryUseSolana();
|
|
12
|
-
const client = solana?.client ?? useConnection.useConnection();
|
|
13
|
-
const tokenAccounts$1 = 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(owner);
|
|
20
|
-
if (!value || !solana) {
|
|
21
|
-
tokenAccounts$1.value = [];
|
|
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
|
-
tokenAccounts$1.value = [];
|
|
32
|
-
loading.value = false;
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
const nextAccounts = await tokenAccounts.getTokenAccountsByOwner(client, parsedAddress, {
|
|
36
|
-
commitment: options?.commitment,
|
|
37
|
-
programId: options?.programId
|
|
38
|
-
});
|
|
39
|
-
if (requestId === refreshId) {
|
|
40
|
-
tokenAccounts$1.value = nextAccounts;
|
|
41
|
-
}
|
|
42
|
-
return nextAccounts;
|
|
43
|
-
} catch (cause) {
|
|
44
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
45
|
-
if (requestId === refreshId) {
|
|
46
|
-
error.value = normalizedError;
|
|
47
|
-
}
|
|
48
|
-
throw normalizedError;
|
|
49
|
-
} finally {
|
|
50
|
-
if (requestId === refreshId) {
|
|
51
|
-
loading.value = false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
vue.onMounted(() => {
|
|
56
|
-
void refresh().catch(() => void 0);
|
|
57
|
-
});
|
|
58
|
-
vue.watch(
|
|
59
|
-
() => vue.toValue(owner),
|
|
60
|
-
() => {
|
|
61
|
-
void refresh().catch(() => void 0);
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
return {
|
|
65
|
-
tokenAccounts: tokenAccounts$1,
|
|
66
|
-
loading,
|
|
67
|
-
error,
|
|
68
|
-
refresh
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
exports.useTokenAccounts = useTokenAccounts;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
-
import { createNoWalletSelectedError, assertWalletCanSignIn } from '@vue-solana/core/wallet';
|
|
3
|
-
import { shallowRef, ref } from 'vue';
|
|
4
|
-
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
5
|
-
|
|
6
|
-
function useSignIn() {
|
|
7
|
-
const { wallet } = useWallet();
|
|
8
|
-
const signInResult = shallowRef(null);
|
|
9
|
-
const status = ref("idle");
|
|
10
|
-
const loading = ref(false);
|
|
11
|
-
const error = ref(null);
|
|
12
|
-
let executionId = 0;
|
|
13
|
-
async function signIn(input) {
|
|
14
|
-
const currentExecutionId = ++executionId;
|
|
15
|
-
status.value = "signing-in";
|
|
16
|
-
loading.value = true;
|
|
17
|
-
error.value = null;
|
|
18
|
-
signInResult.value = null;
|
|
19
|
-
const activeWallet = wallet.value;
|
|
20
|
-
if (!activeWallet) {
|
|
21
|
-
const normalizedError = createNoWalletSelectedError();
|
|
22
|
-
error.value = normalizedError;
|
|
23
|
-
status.value = "error";
|
|
24
|
-
loading.value = false;
|
|
25
|
-
throw normalizedError;
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
assertWalletCanSignIn(activeWallet);
|
|
29
|
-
const result = await activeWallet.signIn(input);
|
|
30
|
-
if (currentExecutionId === executionId) {
|
|
31
|
-
signInResult.value = result;
|
|
32
|
-
status.value = "signed-in";
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
} catch (cause) {
|
|
36
|
-
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
37
|
-
if (currentExecutionId === executionId) {
|
|
38
|
-
error.value = normalizedError;
|
|
39
|
-
status.value = "error";
|
|
40
|
-
}
|
|
41
|
-
throw normalizedError;
|
|
42
|
-
} finally {
|
|
43
|
-
if (currentExecutionId === executionId) {
|
|
44
|
-
loading.value = false;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
signInResult,
|
|
50
|
-
status,
|
|
51
|
-
loading,
|
|
52
|
-
error,
|
|
53
|
-
signIn
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export { useSignIn as u };
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
-
import { shallowRef, onMounted, onUnmounted, watch, toValue } from 'vue';
|
|
3
|
-
import { parseAddress } from '@vue-solana/core/address';
|
|
4
|
-
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
5
|
-
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
6
|
-
import { d as decodeBase64 } from './vue.Bfu1dCKe.mjs';
|
|
7
|
-
|
|
8
|
-
function useProgramAccounts(programId, options = {}) {
|
|
9
|
-
const solana = tryUseSolana();
|
|
10
|
-
const client = solana?.client ?? useConnection();
|
|
11
|
-
const accounts = shallowRef([]);
|
|
12
|
-
const loading = shallowRef(false);
|
|
13
|
-
const error = shallowRef(null);
|
|
14
|
-
let refreshId = 0;
|
|
15
|
-
async function refresh() {
|
|
16
|
-
const requestId = ++refreshId;
|
|
17
|
-
const value = toValue(programId);
|
|
18
|
-
if (!value || !solana) {
|
|
19
|
-
accounts.value = [];
|
|
20
|
-
loading.value = false;
|
|
21
|
-
error.value = null;
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
loading.value = true;
|
|
25
|
-
error.value = null;
|
|
26
|
-
try {
|
|
27
|
-
const parsedAddress = parseAddress(value);
|
|
28
|
-
if (!parsedAddress) {
|
|
29
|
-
accounts.value = [];
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
const { value: response } = await client.rpc.getProgramAccounts(parsedAddress, {
|
|
33
|
-
encoding: "base64",
|
|
34
|
-
commitment: options.commitment,
|
|
35
|
-
dataSlice: options.dataSlice,
|
|
36
|
-
filters: options.filters
|
|
37
|
-
}).send();
|
|
38
|
-
const nextAccounts = response.map(({ pubkey, account }) => ({
|
|
39
|
-
pubkey,
|
|
40
|
-
account: {
|
|
41
|
-
executable: account.executable,
|
|
42
|
-
lamports: Number(account.lamports),
|
|
43
|
-
owner: account.owner,
|
|
44
|
-
space: Number(account.space),
|
|
45
|
-
data: decodeBase64(account.data[0])
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
if (requestId === refreshId) {
|
|
49
|
-
accounts.value = nextAccounts;
|
|
50
|
-
}
|
|
51
|
-
return nextAccounts;
|
|
52
|
-
} catch (cause) {
|
|
53
|
-
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
54
|
-
if (requestId === refreshId) {
|
|
55
|
-
accounts.value = [];
|
|
56
|
-
error.value = normalizedError;
|
|
57
|
-
}
|
|
58
|
-
throw normalizedError;
|
|
59
|
-
} finally {
|
|
60
|
-
if (requestId === refreshId) {
|
|
61
|
-
loading.value = false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
onMounted(() => {
|
|
66
|
-
void refresh().catch(() => void 0);
|
|
67
|
-
});
|
|
68
|
-
onUnmounted(() => {
|
|
69
|
-
refreshId += 1;
|
|
70
|
-
});
|
|
71
|
-
watch(
|
|
72
|
-
() => toValue(programId),
|
|
73
|
-
() => {
|
|
74
|
-
void refresh().catch(() => void 0);
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
return {
|
|
78
|
-
accounts,
|
|
79
|
-
loading,
|
|
80
|
-
error,
|
|
81
|
-
refresh
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export { useProgramAccounts as u };
|