@vue-solana/vue 0.6.1 → 0.8.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 +39 -3
- package/dist/index.cjs +71 -34
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +69 -34
- package/dist/shared/{vue.DYf_CRDv.mjs → vue.5sF8eKgx.mjs} +30 -5
- package/dist/shared/{vue.BPnK_lsh.cjs → vue.BBoDTIfF.cjs} +6 -4
- package/dist/shared/{vue.DQhHHVu6.mjs → vue.BDl2vVkp.mjs} +10 -4
- package/dist/shared/{vue.DHVYJk8P.cjs → vue.BeA8WQ2g.cjs} +4 -2
- package/dist/shared/{vue.RQ9fETnm.mjs → vue.BlfFUgC-.mjs} +20 -28
- package/dist/shared/{vue.DEQJ23UM.cjs → vue.BnSjOzvb.cjs} +21 -29
- package/dist/shared/{vue.JC5FdU2O.mjs → vue.BzopW_4m.mjs} +8 -6
- package/dist/shared/{vue.gLqkzJY4.mjs → vue.C4d2JA8U.mjs} +7 -23
- package/dist/shared/{vue.DQi38JeF.cjs → vue.CE5i8KZZ.cjs} +6 -23
- package/dist/shared/{vue.7TzeDJZX.mjs → vue.Cl3hXlXK.mjs} +6 -4
- package/dist/shared/{vue.jOsz34kz.mjs → vue.CxMrojxC.mjs} +4 -2
- package/dist/shared/{vue.CUTLu1Gf.mjs → vue.CzTu_DPr.mjs} +4 -2
- package/dist/shared/{vue.dmuispJ3.cjs → vue.D1JtJ2lD.cjs} +4 -2
- package/dist/shared/{vue.DGhodYJh.d.cts → vue.DL3z5PxP.d.cts} +2 -1
- package/dist/shared/{vue.DGhodYJh.d.mts → vue.DL3z5PxP.d.mts} +2 -1
- package/dist/shared/{vue.DGhodYJh.d.ts → vue.DL3z5PxP.d.ts} +2 -1
- package/dist/shared/{vue.DUufwq8y.cjs → vue.DRlaqQCL.cjs} +8 -6
- package/dist/shared/vue.DfeKj9vL.cjs +94 -0
- package/dist/shared/vue.DuI_Jm5P.cjs +63 -0
- package/dist/shared/{vue.D_AM1Nl8.cjs → vue.NFoc_-Kt.cjs} +13 -7
- package/dist/shared/vue.PTQ2iRAi.mjs +61 -0
- package/dist/useAccountInfo.cjs +2 -1
- package/dist/useAccountInfo.d.cts +2 -1
- package/dist/useAccountInfo.d.mts +2 -1
- package/dist/useAccountInfo.d.ts +2 -1
- package/dist/useAccountInfo.mjs +2 -1
- package/dist/useBalance.cjs +3 -2
- package/dist/useBalance.d.cts +2 -1
- package/dist/useBalance.d.mts +2 -1
- package/dist/useBalance.d.ts +2 -1
- package/dist/useBalance.mjs +3 -2
- package/dist/useProgramAccounts.cjs +2 -1
- package/dist/useProgramAccounts.d.cts +2 -1
- package/dist/useProgramAccounts.d.mts +2 -1
- package/dist/useProgramAccounts.d.ts +2 -1
- package/dist/useProgramAccounts.mjs +2 -1
- package/dist/useRpc.d.cts +3 -2
- package/dist/useRpc.d.mts +3 -2
- package/dist/useRpc.d.ts +3 -2
- package/dist/useSignAndSendTransaction.cjs +6 -3
- package/dist/useSignAndSendTransaction.d.cts +2 -1
- package/dist/useSignAndSendTransaction.d.mts +2 -1
- package/dist/useSignAndSendTransaction.d.ts +2 -1
- package/dist/useSignAndSendTransaction.mjs +6 -3
- package/dist/useSignMessage.cjs +12 -0
- package/dist/useSignMessage.d.cts +236 -0
- package/dist/useSignMessage.d.mts +236 -0
- package/dist/useSignMessage.d.ts +236 -0
- package/dist/useSignMessage.mjs +6 -0
- package/dist/useSignatureStatus.cjs +2 -1
- package/dist/useSignatureStatus.d.cts +2 -1
- package/dist/useSignatureStatus.d.mts +2 -1
- package/dist/useSignatureStatus.d.ts +2 -1
- package/dist/useSignatureStatus.mjs +2 -1
- package/dist/useSolana.d.cts +2 -1
- package/dist/useSolana.d.mts +2 -1
- package/dist/useSolana.d.ts +2 -1
- package/dist/useTransaction.cjs +3 -1
- package/dist/useTransaction.d.cts +2 -1
- package/dist/useTransaction.d.mts +2 -1
- package/dist/useTransaction.d.ts +2 -1
- package/dist/useTransaction.mjs +3 -1
- package/dist/useTransactionConfirmation.cjs +2 -1
- package/dist/useTransactionConfirmation.d.cts +2 -1
- package/dist/useTransactionConfirmation.d.mts +2 -1
- package/dist/useTransactionConfirmation.d.ts +2 -1
- package/dist/useTransactionConfirmation.mjs +2 -1
- package/dist/useWallet.cjs +3 -1
- package/dist/useWallet.d.cts +14 -0
- package/dist/useWallet.d.mts +14 -0
- package/dist/useWallet.d.ts +14 -0
- package/dist/useWallet.mjs +3 -1
- package/package.json +7 -2
- package/dist/shared/vue.CwPjPFN6.cjs +0 -69
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parsePublicKey } from '@vue-solana/core/address';
|
|
2
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
3
|
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
3
4
|
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
4
5
|
import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
|
|
@@ -22,17 +23,22 @@ function useBalance(address, commitment) {
|
|
|
22
23
|
loading.value = true;
|
|
23
24
|
error.value = null;
|
|
24
25
|
try {
|
|
25
|
-
const publicKey =
|
|
26
|
+
const publicKey = parsePublicKey(value);
|
|
27
|
+
if (!publicKey) {
|
|
28
|
+
balance.value = null;
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
26
31
|
const nextBalance = await connection.getBalance(publicKey, commitment);
|
|
27
32
|
if (requestId === refreshId) {
|
|
28
33
|
balance.value = nextBalance;
|
|
29
34
|
}
|
|
30
35
|
return nextBalance;
|
|
31
36
|
} catch (cause) {
|
|
37
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
32
38
|
if (requestId === refreshId) {
|
|
33
|
-
error.value =
|
|
39
|
+
error.value = normalizedError;
|
|
34
40
|
}
|
|
35
|
-
throw
|
|
41
|
+
throw normalizedError;
|
|
36
42
|
} finally {
|
|
37
43
|
if (requestId === refreshId) {
|
|
38
44
|
loading.value = false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const transaction = require('@vue-solana/core/transaction');
|
|
4
|
+
const errors = require('@vue-solana/core/errors');
|
|
4
5
|
const vue = require('vue');
|
|
5
6
|
const useConnection = require('./vue.CwhEmATP.cjs');
|
|
6
7
|
|
|
@@ -38,11 +39,12 @@ function useTransactionConfirmation(defaultOptions = {}) {
|
|
|
38
39
|
}
|
|
39
40
|
return nextConfirmation;
|
|
40
41
|
} catch (cause) {
|
|
42
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
41
43
|
if (currentExecutionId === executionId) {
|
|
42
|
-
error.value =
|
|
44
|
+
error.value = normalizedError;
|
|
43
45
|
status.value = "error";
|
|
44
46
|
}
|
|
45
|
-
throw
|
|
47
|
+
throw normalizedError;
|
|
46
48
|
} finally {
|
|
47
49
|
if (currentExecutionId === executionId) {
|
|
48
50
|
loading.value = false;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { withSolanaTimeout } from '@vue-solana/core/timeout';
|
|
1
3
|
import { signAndSendTransaction, confirmTransactionSignature } from '@vue-solana/core/transaction';
|
|
4
|
+
import { createNoWalletSelectedError } from '@vue-solana/core/wallet';
|
|
2
5
|
import { ref } from 'vue';
|
|
3
6
|
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
4
|
-
import { u as useWallet } from './vue.
|
|
5
|
-
import { g as getConfirmedTransactionStatus } from './vue.
|
|
7
|
+
import { u as useWallet } from './vue.5sF8eKgx.mjs';
|
|
8
|
+
import { g as getConfirmedTransactionStatus } from './vue.CxMrojxC.mjs';
|
|
6
9
|
|
|
7
10
|
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
8
11
|
function useSignAndSendTransaction() {
|
|
@@ -22,12 +25,19 @@ function useSignAndSendTransaction() {
|
|
|
22
25
|
loading.value = true;
|
|
23
26
|
error.value = null;
|
|
24
27
|
confirmation.value = null;
|
|
28
|
+
const activeWallet = wallet.value;
|
|
29
|
+
if (!activeWallet) {
|
|
30
|
+
const normalizedError = createNoWalletSelectedError();
|
|
31
|
+
error.value = normalizedError;
|
|
32
|
+
status.value = "error";
|
|
33
|
+
loading.value = false;
|
|
34
|
+
throw normalizedError;
|
|
35
|
+
}
|
|
25
36
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
signAndSendTransaction(connection, wallet.value, transaction, transactionOptions)
|
|
37
|
+
const nextSignature = await withSolanaTimeout(
|
|
38
|
+
signAndSendTransaction(connection, activeWallet, transaction, transactionOptions),
|
|
39
|
+
SIGN_AND_SEND_TIMEOUT_MS,
|
|
40
|
+
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
31
41
|
);
|
|
32
42
|
if (currentExecutionId === executionId) {
|
|
33
43
|
signature.value = nextSignature;
|
|
@@ -47,11 +57,12 @@ function useSignAndSendTransaction() {
|
|
|
47
57
|
}
|
|
48
58
|
return nextSignature;
|
|
49
59
|
} catch (cause) {
|
|
60
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
50
61
|
if (currentExecutionId === executionId) {
|
|
51
|
-
error.value =
|
|
62
|
+
error.value = normalizedError;
|
|
52
63
|
status.value = "error";
|
|
53
64
|
}
|
|
54
|
-
throw
|
|
65
|
+
throw normalizedError;
|
|
55
66
|
} finally {
|
|
56
67
|
if (currentExecutionId === executionId) {
|
|
57
68
|
loading.value = false;
|
|
@@ -67,24 +78,5 @@ function useSignAndSendTransaction() {
|
|
|
67
78
|
execute
|
|
68
79
|
};
|
|
69
80
|
}
|
|
70
|
-
async function withWalletTransactionTimeout(promise) {
|
|
71
|
-
let timeoutId;
|
|
72
|
-
try {
|
|
73
|
-
const timeout = new Promise((_, reject) => {
|
|
74
|
-
timeoutId = setTimeout(() => {
|
|
75
|
-
reject(
|
|
76
|
-
new Error(
|
|
77
|
-
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
78
|
-
)
|
|
79
|
-
);
|
|
80
|
-
}, SIGN_AND_SEND_TIMEOUT_MS);
|
|
81
|
-
});
|
|
82
|
-
return await Promise.race([promise, timeout]);
|
|
83
|
-
} finally {
|
|
84
|
-
if (timeoutId) {
|
|
85
|
-
clearTimeout(timeoutId);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
81
|
|
|
90
82
|
export { useSignAndSendTransaction as u };
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const errors = require('@vue-solana/core/errors');
|
|
4
|
+
const timeout = require('@vue-solana/core/timeout');
|
|
3
5
|
const transaction = require('@vue-solana/core/transaction');
|
|
6
|
+
const wallet = require('@vue-solana/core/wallet');
|
|
4
7
|
const vue = require('vue');
|
|
5
8
|
const useConnection = require('./vue.CwhEmATP.cjs');
|
|
6
|
-
const useWallet = require('./vue.
|
|
7
|
-
const useTransactionConfirmation = require('./vue.
|
|
9
|
+
const useWallet = require('./vue.DfeKj9vL.cjs');
|
|
10
|
+
const useTransactionConfirmation = require('./vue.BeA8WQ2g.cjs');
|
|
8
11
|
|
|
9
12
|
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
10
13
|
function useSignAndSendTransaction() {
|
|
11
14
|
const connection = useConnection.useConnection();
|
|
12
|
-
const { wallet } = useWallet.useWallet();
|
|
15
|
+
const { wallet: wallet$1 } = useWallet.useWallet();
|
|
13
16
|
const signature = vue.ref(null);
|
|
14
17
|
const confirmation = vue.ref(null);
|
|
15
18
|
const status = vue.ref("idle");
|
|
@@ -24,12 +27,19 @@ function useSignAndSendTransaction() {
|
|
|
24
27
|
loading.value = true;
|
|
25
28
|
error.value = null;
|
|
26
29
|
confirmation.value = null;
|
|
30
|
+
const activeWallet = wallet$1.value;
|
|
31
|
+
if (!activeWallet) {
|
|
32
|
+
const normalizedError = wallet.createNoWalletSelectedError();
|
|
33
|
+
error.value = normalizedError;
|
|
34
|
+
status.value = "error";
|
|
35
|
+
loading.value = false;
|
|
36
|
+
throw normalizedError;
|
|
37
|
+
}
|
|
27
38
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
transaction.signAndSendTransaction(connection, wallet.value, transaction$1, transactionOptions)
|
|
39
|
+
const nextSignature = await timeout.withSolanaTimeout(
|
|
40
|
+
transaction.signAndSendTransaction(connection, activeWallet, transaction$1, transactionOptions),
|
|
41
|
+
SIGN_AND_SEND_TIMEOUT_MS,
|
|
42
|
+
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
33
43
|
);
|
|
34
44
|
if (currentExecutionId === executionId) {
|
|
35
45
|
signature.value = nextSignature;
|
|
@@ -49,11 +59,12 @@ function useSignAndSendTransaction() {
|
|
|
49
59
|
}
|
|
50
60
|
return nextSignature;
|
|
51
61
|
} catch (cause) {
|
|
62
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
52
63
|
if (currentExecutionId === executionId) {
|
|
53
|
-
error.value =
|
|
64
|
+
error.value = normalizedError;
|
|
54
65
|
status.value = "error";
|
|
55
66
|
}
|
|
56
|
-
throw
|
|
67
|
+
throw normalizedError;
|
|
57
68
|
} finally {
|
|
58
69
|
if (currentExecutionId === executionId) {
|
|
59
70
|
loading.value = false;
|
|
@@ -69,24 +80,5 @@ function useSignAndSendTransaction() {
|
|
|
69
80
|
execute
|
|
70
81
|
};
|
|
71
82
|
}
|
|
72
|
-
async function withWalletTransactionTimeout(promise) {
|
|
73
|
-
let timeoutId;
|
|
74
|
-
try {
|
|
75
|
-
const timeout = new Promise((_, reject) => {
|
|
76
|
-
timeoutId = setTimeout(() => {
|
|
77
|
-
reject(
|
|
78
|
-
new Error(
|
|
79
|
-
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
80
|
-
)
|
|
81
|
-
);
|
|
82
|
-
}, SIGN_AND_SEND_TIMEOUT_MS);
|
|
83
|
-
});
|
|
84
|
-
return await Promise.race([promise, timeout]);
|
|
85
|
-
} finally {
|
|
86
|
-
if (timeoutId) {
|
|
87
|
-
clearTimeout(timeoutId);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
83
|
|
|
92
84
|
exports.useSignAndSendTransaction = useSignAndSendTransaction;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeSolanaError, createSolanaError } from '@vue-solana/core/errors';
|
|
1
2
|
import bs58 from 'bs58';
|
|
2
3
|
import { shallowRef, onMounted, onUnmounted, watch, toValue } from 'vue';
|
|
3
4
|
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
@@ -37,11 +38,12 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
37
38
|
}
|
|
38
39
|
return nextStatus;
|
|
39
40
|
} catch (cause) {
|
|
41
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
40
42
|
if (requestId === refreshId) {
|
|
41
43
|
status.value = null;
|
|
42
|
-
error.value =
|
|
44
|
+
error.value = normalizedError;
|
|
43
45
|
}
|
|
44
|
-
throw
|
|
46
|
+
throw normalizedError;
|
|
45
47
|
} finally {
|
|
46
48
|
if (requestId === refreshId) {
|
|
47
49
|
loading.value = false;
|
|
@@ -66,13 +68,13 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
66
68
|
return;
|
|
67
69
|
}
|
|
68
70
|
if (options.pollIntervalMs <= 0) {
|
|
69
|
-
error.value =
|
|
71
|
+
error.value = createSolanaError("RPC_FAILURE", "pollIntervalMs must be greater than 0");
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
74
|
try {
|
|
73
75
|
parseTransactionSignature(value);
|
|
74
76
|
} catch (cause) {
|
|
75
|
-
error.value = cause;
|
|
77
|
+
error.value = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
76
78
|
return;
|
|
77
79
|
}
|
|
78
80
|
pollId = setInterval(() => {
|
|
@@ -93,7 +95,7 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
93
95
|
try {
|
|
94
96
|
await connection.removeSignatureListener(currentSubscriptionId);
|
|
95
97
|
} catch (cause) {
|
|
96
|
-
error.value = cause;
|
|
98
|
+
error.value = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
async function startSubscription() {
|
|
@@ -131,7 +133,7 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
131
133
|
subscriptionId = nextSubscriptionId;
|
|
132
134
|
} catch (cause) {
|
|
133
135
|
if (requestId === subscriptionStartId) {
|
|
134
|
-
error.value = cause;
|
|
136
|
+
error.value = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
}
|
|
@@ -1,24 +1,7 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { withSolanaTimeout } from '@vue-solana/core/timeout';
|
|
1
3
|
import { ref } from 'vue';
|
|
2
4
|
|
|
3
|
-
async function withTimeout(promise, timeoutMs, message) {
|
|
4
|
-
if (!timeoutMs) {
|
|
5
|
-
return promise;
|
|
6
|
-
}
|
|
7
|
-
let timeoutId;
|
|
8
|
-
try {
|
|
9
|
-
const timeout = new Promise((_, reject) => {
|
|
10
|
-
timeoutId = setTimeout(() => {
|
|
11
|
-
reject(new Error(message));
|
|
12
|
-
}, timeoutMs);
|
|
13
|
-
});
|
|
14
|
-
return await Promise.race([promise, timeout]);
|
|
15
|
-
} finally {
|
|
16
|
-
if (timeoutId) {
|
|
17
|
-
clearTimeout(timeoutId);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
5
|
function useTransaction(handler, options = {}) {
|
|
23
6
|
const signature = ref(null);
|
|
24
7
|
const loading = ref(false);
|
|
@@ -29,7 +12,7 @@ function useTransaction(handler, options = {}) {
|
|
|
29
12
|
loading.value = true;
|
|
30
13
|
error.value = null;
|
|
31
14
|
try {
|
|
32
|
-
const nextSignature = await
|
|
15
|
+
const nextSignature = await withSolanaTimeout(
|
|
33
16
|
handler(...args),
|
|
34
17
|
options.timeoutMs,
|
|
35
18
|
options.timeoutMessage ?? "Transaction did not return a result before timing out."
|
|
@@ -39,10 +22,11 @@ function useTransaction(handler, options = {}) {
|
|
|
39
22
|
}
|
|
40
23
|
return nextSignature;
|
|
41
24
|
} catch (cause) {
|
|
25
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
42
26
|
if (currentExecutionId === executionId) {
|
|
43
|
-
error.value =
|
|
27
|
+
error.value = normalizedError;
|
|
44
28
|
}
|
|
45
|
-
throw
|
|
29
|
+
throw normalizedError;
|
|
46
30
|
} finally {
|
|
47
31
|
if (currentExecutionId === executionId) {
|
|
48
32
|
loading.value = false;
|
|
@@ -57,4 +41,4 @@ function useTransaction(handler, options = {}) {
|
|
|
57
41
|
};
|
|
58
42
|
}
|
|
59
43
|
|
|
60
|
-
export { useTransaction as u
|
|
44
|
+
export { useTransaction as u };
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const errors = require('@vue-solana/core/errors');
|
|
4
|
+
const timeout = require('@vue-solana/core/timeout');
|
|
3
5
|
const vue = require('vue');
|
|
4
6
|
|
|
5
|
-
async function withTimeout(promise, timeoutMs, message) {
|
|
6
|
-
if (!timeoutMs) {
|
|
7
|
-
return promise;
|
|
8
|
-
}
|
|
9
|
-
let timeoutId;
|
|
10
|
-
try {
|
|
11
|
-
const timeout = new Promise((_, reject) => {
|
|
12
|
-
timeoutId = setTimeout(() => {
|
|
13
|
-
reject(new Error(message));
|
|
14
|
-
}, timeoutMs);
|
|
15
|
-
});
|
|
16
|
-
return await Promise.race([promise, timeout]);
|
|
17
|
-
} finally {
|
|
18
|
-
if (timeoutId) {
|
|
19
|
-
clearTimeout(timeoutId);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
7
|
function useTransaction(handler, options = {}) {
|
|
25
8
|
const signature = vue.ref(null);
|
|
26
9
|
const loading = vue.ref(false);
|
|
@@ -31,7 +14,7 @@ function useTransaction(handler, options = {}) {
|
|
|
31
14
|
loading.value = true;
|
|
32
15
|
error.value = null;
|
|
33
16
|
try {
|
|
34
|
-
const nextSignature = await
|
|
17
|
+
const nextSignature = await timeout.withSolanaTimeout(
|
|
35
18
|
handler(...args),
|
|
36
19
|
options.timeoutMs,
|
|
37
20
|
options.timeoutMessage ?? "Transaction did not return a result before timing out."
|
|
@@ -41,10 +24,11 @@ function useTransaction(handler, options = {}) {
|
|
|
41
24
|
}
|
|
42
25
|
return nextSignature;
|
|
43
26
|
} catch (cause) {
|
|
27
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
44
28
|
if (currentExecutionId === executionId) {
|
|
45
|
-
error.value =
|
|
29
|
+
error.value = normalizedError;
|
|
46
30
|
}
|
|
47
|
-
throw
|
|
31
|
+
throw normalizedError;
|
|
48
32
|
} finally {
|
|
49
33
|
if (currentExecutionId === executionId) {
|
|
50
34
|
loading.value = false;
|
|
@@ -60,4 +44,3 @@ function useTransaction(handler, options = {}) {
|
|
|
60
44
|
}
|
|
61
45
|
|
|
62
46
|
exports.useTransaction = useTransaction;
|
|
63
|
-
exports.withTimeout = withTimeout;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parsePublicKey } from '@vue-solana/core/address';
|
|
2
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
3
|
import { shallowRef, onMounted, onUnmounted, watch, toValue } from 'vue';
|
|
3
4
|
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
4
5
|
import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
|
|
@@ -36,11 +37,12 @@ function useAccountInfo(address, options = {}) {
|
|
|
36
37
|
}
|
|
37
38
|
return nextAccountInfo;
|
|
38
39
|
} catch (cause) {
|
|
40
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
39
41
|
if (requestId === refreshId) {
|
|
40
42
|
accountInfo.value = null;
|
|
41
|
-
error.value =
|
|
43
|
+
error.value = normalizedError;
|
|
42
44
|
}
|
|
43
|
-
throw
|
|
45
|
+
throw normalizedError;
|
|
44
46
|
} finally {
|
|
45
47
|
if (requestId === refreshId) {
|
|
46
48
|
loading.value = false;
|
|
@@ -61,7 +63,7 @@ function useAccountInfo(address, options = {}) {
|
|
|
61
63
|
try {
|
|
62
64
|
await connection.removeAccountChangeListener(currentSubscriptionId);
|
|
63
65
|
} catch (cause) {
|
|
64
|
-
error.value = cause;
|
|
66
|
+
error.value = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
async function startWatching() {
|
|
@@ -96,7 +98,7 @@ function useAccountInfo(address, options = {}) {
|
|
|
96
98
|
subscriptionId = nextSubscriptionId;
|
|
97
99
|
} catch (cause) {
|
|
98
100
|
if (requestId === watchId) {
|
|
99
|
-
error.value = cause;
|
|
101
|
+
error.value = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { confirmTransactionSignature } from '@vue-solana/core/transaction';
|
|
2
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
3
|
import { ref } from 'vue';
|
|
3
4
|
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
4
5
|
|
|
@@ -36,11 +37,12 @@ function useTransactionConfirmation(defaultOptions = {}) {
|
|
|
36
37
|
}
|
|
37
38
|
return nextConfirmation;
|
|
38
39
|
} catch (cause) {
|
|
40
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
39
41
|
if (currentExecutionId === executionId) {
|
|
40
|
-
error.value =
|
|
42
|
+
error.value = normalizedError;
|
|
41
43
|
status.value = "error";
|
|
42
44
|
}
|
|
43
|
-
throw
|
|
45
|
+
throw normalizedError;
|
|
44
46
|
} finally {
|
|
45
47
|
if (currentExecutionId === executionId) {
|
|
46
48
|
loading.value = false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parsePublicKey } from '@vue-solana/core/address';
|
|
2
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
3
|
import { shallowRef, onMounted, onUnmounted, watch, toValue } from 'vue';
|
|
3
4
|
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
4
5
|
import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
|
|
@@ -37,11 +38,12 @@ function useProgramAccounts(programId, options = {}) {
|
|
|
37
38
|
}
|
|
38
39
|
return nextAccounts;
|
|
39
40
|
} catch (cause) {
|
|
41
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
40
42
|
if (requestId === refreshId) {
|
|
41
43
|
accounts.value = [];
|
|
42
|
-
error.value =
|
|
44
|
+
error.value = normalizedError;
|
|
43
45
|
}
|
|
44
|
-
throw
|
|
46
|
+
throw normalizedError;
|
|
45
47
|
} finally {
|
|
46
48
|
if (requestId === refreshId) {
|
|
47
49
|
loading.value = false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const address = require('@vue-solana/core/address');
|
|
4
|
+
const errors = require('@vue-solana/core/errors');
|
|
4
5
|
const vue = require('vue');
|
|
5
6
|
const useConnection = require('./vue.CwhEmATP.cjs');
|
|
6
7
|
const useSolana = require('./vue.C4tLiG3R.cjs');
|
|
@@ -39,11 +40,12 @@ function useProgramAccounts(programId, options = {}) {
|
|
|
39
40
|
}
|
|
40
41
|
return nextAccounts;
|
|
41
42
|
} catch (cause) {
|
|
43
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
42
44
|
if (requestId === refreshId) {
|
|
43
45
|
accounts.value = [];
|
|
44
|
-
error.value =
|
|
46
|
+
error.value = normalizedError;
|
|
45
47
|
}
|
|
46
|
-
throw
|
|
48
|
+
throw normalizedError;
|
|
47
49
|
} finally {
|
|
48
50
|
if (requestId === refreshId) {
|
|
49
51
|
loading.value = false;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SolanaError } from '@vue-solana/core/errors';
|
|
1
2
|
import { SolanaContext, SolanaWallet, SolanaWalletInfo } from '@vue-solana/core/types';
|
|
2
3
|
import { Ref, InjectionKey } from 'vue';
|
|
3
4
|
|
|
@@ -5,7 +6,7 @@ type SolanaConnectionStatus = "idle" | "checking" | "connected" | "error";
|
|
|
5
6
|
interface VueSolanaContext extends SolanaContext {
|
|
6
7
|
wallet: Ref<SolanaWallet | null>;
|
|
7
8
|
status: Ref<SolanaConnectionStatus>;
|
|
8
|
-
error: Ref<
|
|
9
|
+
error: Ref<SolanaError | null>;
|
|
9
10
|
latestBlockhash: Ref<string | null>;
|
|
10
11
|
wallets: Ref<SolanaWalletInfo[]>;
|
|
11
12
|
selectedWallet: Ref<SolanaWalletInfo | null>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SolanaError } from '@vue-solana/core/errors';
|
|
1
2
|
import { SolanaContext, SolanaWallet, SolanaWalletInfo } from '@vue-solana/core/types';
|
|
2
3
|
import { Ref, InjectionKey } from 'vue';
|
|
3
4
|
|
|
@@ -5,7 +6,7 @@ type SolanaConnectionStatus = "idle" | "checking" | "connected" | "error";
|
|
|
5
6
|
interface VueSolanaContext extends SolanaContext {
|
|
6
7
|
wallet: Ref<SolanaWallet | null>;
|
|
7
8
|
status: Ref<SolanaConnectionStatus>;
|
|
8
|
-
error: Ref<
|
|
9
|
+
error: Ref<SolanaError | null>;
|
|
9
10
|
latestBlockhash: Ref<string | null>;
|
|
10
11
|
wallets: Ref<SolanaWalletInfo[]>;
|
|
11
12
|
selectedWallet: Ref<SolanaWalletInfo | null>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SolanaError } from '@vue-solana/core/errors';
|
|
1
2
|
import { SolanaContext, SolanaWallet, SolanaWalletInfo } from '@vue-solana/core/types';
|
|
2
3
|
import { Ref, InjectionKey } from 'vue';
|
|
3
4
|
|
|
@@ -5,7 +6,7 @@ type SolanaConnectionStatus = "idle" | "checking" | "connected" | "error";
|
|
|
5
6
|
interface VueSolanaContext extends SolanaContext {
|
|
6
7
|
wallet: Ref<SolanaWallet | null>;
|
|
7
8
|
status: Ref<SolanaConnectionStatus>;
|
|
8
|
-
error: Ref<
|
|
9
|
+
error: Ref<SolanaError | null>;
|
|
9
10
|
latestBlockhash: Ref<string | null>;
|
|
10
11
|
wallets: Ref<SolanaWalletInfo[]>;
|
|
11
12
|
selectedWallet: Ref<SolanaWalletInfo | null>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const errors = require('@vue-solana/core/errors');
|
|
3
4
|
const bs58 = require('bs58');
|
|
4
5
|
const vue = require('vue');
|
|
5
6
|
const useConnection = require('./vue.CwhEmATP.cjs');
|
|
@@ -43,11 +44,12 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
43
44
|
}
|
|
44
45
|
return nextStatus;
|
|
45
46
|
} catch (cause) {
|
|
47
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
46
48
|
if (requestId === refreshId) {
|
|
47
49
|
status.value = null;
|
|
48
|
-
error.value =
|
|
50
|
+
error.value = normalizedError;
|
|
49
51
|
}
|
|
50
|
-
throw
|
|
52
|
+
throw normalizedError;
|
|
51
53
|
} finally {
|
|
52
54
|
if (requestId === refreshId) {
|
|
53
55
|
loading.value = false;
|
|
@@ -72,13 +74,13 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
72
74
|
return;
|
|
73
75
|
}
|
|
74
76
|
if (options.pollIntervalMs <= 0) {
|
|
75
|
-
error.value =
|
|
77
|
+
error.value = errors.createSolanaError("RPC_FAILURE", "pollIntervalMs must be greater than 0");
|
|
76
78
|
return;
|
|
77
79
|
}
|
|
78
80
|
try {
|
|
79
81
|
parseTransactionSignature(value);
|
|
80
82
|
} catch (cause) {
|
|
81
|
-
error.value = cause;
|
|
83
|
+
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
82
84
|
return;
|
|
83
85
|
}
|
|
84
86
|
pollId = setInterval(() => {
|
|
@@ -99,7 +101,7 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
99
101
|
try {
|
|
100
102
|
await connection.removeSignatureListener(currentSubscriptionId);
|
|
101
103
|
} catch (cause) {
|
|
102
|
-
error.value = cause;
|
|
104
|
+
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
async function startSubscription() {
|
|
@@ -137,7 +139,7 @@ function useSignatureStatus(signature, options = {}) {
|
|
|
137
139
|
subscriptionId = nextSubscriptionId;
|
|
138
140
|
} catch (cause) {
|
|
139
141
|
if (requestId === subscriptionStartId) {
|
|
140
|
-
error.value = cause;
|
|
142
|
+
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
}
|