@rango-dev/widget-embedded 0.21.1-next.0 → 0.21.1-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 (138) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
  2. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  4. package/dist/components/CustomCollapsible/CustomCollapsible.d.ts.map +1 -1
  5. package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
  6. package/dist/components/HistoryGroupedList/HistoryGroupedList.d.ts +4 -0
  7. package/dist/components/HistoryGroupedList/HistoryGroupedList.d.ts.map +1 -0
  8. package/dist/components/HistoryGroupedList/HistoryGroupedList.helpers.d.ts +2 -0
  9. package/dist/components/HistoryGroupedList/HistoryGroupedList.helpers.d.ts.map +1 -0
  10. package/dist/components/{SwapsGroup/SwapsGroup.styles.d.ts → HistoryGroupedList/HistoryGroupedList.styles.d.ts} +162 -1
  11. package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts.map +1 -0
  12. package/dist/components/{SwapsGroup/SwapsGroup.types.d.ts → HistoryGroupedList/HistoryGroupedList.types.d.ts} +5 -4
  13. package/dist/components/HistoryGroupedList/HistoryGroupedList.types.d.ts.map +1 -0
  14. package/dist/components/HistoryGroupedList/index.d.ts +2 -0
  15. package/dist/components/HistoryGroupedList/index.d.ts.map +1 -0
  16. package/dist/components/Layout/Layout.d.ts.map +1 -1
  17. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  18. package/dist/components/Layout/Layout.types.d.ts +0 -1
  19. package/dist/components/Layout/Layout.types.d.ts.map +1 -1
  20. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  21. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  22. package/dist/components/Quote/Quote.d.ts.map +1 -1
  23. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
  24. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +1 -1
  25. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -1
  26. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +1 -1
  27. package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
  28. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
  29. package/dist/components/SwapDetailsModal/SwapDetailsModal.d.ts.map +1 -1
  30. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  31. package/dist/components/WalletModal/WalletModal.d.ts.map +1 -1
  32. package/dist/components/common/ActivateTabModal/ActivateTabModal.d.ts.map +1 -1
  33. package/dist/components/common/WatermarkedModal/WatermarkedModal.d.ts +5 -0
  34. package/dist/components/common/WatermarkedModal/WatermarkedModal.d.ts.map +1 -0
  35. package/dist/components/common/WatermarkedModal/index.d.ts +2 -0
  36. package/dist/components/common/WatermarkedModal/index.d.ts.map +1 -0
  37. package/dist/constants/index.d.ts +7 -1
  38. package/dist/constants/index.d.ts.map +1 -1
  39. package/dist/constants/searchParams.d.ts +2 -1
  40. package/dist/constants/searchParams.d.ts.map +1 -1
  41. package/dist/containers/App/App.d.ts.map +1 -1
  42. package/dist/hooks/useFetchApiConfig.d.ts +7 -0
  43. package/dist/hooks/useFetchApiConfig.d.ts.map +1 -0
  44. package/dist/hooks/useIframe/index.d.ts +2 -0
  45. package/dist/hooks/useIframe/index.d.ts.map +1 -0
  46. package/dist/hooks/useIframe/useIframe.d.ts +9 -0
  47. package/dist/hooks/useIframe/useIframe.d.ts.map +1 -0
  48. package/dist/hooks/useIframe/useIframe.helpers.d.ts +2 -0
  49. package/dist/hooks/useIframe/useIframe.helpers.d.ts.map +1 -0
  50. package/dist/hooks/useIframe/useIframe.types.d.ts +10 -0
  51. package/dist/hooks/useIframe/useIframe.types.d.ts.map +1 -0
  52. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
  53. package/dist/hooks/useWalletList.d.ts +1 -0
  54. package/dist/hooks/useWalletList.d.ts.map +1 -1
  55. package/dist/index.d.ts +2 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +2 -2
  58. package/dist/index.js.map +4 -4
  59. package/dist/pages/Home.d.ts.map +1 -1
  60. package/dist/pages/WalletsPage.d.ts.map +1 -1
  61. package/dist/store/slices/config.d.ts +8 -0
  62. package/dist/store/slices/config.d.ts.map +1 -1
  63. package/dist/store/ui.d.ts +5 -0
  64. package/dist/store/ui.d.ts.map +1 -1
  65. package/dist/types/config.d.ts +1 -0
  66. package/dist/types/config.d.ts.map +1 -1
  67. package/dist/types/notification.d.ts +4 -4
  68. package/dist/types/notification.d.ts.map +1 -1
  69. package/dist/utils/common.d.ts.map +1 -1
  70. package/dist/utils/date.d.ts +1 -1
  71. package/dist/utils/date.d.ts.map +1 -1
  72. package/dist/utils/wallets.d.ts +2 -1
  73. package/dist/utils/wallets.d.ts.map +1 -1
  74. package/package.json +2 -2
  75. package/readme.md +1 -0
  76. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +9 -7
  77. package/src/components/ConfirmWalletsModal/WalletList.tsx +35 -27
  78. package/src/components/CustomCollapsible/CustomCollapsible.tsx +1 -10
  79. package/src/components/HeaderButtons/HomeButtons.tsx +2 -1
  80. package/src/components/HistoryGroupedList/HistoryGroupedList.helpers.ts +17 -0
  81. package/src/components/{SwapsGroup/SwapsGroup.styles.ts → HistoryGroupedList/HistoryGroupedList.styles.ts} +9 -0
  82. package/src/components/HistoryGroupedList/HistoryGroupedList.tsx +162 -0
  83. package/src/components/{SwapsGroup/SwapsGroup.types.ts → HistoryGroupedList/HistoryGroupedList.types.ts} +4 -3
  84. package/src/components/HistoryGroupedList/index.ts +1 -0
  85. package/src/components/Layout/Layout.styles.ts +12 -6
  86. package/src/components/Layout/Layout.tsx +47 -22
  87. package/src/components/Layout/Layout.types.ts +0 -1
  88. package/src/components/NotificationContent/NotificationContent.styles.ts +1 -0
  89. package/src/components/NotificationContent/NotificationContent.tsx +13 -22
  90. package/src/components/NotificationContent/NotificationNotFound.tsx +1 -1
  91. package/src/components/Quote/Quote.tsx +2 -12
  92. package/src/components/Quote/QuoteCostDetails.tsx +3 -3
  93. package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +4 -3
  94. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +5 -3
  95. package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +4 -4
  96. package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +7 -5
  97. package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +29 -3
  98. package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +7 -5
  99. package/src/components/TokenList/TokenList.tsx +4 -24
  100. package/src/components/WalletModal/WalletModal.tsx +8 -5
  101. package/src/components/common/ActivateTabModal/ActivateTabModal.tsx +9 -3
  102. package/src/components/common/WatermarkedModal/WatermarkedModal.tsx +18 -0
  103. package/src/components/common/WatermarkedModal/index.ts +1 -0
  104. package/src/constants/index.ts +7 -1
  105. package/src/constants/searchParams.ts +2 -0
  106. package/src/containers/App/App.tsx +3 -1
  107. package/src/hooks/useFetchApiConfig.ts +33 -0
  108. package/src/hooks/useIframe/index.ts +1 -0
  109. package/src/hooks/useIframe/useIframe.helpers.ts +3 -0
  110. package/src/hooks/useIframe/useIframe.ts +55 -0
  111. package/src/hooks/useIframe/useIframe.types.ts +13 -0
  112. package/src/hooks/useSwapInput.ts +2 -2
  113. package/src/hooks/useSyncStoresWithConfig.ts +3 -3
  114. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +11 -1
  115. package/src/hooks/useWalletList.ts +20 -4
  116. package/src/index.ts +2 -0
  117. package/src/pages/HistoryPage.tsx +6 -6
  118. package/src/pages/Home.tsx +2 -3
  119. package/src/pages/WalletsPage.tsx +24 -18
  120. package/src/store/notification.ts +4 -4
  121. package/src/store/slices/config.ts +29 -1
  122. package/src/store/slices/data.ts +2 -2
  123. package/src/store/ui.ts +8 -0
  124. package/src/types/config.ts +1 -0
  125. package/src/types/notification.ts +4 -4
  126. package/src/utils/common.ts +2 -2
  127. package/src/utils/configs.ts +3 -3
  128. package/src/utils/date.ts +9 -2
  129. package/src/utils/meta.ts +2 -2
  130. package/src/utils/wallets.ts +5 -1
  131. package/dist/components/SwapsGroup/SwapsGroup.d.ts +0 -4
  132. package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +0 -1
  133. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +0 -1
  134. package/dist/components/SwapsGroup/SwapsGroup.types.d.ts.map +0 -1
  135. package/dist/components/SwapsGroup/index.d.ts +0 -2
  136. package/dist/components/SwapsGroup/index.d.ts.map +0 -1
  137. package/src/components/SwapsGroup/SwapsGroup.tsx +0 -141
  138. package/src/components/SwapsGroup/index.ts +0 -1
@@ -1,13 +1,14 @@
1
1
  import type { PendingSwap } from 'rango-types';
2
2
 
3
3
  export type GroupBy = (list: PendingSwap[]) => {
4
- title: string;
5
4
  swaps: PendingSwap[];
6
- }[];
5
+ groups: string[];
6
+ groupCounts: number[];
7
+ };
7
8
 
8
9
  export interface PropTypes {
9
10
  list: PendingSwap[];
10
11
  onSwapClick: (requestId: string) => void;
11
- groupBy?: GroupBy;
12
+ groupBy: GroupBy;
12
13
  isLoading: boolean;
13
14
  }
@@ -0,0 +1 @@
1
+ export { HistoryGroupedList } from './HistoryGroupedList';
@@ -1,12 +1,13 @@
1
1
  import { styled } from '@rango-dev/ui';
2
2
 
3
3
  const WIDGET_HEIGHT = '700px';
4
+
4
5
  export const Container = styled('div', {
5
6
  position: 'relative',
6
7
  display: 'flex',
7
8
  flexDirection: 'column',
8
9
  borderRadius: '$primary',
9
- width: '100vh',
10
+ width: '100vw',
10
11
  minWidth: '300px',
11
12
  maxWidth: '390px',
12
13
  boxShadow: '15px 15px 15px 0px rgba(0, 0, 0, 0.05)',
@@ -35,12 +36,17 @@ export const Content = styled('div', {
35
36
  padding: 0,
36
37
  overflowY: 'auto',
37
38
  });
39
+
38
40
  export const Footer = styled('div', {
39
- backgroundColor: '$background',
40
- '& .footer__content': {
41
- padding: '$0 $20',
42
- },
41
+ padding: '0 $20 $10',
43
42
  '& .footer__logo': {
44
- padding: '$0 $20 $10 $20',
43
+ opacity: 0,
44
+ transition: 'opacity 1s ease-in-out',
45
+ '&.logo__show': {
46
+ opacity: 1,
47
+ },
48
+ '&.logo__hidden': {
49
+ visibility: 'hidden',
50
+ },
45
51
  },
46
52
  });
@@ -6,7 +6,9 @@ import { useManager } from '@rango-dev/queue-manager-react';
6
6
  import { BottomLogo, Divider, Header } from '@rango-dev/ui';
7
7
  import React, { useEffect, useRef } from 'react';
8
8
 
9
- import { RANGO_SWAP_BOX_ID } from '../../constants';
9
+ import { WIDGET_UI_ID } from '../../constants';
10
+ import { useIframe } from '../../hooks/useIframe';
11
+ import { isAppLoadedIntoIframe } from '../../hooks/useIframe/useIframe.helpers';
10
12
  import { useNavigateBack } from '../../hooks/useNavigateBack';
11
13
  import { useTheme } from '../../hooks/useTheme';
12
14
  import { useAppStore } from '../../store/AppStore';
@@ -23,11 +25,15 @@ import { onScrollContentAttachStatusToContainer } from './Layout.helpers';
23
25
  import { Container, Content, Footer } from './Layout.styles';
24
26
 
25
27
  function Layout(props: PropsWithChildren<PropTypes>) {
26
- const { children, header, footer, hasLogo = true, height = 'fixed' } = props;
28
+ const { connectHeightObserver, disconnectHeightObserver } = useIframe();
29
+ const { children, header, footer, height = 'fixed' } = props;
27
30
  const connectedWallets = useWalletsStore.use.connectedWallets();
28
31
  const {
29
32
  config: { features, theme },
30
33
  } = useAppStore();
34
+ const { watermark } = useUiStore();
35
+
36
+ const hasWatermark = watermark === 'FULL';
31
37
  const { activeTheme } = useTheme(theme || {});
32
38
 
33
39
  const isConnectWalletHidden = isFeatureHidden(
@@ -60,13 +66,26 @@ function Layout(props: PropsWithChildren<PropTypes>) {
60
66
  typeof header.hasBackButton === 'undefined' || header.hasBackButton;
61
67
 
62
68
  const scrollViewRef = useRef<HTMLDivElement>(null);
69
+ const containerRef = useRef<HTMLDivElement>(null);
70
+
71
+ useEffect(() => {
72
+ const isIframe = isAppLoadedIntoIframe();
73
+
74
+ // This feature only will be available in an iframe context.
75
+ if (isIframe && containerRef.current) {
76
+ connectHeightObserver(containerRef.current);
77
+ }
78
+
79
+ return () => {
80
+ disconnectHeightObserver();
81
+ };
82
+ }, []);
63
83
 
64
84
  useEffect(() => {
65
85
  scrollViewRef.current?.addEventListener(
66
86
  'scroll',
67
87
  onScrollContentAttachStatusToContainer
68
88
  );
69
-
70
89
  return () => {
71
90
  scrollViewRef.current?.removeEventListener(
72
91
  'scroll',
@@ -76,7 +95,11 @@ function Layout(props: PropsWithChildren<PropTypes>) {
76
95
  }, []);
77
96
 
78
97
  return (
79
- <Container height={height} id={RANGO_SWAP_BOX_ID} className={activeTheme()}>
98
+ <Container
99
+ height={height}
100
+ id={WIDGET_UI_ID.SWAP_BOX_ID}
101
+ className={activeTheme()}
102
+ ref={containerRef}>
80
103
  <Header
81
104
  prefix={<>{showBackButton && <BackButton onClick={navigateBack} />}</>}
82
105
  title={header.title}
@@ -100,25 +123,27 @@ function Layout(props: PropsWithChildren<PropTypes>) {
100
123
  onClose={() => setShowActivateTabModal(false)}
101
124
  onConfirm={onActivateTab}
102
125
  />
103
- {(hasLogo || footer) && (
104
- <Footer>
105
- <div className="footer__content">
106
- {footer}
107
- {tabManagerInitiated && !isActiveTab && (
108
- <>
109
- <Divider size={12} />
110
- <ActivateTabAlert onActivateTab={onActivateTab} />
111
- </>
112
- )}
113
- </div>
114
- <Divider size={12} />
115
- {hasLogo && (
116
- <div className="footer__logo">
117
- <BottomLogo />
118
- </div>
126
+
127
+ <Footer>
128
+ <div className="footer__content">
129
+ {footer}
130
+ {tabManagerInitiated && !isActiveTab && (
131
+ <>
132
+ <Divider size={12} />
133
+ <ActivateTabAlert onActivateTab={onActivateTab} />
134
+ </>
119
135
  )}
120
- </Footer>
121
- )}
136
+ </div>
137
+
138
+ <Divider size={12} />
139
+
140
+ <div
141
+ className={`footer__logo ${
142
+ hasWatermark ? 'logo__show' : 'logo__hidden'
143
+ }`}>
144
+ <BottomLogo />
145
+ </div>
146
+ </Footer>
122
147
  </Container>
123
148
  );
124
149
  }
@@ -15,7 +15,6 @@ export interface PropTypes {
15
15
  hasBackButton?: boolean;
16
16
  onCancel?: () => void;
17
17
  };
18
- hasLogo?: boolean;
19
18
  footer?: React.ReactNode;
20
19
  height?: ContainerHeightProp;
21
20
  }
@@ -3,6 +3,7 @@ import { styled } from '@rango-dev/ui';
3
3
  export const Container = styled('div', {
4
4
  padding: '$10',
5
5
  width: '350px',
6
+ maxWidth: '90vw',
6
7
  minHeight: '150px',
7
8
  });
8
9
 
@@ -14,6 +14,7 @@ import { useNavigate } from 'react-router-dom';
14
14
  import { navigationRoutes } from '../../constants/navigationRoutes';
15
15
  import { useAppStore } from '../../store/AppStore';
16
16
  import { useNotificationStore } from '../../store/notification';
17
+ import { areTokensEqual } from '../../utils/wallets';
17
18
 
18
19
  import { Container, Images, List } from './NotificationContent.styles';
19
20
  import { NotificationNotFound } from './NotificationNotFound';
@@ -41,50 +42,40 @@ export function NotificationContent() {
41
42
  {sortedNotification.length ? (
42
43
  <List>
43
44
  {sortedNotification.map((notificationItem) => {
44
- const fromToken = tokens.find(
45
- (tokenItem) =>
46
- tokenItem.address ===
47
- notificationItem.route.from.tokenAddress &&
48
- tokenItem.blockchain ===
49
- notificationItem.route.from.blockchain &&
50
- tokenItem.symbol === notificationItem.route.from.tokenSymbol
45
+ const { route, requestId, event } = notificationItem;
46
+ const fromToken = tokens.find((tokenItem) =>
47
+ areTokensEqual(tokenItem, route.from)
51
48
  );
52
49
 
53
50
  const fromBlockchain = blockchains.find(
54
- (blockchainItem) =>
55
- blockchainItem.name === notificationItem.route.from.blockchain
51
+ (blockchainItem) => blockchainItem.name === route.from.blockchain
56
52
  );
57
53
 
58
- const toToken = tokens.find(
59
- (tokenItem) =>
60
- tokenItem.address === notificationItem.route.to.tokenAddress &&
61
- tokenItem.blockchain === notificationItem.route.to.blockchain &&
62
- tokenItem.symbol === notificationItem.route.to.tokenSymbol
54
+ const toToken = tokens.find((tokenItem) =>
55
+ areTokensEqual(tokenItem, route.to)
63
56
  );
64
57
 
65
58
  const toBlockchain = blockchains.find(
66
- (blockchainItem) =>
67
- blockchainItem.name === notificationItem.route.to.blockchain
59
+ (blockchainItem) => blockchainItem.name === route.to.blockchain
68
60
  );
69
61
 
70
62
  return (
71
63
  <ListItemButton
72
- key={notificationItem.requestId}
73
- onClick={() => handleOnClick(notificationItem.requestId)}
64
+ key={requestId}
65
+ onClick={() => handleOnClick(requestId)}
74
66
  title={
75
67
  <Typography
76
68
  variant="body"
77
69
  size="small"
78
70
  color={
79
- notificationItem.event.messageSeverity ===
80
- EventSeverity.WARNING
71
+ event.messageSeverity === EventSeverity.WARNING
81
72
  ? '$foreground'
82
73
  : '$neutral700'
83
74
  }>
84
- {i18n.t(notificationItem.event.message)}
75
+ {i18n.t(event.message)}
85
76
  </Typography>
86
77
  }
87
- id={notificationItem.requestId}
78
+ id={requestId}
88
79
  start={
89
80
  <Images>
90
81
  <div className="from-chain-token">
@@ -10,7 +10,7 @@ export function NotificationNotFound() {
10
10
  <NoNotificationIcon color="secondary" size={26} />
11
11
  <Divider size={12} />
12
12
  <Typography variant="body" size="medium" color="neutral700">
13
- {i18n.t('You have no notification')}
13
+ {i18n.t('There are no notifications.')}
14
14
  </Typography>
15
15
  </NotFoundContainer>
16
16
  );
@@ -13,7 +13,7 @@ import {
13
13
  Typography,
14
14
  } from '@rango-dev/ui';
15
15
  import BigNumber from 'bignumber.js';
16
- import React, { useLayoutEffect, useRef, useState } from 'react';
16
+ import React, { useRef, useState } from 'react';
17
17
 
18
18
  import {
19
19
  PERCENTAGE_CHANGE_MAX_DECIMALS,
@@ -42,7 +42,6 @@ import {
42
42
  basicInfoStyles,
43
43
  ContainerInfoOutput,
44
44
  Content,
45
- EXPANDABLE_QUOTE_TRANSITION_DURATION,
46
45
  FrameIcon,
47
46
  HorizontalSeparator,
48
47
  QuoteContainer,
@@ -69,7 +68,6 @@ export function Quote(props: QuoteProps) {
69
68
 
70
69
  const [expanded, setExpanded] = useState(props.expanded);
71
70
  const quoteRef = useRef<HTMLButtonElement | null>(null);
72
- const prevExpanded = useRef(expanded);
73
71
  const roundedInput = numberToString(
74
72
  input.value,
75
73
  TOKEN_AMOUNT_MIN_DECIMALS,
@@ -190,7 +188,7 @@ export function Quote(props: QuoteProps) {
190
188
  title={
191
189
  error?.type === QuoteErrorType.BRIDGE_LIMIT
192
190
  ? error?.recommendation
193
- : i18n.t('Slippage Error:')
191
+ : i18n.t(`Slippage ${stepHasError ? 'Error' : 'Warning'}:`)
194
192
  }
195
193
  footer={
196
194
  <FooterAlert>
@@ -263,14 +261,6 @@ export function Quote(props: QuoteProps) {
263
261
  const steps = getQuoteSteps(quote.result?.swaps ?? []);
264
262
  const numberOfSteps = steps.length;
265
263
  const tooltipContainer = getContainer();
266
- useLayoutEffect(() => {
267
- if (expanded && !prevExpanded.current && quoteRef.current) {
268
- setTimeout(() => {
269
- quoteRef?.current?.scrollIntoView({ behavior: 'smooth' });
270
- }, EXPANDABLE_QUOTE_TRANSITION_DURATION);
271
- }
272
- prevExpanded.current = expanded;
273
- }, [expanded, prevExpanded]);
274
264
 
275
265
  return (
276
266
  <>
@@ -7,7 +7,6 @@ import {
7
7
  CloseIcon,
8
8
  Divider,
9
9
  IconButton,
10
- Modal,
11
10
  QuoteCost,
12
11
  Tooltip,
13
12
  Typography,
@@ -36,6 +35,7 @@ import {
36
35
  getTotalFeesInUsd,
37
36
  getUsdFee,
38
37
  } from '../../utils/swap';
38
+ import { WatermarkedModal } from '../common/WatermarkedModal';
39
39
  import { CustomCollapsible } from '../CustomCollapsible/CustomCollapsible';
40
40
  import { ExpandedIcon } from '../CustomCollapsible/CustomCollapsible.styles';
41
41
 
@@ -96,7 +96,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
96
96
  tooltipContainer={container}
97
97
  />
98
98
 
99
- <Modal
99
+ <WatermarkedModal
100
100
  container={container}
101
101
  open={open}
102
102
  header={
@@ -212,7 +212,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
212
212
  </CustomCollapsible>
213
213
  )}
214
214
  </ModalContainer>
215
- </Modal>
215
+ </WatermarkedModal>
216
216
  </>
217
217
  );
218
218
  }
@@ -5,7 +5,6 @@ import {
5
5
  Button,
6
6
  Divider,
7
7
  MessageBox,
8
- Modal,
9
8
  Typography,
10
9
  WarningIcon,
11
10
  } from '@rango-dev/ui';
@@ -22,6 +21,7 @@ import {
22
21
  } from '../../constants/routing';
23
22
  import { getContainer } from '../../utils/common';
24
23
  import { numberToString } from '../../utils/numbers';
24
+ import { WatermarkedModal } from '../common/WatermarkedModal';
25
25
 
26
26
  import { QuoteErrorsModalItem } from './QuoteErrorsModalItem';
27
27
  import { Flex } from './QuoteWarningsAndErrors.styles';
@@ -37,6 +37,7 @@ type Props = {
37
37
  export function HighValueLossWarningModal(props: Props) {
38
38
  const { open, onClose, onConfirm, warning, confirmationDisabled } = props;
39
39
  const type = warning.warningLevel === 'high' ? 'error' : 'warning';
40
+
40
41
  const highValueLossData = [
41
42
  {
42
43
  title: i18n.t('Swapping'),
@@ -74,7 +75,7 @@ export function HighValueLossWarningModal(props: Props) {
74
75
  ];
75
76
 
76
77
  return (
77
- <Modal open={open} onClose={onClose} container={getContainer()}>
78
+ <WatermarkedModal open={open} onClose={onClose} container={getContainer()}>
78
79
  <MessageBox
79
80
  type={type}
80
81
  title={errorMessages().highValueLossError.impactTitle}
@@ -104,6 +105,6 @@ export function HighValueLossWarningModal(props: Props) {
104
105
  onClick={onConfirm}>
105
106
  {errorMessages().highValueLossError.confirmMessage}
106
107
  </Button>
107
- </Modal>
108
+ </WatermarkedModal>
108
109
  );
109
110
  }
@@ -4,7 +4,7 @@ import type {
4
4
  } from '../../types';
5
5
 
6
6
  import { i18n } from '@lingui/core';
7
- import { Button, Divider, MessageBox, Modal, Typography } from '@rango-dev/ui';
7
+ import { Button, Divider, MessageBox, Typography } from '@rango-dev/ui';
8
8
  import React from 'react';
9
9
  import { useNavigate } from 'react-router-dom';
10
10
 
@@ -12,6 +12,7 @@ import { navigationRoutes } from '../../constants/navigationRoutes';
12
12
  import { useAppStore } from '../../store/AppStore';
13
13
  import { QuoteWarningType } from '../../types';
14
14
  import { getContainer } from '../../utils/common';
15
+ import { WatermarkedModal } from '../common/WatermarkedModal';
15
16
 
16
17
  type PropsTypes = {
17
18
  open: boolean;
@@ -26,8 +27,9 @@ export function SlippageWarningModal(props: PropsTypes) {
26
27
  const { open, onClose, onConfirm, warning, confirmationDisabled } = props;
27
28
  const navigate = useNavigate();
28
29
  const userSlippage = customSlippage ?? slippage;
30
+
29
31
  return (
30
- <Modal
32
+ <WatermarkedModal
31
33
  anchor="bottom"
32
34
  open={open}
33
35
  prefix={
@@ -74,6 +76,6 @@ export function SlippageWarningModal(props: PropsTypes) {
74
76
  {i18n.t('Confirm anyway')}
75
77
  </Button>
76
78
  </MessageBox>
77
- </Modal>
79
+ </WatermarkedModal>
78
80
  );
79
81
  }
@@ -1,10 +1,11 @@
1
1
  import type { UnknownPriceWarning } from '../../types';
2
2
 
3
- import { Button, Divider, MessageBox, Modal, WarningIcon } from '@rango-dev/ui';
3
+ import { Button, Divider, MessageBox, WarningIcon } from '@rango-dev/ui';
4
4
  import React from 'react';
5
5
 
6
6
  import { errorMessages } from '../../constants/errors';
7
7
  import { getContainer } from '../../utils/common';
8
+ import { WatermarkedModal } from '../common/WatermarkedModal';
8
9
 
9
10
  type Props = {
10
11
  open: boolean;
@@ -16,9 +17,8 @@ type Props = {
16
17
 
17
18
  export function UnknownPriceWarningModal(props: Props) {
18
19
  const { open, onClose, onConfirm, confirmationDisabled } = props;
19
-
20
20
  return (
21
- <Modal open={open} onClose={onClose} container={getContainer()}>
21
+ <WatermarkedModal open={open} onClose={onClose} container={getContainer()}>
22
22
  <MessageBox
23
23
  type="warning"
24
24
  title={errorMessages().unknownPriceError.impactTitle}
@@ -35,6 +35,6 @@ export function UnknownPriceWarningModal(props: Props) {
35
35
  onClick={onConfirm}>
36
36
  {errorMessages().unknownPriceError.confirmMessage}
37
37
  </Button>
38
- </Modal>
38
+ </WatermarkedModal>
39
39
  );
40
40
  }
@@ -5,15 +5,15 @@ import {
5
5
  Button,
6
6
  Divider,
7
7
  MessageBox,
8
- Modal,
9
8
  TokenAmount,
10
9
  Typography,
11
10
  } from '@rango-dev/ui';
12
11
  import React from 'react';
13
12
  import { useNavigate } from 'react-router-dom';
14
13
 
15
- import { RANGO_SWAP_BOX_ID } from '../../constants';
14
+ import { WIDGET_UI_ID } from '../../constants';
16
15
  import { getContainer } from '../../utils/common';
16
+ import { WatermarkedModal } from '../common/WatermarkedModal';
17
17
 
18
18
  export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
19
19
  const {
@@ -33,10 +33,12 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
33
33
  const navigate = useNavigate();
34
34
 
35
35
  return (
36
- <Modal
36
+ <WatermarkedModal
37
37
  open={open}
38
38
  onClose={onClose}
39
- container={document.getElementById(RANGO_SWAP_BOX_ID) || document.body}>
39
+ container={
40
+ document.getElementById(WIDGET_UI_ID.SWAP_BOX_ID) || document.body
41
+ }>
40
42
  {status === 'success' ? (
41
43
  <MessageBox type="success" title={i18n.t('Swap Successful')}>
42
44
  <TokenAmount
@@ -105,6 +107,6 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
105
107
  {i18n.t('See Details')}
106
108
  </Typography>
107
109
  </Button>
108
- </Modal>
110
+ </WatermarkedModal>
109
111
  );
110
112
  }
@@ -1,8 +1,8 @@
1
1
  import type { WalletStateContentProps } from './SwapDetailsModal.types';
2
2
 
3
- import { MessageBox, Wallet } from '@rango-dev/ui';
3
+ import { MessageBox, Wallet, WalletState } from '@rango-dev/ui';
4
4
  import { useWallets } from '@rango-dev/wallets-react';
5
- import React from 'react';
5
+ import React, { useEffect, useRef } from 'react';
6
6
 
7
7
  import { getContainer } from '../../utils/common';
8
8
  import { mapStatusToWalletState } from '../../utils/wallets';
@@ -18,14 +18,40 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
18
18
  showWalletButton,
19
19
  walletButtonDisabled,
20
20
  } = props;
21
- const { connect, getWalletInfo, state } = useWallets();
21
+ const { connect, getWalletInfo, state, disconnect } = useWallets();
22
22
  const walletType = currentStepWallet?.walletType;
23
23
  const walletState = walletType
24
24
  ? mapStatusToWalletState(state(walletType))
25
25
  : null;
26
+ const componentWillUnmount = useRef(false);
27
+
26
28
  const walletInfo = walletType ? getWalletInfo(walletType) : null;
27
29
  const shouldShowWallet =
28
30
  showWalletButton && !!walletType && !!walletState && !!walletInfo;
31
+
32
+ /*
33
+ * The order of useEffects is crucial.
34
+ * 1- The first useEffect for componentWillUnmount sets its value to true
35
+ */
36
+ useEffect(() => {
37
+ return () => {
38
+ componentWillUnmount.current = true;
39
+ };
40
+ }, []);
41
+
42
+ // 2- The second useEffect checks if componentWillUnmount is true then it disconnects connecting wallet
43
+ useEffect(() => {
44
+ return () => {
45
+ if (
46
+ componentWillUnmount.current &&
47
+ walletType &&
48
+ walletState === WalletState.CONNECTING
49
+ ) {
50
+ void disconnect(walletType);
51
+ }
52
+ };
53
+ }, [walletState]);
54
+
29
55
  return (
30
56
  <>
31
57
  <MessageBox type={type} title={title} description={message} />
@@ -1,10 +1,10 @@
1
1
  import type { ModalPropTypes } from './SwapDetailsModal.types';
2
2
 
3
- import { Modal } from '@rango-dev/ui';
4
3
  import { PendingSwapNetworkStatus } from 'rango-types';
5
4
  import React from 'react';
6
5
 
7
- import { RANGO_SWAP_BOX_ID } from '../../constants';
6
+ import { WIDGET_UI_ID } from '../../constants';
7
+ import { WatermarkedModal } from '../common/WatermarkedModal';
8
8
 
9
9
  import { CancelContent } from './SwapDetailsModal.Cancel';
10
10
  import { DeleteContent } from './SwapDetailsModal.Delete';
@@ -28,10 +28,12 @@ export function SwapDetailsModal(props: ModalPropTypes) {
28
28
  state === PendingSwapNetworkStatus.NetworkChanged;
29
29
 
30
30
  return (
31
- <Modal
31
+ <WatermarkedModal
32
32
  open={!!state}
33
33
  onClose={onClose}
34
- container={document.getElementById(RANGO_SWAP_BOX_ID) || document.body}>
34
+ container={
35
+ document.getElementById(WIDGET_UI_ID.SWAP_BOX_ID) || document.body
36
+ }>
35
37
  {showWalletStateContent && (
36
38
  <WalletStateContent
37
39
  type={modalNetworkValues[state].type}
@@ -50,6 +52,6 @@ export function SwapDetailsModal(props: ModalPropTypes) {
50
52
  {state === 'cancel' && (
51
53
  <CancelContent onClose={onClose} onCancel={onCancel} />
52
54
  )}
53
- </Modal>
55
+ </WatermarkedModal>
54
56
  );
55
57
  }
@@ -1,7 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-magic-numbers */
2
2
  import type { PropTypes, RenderDescProps } from './TokenList.types';
3
3
  import type { Token } from 'rango-sdk';
4
- import type { CommonProps } from 'react-window';
5
4
 
6
5
  import { i18n } from '@lingui/core';
7
6
  import {
@@ -16,7 +15,7 @@ import {
16
15
  Typography,
17
16
  VirtualizedList,
18
17
  } from '@rango-dev/ui';
19
- import React, { forwardRef, useEffect, useState } from 'react';
18
+ import React, { useEffect, useState } from 'react';
20
19
 
21
20
  import { useAppStore } from '../../store/AppStore';
22
21
  import { useWalletsStore } from '../../store/wallets';
@@ -100,20 +99,6 @@ export function TokenList(props: PropTypes) {
100
99
  const { getBalanceFor, loading: loadingWallet } = useWalletsStore();
101
100
  const { isTokenPinned } = useAppStore();
102
101
 
103
- // eslint-disable-next-line react/display-name
104
- const innerElementType: React.FC<CommonProps> = forwardRef((render, ref) => {
105
- return (
106
- <div
107
- {...render}
108
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
109
- ref={ref as any}
110
- style={{
111
- ...render.style,
112
- height: `${parseFloat(render.style?.height as string) + 8 * 2}px`,
113
- }}
114
- />
115
- );
116
- });
117
102
  const loadNextPage = () => {
118
103
  setTokens(list.slice(0, tokens.length + PAGE_SIZE));
119
104
  };
@@ -140,7 +125,8 @@ export function TokenList(props: PropTypes) {
140
125
  }
141
126
  return (
142
127
  <VirtualizedList
143
- Item={({ index, style }) => {
128
+ endReached={hasNextPage ? loadNextPage : undefined}
129
+ itemContent={(index) => {
144
130
  const token = tokens[index];
145
131
  const tokenBalance = formatBalance(getBalanceFor(token));
146
132
  const address = token.address || '';
@@ -171,12 +157,10 @@ export function TokenList(props: PropTypes) {
171
157
  return (
172
158
  <div
173
159
  style={{
174
- ...style,
175
160
  paddingRight: 5,
176
161
  }}>
177
162
  <ListItemButton
178
163
  style={{
179
- height: style?.height,
180
164
  width: '100%',
181
165
  overflow: 'hidden',
182
166
  }}
@@ -261,11 +245,7 @@ export function TokenList(props: PropTypes) {
261
245
  </div>
262
246
  );
263
247
  }}
264
- hasNextPage={hasNextPage}
265
- itemCount={tokens.length}
266
- loadNextPage={loadNextPage}
267
- innerElementType={innerElementType}
268
- size={60}
248
+ totalCount={tokens.length}
269
249
  key={`${selectedBlockchain}-${searchedFor}`}
270
250
  />
271
251
  );