@rango-dev/widget-embedded 0.17.1-next.2 → 0.17.1-next.3

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 (195) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -3
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  4. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +1 -1
  5. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
  6. package/dist/components/NoResult/NoResult.d.ts +4 -0
  7. package/dist/components/NoResult/NoResult.d.ts.map +1 -0
  8. package/dist/components/NoResult/NoResult.helpers.d.ts +4 -0
  9. package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -0
  10. package/dist/components/{NoRoutes/NoRoutes.styles.d.ts → NoResult/NoResult.styles.d.ts} +1 -1
  11. package/dist/components/{NoRoutes/NoRoutes.styles.d.ts.map → NoResult/NoResult.styles.d.ts.map} +1 -1
  12. package/dist/components/{NoRoutes/NoRoutes.types.d.ts → NoResult/NoResult.types.d.ts} +3 -3
  13. package/dist/components/NoResult/NoResult.types.d.ts.map +1 -0
  14. package/dist/components/NoResult/index.d.ts +2 -0
  15. package/dist/components/NoResult/index.d.ts.map +1 -0
  16. package/dist/components/Quote/Quote.d.ts +4 -0
  17. package/dist/components/Quote/Quote.d.ts.map +1 -0
  18. package/dist/components/Quote/Quote.styles.d.ts +1429 -0
  19. package/dist/components/Quote/Quote.styles.d.ts.map +1 -0
  20. package/dist/components/Quote/Quote.types.d.ts +22 -0
  21. package/dist/components/Quote/Quote.types.d.ts.map +1 -0
  22. package/dist/components/Quote/QuoteSkeleton.d.ts +4 -0
  23. package/dist/components/Quote/QuoteSkeleton.d.ts.map +1 -0
  24. package/dist/components/Quote/QuoteSkeleton.styles.d.ts +319 -0
  25. package/dist/components/Quote/QuoteSkeleton.styles.d.ts.map +1 -0
  26. package/dist/components/Quote/QuoteSkeleton.types.d.ts +6 -0
  27. package/dist/components/Quote/QuoteSkeleton.types.d.ts.map +1 -0
  28. package/dist/components/Quote/QuoteSummary.d.ts +11 -0
  29. package/dist/components/Quote/QuoteSummary.d.ts.map +1 -0
  30. package/dist/components/Quote/QuoteSummary.styles.d.ts +158 -0
  31. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -0
  32. package/dist/components/Quote/index.d.ts +4 -0
  33. package/dist/components/Quote/index.d.ts.map +1 -0
  34. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +11 -0
  35. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +1 -0
  36. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +4 -0
  37. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +1 -0
  38. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +4 -0
  39. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -0
  40. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +9 -0
  41. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -0
  42. package/dist/components/{RouteErrors/RouteErrors.styles.d.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts} +1 -1
  43. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -0
  44. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +22 -0
  45. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -0
  46. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +11 -0
  47. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -0
  48. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +11 -0
  49. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +1 -0
  50. package/dist/components/QuoteWarningsAndErrors/index.d.ts +2 -0
  51. package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +1 -0
  52. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  53. package/dist/constants/errors.d.ts +4 -4
  54. package/dist/constants/errors.d.ts.map +1 -1
  55. package/dist/constants/messages.d.ts +1 -1
  56. package/dist/constants/warnings.d.ts +2 -2
  57. package/dist/constants/warnings.d.ts.map +1 -1
  58. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +4 -0
  59. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -0
  60. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +472 -0
  61. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -0
  62. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +17 -0
  63. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -0
  64. package/dist/containers/QuoteInfo/index.d.ts +2 -0
  65. package/dist/containers/QuoteInfo/index.d.ts.map +1 -0
  66. package/dist/hooks/useConfirmSwap/index.d.ts +2 -0
  67. package/dist/hooks/useConfirmSwap/index.d.ts.map +1 -0
  68. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +3 -0
  69. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -0
  70. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +16 -0
  71. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -0
  72. package/dist/hooks/{useConfirmSwap.d.ts → useConfirmSwap/useConfirmSwap.types.d.ts} +5 -7
  73. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -0
  74. package/dist/hooks/{useFetchBestRoute.d.ts → useFetchQuote.d.ts} +3 -3
  75. package/dist/hooks/useFetchQuote.d.ts.map +1 -0
  76. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  77. package/dist/hooks/useSwapInput.d.ts +4 -2
  78. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  79. package/dist/index.js +1 -1
  80. package/dist/index.js.map +4 -4
  81. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  82. package/dist/pages/Home.d.ts.map +1 -1
  83. package/dist/store/app.d.ts +2 -2
  84. package/dist/store/{bestRoute.d.ts → quote.d.ts} +25 -20
  85. package/dist/store/quote.d.ts.map +1 -0
  86. package/dist/types/index.d.ts +1 -1
  87. package/dist/types/index.d.ts.map +1 -1
  88. package/dist/types/quote.d.ts +82 -0
  89. package/dist/types/quote.d.ts.map +1 -0
  90. package/dist/utils/numbers.d.ts +1 -1
  91. package/dist/utils/numbers.d.ts.map +1 -1
  92. package/dist/utils/{routing.d.ts → quote.d.ts} +16 -12
  93. package/dist/utils/quote.d.ts.map +1 -0
  94. package/dist/utils/settings.d.ts +1 -1
  95. package/dist/utils/swap.d.ts +22 -20
  96. package/dist/utils/swap.d.ts.map +1 -1
  97. package/dist/utils/wallets.d.ts +1 -1
  98. package/package.json +2 -2
  99. package/src/components/BlockchainsSection/BlockchainsSection.tsx +3 -3
  100. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +2 -64
  101. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +23 -26
  102. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +1 -1
  103. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
  104. package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
  105. package/src/components/{NoRoutes/NoRoutes.helper.ts → NoResult/NoResult.helpers.ts} +16 -9
  106. package/src/components/{NoRoutes/NoRoutes.styles.ts → NoResult/NoResult.styles.ts} +2 -0
  107. package/src/components/{NoRoutes/NoRoutes.tsx → NoResult/NoResult.tsx} +7 -12
  108. package/src/components/{NoRoutes/NoRoutes.types.ts → NoResult/NoResult.types.ts} +3 -2
  109. package/src/components/NoResult/index.ts +1 -0
  110. package/src/components/Quote/Quote.styles.ts +212 -0
  111. package/src/components/Quote/Quote.tsx +347 -0
  112. package/src/components/Quote/Quote.types.ts +16 -0
  113. package/src/components/Quote/QuoteSkeleton.styles.ts +110 -0
  114. package/src/components/Quote/QuoteSkeleton.tsx +108 -0
  115. package/src/components/Quote/QuoteSkeleton.types.ts +5 -0
  116. package/src/components/Quote/QuoteSummary.styles.ts +15 -0
  117. package/src/components/Quote/QuoteSummary.tsx +46 -0
  118. package/src/components/Quote/index.ts +3 -0
  119. package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +107 -0
  120. package/src/components/{RouteErrors/RouteErrorsModalItem.tsx → QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx} +3 -3
  121. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +67 -0
  122. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +103 -0
  123. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +24 -0
  124. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +77 -0
  125. package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +38 -0
  126. package/src/components/QuoteWarningsAndErrors/index.ts +1 -0
  127. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
  128. package/src/components/SwapDetails/SwapDetails.tsx +13 -16
  129. package/src/components/SwitchFromAndTo.tsx +2 -2
  130. package/src/components/UpdateUrl.tsx +12 -12
  131. package/src/constants/errors.ts +8 -10
  132. package/src/constants/messages.ts +1 -1
  133. package/src/constants/warnings.ts +7 -7
  134. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +15 -0
  135. package/src/containers/QuoteInfo/QuoteInfo.tsx +97 -0
  136. package/src/containers/QuoteInfo/QuoteInfo.types.ts +17 -0
  137. package/src/containers/QuoteInfo/index.ts +1 -0
  138. package/src/hooks/useConfirmSwap/index.ts +1 -0
  139. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +168 -0
  140. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +136 -0
  141. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +19 -0
  142. package/src/hooks/{useFetchBestRoute.ts → useFetchQuote.ts} +3 -3
  143. package/src/hooks/useNavigateBack.ts +3 -3
  144. package/src/hooks/useSwapInput.ts +57 -23
  145. package/src/hooks/useSyncStoresWithConfig.ts +2 -2
  146. package/src/pages/ConfirmSwapPage.tsx +58 -227
  147. package/src/pages/HistoryPage.tsx +1 -1
  148. package/src/pages/Home.tsx +52 -241
  149. package/src/pages/LanguagePage.tsx +1 -1
  150. package/src/pages/LiquiditySourcePage.tsx +1 -1
  151. package/src/pages/SelectBlockchainPage.tsx +3 -3
  152. package/src/pages/SelectSwapItemsPage.tsx +2 -2
  153. package/src/pages/SettingsPage.tsx +1 -1
  154. package/src/pages/ThemePage.tsx +1 -1
  155. package/src/pages/WalletsPage.tsx +1 -1
  156. package/src/store/{bestRoute.ts → quote.ts} +42 -38
  157. package/src/types/index.ts +1 -1
  158. package/src/types/quote.ts +107 -0
  159. package/src/utils/numbers.ts +1 -1
  160. package/src/utils/quote.ts +338 -0
  161. package/src/utils/swap.ts +99 -69
  162. package/src/utils/wallets.ts +2 -2
  163. package/dist/components/NoRoutes/NoRoutes.d.ts +0 -4
  164. package/dist/components/NoRoutes/NoRoutes.d.ts.map +0 -1
  165. package/dist/components/NoRoutes/NoRoutes.helper.d.ts +0 -3
  166. package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +0 -1
  167. package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +0 -1
  168. package/dist/components/NoRoutes/index.d.ts +0 -2
  169. package/dist/components/NoRoutes/index.d.ts.map +0 -1
  170. package/dist/components/RouteErrors/RouteErrors.d.ts +0 -4
  171. package/dist/components/RouteErrors/RouteErrors.d.ts.map +0 -1
  172. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +0 -1
  173. package/dist/components/RouteErrors/RouteErrors.types.d.ts +0 -24
  174. package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +0 -1
  175. package/dist/components/RouteErrors/RouteErrorsModal.d.ts +0 -4
  176. package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +0 -1
  177. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +0 -4
  178. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +0 -1
  179. package/dist/components/RouteErrors/index.d.ts +0 -2
  180. package/dist/components/RouteErrors/index.d.ts.map +0 -1
  181. package/dist/hooks/useConfirmSwap.d.ts.map +0 -1
  182. package/dist/hooks/useFetchBestRoute.d.ts.map +0 -1
  183. package/dist/store/bestRoute.d.ts.map +0 -1
  184. package/dist/types/routing.d.ts +0 -65
  185. package/dist/types/routing.d.ts.map +0 -1
  186. package/dist/utils/routing.d.ts.map +0 -1
  187. package/src/components/NoRoutes/index.ts +0 -1
  188. package/src/components/RouteErrors/RouteErrors.tsx +0 -79
  189. package/src/components/RouteErrors/RouteErrors.types.ts +0 -29
  190. package/src/components/RouteErrors/RouteErrorsModal.tsx +0 -129
  191. package/src/components/RouteErrors/index.ts +0 -1
  192. package/src/hooks/useConfirmSwap.ts +0 -303
  193. package/src/types/routing.ts +0 -77
  194. package/src/utils/routing.ts +0 -321
  195. /package/src/components/{RouteErrors/RouteErrors.styles.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts} +0 -0
@@ -18,11 +18,11 @@ import {
18
18
  import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
19
19
  import { useNavigate } from 'react-router-dom';
20
20
 
21
- import { getConfirmSwapErrorMessage } from '../../constants/errors';
21
+ import { getQuoteErrorMessage } from '../../constants/errors';
22
22
  import { navigationRoutes } from '../../constants/navigationRoutes';
23
- import { getRouteWarningMessage } from '../../constants/warnings';
24
- import { useBestRouteStore } from '../../store/bestRoute';
23
+ import { getQuoteUpdateWarningMessage } from '../../constants/warnings';
25
24
  import { useMetaStore } from '../../store/meta';
25
+ import { useQuoteStore } from '../../store/quote';
26
26
  import { useWalletsStore } from '../../store/wallets';
27
27
  import { confirmSwapDisabled } from '../../utils/swap';
28
28
 
@@ -53,20 +53,20 @@ export function ConfirmWalletsModal(props: PropTypes) {
53
53
  const { open, onClose, onCancel, onCheckBalance, config, loading } = props;
54
54
  const { blockchains } = useMetaStore.use.meta();
55
55
  const {
56
- bestRoute,
57
- setSelectedWallets: selectRouteWallets,
58
- routeWalletsConfirmed,
59
- setRouteWalletConfirmed,
56
+ quote,
57
+ setSelectedWallets: selectQuoteWallets,
58
+ quoteWalletsConfirmed: quoteWalletsConfirmed,
59
+ setQuoteWalletConfirmed: setQuoteWalletConfirmed,
60
60
  customDestination,
61
61
  setCustomDestination,
62
- } = useBestRouteStore();
62
+ } = useQuoteStore();
63
63
  const { connectedWallets, selectWallets } = useWalletsStore();
64
64
 
65
65
  const [showMoreWalletFor, setShowMoreWalletFor] = useState('');
66
66
  const [balanceWarnings, setBalanceWarnings] = useState<string[]>([]);
67
67
  const [error, setError] = useState('');
68
- const [routeWarning, setRouteWarning] = useState<
69
- ConfirmSwapWarnings['route'] | null
68
+ const [quoteWarning, setQuoteWarning] = useState<
69
+ ConfirmSwapWarnings['quoteUpdate'] | null
70
70
  >(null);
71
71
  const [destination, setDestination] = useState(customDestination);
72
72
  const [showCustomDestination, setShowCustomDestination] = useState(
@@ -74,7 +74,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
74
74
  );
75
75
  const customDestinationRef = useRef<HTMLDivElement | null>(null);
76
76
 
77
- const requiredWallets = getRequiredWallets(bestRoute);
77
+ const requiredWallets = getRequiredWallets(quote);
78
78
  const customDestinationEnabled =
79
79
  typeof config?.customDestination === 'undefined'
80
80
  ? true
@@ -83,13 +83,10 @@ export function ConfirmWalletsModal(props: PropTypes) {
83
83
  const lastStepToBlockchain = blockchains.find(
84
84
  (blockchain) =>
85
85
  blockchain.name ===
86
- bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to
87
- .blockchain
86
+ quote?.result?.swaps[quote?.result?.swaps.length - 1].to.blockchain
88
87
  );
89
88
  const isWalletRequiredFor = (blockchain: string) =>
90
- !!bestRoute?.result?.swaps.find(
91
- (swap) => swap.from.blockchain === blockchain
92
- );
89
+ !!quote?.result?.swaps.find((swap) => swap.from.blockchain === blockchain);
93
90
 
94
91
  const [selectableWallets, setSelectableWallets] = useState<ConnectedWallet[]>(
95
92
  connectedWallets.filter((connectedWallet) => {
@@ -175,16 +172,16 @@ export function ConfirmWalletsModal(props: PropTypes) {
175
172
  (wallet) => wallet.selected
176
173
  );
177
174
  selectWallets(lastSelectedWallets);
178
- selectRouteWallets(lastSelectedWallets);
175
+ selectQuoteWallets(lastSelectedWallets);
179
176
  setCustomDestination(destination);
180
- setRouteWalletConfirmed(true);
177
+ setQuoteWalletConfirmed(true);
181
178
  onClose();
182
179
  };
183
180
 
184
181
  const onConfirmWallets = async () => {
185
182
  setBalanceWarnings([]);
186
183
  setError('');
187
- setRouteWarning(null);
184
+ setQuoteWarning(null);
188
185
  const selectedWallets = connectedWallets.filter((connectedWallet) =>
189
186
  selectableWallets.find(
190
187
  (selectableWallet) =>
@@ -201,11 +198,11 @@ export function ConfirmWalletsModal(props: PropTypes) {
201
198
  if (warnings?.balance?.messages) {
202
199
  setBalanceWarnings(warnings.balance.messages);
203
200
  }
204
- if (warnings?.route) {
205
- setRouteWarning(warnings.route);
201
+ if (warnings?.quoteUpdate) {
202
+ setQuoteWarning(warnings.quoteUpdate);
206
203
  }
207
204
  if (result.error) {
208
- setError(getConfirmSwapErrorMessage(result.error));
205
+ setError(getQuoteErrorMessage(result.error));
209
206
  }
210
207
 
211
208
  if (!result.error && (!warnings?.balance?.messages.length || 0 > 0)) {
@@ -249,7 +246,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
249
246
  <Modal
250
247
  open={open}
251
248
  onClose={() => {
252
- if (!routeWalletsConfirmed) {
249
+ if (!quoteWalletsConfirmed) {
253
250
  navigate(navigationRoutes.home, { replace: true });
254
251
  }
255
252
  onClose();
@@ -265,7 +262,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
265
262
  loading,
266
263
  showCustomDestination,
267
264
  destination,
268
- bestRoute,
265
+ quote,
269
266
  selectableWallets,
270
267
  lastStepToBlockchain
271
268
  )}
@@ -339,12 +336,12 @@ export function ConfirmWalletsModal(props: PropTypes) {
339
336
  <Divider size={12} />
340
337
  </>
341
338
  )}
342
- {routeWarning && (
339
+ {quoteWarning && (
343
340
  <>
344
341
  <Alert
345
342
  variant="alarm"
346
343
  type="warning"
347
- title={getRouteWarningMessage(routeWarning)}
344
+ title={getQuoteUpdateWarningMessage(quoteWarning)}
348
345
  />
349
346
  <Divider size={12} />
350
347
  </>
@@ -1,5 +1,5 @@
1
1
  import type { WidgetConfig } from '../..';
2
- import type { ConfirmSwap } from '../../hooks/useConfirmSwap';
2
+ import type { ConfirmSwap } from '../../hooks/useConfirmSwap/useConfirmSwap.types';
3
3
 
4
4
  export type PropTypes = {
5
5
  open: boolean;
@@ -10,11 +10,11 @@ export const Container = styled('div', {
10
10
  display: 'flex',
11
11
  },
12
12
 
13
- '.route-summary': {
13
+ '.quote-summary': {
14
14
  padding: '$15 $0',
15
15
  },
16
16
 
17
- '.route-summary-item': {
17
+ '.quote-summary-item': {
18
18
  display: 'flex',
19
19
  justifyContent: 'space-between',
20
20
  alignItems: 'center',
@@ -26,7 +26,7 @@ export const Container = styled('div', {
26
26
  alignItems: 'center',
27
27
  },
28
28
 
29
- '.route-summary-separator': {
29
+ '.quote-summary-separator': {
30
30
  width: '0px',
31
31
  height: '$16',
32
32
  borderLeft: '1px solid $neutral400',
@@ -6,8 +6,8 @@ import { Container, StepSeparator } from './LoadingSwapDetails.styles';
6
6
  import { LoadingSwapDetailStep } from './LoadingSwapDetailStep';
7
7
 
8
8
  export function LoadingSwapDetails() {
9
- const routeSummary = (
10
- <div className="route-summary-item">
9
+ const quoteSummary = (
10
+ <div className="quote-summary-item">
11
11
  <div className="token-amount">
12
12
  <ChainToken loading size="medium" chainImage="" tokenImage="" />
13
13
  <Divider size={8} direction="horizontal" />
@@ -27,10 +27,10 @@ export function LoadingSwapDetails() {
27
27
  <Skeleton width={60} height={10} variant="rounded" />
28
28
  </div>
29
29
 
30
- <div className="route-summary">
31
- {routeSummary}
32
- <div className="route-summary-separator"></div>
33
- {routeSummary}
30
+ <div className="quote-summary">
31
+ {quoteSummary}
32
+ <div className="quote-summary-separator"></div>
33
+ {quoteSummary}
34
34
  </div>
35
35
 
36
36
  <div className="swaps-steps">
@@ -1,33 +1,40 @@
1
- import type { Info } from './NoRoutes.types';
1
+ import type { Info } from './NoResult.types';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
4
 
5
5
  import { errorMessages } from '../../constants/errors';
6
+ import {
7
+ type NoResultError,
8
+ QuoteErrorType,
9
+ type QuoteRequestFailed,
10
+ } from '../../types';
6
11
 
7
12
  export function makeInfo(
8
- diagnosisMessage: string | null,
13
+ error: NoResultError | QuoteRequestFailed | null,
9
14
  disabledLiquiditySources: string[],
10
- hasError: boolean,
11
15
  toggleAllLiquiditySources: (shouldReset: boolean) => void,
12
- refetchBestRoute: () => void
16
+ refetchQuote: () => void
13
17
  ): Info {
14
- if (hasError) {
18
+ if (error?.type === QuoteErrorType.REQUEST_FAILED) {
15
19
  return {
16
20
  alert: {
17
21
  type: 'warning',
18
22
  text: errorMessages().genericServerError,
19
23
  action: {
20
- onClick: refetchBestRoute,
24
+ onClick: refetchQuote,
21
25
  title: i18n.t('Retry'),
22
26
  },
23
27
  },
24
28
  description: '',
25
29
  };
26
- } else if (diagnosisMessage) {
30
+ } else if (
31
+ error?.type === QuoteErrorType.NO_RESULT &&
32
+ error.diagnosisMessage
33
+ ) {
27
34
  return {
28
35
  alert: {
29
36
  type: 'error',
30
- text: diagnosisMessage,
37
+ text: error.diagnosisMessage,
31
38
  action: null,
32
39
  },
33
40
  description: '',
@@ -47,6 +54,6 @@ export function makeInfo(
47
54
  }
48
55
  return {
49
56
  alert: null,
50
- description: errorMessages().noRoutesError.description,
57
+ description: errorMessages().noResultError.description,
51
58
  };
52
59
  }
@@ -1,9 +1,11 @@
1
1
  import { styled } from '@rango-dev/ui';
2
2
 
3
3
  export const Container = styled('div', {
4
+ minHeight: '162px',
4
5
  display: 'flex',
5
6
  flexDirection: 'column',
6
7
  alignItems: 'center',
8
+ justifyContent: 'center',
7
9
  });
8
10
 
9
11
  export const Footer = styled('div', {
@@ -1,4 +1,4 @@
1
- import type { PropTypes } from './NoRoutes.types';
1
+ import type { PropTypes } from './NoResult.types';
2
2
 
3
3
  import {
4
4
  Alert,
@@ -11,26 +11,21 @@ import {
11
11
  import React from 'react';
12
12
 
13
13
  import { errorMessages } from '../../constants/errors';
14
- import { useMetaStore } from '../../store/meta';
15
14
  import { useSettingsStore } from '../../store/settings';
16
15
 
17
- import { makeInfo } from './NoRoutes.helper';
18
- import { Container, Footer, PrefixIcon } from './NoRoutes.styles';
16
+ import { makeInfo } from './NoResult.helpers';
17
+ import { Container, Footer, PrefixIcon } from './NoResult.styles';
19
18
 
20
- export function NoRoutes(props: PropTypes) {
21
- const { diagnosisMessage, fetch, error } = props;
19
+ export function NoResult(props: PropTypes) {
20
+ const { fetch, error } = props;
22
21
  const disabledLiquiditySources =
23
22
  useSettingsStore.use.disabledLiquiditySources();
24
- const loadingMetaStatus = useMetaStore.use.loadingStatus();
25
23
  const toggleAllLiquiditySources =
26
24
  useSettingsStore.use.toggleAllLiquiditySources();
27
25
 
28
- const hasError = error || loadingMetaStatus === 'failed';
29
-
30
26
  const info = makeInfo(
31
- diagnosisMessage ?? null,
27
+ error,
32
28
  disabledLiquiditySources,
33
- hasError,
34
29
  toggleAllLiquiditySources,
35
30
  fetch
36
31
  );
@@ -40,7 +35,7 @@ export function NoRoutes(props: PropTypes) {
40
35
  <NoRouteIcon size={24} color="gray" />
41
36
  <Divider size={4} />
42
37
  <Typography variant="title" size="small">
43
- {errorMessages().noRoutesError.title}
38
+ {errorMessages().noResultError.title}
44
39
  </Typography>
45
40
  {!!info.description && (
46
41
  <Typography
@@ -1,7 +1,8 @@
1
+ import type { NoResultError, QuoteRequestFailed } from '../../types';
2
+
1
3
  export interface PropTypes {
2
4
  fetch: () => void;
3
- error: boolean;
4
- diagnosisMessage?: string;
5
+ error: NoResultError | QuoteRequestFailed | null;
5
6
  }
6
7
 
7
8
  type AlertAction = {
@@ -0,0 +1 @@
1
+ export { NoResult } from './NoResult';
@@ -0,0 +1,212 @@
1
+ import * as Collapsible from '@radix-ui/react-collapsible';
2
+ import { darkTheme, styled } from '@rango-dev/ui';
3
+
4
+ import { CollapsibleContent } from '../ConfirmWalletsModal/ConfirmWallets.styles';
5
+
6
+ export const EXPANDABLE_QUOTE_TRANSITION_DURATION = 300;
7
+
8
+ export const QuoteContainer = styled(Collapsible.Root, {
9
+ display: 'flex',
10
+ flexDirection: 'column',
11
+ alignItems: 'start',
12
+ overflowX: 'auto',
13
+ overflowY: 'hidden',
14
+ width: '100%',
15
+ borderRadius: '$xm',
16
+ variants: {
17
+ recommended: {
18
+ true: {
19
+ $$color: '$colors$info300',
20
+ [`.${darkTheme} &`]: {
21
+ $$color: '$colors$secondary800',
22
+ },
23
+ backgroundColor: '$$color',
24
+ },
25
+ false: {
26
+ $$color: '$colors$neutral400',
27
+ [`.${darkTheme} &`]: {
28
+ $$color: '$colors$neutral200',
29
+ },
30
+ backgroundColor: '$$color',
31
+ },
32
+ },
33
+ },
34
+ '& .steps-details': {
35
+ padding: '$10 $15',
36
+ },
37
+ });
38
+
39
+ export const SummaryContainer = styled('div', {
40
+ borderRadius: '$xm',
41
+ display: 'flex',
42
+ flexDirection: 'column',
43
+ alignItems: 'start',
44
+ justifyContent: 'space-between',
45
+ color: '$foreground',
46
+ cursor: 'pointer',
47
+ boxSizing: 'border-box',
48
+ position: 'relative',
49
+ variants: {
50
+ recommended: {
51
+ true: {
52
+ $$color: '$colors$info100',
53
+ [`.${darkTheme} &`]: {
54
+ $$color: '$colors$secondary600',
55
+ },
56
+ backgroundColor: '$$color',
57
+ '&:hover': {
58
+ backgroundColor: '$$color',
59
+ },
60
+ },
61
+ false: {
62
+ $$color: '$colors$neutral200',
63
+ [`.${darkTheme} &`]: {
64
+ $$color: '$colors$neutral500',
65
+ },
66
+ backgroundColor: '$$color',
67
+ '&:hover': {
68
+ backgroundColor: '$$color',
69
+ },
70
+ },
71
+ },
72
+ basic: { true: { borderTopRightRadius: '0', borderTopLeftRadius: '0' } },
73
+ listItem: {
74
+ true: {},
75
+ false: {},
76
+ },
77
+ },
78
+
79
+ compoundVariants: [
80
+ {
81
+ listItem: true,
82
+ recommended: true,
83
+ css: {
84
+ '&:hover': {
85
+ $$color: '$colors$secondary200',
86
+ [`.${darkTheme} &`]: {
87
+ $$color: '$colors$secondary700',
88
+ },
89
+ backgroundColor: '$$color',
90
+ },
91
+ },
92
+ },
93
+ {
94
+ listItem: true,
95
+ recommended: false,
96
+ css: {
97
+ '&:hover': {
98
+ $$color: '$colors$neutral300',
99
+ [`.${darkTheme} &`]: {
100
+ $$color: '$colors$neutral400',
101
+ },
102
+ backgroundColor: '$$color',
103
+ },
104
+ },
105
+ },
106
+ ],
107
+ '& .summary': {
108
+ width: '100%',
109
+ padding: '$15 $15 $10 $15',
110
+ },
111
+ '& .basic-info': {
112
+ paddingTop: '$10',
113
+ display: 'flex',
114
+ alignItems: 'center',
115
+ },
116
+ });
117
+
118
+ export const Chains = styled(Collapsible.Trigger, {
119
+ display: 'flex',
120
+ width: '100%',
121
+ justifyContent: 'space-between',
122
+ alignItems: 'center',
123
+ height: '$36',
124
+ padding: '$10 $15',
125
+ boxSizing: 'border-box',
126
+ cursor: 'pointer',
127
+ border: 'none',
128
+ outline: 'none',
129
+ backgroundColor: 'transparent',
130
+ variants: {
131
+ error: {
132
+ true: {
133
+ [`& ${Image}`]: {
134
+ border: '1px $warning500 solid',
135
+ borderRadius: '100%',
136
+ },
137
+ },
138
+ false: {
139
+ [`& ${Image}`]: {
140
+ border: '1px transparent solid',
141
+ borderRadius: '100%',
142
+ },
143
+ },
144
+ },
145
+ recommended: {
146
+ true: {
147
+ $$color: '$colors$info300',
148
+ [`.${darkTheme} &`]: {
149
+ $$color: '$colors$secondary800',
150
+ },
151
+ backgroundColor: '$$color',
152
+ },
153
+ false: {
154
+ $$color: '$colors$neutral400',
155
+ [`.${darkTheme} &`]: {
156
+ $$color: '$colors$neutral200',
157
+ },
158
+ backgroundColor: '$$color',
159
+ },
160
+ },
161
+ },
162
+ '& div:nth-child(1)': { display: 'flex' },
163
+ });
164
+
165
+ export const Content = styled(CollapsibleContent, {
166
+ width: '100%',
167
+ });
168
+
169
+ export const IconContainer = styled('div', {
170
+ display: 'flex',
171
+ justifyContent: 'center',
172
+ alignItems: 'center',
173
+ padding: '$2',
174
+ transition: `all ${EXPANDABLE_QUOTE_TRANSITION_DURATION}ms ease`,
175
+ variants: {
176
+ orientation: {
177
+ down: {
178
+ transform: 'rotate(0)',
179
+ },
180
+ up: {
181
+ transform: 'rotate(180deg)',
182
+ },
183
+ },
184
+ },
185
+ });
186
+
187
+ export const Separator = styled('div', {
188
+ height: '$12',
189
+ marginLeft: '$10',
190
+ marginRight: '$10',
191
+ borderLeft: '1px solid $foreground',
192
+ });
193
+
194
+ export const HorizontalSeparator = styled('div', {
195
+ display: 'flex',
196
+ justifyContent: 'center',
197
+ margin: '0 $15',
198
+ borderTop: '1px solid',
199
+ $$color: '$colors$neutral300',
200
+ [`.${darkTheme} &`]: {
201
+ $$color: '$colors$neutral400',
202
+ },
203
+ borderColor: '$$color',
204
+ });
205
+
206
+ export const FrameIcon = styled('div', {
207
+ width: '$16',
208
+ height: '$16',
209
+ justifyContent: 'center',
210
+ alignItems: 'center',
211
+ display: 'flex',
212
+ });