@rango-dev/widget-embedded 0.42.4-next.0 → 0.43.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 (172) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +5 -2
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  4. package/dist/components/NoResult/NoResult.d.ts.map +1 -1
  5. package/dist/components/NoResult/NoResult.types.d.ts +0 -1
  6. package/dist/components/NoResult/NoResult.types.d.ts.map +1 -1
  7. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -1
  8. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +3 -5
  9. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
  10. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +0 -440
  11. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
  12. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -2
  13. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -1
  14. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -1
  15. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  16. package/dist/components/Slippage/Slippage.styles.d.ts +0 -162
  17. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  18. package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
  19. package/dist/components/StatefulConnectModal/helpers.d.ts +0 -3
  20. package/dist/components/StatefulConnectModal/helpers.d.ts.map +1 -1
  21. package/dist/components/StatefulConnectModal/index.d.ts +1 -1
  22. package/dist/components/StatefulConnectModal/index.d.ts.map +1 -1
  23. package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts.map +1 -1
  24. package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
  25. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +3 -805
  26. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
  27. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +8 -11
  28. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  29. package/dist/components/WalletStatefulConnect/index.d.ts +0 -1
  30. package/dist/components/WalletStatefulConnect/index.d.ts.map +1 -1
  31. package/dist/constants/errors.d.ts.map +1 -1
  32. package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
  33. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  34. package/dist/containers/Wallets/Wallets.types.d.ts +3 -5
  35. package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -1
  36. package/dist/containers/Wallets/useUpdates.d.ts +3 -3
  37. package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
  38. package/dist/hooks/useBootstrap/useBootstrap.d.ts.map +1 -1
  39. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
  40. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  41. package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts +1 -3
  42. package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts.map +1 -1
  43. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +2 -11
  44. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  45. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
  46. package/dist/hooks/useWalletList.d.ts +2 -2
  47. package/dist/hooks/useWalletList.d.ts.map +1 -1
  48. package/dist/index.d.ts +2 -4
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +2 -2
  51. package/dist/index.js.map +4 -4
  52. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  53. package/dist/pages/Home.d.ts.map +1 -1
  54. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  55. package/dist/pages/WalletsPage.d.ts.map +1 -1
  56. package/dist/store/AppStore.d.ts +0 -2
  57. package/dist/store/AppStore.d.ts.map +1 -1
  58. package/dist/store/app.d.ts +0 -2
  59. package/dist/store/app.d.ts.map +1 -1
  60. package/dist/store/quote.d.ts +0 -2
  61. package/dist/store/quote.d.ts.map +1 -1
  62. package/dist/store/slices/settings.d.ts +0 -3
  63. package/dist/store/slices/settings.d.ts.map +1 -1
  64. package/dist/types/quote.d.ts +0 -1
  65. package/dist/types/quote.d.ts.map +1 -1
  66. package/dist/utils/colors.d.ts.map +1 -1
  67. package/dist/utils/numbers.d.ts +0 -1
  68. package/dist/utils/numbers.d.ts.map +1 -1
  69. package/dist/utils/settings.d.ts +1 -2
  70. package/dist/utils/settings.d.ts.map +1 -1
  71. package/dist/utils/wallets.d.ts +1 -9
  72. package/dist/utils/wallets.d.ts.map +1 -1
  73. package/dist/widget-embedded.build.json +1 -1
  74. package/package.json +8 -8
  75. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +47 -4
  76. package/src/components/ConfirmWalletsModal/WalletList.tsx +19 -35
  77. package/src/components/NoResult/NoResult.tsx +1 -4
  78. package/src/components/NoResult/NoResult.types.ts +0 -1
  79. package/src/components/Quote/Quote.tsx +1 -1
  80. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +4 -29
  81. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts +1 -10
  82. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +7 -38
  83. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -2
  84. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +21 -20
  85. package/src/components/Slippage/Slippage.styles.ts +0 -23
  86. package/src/components/Slippage/Slippage.tsx +22 -28
  87. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -19
  88. package/src/components/StatefulConnectModal/helpers.ts +0 -6
  89. package/src/components/StatefulConnectModal/index.ts +1 -1
  90. package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +33 -14
  91. package/src/components/WalletStatefulConnect/Namespaces.styles.ts +6 -44
  92. package/src/components/WalletStatefulConnect/Namespaces.tsx +7 -12
  93. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +11 -13
  94. package/src/components/WalletStatefulConnect/index.ts +0 -1
  95. package/src/constants/errors.ts +7 -6
  96. package/src/containers/Inputs/Inputs.tsx +0 -2
  97. package/src/containers/Wallets/Wallets.tsx +5 -6
  98. package/src/containers/Wallets/Wallets.types.ts +3 -5
  99. package/src/containers/Wallets/useUpdates.ts +32 -40
  100. package/src/hooks/useBootstrap/useBootstrap.ts +10 -33
  101. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -1
  102. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +1 -1
  103. package/src/hooks/useStatefulConnect/useStatefulConnect.state.ts +1 -11
  104. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +4 -33
  105. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +1 -13
  106. package/src/hooks/useSwapInput.ts +1 -1
  107. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +0 -2
  108. package/src/hooks/useWalletList.ts +3 -3
  109. package/src/index.ts +1 -8
  110. package/src/pages/ConfirmSwapPage.tsx +1 -6
  111. package/src/pages/Home.tsx +12 -61
  112. package/src/pages/LiquiditySourcePage.tsx +3 -5
  113. package/src/pages/WalletsPage.tsx +1 -17
  114. package/src/store/app.ts +0 -1
  115. package/src/store/quote.ts +4 -23
  116. package/src/store/slices/settings.ts +0 -11
  117. package/src/types/quote.ts +1 -4
  118. package/src/utils/colors.ts +10 -3
  119. package/src/utils/numbers.ts +0 -11
  120. package/src/utils/settings.ts +4 -11
  121. package/src/utils/wallets.ts +14 -59
  122. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.d.ts +0 -4
  123. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.d.ts.map +0 -1
  124. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.d.ts +0 -8
  125. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.d.ts.map +0 -1
  126. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.d.ts +0 -4
  127. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.d.ts.map +0 -1
  128. package/dist/components/SwapMetrics/SwapMetrics.constants.d.ts +0 -5
  129. package/dist/components/SwapMetrics/SwapMetrics.constants.d.ts.map +0 -1
  130. package/dist/components/SwapMetrics/SwapMetrics.d.ts +0 -4
  131. package/dist/components/SwapMetrics/SwapMetrics.d.ts.map +0 -1
  132. package/dist/components/SwapMetrics/SwapMetrics.helpers.d.ts +0 -11
  133. package/dist/components/SwapMetrics/SwapMetrics.helpers.d.ts.map +0 -1
  134. package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts +0 -482
  135. package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts.map +0 -1
  136. package/dist/components/SwapMetrics/SwapMetrics.types.d.ts +0 -27
  137. package/dist/components/SwapMetrics/SwapMetrics.types.d.ts.map +0 -1
  138. package/dist/components/SwapMetrics/index.d.ts +0 -2
  139. package/dist/components/SwapMetrics/index.d.ts.map +0 -1
  140. package/dist/components/WalletStatefulConnect/Detached.d.ts +0 -4
  141. package/dist/components/WalletStatefulConnect/Detached.d.ts.map +0 -1
  142. package/dist/components/WalletStatefulConnect/Detached.types.d.ts +0 -8
  143. package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +0 -1
  144. package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts +0 -4
  145. package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +0 -1
  146. package/dist/components/WalletStatefulConnect/NamespaceUnsupportedItem.d.ts +0 -4
  147. package/dist/components/WalletStatefulConnect/NamespaceUnsupportedItem.d.ts.map +0 -1
  148. package/dist/utils/sanitizers.d.ts +0 -27
  149. package/dist/utils/sanitizers.d.ts.map +0 -1
  150. package/dist/utils/sanitizers.test.d.ts +0 -2
  151. package/dist/utils/sanitizers.test.d.ts.map +0 -1
  152. package/dist/utils/validation.d.ts +0 -26
  153. package/dist/utils/validation.d.ts.map +0 -1
  154. package/dist/utils/validation.test.d.ts +0 -2
  155. package/dist/utils/validation.test.d.ts.map +0 -1
  156. package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.ts +0 -33
  157. package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.tsx +0 -48
  158. package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.ts +0 -3
  159. package/src/components/SwapMetrics/SwapMetrics.constants.ts +0 -4
  160. package/src/components/SwapMetrics/SwapMetrics.helpers.ts +0 -76
  161. package/src/components/SwapMetrics/SwapMetrics.styles.ts +0 -32
  162. package/src/components/SwapMetrics/SwapMetrics.tsx +0 -134
  163. package/src/components/SwapMetrics/SwapMetrics.types.ts +0 -26
  164. package/src/components/SwapMetrics/index.ts +0 -1
  165. package/src/components/WalletStatefulConnect/Detached.tsx +0 -53
  166. package/src/components/WalletStatefulConnect/Detached.types.ts +0 -8
  167. package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +0 -177
  168. package/src/components/WalletStatefulConnect/NamespaceUnsupportedItem.tsx +0 -42
  169. package/src/utils/sanitizers.test.ts +0 -122
  170. package/src/utils/sanitizers.ts +0 -41
  171. package/src/utils/validation.test.ts +0 -121
  172. package/src/utils/validation.ts +0 -45
@@ -1,5 +1,6 @@
1
1
  import type { HandleConnectOptions, Result } from './useStatefulConnect.types';
2
2
  import type { WalletInfoWithExtra } from '../../types';
3
+ import type { ExtendedModalWalletInfo } from '../../utils/wallets';
3
4
  import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
4
5
  import type { NamespaceData, WalletType } from '@rango-dev/wallets-shared';
5
6
 
@@ -7,11 +8,6 @@ import { WalletState } from '@rango-dev/ui';
7
8
  import { useWallets } from '@rango-dev/wallets-react';
8
9
  import { useReducer } from 'react';
9
10
 
10
- import {
11
- checkIsWalletPartiallyConnected,
12
- type ExtendedModalWalletInfo,
13
- } from '../../utils/wallets';
14
-
15
11
  import {
16
12
  isStateOnDerivationPathStep,
17
13
  isStateOnNamespace,
@@ -68,6 +64,7 @@ export function useStatefulConnect(): UseStatefulConnect {
68
64
  network: undefined,
69
65
  }));
70
66
  await connect(type, legacyNamespacesInput);
67
+
71
68
  return { status: ResultStatus.Connected };
72
69
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
70
  } catch (e: any) {
@@ -154,25 +151,6 @@ export function useStatefulConnect(): UseStatefulConnect {
154
151
  }
155
152
  }
156
153
 
157
- if (!!wallet.isHub) {
158
- const walletState = state(wallet.type);
159
- const namespacesState = walletState.namespaces;
160
- const isPartiallyConnected = checkIsWalletPartiallyConnected(
161
- wallet,
162
- namespacesState
163
- );
164
- if (isPartiallyConnected) {
165
- dispatch({
166
- type: 'detached',
167
- payload: {
168
- targetWallet: wallet,
169
- selectedNamespaces: null,
170
- },
171
- });
172
- return { status: ResultStatus.Detached };
173
- }
174
- }
175
-
176
154
  if (options?.disconnectIfConnected) {
177
155
  await handleDisconnect(wallet.type);
178
156
  return { status: ResultStatus.Disconnected };
@@ -225,19 +203,12 @@ export function useStatefulConnect(): UseStatefulConnect {
225
203
  );
226
204
  }
227
205
 
206
+ const type = connectState.namespace.targetWallet.type;
228
207
  const namespaces = selectedNamespaces.map((namespace) => ({
229
208
  namespace,
230
209
  }));
231
210
 
232
- dispatch({
233
- type: 'detached',
234
- payload: {
235
- targetWallet: wallet,
236
- selectedNamespaces:
237
- namespaces?.map((namespace) => namespace.namespace) || null,
238
- },
239
- });
240
- return { status: ResultStatus.Detached };
211
+ return await runConnect(type, namespaces);
241
212
  };
242
213
 
243
214
  const handleDerivationPath = async (
@@ -12,11 +12,6 @@ export interface NeedsNamespacesState {
12
12
  defaultSelectedChains?: string[];
13
13
  }
14
14
 
15
- export interface DetachedPayload {
16
- targetWallet: ExtendedModalWalletInfo;
17
- selectedNamespaces: Namespace[] | null;
18
- }
19
-
20
15
  export interface NeedsDerivationPathState {
21
16
  providerType: string;
22
17
  providerImage: string;
@@ -30,7 +25,6 @@ export enum ResultStatus {
30
25
  Disconnected = 'disconnected',
31
26
  DisconnectedUnhandled = 'disconnected-unhandled',
32
27
  Noop = 'noop',
33
- Detached = 'Detached',
34
28
  }
35
29
 
36
30
  export type Result = { status: ResultStatus };
@@ -47,11 +41,6 @@ interface UpdateDerivationPathAction {
47
41
  payload: NeedsDerivationPathState;
48
42
  }
49
43
 
50
- interface UpdateDetachedAction {
51
- type: 'detached';
52
- payload: DetachedPayload;
53
- }
54
-
55
44
  interface ResetAction {
56
45
  type: 'reset';
57
46
  }
@@ -64,5 +53,4 @@ export type Actions =
64
53
  | ResetAction
65
54
  | ResetDerivationAction
66
55
  | UpdateDerivationPathAction
67
- | UpdateNamespaceAction
68
- | UpdateDetachedAction;
56
+ | UpdateNamespaceAction;
@@ -205,7 +205,7 @@ export function useSwapInput({
205
205
  }
206
206
  return;
207
207
  }
208
- if (!isPositiveNumber(inputAmount) && inputUsdValue?.eq(0)) {
208
+ if (!isPositiveNumber(inputAmount) || inputUsdValue?.eq(0)) {
209
209
  resetState(false);
210
210
  cancelFetch();
211
211
  return;
@@ -83,7 +83,6 @@ export function useSyncUrlAndStore() {
83
83
  useEffect(() => {
84
84
  const { autoConnect, clientUrl, utmQueryParams, blockchain } =
85
85
  getUrlSearchParams();
86
-
87
86
  if (isInRouterContext && fetchMetaStatus === 'success') {
88
87
  updateUrlSearchParams({
89
88
  [SearchParams.FROM_BLOCKCHAIN]: fromBlockchain?.name,
@@ -108,7 +107,6 @@ export function useSyncUrlAndStore() {
108
107
  toBlockchain,
109
108
  toToken,
110
109
  campaignMode,
111
- fetchMetaStatus,
112
110
  ]);
113
111
 
114
112
  useEffect(() => {
@@ -1,4 +1,4 @@
1
- import type { ExtendedModalWalletInfo } from '../utils/wallets';
1
+ import type { WalletInfoWithExtra } from '../types';
2
2
  import type { WalletInfo } from '@rango-dev/ui';
3
3
  import type { BlockchainMeta } from 'rango-sdk';
4
4
 
@@ -27,7 +27,7 @@ interface Params {
27
27
  }
28
28
 
29
29
  interface API {
30
- list: ExtendedModalWalletInfo[];
30
+ list: WalletInfoWithExtra[];
31
31
  terminateConnectingWallets: () => void;
32
32
  }
33
33
 
@@ -64,7 +64,7 @@ export function useWalletList(params?: Params): API {
64
64
  )
65
65
  : wallets;
66
66
 
67
- const sortedWallets = sortWalletsBasedOnConnectionState(wallets, state);
67
+ const sortedWallets = sortWalletsBasedOnConnectionState(wallets);
68
68
 
69
69
  const isExperimentalChainNotAdded = (walletType: string) =>
70
70
  !connectedWallets.find(
package/src/index.ts CHANGED
@@ -59,14 +59,9 @@ import { PendingSwapNetworkStatus } from 'rango-types';
59
59
 
60
60
  import {
61
61
  isOnDerivationPath,
62
- isOnDetached,
63
62
  isOnNamespace,
64
63
  } from './components/StatefulConnectModal';
65
- import {
66
- DerivationPath,
67
- Detached,
68
- Namespaces,
69
- } from './components/WalletStatefulConnect';
64
+ import { DerivationPath, Namespaces } from './components/WalletStatefulConnect';
70
65
  import { WIDGET_UI_ID as UI_ID } from './constants';
71
66
  import { SUPPORTED_FONTS } from './constants/fonts';
72
67
  import { WidgetWallets } from './containers/Wallets';
@@ -89,10 +84,8 @@ import { customizedThemeTokens } from './utils/ui';
89
84
  export const StatefulConnect = {
90
85
  DerivationPath,
91
86
  Namespaces,
92
- Detached,
93
87
  isOnDerivationPath,
94
88
  isOnNamespace,
95
- isOnDetached,
96
89
  };
97
90
 
98
91
  export type {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
1
2
  import type {
2
3
  ConfirmSwap,
3
4
  ConfirmSwapFetchResult,
@@ -28,7 +29,6 @@ import { useConfirmSwap } from '../hooks/useConfirmSwap';
28
29
  import { useAppStore } from '../store/AppStore';
29
30
  import { useQuoteStore } from '../store/quote';
30
31
  import { useUiStore } from '../store/ui';
31
- import { QuoteErrorType, QuoteWarningType } from '../types';
32
32
  import { isQuoteWarningConfirmationRequired } from '../utils/quote';
33
33
  import { joinList } from '../utils/ui';
34
34
 
@@ -121,7 +121,6 @@ export function ConfirmSwapPage() {
121
121
  setInputAmount('');
122
122
  }, 0);
123
123
  } catch (e) {
124
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
124
  setDbErrorMessage('Error: ' + (e as any)?.message);
126
125
  }
127
126
  }
@@ -210,10 +209,6 @@ export function ConfirmSwapPage() {
210
209
  error={quoteError}
211
210
  couldChangeSettings={false}
212
211
  refetchQuote={onRefresh}
213
- skipAlerts={
214
- quoteError?.type === QuoteErrorType.INSUFFICIENT_SLIPPAGE ||
215
- quoteWarning?.type === QuoteWarningType.INSUFFICIENT_SLIPPAGE
216
- }
217
212
  showWarningModal={showQuoteWarningModal}
218
213
  confirmationDisabled={!isActiveTab}
219
214
  onOpenWarningModal={() => setShowQuoteWarningModal(true)}
@@ -10,8 +10,6 @@ import { HeaderButtons } from '../components/HeaderButtons';
10
10
  import { Layout, PageContainer } from '../components/Layout';
11
11
  import { QuoteWarningsAndErrors } from '../components/QuoteWarningsAndErrors';
12
12
  import { SameTokensWarning } from '../components/SameTokensWarning';
13
- import { SlippageWarningsAndErrors } from '../components/SlippageWarningsAndErrors/SlippageWarningsAndErrors';
14
- import { SwapMetrics } from '../components/SwapMetrics';
15
13
  import { navigationRoutes } from '../constants/navigationRoutes';
16
14
  import { ExpandedQuotes } from '../containers/ExpandedQuotes';
17
15
  import { Inputs } from '../containers/Inputs';
@@ -24,7 +22,6 @@ import { useUiStore } from '../store/ui';
24
22
  import { UiEventTypes } from '../types';
25
23
  import { isVariantExpandable } from '../utils/configs';
26
24
  import { emitPreventableEvent } from '../utils/events';
27
- import { getSlippageValidation } from '../utils/settings';
28
25
  import { getSwapButtonState, isTokensIdentical } from '../utils/swap';
29
26
 
30
27
  const MainContainer = styled('div', {
@@ -53,7 +50,6 @@ export function Home() {
53
50
  setQuoteWarningsConfirmed,
54
51
  updateQuotePartialState,
55
52
  } = useQuoteStore();
56
-
57
53
  const [isVisibleExpanded, setIsVisibleExpanded] = useState<boolean>(false);
58
54
  const { isLargeScreen, isExtraLargeScreen } = useScreenDetect();
59
55
 
@@ -62,17 +58,10 @@ export function Home() {
62
58
  config,
63
59
  fetchStatus: fetchMetaStatus,
64
60
  connectedWallets,
65
- customSlippage,
66
- slippage,
67
- setSlippage,
68
- setCustomSlippage,
69
61
  } = useAppStore();
70
62
 
71
63
  const { isActiveTab } = useUiStore();
72
64
  const [showQuoteWarningModal, setShowQuoteWarningModal] = useState(false);
73
- const currentSlippage = customSlippage !== null ? customSlippage : slippage;
74
-
75
- const slippageValidation = getSlippageValidation(currentSlippage);
76
65
 
77
66
  const needsToWarnEthOnPath = false;
78
67
 
@@ -102,16 +91,19 @@ export function Home() {
102
91
 
103
92
  const fetchingQuote = hasInputs && fetchMetaStatus === 'success' && loading;
104
93
 
105
- const currentQuoteWarning =
106
- slippageValidation?.quoteValidation || quoteWarning;
107
-
108
94
  const hasValidQuotes =
109
95
  !isExpandable || (isExpandable && quotes?.results.length);
110
- const hasWarningOrError = currentQuoteWarning || quoteError;
96
+ const hasWarningOrError = quoteWarning || quoteError;
111
97
  const showMessages = hasValidQuotes && hasWarningOrError;
112
98
 
113
- const showSwapMetrics = !!fromToken && !!toToken;
114
- const showSlippageAlerts = showSwapMetrics && !!slippageValidation;
99
+ useEffect(() => {
100
+ resetQuoteWallets();
101
+ updateQuotePartialState('refetchQuote', true);
102
+ }, []);
103
+
104
+ useEffect(() => {
105
+ setIsVisibleExpanded(hasInputs);
106
+ }, [hasInputs]);
115
107
 
116
108
  const onClickRefresh =
117
109
  (!!selectedQuote || quoteError) && !showQuoteWarningModal
@@ -135,22 +127,6 @@ export function Home() {
135
127
  }
136
128
  };
137
129
 
138
- const onChangeSlippage = (slippage: number | null) => {
139
- if (slippage) {
140
- setSlippage(slippage);
141
- setCustomSlippage(null);
142
- }
143
- };
144
-
145
- useEffect(() => {
146
- resetQuoteWallets();
147
- updateQuotePartialState('refetchQuote', true);
148
- }, []);
149
-
150
- useEffect(() => {
151
- setIsVisibleExpanded(hasInputs);
152
- }, [hasInputs]);
153
-
154
130
  return (
155
131
  <MainContainer>
156
132
  <Layout
@@ -218,7 +194,7 @@ export function Home() {
218
194
  loading={fetchingQuote}
219
195
  error={quoteError}
220
196
  tagHidden={false}
221
- warning={currentQuoteWarning}
197
+ warning={quoteWarning}
222
198
  type="basic"
223
199
  onClickAllRoutes={
224
200
  !!quotes && quotes.results.length > 1
@@ -230,33 +206,19 @@ export function Home() {
230
206
  }
231
207
  />
232
208
  ) : null}
233
- {showSwapMetrics && (
234
- <>
235
- <Divider size={8} />
236
- <SwapMetrics
237
- quoteError={quoteError}
238
- quoteWarning={currentQuoteWarning}
239
- fromToken={fromToken}
240
- toToken={toToken}
241
- quote={selectedQuote}
242
- loading={fetchingQuote}
243
- />
244
- </>
245
- )}
246
209
 
247
210
  {showMessages ? (
248
211
  <>
212
+ <Divider size="10" />
249
213
  <QuoteWarningsAndErrors
250
- warning={currentQuoteWarning}
214
+ warning={quoteWarning}
251
215
  error={quoteError}
252
- skipAlerts={!!slippageValidation}
253
216
  couldChangeSettings={true}
254
217
  refetchQuote={fetchQuote}
255
218
  showWarningModal={showQuoteWarningModal}
256
219
  confirmationDisabled={!isActiveTab}
257
220
  onOpenWarningModal={() => setShowQuoteWarningModal(true)}
258
221
  onCloseWarningModal={() => setShowQuoteWarningModal(false)}
259
- onChangeSlippage={onChangeSlippage}
260
222
  onConfirmWarningModal={() => {
261
223
  setShowQuoteWarningModal(false);
262
224
  setQuoteWarningsConfirmed(true);
@@ -268,17 +230,6 @@ export function Home() {
268
230
  />
269
231
  </>
270
232
  ) : null}
271
-
272
- {showSlippageAlerts && (
273
- <>
274
- <Divider size="10" />
275
- <SlippageWarningsAndErrors
276
- onChangeSettings={() =>
277
- onHandleNavigation(navigationRoutes.settings)
278
- }
279
- />
280
- </>
281
- )}
282
233
  <SameTokensWarning />
283
234
  </PageContainer>
284
235
  </Layout>
@@ -22,7 +22,6 @@ import {
22
22
  } from '../components/SettingsContainer';
23
23
  import { useAppStore } from '../store/AppStore';
24
24
  import { containsText } from '../utils/numbers';
25
- import { replaceSpacesWithDash } from '../utils/sanitizers';
26
25
  import { getUniqueSwappersGroups } from '../utils/settings';
27
26
 
28
27
  interface PropTypes {
@@ -71,10 +70,9 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
71
70
  const list = liquiditySources.map((sourceItem) => {
72
71
  const { selected, groupTitle, logo, id, ...restSourceItem } = sourceItem;
73
72
  return {
74
- id: `widget-setting-liquidity-source-${replaceSpacesWithDash(
75
- id.toLowerCase()
76
- )}-item-btn`,
77
-
73
+ id: `widget-setting-liquidity-source-${id
74
+ .toLowerCase()
75
+ .replace(/\s+/g, '-')}-item-btn`,
78
76
  start: <Image src={logo} size={22} type="circular" />,
79
77
  onClick: () => {
80
78
  if (!campaignMode) {
@@ -8,9 +8,7 @@ import {
8
8
  styled,
9
9
  Typography,
10
10
  Wallet,
11
- WalletState,
12
11
  } from '@rango-dev/ui';
13
- import { useWallets } from '@rango-dev/wallets-react';
14
12
  import React, { useState } from 'react';
15
13
 
16
14
  import { Layout, PageContainer } from '../components/Layout';
@@ -20,7 +18,6 @@ import { useAppStore } from '../store/AppStore';
20
18
  import { useUiStore } from '../store/ui';
21
19
  import { getContainer, isSingleWalletActive } from '../utils/common';
22
20
  import {
23
- checkIsWalletPartiallyConnected,
24
21
  filterBlockchainsByWalletTypes,
25
22
  filterWalletsByCategory,
26
23
  } from '../utils/wallets';
@@ -29,8 +26,7 @@ const ListContainer = styled('div', {
29
26
  display: 'flex',
30
27
  justifyContent: 'center',
31
28
  alignItems: 'center',
32
- columnGap: '$5',
33
- rowGap: '$10',
29
+ gap: '$10',
34
30
  flexWrap: 'wrap',
35
31
  paddingTop: '$5',
36
32
  });
@@ -44,7 +40,6 @@ export function WalletsPage() {
44
40
  const [blockchainCategory, setBlockchainCategory] = useState<string>('ALL');
45
41
  const blockchains = useAppStore().blockchains();
46
42
  const { config } = useAppStore();
47
- const { state } = useWallets();
48
43
 
49
44
  const [selectedWalletToConnect, setSelectedWalletToConnect] =
50
45
  useState<WalletInfoWithExtra>();
@@ -88,22 +83,11 @@ export function WalletsPage() {
88
83
  </Typography>
89
84
  <ListContainer>
90
85
  {filteredWallets.map((wallet, index) => {
91
- const walletState = state(wallet.type);
92
- const namespacesState = walletState.namespaces;
93
86
  const key = `wallet-${index}-${wallet.type}`;
94
- const isWalletPartiallyConnected = checkIsWalletPartiallyConnected(
95
- wallet,
96
- namespacesState
97
- );
98
87
  return (
99
88
  <Wallet
100
89
  key={key}
101
90
  {...wallet}
102
- state={
103
- isWalletPartiallyConnected
104
- ? WalletState.PARTIALLY_CONNECTED
105
- : wallet.state
106
- }
107
91
  container={getContainer()}
108
92
  onClick={() => handleWalletItemClick(wallet)}
109
93
  isLoading={fetchMetaStatus === 'loading'}
package/src/store/app.ts CHANGED
@@ -46,7 +46,6 @@ export function createAppStore(initialData?: WidgetConfig) {
46
46
  infiniteApprove: state.infiniteApprove,
47
47
  preferredBlockchains: state.preferredBlockchains,
48
48
  disabledLiquiditySources: state.disabledLiquiditySources,
49
- quoteTokensRate: state.quoteTokensRate,
50
49
  };
51
50
  },
52
51
  version: 1,
@@ -21,13 +21,8 @@ import {
21
21
  type Wallet,
22
22
  WidgetEvents,
23
23
  } from '../types';
24
- import { isPositiveNumber, sanitizeInputAmount } from '../utils/numbers';
25
- import {
26
- ensureLeadingZeroForDecimal,
27
- removeLeadingZeros,
28
- } from '../utils/sanitizers';
24
+ import { isPositiveNumber } from '../utils/numbers';
29
25
  import { getUsdInputFrom, getUsdOutputFrom } from '../utils/swap';
30
- import { isZeroValue } from '../utils/validation';
31
26
 
32
27
  import createSelectors from './selectors';
33
28
 
@@ -92,7 +87,6 @@ export interface QuoteState {
92
87
  value: SomeQuoteState[K]
93
88
  ) => void;
94
89
  setInputAmount: (amount: string) => void;
95
- sanitizeInputAmount: (amount: string) => void;
96
90
  setSelectedQuote: (quote: SelectedQuote | null) => void;
97
91
  retry: (retryQuote: RetryQuote) => void;
98
92
  switchFromAndTo: () => void;
@@ -229,29 +223,16 @@ export const useQuoteStore = createSelectors(
229
223
  }),
230
224
  }));
231
225
  },
232
- sanitizeInputAmount: (amount) => {
233
- const sanitized = sanitizeInputAmount(amount);
234
-
235
- set(() => ({
236
- inputAmount: sanitized,
237
- }));
238
- },
239
226
  setInputAmount: (amount) => {
240
- let sanitized = amount;
241
- if (!isZeroValue(amount)) {
242
- // sanitize once a meaningful digit is entered (e.g. "00001" → "1")
243
- sanitized = removeLeadingZeros(sanitized);
244
- sanitized = ensureLeadingZeroForDecimal(sanitized);
245
- }
246
227
  set((state) => ({
247
- inputAmount: sanitized,
248
- ...(!sanitized && {
228
+ inputAmount: amount,
229
+ ...(!amount && {
249
230
  outputAmount: null,
250
231
  outputUsdValue: new BigNumber(0),
251
232
  selectedQuote: null,
252
233
  }),
253
234
  ...(!!state.fromToken && {
254
- inputUsdValue: getUsdValue(state.fromToken, sanitized),
235
+ inputUsdValue: getUsdValue(state.fromToken, amount),
255
236
  }),
256
237
  }));
257
238
  },
@@ -16,7 +16,6 @@ import { isFeatureHidden } from '../../utils/settings';
16
16
  import { getSupportedBlockchainsFromConfig } from '../utils';
17
17
 
18
18
  export type ThemeMode = 'auto' | 'dark' | 'light';
19
- export type QuoteTokensRate = 'default' | 'reversed';
20
19
 
21
20
  export interface SettingsSlice {
22
21
  theme: ThemeMode;
@@ -31,8 +30,6 @@ export interface SettingsSlice {
31
30
  affiliatePercent: number | null;
32
31
  affiliateWallets: { [key: string]: string } | null;
33
32
  _customTokens: Token[];
34
- quoteTokensRate: QuoteTokensRate;
35
-
36
33
  setSlippage: (slippage: number) => void;
37
34
  setCustomSlippage: (customSlippage: number | null) => void;
38
35
  toggleInfiniteApprove: () => void;
@@ -53,7 +50,6 @@ export interface SettingsSlice {
53
50
  setCustomToken: (token: TokenData) => void;
54
51
  deleteCustomToken: (token: Token) => void;
55
52
  customTokens: () => Token[];
56
- changeQuoteTokensRate: () => void;
57
53
  }
58
54
 
59
55
  export const createSettingsSlice: StateCreator<
@@ -73,13 +69,6 @@ export const createSettingsSlice: StateCreator<
73
69
  affiliatePercent: null,
74
70
  affiliateWallets: null,
75
71
  _customTokens: [],
76
- quoteTokensRate: 'default',
77
-
78
- changeQuoteTokensRate: () =>
79
- set((state) => ({
80
- quoteTokensRate:
81
- state.quoteTokensRate === 'default' ? 'reversed' : 'default',
82
- })),
83
72
  addPreferredBlockchain: (blockchain) => {
84
73
  const currentPreferredBlockchains = get().preferredBlockchains;
85
74
 
@@ -36,10 +36,7 @@ export type InsufficientSlippageError = {
36
36
  minRequiredSlippage: string | null;
37
37
  };
38
38
 
39
- export type QuoteRequestFailed = {
40
- type: QuoteErrorType.REQUEST_FAILED;
41
- diagnosisMessage?: string;
42
- };
39
+ export type QuoteRequestFailed = { type: QuoteErrorType.REQUEST_FAILED };
43
40
  export type QuoteRequestCanceled = { type: QuoteErrorType.REQUEST_CANCELED };
44
41
 
45
42
  export type QuoteError =
@@ -2,8 +2,6 @@
2
2
  // Types
3
3
  import type { ThemeColors, WidgetColors, WidgetColorsKeys } from '../types';
4
4
 
5
- import { isColorKeyOverridden } from './validation';
6
-
7
5
  type RGB = {
8
6
  red: number;
9
7
  green: number;
@@ -42,6 +40,15 @@ function expandShortHexColor(hexColor: string) {
42
40
  return `#${hexColor}`;
43
41
  }
44
42
 
43
+ /*
44
+ * We letting users to override some specific colors (e.g. `primary550`, `secondary100`).
45
+ * So we are generating a range of colors if `primary` (or other keys) has passed but if user is passing a specific color,
46
+ * we will override the user color to generated range.
47
+ */
48
+ function isOverridingColor(colorKey: string): boolean {
49
+ return /[0-9]+$/.test(colorKey);
50
+ }
51
+
45
52
  // pad a hexadecimal string with zeros if it needs it
46
53
  function pad(number: string, length: number) {
47
54
  return number.padStart(length, '0');
@@ -164,7 +171,7 @@ export function expandToGenerateThemeColors(
164
171
  */
165
172
  const isSingleColor = ['background', 'foreground'].includes(colorKey);
166
173
 
167
- if (!isSingleColor && !isColorKeyOverridden(colorKey)) {
174
+ if (!isSingleColor && !isOverridingColor(colorKey)) {
168
175
  const expandedHexColor = expandShortHexColor(expandColor);
169
176
  Object.assign(
170
177
  output,
@@ -4,9 +4,6 @@ import type { BestRouteResponse } from 'rango-sdk';
4
4
 
5
5
  import { BigNumber } from 'bignumber.js';
6
6
 
7
- import { stripTrailingZeros } from './sanitizers';
8
- import { isZeroValue } from './validation';
9
-
10
7
  /*
11
8
  * if time > 1h -> rounded with 5 minutes precision
12
9
  * if time < 1h -> rounded with 15 seconds precision
@@ -128,11 +125,3 @@ export const containsText = (text: string, searchText: string) =>
128
125
 
129
126
  export const isPositiveNumber = (text?: string) =>
130
127
  !!text && parseFloat(text) > 0;
131
-
132
- export function sanitizeInputAmount(amount: string): string {
133
- if (isZeroValue(amount)) {
134
- return '0';
135
- }
136
-
137
- return stripTrailingZeros(amount);
138
- }
@@ -1,4 +1,4 @@
1
- import type { Features, HighSlippageWarning, Routing } from '../types';
1
+ import type { Features, Routing } from '../types';
2
2
  import type { SwapperMeta, SwapperType, Token } from 'rango-sdk';
3
3
 
4
4
  import { i18n } from '@lingui/core';
@@ -8,7 +8,6 @@ import {
8
8
  MAX_SLIPPAGE,
9
9
  MIN_SLIPPAGE,
10
10
  } from '../constants/swapSettings';
11
- import { QuoteWarningType } from '../types';
12
11
 
13
12
  import { removeDuplicateFrom } from './common';
14
13
 
@@ -97,11 +96,9 @@ export const addCustomTokensToSupportedTokens = (
97
96
  : supportedTokens.concat(customTokens);
98
97
  };
99
98
 
100
- export function getSlippageValidation(slippage: number): {
101
- type: 'error' | 'warning';
102
- message: string;
103
- quoteValidation?: HighSlippageWarning;
104
- } | null {
99
+ export function getSlippageValidation(
100
+ slippage: number
101
+ ): { type: 'error' | 'warning'; message: string } | null {
105
102
  if (slippage == MIN_SLIPPAGE) {
106
103
  return {
107
104
  type: 'error',
@@ -113,10 +110,6 @@ export function getSlippageValidation(slippage: number): {
113
110
  message: i18n.t(
114
111
  'Your transaction is at risk of being frontrun due to high slippage tolerance.'
115
112
  ),
116
- quoteValidation: {
117
- type: QuoteWarningType.HIGH_SLIPPAGE,
118
- slippage: slippage.toString(),
119
- },
120
113
  };
121
114
  }
122
115