@vue-solana/vue 0.7.0 → 0.8.1

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 (91) hide show
  1. package/dist/index.cjs +74 -39
  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 +74 -40
  6. package/dist/shared/{vue.CGVdFmYI.mjs → vue.B7w1CC4R.mjs} +10 -6
  7. package/dist/shared/{vue.CM6qb_s8.mjs → vue.BBNHeOeb.mjs} +16 -29
  8. package/dist/shared/{vue.CUTLu1Gf.mjs → vue.BTN0h5Il.mjs} +6 -4
  9. package/dist/shared/{vue.CwhEmATP.cjs → vue.Bii4W61L.cjs} +1 -1
  10. package/dist/shared/{vue.dmuispJ3.cjs → vue.BleajB0B.cjs} +6 -4
  11. package/dist/shared/{vue.gLqkzJY4.mjs → vue.C4d2JA8U.mjs} +7 -23
  12. package/dist/shared/{vue.COyyrsQU.cjs → vue.C5C3l0RQ.cjs} +1 -1
  13. package/dist/shared/{vue.DQi38JeF.cjs → vue.CE5i8KZZ.cjs} +6 -23
  14. package/dist/shared/{vue.BPnK_lsh.cjs → vue.CKXhlRu-.cjs} +8 -6
  15. package/dist/shared/{vue.DlEAL2G8.mjs → vue.CKx4lRew.mjs} +1 -1
  16. package/dist/shared/{vue.DWiQYhb8.cjs → vue.CMJANJ4a.cjs} +18 -31
  17. package/dist/shared/{vue.DUufwq8y.cjs → vue.CXNFQf3l.cjs} +10 -8
  18. package/dist/shared/{vue.DHVYJk8P.cjs → vue.CZohWxBN.cjs} +5 -3
  19. package/dist/shared/{vue.BqDzSepb.mjs → vue.ChnRkpDR.mjs} +1 -1
  20. package/dist/shared/{vue.h-uS8MXN.mjs → vue.Cvg6TEXE.mjs} +1 -1
  21. package/dist/shared/{vue.P9tgeC5S.cjs → vue.D5Kmwcx3.cjs} +1 -1
  22. package/dist/shared/{vue.D_AM1Nl8.cjs → vue.D6U1RFZ0.cjs} +15 -9
  23. package/dist/shared/{vue.1M_c5FWA.mjs → vue.DCDTsSjf.mjs} +3 -1
  24. package/dist/shared/{vue.DGhodYJh.d.mts → vue.DL3z5PxP.d.cts} +2 -1
  25. package/dist/shared/{vue.DGhodYJh.d.ts → vue.DL3z5PxP.d.mts} +2 -1
  26. package/dist/shared/{vue.DGhodYJh.d.cts → vue.DL3z5PxP.d.ts} +2 -1
  27. package/dist/shared/{vue.DQhHHVu6.mjs → vue.DOpWV4b3.mjs} +12 -6
  28. package/dist/shared/{vue.JC5FdU2O.mjs → vue.DZWyk9E_.mjs} +10 -8
  29. package/dist/shared/{vue.jOsz34kz.mjs → vue.DaoqgzJC.mjs} +5 -3
  30. package/dist/shared/{vue.7TzeDJZX.mjs → vue.DgPfVZnU.mjs} +8 -6
  31. package/dist/shared/{vue.D1knFN3X.cjs → vue.Dp894nYb.cjs} +6 -8
  32. package/dist/shared/{vue.C4tLiG3R.cjs → vue.eNXmiI3a.cjs} +3 -1
  33. package/dist/shared/{vue.BwipRa1w.cjs → vue.o-mWY2Yg.cjs} +29 -25
  34. package/dist/shared/{vue.BeuIPLGM.mjs → vue.vn--SX8d.mjs} +7 -9
  35. package/dist/useAccountInfo.cjs +5 -4
  36. package/dist/useAccountInfo.d.cts +2 -1
  37. package/dist/useAccountInfo.d.mts +2 -1
  38. package/dist/useAccountInfo.d.ts +2 -1
  39. package/dist/useAccountInfo.mjs +5 -4
  40. package/dist/useBalance.cjs +6 -5
  41. package/dist/useBalance.d.cts +2 -1
  42. package/dist/useBalance.d.mts +2 -1
  43. package/dist/useBalance.d.ts +2 -1
  44. package/dist/useBalance.mjs +6 -5
  45. package/dist/useConnection.cjs +3 -3
  46. package/dist/useConnection.mjs +3 -3
  47. package/dist/useProgramAccounts.cjs +5 -4
  48. package/dist/useProgramAccounts.d.cts +2 -1
  49. package/dist/useProgramAccounts.d.mts +2 -1
  50. package/dist/useProgramAccounts.d.ts +2 -1
  51. package/dist/useProgramAccounts.mjs +5 -4
  52. package/dist/useRpc.cjs +2 -2
  53. package/dist/useRpc.d.cts +3 -2
  54. package/dist/useRpc.d.mts +3 -2
  55. package/dist/useRpc.d.ts +3 -2
  56. package/dist/useRpc.mjs +2 -2
  57. package/dist/useSignAndSendTransaction.cjs +9 -6
  58. package/dist/useSignAndSendTransaction.d.cts +2 -1
  59. package/dist/useSignAndSendTransaction.d.mts +2 -1
  60. package/dist/useSignAndSendTransaction.d.ts +2 -1
  61. package/dist/useSignAndSendTransaction.mjs +9 -6
  62. package/dist/useSignMessage.cjs +4 -3
  63. package/dist/useSignMessage.d.cts +2 -1
  64. package/dist/useSignMessage.d.mts +2 -1
  65. package/dist/useSignMessage.d.ts +2 -1
  66. package/dist/useSignMessage.mjs +4 -3
  67. package/dist/useSignatureStatus.cjs +5 -4
  68. package/dist/useSignatureStatus.d.cts +2 -1
  69. package/dist/useSignatureStatus.d.mts +2 -1
  70. package/dist/useSignatureStatus.d.ts +2 -1
  71. package/dist/useSignatureStatus.mjs +5 -4
  72. package/dist/useSolana.cjs +1 -1
  73. package/dist/useSolana.d.cts +2 -1
  74. package/dist/useSolana.d.mts +2 -1
  75. package/dist/useSolana.d.ts +2 -1
  76. package/dist/useSolana.mjs +1 -1
  77. package/dist/useTransaction.cjs +3 -1
  78. package/dist/useTransaction.d.cts +2 -1
  79. package/dist/useTransaction.d.mts +2 -1
  80. package/dist/useTransaction.d.ts +2 -1
  81. package/dist/useTransaction.mjs +3 -1
  82. package/dist/useTransactionConfirmation.cjs +5 -4
  83. package/dist/useTransactionConfirmation.d.cts +2 -1
  84. package/dist/useTransactionConfirmation.d.mts +2 -1
  85. package/dist/useTransactionConfirmation.d.ts +2 -1
  86. package/dist/useTransactionConfirmation.mjs +5 -4
  87. package/dist/useWallet.cjs +4 -2
  88. package/dist/useWallet.mjs +4 -2
  89. package/dist/useWallets.cjs +2 -2
  90. package/dist/useWallets.mjs +2 -2
  91. package/package.json +2 -2
@@ -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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const vue = require('vue');
4
- const useSolana = require('./vue.C4tLiG3R.cjs');
4
+ const useSolana = require('./vue.eNXmiI3a.cjs');
5
5
 
6
6
  function useRpc() {
7
7
  const solana = useSolana.useSolana();
@@ -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,9 +1,10 @@
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
- const useConnection = require('./vue.CwhEmATP.cjs');
6
- const useSolana = require('./vue.C4tLiG3R.cjs');
6
+ const useConnection = require('./vue.Bii4W61L.cjs');
7
+ const useSolana = require('./vue.eNXmiI3a.cjs');
7
8
 
8
9
  function useAccountInfo(address$1, options = {}) {
9
10
  const solana = useSolana.tryUseSolana();
@@ -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 = cause;
45
+ error.value = normalizedError;
44
46
  }
45
- throw cause;
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,4 @@
1
- import { u as useRpc } from './vue.BqDzSepb.mjs';
1
+ import { u as useRpc } from './vue.ChnRkpDR.mjs';
2
2
 
3
3
  function useConnection() {
4
4
  return useRpc().connection;
@@ -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
- const useConnection = require('./vue.CwhEmATP.cjs');
6
- const useWallet = require('./vue.BwipRa1w.cjs');
7
- const useTransactionConfirmation = require('./vue.DHVYJk8P.cjs');
8
+ const useConnection = require('./vue.Bii4W61L.cjs');
9
+ const useWallet = require('./vue.o-mWY2Yg.cjs');
10
+ const useTransactionConfirmation = require('./vue.CZohWxBN.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,9 +1,10 @@
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
- const useConnection = require('./vue.CwhEmATP.cjs');
6
- const useSolana = require('./vue.C4tLiG3R.cjs');
6
+ const useConnection = require('./vue.Bii4W61L.cjs');
7
+ const useSolana = require('./vue.eNXmiI3a.cjs');
7
8
 
8
9
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
10
 
@@ -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,8 +1,9 @@
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
- const useConnection = require('./vue.CwhEmATP.cjs');
6
+ const useConnection = require('./vue.Bii4W61L.cjs');
6
7
 
7
8
  function getConfirmedTransactionStatus(confirmation) {
8
9
  if (confirmation.commitment === "finalized") {
@@ -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 = cause;
44
+ error.value = normalizedError;
43
45
  status.value = "error";
44
46
  }
45
- throw cause;
47
+ throw normalizedError;
46
48
  } finally {
47
49
  if (currentExecutionId === executionId) {
48
50
  loading.value = false;
@@ -1,5 +1,5 @@
1
1
  import { computed } from 'vue';
2
- import { u as useSolana } from './vue.1M_c5FWA.mjs';
2
+ import { u as useSolana } from './vue.DCDTsSjf.mjs';
3
3
 
4
4
  function useRpc() {
5
5
  const solana = useSolana();
@@ -1,4 +1,4 @@
1
- import { u as useSolana } from './vue.1M_c5FWA.mjs';
1
+ import { u as useSolana } from './vue.DCDTsSjf.mjs';
2
2
 
3
3
  function useWallets() {
4
4
  const solana = useSolana();
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const useSolana = require('./vue.C4tLiG3R.cjs');
3
+ const useSolana = require('./vue.eNXmiI3a.cjs');
4
4
 
5
5
  function useWallets() {
6
6
  const solana = useSolana.useSolana();
@@ -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
- const useConnection = require('./vue.CwhEmATP.cjs');
6
- const useSolana = require('./vue.C4tLiG3R.cjs');
6
+ const useConnection = require('./vue.Bii4W61L.cjs');
7
+ const useSolana = require('./vue.eNXmiI3a.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
  }
@@ -1,6 +1,8 @@
1
1
  import { inject, shallowRef, ref } from 'vue';
2
2
 
3
- const solanaInjectionKey = Symbol("VueSolana");
3
+ const solanaInjectionKey = Symbol.for(
4
+ "vue-solana:context"
5
+ );
4
6
 
5
7
  let ssrContext;
6
8
  function tryUseSolana() {
@@ -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,7 +1,8 @@
1
- import { PublicKey } from '@solana/web3-compat';
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
- import { u as useConnection } from './vue.DlEAL2G8.mjs';
4
- import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
4
+ import { u as useConnection } from './vue.CKx4lRew.mjs';
5
+ import { t as tryUseSolana } from './vue.DCDTsSjf.mjs';
5
6
 
6
7
  function useBalance(address, commitment) {
7
8
  const solana = tryUseSolana();
@@ -22,17 +23,22 @@ function useBalance(address, commitment) {
22
23
  loading.value = true;
23
24
  error.value = null;
24
25
  try {
25
- const publicKey = typeof value === "string" ? new PublicKey(value) : value;
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 = cause;
39
+ error.value = normalizedError;
34
40
  }
35
- throw cause;
41
+ throw normalizedError;
36
42
  } finally {
37
43
  if (requestId === refreshId) {
38
44
  loading.value = false;
@@ -1,7 +1,8 @@
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
- import { u as useConnection } from './vue.DlEAL2G8.mjs';
4
- import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
4
+ import { u as useConnection } from './vue.CKx4lRew.mjs';
5
+ import { t as tryUseSolana } from './vue.DCDTsSjf.mjs';
5
6
 
6
7
  function useSignatureStatus(signature, options = {}) {
7
8
  const solana = tryUseSolana();
@@ -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,6 +1,7 @@
1
1
  import { confirmTransactionSignature } from '@vue-solana/core/transaction';
2
+ import { normalizeSolanaError } from '@vue-solana/core/errors';
2
3
  import { ref } from 'vue';
3
- import { u as useConnection } from './vue.DlEAL2G8.mjs';
4
+ import { u as useConnection } from './vue.CKx4lRew.mjs';
4
5
 
5
6
  function getConfirmedTransactionStatus(confirmation) {
6
7
  if (confirmation.commitment === "finalized") {
@@ -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,7 +1,8 @@
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
- import { u as useConnection } from './vue.DlEAL2G8.mjs';
4
- import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
4
+ import { u as useConnection } from './vue.CKx4lRew.mjs';
5
+ import { t as tryUseSolana } from './vue.DCDTsSjf.mjs';
5
6
 
6
7
  function useAccountInfo(address, options = {}) {
7
8
  const solana = tryUseSolana();
@@ -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
  }