@rango-dev/widget-embedded 0.22.4-next.6 → 0.22.4-next.8

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 (175) hide show
  1. package/dist/components/AppRoutes.d.ts.map +1 -1
  2. package/dist/components/BlockchainList/BlockchainList.styles.d.ts +3 -0
  3. package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
  4. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -0
  5. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  6. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +2 -2
  7. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  8. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +15 -0
  9. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  10. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  11. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +3 -0
  12. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
  13. package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts +4 -0
  14. package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts.map +1 -1
  15. package/dist/components/HeaderButtons/HeaderButtons.d.ts +4 -0
  16. package/dist/components/HeaderButtons/HeaderButtons.d.ts.map +1 -0
  17. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +5 -0
  18. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  19. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +3 -2
  20. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
  21. package/dist/components/HeaderButtons/index.d.ts +1 -1
  22. package/dist/components/HeaderButtons/index.d.ts.map +1 -1
  23. package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts +6 -0
  24. package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts.map +1 -1
  25. package/dist/components/Layout/Layout.d.ts.map +1 -1
  26. package/dist/components/Layout/Layout.styles.d.ts +3 -0
  27. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  28. package/dist/components/Layout/Layout.types.d.ts +1 -0
  29. package/dist/components/Layout/Layout.types.d.ts.map +1 -1
  30. package/dist/components/Layout/PageContainer.d.ts +1 -0
  31. package/dist/components/Layout/PageContainer.d.ts.map +1 -1
  32. package/dist/components/Layout/ScrollableArea.d.ts +1 -0
  33. package/dist/components/Layout/ScrollableArea.d.ts.map +1 -1
  34. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -0
  35. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  36. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +14 -0
  37. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
  38. package/dist/components/NoResult/NoResult.styles.d.ts +3 -0
  39. package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
  40. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +4 -0
  41. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  42. package/dist/components/Quote/Quote.d.ts.map +1 -1
  43. package/dist/components/Quote/Quote.styles.d.ts +1136 -25
  44. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  45. package/dist/components/Quote/Quote.types.d.ts +12 -7
  46. package/dist/components/Quote/Quote.types.d.ts.map +1 -1
  47. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
  48. package/dist/components/Quote/QuoteCostDetails.styles.d.ts +5 -0
  49. package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -1
  50. package/dist/components/Quote/QuoteSummary.styles.d.ts +2 -0
  51. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -1
  52. package/dist/components/Quote/QuoteTrigger .d.ts.map +1 -1
  53. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +4 -0
  54. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -1
  55. package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +1 -1
  56. package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +1 -1
  57. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +1 -1
  58. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +20 -10
  59. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +1 -1
  60. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +1 -1
  61. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +1 -1
  62. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +5 -0
  63. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +1 -1
  64. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +4 -0
  65. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
  66. package/dist/components/SearchInput/SearchInput.styles.d.ts +1 -0
  67. package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  68. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +3 -0
  69. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  70. package/dist/components/Slippage/Slippage.styles.d.ts +5 -0
  71. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  72. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +13 -0
  73. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  74. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +1 -0
  75. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
  76. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
  77. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
  78. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +1 -0
  79. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
  80. package/dist/components/SwapDetailsModal/index.d.ts +1 -1
  81. package/dist/components/SwapDetailsModal/index.d.ts.map +1 -1
  82. package/dist/components/TokenList/TokenList.styles.d.ts +17 -0
  83. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  84. package/dist/components/WalletModal/WalletModalContent.styles.d.ts +4 -0
  85. package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
  86. package/dist/constants/navigationRoutes.d.ts +1 -0
  87. package/dist/constants/navigationRoutes.d.ts.map +1 -1
  88. package/dist/constants/quote.d.ts +5 -1
  89. package/dist/constants/quote.d.ts.map +1 -1
  90. package/dist/containers/App/App.styles.d.ts +1 -0
  91. package/dist/containers/App/App.styles.d.ts.map +1 -1
  92. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
  93. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +3 -0
  94. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
  95. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +6 -3
  96. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
  97. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
  98. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +5 -4
  99. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
  100. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts +1 -1
  101. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -1
  102. package/dist/hooks/useFetch.d.ts +12 -0
  103. package/dist/hooks/useFetch.d.ts.map +1 -0
  104. package/dist/hooks/useFetchAllQuotes.d.ts +4 -0
  105. package/dist/hooks/useFetchAllQuotes.d.ts.map +1 -0
  106. package/dist/hooks/useFetchConfirmQuote.d.ts +4 -0
  107. package/dist/hooks/useFetchConfirmQuote.d.ts.map +1 -0
  108. package/dist/hooks/useSwapInput.d.ts +5 -5
  109. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  110. package/dist/index.js +2 -2
  111. package/dist/index.js.map +4 -4
  112. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  113. package/dist/pages/Home.d.ts.map +1 -1
  114. package/dist/pages/Routes.d.ts +3 -0
  115. package/dist/pages/Routes.d.ts.map +1 -0
  116. package/dist/store/quote.d.ts +32 -10
  117. package/dist/store/quote.d.ts.map +1 -1
  118. package/dist/store/wallets.d.ts +0 -2
  119. package/dist/store/wallets.d.ts.map +1 -1
  120. package/dist/types/quote.d.ts +19 -1
  121. package/dist/types/quote.d.ts.map +1 -1
  122. package/dist/utils/quote.d.ts +12 -9
  123. package/dist/utils/quote.d.ts.map +1 -1
  124. package/dist/utils/swap.d.ts +18 -18
  125. package/dist/utils/swap.d.ts.map +1 -1
  126. package/dist/utils/wallets.d.ts +3 -3
  127. package/dist/utils/wallets.d.ts.map +1 -1
  128. package/package.json +2 -2
  129. package/src/components/AppRoutes.tsx +5 -0
  130. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +3 -3
  131. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +21 -18
  132. package/src/components/HeaderButtons/{HomeButtons.tsx → HeaderButtons.tsx} +39 -26
  133. package/src/components/HeaderButtons/HeaderButtons.types.ts +3 -2
  134. package/src/components/HeaderButtons/index.ts +1 -1
  135. package/src/components/Layout/Layout.tsx +13 -1
  136. package/src/components/Layout/Layout.types.ts +1 -0
  137. package/src/components/Quote/Quote.styles.ts +133 -38
  138. package/src/components/Quote/Quote.tsx +68 -13
  139. package/src/components/Quote/Quote.types.ts +13 -7
  140. package/src/components/Quote/QuoteCostDetails.tsx +9 -4
  141. package/src/components/Quote/QuoteTrigger .tsx +7 -3
  142. package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +2 -2
  143. package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +1 -1
  144. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +10 -12
  145. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +28 -9
  146. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +1 -1
  147. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +19 -19
  148. package/src/components/SwapDetails/SwapDetails.tsx +1 -1
  149. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +1 -1
  150. package/src/components/SwapDetailsModal/index.ts +1 -1
  151. package/src/constants/navigationRoutes.ts +1 -0
  152. package/src/constants/quote.ts +17 -1
  153. package/src/containers/QuoteInfo/QuoteInfo.tsx +32 -7
  154. package/src/containers/QuoteInfo/QuoteInfo.types.ts +6 -3
  155. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +36 -20
  156. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +76 -78
  157. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +1 -1
  158. package/src/hooks/useFetch.ts +48 -0
  159. package/src/hooks/useFetchAllQuotes.ts +21 -0
  160. package/src/hooks/useFetchConfirmQuote.ts +21 -0
  161. package/src/hooks/useSwapInput.ts +59 -31
  162. package/src/pages/ConfirmSwapPage.tsx +12 -9
  163. package/src/pages/Home.tsx +25 -15
  164. package/src/pages/Routes.tsx +131 -0
  165. package/src/store/quote.ts +60 -22
  166. package/src/store/wallets.ts +0 -2
  167. package/src/types/quote.ts +27 -1
  168. package/src/utils/quote.ts +129 -67
  169. package/src/utils/swap.ts +37 -77
  170. package/src/utils/wallets.ts +10 -9
  171. package/dist/components/HeaderButtons/HomeButtons.d.ts +0 -4
  172. package/dist/components/HeaderButtons/HomeButtons.d.ts.map +0 -1
  173. package/dist/hooks/useFetchQuote.d.ts +0 -9
  174. package/dist/hooks/useFetchQuote.d.ts.map +0 -1
  175. package/src/hooks/useFetchQuote.ts +0 -38
@@ -44,7 +44,7 @@ const ImageComponent = (props: QuoteTriggerImagesProps) => {
44
44
  };
45
45
 
46
46
  export function QuoteTrigger(props: QuoteTriggerProps) {
47
- const { quoteRef, recommended, setExpanded, steps, expanded } = props;
47
+ const { quoteRef, selected, setExpanded, steps, expanded, type } = props;
48
48
  const tooltipContainer = getContainer();
49
49
  const numberOfSteps = steps.length;
50
50
  const blockchains = getUniqueBlockchains(steps);
@@ -65,9 +65,13 @@ export function QuoteTrigger(props: QuoteTriggerProps) {
65
65
 
66
66
  return (
67
67
  <Trigger
68
+ listItem={type === 'list-item'}
68
69
  ref={(ref) => (quoteRef.current = ref)}
69
- recommended={recommended}
70
- onClick={() => setExpanded((prevState) => !prevState)}>
70
+ selected={selected}
71
+ onClick={(e) => {
72
+ e.stopPropagation();
73
+ setExpanded((prevState) => !prevState);
74
+ }}>
71
75
  <div className={rowStyles()}>
72
76
  <Typography variant="body" size="xsmall">
73
77
  {i18n.t('Via:')}
@@ -8,11 +8,11 @@ import { QuoteSummarySkeleton } from './QuoteSummarySkeleton';
8
8
  import { StepSkeleton } from './StepSkeleton';
9
9
 
10
10
  export function QuoteSkeleton(props: PropTypes) {
11
- const { type, expanded, tag = false } = props;
11
+ const { type, expanded, tagHidden = false } = props;
12
12
 
13
13
  return (
14
14
  <Container rounded={type !== 'basic'}>
15
- <QuoteSummarySkeleton type={type} tag={tag} />
15
+ <QuoteSummarySkeleton type={type} tagHidden={tagHidden} />
16
16
  <Chains>
17
17
  <Skeleton height={15} variant="rounded" />
18
18
  </Chains>
@@ -1,5 +1,5 @@
1
1
  export type PropTypes = {
2
2
  type: 'basic' | 'list-item' | 'swap-preview';
3
3
  expanded?: boolean;
4
- tag?: boolean;
4
+ tagHidden?: boolean;
5
5
  };
@@ -1,22 +1,15 @@
1
- import { styled } from '@rango-dev/ui';
1
+ import { css, styled } from '@rango-dev/ui';
2
2
 
3
- export const CostAndTag = styled('div', {
4
- display: 'flex',
5
- justifyContent: 'space-between',
6
- alignItems: 'center',
7
- height: '22px',
8
- });
9
-
10
- export const Cost = styled('div', {
3
+ export const FlexContent = styled('div', {
11
4
  display: 'flex',
12
5
  });
13
6
 
14
7
  export const BasicSummary = styled('div', {
15
- padding: '$15 $0 14px $0',
8
+ padding: '$10 $0 $20',
16
9
  });
17
10
 
18
11
  export const Output = styled('div', {
19
- padding: '$6 $0 $15 $0',
12
+ padding: '$12 $0 $20 $0',
20
13
  display: 'flex',
21
14
  flexDirection: 'column',
22
15
  });
@@ -25,7 +18,6 @@ export const OutputTokenInfo = styled('div', {
25
18
  display: 'flex',
26
19
  justifyContent: 'start',
27
20
  alignItems: 'center',
28
- paddingBottom: '$5',
29
21
  });
30
22
 
31
23
  export const QuoteSummary = styled('div', {
@@ -55,3 +47,9 @@ export const TokenAmountLabel = styled('div', {
55
47
  });
56
48
 
57
49
  export const SwapPreview = styled('div', { padding: '$15 $0 $15 $0' });
50
+
51
+ export const RowStyle = css({
52
+ display: 'flex',
53
+ justifyContent: 'space-between',
54
+ alignItems: 'center',
55
+ });
@@ -3,21 +3,23 @@ import type { PropTypes } from './QuoteSummarySkeleton.types';
3
3
  import { ChainToken, Divider, Skeleton } from '@rango-dev/ui';
4
4
  import React from 'react';
5
5
 
6
+ import { Line } from '../Quote/Quote.styles';
7
+
6
8
  import {
7
9
  BasicSummary,
8
- Cost,
9
- CostAndTag,
10
+ FlexContent,
10
11
  Output,
11
12
  OutputTokenInfo,
12
13
  QuoteSummary,
13
14
  QuoteSummarySeparator,
15
+ RowStyle,
14
16
  SwapPreview,
15
17
  TokenAmount,
16
18
  TokenAmountLabel,
17
19
  } from './QuoteSummarySkeleton.styles';
18
20
 
19
21
  export function QuoteSummarySkeleton(props: PropTypes) {
20
- const { type, tag = false } = props;
22
+ const { type, tagHidden = true } = props;
21
23
  const quotePreview = (
22
24
  <QuoteSummary>
23
25
  <TokenAmount>
@@ -32,19 +34,36 @@ export function QuoteSummarySkeleton(props: PropTypes) {
32
34
  <Skeleton height={12} width={64} variant="rounded" />
33
35
  </QuoteSummary>
34
36
  );
37
+ const showAllRoutesSkeleton = type === 'basic' && !tagHidden;
35
38
 
36
39
  return (
37
40
  <div>
38
- <CostAndTag>
39
- <Cost>
41
+ {!tagHidden && (
42
+ <>
43
+ <FlexContent>
44
+ <Skeleton width={65} height={14} variant="rounded" />
45
+ <Divider size={4} direction="horizontal" />
46
+ <Skeleton width={65} height={14} variant="rounded" />
47
+ <Divider size={4} direction="horizontal" />
48
+ <Skeleton width={65} height={14} variant="rounded" />
49
+ </FlexContent>
50
+ <Line />
51
+ {!showAllRoutesSkeleton && <Divider size={4} />}
52
+ </>
53
+ )}
54
+ <div className={RowStyle()}>
55
+ <FlexContent>
40
56
  <Skeleton width={60} height={10} variant="rounded" />
41
57
  <Divider size={4} direction="horizontal" />
42
58
  <Skeleton width={60} height={10} variant="rounded" />
43
59
  <Divider size={4} direction="horizontal" />
44
60
  <Skeleton width={60} height={10} variant="rounded" />
45
- </Cost>
46
- {tag && <Skeleton height={22} width={100} variant="rounded" />}
47
- </CostAndTag>
61
+ </FlexContent>
62
+ {showAllRoutesSkeleton && (
63
+ <Skeleton width={100} height={22} variant="rounded" />
64
+ )}
65
+ </div>
66
+
48
67
  {type === 'basic' && (
49
68
  <BasicSummary>
50
69
  <Skeleton height={15} width={148} variant="rounded" />
@@ -57,7 +76,7 @@ export function QuoteSummarySkeleton(props: PropTypes) {
57
76
  <Divider direction="horizontal" size={4} />
58
77
  <Skeleton height={15} width={150} variant="rounded" />
59
78
  </OutputTokenInfo>
60
- <Divider size={4} />
79
+ <Divider size={10} />
61
80
  <Skeleton height={10} width={184} variant="rounded" />
62
81
  </Output>
63
82
  )}
@@ -2,5 +2,5 @@ import type { QuoteProps } from '../Quote/Quote.types';
2
2
 
3
3
  export type PropTypes = {
4
4
  type: QuoteProps['type'];
5
- tag?: boolean;
5
+ tagHidden?: boolean;
6
6
  };
@@ -25,6 +25,25 @@ export function makeAlerts(
25
25
  title: '',
26
26
  action: 'show-info',
27
27
  };
28
+ if (error) {
29
+ alertInfo.alertType = 'error';
30
+ if (error.type === QuoteErrorType.BRIDGE_LIMIT) {
31
+ alertInfo.title = error.recommendation;
32
+ alertInfo.action = 'show-info';
33
+ }
34
+
35
+ if (error.type === QuoteErrorType.INSUFFICIENT_SLIPPAGE) {
36
+ alertInfo.title = i18n.t({
37
+ id: 'You need to increase slippage to at least {minRequiredSlippage} for this route.',
38
+ values: {
39
+ minRequiredSlippage: error.minRequiredSlippage,
40
+ },
41
+ });
42
+ alertInfo.action = 'change-settings';
43
+ }
44
+
45
+ return alertInfo;
46
+ }
28
47
  if (warning) {
29
48
  if (warning.type === QuoteWarningType.HIGH_VALUE_LOSS) {
30
49
  const warningLevel = getPriceImpactLevel(warning.priceImpact);
@@ -51,24 +70,5 @@ export function makeAlerts(
51
70
  }
52
71
  return alertInfo;
53
72
  }
54
- if (error) {
55
- alertInfo.alertType = 'error';
56
- if (error.type === QuoteErrorType.BRIDGE_LIMIT) {
57
- alertInfo.title = error.recommendation;
58
- alertInfo.action = 'show-info';
59
- }
60
-
61
- if (error.type === QuoteErrorType.INSUFFICIENT_SLIPPAGE) {
62
- alertInfo.title = i18n.t({
63
- id: 'You need to increase slippage to at least {minRequiredSlippage} for this route.',
64
- values: {
65
- minRequiredSlippage: error.minRequiredSlippage,
66
- },
67
- });
68
- alertInfo.action = 'change-settings';
69
- }
70
-
71
- return alertInfo;
72
- }
73
73
  return null;
74
74
  }
@@ -163,7 +163,7 @@ export function SwapDetails(props: SwapDetailsProps) {
163
163
  setNetworkModal: setModalState,
164
164
  message: stepMessage,
165
165
  blockchains: blockchains,
166
- swappers: swappers,
166
+ swappers,
167
167
  });
168
168
  const numberOfSteps = steps.length;
169
169
  const [firstStep, lastStep] = [swap.steps[0], swap.steps[numberOfSteps - 1]];
@@ -1,12 +1,12 @@
1
1
  import type { getSwapMessages } from '../../utils/swap';
2
2
  import type { ModalState } from '../SwapDetailsModal';
3
3
  import type { ConnectResult } from '@rango-dev/wallets-react';
4
+ import type { SwapperMeta } from 'rango-sdk';
4
5
  import type {
5
6
  BlockchainMeta,
6
7
  PendingSwap,
7
8
  PendingSwapNetworkStatus,
8
9
  PendingSwapStep,
9
- SwapperMeta,
10
10
  } from 'rango-types';
11
11
 
12
12
  export interface SwapAlertsProps extends WaningAlertsProps {
@@ -1,3 +1,3 @@
1
1
  export { SwapDetailsModal } from './SwapDetailsModal';
2
2
  export { SwapDetailsCompleteModal } from './SwapDetailsCompleteModal';
3
- export type { ModalState } from './SwapDetailsModal.types';
3
+ export type { ModalState, ModalPropTypes } from './SwapDetailsModal.types';
@@ -13,4 +13,5 @@ export const navigationRoutes = {
13
13
  wallets: 'wallets',
14
14
  confirmSwap: 'confirm-swap',
15
15
  swapDetails: ':requestId',
16
+ routes: 'routes',
16
17
  };
@@ -1,4 +1,4 @@
1
- import type { SwapFee } from 'rango-sdk';
1
+ import type { PreferenceType, SwapFee, TagValue } from 'rango-sdk';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
4
 
@@ -21,3 +21,19 @@ export type FeesGroup = {
21
21
  payable: { [key in NameOfFees]?: SwapFee[] };
22
22
  nonePayable: { [key in NameOfFees]?: SwapFee[] };
23
23
  };
24
+
25
+ export const ROUTE_SORTING_STRATEGY: { [key in PreferenceType]: string } = {
26
+ SPEED: i18n.t('Fastest Transfer'),
27
+ NET_OUTPUT: i18n.t('Maximum Return'),
28
+ FEE: i18n.t('Lowest Fee'),
29
+ PRICE: i18n.t('Maximum Output'),
30
+ SMART: i18n.t('Smart Routing'),
31
+ };
32
+
33
+ export const HIGH_PRIORITY_TAGS: TagValue[] = [
34
+ 'RECOMMENDED',
35
+ 'CENTRALIZED',
36
+ 'LOWEST_FEE',
37
+ 'FASTEST',
38
+ 'HIGH_IMPACT',
39
+ ];
@@ -1,43 +1,68 @@
1
1
  import type { PropTypes } from './QuoteInfo.types';
2
2
 
3
+ import BigNumber from 'bignumber.js';
3
4
  import React from 'react';
4
5
 
5
6
  import { Quote } from '../../components/Quote';
6
7
  import { QuoteSkeleton } from '../../components/QuoteSkeleton';
7
8
  import { useQuoteStore } from '../../store/quote';
8
9
  import { QuoteErrorType } from '../../types';
10
+ import { getQuoteToTokenUsdPrice } from '../../utils/quote';
11
+ import { calcOutputUsdValue } from '../../utils/swap';
9
12
 
10
13
  import { QuoteContainer } from './QuoteInfo.styles';
11
14
 
12
15
  export function QuoteInfo(props: PropTypes) {
13
- const { quote, type, loading, error, warning, expanded = false } = props;
14
- const { inputAmount, inputUsdValue, outputUsdValue, outputAmount } =
15
- useQuoteStore();
16
+ const {
17
+ quote,
18
+ type,
19
+ loading,
20
+ error,
21
+ warning,
22
+ expanded = false,
23
+ tagHidden,
24
+ onClick,
25
+ selected,
26
+ onClickAllRoutes,
27
+ } = props;
28
+ const { inputAmount, inputUsdValue, toToken } = useQuoteStore();
29
+
30
+ const outputAmount = !!quote?.outputAmount
31
+ ? new BigNumber(quote?.outputAmount)
32
+ : null;
33
+ const outputUsdValue = !!quote?.outputAmount
34
+ ? calcOutputUsdValue(
35
+ quote?.outputAmount,
36
+ getQuoteToTokenUsdPrice(quote) || toToken?.usdPrice
37
+ )
38
+ : null;
16
39
 
17
40
  const noResult =
18
41
  error &&
19
42
  (error.type === QuoteErrorType.NO_RESULT ||
20
43
  error.type === QuoteErrorType.REQUEST_FAILED);
21
44
 
22
- const showQuote = !noResult && quote && quote.result && !loading;
45
+ const showQuote = !noResult && quote && !loading;
23
46
 
24
47
  if (loading) {
25
48
  return (
26
49
  <QuoteContainer>
27
- <QuoteSkeleton type={type} expanded={expanded} />
50
+ <QuoteSkeleton tagHidden={tagHidden} type={type} expanded={expanded} />
28
51
  </QuoteContainer>
29
52
  );
30
53
  }
31
54
 
32
55
  return showQuote ? (
33
- <QuoteContainer>
56
+ <QuoteContainer onClick={() => onClick?.(quote)}>
34
57
  <Quote
35
58
  quote={quote}
36
59
  error={error}
37
60
  warning={warning}
61
+ tagHidden={tagHidden}
62
+ selected={selected}
38
63
  type={type}
39
64
  expanded={expanded}
40
- recommended={true}
65
+ onClickAllRoutes={onClickAllRoutes}
41
66
  input={{
42
67
  value: inputAmount,
43
68
  usdValue: inputUsdValue?.toString() ?? '',
@@ -1,13 +1,16 @@
1
1
  import type { QuoteProps } from '../../components/Quote/Quote.types';
2
- import type { QuoteError, QuoteWarning } from '../../types';
3
- import type { BestRouteResponse } from 'rango-sdk';
2
+ import type { QuoteError, QuoteWarning, SelectedQuote } from '../../types';
4
3
 
5
4
  export type PropTypes = {
6
- quote: BestRouteResponse | null;
5
+ quote: SelectedQuote | null;
7
6
  type: QuoteProps['type'];
7
+ onClick?: (quote: SelectedQuote) => void;
8
8
  loading: boolean;
9
+ tagHidden?: boolean;
9
10
  error: QuoteError | null;
10
11
  warning: QuoteWarning | null;
11
12
  autoScrollOnExpanding?: boolean;
12
13
  expanded?: boolean;
14
+ onClickAllRoutes?: () => void;
15
+ selected?: boolean;
13
16
  };
@@ -1,6 +1,12 @@
1
1
  import type { ConfirmSwapFetchResult } from './useConfirmSwap.types';
2
- import type { ConfirmSwapWarnings, Wallet } from '../../types';
3
- import type { BestRouteResponse, BlockchainMeta, Token } from 'rango-sdk';
2
+ import type {
3
+ ConfirmSwapWarnings,
4
+ QuoteErrorResponse,
5
+ QuoteResponse,
6
+ SelectedQuote,
7
+ Wallet,
8
+ } from '../../types';
9
+ import type { BlockchainMeta, SwapResult, Token } from 'rango-sdk';
4
10
 
5
11
  import { errorMessages } from '../../constants/errors';
6
12
  import { QuoteErrorType, QuoteUpdateType } from '../../types';
@@ -26,8 +32,8 @@ import {
26
32
  /**
27
33
  * A request can be successful but in body of the response, it can be some case which is considered as failed.
28
34
  */
29
- export function throwErrorIfResponseIsNotValid(response: BestRouteResponse) {
30
- if (!response.result) {
35
+ export function throwErrorIfResponseIsNotValid(response: QuoteResponse) {
36
+ if (!response.swaps) {
31
37
  throw new Error(errorMessages().noResultError.title, {
32
38
  cause: {
33
39
  type: QuoteErrorType.NO_RESULT,
@@ -35,40 +41,49 @@ export function throwErrorIfResponseIsNotValid(response: BestRouteResponse) {
35
41
  },
36
42
  });
37
43
  }
38
- const limitError = hasLimitError(response);
44
+ const quoteError = getQuoteError(response.swaps);
45
+ if (quoteError) {
46
+ throw new Error(quoteError.message, {
47
+ cause: quoteError.options,
48
+ });
49
+ }
50
+ }
51
+
52
+ export function getQuoteError(swaps: SwapResult[]): QuoteErrorResponse | null {
53
+ const limitError = hasLimitError(swaps);
39
54
  if (limitError) {
40
55
  const { swap, recommendation, fromAmountRangeError } =
41
- getLimitErrorMessage(response);
42
-
43
- throw new Error('bridge limit error', {
44
- cause: {
56
+ getLimitErrorMessage(swaps);
57
+ return {
58
+ message: 'bridge limit error',
59
+ options: {
45
60
  type: QuoteErrorType.BRIDGE_LIMIT,
46
- swap: swap,
61
+ swap,
47
62
  recommendation,
48
63
  fromAmountRangeError,
49
64
  },
50
- });
65
+ };
51
66
  }
52
67
 
53
- const recommendedSlippages = checkSlippageErrors(response);
68
+ const recommendedSlippages = checkSlippageErrors(swaps);
54
69
 
55
70
  if (recommendedSlippages) {
56
- const minRequiredSlippage = getMinRequiredSlippage(response);
57
- throw new Error('', {
58
- cause: {
71
+ const minRequiredSlippage = getMinRequiredSlippage(swaps);
72
+ return {
73
+ message: '',
74
+ options: {
59
75
  type: QuoteErrorType.INSUFFICIENT_SLIPPAGE,
60
76
  recommendedSlippages,
61
77
  minRequiredSlippage,
62
78
  },
63
- });
79
+ };
64
80
  }
65
-
66
- return response;
81
+ return null;
67
82
  }
68
83
 
69
84
  export function generateWarnings(
70
- previousQuote: BestRouteResponse | undefined,
71
- currentQuote: BestRouteResponse,
85
+ previousQuote: SelectedQuote | undefined,
86
+ currentQuote: SelectedQuote,
72
87
  params: {
73
88
  fromToken: Token;
74
89
  toToken: Token;
@@ -132,6 +147,7 @@ export function generateWarnings(
132
147
  params.selectedWallets,
133
148
  params.meta.blockchains
134
149
  );
150
+
135
151
  const enoughBalance = balanceWarnings.length === 0;
136
152
 
137
153
  if (!enoughBalance) {