@rango-dev/widget-embedded 0.0.0-experimental-1624fbb4-20260708 → 0.0.0-experimental-99f1781b-20260920

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 (190) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/QueueManager.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
  4. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  5. package/dist/components/CustomDestination/CustomDestination.styles.d.ts +4 -4
  6. package/dist/components/CustomDestination/CustomDestination.styles.d.ts.map +1 -1
  7. package/dist/components/CustomTokenModal/CustomTokenModal.styles.d.ts +169 -169
  8. package/dist/components/CustomTokenModal/CustomTokenModal.styles.d.ts.map +1 -1
  9. package/dist/components/FilterSelector/FilterSelector.style.d.ts +1 -1
  10. package/dist/components/FilterSelector/FilterSelector.style.d.ts.map +1 -1
  11. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +1 -1
  12. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  13. package/dist/components/NamespaceItem/NamespaceItem.d.ts.map +1 -1
  14. package/dist/components/NamespaceItem/NamespaceItem.styles.d.ts +1 -1
  15. package/dist/components/NamespaceItem/NamespaceItem.styles.d.ts.map +1 -1
  16. package/dist/components/NamespaceItem/NamespaceItem.types.d.ts +3 -3
  17. package/dist/components/NamespaceItem/NamespaceItem.types.d.ts.map +1 -1
  18. package/dist/components/Quote/Quote.d.ts.map +1 -1
  19. package/dist/components/Quote/Quote.styles.d.ts +171 -171
  20. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  21. package/dist/components/Quote/Quote.types.d.ts +0 -2
  22. package/dist/components/Quote/Quote.types.d.ts.map +1 -1
  23. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
  24. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +169 -169
  25. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
  26. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +168 -168
  27. package/dist/components/RefreshModal/RefreshModal.styles.d.ts.map +1 -1
  28. package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts +2 -1
  29. package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
  30. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  31. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +1 -1
  32. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  33. package/dist/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.d.ts.map +1 -1
  34. package/dist/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.d.ts.map +1 -1
  35. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +3 -3
  36. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
  37. package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts +1 -1
  38. package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts.map +1 -1
  39. package/dist/components/TokenList/TokenList.styles.d.ts +2 -2
  40. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  41. package/dist/components/WalletStatefulConnect/DerivationPath.d.ts.map +1 -1
  42. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +7 -3
  43. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
  44. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.test.d.ts +2 -0
  45. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.test.d.ts.map +1 -0
  46. package/dist/components/WalletStatefulConnect/DerivationPath.styles.d.ts +169 -169
  47. package/dist/components/WalletStatefulConnect/DerivationPath.styles.d.ts.map +1 -1
  48. package/dist/components/WalletStatefulConnect/Detached.d.ts.map +1 -1
  49. package/dist/components/WalletStatefulConnect/Detached.types.d.ts +2 -1
  50. package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +1 -1
  51. package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +1 -1
  52. package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
  53. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +168 -168
  54. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
  55. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +3 -3
  56. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  57. package/dist/constants/errors.d.ts +1 -0
  58. package/dist/constants/errors.d.ts.map +1 -1
  59. package/dist/containers/Wallets/Wallets.constants.d.ts +3 -0
  60. package/dist/containers/Wallets/Wallets.constants.d.ts.map +1 -0
  61. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  62. package/dist/containers/Wallets/Wallets.helpers.d.ts +2 -2
  63. package/dist/containers/Wallets/Wallets.helpers.d.ts.map +1 -1
  64. package/dist/containers/Wallets/Wallets.helpers.test.d.ts +2 -0
  65. package/dist/containers/Wallets/Wallets.helpers.test.d.ts.map +1 -0
  66. package/dist/containers/Wallets/Wallets.types.d.ts +6 -4
  67. package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -1
  68. package/dist/containers/Wallets/useUpdates.d.ts +1 -1
  69. package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
  70. package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
  71. package/dist/containers/WidgetProvider/WidgetProvider.helpers.d.ts +5 -0
  72. package/dist/containers/WidgetProvider/WidgetProvider.helpers.d.ts.map +1 -0
  73. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +1 -1
  74. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +1 -1
  75. package/dist/hooks/useConnectWithLogging/index.d.ts +2 -0
  76. package/dist/hooks/useConnectWithLogging/index.d.ts.map +1 -0
  77. package/dist/hooks/useConnectWithLogging/useConnectWithLogging.d.ts +11 -0
  78. package/dist/hooks/useConnectWithLogging/useConnectWithLogging.d.ts.map +1 -0
  79. package/dist/hooks/useConnectWithLogging/useConnectWithLogging.test.d.ts +2 -0
  80. package/dist/hooks/useConnectWithLogging/useConnectWithLogging.test.d.ts.map +1 -0
  81. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +2 -1
  82. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  83. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +5 -4
  84. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  85. package/dist/hooks/useWalletList.d.ts.map +1 -1
  86. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +2 -2
  87. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -1
  88. package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts +2 -3
  89. package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts.map +1 -1
  90. package/dist/index.d.ts +10 -7
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +3 -2
  93. package/dist/index.js.map +4 -4
  94. package/dist/libs/connectLogging/connectLogging.constants.d.ts +9 -0
  95. package/dist/libs/connectLogging/connectLogging.constants.d.ts.map +1 -0
  96. package/dist/libs/connectLogging/connectLogging.d.ts +12 -0
  97. package/dist/libs/connectLogging/connectLogging.d.ts.map +1 -0
  98. package/dist/libs/connectLogging/connectLogging.test.d.ts +2 -0
  99. package/dist/libs/connectLogging/connectLogging.test.d.ts.map +1 -0
  100. package/dist/libs/connectLogging/connectLogging.types.d.ts +57 -0
  101. package/dist/libs/connectLogging/connectLogging.types.d.ts.map +1 -0
  102. package/dist/libs/connectLogging/index.d.ts +3 -0
  103. package/dist/libs/connectLogging/index.d.ts.map +1 -0
  104. package/dist/pages/WalletsPage.d.ts.map +1 -1
  105. package/dist/store/AppStore.d.ts +2 -2
  106. package/dist/store/AppStore.d.ts.map +1 -1
  107. package/dist/store/app.d.ts +2 -2
  108. package/dist/store/app.d.ts.map +1 -1
  109. package/dist/store/slices/config.d.ts +5 -5
  110. package/dist/store/slices/config.d.ts.map +1 -1
  111. package/dist/test-utils/fixtures.d.ts +2 -2
  112. package/dist/test-utils/fixtures.d.ts.map +1 -1
  113. package/dist/types/config.d.ts +25 -4
  114. package/dist/types/config.d.ts.map +1 -1
  115. package/dist/types/wallets.d.ts +1 -1
  116. package/dist/types/wallets.d.ts.map +1 -1
  117. package/dist/utils/common.d.ts +1 -0
  118. package/dist/utils/common.d.ts.map +1 -1
  119. package/dist/utils/errors.d.ts +14 -0
  120. package/dist/utils/errors.d.ts.map +1 -0
  121. package/dist/utils/errors.test.d.ts +2 -0
  122. package/dist/utils/errors.test.d.ts.map +1 -0
  123. package/dist/utils/providers.d.ts +3 -6
  124. package/dist/utils/providers.d.ts.map +1 -1
  125. package/dist/utils/swap.d.ts +1 -1
  126. package/dist/utils/swap.d.ts.map +1 -1
  127. package/dist/utils/wallets.d.ts +2 -1
  128. package/dist/utils/wallets.d.ts.map +1 -1
  129. package/package.json +16 -16
  130. package/src/QueueManager.tsx +17 -16
  131. package/src/components/ConfirmWalletsModal/WalletList.tsx +2 -2
  132. package/src/components/NamespaceItem/NamespaceItem.styles.ts +1 -0
  133. package/src/components/NamespaceItem/NamespaceItem.tsx +5 -1
  134. package/src/components/NamespaceItem/NamespaceItem.types.ts +3 -3
  135. package/src/components/Quote/Quote.tsx +0 -2
  136. package/src/components/Quote/Quote.types.ts +0 -2
  137. package/src/components/Quote/QuoteCostDetails.tsx +15 -4
  138. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +4 -2
  139. package/src/components/SwapDetails/SwapDetails.tsx +17 -8
  140. package/src/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.tsx +12 -13
  141. package/src/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.tsx +8 -2
  142. package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +3 -3
  143. package/src/components/TokenList/LoadingTokenList.tsx +2 -2
  144. package/src/components/WalletStatefulConnect/DerivationPath.helpers.test.ts +98 -0
  145. package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +14 -10
  146. package/src/components/WalletStatefulConnect/DerivationPath.tsx +14 -7
  147. package/src/components/WalletStatefulConnect/Detached.tsx +17 -10
  148. package/src/components/WalletStatefulConnect/Detached.types.ts +2 -1
  149. package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +2 -1
  150. package/src/components/WalletStatefulConnect/Namespaces.tsx +6 -12
  151. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +3 -3
  152. package/src/constants/errors.ts +3 -0
  153. package/src/containers/Wallets/Wallets.constants.ts +14 -0
  154. package/src/containers/Wallets/Wallets.helpers.test.ts +67 -0
  155. package/src/containers/Wallets/Wallets.helpers.ts +9 -9
  156. package/src/containers/Wallets/Wallets.tsx +20 -3
  157. package/src/containers/Wallets/Wallets.types.ts +7 -7
  158. package/src/containers/Wallets/useUpdates.ts +7 -117
  159. package/src/containers/WidgetProvider/WidgetProvider.helpers.ts +10 -0
  160. package/src/containers/WidgetProvider/WidgetProvider.tsx +12 -1
  161. package/src/containers/WidgetProvider/WidgetProvider.types.ts +1 -1
  162. package/src/hooks/useConnectWithLogging/index.ts +1 -0
  163. package/src/hooks/useConnectWithLogging/useConnectWithLogging.test.ts +138 -0
  164. package/src/hooks/useConnectWithLogging/useConnectWithLogging.ts +36 -0
  165. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +36 -29
  166. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +6 -3
  167. package/src/hooks/useWalletList.ts +10 -7
  168. package/src/hooks/useWalletProviders/useWalletProviders.helpers.ts +3 -10
  169. package/src/hooks/useWalletProviders/useWalletProviders.ts +2 -2
  170. package/src/index.ts +10 -11
  171. package/src/libs/connectLogging/connectLogging.constants.ts +17 -0
  172. package/src/libs/connectLogging/connectLogging.test.ts +918 -0
  173. package/src/libs/connectLogging/connectLogging.ts +359 -0
  174. package/src/libs/connectLogging/connectLogging.types.ts +70 -0
  175. package/src/libs/connectLogging/index.ts +5 -0
  176. package/src/pages/WalletsPage.tsx +1 -0
  177. package/src/store/AppStore.tsx +4 -2
  178. package/src/store/app.ts +7 -2
  179. package/src/store/slices/config.ts +36 -25
  180. package/src/store/slices/data.test.ts +2 -2
  181. package/src/test-utils/fixtures.ts +6 -2
  182. package/src/types/config.ts +31 -4
  183. package/src/types/wallets.ts +1 -1
  184. package/src/utils/common.ts +6 -0
  185. package/src/utils/errors.test.ts +78 -0
  186. package/src/utils/errors.ts +69 -0
  187. package/src/utils/providers.ts +16 -50
  188. package/src/utils/swap.ts +8 -1
  189. package/src/utils/wallets.ts +12 -15
  190. package/dist/widget-embedded.build.json +0 -1
@@ -1,14 +1,20 @@
1
- import type { HandleConnectOptions, Result } from './useStatefulConnect.types';
1
+ import type {
2
+ HandleConnectOptions,
3
+ NamespaceData,
4
+ Result,
5
+ } from './useStatefulConnect.types';
6
+ import type { WithConnectTrigger } from '../../libs/connectLogging';
2
7
  import type { WalletInfoWithExtra } from '../../types';
3
8
  import type { Namespace } from '@hub3js/namespaces';
4
- import type { NamespaceData } from '@rango-dev/wallets-shared';
5
9
 
6
10
  import { WalletState } from '@rango-dev/ui';
7
11
  import { useWallets } from '@rango-dev/wallets-react';
8
12
  import { useReducer } from 'react';
9
13
 
10
14
  import { isOnDetached } from '../../components/StatefulConnectModal';
15
+ import { tryRefineErrorMessage } from '../../utils/errors';
11
16
  import { type ExtendedModalWalletInfo } from '../../utils/wallets';
17
+ import { useConnectWithLogging } from '../useConnectWithLogging';
12
18
 
13
19
  import {
14
20
  isStateOnDerivationPathStep,
@@ -48,8 +54,11 @@ export interface UseStatefulConnect {
48
54
  * or what derivation path should be used for.
49
55
  *
50
56
  */
51
- export function useStatefulConnect(): UseStatefulConnect {
52
- const { state, disconnect, connect } = useWallets();
57
+ export function useStatefulConnect({
58
+ trigger,
59
+ }: WithConnectTrigger = {}): UseStatefulConnect {
60
+ const { state, disconnect } = useWallets();
61
+ const connect = useConnectWithLogging();
53
62
 
54
63
  const [connectState, dispatch] = useReducer(reducer, initState);
55
64
 
@@ -71,13 +80,16 @@ export function useStatefulConnect(): UseStatefulConnect {
71
80
  ...namespaceInput,
72
81
  network: undefined,
73
82
  }));
74
- await connect(wallet.type, legacyNamespacesInput);
83
+ await connect(wallet.type, legacyNamespacesInput, { trigger });
75
84
  return { status: ResultStatus.Connected };
76
85
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
86
  } catch (e: any) {
78
- const message = e?.message
79
- ? `Error: ${e.message}`
80
- : 'An unknown error happened during connecting wallet.';
87
+ const message = tryRefineErrorMessage(
88
+ e,
89
+ e?.message
90
+ ? `Error: ${e.message}`
91
+ : 'An unknown error happened during connecting wallet.'
92
+ );
81
93
 
82
94
  if (options?.disconnectOnError) {
83
95
  try {
@@ -110,16 +122,13 @@ export function useStatefulConnect(): UseStatefulConnect {
110
122
  * 3. Target wallet contains only one namespace, in this situation we should check if that namespace needs derivation path and based on that, try to connect to the related provider or display derivation path modal.
111
123
  */
112
124
 
113
- // Legacy and hub have different structure to handle each situation.
114
- const isHub = !!wallet.isHub;
115
- const needsNamespace = isHub
116
- ? wallet.properties?.find((item) => item.name === 'namespaces')?.value
117
- : wallet.needsNamespace;
125
+ const needsNamespace = wallet.properties?.find(
126
+ (item) => item.name === 'namespaces'
127
+ )?.value;
118
128
 
119
- const needsDerivationPath = isHub
120
- ? wallet.properties?.find((item) => item.name === 'derivationPath')
121
- ?.value
122
- : wallet.needsDerivationPath;
129
+ const needsDerivationPath = wallet.properties?.find(
130
+ (item) => item.name === 'derivationPath'
131
+ )?.value;
123
132
 
124
133
  // Forced namespaces are used to bypass namespace selection flow.
125
134
  if (forceConnectToNamespaces) {
@@ -209,7 +218,7 @@ export function useStatefulConnect(): UseStatefulConnect {
209
218
  * and forced namespaces are not enabled,
210
219
  * we should display detached modal
211
220
  */
212
- if (!!wallet.isHub && !options?.forceConnectToNamespaces) {
221
+ if (!options?.forceConnectToNamespaces) {
213
222
  const needsNamespace = wallet.properties?.find(
214
223
  (item) => item.name === 'namespaces'
215
224
  )?.value;
@@ -237,14 +246,13 @@ export function useStatefulConnect(): UseStatefulConnect {
237
246
  wallet: ExtendedModalWalletInfo,
238
247
  selectedNamespaces: Namespace[]
239
248
  ): Promise<Result> => {
240
- const isHub = !!wallet.isHub;
241
- const needsNamespace = isHub
242
- ? wallet.properties?.find((item) => item.name === 'namespaces')?.value
243
- : wallet.needsNamespace;
249
+ const needsNamespace = wallet.properties?.find(
250
+ (item) => item.name === 'namespaces'
251
+ )?.value;
244
252
 
245
- const needsDerivationPath = isHub
246
- ? wallet.properties?.find((item) => item.name === 'derivationPath')?.value
247
- : wallet.needsDerivationPath;
253
+ const needsDerivationPath = wallet.properties?.find(
254
+ (item) => item.name === 'derivationPath'
255
+ )?.value;
248
256
 
249
257
  const isSingleNamespace = needsNamespace?.selection === 'single';
250
258
  const firstSelectedNamespace = selectedNamespaces[0];
@@ -320,10 +328,9 @@ export function useStatefulConnect(): UseStatefulConnect {
320
328
  const selectedNamespace = connectState.derivationPath.namespace;
321
329
  const namespaces = [{ namespace: selectedNamespace, derivationPath }];
322
330
 
323
- const isHub = !!wallet.isHub;
324
- const needsNamespace = isHub
325
- ? wallet.properties?.find((item) => item.name === 'namespaces')?.value
326
- : wallet.needsNamespace;
331
+ const needsNamespace = wallet.properties?.find(
332
+ (item) => item.name === 'namespaces'
333
+ )?.value;
327
334
 
328
335
  const namespaceIsAvailable =
329
336
  !!needsNamespace?.data && needsNamespace.data.length > 1;
@@ -1,6 +1,11 @@
1
1
  import type { ExtendedModalWalletInfo } from '../../utils/wallets';
2
2
  import type { Namespace } from '@hub3js/namespaces';
3
3
 
4
+ export interface NamespaceData {
5
+ namespace: Namespace;
6
+ derivationPath?: string;
7
+ }
8
+
4
9
  export interface HandleConnectOptions {
5
10
  // To have a switch between connect and disconnect when user is clicking on a button, this option can be helpful.
6
11
  forceConnectToNamespaces?: Namespace[];
@@ -15,9 +20,7 @@ export interface NeedsNamespacesState {
15
20
 
16
21
  export interface DetachedPayload {
17
22
  targetWallet: ExtendedModalWalletInfo;
18
- selectedNamespaces:
19
- | { namespace: Namespace; derivationPath?: string }[]
20
- | null;
23
+ selectedNamespaces: NamespaceData[] | null;
21
24
  derivationPath?: string;
22
25
  }
23
26
 
@@ -1,12 +1,13 @@
1
1
  import type { ExtendedModalWalletInfo } from '../utils/wallets';
2
2
  import type { WalletInfo } from '@rango-dev/ui';
3
3
 
4
+ import { WalletTypes } from '@rango-dev/provider-all';
4
5
  import { WalletState } from '@rango-dev/ui';
5
6
  import { useWallets } from '@rango-dev/wallets-react';
6
- import { detectMobileScreens, WalletTypes } from '@rango-dev/wallets-shared';
7
7
  import { useCallback, useEffect } from 'react';
8
8
 
9
9
  import { useAppStore } from '../store/AppStore';
10
+ import { detectMobileScreens } from '../utils/common';
10
11
  import { emitWalletDetected } from '../utils/events';
11
12
  import { configWalletsToWalletName } from '../utils/providers';
12
13
  import {
@@ -37,6 +38,12 @@ const NON_INJECTED_WALLET_TYPES = new Set<string>([
37
38
  WalletTypes.DEFAULT,
38
39
  ]);
39
40
 
41
+ const DEFAULT_EVM_WALLETS = new Set<string>([
42
+ WalletTypes.DEFAULT,
43
+ WalletTypes.WALLET_CONNECT_2,
44
+ WalletTypes.LEDGER,
45
+ ]);
46
+
40
47
  interface Params {
41
48
  chain?: string;
42
49
  }
@@ -89,7 +96,7 @@ export function useWalletList(params?: Params): API {
89
96
  if (isDetected && !detectedWalletsReported.has(wallet.type)) {
90
97
  detectedWalletsReported.add(wallet.type);
91
98
  emitWalletDetected({
92
- walletName: wallet.title,
99
+ walletName: wallet.type,
93
100
  });
94
101
  }
95
102
  });
@@ -131,11 +138,7 @@ export function useWalletList(params?: Params): API {
131
138
  const isEvmWalletInstalledExceptDefault = wallets.filter(
132
139
  (wallet) =>
133
140
  wallet.state != WalletState.NOT_INSTALLED &&
134
- ![
135
- WalletTypes.DEFAULT,
136
- WalletTypes.WALLET_CONNECT_2,
137
- WalletTypes.LEDGER,
138
- ].includes(wallet.type as WalletTypes) &&
141
+ !DEFAULT_EVM_WALLETS.has(wallet.type) &&
139
142
  getWalletInfo(wallet.type).supportedChains.filter(
140
143
  (blockchain) => blockchain.type == 'EVM'
141
144
  ).length > 0
@@ -1,19 +1,12 @@
1
- import type { ProviderInterface } from '@rango-dev/wallets-react';
1
+ import type { Provider } from '@hub3js/core';
2
2
 
3
- import { Provider } from '@hub3js/core';
4
-
5
- export function hashProviders(
6
- providers: (string | ProviderInterface | Provider)[]
7
- ): string {
3
+ export function hashProviders(providers: (string | Provider)[]): string {
8
4
  return providers
9
5
  .map((provider) => {
10
6
  if (typeof provider === 'string') {
11
7
  return provider;
12
8
  }
13
- if (provider instanceof Provider) {
14
- return provider.id;
15
- }
16
- return provider.config.type;
9
+ return provider.id;
17
10
  })
18
11
  .join('-');
19
12
  }
@@ -1,4 +1,4 @@
1
- import type { WidgetConfig } from '../../types';
1
+ import type { WidgetConfigWithoutLegacyProviders } from '../../types';
2
2
  import type { ProvidersOptions } from '../../utils/providers';
3
3
 
4
4
  import { useEffect } from 'react';
@@ -8,7 +8,7 @@ import { useAppStore } from '../../store/AppStore';
8
8
  import { hashProviders } from './useWalletProviders.helpers';
9
9
 
10
10
  export function useWalletProviders(
11
- configWallets: WidgetConfig['wallets'],
11
+ configWallets: WidgetConfigWithoutLegacyProviders['wallets'],
12
12
  options?: ProvidersOptions
13
13
  ) {
14
14
  const { clearConnectedWallet, getAvailableProviders, buildAndSetProviders } =
package/src/index.ts CHANGED
@@ -14,6 +14,7 @@ import type {
14
14
  WidgetTheme,
15
15
  WidgetVariant,
16
16
  } from './types';
17
+ import type { WalletType } from '@hub3js/core';
17
18
  import type {
18
19
  PendingSwapWithQueueID,
19
20
  Route,
@@ -36,16 +37,14 @@ import type {
36
37
  StepTxExecutionUpdatedEvent,
37
38
  } from '@rango-dev/queue-manager-rango-preset';
38
39
  import type {
39
- LegacyEventHandler as HandleWalletsUpdate,
40
- LegacyProviderInterface as ProviderInterface,
41
- } from '@rango-dev/wallets-core/legacy';
42
- import type {
40
+ EventHandler as HandleWalletsUpdate,
41
+ ProviderInterface,
43
42
  WalletInfo,
44
43
  WalletState,
45
- WalletType,
46
- } from '@rango-dev/wallets-shared';
44
+ } from '@rango-dev/wallets-react';
47
45
  import type { PendingSwap, PendingSwapStep } from 'rango-types';
48
46
 
47
+ import { Networks, readAccountAddress } from '@rango-dev/internal-blockchains';
49
48
  import {
50
49
  EventSeverity,
51
50
  RouteEventType,
@@ -53,9 +52,7 @@ import {
53
52
  StepExecutionBlockedEventStatus,
54
53
  StepExecutionEventStatus,
55
54
  } from '@rango-dev/queue-manager-rango-preset';
56
- import { legacyReadAccountAddress as readAccountAddress } from '@rango-dev/wallets-core/legacy';
57
55
  import { useWallets, Events as WalletEvents } from '@rango-dev/wallets-react';
58
- import { Networks, WalletTypes } from '@rango-dev/wallets-shared';
59
56
  import { PendingSwapNetworkStatus } from 'rango-types';
60
57
 
61
58
  import {
@@ -87,7 +84,7 @@ import {
87
84
  WalletEventTypes,
88
85
  WidgetEvents,
89
86
  } from './types';
90
- import { pickProviderVersionWithFallbackToLegacy } from './utils/providers';
87
+ import { pickProviderVersion } from './utils/providers';
91
88
  import { customizedThemeTokens } from './utils/ui';
92
89
 
93
90
  export const StatefulConnect = {
@@ -105,6 +102,9 @@ export type {
105
102
  WidgetTheme,
106
103
  WidgetColors,
107
104
  WidgetColorsKeys,
105
+ /**
106
+ * @deprecated Pass a hub `Provider` instead. This type will be removed in future versions.
107
+ */
108
108
  ProviderInterface,
109
109
  BlockchainAndTokenConfig,
110
110
  WidgetProps,
@@ -183,10 +183,9 @@ export type {
183
183
  // Internal function and enum exports for Rango
184
184
  export {
185
185
  readAccountAddress,
186
- pickProviderVersionWithFallbackToLegacy,
186
+ pickProviderVersion,
187
187
  Networks,
188
188
  WalletEvents,
189
- WalletTypes,
190
189
  PendingSwapNetworkStatus,
191
190
  EventSeverity,
192
191
  };
@@ -0,0 +1,17 @@
1
+ /** How long a wallet may leave an attempt unanswered before it's logged. */
2
+ export const CONNECT_TIMEOUT = 180_000;
3
+
4
+ export const CONNECT_TIMEOUT_MESSAGE =
5
+ 'Wallet connection still pending after 3 minutes';
6
+
7
+ export const UNREADABLE_FAILURE_MESSAGE = 'Failure could not be described';
8
+
9
+ /** No class is named like this, so it can't be mistaken for a real name. */
10
+ export const UNREADABLE_FAILURE_NAME = '(unreadable)';
11
+
12
+ export const ATTEMPT_ERROR_NAMES: readonly string[] = [
13
+ 'WalletConnectionAttemptError',
14
+ 'AutoConnectionAttemptError',
15
+ ];
16
+
17
+ export const CONNECTION_ERROR_NAME = 'WalletConnectionError';