@rango-dev/widget-embedded 0.22.4-next.0 → 0.22.4-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/dist/QueueManager.d.ts.map +1 -1
  2. package/dist/components/AppRoutes.d.ts.map +1 -1
  3. package/dist/components/BlockchainList/BlockchainList.styles.d.ts +3 -0
  4. package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
  5. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -0
  6. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  7. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +2 -2
  8. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  9. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +15 -0
  10. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  11. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  12. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  13. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +3 -0
  14. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
  15. package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts +4 -0
  16. package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts.map +1 -1
  17. package/dist/components/HeaderButtons/HeaderButtons.d.ts +4 -0
  18. package/dist/components/HeaderButtons/HeaderButtons.d.ts.map +1 -0
  19. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +5 -0
  20. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  21. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +3 -2
  22. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
  23. package/dist/components/HeaderButtons/index.d.ts +1 -1
  24. package/dist/components/HeaderButtons/index.d.ts.map +1 -1
  25. package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts +6 -0
  26. package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts.map +1 -1
  27. package/dist/components/Layout/Layout.d.ts.map +1 -1
  28. package/dist/components/Layout/Layout.styles.d.ts +3 -0
  29. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  30. package/dist/components/Layout/Layout.types.d.ts +1 -0
  31. package/dist/components/Layout/Layout.types.d.ts.map +1 -1
  32. package/dist/components/Layout/PageContainer.d.ts +1 -0
  33. package/dist/components/Layout/PageContainer.d.ts.map +1 -1
  34. package/dist/components/Layout/ScrollableArea.d.ts +1 -0
  35. package/dist/components/Layout/ScrollableArea.d.ts.map +1 -1
  36. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -0
  37. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  38. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +14 -0
  39. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
  40. package/dist/components/NoResult/NoResult.styles.d.ts +3 -0
  41. package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
  42. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +4 -0
  43. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  44. package/dist/components/Quote/Quote.d.ts.map +1 -1
  45. package/dist/components/Quote/Quote.styles.d.ts +1136 -25
  46. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  47. package/dist/components/Quote/Quote.types.d.ts +12 -7
  48. package/dist/components/Quote/Quote.types.d.ts.map +1 -1
  49. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
  50. package/dist/components/Quote/QuoteCostDetails.styles.d.ts +5 -0
  51. package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -1
  52. package/dist/components/Quote/QuoteSummary.styles.d.ts +2 -0
  53. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -1
  54. package/dist/components/Quote/QuoteTrigger .d.ts.map +1 -1
  55. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +4 -0
  56. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -1
  57. package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +1 -1
  58. package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +1 -1
  59. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +1 -1
  60. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +20 -10
  61. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +1 -1
  62. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +1 -1
  63. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +1 -1
  64. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +5 -0
  65. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +1 -1
  66. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +4 -0
  67. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
  68. package/dist/components/SearchInput/SearchInput.styles.d.ts +1 -0
  69. package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  70. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +3 -0
  71. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  72. package/dist/components/Slippage/Slippage.styles.d.ts +5 -0
  73. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  74. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +13 -0
  75. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  76. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +1 -0
  77. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
  78. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
  79. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
  80. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +1 -0
  81. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
  82. package/dist/components/SwapDetailsModal/index.d.ts +1 -1
  83. package/dist/components/SwapDetailsModal/index.d.ts.map +1 -1
  84. package/dist/components/TokenList/TokenList.styles.d.ts +17 -0
  85. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  86. package/dist/components/WalletModal/WalletModalContent.styles.d.ts +4 -0
  87. package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
  88. package/dist/constants/languages.d.ts.map +1 -1
  89. package/dist/constants/navigationRoutes.d.ts +1 -0
  90. package/dist/constants/navigationRoutes.d.ts.map +1 -1
  91. package/dist/constants/quote.d.ts +5 -1
  92. package/dist/constants/quote.d.ts.map +1 -1
  93. package/dist/containers/App/App.styles.d.ts +1 -0
  94. package/dist/containers/App/App.styles.d.ts.map +1 -1
  95. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
  96. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +3 -0
  97. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
  98. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +6 -3
  99. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
  100. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  101. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
  102. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +5 -4
  103. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
  104. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts +1 -1
  105. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -1
  106. package/dist/hooks/useFetch.d.ts +12 -0
  107. package/dist/hooks/useFetch.d.ts.map +1 -0
  108. package/dist/hooks/useFetchAllQuotes.d.ts +4 -0
  109. package/dist/hooks/useFetchAllQuotes.d.ts.map +1 -0
  110. package/dist/hooks/useFetchConfirmQuote.d.ts +4 -0
  111. package/dist/hooks/useFetchConfirmQuote.d.ts.map +1 -0
  112. package/dist/hooks/useSwapInput.d.ts +5 -5
  113. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  114. package/dist/hooks/useWalletList.d.ts +1 -0
  115. package/dist/hooks/useWalletList.d.ts.map +1 -1
  116. package/dist/index.js +2 -2
  117. package/dist/index.js.map +4 -4
  118. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  119. package/dist/pages/Home.d.ts.map +1 -1
  120. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  121. package/dist/pages/Routes.d.ts +3 -0
  122. package/dist/pages/Routes.d.ts.map +1 -0
  123. package/dist/pages/SettingsPage.d.ts.map +1 -1
  124. package/dist/pages/WalletsPage.d.ts.map +1 -1
  125. package/dist/store/AppStore.d.ts +2 -2
  126. package/dist/store/app.d.ts +2 -2
  127. package/dist/store/quote.d.ts +32 -10
  128. package/dist/store/quote.d.ts.map +1 -1
  129. package/dist/store/wallets.d.ts +0 -2
  130. package/dist/store/wallets.d.ts.map +1 -1
  131. package/dist/types/quote.d.ts +19 -1
  132. package/dist/types/quote.d.ts.map +1 -1
  133. package/dist/utils/quote.d.ts +12 -9
  134. package/dist/utils/quote.d.ts.map +1 -1
  135. package/dist/utils/settings.d.ts +2 -3
  136. package/dist/utils/settings.d.ts.map +1 -1
  137. package/dist/utils/swap.d.ts +18 -18
  138. package/dist/utils/swap.d.ts.map +1 -1
  139. package/dist/utils/wallets.d.ts +4 -3
  140. package/dist/utils/wallets.d.ts.map +1 -1
  141. package/package.json +10 -10
  142. package/src/QueueManager.tsx +0 -3
  143. package/src/components/AppRoutes.tsx +5 -0
  144. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +3 -3
  145. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +22 -19
  146. package/src/components/ConfirmWalletsModal/WalletList.tsx +24 -18
  147. package/src/components/HeaderButtons/{HomeButtons.tsx → HeaderButtons.tsx} +39 -26
  148. package/src/components/HeaderButtons/HeaderButtons.types.ts +3 -2
  149. package/src/components/HeaderButtons/index.ts +1 -1
  150. package/src/components/Layout/Layout.tsx +13 -1
  151. package/src/components/Layout/Layout.types.ts +1 -0
  152. package/src/components/Quote/Quote.styles.ts +133 -38
  153. package/src/components/Quote/Quote.tsx +77 -18
  154. package/src/components/Quote/Quote.types.ts +13 -7
  155. package/src/components/Quote/QuoteCostDetails.tsx +9 -4
  156. package/src/components/Quote/QuoteTrigger .tsx +7 -3
  157. package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +2 -2
  158. package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +1 -1
  159. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +10 -12
  160. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +28 -9
  161. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +1 -1
  162. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +19 -19
  163. package/src/components/SwapDetails/SwapDetails.tsx +1 -1
  164. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +1 -1
  165. package/src/components/SwapDetailsModal/index.ts +1 -1
  166. package/src/constants/languages.ts +2 -1
  167. package/src/constants/navigationRoutes.ts +1 -0
  168. package/src/constants/quote.ts +17 -1
  169. package/src/containers/QuoteInfo/QuoteInfo.tsx +32 -7
  170. package/src/containers/QuoteInfo/QuoteInfo.types.ts +6 -3
  171. package/src/containers/Wallets/Wallets.tsx +5 -11
  172. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +36 -20
  173. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +76 -78
  174. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +1 -1
  175. package/src/hooks/useFetch.ts +48 -0
  176. package/src/hooks/useFetchAllQuotes.ts +21 -0
  177. package/src/hooks/useFetchConfirmQuote.ts +21 -0
  178. package/src/hooks/useSwapInput.ts +59 -31
  179. package/src/hooks/useWalletList.ts +5 -3
  180. package/src/pages/ConfirmSwapPage.tsx +12 -9
  181. package/src/pages/Home.tsx +25 -15
  182. package/src/pages/LiquiditySourcePage.tsx +3 -5
  183. package/src/pages/Routes.tsx +131 -0
  184. package/src/pages/SettingsPage.tsx +11 -13
  185. package/src/pages/WalletsPage.tsx +24 -18
  186. package/src/store/quote.ts +60 -22
  187. package/src/store/wallets.ts +0 -2
  188. package/src/types/quote.ts +27 -1
  189. package/src/utils/quote.ts +129 -67
  190. package/src/utils/settings.ts +2 -4
  191. package/src/utils/swap.ts +37 -77
  192. package/src/utils/wallets.ts +14 -9
  193. package/dist/components/HeaderButtons/HomeButtons.d.ts +0 -4
  194. package/dist/components/HeaderButtons/HomeButtons.d.ts.map +0 -1
  195. package/dist/hooks/useFetchQuote.d.ts +0 -9
  196. package/dist/hooks/useFetchQuote.d.ts.map +0 -1
  197. package/src/hooks/useFetchQuote.ts +0 -38
@@ -35,19 +35,29 @@ import {
35
35
  getSwapperDisplayName,
36
36
  } from '../../utils/meta';
37
37
  import { formatTooltipNumbers, numberToString } from '../../utils/numbers';
38
- import { getPriceImpact, getPriceImpactLevel } from '../../utils/quote';
38
+ import {
39
+ getPriceImpact,
40
+ getPriceImpactLevel,
41
+ getRouteTagColor,
42
+ sortTags,
43
+ } from '../../utils/quote';
39
44
 
40
45
  import {
46
+ AllRoutesButton,
41
47
  BasicInfoOutput,
42
48
  basicInfoStyles,
43
49
  ContainerInfoOutput,
44
50
  Content,
45
51
  FrameIcon,
46
52
  HorizontalSeparator,
53
+ Line,
47
54
  QuoteContainer,
48
55
  stepsDetailsStyles,
49
56
  SummaryContainer,
57
+ summaryHeaderStyles,
50
58
  summaryStyles,
59
+ Tag,
60
+ TagContainer,
51
61
  } from './Quote.styles';
52
62
  import { QuoteCostDetails } from './QuoteCostDetails';
53
63
  import { QuoteSummary } from './QuoteSummary';
@@ -61,11 +71,12 @@ export function Quote(props: QuoteProps) {
61
71
  error,
62
72
  warning,
63
73
  type,
64
- recommended = true,
74
+ selected = false,
75
+ tagHidden = true,
76
+ onClickAllRoutes,
65
77
  } = props;
66
78
  const blockchains = useAppStore().blockchains();
67
79
  const swappers = useAppStore().swappers();
68
-
69
80
  const [expanded, setExpanded] = useState(props.expanded);
70
81
  const quoteRef = useRef<HTMLButtonElement | null>(null);
71
82
  const roundedInput = numberToString(
@@ -111,6 +122,14 @@ export function Quote(props: QuoteProps) {
111
122
  stepState = 'warning';
112
123
  }
113
124
 
125
+ let alertTitle = stepHasError
126
+ ? i18n.t('Slippage Error')
127
+ : i18n.t('Slippage Warning');
128
+
129
+ if (error?.type === QuoteErrorType.BRIDGE_LIMIT) {
130
+ alertTitle = error?.recommendation;
131
+ }
132
+
114
133
  return {
115
134
  swapper: {
116
135
  displayName: getSwapperDisplayName(swap.swapperId, swappers),
@@ -184,12 +203,9 @@ export function Quote(props: QuoteProps) {
184
203
  stepHasError || stepHasWarning ? (
185
204
  <FooterStepAlarm>
186
205
  <Alert
206
+ variant="alarm"
187
207
  type={stepHasError ? 'error' : 'warning'}
188
- title={
189
- error?.type === QuoteErrorType.BRIDGE_LIMIT
190
- ? error?.recommendation
191
- : i18n.t(`Slippage ${stepHasError ? 'Error' : 'Warning'}:`)
192
- }
208
+ title={alertTitle}
193
209
  footer={
194
210
  <FooterAlert>
195
211
  {error?.type === QuoteErrorType.BRIDGE_LIMIT && (
@@ -258,18 +274,59 @@ export function Quote(props: QuoteProps) {
258
274
  };
259
275
  });
260
276
  };
261
- const steps = getQuoteSteps(quote.result?.swaps ?? []);
277
+ const steps = getQuoteSteps(quote?.swaps ?? []);
278
+
262
279
  const numberOfSteps = steps.length;
263
- const tooltipContainer = getContainer();
280
+ const container = getContainer();
281
+ const sortedQuoteTags = sortTags(props.quote.tags || []);
282
+ const showAllRoutesButton = !!onClickAllRoutes;
264
283
 
265
284
  return (
266
285
  <>
267
286
  <SummaryContainer
268
- recommended={recommended}
287
+ selected={selected}
269
288
  listItem={type === 'list-item'}
270
289
  basic={type === 'basic'}>
271
290
  <div className={summaryStyles()}>
272
- <QuoteCostDetails steps={numberOfSteps} quote={quote} />
291
+ {!tagHidden && sortedQuoteTags.length ? (
292
+ <>
293
+ <TagContainer>
294
+ {sortedQuoteTags.map((tag, index) => {
295
+ const key = `${tag.value}_${index}`;
296
+ return (
297
+ <>
298
+ <Tag
299
+ style={{ color: getRouteTagColor(tag.value) }}
300
+ key={key}>
301
+ {tag.label}
302
+ </Tag>
303
+ <Divider size={4} direction="horizontal" />
304
+ </>
305
+ );
306
+ })}
307
+ </TagContainer>
308
+ <Line />
309
+ {!showAllRoutesButton && <Divider size={4} />}
310
+ </>
311
+ ) : null}
312
+ <div id="portal-root" className={summaryHeaderStyles()}>
313
+ <QuoteCostDetails steps={numberOfSteps} quote={quote} />
314
+
315
+ {showAllRoutesButton && (
316
+ <AllRoutesButton
317
+ onClick={(e) => {
318
+ e.stopPropagation();
319
+ onClickAllRoutes();
320
+ }}
321
+ size="xxsmall"
322
+ type="secondary"
323
+ variant="default">
324
+ <Typography color="secondary" variant="label" size="medium">
325
+ {i18n.t('See All Routes')}
326
+ </Typography>
327
+ </AllRoutesButton>
328
+ )}
329
+ </div>
273
330
  {type === 'basic' && (
274
331
  <div className={basicInfoStyles()}>
275
332
  <FrameIcon>
@@ -281,7 +338,7 @@ export function Quote(props: QuoteProps) {
281
338
  </BasicInfoOutput>
282
339
  <Tooltip
283
340
  content={formatTooltipNumbers(output.value)}
284
- container={tooltipContainer}
341
+ container={container}
285
342
  open={!output.value ? false : undefined}>
286
343
  <BasicInfoOutput size="small" variant="body">
287
344
  &nbsp;
@@ -293,7 +350,7 @@ export function Quote(props: QuoteProps) {
293
350
  </ContainerInfoOutput>
294
351
  <Tooltip
295
352
  content={formatTooltipNumbers(output.usdValue)}
296
- container={tooltipContainer}
353
+ container={container}
297
354
  style={{
298
355
  display: 'flex',
299
356
  }}>
@@ -309,9 +366,9 @@ export function Quote(props: QuoteProps) {
309
366
  )}
310
367
  {type === 'list-item' && (
311
368
  <TokenAmount
369
+ tooltipContainer={container}
312
370
  type="output"
313
371
  direction="vertical"
314
- tooltipContainer={tooltipContainer}
315
372
  price={{
316
373
  value: roundedOutput,
317
374
  usdValue: roundedOutputUsdValue,
@@ -340,12 +397,14 @@ export function Quote(props: QuoteProps) {
340
397
  )}
341
398
  </div>
342
399
  <QuoteContainer
343
- recommended={recommended}
400
+ selected={selected}
401
+ listItem={type === 'list-item'}
344
402
  open={expanded}
345
403
  onOpenChange={setExpanded}>
346
404
  <QuoteTrigger
405
+ type={type}
347
406
  quoteRef={quoteRef}
348
- recommended={recommended}
407
+ selected={selected}
349
408
  setExpanded={setExpanded}
350
409
  expanded={expanded}
351
410
  steps={steps}
@@ -359,10 +418,10 @@ export function Quote(props: QuoteProps) {
359
418
  <StepDetails
360
419
  type="quote-details"
361
420
  key={key}
421
+ tooltipContainer={container}
362
422
  step={step}
363
423
  hasSeparator={index !== steps.length - 1}
364
424
  state={step.state}
365
- tooltipContainer={tooltipContainer}
366
425
  />
367
426
  );
368
427
  })}
@@ -1,23 +1,29 @@
1
- import type { QuoteError, QuoteWarning } from '../../types';
1
+ import type { QuoteError, QuoteWarning, SelectedQuote } from '../../types';
2
2
  import type { Step } from '@rango-dev/ui';
3
- import type { BestRouteResponse } from 'rango-sdk';
4
3
  import type { ReactNode } from 'react';
5
4
 
6
5
  export type QuoteProps = {
7
6
  type: 'basic' | 'list-item' | 'swap-preview';
8
7
  error: QuoteError | null;
9
8
  warning: QuoteWarning | null;
10
- recommended: boolean;
11
- tag?: ReactNode;
12
- quote: BestRouteResponse;
9
+ quote: SelectedQuote;
13
10
  input: { value: string; usdValue: string };
14
11
  output: { value: string; usdValue?: string };
15
12
  expanded?: boolean;
13
+ tagHidden?: boolean;
14
+ selected?: boolean;
15
+ onClickAllRoutes?: () => void;
16
+ };
17
+
18
+ export type optionProps = {
19
+ value: string;
20
+ label: string;
16
21
  };
17
22
 
18
23
  export type QuoteTriggerProps = {
24
+ type: QuoteProps['type'];
19
25
  quoteRef: React.MutableRefObject<HTMLButtonElement | null>;
20
- recommended: boolean;
26
+ selected: boolean;
21
27
  setExpanded: React.Dispatch<React.SetStateAction<boolean | undefined>>;
22
28
  steps: Step[];
23
29
  expanded?: boolean;
@@ -32,6 +38,6 @@ export type QuoteTriggerImagesProps = {
32
38
  };
33
39
 
34
40
  export type QuoteCostDetailsProps = {
35
- quote: BestRouteResponse;
41
+ quote: SelectedQuote | null;
36
42
  steps: number;
37
43
  };
@@ -72,8 +72,8 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
72
72
  const [openCollapse, setOpenCollapse] = useState<boolean>(false);
73
73
  const { steps, quote } = props;
74
74
  const tokens = useAppStore().tokens();
75
- const totalTime = secondsToString(totalArrivalTime(quote.result?.swaps));
76
- const swaps = quote.result?.swaps ?? [];
75
+ const totalTime = secondsToString(totalArrivalTime(quote?.swaps));
76
+ const swaps = quote?.swaps ?? [];
77
77
  const container = getContainer();
78
78
 
79
79
  const totalFee = getTotalFeeInUsd(swaps, tokens);
@@ -83,7 +83,10 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
83
83
  return (
84
84
  <>
85
85
  <QuoteCost
86
- onClickFee={() => setOpen(!open)}
86
+ onClickFee={(e) => {
87
+ e.stopPropagation();
88
+ setOpen(!open);
89
+ }}
87
90
  fee={numberToString(
88
91
  totalFee,
89
92
  GAS_FEE_MIN_DECIMALS,
@@ -110,7 +113,9 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
110
113
  </IconButton>
111
114
  </ModalHeader>
112
115
  }
113
- onClose={() => setOpen(false)}>
116
+ onClose={() => {
117
+ setOpen(false);
118
+ }}>
114
119
  <ModalContainer>
115
120
  <Typography variant="title" size="small">
116
121
  {i18n.t('Details')}
@@ -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';
@@ -1,6 +1,6 @@
1
1
  import type { FlagPropTypes, Language } from '@rango-dev/ui';
2
2
 
3
- import { English, French, Japanese, Spanish } from '@rango-dev/ui';
3
+ import { English, French, Japanese, Portuguese, Spanish } from '@rango-dev/ui';
4
4
 
5
5
  export type LanguageItem = {
6
6
  title: string;
@@ -14,6 +14,7 @@ export const LANGUAGES: LanguageItem[] = [
14
14
  { title: 'Spanish', label: 'Español', local: 'es', SVGFlag: Spanish },
15
15
  { title: 'French', label: 'Français', local: 'fr', SVGFlag: French },
16
16
  { title: 'Japanese', label: '日本語', local: 'ja', SVGFlag: Japanese },
17
+ { title: 'Portuguese', label: 'Português', local: 'pt', SVGFlag: Portuguese },
17
18
  ];
18
19
 
19
20
  export const DEFAULT_LANGUAGE = 'en';
@@ -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() ?? '',