@rango-dev/widget-embedded 0.23.1-next.2 → 0.23.1-next.21

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 (134) hide show
  1. package/dist/components/AppRoutes.d.ts.map +1 -1
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -283
  3. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  4. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  5. package/dist/components/HeaderButtons/HeaderButtons.d.ts.map +1 -1
  6. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +489 -1
  7. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  8. package/dist/components/HeaderButtons/InProgressTransactionBadge.d.ts +4 -0
  9. package/dist/components/HeaderButtons/InProgressTransactionBadge.d.ts.map +1 -0
  10. package/dist/components/HeaderButtons/RefreshButton.d.ts.map +1 -1
  11. package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +1 -1
  12. package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
  13. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  14. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -1
  15. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  16. package/dist/components/NoResult/NoResult.d.ts.map +1 -1
  17. package/dist/components/NoResult/NoResult.helpers.d.ts +8 -0
  18. package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -1
  19. package/dist/components/NoResult/NoResult.styles.d.ts +167 -1
  20. package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
  21. package/dist/components/NoResult/NoResult.types.d.ts +1 -0
  22. package/dist/components/NoResult/NoResult.types.d.ts.map +1 -1
  23. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  24. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +165 -0
  25. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  26. package/dist/components/Quote/Quote.d.ts.map +1 -1
  27. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  28. package/dist/components/Quote/Quote.types.d.ts +1 -0
  29. package/dist/components/Quote/Quote.types.d.ts.map +1 -1
  30. package/dist/components/Quote/QuoteTrigger.d.ts.map +1 -1
  31. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
  32. package/dist/components/Quotes/Quotes.d.ts.map +1 -1
  33. package/dist/components/Quotes/Quotes.types.d.ts +1 -0
  34. package/dist/components/Quotes/Quotes.types.d.ts.map +1 -1
  35. package/dist/components/Quotes/SelectStrategy.d.ts.map +1 -1
  36. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  37. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  38. package/dist/components/common/ActivateTabAlert/ActivateTabAlert.d.ts.map +1 -1
  39. package/dist/constants/navigationRoutes.d.ts +0 -1
  40. package/dist/constants/navigationRoutes.d.ts.map +1 -1
  41. package/dist/constants/settings.d.ts +6 -0
  42. package/dist/constants/settings.d.ts.map +1 -0
  43. package/dist/containers/App/App.styles.d.ts.map +1 -1
  44. package/dist/containers/ExpandedQuotes/ExpandedQuotes.d.ts.map +1 -1
  45. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts +3 -1
  46. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
  47. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
  48. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +1 -0
  49. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
  50. package/dist/containers/Settings/Lists.d.ts +3 -0
  51. package/dist/containers/Settings/Lists.d.ts.map +1 -0
  52. package/dist/hooks/useScreenDetect.d.ts +9 -0
  53. package/dist/hooks/useScreenDetect.d.ts.map +1 -0
  54. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  55. package/dist/index.js +2 -2
  56. package/dist/index.js.map +4 -4
  57. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  58. package/dist/pages/Home.d.ts.map +1 -1
  59. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  60. package/dist/pages/SettingsPage.d.ts.map +1 -1
  61. package/dist/store/slices/data.d.ts.map +1 -1
  62. package/dist/store/slices/settings.d.ts.map +1 -1
  63. package/dist/types/config.d.ts +9 -5
  64. package/dist/types/config.d.ts.map +1 -1
  65. package/dist/utils/colors.d.ts +5 -3
  66. package/dist/utils/colors.d.ts.map +1 -1
  67. package/dist/utils/configs.d.ts +2 -1
  68. package/dist/utils/configs.d.ts.map +1 -1
  69. package/dist/utils/swap.d.ts +2 -0
  70. package/dist/utils/swap.d.ts.map +1 -1
  71. package/dist/utils/ui.d.ts +5 -2
  72. package/dist/utils/ui.d.ts.map +1 -1
  73. package/package.json +6 -6
  74. package/src/components/AppRoutes.tsx +0 -5
  75. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +6 -12
  76. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +7 -11
  77. package/src/components/ConfirmWalletsModal/WalletList.tsx +2 -2
  78. package/src/components/HeaderButtons/HeaderButtons.styles.ts +43 -2
  79. package/src/components/HeaderButtons/HeaderButtons.tsx +2 -0
  80. package/src/components/HeaderButtons/InProgressTransactionBadge.tsx +26 -0
  81. package/src/components/HeaderButtons/RefreshButton.tsx +2 -1
  82. package/src/components/HeaderButtons/UnreadNotificationsBadge.tsx +10 -2
  83. package/src/components/HeaderButtons/WalletButton.tsx +26 -6
  84. package/src/components/Layout/Layout.styles.ts +3 -0
  85. package/src/components/Layout/Layout.tsx +4 -4
  86. package/src/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.ts +1 -1
  87. package/src/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.tsx +4 -4
  88. package/src/components/NoResult/NoResult.helpers.ts +13 -0
  89. package/src/components/NoResult/NoResult.styles.ts +19 -1
  90. package/src/components/NoResult/NoResult.tsx +27 -16
  91. package/src/components/NoResult/NoResult.types.ts +1 -0
  92. package/src/components/NotificationContent/NotificationContent.styles.ts +14 -1
  93. package/src/components/NotificationContent/NotificationContent.tsx +49 -39
  94. package/src/components/Quote/Quote.styles.ts +13 -14
  95. package/src/components/Quote/Quote.tsx +166 -145
  96. package/src/components/Quote/Quote.types.ts +1 -0
  97. package/src/components/Quote/QuoteTrigger.tsx +7 -8
  98. package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +1 -1
  99. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +2 -3
  100. package/src/components/Quotes/Quotes.tsx +21 -10
  101. package/src/components/Quotes/Quotes.types.ts +1 -0
  102. package/src/components/Quotes/SelectStrategy.tsx +3 -11
  103. package/src/components/Slippage/Slippage.tsx +11 -13
  104. package/src/components/SwapDetails/SwapDetails.tsx +1 -1
  105. package/src/components/TokenList/TokenList.tsx +9 -8
  106. package/src/components/common/ActivateTabAlert/ActivateTabAlert.tsx +2 -4
  107. package/src/constants/navigationRoutes.ts +0 -1
  108. package/src/constants/settings.ts +5 -0
  109. package/src/containers/App/App.styles.ts +0 -4
  110. package/src/containers/ExpandedQuotes/ExpandedQuotes.styles.ts +13 -0
  111. package/src/containers/ExpandedQuotes/ExpandedQuotes.tsx +5 -0
  112. package/src/containers/QuoteInfo/QuoteInfo.tsx +2 -0
  113. package/src/containers/QuoteInfo/QuoteInfo.types.ts +1 -0
  114. package/src/containers/Settings/Lists.tsx +264 -0
  115. package/src/hooks/useScreenDetect.ts +49 -0
  116. package/src/hooks/useSwapInput.ts +7 -2
  117. package/src/pages/ConfirmSwapPage.tsx +7 -3
  118. package/src/pages/Home.tsx +31 -7
  119. package/src/pages/LiquiditySourcePage.tsx +4 -3
  120. package/src/pages/SettingsPage.tsx +6 -185
  121. package/src/store/slices/config.ts +2 -2
  122. package/src/store/slices/data.ts +8 -5
  123. package/src/store/slices/settings.ts +7 -3
  124. package/src/types/config.ts +9 -5
  125. package/src/utils/colors.ts +106 -75
  126. package/src/utils/configs.ts +12 -1
  127. package/src/utils/swap.ts +11 -0
  128. package/src/utils/ui.ts +7 -5
  129. package/dist/hooks/useMobileDetect.d.ts +0 -3
  130. package/dist/hooks/useMobileDetect.d.ts.map +0 -1
  131. package/dist/pages/ThemePage.d.ts +0 -3
  132. package/dist/pages/ThemePage.d.ts.map +0 -1
  133. package/src/hooks/useMobileDetect.ts +0 -21
  134. package/src/pages/ThemePage.tsx +0 -90
@@ -0,0 +1,49 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ /*
4
+ * mobile: screen <= 480
5
+ * tablet: screen > 480 and screen <= 768
6
+ * notebook: screen > 768 & screen <= 1024
7
+ * large: screen > 1024 & screen <= 1200
8
+ * extra large: screen > 1200
9
+ */
10
+
11
+ const MIN_TABLET_WIDTH = 480;
12
+ const MIN_NOTEBOOK_WIDTH = 768;
13
+ const MIN_LARGE_SCREEN_WIDTH = 1024;
14
+ const MIN_EXTRA_LARGE_SCREEN_WIDTH = 1200;
15
+
16
+ const useScreenDetect = () => {
17
+ const [isMobile, setIsMobile] = useState(false);
18
+ const [isTablet, setIsTablet] = useState(false);
19
+ const [isNotebook, setIsNotebook] = useState(false);
20
+ const [isLargeScreen, setIsLargeScreen] = useState(false);
21
+ const [isExtraLargeScreen, setIsExtraLargeScreen] = useState(false);
22
+
23
+ const handleResize = () => {
24
+ setIsMobile(window.innerWidth <= MIN_TABLET_WIDTH);
25
+ setIsTablet(
26
+ window.innerWidth > MIN_TABLET_WIDTH &&
27
+ window.innerWidth <= MIN_NOTEBOOK_WIDTH
28
+ );
29
+ setIsNotebook(
30
+ window.innerWidth > MIN_NOTEBOOK_WIDTH &&
31
+ window.innerWidth <= MIN_LARGE_SCREEN_WIDTH
32
+ );
33
+ setIsLargeScreen(
34
+ window.innerWidth > MIN_LARGE_SCREEN_WIDTH &&
35
+ window.innerWidth <= MIN_EXTRA_LARGE_SCREEN_WIDTH
36
+ );
37
+ setIsExtraLargeScreen(window.innerWidth > MIN_EXTRA_LARGE_SCREEN_WIDTH);
38
+ };
39
+
40
+ useEffect(() => {
41
+ handleResize(); // Initial check
42
+ window.addEventListener('resize', handleResize);
43
+ return () => window.removeEventListener('resize', handleResize);
44
+ }, []);
45
+
46
+ return { isMobile, isTablet, isNotebook, isLargeScreen, isExtraLargeScreen };
47
+ };
48
+
49
+ export default useScreenDetect;
@@ -46,7 +46,11 @@ export function useSwapInput({
46
46
  refetchQuote,
47
47
  }: UseSwapInputProps): UseSwapInput {
48
48
  const { fetch: fetchQuote, cancelFetch } = useFetchAllQuotes();
49
- const { enableNewLiquiditySources, features } = useAppStore().config;
49
+ const {
50
+ excludeLiquiditySources: configExcludeLiquiditySources,
51
+ features,
52
+ enableCentralizedSwappers,
53
+ } = useAppStore().config;
50
54
  const connectedWallets = useWalletsStore.use.connectedWallets();
51
55
 
52
56
  const tokens = useAppStore().tokens();
@@ -118,6 +122,7 @@ export function useSwapInput({
118
122
  affiliateRef,
119
123
  affiliatePercent,
120
124
  affiliateWallets,
125
+ enableCentralizedSwappers,
121
126
  });
122
127
  if (isFeatureEnabled('experimentalRoute', features)) {
123
128
  requestBody.experimental = true;
@@ -223,7 +228,7 @@ export function useSwapInput({
223
228
  toToken?.blockchain,
224
229
  shouldSkipRequest,
225
230
  liquiditySources?.length,
226
- enableNewLiquiditySources,
231
+ configExcludeLiquiditySources,
227
232
  disabledLiquiditySources.length,
228
233
  userSlippage,
229
234
  affiliateRef,
@@ -371,15 +371,19 @@ export function ConfirmSwapPage() {
371
371
  </div>
372
372
  <Divider size="12" />
373
373
 
374
- {joinList(alerts, <Divider size={10} />)}
374
+ {joinList(
375
+ alerts.map((alert, index) => ({
376
+ element: alert,
377
+ key: `alert-${index}`,
378
+ })),
379
+ <Divider size={10} />
380
+ )}
375
381
  {alerts.length > 0 ? <Divider size={10} /> : null}
376
382
 
377
383
  <QuoteInfo
378
384
  quote={selectedQuote}
379
385
  type="swap-preview"
380
386
  expanded={true}
381
- selected
382
- tagHidden
383
387
  error={confirmSwapResult.error}
384
388
  loading={fetchingConfirmationQuote}
385
389
  warning={confirmSwapResult.warnings?.quote ?? null}
@@ -1,3 +1,5 @@
1
+ import type { SelectedQuote } from '../types';
2
+
1
3
  import { i18n } from '@lingui/core';
2
4
  import { Button, Divider, styled, WarningIcon } from '@rango-dev/ui';
3
5
  import React, { useEffect, useState } from 'react';
@@ -10,19 +12,23 @@ import { navigationRoutes } from '../constants/navigationRoutes';
10
12
  import { ExpandedQuotes } from '../containers/ExpandedQuotes';
11
13
  import { Inputs } from '../containers/Inputs';
12
14
  import { QuoteInfo } from '../containers/QuoteInfo';
13
- import useMobileDetect from '../hooks/useMobileDetect';
15
+ import useScreenDetect from '../hooks/useScreenDetect';
14
16
  import { useSwapInput } from '../hooks/useSwapInput';
15
17
  import { useAppStore } from '../store/AppStore';
16
18
  import { useQuoteStore } from '../store/quote';
17
19
  import { useUiStore } from '../store/ui';
18
20
  import { useWalletsStore } from '../store/wallets';
19
- import { getSwapButtonState } from '../utils/swap';
21
+ import { isVariantExpandable } from '../utils/configs';
22
+ import { getSwapButtonState, isTokensIdentical } from '../utils/swap';
20
23
 
21
24
  const MainContainer = styled('div', {
22
25
  display: 'grid',
23
26
  gridTemplateColumns: 'auto auto',
24
27
  alignItems: 'flex-start',
25
- height: 700,
28
+ maxHeight: 700,
29
+ '& .footer__alert': {
30
+ paddingTop: '0',
31
+ },
26
32
  });
27
33
  export const TIME_TO_NAVIGATE_ANOTHER_PAGE = 300;
28
34
 
@@ -43,7 +49,7 @@ export function Home() {
43
49
  updateQuotePartialState,
44
50
  } = useQuoteStore();
45
51
  const [isVisibleExpanded, setIsVisibleExpanded] = useState<boolean>(false);
46
- const isMobile = useMobileDetect();
52
+ const { isLargeScreen, isExtraLargeScreen } = useScreenDetect();
47
53
 
48
54
  const { fetch: fetchQuote, loading } = useSwapInput({ refetchQuote });
49
55
  const { config, fetchStatus: fetchMetaStatus } = useAppStore();
@@ -64,9 +70,20 @@ export function Home() {
64
70
  warning: quoteWarning,
65
71
  needsToWarnEthOnPath,
66
72
  });
67
- const isExpandable = config?.variant === 'expandable' && !isMobile;
73
+
74
+ const isExpandable = isVariantExpandable(
75
+ isLargeScreen,
76
+ isExtraLargeScreen,
77
+ config?.variant
78
+ );
79
+
68
80
  const hasInputs =
69
- !!inputAmount && !!fromToken && !!toToken && inputAmount !== '0';
81
+ !!inputAmount &&
82
+ !!fromToken &&
83
+ !!toToken &&
84
+ inputAmount !== '0' &&
85
+ !isTokensIdentical(fromToken, toToken);
86
+
70
87
  const fetchingQuote = hasInputs && fetchMetaStatus === 'success' && loading;
71
88
 
72
89
  const hasValidQuotes =
@@ -99,6 +116,13 @@ export function Home() {
99
116
  }
100
117
  };
101
118
 
119
+ const onClickOnQuote = (quote: SelectedQuote) => {
120
+ if (selectedQuote?.requestId !== quote.requestId) {
121
+ setShowQuoteWarningModal(false);
122
+ setSelectedQuote(quote);
123
+ }
124
+ };
125
+
102
126
  return (
103
127
  <MainContainer>
104
128
  <Layout
@@ -200,7 +224,7 @@ export function Home() {
200
224
  {isExpandable ? (
201
225
  <ExpandedQuotes
202
226
  loading={fetchingQuote}
203
- onClickOnQuote={(quote) => setSelectedQuote(quote)}
227
+ onClickOnQuote={onClickOnQuote}
204
228
  fetch={fetchQuote}
205
229
  onClickRefresh={onClickRefresh}
206
230
  isVisible={isVisibleExpanded}
@@ -44,8 +44,7 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
44
44
  validTypes.push('DEX');
45
45
  }
46
46
  if (sourceType === 'Bridges') {
47
- validTypes.push('BRIDGE');
48
- validTypes.push('AGGREGATOR');
47
+ validTypes.push('BRIDGE', 'AGGREGATOR', 'OFF_CHAIN');
49
48
  }
50
49
 
51
50
  const liquiditySources = supportedUniqueSwappersGroups.filter((uniqueItem) =>
@@ -136,11 +135,13 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
136
135
  fetchStatus === 'success' && (
137
136
  <LiquiditySourceList disabled={campaignMode}>
138
137
  {filteredList.map((sourceItem) => {
138
+ const { groupTitle, ...otherProps } = sourceItem;
139
+
139
140
  return (
140
141
  <React.Fragment key={sourceItem.id}>
141
142
  <ListItemButton
142
143
  style={{ height: '61px' }}
143
- {...sourceItem}
144
+ {...otherProps}
144
145
  selected={false}
145
146
  hasDivider
146
147
  />
@@ -1,194 +1,21 @@
1
1
  import { i18n } from '@lingui/core';
2
- import {
3
- Alert,
4
- Button,
5
- ChevronRightIcon,
6
- Divider,
7
- InfoIcon,
8
- List,
9
- ListItemButton,
10
- Skeleton,
11
- styled,
12
- Switch,
13
- Tooltip,
14
- Typography,
15
- } from '@rango-dev/ui';
2
+ import { Alert, Button, styled } from '@rango-dev/ui';
16
3
  import React from 'react';
17
- import {
18
- useInRouterContext,
19
- useNavigate,
20
- useSearchParams,
21
- } from 'react-router-dom';
4
+ import { useInRouterContext, useSearchParams } from 'react-router-dom';
22
5
 
23
6
  import { Layout, PageContainer } from '../components/Layout';
24
7
  import { Slippage } from '../components/Slippage';
25
- import { SlippageTooltipContainer as TooltipContainer } from '../components/Slippage/Slippage.styles';
26
- import { navigationRoutes } from '../constants/navigationRoutes';
27
8
  import { SearchParams } from '../constants/searchParams';
9
+ import { SettingsLists } from '../containers/Settings/Lists';
28
10
  import { useAppStore } from '../store/AppStore';
29
- import { getContainer } from '../utils/common';
30
- import { getUniqueSwappersGroups, isFeatureHidden } from '../utils/settings';
31
11
 
32
12
  const ResetAction = styled('div', {
33
13
  paddingLeft: '$8',
34
14
  });
35
15
 
36
16
  export function SettingsPage() {
37
- const navigate = useNavigate();
38
- const { theme } = useAppStore().config;
39
- const fetchStatus = useAppStore().fetchStatus;
40
- const swappers = useAppStore().swappers();
41
- const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
42
- const {
43
- config: { features },
44
- isInCampaignMode,
45
- updateCampaignMode,
46
- } = useAppStore();
17
+ const { isInCampaignMode, updateCampaignMode } = useAppStore();
47
18
  const campaignMode = isInCampaignMode();
48
- const isThemeHidden = isFeatureHidden('theme', features);
49
-
50
- const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
51
-
52
- const isLanguageHidden = isFeatureHidden('language', features);
53
-
54
- const infiniteApprove = useAppStore().infiniteApprove;
55
- const toggleInfiniteApprove = useAppStore().toggleInfiniteApprove;
56
-
57
- const supportedUniqueSwappersGroups = getUniqueSwappersGroups(
58
- swappers,
59
- disabledLiquiditySources
60
- );
61
-
62
- const bridgeSources = supportedUniqueSwappersGroups.filter(
63
- (uniqueItem) =>
64
- uniqueItem.type === 'BRIDGE' || uniqueItem.type === 'AGGREGATOR'
65
- );
66
- const totalBridgeSources = bridgeSources.length;
67
- const totalSelectedBridgeSources = bridgeSources.filter(
68
- (uniqueItem) => uniqueItem.selected
69
- ).length;
70
-
71
- const exchangeSources = supportedUniqueSwappersGroups.filter(
72
- (uniqueItem) => uniqueItem.type === 'DEX'
73
- );
74
- const totalExchangeSources = exchangeSources.length;
75
- const totalSelectedExchangeSources = exchangeSources.filter(
76
- (uniqueItem) => uniqueItem.selected
77
- ).length;
78
-
79
- const handleEndItem = (totalSelected: number, total: number) => {
80
- switch (fetchStatus) {
81
- case 'loading':
82
- return <Skeleton variant="text" size="medium" width={50} />;
83
- case 'failed':
84
- return (
85
- <Typography variant="body" size="medium" color="$error500">
86
- {i18n.t('Loading failed')}
87
- </Typography>
88
- );
89
- default:
90
- return (
91
- <Typography variant="body" size="medium">
92
- {`${totalSelected} / ${total}`}
93
- </Typography>
94
- );
95
- }
96
- };
97
-
98
- const bridgeItem = {
99
- id: 'bridge-item',
100
- title: (
101
- <Typography variant="title" size="xmedium">
102
- {i18n.t('Enabled bridges')}
103
- </Typography>
104
- ),
105
- end: (
106
- <>
107
- {handleEndItem(totalSelectedBridgeSources, totalBridgeSources)}
108
- <Divider direction="horizontal" size={8} />
109
- <ChevronRightIcon color="black" />
110
- </>
111
- ),
112
- onClick: () => navigate(navigationRoutes.bridges),
113
- };
114
-
115
- const exchangeItem = {
116
- id: 'exchange-item',
117
- title: (
118
- <Typography variant="title" size="xmedium">
119
- {i18n.t('Enabled exchanges')}
120
- </Typography>
121
- ),
122
- end: (
123
- <>
124
- {handleEndItem(totalSelectedExchangeSources, totalExchangeSources)}
125
- <Divider direction="horizontal" size={8} />
126
- <ChevronRightIcon color="gray" />
127
- </>
128
- ),
129
- onClick: () => navigate(navigationRoutes.exchanges),
130
- };
131
-
132
- const languageItem = {
133
- id: 'language-item',
134
- title: (
135
- <Typography variant="title" size="xmedium">
136
- {i18n.t('Language')}
137
- </Typography>
138
- ),
139
- end: <ChevronRightIcon color="gray" />,
140
- onClick: () => navigate(navigationRoutes.languages),
141
- };
142
-
143
- const themeItem = {
144
- id: 'theme-item',
145
- title: (
146
- <Typography variant="title" size="xmedium">
147
- {i18n.t('Theme')}
148
- </Typography>
149
- ),
150
- end: <ChevronRightIcon color="gray" />,
151
- onClick: () => navigate(navigationRoutes.themes),
152
- };
153
-
154
- const infiniteApprovalItem = {
155
- id: 'infinite-approval-item',
156
- title: (
157
- <>
158
- <Typography variant="title" size="xmedium">
159
- {i18n.t('Infinite approval')}
160
- </Typography>
161
- <Divider direction="horizontal" size={4} />
162
- <Tooltip
163
- side="top"
164
- sideOffset={4}
165
- container={getContainer()}
166
- content={
167
- <TooltipContainer>
168
- <Typography variant="label" size="medium" color="neutral700">
169
- {i18n.t(
170
- "Enabling the 'Infinite approval' mode grants unrestricted access to smart contracts of DEXes/Bridges, allowing them to utilize the approved token amount without limitations."
171
- )}
172
- </Typography>
173
- </TooltipContainer>
174
- }>
175
- <InfoIcon color="gray" />
176
- </Tooltip>
177
- </>
178
- ),
179
- end: <Switch checked={infiniteApprove} />,
180
- onClick: toggleInfiniteApprove,
181
- };
182
-
183
- const settingItems = isLiquidityHidden ? [] : [bridgeItem, exchangeItem];
184
-
185
- if (!isLanguageHidden) {
186
- settingItems.push(languageItem);
187
- }
188
- if (!theme?.singleTheme && !isThemeHidden) {
189
- settingItems.push(themeItem);
190
- }
191
- settingItems.push(infiniteApprovalItem);
192
19
 
193
20
  const [, setSearchParams] = useSearchParams();
194
21
  const isRouterInContext = useInRouterContext();
@@ -205,7 +32,6 @@ export function SettingsPage() {
205
32
  updateCampaignMode('liquiditySources', undefined);
206
33
  }
207
34
  };
208
-
209
35
  return (
210
36
  <Layout
211
37
  header={{
@@ -222,19 +48,14 @@ export function SettingsPage() {
222
48
  action={
223
49
  <ResetAction>
224
50
  <Button type="secondary" size="small" onClick={onClick}>
225
- Reset
51
+ {i18n.t('Reset')}
226
52
  </Button>
227
53
  </ResetAction>
228
54
  }
229
55
  />
230
56
  )}
231
57
  <Slippage />
232
- <List
233
- type={
234
- <ListItemButton title="_" id="_" onClick={() => console.log()} />
235
- }
236
- items={settingItems}
237
- />
58
+ <SettingsLists />
238
59
  </PageContainer>
239
60
  </Layout>
240
61
  );
@@ -6,7 +6,7 @@ export const DEFAULT_CONFIG: WidgetConfig = {
6
6
  apiKey: '',
7
7
  title: undefined,
8
8
  multiWallets: true,
9
- enableNewLiquiditySources: true,
9
+ excludeLiquiditySources: true,
10
10
  customDestination: true,
11
11
  };
12
12
 
@@ -72,7 +72,7 @@ export const createConfigSlice: StateCreatorWithInitialData<
72
72
  const { config, campaignMode } = get();
73
73
  return campaignMode.liquiditySources?.length
74
74
  ? false
75
- : !!config.enableNewLiquiditySources;
75
+ : !!config.excludeLiquiditySources;
76
76
  },
77
77
  isInCampaignMode: () => {
78
78
  const { campaignMode } = get();
@@ -177,12 +177,12 @@ export const createDataSlice: StateCreator<
177
177
  const liquiditySources =
178
178
  campaignModeLiquiditySource ?? config.liquiditySources;
179
179
 
180
- const enableNewLiquiditySources = campaignModeLiquiditySource
180
+ const excludeLiquiditySources = campaignModeLiquiditySource
181
181
  ? false
182
- : config.enableNewLiquiditySources;
182
+ : config.excludeLiquiditySources;
183
183
 
184
184
  /*
185
- * If the enableNewLiquiditySources flag is set to true, we return all swappers that are not included in the config.
185
+ * If the excludeLiquiditySources flag is set to true, we return all swappers that are not included in the config.
186
186
  * Otherwise, we return all swappers that are included in the config.
187
187
  */
188
188
  const swappers = get()._swappers.filter((swapper) => {
@@ -191,7 +191,7 @@ export const createDataSlice: StateCreator<
191
191
  );
192
192
 
193
193
  const shouldExcludeLiquiditySources =
194
- enableNewLiquiditySources ||
194
+ excludeLiquiditySources ||
195
195
  !liquiditySources ||
196
196
  liquiditySources.length === 0;
197
197
 
@@ -207,7 +207,10 @@ export const createDataSlice: StateCreator<
207
207
  // Actions
208
208
  fetch: async () => {
209
209
  try {
210
- const response = await sdk().getAllMetadata();
210
+ const { enableCentralizedSwappers } = get().config;
211
+ const response = await sdk().getAllMetadata({
212
+ enableCentralizedSwappers,
213
+ });
211
214
 
212
215
  set({ fetchStatus: 'success' });
213
216
  const blockchains: BlockchainMeta[] = [];
@@ -160,9 +160,13 @@ export const createSettingsSlice: StateCreator<
160
160
  const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
161
161
 
162
162
  set({
163
- ...(isThemeHidden && { theme: 'auto' }),
164
- ...(isLanguageHidden && { language: DEFAULT_LANGUAGE }),
165
- ...(isLiquidityHidden && { disabledLiquiditySources: [] }),
163
+ ...(isThemeHidden && { theme: nextConfig.theme?.mode || 'auto' }),
164
+ ...(isLanguageHidden && {
165
+ language: nextConfig.language || DEFAULT_LANGUAGE,
166
+ }),
167
+ ...(isLiquidityHidden && {
168
+ disabledLiquiditySources: nextConfig.liquiditySources || [],
169
+ }),
166
170
  });
167
171
  },
168
172
  });
@@ -3,7 +3,7 @@ import type { ProviderInterface } from '@rango-dev/wallets-react';
3
3
  import type { WalletType } from '@rango-dev/wallets-shared';
4
4
  import type { Asset } from 'rango-sdk';
5
5
 
6
- export type WidgetVariant = 'default' | 'expandable';
6
+ export type WidgetVariant = 'default' | 'expanded' | 'full-expanded';
7
7
 
8
8
  /**
9
9
  * The above type defines a set of optional color properties for a widget.
@@ -171,8 +171,8 @@ export type Features = Partial<
171
171
  * that defines the various properties of the theme, such as colors, fonts, and others.
172
172
  * @property {boolean} externalWallets
173
173
  * If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
174
- * @property {boolean} enableNewLiquiditySources - The `enableNewLiquiditySources` property is a boolean value that when you
175
- * set it to true, whenever a new liquidity source is added, it will be added to your list as well.
174
+ * @property {boolean} excludeLiquiditySources - The `excludeLiquiditySources` property is a boolean value that when you
175
+ * set it to true, the list of liquidity sources provided in `liquiditySources` will be excluded; otherwise, they will be included.
176
176
  * @property {Features} features - An optional object for configuring the visibility or enablement of various features.
177
177
  * Keys include:
178
178
  * - 'notification': Visibility state for the notification icon.
@@ -182,8 +182,11 @@ export type Features = Partial<
182
182
  * - 'language': Visibility state for the language.
183
183
  * - 'experimentalRoute': Enablement state for the experimental route.
184
184
  * @property {WidgetVariant} variant
185
- * If it is expandable, multiple routes will show up on the home page;
185
+ * If it is expanded, multiple routes will show up on the home page;
186
+ * If it is full-expanded, multiple routes will show up on the home page with full routes;
186
187
  * if not, you will need to go to a different page to see the suggested routes.
188
+ * @property {boolean} enableCentralizedSwappers
189
+ * If you want to enable routing from the centralized protocols like XO Swap, you could set this parameter to true.
187
190
  */
188
191
 
189
192
  export type WidgetConfig = {
@@ -202,7 +205,8 @@ export type WidgetConfig = {
202
205
  language?: Language;
203
206
  theme?: WidgetTheme;
204
207
  externalWallets?: boolean;
205
- enableNewLiquiditySources?: boolean;
208
+ excludeLiquiditySources?: boolean;
206
209
  features?: Features;
207
210
  variant?: WidgetVariant;
211
+ enableCentralizedSwappers?: boolean;
208
212
  };