@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.
Files changed (75) hide show
  1. package/dist/index.cjs +69 -35
  2. package/dist/index.d.cts +2 -1
  3. package/dist/index.d.mts +2 -1
  4. package/dist/index.d.ts +2 -1
  5. package/dist/index.mjs +68 -35
  6. package/dist/shared/{vue.CGVdFmYI.mjs → vue.5sF8eKgx.mjs} +9 -5
  7. package/dist/shared/{vue.BPnK_lsh.cjs → vue.BBoDTIfF.cjs} +6 -4
  8. package/dist/shared/{vue.DQhHHVu6.mjs → vue.BDl2vVkp.mjs} +10 -4
  9. package/dist/shared/{vue.DHVYJk8P.cjs → vue.BeA8WQ2g.cjs} +4 -2
  10. package/dist/shared/{vue.CM6qb_s8.mjs → vue.BlfFUgC-.mjs} +15 -28
  11. package/dist/shared/{vue.DWiQYhb8.cjs → vue.BnSjOzvb.cjs} +17 -30
  12. package/dist/shared/{vue.JC5FdU2O.mjs → vue.BzopW_4m.mjs} +8 -6
  13. package/dist/shared/{vue.gLqkzJY4.mjs → vue.C4d2JA8U.mjs} +7 -23
  14. package/dist/shared/{vue.DQi38JeF.cjs → vue.CE5i8KZZ.cjs} +6 -23
  15. package/dist/shared/{vue.7TzeDJZX.mjs → vue.Cl3hXlXK.mjs} +6 -4
  16. package/dist/shared/{vue.jOsz34kz.mjs → vue.CxMrojxC.mjs} +4 -2
  17. package/dist/shared/{vue.CUTLu1Gf.mjs → vue.CzTu_DPr.mjs} +4 -2
  18. package/dist/shared/{vue.dmuispJ3.cjs → vue.D1JtJ2lD.cjs} +4 -2
  19. package/dist/shared/{vue.DGhodYJh.d.mts → vue.DL3z5PxP.d.cts} +2 -1
  20. package/dist/shared/{vue.DGhodYJh.d.ts → vue.DL3z5PxP.d.mts} +2 -1
  21. package/dist/shared/{vue.DGhodYJh.d.cts → vue.DL3z5PxP.d.ts} +2 -1
  22. package/dist/shared/{vue.DUufwq8y.cjs → vue.DRlaqQCL.cjs} +8 -6
  23. package/dist/shared/{vue.BwipRa1w.cjs → vue.DfeKj9vL.cjs} +28 -24
  24. package/dist/shared/{vue.D1knFN3X.cjs → vue.DuI_Jm5P.cjs} +6 -8
  25. package/dist/shared/{vue.D_AM1Nl8.cjs → vue.NFoc_-Kt.cjs} +13 -7
  26. package/dist/shared/{vue.BeuIPLGM.mjs → vue.PTQ2iRAi.mjs} +7 -9
  27. package/dist/useAccountInfo.cjs +2 -1
  28. package/dist/useAccountInfo.d.cts +2 -1
  29. package/dist/useAccountInfo.d.mts +2 -1
  30. package/dist/useAccountInfo.d.ts +2 -1
  31. package/dist/useAccountInfo.mjs +2 -1
  32. package/dist/useBalance.cjs +3 -2
  33. package/dist/useBalance.d.cts +2 -1
  34. package/dist/useBalance.d.mts +2 -1
  35. package/dist/useBalance.d.ts +2 -1
  36. package/dist/useBalance.mjs +3 -2
  37. package/dist/useProgramAccounts.cjs +2 -1
  38. package/dist/useProgramAccounts.d.cts +2 -1
  39. package/dist/useProgramAccounts.d.mts +2 -1
  40. package/dist/useProgramAccounts.d.ts +2 -1
  41. package/dist/useProgramAccounts.mjs +2 -1
  42. package/dist/useRpc.d.cts +3 -2
  43. package/dist/useRpc.d.mts +3 -2
  44. package/dist/useRpc.d.ts +3 -2
  45. package/dist/useSignAndSendTransaction.cjs +6 -3
  46. package/dist/useSignAndSendTransaction.d.cts +2 -1
  47. package/dist/useSignAndSendTransaction.d.mts +2 -1
  48. package/dist/useSignAndSendTransaction.d.ts +2 -1
  49. package/dist/useSignAndSendTransaction.mjs +6 -3
  50. package/dist/useSignMessage.cjs +3 -2
  51. package/dist/useSignMessage.d.cts +2 -1
  52. package/dist/useSignMessage.d.mts +2 -1
  53. package/dist/useSignMessage.d.ts +2 -1
  54. package/dist/useSignMessage.mjs +3 -2
  55. package/dist/useSignatureStatus.cjs +2 -1
  56. package/dist/useSignatureStatus.d.cts +2 -1
  57. package/dist/useSignatureStatus.d.mts +2 -1
  58. package/dist/useSignatureStatus.d.ts +2 -1
  59. package/dist/useSignatureStatus.mjs +2 -1
  60. package/dist/useSolana.d.cts +2 -1
  61. package/dist/useSolana.d.mts +2 -1
  62. package/dist/useSolana.d.ts +2 -1
  63. package/dist/useTransaction.cjs +3 -1
  64. package/dist/useTransaction.d.cts +2 -1
  65. package/dist/useTransaction.d.mts +2 -1
  66. package/dist/useTransaction.d.ts +2 -1
  67. package/dist/useTransaction.mjs +3 -1
  68. package/dist/useTransactionConfirmation.cjs +2 -1
  69. package/dist/useTransactionConfirmation.d.cts +2 -1
  70. package/dist/useTransactionConfirmation.d.mts +2 -1
  71. package/dist/useTransactionConfirmation.d.ts +2 -1
  72. package/dist/useTransactionConfirmation.mjs +2 -1
  73. package/dist/useWallet.cjs +3 -1
  74. package/dist/useWallet.mjs +3 -1
  75. package/package.json +2 -2
@@ -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.BwipRa1w.cjs');
7
- const useTransactionConfirmation = require('./vue.DHVYJk8P.cjs');
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,17 +27,19 @@ function useSignAndSendTransaction() {
24
27
  loading.value = true;
25
28
  error.value = null;
26
29
  confirmation.value = null;
27
- const activeWallet = wallet.value;
30
+ const activeWallet = wallet$1.value;
28
31
  if (!activeWallet) {
29
- const cause = new Error("No Solana wallet is configured");
30
- error.value = cause;
32
+ const normalizedError = wallet.createNoWalletSelectedError();
33
+ error.value = normalizedError;
31
34
  status.value = "error";
32
35
  loading.value = false;
33
- throw cause;
36
+ throw normalizedError;
34
37
  }
35
38
  try {
36
- const nextSignature = await withWalletTransactionTimeout(
37
- transaction.signAndSendTransaction(connection, activeWallet, 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."
38
43
  );
39
44
  if (currentExecutionId === executionId) {
40
45
  signature.value = nextSignature;
@@ -54,11 +59,12 @@ function useSignAndSendTransaction() {
54
59
  }
55
60
  return nextSignature;
56
61
  } catch (cause) {
62
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
57
63
  if (currentExecutionId === executionId) {
58
- error.value = cause;
64
+ error.value = normalizedError;
59
65
  status.value = "error";
60
66
  }
61
- throw cause;
67
+ throw normalizedError;
62
68
  } finally {
63
69
  if (currentExecutionId === executionId) {
64
70
  loading.value = false;
@@ -74,24 +80,5 @@ function useSignAndSendTransaction() {
74
80
  execute
75
81
  };
76
82
  }
77
- async function withWalletTransactionTimeout(promise) {
78
- let timeoutId;
79
- try {
80
- const timeout = new Promise((_, reject) => {
81
- timeoutId = setTimeout(() => {
82
- reject(
83
- new Error(
84
- "Wallet transaction did not return a result. Check your wallet or explorer for the final status."
85
- )
86
- );
87
- }, SIGN_AND_SEND_TIMEOUT_MS);
88
- });
89
- return await Promise.race([promise, timeout]);
90
- } finally {
91
- if (timeoutId) {
92
- clearTimeout(timeoutId);
93
- }
94
- }
95
- }
96
83
 
97
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 = cause;
44
+ error.value = normalizedError;
43
45
  }
44
- throw cause;
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 = new RangeError("pollIntervalMs must be greater than 0");
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 withTimeout(
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 = cause;
27
+ error.value = normalizedError;
44
28
  }
45
- throw cause;
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, withTimeout as w };
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 withTimeout(
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 = cause;
29
+ error.value = normalizedError;
46
30
  }
47
- throw cause;
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 = cause;
43
+ error.value = normalizedError;
42
44
  }
43
- throw cause;
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 = cause;
42
+ error.value = normalizedError;
41
43
  status.value = "error";
42
44
  }
43
- throw cause;
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 = cause;
44
+ error.value = normalizedError;
43
45
  }
44
- throw cause;
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 = cause;
46
+ error.value = normalizedError;
45
47
  }
46
- throw cause;
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<string | null>;
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<string | null>;
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<string | null>;
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 = cause;
50
+ error.value = normalizedError;
49
51
  }
50
- throw cause;
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 = new RangeError("pollIntervalMs must be greater than 0");
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
  }
@@ -1,37 +1,40 @@
1
1
  'use strict';
2
2
 
3
+ const errors = require('@vue-solana/core/errors');
4
+ const wallet = require('@vue-solana/core/wallet');
3
5
  const vue = require('vue');
4
6
  const useSolana = require('./vue.C4tLiG3R.cjs');
5
7
 
6
8
  function useWallet() {
7
9
  const solana = useSolana.useSolana();
8
- const wallet = solana.wallet;
10
+ const wallet$1 = solana.wallet;
9
11
  const connecting = vue.ref(false);
10
12
  const disconnecting = vue.ref(false);
11
13
  async function connect() {
12
- const activeWallet = wallet.value;
14
+ const activeWallet = wallet$1.value;
13
15
  if (!activeWallet) {
14
- throw new Error("No Solana wallet is configured");
16
+ throw wallet.createNoWalletSelectedError();
15
17
  }
16
18
  connecting.value = true;
17
19
  try {
18
20
  const connection = activeWallet.connect();
19
- vue.triggerRef(wallet);
21
+ vue.triggerRef(wallet$1);
20
22
  await connection;
21
- vue.triggerRef(wallet);
23
+ vue.triggerRef(wallet$1);
22
24
  console.info("[Vue Solana] Wallet connected", {
23
25
  publicKey: activeWallet.publicKey?.toBase58() ?? null
24
26
  });
25
27
  } catch (error) {
26
- vue.triggerRef(wallet);
27
- console.error("[Vue Solana] Wallet connection failed", error);
28
- throw error;
28
+ const normalizedError = errors.normalizeSolanaError(error, "RPC_FAILURE");
29
+ vue.triggerRef(wallet$1);
30
+ console.error("[Vue Solana] Wallet connection failed", normalizedError);
31
+ throw normalizedError;
29
32
  } finally {
30
33
  connecting.value = false;
31
34
  }
32
35
  }
33
36
  async function disconnect() {
34
- const activeWallet = wallet.value;
37
+ const activeWallet = wallet$1.value;
35
38
  if (!activeWallet) {
36
39
  return;
37
40
  }
@@ -39,26 +42,27 @@ function useWallet() {
39
42
  disconnecting.value = true;
40
43
  try {
41
44
  await activeWallet.disconnect();
42
- vue.triggerRef(wallet);
45
+ vue.triggerRef(wallet$1);
43
46
  console.info("[Vue Solana] Wallet disconnected", { publicKey });
44
47
  } catch (error) {
45
- vue.triggerRef(wallet);
46
- console.error("[Vue Solana] Wallet disconnection failed", error);
47
- throw error;
48
+ const normalizedError = errors.normalizeSolanaError(error, "RPC_FAILURE");
49
+ vue.triggerRef(wallet$1);
50
+ console.error("[Vue Solana] Wallet disconnection failed", normalizedError);
51
+ throw normalizedError;
48
52
  } finally {
49
53
  disconnecting.value = false;
50
54
  }
51
55
  }
52
- const isConnecting = vue.computed(() => Boolean(connecting.value || wallet.value?.connecting));
56
+ const isConnecting = vue.computed(() => Boolean(connecting.value || wallet$1.value?.connecting));
53
57
  const isDisconnecting = vue.computed(
54
- () => Boolean(disconnecting.value || wallet.value?.disconnecting)
58
+ () => Boolean(disconnecting.value || wallet$1.value?.disconnecting)
55
59
  );
56
- const canConnect = vue.computed(() => Boolean(wallet.value?.connect));
57
- const canDisconnect = vue.computed(() => Boolean(wallet.value?.disconnect));
58
- const canSignMessage = vue.computed(() => Boolean(wallet.value?.signMessage));
59
- const canSignTransaction = vue.computed(() => Boolean(wallet.value?.signTransaction));
60
- const canSignAllTransactions = vue.computed(() => Boolean(wallet.value?.signAllTransactions));
61
- const canSignAndSendTransaction = vue.computed(() => Boolean(wallet.value?.signAndSendTransaction));
60
+ const canConnect = vue.computed(() => Boolean(wallet$1.value?.connect));
61
+ const canDisconnect = vue.computed(() => Boolean(wallet$1.value?.disconnect));
62
+ const canSignMessage = vue.computed(() => Boolean(wallet$1.value?.signMessage));
63
+ const canSignTransaction = vue.computed(() => Boolean(wallet$1.value?.signTransaction));
64
+ const canSignAllTransactions = vue.computed(() => Boolean(wallet$1.value?.signAllTransactions));
65
+ const canSignAndSendTransaction = vue.computed(() => Boolean(wallet$1.value?.signAndSendTransaction));
62
66
  const capabilities = vue.computed(() => ({
63
67
  connect: canConnect.value,
64
68
  disconnect: canDisconnect.value,
@@ -68,9 +72,9 @@ function useWallet() {
68
72
  signAndSendTransaction: canSignAndSendTransaction.value
69
73
  }));
70
74
  return {
71
- wallet,
72
- publicKey: vue.computed(() => wallet.value?.publicKey ?? null),
73
- connected: vue.computed(() => Boolean(wallet.value?.connected && wallet.value.publicKey)),
75
+ wallet: wallet$1,
76
+ publicKey: vue.computed(() => wallet$1.value?.publicKey ?? null),
77
+ connected: vue.computed(() => Boolean(wallet$1.value?.connected && wallet$1.value.publicKey)),
74
78
  connecting: isConnecting,
75
79
  disconnecting: isDisconnecting,
76
80
  loading: vue.computed(() => isConnecting.value || isDisconnecting.value),
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ const errors = require('@vue-solana/core/errors');
3
4
  const wallet = require('@vue-solana/core/wallet');
4
5
  const vue = require('vue');
5
- const useWallet = require('./vue.BwipRa1w.cjs');
6
+ const useWallet = require('./vue.DfeKj9vL.cjs');
6
7
 
7
8
  function useSignMessage() {
8
9
  const { wallet: wallet$1 } = useWallet.useWallet();
@@ -21,11 +22,11 @@ function useSignMessage() {
21
22
  signature.value = null;
22
23
  const activeWallet = wallet$1.value;
23
24
  if (!activeWallet) {
24
- const cause = new Error("No Solana wallet is configured");
25
- error.value = cause;
25
+ const normalizedError = wallet.createNoWalletSelectedError();
26
+ error.value = normalizedError;
26
27
  status.value = "error";
27
28
  loading.value = false;
28
- throw cause;
29
+ throw normalizedError;
29
30
  }
30
31
  try {
31
32
  wallet.assertWalletCanSignMessage(activeWallet);
@@ -37,7 +38,7 @@ function useSignMessage() {
37
38
  }
38
39
  return result;
39
40
  } catch (cause) {
40
- const normalizedError = normalizeError(cause);
41
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
41
42
  if (currentExecutionId === executionId) {
42
43
  error.value = normalizedError;
43
44
  status.value = "error";
@@ -58,8 +59,5 @@ function useSignMessage() {
58
59
  execute
59
60
  };
60
61
  }
61
- function normalizeError(cause) {
62
- return cause instanceof Error ? cause : new Error(String(cause));
63
- }
64
62
 
65
63
  exports.useSignMessage = useSignMessage;
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
- const web3Compat = require('@solana/web3-compat');
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');
7
8
 
8
- function useBalance(address, commitment) {
9
+ function useBalance(address$1, commitment) {
9
10
  const solana = useSolana.tryUseSolana();
10
11
  const connection = solana?.connection ?? useConnection.useConnection();
11
12
  const balance = vue.shallowRef(null);
@@ -14,7 +15,7 @@ function useBalance(address, commitment) {
14
15
  let refreshId = 0;
15
16
  async function refresh() {
16
17
  const requestId = ++refreshId;
17
- const value = vue.toValue(address);
18
+ const value = vue.toValue(address$1);
18
19
  if (!value || !solana) {
19
20
  balance.value = null;
20
21
  loading.value = false;
@@ -24,17 +25,22 @@ function useBalance(address, commitment) {
24
25
  loading.value = true;
25
26
  error.value = null;
26
27
  try {
27
- const publicKey = typeof value === "string" ? new web3Compat.PublicKey(value) : value;
28
+ const publicKey = address.parsePublicKey(value);
29
+ if (!publicKey) {
30
+ balance.value = null;
31
+ return null;
32
+ }
28
33
  const nextBalance = await connection.getBalance(publicKey, commitment);
29
34
  if (requestId === refreshId) {
30
35
  balance.value = nextBalance;
31
36
  }
32
37
  return nextBalance;
33
38
  } catch (cause) {
39
+ const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
34
40
  if (requestId === refreshId) {
35
- error.value = cause;
41
+ error.value = normalizedError;
36
42
  }
37
- throw cause;
43
+ throw normalizedError;
38
44
  } finally {
39
45
  if (requestId === refreshId) {
40
46
  loading.value = false;
@@ -45,7 +51,7 @@ function useBalance(address, commitment) {
45
51
  void refresh().catch(() => void 0);
46
52
  });
47
53
  vue.watch(
48
- () => vue.toValue(address),
54
+ () => vue.toValue(address$1),
49
55
  () => {
50
56
  void refresh().catch(() => void 0);
51
57
  }