@vue-solana/vue 0.7.0 → 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/dist/index.cjs +69 -35
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +68 -35
- package/dist/shared/{vue.CGVdFmYI.mjs → vue.5sF8eKgx.mjs} +9 -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.CM6qb_s8.mjs → vue.BlfFUgC-.mjs} +15 -28
- package/dist/shared/{vue.DWiQYhb8.cjs → vue.BnSjOzvb.cjs} +17 -30
- 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.mts → vue.DL3z5PxP.d.cts} +2 -1
- package/dist/shared/{vue.DGhodYJh.d.ts → vue.DL3z5PxP.d.mts} +2 -1
- package/dist/shared/{vue.DGhodYJh.d.cts → vue.DL3z5PxP.d.ts} +2 -1
- package/dist/shared/{vue.DUufwq8y.cjs → vue.DRlaqQCL.cjs} +8 -6
- package/dist/shared/{vue.BwipRa1w.cjs → vue.DfeKj9vL.cjs} +28 -24
- package/dist/shared/{vue.D1knFN3X.cjs → vue.DuI_Jm5P.cjs} +6 -8
- package/dist/shared/{vue.D_AM1Nl8.cjs → vue.NFoc_-Kt.cjs} +13 -7
- package/dist/shared/{vue.BeuIPLGM.mjs → vue.PTQ2iRAi.mjs} +7 -9
- 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 +3 -2
- package/dist/useSignMessage.d.cts +2 -1
- package/dist/useSignMessage.d.mts +2 -1
- package/dist/useSignMessage.d.ts +2 -1
- package/dist/useSignMessage.mjs +3 -2
- 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.mjs +3 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,53 +1,62 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useAccountInfo = require('./shared/vue.
|
|
4
|
-
const useBalance = require('./shared/vue.
|
|
3
|
+
const useAccountInfo = require('./shared/vue.BBoDTIfF.cjs');
|
|
4
|
+
const useBalance = require('./shared/vue.NFoc_-Kt.cjs');
|
|
5
5
|
const useConnection = require('./shared/vue.CwhEmATP.cjs');
|
|
6
|
-
const useProgramAccounts = require('./shared/vue.
|
|
6
|
+
const useProgramAccounts = require('./shared/vue.D1JtJ2lD.cjs');
|
|
7
7
|
const useRpc = require('./shared/vue.COyyrsQU.cjs');
|
|
8
|
-
const useSignMessage = require('./shared/vue.
|
|
9
|
-
const useSignAndSendTransaction = require('./shared/vue.
|
|
10
|
-
const useSignatureStatus = require('./shared/vue.
|
|
8
|
+
const useSignMessage = require('./shared/vue.DuI_Jm5P.cjs');
|
|
9
|
+
const useSignAndSendTransaction = require('./shared/vue.BnSjOzvb.cjs');
|
|
10
|
+
const useSignatureStatus = require('./shared/vue.DRlaqQCL.cjs');
|
|
11
11
|
const useSolana = require('./shared/vue.C4tLiG3R.cjs');
|
|
12
|
-
const useTransaction = require('./shared/vue.
|
|
13
|
-
const useTransactionConfirmation = require('./shared/vue.
|
|
14
|
-
const useWallet = require('./shared/vue.
|
|
12
|
+
const useTransaction = require('./shared/vue.CE5i8KZZ.cjs');
|
|
13
|
+
const useTransactionConfirmation = require('./shared/vue.BeA8WQ2g.cjs');
|
|
14
|
+
const useWallet = require('./shared/vue.DfeKj9vL.cjs');
|
|
15
15
|
const useWallets = require('./shared/vue.P9tgeC5S.cjs');
|
|
16
|
+
const errors = require('@vue-solana/core/errors');
|
|
16
17
|
const rpc = require('@vue-solana/core/rpc');
|
|
18
|
+
const timeout = require('@vue-solana/core/timeout');
|
|
17
19
|
const walletStandard = require('@vue-solana/core/wallet-standard');
|
|
18
20
|
const vue = require('vue');
|
|
19
21
|
const iosWallet = require('@vue-solana/core/ios-wallet');
|
|
20
22
|
require('@vue-solana/core/address');
|
|
21
|
-
require('@solana/web3-compat');
|
|
22
23
|
require('@vue-solana/core/wallet');
|
|
23
24
|
require('@vue-solana/core/transaction');
|
|
24
25
|
require('bs58');
|
|
25
26
|
|
|
26
27
|
const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
|
|
27
28
|
function readSelectedWallet() {
|
|
28
|
-
const storage = getLocalStorage();
|
|
29
|
-
if (!storage) {
|
|
30
|
-
return null;
|
|
29
|
+
const { storage, error } = getLocalStorage();
|
|
30
|
+
if (error || !storage) {
|
|
31
|
+
return { wallet: null, error };
|
|
31
32
|
}
|
|
32
33
|
try {
|
|
33
34
|
const value = storage.getItem(SELECTED_WALLET_STORAGE_KEY);
|
|
34
35
|
if (!value) {
|
|
35
|
-
return null;
|
|
36
|
+
return { wallet: null, error: null };
|
|
36
37
|
}
|
|
37
38
|
const wallet = JSON.parse(value);
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
return {
|
|
40
|
+
wallet: typeof wallet.name === "string" ? {
|
|
41
|
+
name: wallet.name,
|
|
42
|
+
platform: wallet.platform,
|
|
43
|
+
source: wallet.source
|
|
44
|
+
} : null,
|
|
45
|
+
error: null
|
|
46
|
+
};
|
|
47
|
+
} catch (cause) {
|
|
48
|
+
return {
|
|
49
|
+
wallet: null,
|
|
50
|
+
error: errors.createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
|
|
51
|
+
cause
|
|
52
|
+
})
|
|
53
|
+
};
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
56
|
function writeSelectedWallet(wallet) {
|
|
48
|
-
const storage = getLocalStorage();
|
|
49
|
-
if (!storage) {
|
|
50
|
-
return;
|
|
57
|
+
const { storage, error } = getLocalStorage();
|
|
58
|
+
if (error || !storage) {
|
|
59
|
+
return error;
|
|
51
60
|
}
|
|
52
61
|
try {
|
|
53
62
|
if (wallet) {
|
|
@@ -55,7 +64,11 @@ function writeSelectedWallet(wallet) {
|
|
|
55
64
|
} else {
|
|
56
65
|
storage.removeItem(SELECTED_WALLET_STORAGE_KEY);
|
|
57
66
|
}
|
|
58
|
-
|
|
67
|
+
return null;
|
|
68
|
+
} catch (cause) {
|
|
69
|
+
return errors.createSolanaError("STORAGE_FAILURE", "Unable to persist the selected Solana wallet", {
|
|
70
|
+
cause
|
|
71
|
+
});
|
|
59
72
|
}
|
|
60
73
|
}
|
|
61
74
|
function stringifySelectedWallet(wallet) {
|
|
@@ -70,12 +83,17 @@ function stringifySelectedWallet(wallet) {
|
|
|
70
83
|
}
|
|
71
84
|
function getLocalStorage() {
|
|
72
85
|
if (typeof window === "undefined") {
|
|
73
|
-
return null;
|
|
86
|
+
return { storage: null, error: null };
|
|
74
87
|
}
|
|
75
88
|
try {
|
|
76
|
-
return window.localStorage;
|
|
77
|
-
} catch {
|
|
78
|
-
return
|
|
89
|
+
return { storage: window.localStorage, error: null };
|
|
90
|
+
} catch (cause) {
|
|
91
|
+
return {
|
|
92
|
+
storage: null,
|
|
93
|
+
error: errors.createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
|
|
94
|
+
cause
|
|
95
|
+
})
|
|
96
|
+
};
|
|
79
97
|
}
|
|
80
98
|
}
|
|
81
99
|
|
|
@@ -203,10 +221,12 @@ function createSolanaPlugin(options = {}) {
|
|
|
203
221
|
wsEndpoint: context.wsEndpoint
|
|
204
222
|
});
|
|
205
223
|
try {
|
|
206
|
-
const blockhash = await
|
|
224
|
+
const blockhash = await timeout.withTimeout(
|
|
207
225
|
context.connection.getLatestBlockhash(),
|
|
208
226
|
RPC_CHECK_TIMEOUT_MS,
|
|
209
|
-
|
|
227
|
+
() => new Error(
|
|
228
|
+
`RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
|
|
229
|
+
)
|
|
210
230
|
);
|
|
211
231
|
if (checkId !== rpcCheckId) {
|
|
212
232
|
return;
|
|
@@ -224,7 +244,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
224
244
|
return;
|
|
225
245
|
}
|
|
226
246
|
status.value = "error";
|
|
227
|
-
error.value =
|
|
247
|
+
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
228
248
|
console.error("[Vue Solana] Connection failed", cause);
|
|
229
249
|
}
|
|
230
250
|
}
|
|
@@ -240,7 +260,13 @@ function createSolanaPlugin(options = {}) {
|
|
|
240
260
|
}
|
|
241
261
|
} else if (!options.wallet) {
|
|
242
262
|
const persistedWallet = readSelectedWallet();
|
|
243
|
-
|
|
263
|
+
if (persistedWallet.error) {
|
|
264
|
+
error.value = persistedWallet.error;
|
|
265
|
+
console.error("[Vue Solana] Selected wallet restoration failed", persistedWallet.error);
|
|
266
|
+
}
|
|
267
|
+
restoredWallet = persistedWallet.wallet ? wallets.value.find(
|
|
268
|
+
(nextWallet) => isSameWallet(nextWallet, persistedWallet.wallet)
|
|
269
|
+
) ?? null : null;
|
|
244
270
|
if (restoredWallet) {
|
|
245
271
|
selectedWallet.value = restoredWallet;
|
|
246
272
|
wallet.value = walletRegistry.getAdaptedWallet(restoredWallet);
|
|
@@ -269,7 +295,11 @@ function createSolanaPlugin(options = {}) {
|
|
|
269
295
|
function selectWallet(nextWallet) {
|
|
270
296
|
selectedWallet.value = nextWallet;
|
|
271
297
|
wallet.value = nextWallet ? walletRegistry.getAdaptedWallet(nextWallet) : options.wallet ?? null;
|
|
272
|
-
writeSelectedWallet(nextWallet);
|
|
298
|
+
const storageError = writeSelectedWallet(nextWallet);
|
|
299
|
+
if (storageError) {
|
|
300
|
+
error.value = storageError;
|
|
301
|
+
console.error("[Vue Solana] Selected wallet persistence failed", storageError);
|
|
302
|
+
}
|
|
273
303
|
}
|
|
274
304
|
function autoConnectWallet(walletInfo) {
|
|
275
305
|
if (!options.autoConnect) {
|
|
@@ -301,7 +331,11 @@ function createSolanaPlugin(options = {}) {
|
|
|
301
331
|
setWallet(nextWallet) {
|
|
302
332
|
selectedWallet.value = null;
|
|
303
333
|
wallet.value = nextWallet;
|
|
304
|
-
writeSelectedWallet(null);
|
|
334
|
+
const storageError = writeSelectedWallet(null);
|
|
335
|
+
if (storageError) {
|
|
336
|
+
error.value = storageError;
|
|
337
|
+
console.error("[Vue Solana] Selected wallet persistence failed", storageError);
|
|
338
|
+
}
|
|
305
339
|
}
|
|
306
340
|
};
|
|
307
341
|
app.provide(useSolana.solanaInjectionKey, vueContext);
|
package/dist/index.d.cts
CHANGED
|
@@ -11,12 +11,13 @@ export { UseTransactionOptions, useTransaction } from './useTransaction.cjs';
|
|
|
11
11
|
export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.cjs';
|
|
12
12
|
export { useWallet } from './useWallet.cjs';
|
|
13
13
|
export { useWallets } from './useWallets.cjs';
|
|
14
|
-
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.
|
|
14
|
+
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DL3z5PxP.cjs';
|
|
15
15
|
import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
|
|
16
16
|
import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
|
|
17
17
|
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
18
18
|
import { App } from 'vue';
|
|
19
19
|
import '@vue-solana/core/address';
|
|
20
|
+
import '@vue-solana/core/errors';
|
|
20
21
|
import '@solana/web3-compat';
|
|
21
22
|
|
|
22
23
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
package/dist/index.d.mts
CHANGED
|
@@ -11,12 +11,13 @@ export { UseTransactionOptions, useTransaction } from './useTransaction.mjs';
|
|
|
11
11
|
export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.mjs';
|
|
12
12
|
export { useWallet } from './useWallet.mjs';
|
|
13
13
|
export { useWallets } from './useWallets.mjs';
|
|
14
|
-
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.
|
|
14
|
+
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DL3z5PxP.mjs';
|
|
15
15
|
import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
|
|
16
16
|
import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
|
|
17
17
|
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
18
18
|
import { App } from 'vue';
|
|
19
19
|
import '@vue-solana/core/address';
|
|
20
|
+
import '@vue-solana/core/errors';
|
|
20
21
|
import '@solana/web3-compat';
|
|
21
22
|
|
|
22
23
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
package/dist/index.d.ts
CHANGED
|
@@ -11,12 +11,13 @@ export { UseTransactionOptions, useTransaction } from './useTransaction.js';
|
|
|
11
11
|
export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.js';
|
|
12
12
|
export { useWallet } from './useWallet.js';
|
|
13
13
|
export { useWallets } from './useWallets.js';
|
|
14
|
-
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.
|
|
14
|
+
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DL3z5PxP.js';
|
|
15
15
|
import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
|
|
16
16
|
import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
|
|
17
17
|
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
18
18
|
import { App } from 'vue';
|
|
19
19
|
import '@vue-solana/core/address';
|
|
20
|
+
import '@vue-solana/core/errors';
|
|
20
21
|
import '@solana/web3-compat';
|
|
21
22
|
|
|
22
23
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
package/dist/index.mjs
CHANGED
|
@@ -1,53 +1,61 @@
|
|
|
1
|
-
export { u as useAccountInfo } from './shared/vue.
|
|
2
|
-
export { u as useBalance } from './shared/vue.
|
|
1
|
+
export { u as useAccountInfo } from './shared/vue.Cl3hXlXK.mjs';
|
|
2
|
+
export { u as useBalance } from './shared/vue.BDl2vVkp.mjs';
|
|
3
3
|
export { u as useConnection } from './shared/vue.DlEAL2G8.mjs';
|
|
4
|
-
export { u as useProgramAccounts } from './shared/vue.
|
|
4
|
+
export { u as useProgramAccounts } from './shared/vue.CzTu_DPr.mjs';
|
|
5
5
|
export { u as useRpc } from './shared/vue.BqDzSepb.mjs';
|
|
6
|
-
export { u as useSignMessage } from './shared/vue.
|
|
7
|
-
export { u as useSignAndSendTransaction } from './shared/vue.
|
|
8
|
-
export { u as useSignatureStatus } from './shared/vue.
|
|
6
|
+
export { u as useSignMessage } from './shared/vue.PTQ2iRAi.mjs';
|
|
7
|
+
export { u as useSignAndSendTransaction } from './shared/vue.BlfFUgC-.mjs';
|
|
8
|
+
export { u as useSignatureStatus } from './shared/vue.BzopW_4m.mjs';
|
|
9
9
|
import { s as solanaInjectionKey } from './shared/vue.1M_c5FWA.mjs';
|
|
10
10
|
export { t as tryUseSolana, u as useSolana } from './shared/vue.1M_c5FWA.mjs';
|
|
11
|
-
|
|
12
|
-
export { u as
|
|
13
|
-
export {
|
|
14
|
-
export { u as useWallet } from './shared/vue.CGVdFmYI.mjs';
|
|
11
|
+
export { u as useTransaction } from './shared/vue.C4d2JA8U.mjs';
|
|
12
|
+
export { g as getConfirmedTransactionStatus, u as useTransactionConfirmation } from './shared/vue.CxMrojxC.mjs';
|
|
13
|
+
export { u as useWallet } from './shared/vue.5sF8eKgx.mjs';
|
|
15
14
|
export { u as useWallets } from './shared/vue.h-uS8MXN.mjs';
|
|
15
|
+
import { createSolanaError, normalizeSolanaError } from '@vue-solana/core/errors';
|
|
16
16
|
import { createSolanaContext } from '@vue-solana/core/rpc';
|
|
17
|
+
import { withTimeout } from '@vue-solana/core/timeout';
|
|
17
18
|
import { getRegisteredSolanaWallets, getSolanaChain, adaptSolanaStandardWallet, subscribeSolanaWallets } from '@vue-solana/core/wallet-standard';
|
|
18
19
|
import { shallowRef, ref, triggerRef } from 'vue';
|
|
19
20
|
import { handleSolanaIosWalletCallback, getSolanaIosWallets, isSolanaIosWalletInfo, adaptSolanaIosWallet } from '@vue-solana/core/ios-wallet';
|
|
20
21
|
import '@vue-solana/core/address';
|
|
21
|
-
import '@solana/web3-compat';
|
|
22
22
|
import '@vue-solana/core/wallet';
|
|
23
23
|
import '@vue-solana/core/transaction';
|
|
24
24
|
import 'bs58';
|
|
25
25
|
|
|
26
26
|
const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
|
|
27
27
|
function readSelectedWallet() {
|
|
28
|
-
const storage = getLocalStorage();
|
|
29
|
-
if (!storage) {
|
|
30
|
-
return null;
|
|
28
|
+
const { storage, error } = getLocalStorage();
|
|
29
|
+
if (error || !storage) {
|
|
30
|
+
return { wallet: null, error };
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
33
|
const value = storage.getItem(SELECTED_WALLET_STORAGE_KEY);
|
|
34
34
|
if (!value) {
|
|
35
|
-
return null;
|
|
35
|
+
return { wallet: null, error: null };
|
|
36
36
|
}
|
|
37
37
|
const wallet = JSON.parse(value);
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
return {
|
|
39
|
+
wallet: typeof wallet.name === "string" ? {
|
|
40
|
+
name: wallet.name,
|
|
41
|
+
platform: wallet.platform,
|
|
42
|
+
source: wallet.source
|
|
43
|
+
} : null,
|
|
44
|
+
error: null
|
|
45
|
+
};
|
|
46
|
+
} catch (cause) {
|
|
47
|
+
return {
|
|
48
|
+
wallet: null,
|
|
49
|
+
error: createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
|
|
50
|
+
cause
|
|
51
|
+
})
|
|
52
|
+
};
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
function writeSelectedWallet(wallet) {
|
|
48
|
-
const storage = getLocalStorage();
|
|
49
|
-
if (!storage) {
|
|
50
|
-
return;
|
|
56
|
+
const { storage, error } = getLocalStorage();
|
|
57
|
+
if (error || !storage) {
|
|
58
|
+
return error;
|
|
51
59
|
}
|
|
52
60
|
try {
|
|
53
61
|
if (wallet) {
|
|
@@ -55,7 +63,11 @@ function writeSelectedWallet(wallet) {
|
|
|
55
63
|
} else {
|
|
56
64
|
storage.removeItem(SELECTED_WALLET_STORAGE_KEY);
|
|
57
65
|
}
|
|
58
|
-
|
|
66
|
+
return null;
|
|
67
|
+
} catch (cause) {
|
|
68
|
+
return createSolanaError("STORAGE_FAILURE", "Unable to persist the selected Solana wallet", {
|
|
69
|
+
cause
|
|
70
|
+
});
|
|
59
71
|
}
|
|
60
72
|
}
|
|
61
73
|
function stringifySelectedWallet(wallet) {
|
|
@@ -70,12 +82,17 @@ function stringifySelectedWallet(wallet) {
|
|
|
70
82
|
}
|
|
71
83
|
function getLocalStorage() {
|
|
72
84
|
if (typeof window === "undefined") {
|
|
73
|
-
return null;
|
|
85
|
+
return { storage: null, error: null };
|
|
74
86
|
}
|
|
75
87
|
try {
|
|
76
|
-
return window.localStorage;
|
|
77
|
-
} catch {
|
|
78
|
-
return
|
|
88
|
+
return { storage: window.localStorage, error: null };
|
|
89
|
+
} catch (cause) {
|
|
90
|
+
return {
|
|
91
|
+
storage: null,
|
|
92
|
+
error: createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
|
|
93
|
+
cause
|
|
94
|
+
})
|
|
95
|
+
};
|
|
79
96
|
}
|
|
80
97
|
}
|
|
81
98
|
|
|
@@ -206,7 +223,9 @@ function createSolanaPlugin(options = {}) {
|
|
|
206
223
|
const blockhash = await withTimeout(
|
|
207
224
|
context.connection.getLatestBlockhash(),
|
|
208
225
|
RPC_CHECK_TIMEOUT_MS,
|
|
209
|
-
|
|
226
|
+
() => new Error(
|
|
227
|
+
`RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
|
|
228
|
+
)
|
|
210
229
|
);
|
|
211
230
|
if (checkId !== rpcCheckId) {
|
|
212
231
|
return;
|
|
@@ -224,7 +243,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
224
243
|
return;
|
|
225
244
|
}
|
|
226
245
|
status.value = "error";
|
|
227
|
-
error.value = cause
|
|
246
|
+
error.value = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
228
247
|
console.error("[Vue Solana] Connection failed", cause);
|
|
229
248
|
}
|
|
230
249
|
}
|
|
@@ -240,7 +259,13 @@ function createSolanaPlugin(options = {}) {
|
|
|
240
259
|
}
|
|
241
260
|
} else if (!options.wallet) {
|
|
242
261
|
const persistedWallet = readSelectedWallet();
|
|
243
|
-
|
|
262
|
+
if (persistedWallet.error) {
|
|
263
|
+
error.value = persistedWallet.error;
|
|
264
|
+
console.error("[Vue Solana] Selected wallet restoration failed", persistedWallet.error);
|
|
265
|
+
}
|
|
266
|
+
restoredWallet = persistedWallet.wallet ? wallets.value.find(
|
|
267
|
+
(nextWallet) => isSameWallet(nextWallet, persistedWallet.wallet)
|
|
268
|
+
) ?? null : null;
|
|
244
269
|
if (restoredWallet) {
|
|
245
270
|
selectedWallet.value = restoredWallet;
|
|
246
271
|
wallet.value = walletRegistry.getAdaptedWallet(restoredWallet);
|
|
@@ -269,7 +294,11 @@ function createSolanaPlugin(options = {}) {
|
|
|
269
294
|
function selectWallet(nextWallet) {
|
|
270
295
|
selectedWallet.value = nextWallet;
|
|
271
296
|
wallet.value = nextWallet ? walletRegistry.getAdaptedWallet(nextWallet) : options.wallet ?? null;
|
|
272
|
-
writeSelectedWallet(nextWallet);
|
|
297
|
+
const storageError = writeSelectedWallet(nextWallet);
|
|
298
|
+
if (storageError) {
|
|
299
|
+
error.value = storageError;
|
|
300
|
+
console.error("[Vue Solana] Selected wallet persistence failed", storageError);
|
|
301
|
+
}
|
|
273
302
|
}
|
|
274
303
|
function autoConnectWallet(walletInfo) {
|
|
275
304
|
if (!options.autoConnect) {
|
|
@@ -301,7 +330,11 @@ function createSolanaPlugin(options = {}) {
|
|
|
301
330
|
setWallet(nextWallet) {
|
|
302
331
|
selectedWallet.value = null;
|
|
303
332
|
wallet.value = nextWallet;
|
|
304
|
-
writeSelectedWallet(null);
|
|
333
|
+
const storageError = writeSelectedWallet(null);
|
|
334
|
+
if (storageError) {
|
|
335
|
+
error.value = storageError;
|
|
336
|
+
console.error("[Vue Solana] Selected wallet persistence failed", storageError);
|
|
337
|
+
}
|
|
305
338
|
}
|
|
306
339
|
};
|
|
307
340
|
app.provide(solanaInjectionKey, vueContext);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { createNoWalletSelectedError } from '@vue-solana/core/wallet';
|
|
1
3
|
import { ref, computed, triggerRef } from 'vue';
|
|
2
4
|
import { u as useSolana } from './vue.1M_c5FWA.mjs';
|
|
3
5
|
|
|
@@ -9,7 +11,7 @@ function useWallet() {
|
|
|
9
11
|
async function connect() {
|
|
10
12
|
const activeWallet = wallet.value;
|
|
11
13
|
if (!activeWallet) {
|
|
12
|
-
throw
|
|
14
|
+
throw createNoWalletSelectedError();
|
|
13
15
|
}
|
|
14
16
|
connecting.value = true;
|
|
15
17
|
try {
|
|
@@ -21,9 +23,10 @@ function useWallet() {
|
|
|
21
23
|
publicKey: activeWallet.publicKey?.toBase58() ?? null
|
|
22
24
|
});
|
|
23
25
|
} catch (error) {
|
|
26
|
+
const normalizedError = normalizeSolanaError(error, "RPC_FAILURE");
|
|
24
27
|
triggerRef(wallet);
|
|
25
|
-
console.error("[Vue Solana] Wallet connection failed",
|
|
26
|
-
throw
|
|
28
|
+
console.error("[Vue Solana] Wallet connection failed", normalizedError);
|
|
29
|
+
throw normalizedError;
|
|
27
30
|
} finally {
|
|
28
31
|
connecting.value = false;
|
|
29
32
|
}
|
|
@@ -40,9 +43,10 @@ function useWallet() {
|
|
|
40
43
|
triggerRef(wallet);
|
|
41
44
|
console.info("[Vue Solana] Wallet disconnected", { publicKey });
|
|
42
45
|
} catch (error) {
|
|
46
|
+
const normalizedError = normalizeSolanaError(error, "RPC_FAILURE");
|
|
43
47
|
triggerRef(wallet);
|
|
44
|
-
console.error("[Vue Solana] Wallet disconnection failed",
|
|
45
|
-
throw
|
|
48
|
+
console.error("[Vue Solana] Wallet disconnection failed", normalizedError);
|
|
49
|
+
throw normalizedError;
|
|
46
50
|
} finally {
|
|
47
51
|
disconnecting.value = false;
|
|
48
52
|
}
|
|
@@ -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');
|
|
@@ -38,11 +39,12 @@ function useAccountInfo(address$1, options = {}) {
|
|
|
38
39
|
}
|
|
39
40
|
return nextAccountInfo;
|
|
40
41
|
} catch (cause) {
|
|
42
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
41
43
|
if (requestId === refreshId) {
|
|
42
44
|
accountInfo.value = null;
|
|
43
|
-
error.value =
|
|
45
|
+
error.value = normalizedError;
|
|
44
46
|
}
|
|
45
|
-
throw
|
|
47
|
+
throw normalizedError;
|
|
46
48
|
} finally {
|
|
47
49
|
if (requestId === refreshId) {
|
|
48
50
|
loading.value = false;
|
|
@@ -63,7 +65,7 @@ function useAccountInfo(address$1, options = {}) {
|
|
|
63
65
|
try {
|
|
64
66
|
await connection.removeAccountChangeListener(currentSubscriptionId);
|
|
65
67
|
} catch (cause) {
|
|
66
|
-
error.value = cause;
|
|
68
|
+
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
async function startWatching() {
|
|
@@ -98,7 +100,7 @@ function useAccountInfo(address$1, options = {}) {
|
|
|
98
100
|
subscriptionId = nextSubscriptionId;
|
|
99
101
|
} catch (cause) {
|
|
100
102
|
if (requestId === watchId) {
|
|
101
|
-
error.value = cause;
|
|
103
|
+
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
106
|
}
|
|
@@ -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() {
|
|
@@ -24,15 +27,17 @@ function useSignAndSendTransaction() {
|
|
|
24
27
|
confirmation.value = null;
|
|
25
28
|
const activeWallet = wallet.value;
|
|
26
29
|
if (!activeWallet) {
|
|
27
|
-
const
|
|
28
|
-
error.value =
|
|
30
|
+
const normalizedError = createNoWalletSelectedError();
|
|
31
|
+
error.value = normalizedError;
|
|
29
32
|
status.value = "error";
|
|
30
33
|
loading.value = false;
|
|
31
|
-
throw
|
|
34
|
+
throw normalizedError;
|
|
32
35
|
}
|
|
33
36
|
try {
|
|
34
|
-
const nextSignature = await
|
|
35
|
-
signAndSendTransaction(connection, activeWallet, 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."
|
|
36
41
|
);
|
|
37
42
|
if (currentExecutionId === executionId) {
|
|
38
43
|
signature.value = nextSignature;
|
|
@@ -52,11 +57,12 @@ function useSignAndSendTransaction() {
|
|
|
52
57
|
}
|
|
53
58
|
return nextSignature;
|
|
54
59
|
} catch (cause) {
|
|
60
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
55
61
|
if (currentExecutionId === executionId) {
|
|
56
|
-
error.value =
|
|
62
|
+
error.value = normalizedError;
|
|
57
63
|
status.value = "error";
|
|
58
64
|
}
|
|
59
|
-
throw
|
|
65
|
+
throw normalizedError;
|
|
60
66
|
} finally {
|
|
61
67
|
if (currentExecutionId === executionId) {
|
|
62
68
|
loading.value = false;
|
|
@@ -72,24 +78,5 @@ function useSignAndSendTransaction() {
|
|
|
72
78
|
execute
|
|
73
79
|
};
|
|
74
80
|
}
|
|
75
|
-
async function withWalletTransactionTimeout(promise) {
|
|
76
|
-
let timeoutId;
|
|
77
|
-
try {
|
|
78
|
-
const timeout = new Promise((_, reject) => {
|
|
79
|
-
timeoutId = setTimeout(() => {
|
|
80
|
-
reject(
|
|
81
|
-
new Error(
|
|
82
|
-
"Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
83
|
-
)
|
|
84
|
-
);
|
|
85
|
-
}, SIGN_AND_SEND_TIMEOUT_MS);
|
|
86
|
-
});
|
|
87
|
-
return await Promise.race([promise, timeout]);
|
|
88
|
-
} finally {
|
|
89
|
-
if (timeoutId) {
|
|
90
|
-
clearTimeout(timeoutId);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
81
|
|
|
95
82
|
export { useSignAndSendTransaction as u };
|