@rango-dev/widget-embedded 0.1.10 → 0.1.11-next.10

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 (88) hide show
  1. package/dist/App.d.ts +3 -3
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/QueueManager.d.ts.map +1 -1
  4. package/dist/components/AppRouter.d.ts +1 -7
  5. package/dist/components/AppRouter.d.ts.map +1 -1
  6. package/dist/components/AppRoutes.d.ts +2 -2
  7. package/dist/components/AppRoutes.d.ts.map +1 -1
  8. package/dist/components/Layout.d.ts +3 -3
  9. package/dist/components/Layout.d.ts.map +1 -1
  10. package/dist/components/PercentageChange.d.ts +9 -0
  11. package/dist/components/PercentageChange.d.ts.map +1 -0
  12. package/dist/components/TokenInfo.d.ts.map +1 -1
  13. package/dist/components/TokenPreview.d.ts +2 -1
  14. package/dist/components/TokenPreview.d.ts.map +1 -1
  15. package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
  16. package/dist/hooks/useTheme.d.ts +2 -5
  17. package/dist/hooks/useTheme.d.ts.map +1 -1
  18. package/dist/lib.d.ts +2 -2
  19. package/dist/lib.d.ts.map +1 -1
  20. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  21. package/dist/pages/Home.d.ts +1 -7
  22. package/dist/pages/Home.d.ts.map +1 -1
  23. package/dist/pages/LiquiditySourcesPage.d.ts +1 -2
  24. package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
  25. package/dist/pages/SelectChainPage.d.ts +1 -2
  26. package/dist/pages/SelectChainPage.d.ts.map +1 -1
  27. package/dist/pages/SelectTokenPage.d.ts +2 -2
  28. package/dist/pages/SelectTokenPage.d.ts.map +1 -1
  29. package/dist/pages/SettingsPage.d.ts +1 -2
  30. package/dist/pages/SettingsPage.d.ts.map +1 -1
  31. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  32. package/dist/pages/WalletsPage.d.ts +1 -1
  33. package/dist/pages/WalletsPage.d.ts.map +1 -1
  34. package/dist/services/httpService.d.ts +2 -1
  35. package/dist/services/httpService.d.ts.map +1 -1
  36. package/dist/store/bestRoute.d.ts +1 -0
  37. package/dist/store/bestRoute.d.ts.map +1 -1
  38. package/dist/store/meta.d.ts.map +1 -1
  39. package/dist/store/settings.d.ts +2 -0
  40. package/dist/store/settings.d.ts.map +1 -1
  41. package/dist/types/config.d.ts +27 -29
  42. package/dist/types/config.d.ts.map +1 -1
  43. package/dist/types/routing.d.ts +14 -1
  44. package/dist/types/routing.d.ts.map +1 -1
  45. package/dist/utils/configs.d.ts +7 -0
  46. package/dist/utils/configs.d.ts.map +1 -0
  47. package/dist/utils/routing.d.ts +2 -2
  48. package/dist/utils/routing.d.ts.map +1 -1
  49. package/dist/utils/swap.d.ts +2 -6
  50. package/dist/utils/swap.d.ts.map +1 -1
  51. package/dist/widget-embedded.cjs.development.js +232 -223
  52. package/dist/widget-embedded.cjs.development.js.map +1 -1
  53. package/dist/widget-embedded.cjs.production.min.js +232 -223
  54. package/dist/widget-embedded.cjs.production.min.js.map +1 -1
  55. package/dist/widget-embedded.esm.js +232 -223
  56. package/dist/widget-embedded.esm.js.map +1 -1
  57. package/package.json +6 -4
  58. package/readme.md +1 -1
  59. package/src/App.tsx +36 -14
  60. package/src/QueueManager.tsx +9 -3
  61. package/src/components/AppRouter.tsx +7 -16
  62. package/src/components/AppRoutes.tsx +13 -32
  63. package/src/components/HeaderButtons.tsx +1 -1
  64. package/src/components/Layout.tsx +37 -27
  65. package/src/components/PercentageChange.tsx +33 -0
  66. package/src/components/TokenInfo.tsx +24 -12
  67. package/src/components/TokenPreview.tsx +19 -15
  68. package/src/hooks/useConfirmSwap.ts +6 -5
  69. package/src/hooks/useTheme.ts +21 -9
  70. package/src/lib.tsx +30 -36
  71. package/src/pages/ConfirmSwapPage.tsx +14 -7
  72. package/src/pages/Home.tsx +10 -22
  73. package/src/pages/LiquiditySourcesPage.tsx +3 -6
  74. package/src/pages/SelectChainPage.tsx +6 -6
  75. package/src/pages/SelectTokenPage.tsx +16 -18
  76. package/src/pages/SettingsPage.tsx +8 -18
  77. package/src/pages/SwapDetailsPage.tsx +2 -4
  78. package/src/pages/WalletsPage.tsx +2 -2
  79. package/src/services/httpService.ts +12 -3
  80. package/src/store/bestRoute.ts +39 -9
  81. package/src/store/meta.ts +6 -4
  82. package/src/store/settings.ts +7 -0
  83. package/src/store/wallets.ts +1 -1
  84. package/src/types/config.ts +28 -29
  85. package/src/types/routing.ts +17 -1
  86. package/src/utils/configs.ts +24 -0
  87. package/src/utils/routing.ts +29 -23
  88. package/src/utils/swap.ts +5 -97
@@ -12,7 +12,6 @@ import {
12
12
  } from '../types';
13
13
  import { PendingSwap } from '@rango-dev/ui/dist/containers/History/types';
14
14
  import {
15
- calculatePendingSwap,
16
15
  createBestRouteRequestBody,
17
16
  getBalanceWarnings,
18
17
  getMinRequiredSlippage,
@@ -34,6 +33,7 @@ import {
34
33
  } from '../utils/routing';
35
34
  import { numberToString } from '../utils/numbers';
36
35
  import { BestRouteResponse } from 'rango-sdk';
36
+ import { calculatePendingSwap } from '@rango-dev/queue-manager-rango-preset';
37
37
 
38
38
  type ConfirmSwap = {
39
39
  loading: boolean;
@@ -49,6 +49,8 @@ export function useConfirmSwap(): ConfirmSwap {
49
49
  const initialRoute = useBestRouteStore.use.bestRoute();
50
50
  const setBestRoute = useBestRouteStore.use.setBestRoute();
51
51
  const inputUsdValue = useBestRouteStore.use.inputUsdValue();
52
+ const affiliateRef = useSettingsStore.use.affiliateRef();
53
+
52
54
  const accounts = useWalletsStore.use.accounts();
53
55
  const selectedWallets = useWalletsStore.use.selectedWallets();
54
56
  const meta = useMetaStore.use.meta();
@@ -93,7 +95,6 @@ export function useConfirmSwap(): ConfirmSwap {
93
95
  meta
94
96
  );
95
97
 
96
- //@ts-ignore
97
98
  return newSwap;
98
99
  }
99
100
  return;
@@ -111,11 +112,12 @@ export function useConfirmSwap(): ConfirmSwap {
111
112
  selectedWallets,
112
113
  disabledLiquiditySources,
113
114
  userSlippage,
114
- true
115
+ true,
116
+ affiliateRef
115
117
  );
116
118
 
117
119
  try {
118
- const confiremedRoute = await httpService.getBestRoute(requestBody, {
120
+ const confiremedRoute = await httpService().getBestRoute(requestBody, {
119
121
  signal: abortControllerRef.current?.signal,
120
122
  });
121
123
 
@@ -229,7 +231,6 @@ export function useConfirmSwap(): ConfirmSwap {
229
231
  false,
230
232
  meta
231
233
  );
232
- //@ts-ignore
233
234
  return newSwap;
234
235
  } else if (!proceedAnywayRef.current) {
235
236
  proceedAnywayRef.current = true;
@@ -2,22 +2,26 @@ import { createTheme } from '@rango-dev/ui';
2
2
  import { useState, useEffect, useLayoutEffect } from 'react';
3
3
  import { useMetaStore } from '../store/meta';
4
4
  import { useSettingsStore } from '../store/settings';
5
- import { Colors } from '../types';
5
+ import { Theme } from '../types';
6
6
  import { shadeColor } from '../utils/common';
7
7
  import usePrevious from './usePrevious';
8
8
 
9
9
  export function useTheme({
10
- primary = '#5FA425',
11
- background = '#fff',
12
- foreground = '#000',
13
- error = '#FF0000',
14
- warning = '#F5A623',
15
- success = '#0070F3',
10
+ colors: themeColors,
16
11
  fontFamily = 'Robot',
17
12
  borderRadius = 8,
18
- }: Colors & { borderRadius?: number; fontFamily?: string }) {
13
+ mode = 'auto',
14
+ }: Theme) {
19
15
  const theme = useSettingsStore.use.theme();
20
16
  const fetchMeta = useMetaStore.use.fetchMeta();
17
+ const setTheme = useSettingsStore.use.setTheme();
18
+
19
+ const primary = themeColors?.primary || '#5FA425',
20
+ background = themeColors?.background || '#fff',
21
+ foreground = themeColors?.foreground || '#000',
22
+ error = themeColors?.error || '#FF0000',
23
+ warning = themeColors?.warning || '#F5A623',
24
+ success = themeColors?.success || '#0070F3';
21
25
  const colors = {
22
26
  neutrals200: '#FAFAFA',
23
27
  neutrals300: '#f2f2f2',
@@ -61,6 +65,9 @@ export function useTheme({
61
65
  radii: {
62
66
  5: `${borderRadius}px`,
63
67
  },
68
+ shadows: {
69
+ s: '0px 3px 5px 3px #f0f2f5, 0px 6px 10px 3px #f0f2f5, 0px 1px 18px 3px #f0f2f5',
70
+ },
64
71
  });
65
72
 
66
73
  const customeDarkTheme = createTheme({
@@ -80,6 +87,9 @@ export function useTheme({
80
87
  radii: {
81
88
  5: `${borderRadius}px`,
82
89
  },
90
+ shadows: {
91
+ s: '0px 3px 5px 3px #222, 0px 6px 10px 3px #222, 0px 1px 18px 3px #222',
92
+ },
83
93
  });
84
94
  const [OSTheme, setOSTheme] = useState(customeLightTheme);
85
95
  useEffect(() => {
@@ -108,7 +118,9 @@ export function useTheme({
108
118
  .removeEventListener('change', switchTheme);
109
119
  };
110
120
  }, []);
111
-
121
+ useEffect(() => {
122
+ if (mode !== 'auto') setTheme(mode);
123
+ }, [mode]);
112
124
  const prevFont = usePrevious(fontFamily);
113
125
 
114
126
  useLayoutEffect(() => {
package/src/lib.tsx CHANGED
@@ -15,35 +15,31 @@ import { Layout } from './components/Layout';
15
15
  import { globalFont, globalStyles } from './globalStyles';
16
16
  import { useTheme } from './hooks/useTheme';
17
17
  import { isEvmBlockchain } from 'rango-sdk';
18
- import { Configs } from './types';
19
- import { useSettingsStore } from './store/settings';
18
+ import { WidgetConfig } from './types';
20
19
  import useSelectLanguage from './hooks/useSelectLanguage';
21
20
  import './i18n';
22
21
  import QueueManager from './QueueManager';
22
+ import { useUiStore } from './store/ui';
23
+ import { navigationRoutes } from './constants/navigationRoutes';
23
24
 
24
25
  export type WidgetProps = {
25
- configs: Configs;
26
+ config?: WidgetConfig;
26
27
  };
27
28
 
28
- export const SwapBox: React.FC<WidgetProps> = ({ configs }) => {
29
+ export const SwapBox: React.FC<WidgetProps> = ({ config }) => {
29
30
  globalStyles();
30
- globalFont(configs?.fontFamily || 'Roboto');
31
+ globalFont(config?.theme?.fontFamily || 'Roboto');
31
32
 
32
- const { activeTheme } = useTheme({
33
- ...configs.colors,
34
- borderRadius: configs?.borderRadius,
35
- fontFamily: configs?.fontFamily,
36
- });
33
+ const { activeTheme } = useTheme({ ...config?.theme });
37
34
  const { blockchains } = useMetaStore.use.meta();
38
35
  const disconnectWallet = useWalletsStore.use.disconnectWallet();
39
36
  const connectWallet = useWalletsStore.use.connectWallet();
40
- const setTheme = useSettingsStore.use.setTheme();
41
37
  const { changeLanguage } = useSelectLanguage();
42
38
  const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
43
-
44
39
  const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
45
40
  useState<string>('');
46
41
  const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
42
+ const currentPage = useUiStore.use.currentPage();
47
43
 
48
44
  const evmBasedChainNames = blockchains
49
45
  .filter(isEvmBlockchain)
@@ -71,7 +67,6 @@ export const SwapBox: React.FC<WidgetProps> = ({ configs }) => {
71
67
  disconnectWallet(type);
72
68
  }
73
69
  }
74
-
75
70
  if (event === Events.ACCOUNTS && state.connected) {
76
71
  const key = `${type}-${state.network}-${value}`;
77
72
 
@@ -88,24 +83,19 @@ export const SwapBox: React.FC<WidgetProps> = ({ configs }) => {
88
83
  let providers = allProviders();
89
84
 
90
85
  useEffect(() => {
91
- if (configs.theme !== 'auto') setTheme(configs.theme);
92
- }, [configs.theme]);
93
-
94
- useEffect(() => {
95
- const wallets = configs.wallets;
86
+ const wallets = config?.wallets;
96
87
  clearConnectedWallet();
97
- providers =
98
- wallets === 'all'
99
- ? allProviders()
100
- : allProviders().filter((provider) => {
101
- const type = provider.config.type;
102
- return wallets.find((w) => w === type);
103
- });
104
- }, [configs?.wallets]);
88
+ providers = !wallets
89
+ ? allProviders()
90
+ : allProviders().filter((provider) => {
91
+ const type = provider.config.type;
92
+ return wallets.find((w) => w === type);
93
+ });
94
+ }, [config?.wallets]);
105
95
 
106
96
  useEffect(() => {
107
- changeLanguage(configs?.languege);
108
- }, [configs?.languege]);
97
+ changeLanguage(config?.language || 'en');
98
+ }, [config?.language]);
109
99
 
110
100
  return (
111
101
  <Provider
@@ -116,22 +106,26 @@ export const SwapBox: React.FC<WidgetProps> = ({ configs }) => {
116
106
  <div id="pageContainer" className={activeTheme}>
117
107
  <QueueManager>
118
108
  <SwapContainer
119
- style={{
120
- width: configs?.width || 'auto',
121
- height: configs?.height || 'auto',
122
- }}
109
+ fixedHeight={currentPage !== navigationRoutes.home}
110
+ // style={
111
+ // currentPage !== navigationRoutes.home && config?.theme?.height
112
+ // ? {
113
+ // height: config?.theme?.height,
114
+ // width: config?.theme?.width || 'auto',
115
+ // }
116
+ // : {
117
+ // width: config?.theme?.width || 'auto',
118
+ // }
119
+ // }
123
120
  >
124
121
  <AppRouter
125
- title={configs.title}
126
- titleSize={configs.titleSize}
127
- titleWeight={configs.titleWeight}
128
122
  lastConnectedWallet={lastConnectedWalletWithNetwork}
129
123
  disconnectedWallet={disconnectedWallet}
130
124
  clearDisconnectedWallet={() => {
131
125
  setDisconnectedWallet(undefined);
132
126
  }}
133
127
  >
134
- <Layout configs={configs} />
128
+ <Layout config={config} />
135
129
  </AppRouter>
136
130
  </SwapContainer>
137
131
  </QueueManager>
@@ -10,11 +10,7 @@ import {
10
10
  getSelectableWallets,
11
11
  isExperimentalChain,
12
12
  } from '../utils/wallets';
13
- import {
14
- calcOutputUsdValue,
15
- getTotalFeeInUsd,
16
- requiredWallets,
17
- } from '../utils/swap';
13
+ import { getTotalFeeInUsd, requiredWallets } from '../utils/swap';
18
14
  import { decimalNumber, numberToString } from '../utils/numbers';
19
15
  import { useMetaStore } from '../store/meta';
20
16
  import { Network, WalletType } from '@rango-dev/wallets-shared';
@@ -33,6 +29,7 @@ import { ConfirmSwapErrors } from '../components/ConfirmSwapErrors';
33
29
  import { ConfirmSwapWarnings } from '../components/ConfirmSwapWarnings';
34
30
  import { ConfirmSwapExtraMessages } from '../components/warnings/ConfirmSwapExtraMessages';
35
31
  import { getBestRouteStatus } from '../utils/routing';
32
+ import { PercentageChange } from '../components/PercentageChange';
36
33
 
37
34
  export function ConfirmSwapPage() {
38
35
  const navigate = useNavigate();
@@ -48,6 +45,8 @@ export function ConfirmSwapPage() {
48
45
  const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
49
46
  const slippage = useSettingsStore.use.slippage();
50
47
  const customSlippage = useSettingsStore.use.customSlippage();
48
+ const inputUsdValue = useBestRouteStore.use.inputUsdValue();
49
+ const outputUsdValue = useBestRouteStore.use.outputUsdValue();
51
50
 
52
51
  const bestRouteloadingStatus = getBestRouteStatus(
53
52
  fetchingBestRoute,
@@ -97,6 +96,7 @@ export function ConfirmSwapPage() {
97
96
 
98
97
  return (
99
98
  <ConfirmSwap
99
+ // @ts-ignore
100
100
  requiredWallets={getRequiredChains(bestRoute)}
101
101
  selectableWallets={selectableWallets}
102
102
  onBack={navigateBackFrom.bind(null, navigationRoutes.confirmSwap)}
@@ -106,6 +106,7 @@ export function ConfirmSwapPage() {
106
106
  manager?.create(
107
107
  'swap',
108
108
  { swapDetails: swap },
109
+ // @ts-ignore
109
110
  { id: swap.requestId }
110
111
  );
111
112
  setSelectedSwap(swap.requestId);
@@ -134,7 +135,7 @@ export function ConfirmSwapPage() {
134
135
  symbol: firstStep?.from.symbol || '',
135
136
  image: firstStep?.from.logo || '',
136
137
  }}
137
- usdValue={calcOutputUsdValue(fromAmount, firstStep?.from.usdPrice)}
138
+ usdValue={inputUsdValue}
138
139
  amount={fromAmount}
139
140
  label={t('From')}
140
141
  loadingStatus={bestRouteloadingStatus}
@@ -149,10 +150,16 @@ export function ConfirmSwapPage() {
149
150
  symbol: lastStep?.to.symbol || '',
150
151
  image: lastStep?.to.logo || '',
151
152
  }}
152
- usdValue={calcOutputUsdValue(toAmount, lastStep?.to.usdPrice)}
153
+ usdValue={outputUsdValue}
153
154
  amount={toAmount}
154
155
  label={t('To')}
155
156
  loadingStatus={bestRouteloadingStatus}
157
+ percentageChange={
158
+ <PercentageChange
159
+ inputUsdValue={inputUsdValue}
160
+ outputUsdValue={outputUsdValue}
161
+ />
162
+ }
156
163
  />
157
164
  </>
158
165
  }
@@ -63,14 +63,8 @@ const Alerts = styled('div', {
63
63
  width: '100%',
64
64
  paddingTop: '$16',
65
65
  });
66
- interface PropTypes {
67
- title?: string;
68
- titleSize?: number;
69
- titleWeight?: number;
70
- }
71
- export function Home(props: PropTypes) {
72
- const { title = 'SWAP' } = props;
73
66
 
67
+ export function Home() {
74
68
  const isRouterInContext = useInRouterContext();
75
69
  const navigate = useNavigate();
76
70
  const [count, setCount] = useState(0);
@@ -78,10 +72,6 @@ export function Home(props: PropTypes) {
78
72
  const fromToken = useBestRouteStore.use.fromToken();
79
73
  const toChain = useBestRouteStore.use.toChain();
80
74
  const toToken = useBestRouteStore.use.toToken();
81
- const setFromChain = useBestRouteStore.use.setFromChain();
82
- const setFromToken = useBestRouteStore.use.setFromToken();
83
- const setToChain = useBestRouteStore.use.setToChain();
84
- const setToToken = useBestRouteStore.use.setToToken();
85
75
  const setInputAmount = useBestRouteStore.use.setInputAmount();
86
76
  const inputUsdValue = useBestRouteStore.use.inputUsdValue();
87
77
  const inputAmount = useBestRouteStore.use.inputAmount();
@@ -94,15 +84,7 @@ export function Home(props: PropTypes) {
94
84
  const loadingMetaStatus = useMetaStore.use.loadingStatus();
95
85
  const accounts = useWalletsStore.use.accounts();
96
86
  const setCurrentPage = useUiStore.use.setCurrentPage();
97
-
98
- const swithFromAndTo = () => {
99
- setFromChain(toChain);
100
- setFromToken(toToken);
101
- setToChain(fromChain);
102
- setToToken(fromToken);
103
- setInputAmount(outputAmount?.toString() || '');
104
- setCount((prev) => prev + 1);
105
- };
87
+ const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
106
88
 
107
89
  const errorMessage =
108
90
  loadingMetaStatus === 'failed'
@@ -154,7 +136,7 @@ export function Home(props: PropTypes) {
154
136
  return (
155
137
  <Container>
156
138
  <Header
157
- title={title}
139
+ title="SWAP"
158
140
  suffix={
159
141
  <HeaderButtons
160
142
  onClickRefresh={!!bestRoute ? fetchBestRoute : undefined}
@@ -170,7 +152,13 @@ export function Home(props: PropTypes) {
170
152
  inputAmount={inputAmount}
171
153
  />
172
154
  <SwitchButtonContainer>
173
- <Button variant="ghost" onClick={swithFromAndTo}>
155
+ <Button
156
+ variant="ghost"
157
+ onClick={() => {
158
+ switchFromAndTo();
159
+ setCount((prev) => prev + 1);
160
+ }}
161
+ >
174
162
  <VerticalSwapIcon size={32} />
175
163
  {isRouterInContext && <SwithFromAndTo count={count} />}
176
164
  </Button>
@@ -4,10 +4,9 @@ import { navigationRoutes } from '../constants/navigationRoutes';
4
4
  import { useNavigateBack } from '../hooks/useNavigateBack';
5
5
  import { useMetaStore } from '../store/meta';
6
6
  import { useSettingsStore } from '../store/settings';
7
- import { Source } from '../types';
8
7
  import { removeDuplicateFrom } from '../utils/common';
9
8
  interface PropTypes {
10
- supportedSwappers: 'all' | Source[];
9
+ supportedSwappers?: string[];
11
10
  }
12
11
  export function LiquiditySourcePage({ supportedSwappers }: PropTypes) {
13
12
  const swappers = useMetaStore.use.meta().swappers;
@@ -47,12 +46,10 @@ export function LiquiditySourcePage({ supportedSwappers }: PropTypes) {
47
46
  <LiquiditySourcesSelector
48
47
  toggleAll={toggleAllLiquiditySources}
49
48
  list={
50
- supportedSwappers !== 'all'
49
+ supportedSwappers
51
50
  ? uniqueSwappersGroups.filter(
52
51
  (item) =>
53
- supportedSwappers.filter(
54
- (s) => s.title === item.title && s.type === item.type
55
- ).length > 0
52
+ supportedSwappers.filter((s) => s === item.title).length > 0
56
53
  )
57
54
  : uniqueSwappersGroups
58
55
  }
@@ -4,19 +4,19 @@ import { useBestRouteStore } from '../store/bestRoute';
4
4
  import { useMetaStore } from '../store/meta';
5
5
  import { useNavigateBack } from '../hooks/useNavigateBack';
6
6
  import { navigationRoutes } from '../constants/navigationRoutes';
7
- import { BlockchainMeta } from 'rango-sdk';
8
7
 
9
8
  interface PropTypes {
10
9
  type: 'from' | 'to';
11
- supportedChains: 'all' | BlockchainMeta[];
10
+ supportedChains?: string[];
12
11
  }
13
12
 
14
13
  export function SelectChainPage(props: PropTypes) {
15
14
  const { type, supportedChains } = props;
16
- const blockchains =
17
- supportedChains === 'all'
18
- ? useMetaStore.use.meta().blockchains
19
- : supportedChains;
15
+ const blockchains = supportedChains
16
+ ? useMetaStore.use
17
+ .meta()
18
+ .blockchains.filter((chain) => supportedChains.includes(chain.name))
19
+ : useMetaStore.use.meta().blockchains;
20
20
  const loadingStatus = useMetaStore.use.loadingStatus();
21
21
  const fromChain = useBestRouteStore.use.fromChain();
22
22
  const toChain = useBestRouteStore.use.toChain();
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TokenSelector } from '@rango-dev/ui';
3
3
  import { useBestRouteStore } from '../store/bestRoute';
4
- import { Token } from 'rango-sdk';
4
+ import { Asset, Token } from 'rango-sdk';
5
5
  import { useNavigateBack } from '../hooks/useNavigateBack';
6
6
  import { navigationRoutes } from '../constants/navigationRoutes';
7
7
  import { tokensAreEqual } from '../utils/wallets';
@@ -9,7 +9,7 @@ import { useMetaStore } from '../store/meta';
9
9
 
10
10
  interface PropTypes {
11
11
  type: 'from' | 'to';
12
- supportedTokens: 'all' | Token[];
12
+ supportedTokens?: Asset[];
13
13
  }
14
14
 
15
15
  export interface TokenWithBalance extends Token {
@@ -25,23 +25,21 @@ export function SelectTokenPage(props: PropTypes) {
25
25
  const { type, supportedTokens } = props;
26
26
  const sourceTokens = useBestRouteStore.use.sourceTokens();
27
27
  const destinationTokens = useBestRouteStore.use.destinationTokens();
28
- const supportedSourceTokens =
29
- supportedTokens === 'all'
30
- ? sourceTokens
31
- : sourceTokens.filter((token) =>
32
- supportedTokens.some((supportedToken) =>
33
- tokensAreEqual(supportedToken, token)
34
- )
35
- );
28
+ const supportedSourceTokens = supportedTokens
29
+ ? sourceTokens.filter((token) =>
30
+ supportedTokens.some((supportedToken) =>
31
+ tokensAreEqual(supportedToken, token)
32
+ )
33
+ )
34
+ : sourceTokens;
36
35
 
37
- const supportedDestinationTokens =
38
- supportedTokens === 'all'
39
- ? destinationTokens
40
- : destinationTokens.filter((token) =>
41
- supportedTokens.some((supportedToken) =>
42
- tokensAreEqual(supportedToken, token)
43
- )
44
- );
36
+ const supportedDestinationTokens = supportedTokens
37
+ ? destinationTokens.filter((token) =>
38
+ supportedTokens.some((supportedToken) =>
39
+ tokensAreEqual(supportedToken, token)
40
+ )
41
+ )
42
+ : destinationTokens;
45
43
 
46
44
  const fromToken = useBestRouteStore.use.fromToken();
47
45
  const toToken = useBestRouteStore.use.toToken();
@@ -5,7 +5,6 @@ import { useMetaStore } from '../store/meta';
5
5
  import { useNavigate } from 'react-router-dom';
6
6
  import { navigationRoutes } from '../constants/navigationRoutes';
7
7
  import { removeDuplicateFrom } from '../utils/common';
8
- import { Source } from '../types';
9
8
  import {
10
9
  MAX_SLIPPAGE,
11
10
  MIN_SLIPPGAE,
@@ -13,7 +12,7 @@ import {
13
12
  } from '../constants/swapSettings';
14
13
  import { useNavigateBack } from '../hooks/useNavigateBack';
15
14
  interface PropTypes {
16
- supportedSwappers: 'all' | Source[];
15
+ supportedSwappers?: string[];
17
16
  }
18
17
  export function SettingsPage({ supportedSwappers }: PropTypes) {
19
18
  const slippage = useSettingsStore.use.slippage();
@@ -45,8 +44,6 @@ export function SettingsPage({ supportedSwappers }: PropTypes) {
45
44
  .find((s) => {
46
45
  if (s) {
47
46
  for (const type of s.types) {
48
- if (supportedSwappers !== 'all') {
49
- }
50
47
  uniqueSwappersGroups.push({
51
48
  title: s.swapperGroup,
52
49
  logo: s.logo,
@@ -56,23 +53,16 @@ export function SettingsPage({ supportedSwappers }: PropTypes) {
56
53
  }
57
54
  }
58
55
  });
59
- supportedSwappers !== 'all' &&
56
+ supportedSwappers &&
60
57
  uniqueSwappersGroups.filter(
61
- (item) =>
62
- supportedSwappers.filter(
63
- (s) => s.title === item.title && s.type === item.type
64
- ).length > 0
58
+ (item) => supportedSwappers.filter((s) => s === item.title).length > 0
65
59
  );
66
60
 
67
- const supportedUniqueSwappersGroups =
68
- supportedSwappers !== 'all'
69
- ? uniqueSwappersGroups.filter(
70
- (item) =>
71
- supportedSwappers.filter(
72
- (s) => s.title === item.title && s.type === item.type
73
- ).length > 0
74
- )
75
- : uniqueSwappersGroups;
61
+ const supportedUniqueSwappersGroups = supportedSwappers
62
+ ? uniqueSwappersGroups.filter(
63
+ (item) => supportedSwappers.filter((s) => s === item.title).length > 0
64
+ )
65
+ : uniqueSwappersGroups;
76
66
 
77
67
  return (
78
68
  <Settings
@@ -4,7 +4,7 @@ import useCopyToClipboard from '../hooks/useCopyToClipboard';
4
4
  import { useManager } from '@rango-dev/queue-manager-react';
5
5
  import { useNavigateBack } from '../hooks/useNavigateBack';
6
6
  import { getPendingSwaps } from '../utils/queue';
7
- import { SwapHistory } from '@rango-dev/ui';
7
+ import { SwapHistory, Spacer } from '@rango-dev/ui';
8
8
  import { useUiStore } from '../store/ui';
9
9
  import {
10
10
  cancelSwap,
@@ -26,7 +26,6 @@ import {
26
26
  shouldRetrySwap,
27
27
  } from '../utils/swap';
28
28
  import { TokenPreview } from '../components/TokenPreview';
29
- import { Spacer } from '@rango-dev/ui';
30
29
  import { numberToString } from '../utils/numbers';
31
30
  //@ts-ignore
32
31
  import { t } from 'i18next';
@@ -127,7 +126,7 @@ export function SwapDetailsPage() {
127
126
  <TokenPreview
128
127
  chain={{
129
128
  displayName: lastStep?.toBlockchain || '',
130
- // @ts-ignore
129
+ //@ts-ignore
131
130
  logo: lastStep?.toBlockchainLogo || '',
132
131
  }}
133
132
  token={{
@@ -141,7 +140,6 @@ export function SwapDetailsPage() {
141
140
  </>
142
141
  }
143
142
  //todo: move PendingSwap type to rango-types
144
- //@ts-ignore
145
143
  pendingSwap={swap}
146
144
  onCopy={handleCopy}
147
145
  isCopied={isCopied}
@@ -20,7 +20,7 @@ import { Spinner } from '@rango-dev/ui';
20
20
  import { LoadingFailedAlert } from '@rango-dev/ui';
21
21
 
22
22
  interface PropTypes {
23
- supportedWallets: 'all' | WalletType[];
23
+ supportedWallets?: WalletType[];
24
24
  multiWallets: boolean;
25
25
  }
26
26
 
@@ -50,7 +50,7 @@ export function WalletsPage({ supportedWallets, multiWallets }: PropTypes) {
50
50
  const wallets = getlistWallet(
51
51
  state,
52
52
  getWalletInfo,
53
- supportedWallets === 'all' ? Object.values(WalletType) : supportedWallets
53
+ supportedWallets || Object.values(WalletType)
54
54
  );
55
55
  const walletsRef = useRef<WalletInfo[]>();
56
56
 
@@ -1,5 +1,14 @@
1
1
  import { RangoClient } from 'rango-sdk';
2
+ import { getConfig } from '../utils/configs';
2
3
 
3
- export const httpService = new RangoClient(
4
- process.env.REACT_APP_API_KEY as string
5
- );
4
+ // this API key is limited and
5
+ // it is only for test purpose
6
+ export const RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
7
+
8
+ let rango: RangoClient | undefined = undefined;
9
+
10
+ export const httpService = () => {
11
+ if (rango) return rango;
12
+ rango = new RangoClient(getConfig('API_KEY'));
13
+ return rango;
14
+ };