@rango-dev/widget-embedded 0.1.10-next.106 → 0.1.10-next.114

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 (62) hide show
  1. package/dist/App.d.ts.map +1 -1
  2. package/dist/components/AppRoutes.d.ts.map +1 -1
  3. package/dist/components/HeaderButtons.d.ts +4 -1
  4. package/dist/components/HeaderButtons.d.ts.map +1 -1
  5. package/dist/components/Layout.d.ts.map +1 -1
  6. package/dist/components/SwapDetailsPlaceholder.d.ts +9 -0
  7. package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -0
  8. package/dist/components/TokenPreview.d.ts +1 -1
  9. package/dist/components/TokenPreview.d.ts.map +1 -1
  10. package/dist/globalStyles.d.ts.map +1 -1
  11. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  12. package/dist/pages/HistoryPage.d.ts.map +1 -1
  13. package/dist/pages/Home.d.ts.map +1 -1
  14. package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
  15. package/dist/pages/SelectTokenPage.d.ts.map +1 -1
  16. package/dist/pages/SettingsPage.d.ts.map +1 -1
  17. package/dist/pages/SwapDetailsPage.d.ts +1 -1
  18. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  19. package/dist/pages/WalletsPage.d.ts +1 -0
  20. package/dist/pages/WalletsPage.d.ts.map +1 -1
  21. package/dist/store/bestRoute.d.ts +1 -1
  22. package/dist/store/bestRoute.d.ts.map +1 -1
  23. package/dist/store/ui.d.ts.map +1 -1
  24. package/dist/store/wallets.d.ts +14 -0
  25. package/dist/store/wallets.d.ts.map +1 -1
  26. package/dist/utils/date.d.ts +3 -0
  27. package/dist/utils/date.d.ts.map +1 -0
  28. package/dist/utils/routing.d.ts +1 -0
  29. package/dist/utils/routing.d.ts.map +1 -1
  30. package/dist/utils/swap.d.ts.map +1 -1
  31. package/dist/widget-embedded.cjs.development.js +249 -115
  32. package/dist/widget-embedded.cjs.development.js.map +1 -1
  33. package/dist/widget-embedded.cjs.production.min.js +249 -115
  34. package/dist/widget-embedded.cjs.production.min.js.map +1 -1
  35. package/dist/widget-embedded.esm.js +250 -116
  36. package/dist/widget-embedded.esm.js.map +1 -1
  37. package/package.json +4 -3
  38. package/readme.md +1 -2
  39. package/src/App.tsx +4 -1
  40. package/src/components/AppRoutes.tsx +15 -10
  41. package/src/components/HeaderButtons.tsx +9 -2
  42. package/src/components/Layout.tsx +25 -6
  43. package/src/components/SwapDetailsPlaceholder.tsx +32 -0
  44. package/src/components/TokenPreview.tsx +7 -4
  45. package/src/globalStyles.ts +2 -1
  46. package/src/pages/ConfirmSwapPage.tsx +9 -2
  47. package/src/pages/HistoryPage.tsx +4 -4
  48. package/src/pages/Home.tsx +18 -7
  49. package/src/pages/LiquiditySourcesPage.tsx +2 -0
  50. package/src/pages/SelectTokenPage.tsx +3 -0
  51. package/src/pages/SettingsPage.tsx +3 -0
  52. package/src/pages/SwapDetailsPage.tsx +63 -4
  53. package/src/pages/WalletsPage.tsx +27 -8
  54. package/src/store/bestRoute.ts +40 -13
  55. package/src/store/ui.ts +4 -0
  56. package/src/store/wallets.ts +4 -1
  57. package/src/utils/date.ts +62 -0
  58. package/src/utils/routing.ts +23 -13
  59. package/src/utils/swap.ts +3 -1
  60. package/dist/components/Header.d.ts +0 -10
  61. package/dist/components/Header.d.ts.map +0 -1
  62. package/src/components/Header.tsx +0 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.1.10-next.106",
3
+ "version": "0.1.10-next.114",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -10,8 +10,8 @@
10
10
  ],
11
11
  "browserslist": "> 0.5%, last 2 versions, not dead",
12
12
  "scripts": {
13
- "dev": "parcel public/index.html -p 3001",
14
- "build:app": "parcel build",
13
+ "dev": "parcel public/index.html -p 3001 --cache-dir=.parcel-cache",
14
+ "build:app": "parcel build --cache-dir=.parcel-cache",
15
15
  "build": "tsdx build --entry ./src/lib.tsx"
16
16
  },
17
17
  "husky": {
@@ -35,6 +35,7 @@
35
35
  "@rango-dev/wallets-shared": "^0.1.11-next.84",
36
36
  "bignumber.js": "^9.1.1",
37
37
  "copy-to-clipboard": "^3.3.3",
38
+ "dayjs": "^1.11.7",
38
39
  "i18next": "^22.4.11",
39
40
  "i18next-browser-languagedetector": "^7.0.1",
40
41
  "i18next-http-backend": "^2.1.1",
package/readme.md CHANGED
@@ -1,2 +1 @@
1
-
2
- Widget will use `components`, `queues` and `wallets` to make a react app to be embedded as widget.
1
+ # @rango-dev/widget-embedded
package/src/App.tsx CHANGED
@@ -19,6 +19,8 @@ import QueueManager from './QueueManager';
19
19
  import { isEvmBlockchain } from 'rango-sdk';
20
20
  import { Configs } from './types';
21
21
  import './i18n';
22
+ import { useUiStore } from './store/ui';
23
+ import { navigationRoutes } from './constants/navigationRoutes';
22
24
 
23
25
  const providers = allProviders();
24
26
 
@@ -37,6 +39,7 @@ export function App({ configs }: WidgetProps) {
37
39
  const { blockchains } = useMetaStore.use.meta();
38
40
  const disconnectWallet = useWalletsStore.use.disconnectWallet();
39
41
  const connectWallet = useWalletsStore.use.connectWallet();
42
+ const currentPage = useUiStore.use.currentPage();
40
43
 
41
44
  const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
42
45
  useState<string>('');
@@ -92,7 +95,7 @@ export function App({ configs }: WidgetProps) {
92
95
  >
93
96
  <div id="pageContainer" className={activeTheme}>
94
97
  <QueueManager>
95
- <SwapContainer>
98
+ <SwapContainer fixedHeight={currentPage != navigationRoutes.home}>
96
99
  <AppRouter
97
100
  title={configs?.title}
98
101
  titleSize={configs?.titleSize}
@@ -12,6 +12,8 @@ import { WalletsPage } from '../pages/WalletsPage';
12
12
  import { SwapDetailsPage } from '../pages/SwapDetailsPage';
13
13
  import { Configs } from '../types';
14
14
 
15
+ const getAbsolutePath = (path: string) => path.replace('/', '');
16
+
15
17
  interface PropTypes {
16
18
  configs?: Configs;
17
19
  }
@@ -21,7 +23,7 @@ export function AppRoutes(props: PropTypes) {
21
23
 
22
24
  return useRoutes([
23
25
  {
24
- path: navigationRoutes.home,
26
+ path: getAbsolutePath(navigationRoutes.home),
25
27
  element: (
26
28
  <Home
27
29
  title={configs?.title}
@@ -31,7 +33,7 @@ export function AppRoutes(props: PropTypes) {
31
33
  ),
32
34
  },
33
35
  {
34
- path: navigationRoutes.fromChain,
36
+ path: getAbsolutePath(navigationRoutes.fromChain),
35
37
  element: (
36
38
  <SelectChainPage
37
39
  type="from"
@@ -40,7 +42,7 @@ export function AppRoutes(props: PropTypes) {
40
42
  ),
41
43
  },
42
44
  {
43
- path: navigationRoutes.toChain,
45
+ path: getAbsolutePath(navigationRoutes.toChain),
44
46
  element: (
45
47
  <SelectChainPage
46
48
  type="to"
@@ -49,7 +51,7 @@ export function AppRoutes(props: PropTypes) {
49
51
  ),
50
52
  },
51
53
  {
52
- path: navigationRoutes.fromToken + '/*',
54
+ path: getAbsolutePath(navigationRoutes.fromToken),
53
55
  element: (
54
56
  <SelectTokenPage
55
57
  type="from"
@@ -58,7 +60,7 @@ export function AppRoutes(props: PropTypes) {
58
60
  ),
59
61
  },
60
62
  {
61
- path: navigationRoutes.toToken,
63
+ path: getAbsolutePath(navigationRoutes.toToken),
62
64
  element: (
63
65
  <SelectTokenPage
64
66
  type="to"
@@ -67,26 +69,26 @@ export function AppRoutes(props: PropTypes) {
67
69
  ),
68
70
  },
69
71
  {
70
- path: navigationRoutes.settings,
72
+ path: getAbsolutePath(navigationRoutes.settings),
71
73
  element: (
72
74
  <SettingsPage supportedSwappers={configs?.liquiditySources || 'all'} />
73
75
  ),
74
76
  },
75
77
  {
76
- path: navigationRoutes.liquiditySources,
78
+ path: getAbsolutePath(navigationRoutes.liquiditySources),
77
79
  element: (
78
80
  <LiquiditySourcePage
79
81
  supportedSwappers={configs?.liquiditySources || 'all'}
80
82
  />
81
83
  ),
82
84
  },
83
- { path: navigationRoutes.swaps, element: <HistoryPage /> },
85
+ { path: getAbsolutePath(navigationRoutes.swaps), element: <HistoryPage /> },
84
86
  {
85
87
  path: navigationRoutes.swapDetails,
86
88
  element: <SwapDetailsPage />,
87
89
  },
88
90
  {
89
- path: navigationRoutes.wallets,
91
+ path: getAbsolutePath(navigationRoutes.wallets),
90
92
  element: (
91
93
  <WalletsPage
92
94
  supportedWallets={configs?.wallets || 'all'}
@@ -98,6 +100,9 @@ export function AppRoutes(props: PropTypes) {
98
100
  />
99
101
  ),
100
102
  },
101
- { path: navigationRoutes.confirmSwap, element: <ConfirmSwapPage /> },
103
+ {
104
+ path: getAbsolutePath(navigationRoutes.confirmSwap),
105
+ element: <ConfirmSwapPage />,
106
+ },
102
107
  ]);
103
108
  }
@@ -9,12 +9,15 @@ import {
9
9
  } from '@rango-dev/ui';
10
10
  import { useNavigate } from 'react-router-dom';
11
11
  import { navigationRoutes } from '../constants/navigationRoutes';
12
- import { PropTypes } from './Header';
13
12
 
14
13
  const ButtonsContainer = styled('div', {
15
14
  display: 'flex',
16
15
  });
17
16
 
17
+ interface PropTypes {
18
+ onClickRefresh?: () => void;
19
+ }
20
+
18
21
  export function HeaderButtons(props: PropTypes) {
19
22
  const { onClickRefresh } = props;
20
23
  const navigate = useNavigate();
@@ -22,7 +25,11 @@ export function HeaderButtons(props: PropTypes) {
22
25
  return (
23
26
  <ButtonsContainer>
24
27
  <Tooltip content="Refresh">
25
- <Button variant="ghost" onClick={onClickRefresh}>
28
+ <Button
29
+ variant="ghost"
30
+ onClick={onClickRefresh}
31
+ disabled={!onClickRefresh}
32
+ >
26
33
  <RetryIcon size={24} />
27
34
  </Button>
28
35
  </Tooltip>
@@ -1,11 +1,17 @@
1
- import { Button, AddWalletIcon, Typography, styled } from '@rango-dev/ui';
1
+ import {
2
+ Button,
3
+ AddWalletIcon,
4
+ Typography,
5
+ styled,
6
+ Spinner,
7
+ } from '@rango-dev/ui';
2
8
  import React, { useEffect } from 'react';
3
9
  import { useNavigate } from 'react-router-dom';
4
10
  import { useWallets } from '@rango-dev/wallets-core';
5
11
  import { navigationRoutes } from '../constants/navigationRoutes';
6
12
  import { useUiStore } from '../store/ui';
7
13
  import { AppRoutes } from './AppRoutes';
8
- import { useWalletsStore } from '../store/wallets';
14
+ import { fetchingBalanceSelector, useWalletsStore } from '../store/wallets';
9
15
  import {
10
16
  calculateWalletUsdValue,
11
17
  getSelectableWallets,
@@ -14,11 +20,15 @@ import { removeDuplicateFrom } from '../utils/common';
14
20
  import { Configs } from '../types';
15
21
  import { useTranslation } from 'react-i18next';
16
22
  import { useBestRouteStore } from '../store/bestRoute';
23
+ import { useMetaStore } from '../store/meta';
17
24
 
18
25
  const Header = styled('div', {
19
26
  display: 'flex',
20
27
  width: '100%',
21
28
  justifyContent: 'end',
29
+ '.balance': {
30
+ display: 'flex',
31
+ },
22
32
  });
23
33
 
24
34
  const WalletImage = styled('img', {
@@ -52,6 +62,9 @@ export function Layout({ configs }: LayoutProps) {
52
62
  const totalBalance = calculateWalletUsdValue(balances);
53
63
  const connectWalletsButtonDisabled =
54
64
  useUiStore.use.connectWalletsButtonDisabled();
65
+ const loadingMetaStatus = useMetaStore.use.loadingStatus();
66
+ const fetchingBalance = useWalletsStore(fetchingBalanceSelector);
67
+
55
68
  const { t } = useTranslation();
56
69
  useEffect(() => {
57
70
  setToChain(configs?.toChain || null);
@@ -77,7 +90,6 @@ export function Layout({ configs }: LayoutProps) {
77
90
  configs?.fromTokens,
78
91
  configs?.toTokens,
79
92
  ]);
80
-
81
93
  return (
82
94
  <>
83
95
  <Header>
@@ -86,6 +98,8 @@ export function Layout({ configs }: LayoutProps) {
86
98
  suffix={<AddWalletIcon size={20} />}
87
99
  variant="ghost"
88
100
  flexContent
101
+ loading={loadingMetaStatus === 'loading'}
102
+ disabled={loadingMetaStatus === 'failed'}
89
103
  onClick={() => {
90
104
  if (!connectWalletsButtonDisabled)
91
105
  navigate(navigationRoutes.wallets);
@@ -98,9 +112,14 @@ export function Layout({ configs }: LayoutProps) {
98
112
  ) : (
99
113
  <></>
100
114
  )}
101
- <Typography variant="body2">
102
- {!accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`}
103
- </Typography>
115
+ <div className="balance">
116
+ <Typography variant="body2">
117
+ {!accounts?.length
118
+ ? t('Connect Wallet')
119
+ : `$${totalBalance || 0}`}
120
+ </Typography>
121
+ {fetchingBalance && <Spinner />}
122
+ </div>
104
123
  </Button>
105
124
  </Header>
106
125
  <AppRoutes configs={configs} />
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { SecondaryPage, Spinner, Alert, styled } from '@rango-dev/ui';
3
+ import { LoaderContainer } from '../pages/WalletsPage';
4
+
5
+ const PlaceholderContainer = styled('div', { height: '450px' });
6
+
7
+ interface PropTypes {
8
+ requestId: string;
9
+ loading: boolean;
10
+ onBack: () => void;
11
+ }
12
+
13
+ export function SwapDetailsPlaceholder(props: PropTypes) {
14
+ const { requestId, loading, onBack } = props;
15
+
16
+ return (
17
+ <SecondaryPage title="Swap Details" textField={false} onBack={onBack}>
18
+ <PlaceholderContainer>
19
+ {loading ? (
20
+ <LoaderContainer>
21
+ <Spinner size={24} />
22
+ </LoaderContainer>
23
+ ) : (
24
+ <Alert
25
+ type="secondary"
26
+ title={`Swap with request ID = ${requestId} not found.`}
27
+ />
28
+ )}
29
+ </PlaceholderContainer>
30
+ </SecondaryPage>
31
+ );
32
+ }
@@ -85,7 +85,7 @@ const OutputContainer = styled('div', {
85
85
  interface PropTypes {
86
86
  label: string;
87
87
  amount: string;
88
- usdValue: BigNumber;
88
+ usdValue?: BigNumber;
89
89
  loadingStatus: LoadingStatus;
90
90
  chain: {
91
91
  displayName: string;
@@ -120,9 +120,12 @@ export function TokenPreview(props: PropTypes) {
120
120
  <Typography variant="body2" color="neutrals800">
121
121
  {props.label}
122
122
  </Typography>
123
- <Typography variant="caption" color="neutrals600">{`$${numberToString(
124
- props.usdValue
125
- )}`}</Typography>
123
+ {props.usdValue && (
124
+ <Typography
125
+ variant="caption"
126
+ color="neutrals600"
127
+ >{`$${numberToString(props.usdValue)}`}</Typography>
128
+ )}
126
129
  </div>
127
130
  <div className="form">
128
131
  <Button
@@ -2,9 +2,10 @@ import { globalCss } from '@rango-dev/ui';
2
2
 
3
3
  export const globalStyles = globalCss({
4
4
  '*': {
5
- '&::-webkit-scrollbar': { width: '$8' },
5
+ '&::-webkit-scrollbar': { width: '$8', height: '$8' },
6
6
  '&::-webkit-scrollbar-thumb': {
7
7
  backgroundColor: '$neutrals400',
8
+ borderRadius: '$10',
8
9
  },
9
10
  '&::-webkit-scrollbar-thumb:hover': {
10
11
  backgroundColor: '$neutrals500',
@@ -32,12 +32,14 @@ import { ConfirmSwapErrorTypes } from '../types';
32
32
  import { ConfirmSwapErrors } from '../components/ConfirmSwapErrors';
33
33
  import { ConfirmSwapWarnings } from '../components/ConfirmSwapWarnings';
34
34
  import { ConfirmSwapExtraMessages } from '../components/warnings/ConfirmSwapExtraMessages';
35
+ import { getBestRouteStatus } from '../utils/routing';
35
36
 
36
37
  export function ConfirmSwapPage() {
37
38
  const navigate = useNavigate();
38
39
  const { navigateBackFrom } = useNavigateBack();
39
40
  const bestRoute = useBestRouteStore.use.bestRoute();
40
41
  const fetchingBestRoute = useBestRouteStore.use.loading();
42
+ const fetchingBestRouteError = useBestRouteStore.use.error();
41
43
  const setSelectedSwap = useUiStore.use.setSelectedSwap();
42
44
  const { blockchains, tokens } = useMetaStore.use.meta();
43
45
  const accounts = useWalletsStore.use.accounts();
@@ -47,6 +49,11 @@ export function ConfirmSwapPage() {
47
49
  const slippage = useSettingsStore.use.slippage();
48
50
  const customSlippage = useSettingsStore.use.customSlippage();
49
51
 
52
+ const bestRouteloadingStatus = getBestRouteStatus(
53
+ fetchingBestRoute,
54
+ !!fetchingBestRouteError
55
+ );
56
+
50
57
  const { manager } = useManager();
51
58
  const { loading, errors, warnings, confirmSwap } = useConfirmSwap();
52
59
 
@@ -130,7 +137,7 @@ export function ConfirmSwapPage() {
130
137
  usdValue={calcOutputUsdValue(fromAmount, firstStep?.from.usdPrice)}
131
138
  amount={fromAmount}
132
139
  label={t('From')}
133
- loadingStatus={'success'}
140
+ loadingStatus={bestRouteloadingStatus}
134
141
  />
135
142
  <Spacer size={12} direction="vertical" />
136
143
  <TokenPreview
@@ -145,7 +152,7 @@ export function ConfirmSwapPage() {
145
152
  usdValue={calcOutputUsdValue(toAmount, lastStep?.to.usdPrice)}
146
153
  amount={toAmount}
147
154
  label={t('To')}
148
- loadingStatus={'success'}
155
+ loadingStatus={bestRouteloadingStatus}
149
156
  />
150
157
  </>
151
158
  }
@@ -6,6 +6,7 @@ import { navigationRoutes } from '../constants/navigationRoutes';
6
6
  import { useNavigateBack } from '../hooks/useNavigateBack';
7
7
  import { getPendingSwaps } from '../utils/queue';
8
8
  import { useUiStore } from '../store/ui';
9
+ import { groupSwapsByDate } from '../utils/date';
9
10
 
10
11
  export function HistoryPage() {
11
12
  const setSelectedSwap = useUiStore.use.setSelectedSwap();
@@ -16,12 +17,11 @@ export function HistoryPage() {
16
17
 
17
18
  return (
18
19
  <History
19
- //todo: move PendingSwap type to rango-types
20
- //@ts-ignore
21
20
  list={pendingSwaps}
22
- onSwapClick={(requestId) => {
21
+ groupBy={groupSwapsByDate}
22
+ onSwapClick={requestId => {
23
23
  setSelectedSwap(requestId);
24
- navigate(navigationRoutes.swaps + `/${requestId}`);
24
+ navigate(navigationRoutes.swaps + `/${requestId}`, { replace: true });
25
25
  }}
26
26
  onBack={navigateBackFrom.bind(null, navigationRoutes.swaps)}
27
27
  />
@@ -5,10 +5,10 @@ import {
5
5
  styled,
6
6
  Typography,
7
7
  VerticalSwapIcon,
8
+ Header,
8
9
  } from '@rango-dev/ui';
9
- import React, { useState } from 'react';
10
+ import React, { useEffect, useState } from 'react';
10
11
  import { useInRouterContext, useNavigate } from 'react-router-dom';
11
- import { Header } from '../components/Header';
12
12
  import { TokenInfo } from '../components/TokenInfo';
13
13
  import { fetchBestRoute, useBestRouteStore } from '../store/bestRoute';
14
14
  import { BottomLogo } from '../components/BottomLogo';
@@ -34,6 +34,8 @@ import {
34
34
  totalArrivalTime,
35
35
  } from '../utils/numbers';
36
36
  import BigNumber from 'bignumber.js';
37
+ import { HeaderButtons } from '../components/HeaderButtons';
38
+ import { useUiStore } from '../store/ui';
37
39
 
38
40
  const Container = styled('div', {
39
41
  display: 'flex',
@@ -67,7 +69,7 @@ interface PropTypes {
67
69
  titleWeight?: number;
68
70
  }
69
71
  export function Home(props: PropTypes) {
70
- const { title = 'SWAP', titleSize = 18, titleWeight = 600 } = props;
72
+ const { title = 'SWAP' } = props;
71
73
 
72
74
  const isRouterInContext = useInRouterContext();
73
75
  const navigate = useNavigate();
@@ -91,6 +93,7 @@ export function Home(props: PropTypes) {
91
93
  const bestRouteError = useBestRouteStore.use.error();
92
94
  const loadingMetaStatus = useMetaStore.use.loadingStatus();
93
95
  const accounts = useWalletsStore.use.accounts();
96
+ const setCurrentPage = useUiStore.use.setCurrentPage();
94
97
 
95
98
  const swithFromAndTo = () => {
96
99
  setFromChain(toChain);
@@ -142,13 +145,21 @@ export function Home(props: PropTypes) {
142
145
 
143
146
  const highFee = hasHighFee(totalFeeInUsd);
144
147
 
148
+ useEffect(() => {
149
+ setCurrentPage(navigationRoutes.home);
150
+
151
+ return setCurrentPage.bind(null, '');
152
+ }, []);
153
+
145
154
  return (
146
155
  <Container>
147
156
  <Header
148
157
  title={title}
149
- titleSize={titleSize}
150
- titleWeight={titleWeight}
151
- onClickRefresh={fetchBestRoute}
158
+ suffix={
159
+ <HeaderButtons
160
+ onClickRefresh={!!bestRoute ? fetchBestRoute : undefined}
161
+ />
162
+ }
152
163
  />
153
164
  <FromContainer>
154
165
  <TokenInfo
@@ -160,7 +171,7 @@ export function Home(props: PropTypes) {
160
171
  />
161
172
  <SwitchButtonContainer>
162
173
  <Button variant="ghost" onClick={swithFromAndTo}>
163
- <VerticalSwapIcon size={24} />
174
+ <VerticalSwapIcon size={32} />
164
175
  {isRouterInContext && <SwithFromAndTo count={count} />}
165
176
  </Button>
166
177
  </SwitchButtonContainer>
@@ -11,6 +11,7 @@ interface PropTypes {
11
11
  }
12
12
  export function LiquiditySourcePage({ supportedSwappers }: PropTypes) {
13
13
  const swappers = useMetaStore.use.meta().swappers;
14
+ const loadingMetaStatus = useMetaStore.use.loadingStatus();
14
15
  const toggleLiquiditySource = useSettingsStore.use.toggleLiquiditySource();
15
16
  const disabledLiquiditySources =
16
17
  useSettingsStore.use.disabledLiquiditySources();
@@ -59,6 +60,7 @@ export function LiquiditySourcePage({ supportedSwappers }: PropTypes) {
59
60
  toggleLiquiditySource(liquiditySource.title)
60
61
  }
61
62
  onBack={navigateBackFrom.bind(null, navigationRoutes.liquiditySources)}
63
+ loadingStatus={loadingMetaStatus}
62
64
  />
63
65
  );
64
66
  }
@@ -5,6 +5,7 @@ import { 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';
8
+ import { useMetaStore } from '../store/meta';
8
9
 
9
10
  interface PropTypes {
10
11
  type: 'from' | 'to';
@@ -46,6 +47,7 @@ export function SelectTokenPage(props: PropTypes) {
46
47
  const toToken = useBestRouteStore.use.toToken();
47
48
  const setFromToken = useBestRouteStore.use.setFromToken();
48
49
  const setToToken = useBestRouteStore.use.setToToken();
50
+ const loadingMetaStatus = useMetaStore.use.loadingStatus();
49
51
 
50
52
  return (
51
53
  <TokenSelector
@@ -58,6 +60,7 @@ export function SelectTokenPage(props: PropTypes) {
58
60
  navigateBackFrom(navigationRoutes.fromToken);
59
61
  }}
60
62
  onBack={navigateBackFrom.bind(null, navigationRoutes.fromToken)}
63
+ loadingStatus={loadingMetaStatus}
61
64
  />
62
65
  );
63
66
  }
@@ -30,6 +30,8 @@ export function SettingsPage({ supportedSwappers }: PropTypes) {
30
30
 
31
31
  const infiniteApprove = useSettingsStore.use.infiniteApprove();
32
32
  const toggleInfiniteApprove = useSettingsStore.use.toggleInfiniteApprove();
33
+ const loadingMetaStatus = useMetaStore.use.loadingStatus();
34
+
33
35
  const uniqueSwappersGroups: Array<{
34
36
  title: string;
35
37
  logo: string;
@@ -93,6 +95,7 @@ export function SettingsPage({ supportedSwappers }: PropTypes) {
93
95
  onThemeChange={setTheme}
94
96
  infiniteApprove={infiniteApprove}
95
97
  toggleInfiniteApprove={toggleInfiniteApprove}
98
+ loadingStatus={loadingMetaStatus}
96
99
  />
97
100
  );
98
101
  }
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import { navigationRoutes } from '../constants/navigationRoutes';
3
3
  import useCopyToClipboard from '../hooks/useCopyToClipboard';
4
4
  import { useManager } from '@rango-dev/queue-manager-react';
@@ -25,6 +25,12 @@ import {
25
25
  isNetworkStatusInWarningState,
26
26
  shouldRetrySwap,
27
27
  } from '../utils/swap';
28
+ import { TokenPreview } from '../components/TokenPreview';
29
+ import { Spacer } from '@rango-dev/ui';
30
+ import { numberToString } from '../utils/numbers';
31
+ //@ts-ignore
32
+ import { t } from 'i18next';
33
+ import { SwapDetailsPlaceholder } from '../components/SwapDetailsPlaceholder';
28
34
 
29
35
  export function SwapDetailsPage() {
30
36
  const selectedSwapRequestId = useUiStore.use.selectedSwapRequestId();
@@ -35,6 +41,14 @@ export function SwapDetailsPage() {
35
41
  const [isCopied, handleCopy] = useCopyToClipboard(2000);
36
42
  const { manager } = useManager();
37
43
 
44
+ const [loading, setLoading] = useState(true);
45
+
46
+ useEffect(() => {
47
+ setTimeout(() => {
48
+ setLoading(false);
49
+ }, 5000);
50
+ }, []);
51
+
38
52
  const pendingSwaps = getPendingSwaps(manager);
39
53
  const selectedSwap = pendingSwaps.find(
40
54
  ({ swap }) => swap.requestId === selectedSwapRequestId
@@ -44,9 +58,21 @@ export function SwapDetailsPage() {
44
58
  const swap = manager?.get(selectedSwap?.id!);
45
59
  if (swap) cancelSwap(swap);
46
60
  };
47
-
48
61
  const swap = selectedSwap?.swap;
49
- if (!swap) return null;
62
+
63
+ if (!swap)
64
+ return (
65
+ <SwapDetailsPlaceholder
66
+ requestId={selectedSwapRequestId || ''}
67
+ loading={loading}
68
+ onBack={navigateBackFrom.bind(null, navigationRoutes.swapDetails)}
69
+ />
70
+ );
71
+
72
+ const firstStep = swap.steps[0];
73
+ const lastStep = swap.steps[swap.steps.length - 1];
74
+ const fromAmount = numberToString(swap.inputAmount);
75
+ const toAmount = numberToString(swap.simulationResult.outputAmount);
50
76
 
51
77
  const currentStep = getCurrentStep(swap);
52
78
 
@@ -81,6 +107,39 @@ export function SwapDetailsPage() {
81
107
  return (
82
108
  <SwapHistory
83
109
  onBack={navigateBackFrom.bind(null, navigationRoutes.swapDetails)}
110
+ previewInputs={
111
+ <>
112
+ <TokenPreview
113
+ chain={{
114
+ displayName: firstStep?.fromBlockchain || '',
115
+ // @ts-ignore
116
+ logo: firstStep?.fromBlockchainLogo || '',
117
+ }}
118
+ token={{
119
+ symbol: firstStep?.fromSymbol || '',
120
+ image: firstStep?.fromLogo || '',
121
+ }}
122
+ amount={fromAmount}
123
+ label={t('From')}
124
+ loadingStatus={'success'}
125
+ />
126
+ <Spacer size={12} direction="vertical" />
127
+ <TokenPreview
128
+ chain={{
129
+ displayName: lastStep?.toBlockchain || '',
130
+ // @ts-ignore
131
+ logo: lastStep?.toBlockchainLogo || '',
132
+ }}
133
+ token={{
134
+ symbol: lastStep?.toSymbol || '',
135
+ image: lastStep?.toLogo || '',
136
+ }}
137
+ amount={toAmount}
138
+ label={t('To')}
139
+ loadingStatus={'success'}
140
+ />
141
+ </>
142
+ }
84
143
  //todo: move PendingSwap type to rango-types
85
144
  //@ts-ignore
86
145
  pendingSwap={swap}
@@ -106,7 +165,7 @@ export function SwapDetailsPage() {
106
165
  {...(lastConvertedTokenInFailedSwap && {
107
166
  lastConvertedTokenInFailedSwap: {
108
167
  blockchain: lastConvertedTokenInFailedSwap.blockchain,
109
- outputAmount: lastConvertedTokenInFailedSwap.outputAmount,
168
+ outputAmount: lastConvertedTokenInFailedSwap.outputAmount || '',
110
169
  symbol: lastConvertedTokenInFailedSwap.symbol,
111
170
  },
112
171
  })}