@rango-dev/widget-embedded 0.1.11-next.0 → 0.1.11-next.5

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 (61) hide show
  1. package/dist/App.d.ts +3 -3
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/components/AppRouter.d.ts +1 -7
  4. package/dist/components/AppRouter.d.ts.map +1 -1
  5. package/dist/components/AppRoutes.d.ts +2 -2
  6. package/dist/components/AppRoutes.d.ts.map +1 -1
  7. package/dist/components/Layout.d.ts +3 -3
  8. package/dist/components/Layout.d.ts.map +1 -1
  9. package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
  10. package/dist/hooks/useTheme.d.ts +2 -5
  11. package/dist/hooks/useTheme.d.ts.map +1 -1
  12. package/dist/lib.d.ts +2 -2
  13. package/dist/lib.d.ts.map +1 -1
  14. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  15. package/dist/pages/Home.d.ts +1 -7
  16. package/dist/pages/Home.d.ts.map +1 -1
  17. package/dist/pages/LiquiditySourcesPage.d.ts +1 -2
  18. package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
  19. package/dist/pages/SelectChainPage.d.ts +1 -2
  20. package/dist/pages/SelectChainPage.d.ts.map +1 -1
  21. package/dist/pages/SelectTokenPage.d.ts +2 -2
  22. package/dist/pages/SelectTokenPage.d.ts.map +1 -1
  23. package/dist/pages/SettingsPage.d.ts +1 -2
  24. package/dist/pages/SettingsPage.d.ts.map +1 -1
  25. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  26. package/dist/pages/WalletsPage.d.ts +1 -1
  27. package/dist/pages/WalletsPage.d.ts.map +1 -1
  28. package/dist/store/bestRoute.d.ts.map +1 -1
  29. package/dist/store/settings.d.ts +2 -0
  30. package/dist/store/settings.d.ts.map +1 -1
  31. package/dist/types/config.d.ts +26 -29
  32. package/dist/types/config.d.ts.map +1 -1
  33. package/dist/utils/swap.d.ts +2 -6
  34. package/dist/utils/swap.d.ts.map +1 -1
  35. package/dist/widget-embedded.cjs.development.js +87 -159
  36. package/dist/widget-embedded.cjs.development.js.map +1 -1
  37. package/dist/widget-embedded.cjs.production.min.js +87 -159
  38. package/dist/widget-embedded.cjs.production.min.js.map +1 -1
  39. package/dist/widget-embedded.esm.js +86 -158
  40. package/dist/widget-embedded.esm.js.map +1 -1
  41. package/package.json +7 -5
  42. package/readme.md +1 -1
  43. package/src/App.tsx +21 -13
  44. package/src/components/AppRouter.tsx +7 -16
  45. package/src/components/AppRoutes.tsx +13 -32
  46. package/src/components/Layout.tsx +32 -23
  47. package/src/hooks/useConfirmSwap.ts +5 -4
  48. package/src/hooks/useTheme.ts +15 -9
  49. package/src/lib.tsx +30 -36
  50. package/src/pages/ConfirmSwapPage.tsx +2 -0
  51. package/src/pages/Home.tsx +2 -8
  52. package/src/pages/LiquiditySourcesPage.tsx +3 -6
  53. package/src/pages/SelectChainPage.tsx +6 -6
  54. package/src/pages/SelectTokenPage.tsx +16 -18
  55. package/src/pages/SettingsPage.tsx +8 -18
  56. package/src/pages/SwapDetailsPage.tsx +2 -4
  57. package/src/pages/WalletsPage.tsx +2 -2
  58. package/src/store/bestRoute.ts +3 -2
  59. package/src/store/settings.ts +7 -0
  60. package/src/types/config.ts +27 -29
  61. package/src/utils/swap.ts +3 -96
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.1.11-next.0",
3
+ "version": "0.1.11-next.5",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -10,7 +10,9 @@
10
10
  ],
11
11
  "browserslist": "> 0.5%, last 2 versions, not dead",
12
12
  "scripts": {
13
- "dev": "parcel public/index.html -p 3001 --cache-dir=.parcel-cache",
13
+ "watch-tsc": "tsc --watch --noEmit",
14
+ "parcel": "parcel public/index.html -p 3001 --cache-dir=.parcel-cache",
15
+ "dev": "npm-run-all --parallel watch-tsc parcel",
14
16
  "build:app": "parcel build --cache-dir=.parcel-cache",
15
17
  "build": "tsdx build --entry ./src/lib.tsx"
16
18
  },
@@ -27,10 +29,10 @@
27
29
  },
28
30
  "dependencies": {
29
31
  "@rango-dev/provider-all": "^0.1.11-next.84",
30
- "@rango-dev/queue-manager-core": "^0.1.10-next.82",
31
- "@rango-dev/queue-manager-rango-preset": "^0.1.10-next.102",
32
+ "@rango-dev/queue-manager-core": "^0.1.11-next.0",
33
+ "@rango-dev/queue-manager-rango-preset": "^0.1.11-next.2",
32
34
  "@rango-dev/queue-manager-react": "^0.1.10-next.76",
33
- "@rango-dev/ui": "^0.1.10-next.75",
35
+ "@rango-dev/ui": "^0.1.11-next.3",
34
36
  "@rango-dev/wallets-core": "^0.1.11-next.88",
35
37
  "@rango-dev/wallets-shared": "^0.1.11-next.84",
36
38
  "bignumber.js": "^9.1.1",
package/readme.md CHANGED
@@ -1 +1 @@
1
- # @rango-dev/widget-embedded
1
+ # @rango-dev/widget-embedded
package/src/App.tsx CHANGED
@@ -17,7 +17,7 @@ import { globalFont, globalStyles } from './globalStyles';
17
17
  import { useTheme } from './hooks/useTheme';
18
18
  import QueueManager from './QueueManager';
19
19
  import { isEvmBlockchain } from 'rango-sdk';
20
- import { Configs } from './types';
20
+ import { WidgetConfig } from './types';
21
21
  import './i18n';
22
22
  import { useUiStore } from './store/ui';
23
23
  import { navigationRoutes } from './constants/navigationRoutes';
@@ -25,16 +25,13 @@ import { navigationRoutes } from './constants/navigationRoutes';
25
25
  const providers = allProviders();
26
26
 
27
27
  export type WidgetProps = {
28
- configs?: Configs;
28
+ config?: WidgetConfig;
29
29
  };
30
30
 
31
- export function App({ configs }: WidgetProps) {
31
+ export function App({ config }: WidgetProps) {
32
32
  globalStyles();
33
- globalFont(configs?.fontFamily || 'Roboto');
34
- const { activeTheme } = useTheme({
35
- ...configs?.colors,
36
- borderRadius: configs?.borderRadius,
37
- });
33
+ globalFont(config?.theme?.fontFamily || 'Roboto');
34
+ const { activeTheme } = useTheme({ ...config?.theme });
38
35
 
39
36
  const { blockchains } = useMetaStore.use.meta();
40
37
  const disconnectWallet = useWalletsStore.use.disconnectWallet();
@@ -95,18 +92,29 @@ export function App({ configs }: WidgetProps) {
95
92
  >
96
93
  <div id="pageContainer" className={activeTheme}>
97
94
  <QueueManager>
98
- <SwapContainer fixedHeight={currentPage != navigationRoutes.home}>
95
+ <SwapContainer
96
+ // style={
97
+ // currentPage !== navigationRoutes.home && config?.theme?.height
98
+ // ? {
99
+ // height: config?.theme?.height,
100
+ // width: config?.theme?.width || 'auto',
101
+ // }
102
+ // : config?.theme?.width
103
+ // ? {
104
+ // width: config?.theme?.width || 'auto',
105
+ // }
106
+ // : undefined
107
+ // }
108
+ fixedHeight={currentPage !== navigationRoutes.home}
109
+ >
99
110
  <AppRouter
100
- title={configs?.title}
101
- titleSize={configs?.titleSize}
102
- titleWeight={configs?.titleWeight}
103
111
  lastConnectedWallet={lastConnectedWalletWithNetwork}
104
112
  disconnectedWallet={disconnectedWallet}
105
113
  clearDisconnectedWallet={() => {
106
114
  setDisconnectedWallet(undefined);
107
115
  }}
108
116
  >
109
- <Layout configs={configs} />
117
+ <Layout config={config} />
110
118
  </AppRouter>
111
119
  </SwapContainer>
112
120
  </QueueManager>
@@ -13,15 +13,7 @@ import { UpdateUrl } from './UpdateUrl';
13
13
  import { Home } from '../pages/Home';
14
14
  import { useMetaStore } from '../store/meta';
15
15
 
16
- interface PropTypes {
17
- title?: string;
18
- titleSize?: number;
19
- titleWeight?: number;
20
- }
21
- const Route: React.FC = ({
22
- children,
23
- ...props
24
- }: PropTypes & PropsWithChildren) => {
16
+ const Route: React.FC = ({ children }: PropsWithChildren) => {
25
17
  const location = useLocation();
26
18
  const navigate = useNavigate();
27
19
  const ref = useRef(true);
@@ -34,7 +26,7 @@ const Route: React.FC = ({
34
26
  }, []);
35
27
 
36
28
  if (location.pathname === navigationRoutes.confirmSwap && ref.current)
37
- return <Home {...props} />;
29
+ return <Home />;
38
30
 
39
31
  return <> {children}</>;
40
32
  };
@@ -42,12 +34,11 @@ const Route: React.FC = ({
42
34
  export function AppRouter({
43
35
  children,
44
36
  ...props
45
- }: PropTypes &
46
- PropsWithChildren & {
47
- lastConnectedWallet: string;
48
- disconnectedWallet: WalletType | undefined;
49
- clearDisconnectedWallet: () => void;
50
- }) {
37
+ }: PropsWithChildren & {
38
+ lastConnectedWallet: string;
39
+ disconnectedWallet: WalletType | undefined;
40
+ clearDisconnectedWallet: () => void;
41
+ }) {
51
42
  const isRouterInContext = useInRouterContext();
52
43
  const Router = isRouterInContext ? Route : MemoryRouter;
53
44
  const { blockchains } = useMetaStore.use.meta();
@@ -10,76 +10,57 @@ import { SelectTokenPage } from '../pages/SelectTokenPage';
10
10
  import { SettingsPage } from '../pages/SettingsPage';
11
11
  import { WalletsPage } from '../pages/WalletsPage';
12
12
  import { SwapDetailsPage } from '../pages/SwapDetailsPage';
13
- import { Configs } from '../types';
13
+ import { WidgetConfig } from '../types';
14
14
 
15
15
  const getAbsolutePath = (path: string) => path.replace('/', '');
16
16
 
17
17
  interface PropTypes {
18
- configs?: Configs;
18
+ config?: WidgetConfig;
19
19
  }
20
20
 
21
21
  export function AppRoutes(props: PropTypes) {
22
- const { configs } = props;
22
+ const { config } = props;
23
23
 
24
24
  return useRoutes([
25
25
  {
26
26
  path: getAbsolutePath(navigationRoutes.home),
27
- element: (
28
- <Home
29
- title={configs?.title}
30
- titleSize={configs?.titleSize}
31
- titleWeight={configs?.titleWeight}
32
- />
33
- ),
27
+ element: <Home />,
34
28
  },
35
29
  {
36
30
  path: getAbsolutePath(navigationRoutes.fromChain),
37
31
  element: (
38
32
  <SelectChainPage
39
33
  type="from"
40
- supportedChains={configs?.fromChains || 'all'}
34
+ supportedChains={config?.from?.blockchains}
41
35
  />
42
36
  ),
43
37
  },
44
38
  {
45
39
  path: getAbsolutePath(navigationRoutes.toChain),
46
40
  element: (
47
- <SelectChainPage
48
- type="to"
49
- supportedChains={configs?.toChains || 'all'}
50
- />
41
+ <SelectChainPage type="to" supportedChains={config?.to?.blockchains} />
51
42
  ),
52
43
  },
53
44
  {
54
45
  path: getAbsolutePath(navigationRoutes.fromToken),
55
46
  element: (
56
- <SelectTokenPage
57
- type="from"
58
- supportedTokens={configs?.fromTokens || 'all'}
59
- />
47
+ <SelectTokenPage type="from" supportedTokens={config?.from?.tokens} />
60
48
  ),
61
49
  },
62
50
  {
63
51
  path: getAbsolutePath(navigationRoutes.toToken),
64
52
  element: (
65
- <SelectTokenPage
66
- type="to"
67
- supportedTokens={configs?.toTokens || 'all'}
68
- />
53
+ <SelectTokenPage type="to" supportedTokens={config?.to?.tokens} />
69
54
  ),
70
55
  },
71
56
  {
72
57
  path: getAbsolutePath(navigationRoutes.settings),
73
- element: (
74
- <SettingsPage supportedSwappers={configs?.liquiditySources || 'all'} />
75
- ),
58
+ element: <SettingsPage supportedSwappers={config?.liquiditySources} />,
76
59
  },
77
60
  {
78
61
  path: getAbsolutePath(navigationRoutes.liquiditySources),
79
62
  element: (
80
- <LiquiditySourcePage
81
- supportedSwappers={configs?.liquiditySources || 'all'}
82
- />
63
+ <LiquiditySourcePage supportedSwappers={config?.liquiditySources} />
83
64
  ),
84
65
  },
85
66
  { path: getAbsolutePath(navigationRoutes.swaps), element: <HistoryPage /> },
@@ -91,11 +72,11 @@ export function AppRoutes(props: PropTypes) {
91
72
  path: getAbsolutePath(navigationRoutes.wallets),
92
73
  element: (
93
74
  <WalletsPage
94
- supportedWallets={configs?.wallets || 'all'}
75
+ supportedWallets={config?.wallets}
95
76
  multiWallets={
96
- typeof configs?.multiWallets === 'undefined'
77
+ typeof config?.multiWallets === 'undefined'
97
78
  ? true
98
- : configs.multiWallets
79
+ : config.multiWallets
99
80
  }
100
81
  />
101
82
  ),
@@ -15,12 +15,14 @@ import { fetchingBalanceSelector, useWalletsStore } from '../store/wallets';
15
15
  import {
16
16
  calculateWalletUsdValue,
17
17
  getSelectableWallets,
18
+ tokensAreEqual,
18
19
  } from '../utils/wallets';
19
20
  import { removeDuplicateFrom } from '../utils/common';
20
- import { Configs } from '../types';
21
+ import { WidgetConfig } from '../types';
21
22
  import { useTranslation } from 'react-i18next';
22
23
  import { useBestRouteStore } from '../store/bestRoute';
23
24
  import { useMetaStore } from '../store/meta';
25
+ import { useSettingsStore } from '../store/settings';
24
26
 
25
27
  const Header = styled('div', {
26
28
  display: 'flex',
@@ -40,10 +42,10 @@ const WalletImage = styled('img', {
40
42
  });
41
43
 
42
44
  export type LayoutProps = {
43
- configs?: Configs;
45
+ config?: WidgetConfig;
44
46
  };
45
47
 
46
- export function Layout({ configs }: LayoutProps) {
48
+ export function Layout({ config }: LayoutProps) {
47
49
  const navigate = useNavigate();
48
50
  const { balances, accounts, selectedWallets } = useWalletsStore();
49
51
  const { getWalletInfo } = useWallets();
@@ -52,12 +54,13 @@ export function Layout({ configs }: LayoutProps) {
52
54
  (w) => w.image
53
55
  )
54
56
  );
55
-
57
+ const { blockchains, tokens } = useMetaStore.use.meta();
56
58
  const setFromChain = useBestRouteStore.use.setFromChain();
57
59
  const setFromToken = useBestRouteStore.use.setFromToken();
58
60
  const setToChain = useBestRouteStore.use.setToChain();
59
61
  const setToToken = useBestRouteStore.use.setToToken();
60
62
  const setInputAmount = useBestRouteStore.use.setInputAmount();
63
+ const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
61
64
 
62
65
  const totalBalance = calculateWalletUsdValue(balances);
63
66
  const connectWalletsButtonDisabled =
@@ -67,29 +70,35 @@ export function Layout({ configs }: LayoutProps) {
67
70
 
68
71
  const { t } = useTranslation();
69
72
  useEffect(() => {
70
- setToChain(configs?.toChain || null);
71
- setToToken(configs?.toToken || null);
72
- }, [configs?.toChain, configs?.toToken]);
73
+ const chain = blockchains.find(
74
+ (chain) => chain.name === config?.to?.blockchain
75
+ );
76
+ const token = tokens.find((t) =>
77
+ tokensAreEqual(t, config?.to?.token || null)
78
+ );
79
+ setToChain(chain || null);
80
+ setToToken(token || null);
81
+ }, [config?.to?.token, config?.to?.blockchain]);
82
+
73
83
  useEffect(() => {
74
- setInputAmount(configs?.fromAmount?.toString() || '');
75
- }, [configs?.fromAmount]);
84
+ setInputAmount(config?.amount?.toString() || '');
85
+ }, [config?.amount]);
76
86
 
77
87
  useEffect(() => {
78
- setFromToken(configs?.fromToken || null);
79
- setFromChain(configs?.fromChain || null);
80
- }, [configs?.fromToken, configs?.fromChain]);
88
+ const chain = blockchains.find(
89
+ (chain) => chain.name === config?.from?.blockchain
90
+ );
91
+ const token = tokens.find((t) =>
92
+ tokensAreEqual(t, config?.from?.token || null)
93
+ );
94
+
95
+ setFromChain(chain || null);
96
+ setFromToken(token || null);
97
+ }, [config?.from?.token, config?.from?.blockchain]);
81
98
 
82
99
  useEffect(() => {
83
- setToChain(null);
84
- setFromChain(null);
85
- setFromToken(null);
86
- setToToken(null);
87
- }, [
88
- configs?.fromChains,
89
- configs?.toChains,
90
- configs?.fromTokens,
91
- configs?.toTokens,
92
- ]);
100
+ setAffiliateRef(config?.affiliateRef || null);
101
+ }, [config?.affiliateRef]);
93
102
  return (
94
103
  <>
95
104
  <Header>
@@ -122,7 +131,7 @@ export function Layout({ configs }: LayoutProps) {
122
131
  </div>
123
132
  </Button>
124
133
  </Header>
125
- <AppRoutes configs={configs} />
134
+ <AppRoutes config={config} />
126
135
  </>
127
136
  );
128
137
  }
@@ -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,7 +112,8 @@ 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 {
@@ -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',
@@ -108,7 +112,9 @@ export function useTheme({
108
112
  .removeEventListener('change', switchTheme);
109
113
  };
110
114
  }, []);
111
-
115
+ useEffect(() => {
116
+ if (mode !== 'auto') setTheme(mode);
117
+ }, [mode]);
112
118
  const prevFont = usePrevious(fontFamily);
113
119
 
114
120
  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>
@@ -96,6 +96,7 @@ export function ConfirmSwapPage() {
96
96
 
97
97
  return (
98
98
  <ConfirmSwap
99
+ // @ts-ignore
99
100
  requiredWallets={getRequiredChains(bestRoute)}
100
101
  selectableWallets={selectableWallets}
101
102
  onBack={navigateBackFrom.bind(null, navigationRoutes.confirmSwap)}
@@ -105,6 +106,7 @@ export function ConfirmSwapPage() {
105
106
  manager?.create(
106
107
  'swap',
107
108
  { swapDetails: swap },
109
+ // @ts-ignore
108
110
  { id: swap.requestId }
109
111
  );
110
112
  setSelectedSwap(swap.requestId);
@@ -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);
@@ -142,7 +136,7 @@ export function Home(props: PropTypes) {
142
136
  return (
143
137
  <Container>
144
138
  <Header
145
- title={title}
139
+ title="SWAP"
146
140
  suffix={
147
141
  <HeaderButtons
148
142
  onClickRefresh={!!bestRoute ? fetchBestRoute : undefined}
@@ -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();