@vue-solana/vue 1.2.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -23
- package/dist/buffer-polyfill.d.cts +0 -1
- package/dist/buffer-polyfill.d.mts +0 -1
- package/dist/buffer-polyfill.d.ts +0 -1
- package/dist/index.cjs +62 -22
- package/dist/index.d.cts +29 -13
- package/dist/index.d.mts +29 -13
- package/dist/index.d.ts +29 -13
- package/dist/index.mjs +41 -21
- package/dist/kit.d.cts +1 -1
- package/dist/kit.d.mts +1 -1
- package/dist/kit.d.ts +1 -1
- package/dist/shared/vue.5euWd6-V.mjs +59 -0
- package/dist/shared/vue.9TPxZPMf.cjs +59 -0
- package/dist/shared/vue.B4-LEdSE.cjs +102 -0
- package/dist/shared/{vue.C0uCLjJ6.cjs → vue.B6ainw2G.cjs} +1 -1
- package/dist/shared/vue.B8LptjZP.mjs +32 -0
- package/dist/shared/vue.B8pLQ8P4.cjs +105 -0
- package/dist/shared/vue.B8ub540p.mjs +109 -0
- package/dist/shared/{vue.D0ycWj82.mjs → vue.BD6Gm1nl.mjs} +9 -9
- package/dist/shared/{vue.BEesxsrA.cjs → vue.BGxz4dru.cjs} +7 -3
- package/dist/shared/{vue.DDxhSi72.mjs → vue.BINkrA8h.mjs} +9 -9
- package/dist/shared/{vue.COPnX5fq.cjs → vue.BIxphCAq.cjs} +1 -1
- package/dist/shared/{vue.CKTUFwSI.mjs → vue.BOpgWr43.mjs} +9 -10
- package/dist/shared/vue.BQRpjwKl.mjs +80 -0
- package/dist/shared/vue.BVaMoz9y.cjs +9 -0
- package/dist/shared/vue.BVj9lWBK.cjs +111 -0
- package/dist/shared/vue.BY0qpgYr.cjs +35 -0
- package/dist/shared/vue.Bfu1dCKe.mjs +10 -0
- package/dist/shared/vue.Bk5xjlUx.cjs +61 -0
- package/dist/shared/{vue.BtUKvuQw.mjs → vue.BsGwt78R.mjs} +2 -2
- package/dist/shared/{vue.BbX3ePDY.cjs → vue.Bwd1sGAM.cjs} +9 -10
- package/dist/shared/vue.ByxbBC3y.mjs +57 -0
- package/dist/shared/{vue.CPjEwHSg.mjs → vue.C13umiQi.mjs} +20 -8
- package/dist/shared/vue.C5FVoEZT.mjs +99 -0
- package/dist/shared/vue.CATOh_9G.mjs +42 -0
- package/dist/shared/{vue.Bhdhmz8d.cjs → vue.CIs8QhCw.cjs} +18 -74
- package/dist/shared/vue.CMohL_Cz.mjs +58 -0
- package/dist/shared/{vue.CYKT65tB.mjs → vue.CQh3AUE8.mjs} +2 -6
- package/dist/shared/{vue.DzKfcfpX.cjs → vue.CWZSMVnB.cjs} +6 -6
- package/dist/shared/{vue.B12Pt1PQ.mjs → vue.CXB4NEMA.mjs} +18 -74
- package/dist/shared/{vue.DFbay4mm.mjs → vue.C_4qJDiF.mjs} +1 -1
- package/dist/shared/vue.CoaIWGPT.cjs +38 -0
- package/dist/shared/vue.CogzzQXM.mjs +171 -0
- package/dist/shared/vue.CpkwC8Th.mjs +7 -0
- package/dist/shared/vue.CrkK_T15.cjs +86 -0
- package/dist/shared/vue.D-qi8PSL.cjs +82 -0
- package/dist/shared/{vue.B2AQR2bE.mjs → vue.D218Ow7t.mjs} +8 -4
- package/dist/shared/{vue.QHAHFnw8.mjs → vue.D3Y0PWbF.mjs} +3 -3
- package/dist/shared/vue.D5U1yLG3.mjs +83 -0
- package/dist/shared/{vue.j1vB3h1n.cjs → vue.DAg5wC1G.cjs} +9 -9
- package/dist/shared/vue.DDbVk0Zh.cjs +180 -0
- package/dist/shared/{vue.BE4KHksm.cjs → vue.DE3emjSF.cjs} +2 -7
- package/dist/shared/vue.DEHxNvUX.cjs +7 -0
- package/dist/shared/vue.DFaMJLAQ.cjs +60 -0
- package/dist/shared/vue.DImwKTwJ.mjs +103 -0
- package/dist/shared/{vue.G9t8pE0J.cjs → vue.DKyQ7J67.cjs} +1 -1
- package/dist/shared/vue.DNxOpDXz.cjs +12 -0
- package/dist/shared/vue.DXQVIRZA.mjs +174 -0
- package/dist/shared/vue.DYk0Xfr3.mjs +36 -0
- package/dist/shared/vue.D_P5SqqD.mjs +5 -0
- package/dist/shared/{vue.B14U1xmP.cjs → vue.Di7yjJ-R.cjs} +20 -8
- package/dist/shared/vue.DtCbCcPd.cjs +173 -0
- package/dist/shared/{vue.CM_uqVc0.mjs → vue.Dyi1OCI1.mjs} +6 -6
- package/dist/shared/{vue.BsD6AAmO.cjs → vue.E_npPFoV.cjs} +8 -8
- package/dist/shared/{vue.LNhX07HB.cjs → vue.FiMmnMHr.cjs} +2 -2
- package/dist/shared/{vue.CSzg70vB.mjs → vue.JUWqu6kD.mjs} +1 -1
- package/dist/shared/{vue.By1CUlOU.mjs → vue.Mxc8w6Qk.mjs} +1 -1
- package/dist/shared/{vue.ByUemLSf.cjs → vue.Sbbm9JSu.cjs} +3 -3
- package/dist/shared/vue.g8fnm_ca.cjs +45 -0
- package/dist/swr.cjs +136 -0
- package/dist/swr.d.cts +41 -0
- package/dist/swr.d.mts +41 -0
- package/dist/swr.d.ts +41 -0
- package/dist/swr.mjs +131 -0
- package/dist/useAccountInfo.cjs +7 -5
- package/dist/useAccountInfo.d.cts +12 -8
- package/dist/useAccountInfo.d.mts +12 -8
- package/dist/useAccountInfo.d.ts +12 -8
- package/dist/useAccountInfo.mjs +7 -5
- package/dist/useAction.cjs +9 -0
- package/dist/useAction.d.cts +45 -0
- package/dist/useAction.d.mts +45 -0
- package/dist/useAction.d.ts +45 -0
- package/dist/useAction.mjs +3 -0
- package/dist/useBalance.cjs +5 -4
- package/dist/useBalance.d.cts +4 -2
- package/dist/useBalance.d.mts +4 -2
- package/dist/useBalance.d.ts +4 -2
- package/dist/useBalance.mjs +5 -4
- package/dist/useClientCapability.cjs +12 -0
- package/dist/useClientCapability.d.cts +39 -0
- package/dist/useClientCapability.d.mts +39 -0
- package/dist/useClientCapability.d.ts +39 -0
- package/dist/useClientCapability.mjs +5 -0
- package/dist/useConnection.cjs +4 -3
- package/dist/useConnection.d.cts +9 -2
- package/dist/useConnection.d.mts +9 -2
- package/dist/useConnection.d.ts +9 -2
- package/dist/useConnection.mjs +4 -3
- package/dist/useIdentity.cjs +12 -0
- package/dist/useIdentity.d.cts +3 -0
- package/dist/useIdentity.d.mts +3 -0
- package/dist/useIdentity.d.ts +3 -0
- package/dist/useIdentity.mjs +6 -0
- package/dist/usePayer.cjs +13 -0
- package/dist/usePayer.d.cts +18 -0
- package/dist/usePayer.d.mts +18 -0
- package/dist/usePayer.d.ts +18 -0
- package/dist/usePayer.mjs +6 -0
- package/dist/usePlanTransaction.cjs +14 -0
- package/dist/usePlanTransaction.d.cts +37 -0
- package/dist/usePlanTransaction.d.mts +37 -0
- package/dist/usePlanTransaction.d.ts +37 -0
- package/dist/usePlanTransaction.mjs +7 -0
- package/dist/usePlanTransactions.cjs +13 -0
- package/dist/usePlanTransactions.d.cts +4 -0
- package/dist/usePlanTransactions.d.mts +4 -0
- package/dist/usePlanTransactions.d.ts +4 -0
- package/dist/usePlanTransactions.mjs +7 -0
- package/dist/useProgramAccounts.cjs +7 -5
- package/dist/useProgramAccounts.d.cts +24 -9
- package/dist/useProgramAccounts.d.mts +24 -9
- package/dist/useProgramAccounts.d.ts +24 -9
- package/dist/useProgramAccounts.mjs +7 -5
- package/dist/useRequest.cjs +11 -0
- package/dist/useRequest.d.cts +57 -0
- package/dist/useRequest.d.mts +57 -0
- package/dist/useRequest.d.ts +57 -0
- package/dist/useRequest.mjs +5 -0
- package/dist/useRpc.cjs +3 -2
- package/dist/useRpc.d.cts +5 -2
- package/dist/useRpc.d.mts +5 -2
- package/dist/useRpc.d.ts +5 -2
- package/dist/useRpc.mjs +3 -2
- package/dist/useSelectedWalletAccount.cjs +13 -0
- package/dist/useSelectedWalletAccount.d.cts +117 -0
- package/dist/useSelectedWalletAccount.d.mts +117 -0
- package/dist/useSelectedWalletAccount.d.ts +117 -0
- package/dist/useSelectedWalletAccount.mjs +3 -0
- package/dist/useSignAndSendTransaction.cjs +7 -6
- package/dist/useSignAndSendTransaction.d.cts +18 -24
- package/dist/useSignAndSendTransaction.d.mts +18 -24
- package/dist/useSignAndSendTransaction.d.ts +18 -24
- package/dist/useSignAndSendTransaction.mjs +7 -6
- package/dist/useSignAndSendTransactions.cjs +15 -0
- package/dist/useSignAndSendTransactions.d.cts +35 -0
- package/dist/useSignAndSendTransactions.d.mts +35 -0
- package/dist/useSignAndSendTransactions.d.ts +35 -0
- package/dist/useSignAndSendTransactions.mjs +8 -0
- package/dist/useSignIn.cjs +13 -0
- package/dist/useSignIn.d.cts +23 -0
- package/dist/useSignIn.d.mts +23 -0
- package/dist/useSignIn.d.ts +23 -0
- package/dist/useSignIn.mjs +7 -0
- package/dist/useSignMessage.cjs +4 -3
- package/dist/useSignMessage.mjs +4 -3
- package/dist/useSignTransactions.cjs +13 -0
- package/dist/useSignTransactions.d.cts +24 -0
- package/dist/useSignTransactions.d.mts +24 -0
- package/dist/useSignTransactions.d.ts +24 -0
- package/dist/useSignTransactions.mjs +7 -0
- package/dist/useSignatureStatus.cjs +5 -4
- package/dist/useSignatureStatus.d.cts +9 -5
- package/dist/useSignatureStatus.d.mts +9 -5
- package/dist/useSignatureStatus.d.ts +9 -5
- package/dist/useSignatureStatus.mjs +5 -4
- package/dist/useSolana.cjs +2 -1
- package/dist/useSolana.mjs +2 -1
- package/dist/useSolanaClient.cjs +3 -2
- package/dist/useSolanaClient.mjs +3 -2
- package/dist/useSubscription.cjs +9 -0
- package/dist/useSubscription.d.cts +58 -0
- package/dist/useSubscription.d.mts +58 -0
- package/dist/useSubscription.d.ts +58 -0
- package/dist/useSubscription.mjs +3 -0
- package/dist/useTokenAccounts.cjs +7 -6
- package/dist/useTokenAccounts.d.cts +6 -6
- package/dist/useTokenAccounts.d.mts +6 -6
- package/dist/useTokenAccounts.d.ts +6 -6
- package/dist/useTokenAccounts.mjs +7 -6
- package/dist/useTokenBalance.cjs +7 -6
- package/dist/useTokenBalance.d.cts +2 -2
- package/dist/useTokenBalance.d.mts +2 -2
- package/dist/useTokenBalance.d.ts +2 -2
- package/dist/useTokenBalance.mjs +7 -6
- package/dist/useTrackedData.cjs +10 -0
- package/dist/useTrackedData.d.cts +86 -0
- package/dist/useTrackedData.d.mts +86 -0
- package/dist/useTrackedData.d.ts +86 -0
- package/dist/useTrackedData.mjs +4 -0
- package/dist/useTransaction.cjs +2 -1
- package/dist/useTransaction.d.cts +13 -3
- package/dist/useTransaction.d.mts +13 -3
- package/dist/useTransaction.d.ts +13 -3
- package/dist/useTransaction.mjs +2 -1
- package/dist/useTransactionConfirmation.cjs +5 -4
- package/dist/useTransactionConfirmation.d.cts +18 -24
- package/dist/useTransactionConfirmation.d.mts +18 -24
- package/dist/useTransactionConfirmation.d.ts +18 -24
- package/dist/useTransactionConfirmation.mjs +5 -4
- package/dist/useWallet.cjs +3 -2
- package/dist/useWallet.d.cts +2 -2
- package/dist/useWallet.d.mts +2 -2
- package/dist/useWallet.d.ts +2 -2
- package/dist/useWallet.mjs +3 -2
- package/dist/useWallets.cjs +3 -2
- package/dist/useWallets.mjs +3 -2
- package/package.json +73 -9
- package/dist/shared/vue.C4d2JA8U.mjs +0 -44
- package/dist/shared/vue.CE5i8KZZ.cjs +0 -46
- package/dist/shared/vue.CfrVAzEf.mjs +0 -129
- package/dist/shared/vue.DCgByzxg.cjs +0 -9
- package/dist/shared/vue.DiNn3XHm.mjs +0 -7
- package/dist/shared/vue._CAClzAz.cjs +0 -131
- package/dist/web3.cjs +0 -13
- package/dist/web3.d.cts +0 -1
- package/dist/web3.d.mts +0 -1
- package/dist/web3.d.ts +0 -1
- package/dist/web3.mjs +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
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,12 +1,13 @@
|
|
|
1
|
-
import { parsePublicKey } from '@vue-solana/core/address';
|
|
2
1
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
2
|
import { shallowRef, onMounted, onUnmounted, watch, toValue } from 'vue';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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';
|
|
6
7
|
|
|
7
8
|
function useProgramAccounts(programId, options = {}) {
|
|
8
9
|
const solana = tryUseSolana();
|
|
9
|
-
const
|
|
10
|
+
const client = solana?.client ?? useConnection();
|
|
10
11
|
const accounts = shallowRef([]);
|
|
11
12
|
const loading = shallowRef(false);
|
|
12
13
|
const error = shallowRef(null);
|
|
@@ -23,16 +24,27 @@ function useProgramAccounts(programId, options = {}) {
|
|
|
23
24
|
loading.value = true;
|
|
24
25
|
error.value = null;
|
|
25
26
|
try {
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
27
|
+
const parsedAddress = parseAddress(value);
|
|
28
|
+
if (!parsedAddress) {
|
|
28
29
|
accounts.value = [];
|
|
29
30
|
return [];
|
|
30
31
|
}
|
|
31
|
-
const
|
|
32
|
+
const { value: response } = await client.rpc.getProgramAccounts(parsedAddress, {
|
|
33
|
+
encoding: "base64",
|
|
32
34
|
commitment: options.commitment,
|
|
33
35
|
dataSlice: options.dataSlice,
|
|
34
36
|
filters: options.filters
|
|
35
|
-
});
|
|
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
|
+
}));
|
|
36
48
|
if (requestId === refreshId) {
|
|
37
49
|
accounts.value = nextAccounts;
|
|
38
50
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { shallowRef, ref } from 'vue';
|
|
3
|
+
import { u as useClientCapability } from './vue.B8LptjZP.mjs';
|
|
4
|
+
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
5
|
+
|
|
6
|
+
function usePlanTransaction() {
|
|
7
|
+
useClientCapability(["planTransaction"], {
|
|
8
|
+
hookName: "usePlanTransaction",
|
|
9
|
+
providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
|
|
10
|
+
});
|
|
11
|
+
const { client } = useSolanaClient();
|
|
12
|
+
const transactionMessage = shallowRef(null);
|
|
13
|
+
const status = ref("idle");
|
|
14
|
+
const loading = ref(false);
|
|
15
|
+
const error = ref(null);
|
|
16
|
+
let executionId = 0;
|
|
17
|
+
async function execute(input, config) {
|
|
18
|
+
const currentExecutionId = ++executionId;
|
|
19
|
+
const planner = client;
|
|
20
|
+
status.value = "planning";
|
|
21
|
+
loading.value = true;
|
|
22
|
+
error.value = null;
|
|
23
|
+
transactionMessage.value = null;
|
|
24
|
+
try {
|
|
25
|
+
const message = await planner.planTransaction(input, config);
|
|
26
|
+
if (currentExecutionId === executionId) {
|
|
27
|
+
transactionMessage.value = message;
|
|
28
|
+
status.value = "planned";
|
|
29
|
+
}
|
|
30
|
+
return message;
|
|
31
|
+
} catch (cause) {
|
|
32
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
33
|
+
if (currentExecutionId === executionId) {
|
|
34
|
+
error.value = normalizedError;
|
|
35
|
+
status.value = "error";
|
|
36
|
+
}
|
|
37
|
+
throw normalizedError;
|
|
38
|
+
} finally {
|
|
39
|
+
if (currentExecutionId === executionId) {
|
|
40
|
+
loading.value = false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
transactionMessage,
|
|
46
|
+
status,
|
|
47
|
+
loading,
|
|
48
|
+
error,
|
|
49
|
+
execute
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function usePlanTransactions() {
|
|
53
|
+
useClientCapability(["planTransactions"], {
|
|
54
|
+
hookName: "usePlanTransactions",
|
|
55
|
+
providerHint: "Install a planner plugin, e.g. `createClient().use(rpcTransactionPlanner())` from `@solana/kit-plugin-rpc`."
|
|
56
|
+
});
|
|
57
|
+
const { client } = useSolanaClient();
|
|
58
|
+
const transactionPlan = shallowRef(null);
|
|
59
|
+
const status = ref("idle");
|
|
60
|
+
const loading = ref(false);
|
|
61
|
+
const error = ref(null);
|
|
62
|
+
let executionId = 0;
|
|
63
|
+
async function execute(input, config) {
|
|
64
|
+
const currentExecutionId = ++executionId;
|
|
65
|
+
const planner = client;
|
|
66
|
+
status.value = "planning";
|
|
67
|
+
loading.value = true;
|
|
68
|
+
error.value = null;
|
|
69
|
+
transactionPlan.value = null;
|
|
70
|
+
try {
|
|
71
|
+
const plan = await planner.planTransactions(input, config);
|
|
72
|
+
if (currentExecutionId === executionId) {
|
|
73
|
+
transactionPlan.value = plan;
|
|
74
|
+
status.value = "planned";
|
|
75
|
+
}
|
|
76
|
+
return plan;
|
|
77
|
+
} catch (cause) {
|
|
78
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
79
|
+
if (currentExecutionId === executionId) {
|
|
80
|
+
error.value = normalizedError;
|
|
81
|
+
status.value = "error";
|
|
82
|
+
}
|
|
83
|
+
throw normalizedError;
|
|
84
|
+
} finally {
|
|
85
|
+
if (currentExecutionId === executionId) {
|
|
86
|
+
loading.value = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
transactionPlan,
|
|
92
|
+
status,
|
|
93
|
+
loading,
|
|
94
|
+
error,
|
|
95
|
+
execute
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { usePlanTransactions as a, usePlanTransaction as u };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { shallowRef, onScopeDispose } from 'vue';
|
|
2
|
+
import { u as useClientCapability } from './vue.B8LptjZP.mjs';
|
|
3
|
+
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
4
|
+
|
|
5
|
+
function useIdentity() {
|
|
6
|
+
useClientCapability(["identity"], {
|
|
7
|
+
hookName: "useIdentity",
|
|
8
|
+
providerHint: "Install a signer plugin, e.g. `createClient().use(generatedIdentity())` from `@solana/kit-plugin-signer`."
|
|
9
|
+
});
|
|
10
|
+
const { client } = useSolanaClient();
|
|
11
|
+
const identity = shallowRef(
|
|
12
|
+
client.identity
|
|
13
|
+
);
|
|
14
|
+
const subscribable = client;
|
|
15
|
+
if (typeof subscribable.subscribeToIdentity === "function") {
|
|
16
|
+
const unsubscribe = subscribable.subscribeToIdentity(() => {
|
|
17
|
+
identity.value = client.identity;
|
|
18
|
+
});
|
|
19
|
+
onScopeDispose(unsubscribe);
|
|
20
|
+
}
|
|
21
|
+
return identity;
|
|
22
|
+
}
|
|
23
|
+
function usePayer() {
|
|
24
|
+
useClientCapability(["payer"], {
|
|
25
|
+
hookName: "usePayer",
|
|
26
|
+
providerHint: "Install a signer plugin, e.g. `createClient().use(generatedPayer())` from `@solana/kit-plugin-signer`."
|
|
27
|
+
});
|
|
28
|
+
const { client } = useSolanaClient();
|
|
29
|
+
const payer = shallowRef(
|
|
30
|
+
client.payer
|
|
31
|
+
);
|
|
32
|
+
const subscribable = client;
|
|
33
|
+
if (typeof subscribable.subscribeToPayer === "function") {
|
|
34
|
+
const unsubscribe = subscribable.subscribeToPayer(() => {
|
|
35
|
+
payer.value = client.payer;
|
|
36
|
+
});
|
|
37
|
+
onScopeDispose(unsubscribe);
|
|
38
|
+
}
|
|
39
|
+
return payer;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { usePayer as a, useIdentity as u };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const errors = require('@vue-solana/core/errors');
|
|
4
4
|
const bs58 = require('bs58');
|
|
5
5
|
const vue = require('vue');
|
|
6
|
-
const useConnection = require('./vue.
|
|
7
|
-
const useSolana = require('./vue.
|
|
6
|
+
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
7
|
+
const useSolana = require('./vue.DE3emjSF.cjs');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
10
10
|
|
|
@@ -12,16 +12,13 @@ const bs58__default = /*#__PURE__*/_interopDefaultCompat(bs58);
|
|
|
12
12
|
|
|
13
13
|
function useSignatureStatus(signature, options = {}) {
|
|
14
14
|
const solana = useSolana.tryUseSolana();
|
|
15
|
-
const
|
|
15
|
+
const client = solana?.client ?? useConnection.useConnection();
|
|
16
16
|
const status = vue.shallowRef(null);
|
|
17
17
|
const loading = vue.shallowRef(false);
|
|
18
18
|
const error = vue.shallowRef(null);
|
|
19
19
|
let refreshId = 0;
|
|
20
|
-
let subscriptionStartId = 0;
|
|
21
20
|
let pollId = null;
|
|
22
|
-
let subscriptionId = null;
|
|
23
21
|
let manuallyStoppedPolling = false;
|
|
24
|
-
let manuallyStoppedSubscription = false;
|
|
25
22
|
async function refresh() {
|
|
26
23
|
const requestId = ++refreshId;
|
|
27
24
|
const value = vue.toValue(signature);
|
|
@@ -35,10 +32,11 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
35
32
|
error.value = null;
|
|
36
33
|
try {
|
|
37
34
|
const validSignature = parseTransactionSignature(value);
|
|
38
|
-
const response = await
|
|
35
|
+
const response = await client.rpc.getSignatureStatuses([validSignature], {
|
|
39
36
|
searchTransactionHistory: options.searchTransactionHistory
|
|
40
|
-
});
|
|
41
|
-
const
|
|
37
|
+
}).send();
|
|
38
|
+
const nextRawStatus = response.value[0] ?? null;
|
|
39
|
+
const nextStatus = nextRawStatus ? normalizeSignatureStatus(nextRawStatus) : null;
|
|
42
40
|
if (requestId === refreshId) {
|
|
43
41
|
status.value = nextStatus;
|
|
44
42
|
}
|
|
@@ -87,80 +85,19 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
87
85
|
void refresh().catch(() => void 0);
|
|
88
86
|
}, options.pollIntervalMs);
|
|
89
87
|
}
|
|
90
|
-
async function stopSubscription() {
|
|
91
|
-
manuallyStoppedSubscription = true;
|
|
92
|
-
subscriptionStartId += 1;
|
|
93
|
-
await stopCurrentSubscription();
|
|
94
|
-
}
|
|
95
|
-
async function stopCurrentSubscription() {
|
|
96
|
-
if (subscriptionId === null) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const currentSubscriptionId = subscriptionId;
|
|
100
|
-
subscriptionId = null;
|
|
101
|
-
try {
|
|
102
|
-
await connection.removeSignatureListener(currentSubscriptionId);
|
|
103
|
-
} catch (cause) {
|
|
104
|
-
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async function startSubscription() {
|
|
108
|
-
const requestId = ++subscriptionStartId;
|
|
109
|
-
await stopCurrentSubscription();
|
|
110
|
-
if (requestId !== subscriptionStartId) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const value = vue.toValue(signature);
|
|
114
|
-
if (manuallyStoppedSubscription || !options.subscribe || !value || !solana) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
const validSignature = parseTransactionSignature(value);
|
|
119
|
-
const nextSubscriptionId = connection.onSignature(
|
|
120
|
-
validSignature,
|
|
121
|
-
(notification, context) => {
|
|
122
|
-
if (requestId !== subscriptionStartId) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
status.value = {
|
|
126
|
-
slot: context.slot,
|
|
127
|
-
confirmations: null,
|
|
128
|
-
err: notification.err,
|
|
129
|
-
confirmationStatus: options.commitment ?? "confirmed"
|
|
130
|
-
};
|
|
131
|
-
error.value = null;
|
|
132
|
-
},
|
|
133
|
-
options.commitment
|
|
134
|
-
);
|
|
135
|
-
if (requestId !== subscriptionStartId) {
|
|
136
|
-
await connection.removeSignatureListener(nextSubscriptionId);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
subscriptionId = nextSubscriptionId;
|
|
140
|
-
} catch (cause) {
|
|
141
|
-
if (requestId === subscriptionStartId) {
|
|
142
|
-
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function resetIntervals() {
|
|
147
|
-
startPolling();
|
|
148
|
-
void startSubscription();
|
|
149
|
-
}
|
|
150
88
|
vue.onMounted(() => {
|
|
151
89
|
void refresh().catch(() => void 0);
|
|
152
|
-
|
|
90
|
+
startPolling();
|
|
153
91
|
});
|
|
154
92
|
vue.onUnmounted(() => {
|
|
155
93
|
refreshId += 1;
|
|
156
94
|
stopPolling();
|
|
157
|
-
void stopSubscription();
|
|
158
95
|
});
|
|
159
96
|
vue.watch(
|
|
160
97
|
() => vue.toValue(signature),
|
|
161
98
|
() => {
|
|
162
99
|
void refresh().catch(() => void 0);
|
|
163
|
-
|
|
100
|
+
startPolling();
|
|
164
101
|
}
|
|
165
102
|
);
|
|
166
103
|
return {
|
|
@@ -168,8 +105,7 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
168
105
|
loading,
|
|
169
106
|
error,
|
|
170
107
|
refresh,
|
|
171
|
-
stopPolling
|
|
172
|
-
stopSubscription
|
|
108
|
+
stopPolling
|
|
173
109
|
};
|
|
174
110
|
}
|
|
175
111
|
function parseTransactionSignature(signature) {
|
|
@@ -184,5 +120,13 @@ function parseTransactionSignature(signature) {
|
|
|
184
120
|
}
|
|
185
121
|
return signature;
|
|
186
122
|
}
|
|
123
|
+
function normalizeSignatureStatus(status) {
|
|
124
|
+
return {
|
|
125
|
+
slot: Number(status.slot),
|
|
126
|
+
confirmations: status.confirmations === null ? null : Number(status.confirmations),
|
|
127
|
+
err: status.err,
|
|
128
|
+
confirmationStatus: status.confirmationStatus
|
|
129
|
+
};
|
|
130
|
+
}
|
|
187
131
|
|
|
188
132
|
exports.useSignatureStatus = useSignatureStatus;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { createNoWalletSelectedError, assertWalletCanSignTransactions } from '@vue-solana/core/wallet';
|
|
3
|
+
import { shallowRef, ref } from 'vue';
|
|
4
|
+
import { u as useWallet } from './vue.D218Ow7t.mjs';
|
|
5
|
+
|
|
6
|
+
function useSignTransactions() {
|
|
7
|
+
const { wallet } = useWallet();
|
|
8
|
+
const signedTransactions = shallowRef(null);
|
|
9
|
+
const status = ref("idle");
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
let executionId = 0;
|
|
13
|
+
async function execute(transactions) {
|
|
14
|
+
const currentExecutionId = ++executionId;
|
|
15
|
+
status.value = "signing";
|
|
16
|
+
loading.value = true;
|
|
17
|
+
error.value = null;
|
|
18
|
+
signedTransactions.value = null;
|
|
19
|
+
const activeWallet = wallet.value;
|
|
20
|
+
if (!activeWallet) {
|
|
21
|
+
const normalizedError = createNoWalletSelectedError();
|
|
22
|
+
error.value = normalizedError;
|
|
23
|
+
status.value = "error";
|
|
24
|
+
loading.value = false;
|
|
25
|
+
throw normalizedError;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
assertWalletCanSignTransactions(activeWallet);
|
|
29
|
+
const sign = activeWallet.signTransactions ? activeWallet.signTransactions.bind(activeWallet) : activeWallet.signAllTransactions.bind(activeWallet);
|
|
30
|
+
const result = await sign([...transactions]);
|
|
31
|
+
if (currentExecutionId === executionId) {
|
|
32
|
+
signedTransactions.value = result;
|
|
33
|
+
status.value = "signed";
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
} catch (cause) {
|
|
37
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
38
|
+
if (currentExecutionId === executionId) {
|
|
39
|
+
error.value = normalizedError;
|
|
40
|
+
status.value = "error";
|
|
41
|
+
}
|
|
42
|
+
throw normalizedError;
|
|
43
|
+
} finally {
|
|
44
|
+
if (currentExecutionId === executionId) {
|
|
45
|
+
loading.value = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
signedTransactions,
|
|
51
|
+
status,
|
|
52
|
+
loading,
|
|
53
|
+
error,
|
|
54
|
+
execute
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { useSignTransactions as u };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { inject, shallowRef, ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
const solanaInjectionKey = Symbol.for(
|
|
4
|
-
"vue-solana:context"
|
|
5
|
-
);
|
|
2
|
+
import { s as solanaInjectionKey } from './vue.D_P5SqqD.mjs';
|
|
6
3
|
|
|
7
4
|
let ssrContext;
|
|
8
5
|
function tryUseSolana() {
|
|
@@ -16,7 +13,6 @@ function getSsrContext() {
|
|
|
16
13
|
cluster: "devnet",
|
|
17
14
|
endpoint: "",
|
|
18
15
|
wsEndpoint: "",
|
|
19
|
-
connection: createUnavailableProxy(),
|
|
20
16
|
client: createUnavailableProxy(),
|
|
21
17
|
wallet: shallowRef(null),
|
|
22
18
|
status: ref("idle"),
|
|
@@ -46,4 +42,4 @@ function createUnavailableProxy() {
|
|
|
46
42
|
);
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
export {
|
|
45
|
+
export { tryUseSolana as t, useSolana as u };
|
|
@@ -5,13 +5,13 @@ const timeout = require('@vue-solana/core/timeout');
|
|
|
5
5
|
const transaction = require('@vue-solana/core/transaction');
|
|
6
6
|
const wallet = require('@vue-solana/core/wallet');
|
|
7
7
|
const vue = require('vue');
|
|
8
|
-
const useConnection = require('./vue.
|
|
9
|
-
const useWallet = require('./vue.
|
|
10
|
-
const useTransactionConfirmation = require('./vue.
|
|
8
|
+
const useConnection = require('./vue.BVaMoz9y.cjs');
|
|
9
|
+
const useWallet = require('./vue.BGxz4dru.cjs');
|
|
10
|
+
const useTransactionConfirmation = require('./vue.Sbbm9JSu.cjs');
|
|
11
11
|
|
|
12
12
|
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
13
13
|
function useSignAndSendTransaction() {
|
|
14
|
-
const
|
|
14
|
+
const client = useConnection.useConnection();
|
|
15
15
|
const { wallet: wallet$1 } = useWallet.useWallet();
|
|
16
16
|
const signature = vue.ref(null);
|
|
17
17
|
const confirmation = vue.ref(null);
|
|
@@ -37,7 +37,7 @@ function useSignAndSendTransaction() {
|
|
|
37
37
|
}
|
|
38
38
|
try {
|
|
39
39
|
const nextSignature = await timeout.withSolanaTimeout(
|
|
40
|
-
transaction.signAndSendTransaction(
|
|
40
|
+
transaction.signAndSendTransaction(client, activeWallet, transaction$1, transactionOptions),
|
|
41
41
|
SIGN_AND_SEND_TIMEOUT_MS,
|
|
42
42
|
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
43
43
|
);
|
|
@@ -49,7 +49,7 @@ function useSignAndSendTransaction() {
|
|
|
49
49
|
return nextSignature;
|
|
50
50
|
}
|
|
51
51
|
const nextConfirmation = await transaction.confirmTransactionSignature(
|
|
52
|
-
|
|
52
|
+
client,
|
|
53
53
|
nextSignature,
|
|
54
54
|
confirmationOptions
|
|
55
55
|
);
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { normalizeSolanaError, createSolanaError } from '@vue-solana/core/errors';
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
3
|
import { shallowRef, onMounted, onUnmounted, watch, toValue } from 'vue';
|
|
4
|
-
import { u as useConnection } from './vue.
|
|
5
|
-
import { t as tryUseSolana } from './vue.
|
|
4
|
+
import { u as useConnection } from './vue.CpkwC8Th.mjs';
|
|
5
|
+
import { t as tryUseSolana } from './vue.CQh3AUE8.mjs';
|
|
6
6
|
|
|
7
7
|
function useSignatureStatus(signature, options = {}) {
|
|
8
8
|
const solana = tryUseSolana();
|
|
9
|
-
const
|
|
9
|
+
const client = solana?.client ?? useConnection();
|
|
10
10
|
const status = shallowRef(null);
|
|
11
11
|
const loading = shallowRef(false);
|
|
12
12
|
const error = shallowRef(null);
|
|
13
13
|
let refreshId = 0;
|
|
14
|
-
let subscriptionStartId = 0;
|
|
15
14
|
let pollId = null;
|
|
16
|
-
let subscriptionId = null;
|
|
17
15
|
let manuallyStoppedPolling = false;
|
|
18
|
-
let manuallyStoppedSubscription = false;
|
|
19
16
|
async function refresh() {
|
|
20
17
|
const requestId = ++refreshId;
|
|
21
18
|
const value = toValue(signature);
|
|
@@ -29,10 +26,11 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
29
26
|
error.value = null;
|
|
30
27
|
try {
|
|
31
28
|
const validSignature = parseTransactionSignature(value);
|
|
32
|
-
const response = await
|
|
29
|
+
const response = await client.rpc.getSignatureStatuses([validSignature], {
|
|
33
30
|
searchTransactionHistory: options.searchTransactionHistory
|
|
34
|
-
});
|
|
35
|
-
const
|
|
31
|
+
}).send();
|
|
32
|
+
const nextRawStatus = response.value[0] ?? null;
|
|
33
|
+
const nextStatus = nextRawStatus ? normalizeSignatureStatus(nextRawStatus) : null;
|
|
36
34
|
if (requestId === refreshId) {
|
|
37
35
|
status.value = nextStatus;
|
|
38
36
|
}
|
|
@@ -81,80 +79,19 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
81
79
|
void refresh().catch(() => void 0);
|
|
82
80
|
}, options.pollIntervalMs);
|
|
83
81
|
}
|
|
84
|
-
async function stopSubscription() {
|
|
85
|
-
manuallyStoppedSubscription = true;
|
|
86
|
-
subscriptionStartId += 1;
|
|
87
|
-
await stopCurrentSubscription();
|
|
88
|
-
}
|
|
89
|
-
async function stopCurrentSubscription() {
|
|
90
|
-
if (subscriptionId === null) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const currentSubscriptionId = subscriptionId;
|
|
94
|
-
subscriptionId = null;
|
|
95
|
-
try {
|
|
96
|
-
await connection.removeSignatureListener(currentSubscriptionId);
|
|
97
|
-
} catch (cause) {
|
|
98
|
-
error.value = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async function startSubscription() {
|
|
102
|
-
const requestId = ++subscriptionStartId;
|
|
103
|
-
await stopCurrentSubscription();
|
|
104
|
-
if (requestId !== subscriptionStartId) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const value = toValue(signature);
|
|
108
|
-
if (manuallyStoppedSubscription || !options.subscribe || !value || !solana) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
const validSignature = parseTransactionSignature(value);
|
|
113
|
-
const nextSubscriptionId = connection.onSignature(
|
|
114
|
-
validSignature,
|
|
115
|
-
(notification, context) => {
|
|
116
|
-
if (requestId !== subscriptionStartId) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
status.value = {
|
|
120
|
-
slot: context.slot,
|
|
121
|
-
confirmations: null,
|
|
122
|
-
err: notification.err,
|
|
123
|
-
confirmationStatus: options.commitment ?? "confirmed"
|
|
124
|
-
};
|
|
125
|
-
error.value = null;
|
|
126
|
-
},
|
|
127
|
-
options.commitment
|
|
128
|
-
);
|
|
129
|
-
if (requestId !== subscriptionStartId) {
|
|
130
|
-
await connection.removeSignatureListener(nextSubscriptionId);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
subscriptionId = nextSubscriptionId;
|
|
134
|
-
} catch (cause) {
|
|
135
|
-
if (requestId === subscriptionStartId) {
|
|
136
|
-
error.value = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function resetIntervals() {
|
|
141
|
-
startPolling();
|
|
142
|
-
void startSubscription();
|
|
143
|
-
}
|
|
144
82
|
onMounted(() => {
|
|
145
83
|
void refresh().catch(() => void 0);
|
|
146
|
-
|
|
84
|
+
startPolling();
|
|
147
85
|
});
|
|
148
86
|
onUnmounted(() => {
|
|
149
87
|
refreshId += 1;
|
|
150
88
|
stopPolling();
|
|
151
|
-
void stopSubscription();
|
|
152
89
|
});
|
|
153
90
|
watch(
|
|
154
91
|
() => toValue(signature),
|
|
155
92
|
() => {
|
|
156
93
|
void refresh().catch(() => void 0);
|
|
157
|
-
|
|
94
|
+
startPolling();
|
|
158
95
|
}
|
|
159
96
|
);
|
|
160
97
|
return {
|
|
@@ -162,8 +99,7 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
162
99
|
loading,
|
|
163
100
|
error,
|
|
164
101
|
refresh,
|
|
165
|
-
stopPolling
|
|
166
|
-
stopSubscription
|
|
102
|
+
stopPolling
|
|
167
103
|
};
|
|
168
104
|
}
|
|
169
105
|
function parseTransactionSignature(signature) {
|
|
@@ -178,5 +114,13 @@ function parseTransactionSignature(signature) {
|
|
|
178
114
|
}
|
|
179
115
|
return signature;
|
|
180
116
|
}
|
|
117
|
+
function normalizeSignatureStatus(status) {
|
|
118
|
+
return {
|
|
119
|
+
slot: Number(status.slot),
|
|
120
|
+
confirmations: status.confirmations === null ? null : Number(status.confirmations),
|
|
121
|
+
err: status.err,
|
|
122
|
+
confirmationStatus: status.confirmationStatus
|
|
123
|
+
};
|
|
124
|
+
}
|
|
181
125
|
|
|
182
126
|
export { useSignatureStatus as u };
|