@vue-solana/vue 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/dist/buffer-polyfill.d.cts +1 -1
- package/dist/buffer-polyfill.d.mts +1 -1
- package/dist/buffer-polyfill.d.ts +1 -1
- package/dist/index.cjs +24 -16
- package/dist/index.d.cts +6 -7
- package/dist/index.d.mts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.mjs +21 -17
- package/dist/kit.cjs +9 -0
- package/dist/kit.d.cts +1 -0
- package/dist/kit.d.mts +1 -0
- package/dist/kit.d.ts +1 -0
- package/dist/kit.mjs +1 -0
- package/dist/shared/{vue.ChnRkpDR.mjs → vue.3VLZmw05.mjs} +2 -2
- package/dist/shared/{vue.DaoqgzJC.mjs → vue.B2sFJ1xI.mjs} +3 -3
- package/dist/shared/{vue.o-mWY2Yg.cjs → vue.BAlo-tIh.cjs} +3 -3
- package/dist/shared/vue.BMencBpI.cjs +82 -0
- package/dist/shared/{vue.Diugnf4a.cjs → vue.B_LRH8SM.cjs} +9 -10
- package/dist/shared/vue.BaFrF2PF.mjs +8 -0
- package/dist/shared/{vue.eNXmiI3a.cjs → vue.BaR1VPhl.cjs} +2 -2
- package/dist/shared/{vue.BTN0h5Il.mjs → vue.BbMPRDeO.mjs} +20 -8
- package/dist/shared/vue.Bfu1dCKe.mjs +10 -0
- package/dist/shared/{vue.CZohWxBN.cjs → vue.C32ozdA1.cjs} +3 -3
- package/dist/shared/{vue.BleajB0B.cjs → vue.C7yR7Cs0.cjs} +20 -8
- package/dist/shared/{vue.D6U1RFZ0.cjs → vue.CEn2purG.cjs} +8 -8
- package/dist/shared/{vue.Dp894nYb.cjs → vue.CP1DPDX9.cjs} +1 -1
- package/dist/shared/{vue.CMJANJ4a.cjs → vue.CSJSK0Nq.cjs} +6 -6
- package/dist/shared/{vue.BM8Qjk74.cjs → vue.CXHYdyKZ.cjs} +9 -9
- package/dist/shared/{vue.vn--SX8d.mjs → vue.CZO8TwJP.mjs} +1 -1
- package/dist/shared/vue.CZwftA0L.cjs +9 -0
- package/dist/shared/vue.ChujsB0B.mjs +7 -0
- package/dist/shared/{vue.DCDTsSjf.mjs → vue.CnUlZSe8.mjs} +2 -2
- package/dist/shared/{vue.Cvg6TEXE.mjs → vue.D7xFeC2m.mjs} +1 -1
- package/dist/shared/{vue.DZWyk9E_.mjs → vue.DL-yMCNc.mjs} +18 -74
- package/dist/shared/vue.DNxOpDXz.cjs +12 -0
- package/dist/shared/{vue.BPuN7ieB.mjs → vue.DP7qY8Rk.mjs} +9 -9
- package/dist/shared/{vue.D5Kmwcx3.cjs → vue.DgCmU1RR.cjs} +1 -1
- package/dist/shared/{vue.B7w1CC4R.mjs → vue.PJjEncbP.mjs} +3 -3
- package/dist/shared/{vue.BBNHeOeb.mjs → vue.WugzPOca.mjs} +6 -6
- package/dist/shared/{vue.CXNFQf3l.cjs → vue.XQFqlMId.cjs} +18 -74
- package/dist/shared/{vue.C5C3l0RQ.cjs → vue.__r7YYZE.cjs} +2 -2
- package/dist/shared/vue.dPRo2X5y.mjs +80 -0
- package/dist/shared/vue.k9Q6aN-0.cjs +10 -0
- package/dist/shared/{vue.DOpWV4b3.mjs → vue.stUBDBI9.mjs} +9 -9
- package/dist/shared/{vue.DYCd9oyI.mjs → vue.yQcL1yMv.mjs} +9 -10
- package/dist/useAccountInfo.cjs +6 -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 +6 -5
- package/dist/useBalance.cjs +4 -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 +4 -4
- package/dist/useConnection.cjs +3 -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 +3 -3
- package/dist/useProgramAccounts.cjs +6 -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 +6 -5
- package/dist/useRpc.cjs +2 -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 +2 -2
- package/dist/useSignAndSendTransaction.cjs +6 -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 +6 -6
- package/dist/useSignMessage.cjs +3 -3
- package/dist/useSignMessage.mjs +3 -3
- package/dist/useSignatureStatus.cjs +4 -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 +4 -4
- package/dist/useSolana.cjs +1 -1
- package/dist/useSolana.mjs +1 -1
- package/dist/useSolanaClient.cjs +9 -0
- package/dist/useSolanaClient.d.cts +11 -0
- package/dist/useSolanaClient.d.mts +11 -0
- package/dist/useSolanaClient.d.ts +11 -0
- package/dist/useSolanaClient.mjs +3 -0
- package/dist/useTokenAccounts.cjs +6 -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 +6 -6
- package/dist/useTokenBalance.cjs +6 -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 +6 -6
- package/dist/useTransaction.d.cts +1 -2
- package/dist/useTransaction.d.mts +1 -2
- package/dist/useTransaction.d.ts +1 -2
- package/dist/useTransactionConfirmation.cjs +4 -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 +4 -4
- package/dist/useWallet.cjs +2 -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 +2 -2
- package/dist/useWallets.cjs +2 -2
- package/dist/useWallets.mjs +2 -2
- package/package.json +11 -7
- package/dist/shared/vue.Bii4W61L.cjs +0 -9
- package/dist/shared/vue.CKXhlRu-.cjs +0 -131
- package/dist/shared/vue.CKx4lRew.mjs +0 -7
- package/dist/shared/vue.DgPfVZnU.mjs +0 -129
- 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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const transaction = require('@vue-solana/core/transaction');
|
|
4
4
|
const errors = require('@vue-solana/core/errors');
|
|
5
5
|
const vue = require('vue');
|
|
6
|
-
const useConnection = require('./vue.
|
|
6
|
+
const useConnection = require('./vue.CZwftA0L.cjs');
|
|
7
7
|
|
|
8
8
|
function getConfirmedTransactionStatus(confirmation) {
|
|
9
9
|
if (confirmation.commitment === "finalized") {
|
|
@@ -12,7 +12,7 @@ function getConfirmedTransactionStatus(confirmation) {
|
|
|
12
12
|
return confirmation.commitment === "processed" ? "processed" : "confirmed";
|
|
13
13
|
}
|
|
14
14
|
function useTransactionConfirmation(defaultOptions = {}) {
|
|
15
|
-
const
|
|
15
|
+
const client = useConnection.useConnection();
|
|
16
16
|
const signature = vue.ref(null);
|
|
17
17
|
const confirmation = vue.ref(null);
|
|
18
18
|
const status = vue.ref("idle");
|
|
@@ -29,7 +29,7 @@ function useTransactionConfirmation(defaultOptions = {}) {
|
|
|
29
29
|
error.value = null;
|
|
30
30
|
try {
|
|
31
31
|
const nextConfirmation = await transaction.confirmTransactionSignature(
|
|
32
|
-
|
|
32
|
+
client,
|
|
33
33
|
nextSignature,
|
|
34
34
|
confirmationOptions
|
|
35
35
|
);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const address = require('@vue-solana/core/address');
|
|
4
3
|
const errors = require('@vue-solana/core/errors');
|
|
5
4
|
const vue = require('vue');
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const address = require('@vue-solana/core/address');
|
|
6
|
+
const useConnection = require('./vue.CZwftA0L.cjs');
|
|
7
|
+
const useSolana = require('./vue.BaR1VPhl.cjs');
|
|
8
|
+
const decodeBase64 = require('./vue.DNxOpDXz.cjs');
|
|
8
9
|
|
|
9
10
|
function useProgramAccounts(programId, options = {}) {
|
|
10
11
|
const solana = useSolana.tryUseSolana();
|
|
11
|
-
const
|
|
12
|
+
const client = solana?.client ?? useConnection.useConnection();
|
|
12
13
|
const accounts = vue.shallowRef([]);
|
|
13
14
|
const loading = vue.shallowRef(false);
|
|
14
15
|
const error = vue.shallowRef(null);
|
|
@@ -25,16 +26,27 @@ function useProgramAccounts(programId, options = {}) {
|
|
|
25
26
|
loading.value = true;
|
|
26
27
|
error.value = null;
|
|
27
28
|
try {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
29
|
+
const parsedAddress = address.parseAddress(value);
|
|
30
|
+
if (!parsedAddress) {
|
|
30
31
|
accounts.value = [];
|
|
31
32
|
return [];
|
|
32
33
|
}
|
|
33
|
-
const
|
|
34
|
+
const { value: response } = await client.rpc.getProgramAccounts(parsedAddress, {
|
|
35
|
+
encoding: "base64",
|
|
34
36
|
commitment: options.commitment,
|
|
35
37
|
dataSlice: options.dataSlice,
|
|
36
38
|
filters: options.filters
|
|
37
|
-
});
|
|
39
|
+
}).send();
|
|
40
|
+
const nextAccounts = response.map(({ pubkey, account }) => ({
|
|
41
|
+
pubkey,
|
|
42
|
+
account: {
|
|
43
|
+
executable: account.executable,
|
|
44
|
+
lamports: Number(account.lamports),
|
|
45
|
+
owner: account.owner,
|
|
46
|
+
space: Number(account.space),
|
|
47
|
+
data: decodeBase64.decodeBase64(account.data[0])
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
38
50
|
if (requestId === refreshId) {
|
|
39
51
|
accounts.value = nextAccounts;
|
|
40
52
|
}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
const address = require('@vue-solana/core/address');
|
|
4
4
|
const errors = require('@vue-solana/core/errors');
|
|
5
5
|
const vue = require('vue');
|
|
6
|
-
const useConnection = require('./vue.
|
|
7
|
-
const useSolana = require('./vue.
|
|
6
|
+
const useConnection = require('./vue.CZwftA0L.cjs');
|
|
7
|
+
const useSolana = require('./vue.BaR1VPhl.cjs');
|
|
8
8
|
|
|
9
9
|
function useBalance(address$1, commitment) {
|
|
10
10
|
const solana = useSolana.tryUseSolana();
|
|
11
|
-
const
|
|
11
|
+
const client = solana?.client ?? useConnection.useConnection();
|
|
12
12
|
const balance = vue.shallowRef(null);
|
|
13
13
|
const loading = vue.shallowRef(false);
|
|
14
14
|
const error = vue.shallowRef(null);
|
|
@@ -25,16 +25,16 @@ function useBalance(address$1, commitment) {
|
|
|
25
25
|
loading.value = true;
|
|
26
26
|
error.value = null;
|
|
27
27
|
try {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
28
|
+
const parsedAddress = address.parseAddress(value);
|
|
29
|
+
if (!parsedAddress) {
|
|
30
30
|
balance.value = null;
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
|
-
const
|
|
33
|
+
const { value: lamports } = await client.rpc.getBalance(parsedAddress, commitment ? { commitment } : void 0).send();
|
|
34
34
|
if (requestId === refreshId) {
|
|
35
|
-
balance.value =
|
|
35
|
+
balance.value = Number(lamports);
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return Number(lamports);
|
|
38
38
|
} catch (cause) {
|
|
39
39
|
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
40
40
|
if (requestId === refreshId) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const errors = require('@vue-solana/core/errors');
|
|
4
4
|
const wallet = require('@vue-solana/core/wallet');
|
|
5
5
|
const vue = require('vue');
|
|
6
|
-
const useWallet = require('./vue.
|
|
6
|
+
const useWallet = require('./vue.BAlo-tIh.cjs');
|
|
7
7
|
|
|
8
8
|
function useSignMessage() {
|
|
9
9
|
const { wallet: wallet$1 } = useWallet.useWallet();
|
|
@@ -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.CZwftA0L.cjs');
|
|
9
|
+
const useWallet = require('./vue.BAlo-tIh.cjs');
|
|
10
|
+
const useTransactionConfirmation = require('./vue.C32ozdA1.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,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const address = require('@vue-solana/core/address');
|
|
4
|
-
const errors = require('@vue-solana/core/errors');
|
|
5
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
6
|
const vue = require('vue');
|
|
7
|
-
const useConnection = require('./vue.
|
|
8
|
-
const useSolana = require('./vue.
|
|
7
|
+
const useConnection = require('./vue.CZwftA0L.cjs');
|
|
8
|
+
const useSolana = require('./vue.BaR1VPhl.cjs');
|
|
9
9
|
|
|
10
|
-
function useTokenBalance(mint, owner) {
|
|
10
|
+
function useTokenBalance(mint, owner, commitment) {
|
|
11
11
|
const solana = useSolana.tryUseSolana();
|
|
12
|
-
const
|
|
12
|
+
const client = solana?.client ?? useConnection.useConnection();
|
|
13
13
|
const balance = vue.shallowRef(null);
|
|
14
14
|
const decimals = vue.shallowRef(null);
|
|
15
15
|
const loading = vue.shallowRef(false);
|
|
@@ -29,15 +29,15 @@ function useTokenBalance(mint, owner) {
|
|
|
29
29
|
loading.value = true;
|
|
30
30
|
error.value = null;
|
|
31
31
|
try {
|
|
32
|
-
const mintKey = address.
|
|
33
|
-
const ownerKey = address.
|
|
32
|
+
const mintKey = address.parseAddress(mintValue);
|
|
33
|
+
const ownerKey = address.parseAddress(ownerValue);
|
|
34
34
|
if (!mintKey || !ownerKey) {
|
|
35
35
|
balance.value = null;
|
|
36
36
|
decimals.value = null;
|
|
37
37
|
loading.value = false;
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
const nextBalance = await tokenAccounts.getTokenBalance(
|
|
40
|
+
const nextBalance = await tokenAccounts.getTokenBalance(client, mintKey, ownerKey, commitment);
|
|
41
41
|
if (requestId === refreshId) {
|
|
42
42
|
balance.value = nextBalance?.amount ?? null;
|
|
43
43
|
decimals.value = nextBalance?.decimals ?? null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
2
|
import { createNoWalletSelectedError, assertWalletCanSignMessage } from '@vue-solana/core/wallet';
|
|
3
3
|
import { ref } from 'vue';
|
|
4
|
-
import { u as useWallet } from './vue.
|
|
4
|
+
import { u as useWallet } from './vue.PJjEncbP.mjs';
|
|
5
5
|
|
|
6
6
|
function useSignMessage() {
|
|
7
7
|
const { wallet } = useWallet();
|
|
@@ -16,7 +16,7 @@ function getSsrContext() {
|
|
|
16
16
|
cluster: "devnet",
|
|
17
17
|
endpoint: "",
|
|
18
18
|
wsEndpoint: "",
|
|
19
|
-
|
|
19
|
+
client: createUnavailableProxy(),
|
|
20
20
|
wallet: shallowRef(null),
|
|
21
21
|
status: ref("idle"),
|
|
22
22
|
error: ref(null),
|
|
@@ -34,7 +34,7 @@ function getSsrContext() {
|
|
|
34
34
|
};
|
|
35
35
|
return ssrContext;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function createUnavailableProxy() {
|
|
38
38
|
return new Proxy(
|
|
39
39
|
{},
|
|
40
40
|
{
|
|
@@ -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.ChujsB0B.mjs';
|
|
5
|
+
import { t as tryUseSolana } from './vue.CnUlZSe8.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 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function decodeBase64(value) {
|
|
4
|
+
const binary = atob(value);
|
|
5
|
+
const bytes = new Uint8Array(binary.length);
|
|
6
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
7
|
+
bytes[index] = binary.charCodeAt(index);
|
|
8
|
+
}
|
|
9
|
+
return bytes;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.decodeBase64 = decodeBase64;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { parsePublicKey } from '@vue-solana/core/address';
|
|
2
|
-
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
3
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
4
|
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
5
|
-
import { u as useConnection } from './vue.
|
|
6
|
-
import { t as tryUseSolana } from './vue.
|
|
5
|
+
import { u as useConnection } from './vue.ChujsB0B.mjs';
|
|
6
|
+
import { t as tryUseSolana } from './vue.CnUlZSe8.mjs';
|
|
7
7
|
|
|
8
|
-
function useTokenBalance(mint, owner) {
|
|
8
|
+
function useTokenBalance(mint, owner, commitment) {
|
|
9
9
|
const solana = tryUseSolana();
|
|
10
|
-
const
|
|
10
|
+
const client = solana?.client ?? useConnection();
|
|
11
11
|
const balance = shallowRef(null);
|
|
12
12
|
const decimals = shallowRef(null);
|
|
13
13
|
const loading = shallowRef(false);
|
|
@@ -27,15 +27,15 @@ function useTokenBalance(mint, owner) {
|
|
|
27
27
|
loading.value = true;
|
|
28
28
|
error.value = null;
|
|
29
29
|
try {
|
|
30
|
-
const mintKey =
|
|
31
|
-
const ownerKey =
|
|
30
|
+
const mintKey = parseAddress(mintValue);
|
|
31
|
+
const ownerKey = parseAddress(ownerValue);
|
|
32
32
|
if (!mintKey || !ownerKey) {
|
|
33
33
|
balance.value = null;
|
|
34
34
|
decimals.value = null;
|
|
35
35
|
loading.value = false;
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
|
-
const nextBalance = await getTokenBalance(
|
|
38
|
+
const nextBalance = await getTokenBalance(client, mintKey, ownerKey, commitment);
|
|
39
39
|
if (requestId === refreshId) {
|
|
40
40
|
balance.value = nextBalance?.amount ?? null;
|
|
41
41
|
decimals.value = nextBalance?.decimals ?? null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
2
|
import { createNoWalletSelectedError } from '@vue-solana/core/wallet';
|
|
3
3
|
import { ref, computed, triggerRef } from 'vue';
|
|
4
|
-
import { u as useSolana } from './vue.
|
|
4
|
+
import { u as useSolana } from './vue.CnUlZSe8.mjs';
|
|
5
5
|
|
|
6
6
|
function useWallet() {
|
|
7
7
|
const solana = useSolana();
|
|
@@ -20,7 +20,7 @@ function useWallet() {
|
|
|
20
20
|
await connection;
|
|
21
21
|
triggerRef(wallet);
|
|
22
22
|
console.info("[Vue Solana] Wallet connected", {
|
|
23
|
-
publicKey: activeWallet.publicKey
|
|
23
|
+
publicKey: activeWallet.publicKey ?? null
|
|
24
24
|
});
|
|
25
25
|
} catch (error) {
|
|
26
26
|
const normalizedError = normalizeSolanaError(error, "RPC_FAILURE");
|
|
@@ -36,7 +36,7 @@ function useWallet() {
|
|
|
36
36
|
if (!activeWallet) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
const publicKey = activeWallet.publicKey
|
|
39
|
+
const publicKey = activeWallet.publicKey ?? null;
|
|
40
40
|
disconnecting.value = true;
|
|
41
41
|
try {
|
|
42
42
|
await activeWallet.disconnect();
|
|
@@ -3,13 +3,13 @@ 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
5
|
import { ref } from 'vue';
|
|
6
|
-
import { u as useConnection } from './vue.
|
|
7
|
-
import { u as useWallet } from './vue.
|
|
8
|
-
import { g as getConfirmedTransactionStatus } from './vue.
|
|
6
|
+
import { u as useConnection } from './vue.ChujsB0B.mjs';
|
|
7
|
+
import { u as useWallet } from './vue.PJjEncbP.mjs';
|
|
8
|
+
import { g as getConfirmedTransactionStatus } from './vue.B2sFJ1xI.mjs';
|
|
9
9
|
|
|
10
10
|
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
11
11
|
function useSignAndSendTransaction() {
|
|
12
|
-
const
|
|
12
|
+
const client = useConnection();
|
|
13
13
|
const { wallet } = useWallet();
|
|
14
14
|
const signature = ref(null);
|
|
15
15
|
const confirmation = ref(null);
|
|
@@ -35,7 +35,7 @@ function useSignAndSendTransaction() {
|
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
37
|
const nextSignature = await withSolanaTimeout(
|
|
38
|
-
signAndSendTransaction(
|
|
38
|
+
signAndSendTransaction(client, activeWallet, transaction, transactionOptions),
|
|
39
39
|
SIGN_AND_SEND_TIMEOUT_MS,
|
|
40
40
|
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
41
41
|
);
|
|
@@ -47,7 +47,7 @@ function useSignAndSendTransaction() {
|
|
|
47
47
|
return nextSignature;
|
|
48
48
|
}
|
|
49
49
|
const nextConfirmation = await confirmTransactionSignature(
|
|
50
|
-
|
|
50
|
+
client,
|
|
51
51
|
nextSignature,
|
|
52
52
|
confirmationOptions
|
|
53
53
|
);
|