@rango-dev/widget-embedded 0.31.1-next.2 → 0.32.0

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 (193) hide show
  1. package/dist/components/AppRoutes.d.ts.map +1 -1
  2. package/dist/components/BlockchainList/BlockchainList.d.ts.map +1 -1
  3. package/dist/components/BlockchainList/BlockchainList.styles.d.ts +4 -1
  4. package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
  5. package/dist/components/BlockchainList/BlockchainList.types.d.ts +1 -0
  6. package/dist/components/BlockchainList/BlockchainList.types.d.ts.map +1 -1
  7. package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.d.ts +4 -0
  8. package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.d.ts.map +1 -0
  9. package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.styles.d.ts +483 -0
  10. package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.styles.d.ts.map +1 -0
  11. package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.types.d.ts +12 -0
  12. package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.types.d.ts.map +1 -0
  13. package/dist/components/BlockchainSelectorButton/index.d.ts +2 -0
  14. package/dist/components/BlockchainSelectorButton/index.d.ts.map +1 -0
  15. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -0
  16. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  17. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +11 -0
  18. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  19. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +3 -0
  20. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
  21. package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts +4 -0
  22. package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts.map +1 -1
  23. package/dist/components/CustomDestination/CustomDestination.d.ts.map +1 -1
  24. package/dist/components/CustomDestination/CustomDestination.styles.d.ts +5 -2
  25. package/dist/components/CustomDestination/CustomDestination.styles.d.ts.map +1 -1
  26. package/dist/components/CustomTokenModal/CustomTokenModal.d.ts +4 -0
  27. package/dist/components/CustomTokenModal/CustomTokenModal.d.ts.map +1 -0
  28. package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts +3 -0
  29. package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts.map +1 -0
  30. package/dist/components/CustomTokenModal/CustomTokenModal.styles.d.ts +323 -0
  31. package/dist/components/CustomTokenModal/CustomTokenModal.styles.d.ts.map +1 -0
  32. package/dist/components/CustomTokenModal/CustomTokenModal.types.d.ts +9 -0
  33. package/dist/components/CustomTokenModal/CustomTokenModal.types.d.ts.map +1 -0
  34. package/dist/components/CustomTokenModal/index.d.ts +2 -0
  35. package/dist/components/CustomTokenModal/index.d.ts.map +1 -0
  36. package/dist/components/FilterSelector/FilterSelector.style.d.ts +6 -0
  37. package/dist/components/FilterSelector/FilterSelector.style.d.ts.map +1 -1
  38. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +8 -0
  39. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  40. package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts +6 -0
  41. package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts.map +1 -1
  42. package/dist/components/Layout/Layout.styles.d.ts +4 -0
  43. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  44. package/dist/components/Layout/PageContainer.d.ts +1 -0
  45. package/dist/components/Layout/PageContainer.d.ts.map +1 -1
  46. package/dist/components/Layout/ScrollableArea.d.ts +1 -0
  47. package/dist/components/Layout/ScrollableArea.d.ts.map +1 -1
  48. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -0
  49. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  50. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +14 -0
  51. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
  52. package/dist/components/NoResult/NoResult.styles.d.ts +4 -0
  53. package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
  54. package/dist/components/Quote/Quote.styles.d.ts +22 -1
  55. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  56. package/dist/components/Quote/QuoteCostDetails.styles.d.ts +5 -0
  57. package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -1
  58. package/dist/components/Quote/QuoteSummary.styles.d.ts +2 -0
  59. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -1
  60. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +4 -0
  61. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -1
  62. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +10 -0
  63. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.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/Quotes/Quotes.styles.d.ts +3 -0
  69. package/dist/components/Quotes/Quotes.styles.d.ts.map +1 -1
  70. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +2 -1
  71. package/dist/components/RefreshModal/RefreshModal.styles.d.ts.map +1 -1
  72. package/dist/components/SearchInput/SearchInput.styles.d.ts +1 -0
  73. package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  74. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +3 -0
  75. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  76. package/dist/components/Slippage/Slippage.styles.d.ts +5 -0
  77. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  78. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +15 -0
  79. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  80. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +3 -0
  81. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
  82. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +2 -0
  83. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
  84. package/dist/components/SwitchFromAndTo/SwitchFromAndTo.styles.d.ts +2 -0
  85. package/dist/components/SwitchFromAndTo/SwitchFromAndTo.styles.d.ts.map +1 -1
  86. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  87. package/dist/components/TokenList/TokenList.styles.d.ts +18 -0
  88. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  89. package/dist/components/TokenList/TokenList.types.d.ts +5 -2
  90. package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
  91. package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.styles.d.ts +2 -0
  92. package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.styles.d.ts.map +1 -1
  93. package/dist/components/WalletModal/WalletModalContent.styles.d.ts +4 -0
  94. package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
  95. package/dist/components/WalletNamespacesModal/WalletNamespacesModal.styles.d.ts +1 -0
  96. package/dist/components/WalletNamespacesModal/WalletNamespacesModal.styles.d.ts.map +1 -1
  97. package/dist/constants/customTokens.d.ts +2 -0
  98. package/dist/constants/customTokens.d.ts.map +1 -0
  99. package/dist/constants/navigationRoutes.d.ts +2 -0
  100. package/dist/constants/navigationRoutes.d.ts.map +1 -1
  101. package/dist/constants/searchParams.d.ts +1 -0
  102. package/dist/constants/searchParams.d.ts.map +1 -1
  103. package/dist/containers/App/App.styles.d.ts +1 -0
  104. package/dist/containers/App/App.styles.d.ts.map +1 -1
  105. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts +2 -0
  106. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
  107. package/dist/containers/Inputs/Inputs.styles.d.ts +2 -0
  108. package/dist/containers/Inputs/Inputs.styles.d.ts.map +1 -1
  109. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +3 -0
  110. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
  111. package/dist/containers/Settings/Lists.d.ts.map +1 -1
  112. package/dist/hooks/useFetchCustomToken.d.ts +16 -0
  113. package/dist/hooks/useFetchCustomToken.d.ts.map +1 -0
  114. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  115. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  116. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
  117. package/dist/hooks/useTheme.d.ts +1 -0
  118. package/dist/hooks/useTheme.d.ts.map +1 -1
  119. package/dist/index.js +2 -2
  120. package/dist/index.js.map +4 -4
  121. package/dist/pages/AddCustomTokenPage.d.ts +3 -0
  122. package/dist/pages/AddCustomTokenPage.d.ts.map +1 -0
  123. package/dist/pages/CustomTokensPage.d.ts +3 -0
  124. package/dist/pages/CustomTokensPage.d.ts.map +1 -0
  125. package/dist/pages/SelectBlockchainPage.d.ts +2 -1
  126. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  127. package/dist/store/AppStore.d.ts +2 -0
  128. package/dist/store/AppStore.d.ts.map +1 -1
  129. package/dist/store/app.d.ts +2 -0
  130. package/dist/store/app.d.ts.map +1 -1
  131. package/dist/store/quote.d.ts.map +1 -1
  132. package/dist/store/slices/data.d.ts +4 -3
  133. package/dist/store/slices/data.d.ts.map +1 -1
  134. package/dist/store/slices/settings.d.ts +7 -2
  135. package/dist/store/slices/settings.d.ts.map +1 -1
  136. package/dist/store/utils/data.d.ts +4 -1
  137. package/dist/store/utils/data.d.ts.map +1 -1
  138. package/dist/types/config.d.ts +3 -1
  139. package/dist/types/config.d.ts.map +1 -1
  140. package/dist/utils/meta.d.ts +1 -0
  141. package/dist/utils/meta.d.ts.map +1 -1
  142. package/dist/utils/quote.d.ts +1 -0
  143. package/dist/utils/quote.d.ts.map +1 -1
  144. package/dist/utils/settings.d.ts +3 -2
  145. package/dist/utils/settings.d.ts.map +1 -1
  146. package/dist/utils/swap.d.ts.map +1 -1
  147. package/dist/widget-embedded.build.json +1 -1
  148. package/package.json +4 -4
  149. package/src/components/AppRoutes.tsx +30 -0
  150. package/src/components/BlockchainList/BlockchainList.styles.ts +3 -1
  151. package/src/components/BlockchainList/BlockchainList.tsx +26 -17
  152. package/src/components/BlockchainList/BlockchainList.types.ts +1 -0
  153. package/src/components/BlockchainSelectorButton/BlockchainSelectorButton.styles.ts +49 -0
  154. package/src/components/BlockchainSelectorButton/BlockchainSelectorButton.tsx +47 -0
  155. package/src/components/BlockchainSelectorButton/BlockchainSelectorButton.types.ts +11 -0
  156. package/src/components/BlockchainSelectorButton/index.ts +1 -0
  157. package/src/components/CustomDestination/CustomDestination.tsx +5 -3
  158. package/src/components/CustomTokenModal/CustomTokenModal.helpers.ts +19 -0
  159. package/src/components/CustomTokenModal/CustomTokenModal.styles.ts +57 -0
  160. package/src/components/CustomTokenModal/CustomTokenModal.tsx +92 -0
  161. package/src/components/CustomTokenModal/CustomTokenModal.types.ts +9 -0
  162. package/src/components/CustomTokenModal/index.ts +1 -0
  163. package/src/components/TokenList/TokenList.styles.ts +1 -0
  164. package/src/components/TokenList/TokenList.tsx +76 -51
  165. package/src/components/TokenList/TokenList.types.ts +5 -2
  166. package/src/constants/customTokens.ts +6 -0
  167. package/src/constants/navigationRoutes.ts +2 -0
  168. package/src/constants/searchParams.ts +3 -0
  169. package/src/containers/Settings/Lists.tsx +25 -1
  170. package/src/hooks/useFetchCustomToken.ts +114 -0
  171. package/src/hooks/useSwapInput.ts +8 -3
  172. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +6 -1
  173. package/src/hooks/useTheme.ts +5 -1
  174. package/src/pages/AddCustomTokenPage.tsx +210 -0
  175. package/src/pages/CustomTokensPage.tsx +184 -0
  176. package/src/pages/HistoryPage.tsx +2 -2
  177. package/src/pages/LiquiditySourcePage.tsx +2 -2
  178. package/src/pages/SelectBlockchainPage.tsx +15 -8
  179. package/src/pages/SelectSwapItemsPage.tsx +1 -1
  180. package/src/store/app.ts +1 -0
  181. package/src/store/quote.ts +12 -2
  182. package/src/store/slices/data.ts +61 -8
  183. package/src/store/slices/settings.ts +35 -2
  184. package/src/store/utils/data.ts +26 -1
  185. package/src/store/wallets.ts +1 -1
  186. package/src/types/config.ts +4 -1
  187. package/src/utils/meta.ts +12 -1
  188. package/src/utils/quote.ts +16 -3
  189. package/src/utils/settings.ts +13 -1
  190. package/src/utils/swap.ts +7 -7
  191. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +0 -3
  192. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +0 -1
  193. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +0 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.31.1-next.2",
3
+ "version": "0.32.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -25,12 +25,12 @@
25
25
  "@lingui/core": "4.2.1",
26
26
  "@lingui/react": "4.2.1",
27
27
  "@rango-dev/logging-core": "^0.6.0",
28
- "@rango-dev/provider-all": "^0.36.1-next.0",
28
+ "@rango-dev/provider-all": "^0.36.0",
29
29
  "@rango-dev/queue-manager-core": "^0.27.0",
30
30
  "@rango-dev/queue-manager-rango-preset": "^0.36.0",
31
31
  "@rango-dev/queue-manager-react": "^0.27.0",
32
- "@rango-dev/signer-solana": "^0.31.1-next.0",
33
- "@rango-dev/ui": "^0.37.1-next.0",
32
+ "@rango-dev/signer-solana": "^0.31.0",
33
+ "@rango-dev/ui": "^0.38.0",
34
34
  "@rango-dev/wallets-react": "^0.22.0",
35
35
  "@rango-dev/wallets-shared": "^0.36.0",
36
36
  "bignumber.js": "^9.1.1",
@@ -4,7 +4,9 @@ import { useRoutes } from 'react-router-dom';
4
4
  import { navigationRoutes } from '../constants/navigationRoutes';
5
5
  import { useSyncStoresWithConfig } from '../hooks/useSyncStoresWithConfig';
6
6
  import { useSyncUrlAndStore } from '../hooks/useSyncUrlAndStore';
7
+ import { AddCustomTokenPage } from '../pages/AddCustomTokenPage';
7
8
  import { ConfirmSwapPage } from '../pages/ConfirmSwapPage';
9
+ import { CustomTokensPage } from '../pages/CustomTokensPage';
8
10
  import { HistoryPage } from '../pages/HistoryPage';
9
11
  import { Home } from '../pages/Home';
10
12
  import { LanguagePage } from '../pages/LanguagePage';
@@ -80,8 +82,36 @@ export function AppRoutes() {
80
82
  path: navigationRoutes.bridges,
81
83
  element: <LiquiditySourcePage sourceType="Bridges" />,
82
84
  },
85
+ {
86
+ path: navigationRoutes.customTokens,
87
+ children: [
88
+ {
89
+ index: true,
90
+ element: <CustomTokensPage />,
91
+ },
92
+ {
93
+ path: navigationRoutes.addCustomTokens,
94
+ children: [
95
+ {
96
+ index: true,
97
+ element: <AddCustomTokenPage />,
98
+ },
99
+ {
100
+ path: navigationRoutes.blockchains,
101
+ element: (
102
+ <SelectBlockchainPage
103
+ hideCategory={true}
104
+ type="custom-token"
105
+ />
106
+ ),
107
+ },
108
+ ],
109
+ },
110
+ ],
111
+ },
83
112
  ],
84
113
  },
114
+
85
115
  {
86
116
  path: navigationRoutes.swaps,
87
117
  children: [
@@ -2,10 +2,12 @@ import { ImageContainer, styled } from '@rango-dev/ui';
2
2
 
3
3
  import { ScrollableArea } from '../Layout';
4
4
 
5
- export const Container = styled('div', {
5
+ export const BlockchainListContainer = styled('div', {
6
6
  display: 'flex',
7
7
  flexDirection: 'column',
8
8
  overflow: 'hidden',
9
+ height: '100%',
10
+ justifyContent: 'center',
9
11
  });
10
12
 
11
13
  export const List = styled(ScrollableArea, {
@@ -14,11 +14,17 @@ import React, { useEffect, useState } from 'react';
14
14
  import { useAppStore } from '../../store/AppStore';
15
15
 
16
16
  import { filterBlockchains } from './BlockchainList.helpers';
17
- import { Container, List } from './BlockchainList.styles';
17
+ import { BlockchainListContainer, List } from './BlockchainList.styles';
18
18
  import { LoadingBlockchainList } from './LoadingBlockchainList';
19
19
 
20
20
  export function BlockchainList(props: PropTypes) {
21
- const { list, searchedFor, onChange, blockchainCategory } = props;
21
+ const {
22
+ list,
23
+ searchedFor,
24
+ onChange,
25
+ blockchainCategory,
26
+ showTitle = true,
27
+ } = props;
22
28
  const [blockchains, setBlockchains] = useState<BlockchainMeta[]>(list);
23
29
  const { fetchStatus } = useAppStore();
24
30
 
@@ -31,13 +37,10 @@ export function BlockchainList(props: PropTypes) {
31
37
  const renderList = () => {
32
38
  if (!blockchains.length && !!searchedFor) {
33
39
  return (
34
- <>
35
- <Divider size={32} />
36
- <NotFound
37
- title={i18n.t('No results found')}
38
- description={i18n.t('Try using different keywords')}
39
- />
40
- </>
40
+ <NotFound
41
+ title={i18n.t('No results found')}
42
+ description={i18n.t('Try using different keywords')}
43
+ />
41
44
  );
42
45
  }
43
46
  return (
@@ -61,13 +64,19 @@ export function BlockchainList(props: PropTypes) {
61
64
  };
62
65
 
63
66
  return (
64
- <Container>
65
- <Typography variant="label" size="large">
66
- {i18n.t('Select Blockchain')}
67
- </Typography>
68
- <Divider size={4} />
69
- {fetchStatus === 'loading' && <LoadingBlockchainList />}
70
- {fetchStatus === 'success' && renderList()}
71
- </Container>
67
+ <>
68
+ {showTitle && (
69
+ <>
70
+ <Typography variant="label" size="large">
71
+ {i18n.t('Select Blockchain')}
72
+ </Typography>
73
+ <Divider size={4} />
74
+ </>
75
+ )}
76
+ <BlockchainListContainer>
77
+ {fetchStatus === 'loading' && <LoadingBlockchainList />}
78
+ {fetchStatus === 'success' && renderList()}
79
+ </BlockchainListContainer>
80
+ </>
72
81
  );
73
82
  }
@@ -5,4 +5,5 @@ export interface PropTypes {
5
5
  searchedFor: string;
6
6
  blockchainCategory: string;
7
7
  onChange: (blockchain: BlockchainMeta) => void;
8
+ showTitle?: boolean;
8
9
  }
@@ -0,0 +1,49 @@
1
+ import { darkTheme, styled } from '@rango-dev/ui';
2
+
3
+ export const InputContainer = styled('div', {
4
+ display: 'flex',
5
+ justifyContent: 'space-between',
6
+ width: '100%',
7
+ height: '$40',
8
+ padding: '$4 $10',
9
+ borderRadius: '$sm',
10
+ cursor: 'pointer',
11
+ alignItems: 'center',
12
+ backgroundColor: '$neutral300',
13
+ [`.${darkTheme} &`]: {
14
+ backgroundColor: '$neutral400',
15
+ },
16
+
17
+ '&:hover': {
18
+ backgroundColor: '$secondary100',
19
+ [`.${darkTheme} &`]: {
20
+ backgroundColor: '$neutral500',
21
+ },
22
+ },
23
+ variants: {
24
+ disabled: {
25
+ true: {
26
+ cursor: 'default',
27
+ '&:hover': {
28
+ borderColor: '$neutral300',
29
+ '& svg': {
30
+ color: '$neutral700',
31
+ },
32
+ },
33
+ },
34
+ },
35
+ },
36
+ });
37
+
38
+ export const Container = styled('div', {
39
+ display: 'flex',
40
+ flexDirection: 'column',
41
+ width: '100%',
42
+ '.title_typography': {
43
+ textTransform: 'capitalize',
44
+ },
45
+ });
46
+
47
+ export const FlexContainer = styled('div', {
48
+ display: 'flex',
49
+ });
@@ -0,0 +1,47 @@
1
+ import type { PropTypes } from './BlockchainSelectorButton.types';
2
+
3
+ import { ChevronRightIcon, Divider, Image, Typography } from '@rango-dev/ui';
4
+ import React from 'react';
5
+
6
+ import {
7
+ Container,
8
+ FlexContainer,
9
+ InputContainer,
10
+ } from './BlockchainSelectorButton.styles';
11
+
12
+ export function BlockchainSelectorButton(props: PropTypes) {
13
+ const { onClick, value, title, hasLogo, placeholder, disabled } = props;
14
+
15
+ return (
16
+ <Container>
17
+ <Typography size="large" variant="label">
18
+ {title}
19
+ </Typography>
20
+ <Divider size={10} />
21
+ <InputContainer
22
+ onClick={disabled ? undefined : onClick}
23
+ disabled={disabled}>
24
+ <FlexContainer>
25
+ {hasLogo && (
26
+ <>
27
+ <Image
28
+ src={value?.logo}
29
+ size={16}
30
+ useAsPlaceholder={!value?.logo}
31
+ type="circular"
32
+ />
33
+ <Divider size={4} direction="horizontal" />
34
+ </>
35
+ )}
36
+ <Typography
37
+ className="title_typography"
38
+ size="medium"
39
+ variant="label">
40
+ {value?.name || placeholder}
41
+ </Typography>
42
+ </FlexContainer>
43
+ <ChevronRightIcon size={12} color="black" />
44
+ </InputContainer>
45
+ </Container>
46
+ );
47
+ }
@@ -0,0 +1,11 @@
1
+ export interface PropTypes {
2
+ onClick: () => void;
3
+ value?: {
4
+ name: string;
5
+ logo: string;
6
+ };
7
+ title: string;
8
+ placeholder: string;
9
+ hasLogo?: boolean;
10
+ disabled?: boolean;
11
+ }
@@ -0,0 +1 @@
1
+ export { BlockchainSelectorButton } from './BlockchainSelectorButton';
@@ -16,8 +16,10 @@ import React, { useEffect, useRef } from 'react';
16
16
 
17
17
  import { useAppStore } from '../../store/AppStore';
18
18
  import { useQuoteStore } from '../../store/quote';
19
- import { getBlockchainDisplayNameFor } from '../../utils/meta';
20
- import { isValidAddress } from '../ConfirmWalletsModal/ConfirmWallets.helpers';
19
+ import {
20
+ getBlockchainDisplayNameFor,
21
+ isValidTokenAddress,
22
+ } from '../../utils/meta';
21
23
  import { CustomCollapsible } from '../CustomCollapsible/CustomCollapsible';
22
24
  import { ExpandedIcon } from '../CustomCollapsible/CustomCollapsible.styles';
23
25
 
@@ -44,7 +46,7 @@ export function CustomDestination(props: PropTypes) {
44
46
  const isFirefox = navigator?.userAgent.includes('Firefox');
45
47
  const isAddressChecked = open && !!customDestination && blockchain;
46
48
  const isAddressInvalid =
47
- isAddressChecked && !isValidAddress(blockchain, customDestination);
49
+ isAddressChecked && !isValidTokenAddress(blockchain, customDestination);
48
50
  const handleClear = () => {
49
51
  setCustomDestination('');
50
52
  };
@@ -0,0 +1,19 @@
1
+ import type { BlockchainMeta } from 'rango-types';
2
+
3
+ export function generateExplorerLink(
4
+ address: string | null,
5
+ blockchain: BlockchainMeta
6
+ ): string {
7
+ // We don't have Cosmos explorer url in API.
8
+ if (blockchain.type === 'COSMOS') {
9
+ return '';
10
+ }
11
+
12
+ const explorerLinkPattern = blockchain.info?.addressUrl;
13
+
14
+ if (!explorerLinkPattern || !address) {
15
+ return '';
16
+ }
17
+
18
+ return explorerLinkPattern.replace('{wallet}', address);
19
+ }
@@ -0,0 +1,57 @@
1
+ import { darkTheme, styled } from '@rango-dev/ui';
2
+
3
+ export const StyledLink = styled('a', {
4
+ textDecoration: 'none',
5
+ color: '$colors$neutral700',
6
+ [`.${darkTheme} &`]: {
7
+ color: '$colors$neutral900',
8
+ },
9
+
10
+ '& svg': {
11
+ marginLeft: '$4',
12
+ color: '$colors$neutral700',
13
+ [`.${darkTheme} &`]: {
14
+ color: '$colors$neutral900',
15
+ },
16
+ },
17
+
18
+ variants: {
19
+ hasHover: {
20
+ true: {
21
+ '&:hover': {
22
+ color: '$colors$secondary550',
23
+ [`.${darkTheme} &`]: {
24
+ color: '$colors$secondary500',
25
+ },
26
+ '& svg': {
27
+ color: '$colors$secondary550',
28
+ [`.${darkTheme} &`]: {
29
+ color: '$colors$secondary500',
30
+ },
31
+ },
32
+ },
33
+ },
34
+ false: {},
35
+ },
36
+ },
37
+ });
38
+
39
+ export const Container = styled('div', {
40
+ display: 'flex',
41
+ justifyContent: 'center',
42
+ flexDirection: 'column',
43
+ alignItems: 'center',
44
+ textAlign: 'center',
45
+ '& ._blockchain-name, & ._coin-source': {
46
+ color: '$colors$neutral600',
47
+ [`.${darkTheme} &`]: {
48
+ color: '$colors$neutral800',
49
+ },
50
+ },
51
+ '& ._coin-source-name, & ._custom-token-description': {
52
+ color: '$colors$neutral700',
53
+ [`.${darkTheme} &`]: {
54
+ color: '$colors$neutral900',
55
+ },
56
+ },
57
+ });
@@ -0,0 +1,92 @@
1
+ import type { PropTypes } from './CustomTokenModal.types';
2
+
3
+ import { i18n } from '@lingui/core';
4
+ import {
5
+ Button,
6
+ Divider,
7
+ ExternalLinkIcon,
8
+ Image,
9
+ Typography,
10
+ } from '@rango-dev/ui';
11
+ import React from 'react';
12
+
13
+ import { getContainer } from '../../utils/common';
14
+ import { WatermarkedModal } from '../common/WatermarkedModal';
15
+
16
+ import { generateExplorerLink } from './CustomTokenModal.helpers';
17
+ import { Container, StyledLink } from './CustomTokenModal.styles';
18
+
19
+ export function CustomTokenModal(props: PropTypes) {
20
+ const { open, onClose, token, onSubmitClick, blockchain } = props;
21
+
22
+ const explorerLink = generateExplorerLink(token.address, blockchain);
23
+
24
+ return (
25
+ <WatermarkedModal
26
+ open={open}
27
+ dismissible
28
+ onClose={onClose}
29
+ container={getContainer()}>
30
+ <Container>
31
+ <Image src={token.image} size={45} type="circular" />
32
+ <Typography variant="title" size="medium">
33
+ {token.name}
34
+ </Typography>
35
+ <Typography variant="body" size="small" className="_blockchain-name">
36
+ {blockchain.displayName}
37
+ </Typography>
38
+ <Divider size={4} />
39
+
40
+ <Typography variant="body" size="medium">
41
+ {!!explorerLink ? (
42
+ <StyledLink
43
+ hasHover
44
+ href={explorerLink}
45
+ target="_blank"
46
+ rel="nofollow noreferrer">
47
+ {token.address}
48
+ <ExternalLinkIcon size={12} color="gray" />
49
+ </StyledLink>
50
+ ) : (
51
+ <StyledLink>{token.address}</StyledLink>
52
+ )}
53
+ </Typography>
54
+
55
+ <Divider size={4} />
56
+
57
+ {token.coinSource && (
58
+ <Typography className="_coin-source" variant="body" size="xsmall">
59
+ {i18n.t('via')}{' '}
60
+ <Typography
61
+ className="_coin-source-name"
62
+ variant="body"
63
+ size="xsmall">
64
+ {token.coinSource}
65
+ </Typography>
66
+ </Typography>
67
+ )}
68
+ <Divider size={'32'} />
69
+
70
+ <Typography
71
+ size="medium"
72
+ variant="body"
73
+ className="_custom-token-description">
74
+ {i18n.t(
75
+ `This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade.`
76
+ )}
77
+ </Typography>
78
+ </Container>
79
+ <Divider size={40} />
80
+ <Divider size={10} />
81
+
82
+ <Button
83
+ variant="contained"
84
+ size="large"
85
+ type="primary"
86
+ fullWidth
87
+ onClick={onSubmitClick}>
88
+ {i18n.t('Import')}
89
+ </Button>
90
+ </WatermarkedModal>
91
+ );
92
+ }
@@ -0,0 +1,9 @@
1
+ import type { BlockchainMeta, Token } from 'rango-sdk';
2
+
3
+ export type PropTypes = {
4
+ open: boolean;
5
+ onClose: () => void;
6
+ onSubmitClick: () => void;
7
+ token: Token;
8
+ blockchain: BlockchainMeta;
9
+ };
@@ -0,0 +1 @@
1
+ export { CustomTokenModal } from './CustomTokenModal';
@@ -53,6 +53,7 @@ export const Container = styled('div', {
53
53
  flexDirection: 'column',
54
54
  flexGrow: 1,
55
55
  overflow: 'hidden',
56
+ justifyContent: 'center',
56
57
  });
57
58
 
58
59
  export const Title = styled('div', {
@@ -92,7 +92,14 @@ const renderDesc = (props: RenderDescProps) => {
92
92
  };
93
93
 
94
94
  export function TokenList(props: PropTypes) {
95
- const { list, searchedFor = '', onChange, selectedBlockchain } = props;
95
+ const {
96
+ list,
97
+ searchedFor = '',
98
+ onChange,
99
+ selectedBlockchain,
100
+ showTitle = true,
101
+ action,
102
+ } = props;
96
103
 
97
104
  const [tokens, setTokens] = useState<Token[]>(list);
98
105
  const fetchStatus = useAppStore().fetchStatus;
@@ -118,24 +125,48 @@ export function TokenList(props: PropTypes) {
118
125
  setTokens(list.slice(0, PAGE_SIZE));
119
126
  }, [list.length, selectedBlockchain, balanceKey]);
120
127
 
121
- const renderList = () => {
122
- if (!tokens.length && !!searchedFor) {
128
+ const endRenderer = (token: Token) => {
129
+ const tokenBalance = formatBalance(getBalanceFor(token));
130
+
131
+ if (action) {
132
+ return action(token);
133
+ }
134
+ if (loadingWallet) {
123
135
  return (
124
- <>
125
- <Divider size={32} />
126
- <NotFound
127
- title={i18n.t('No results found')}
128
- description={i18n.t('Try using different keywords')}
129
- />
130
- </>
136
+ <End>
137
+ <Skeleton variant="text" size="large" width={70} />
138
+ <Divider size={4} />
139
+ <Skeleton variant="text" size="medium" width={50} />
140
+ </End>
131
141
  );
132
142
  }
143
+
144
+ return (
145
+ tokenBalance && (
146
+ <BalanceContainer>
147
+ <TokenBalance variant="title" size="small">
148
+ {tokenBalance.amount}
149
+ </TokenBalance>
150
+ <div />
151
+ {tokenBalance.usdValue && (
152
+ <Typography
153
+ variant="body"
154
+ className={usdValueStyles()}
155
+ size="xsmall">
156
+ {`$${tokenBalance.usdValue}`}
157
+ </Typography>
158
+ )}
159
+ </BalanceContainer>
160
+ )
161
+ );
162
+ };
163
+
164
+ const renderList = () => {
133
165
  return (
134
166
  <VirtualizedList
135
167
  endReached={hasNextPage ? loadNextPage : undefined}
136
168
  itemContent={(index) => {
137
169
  const token = tokens[index];
138
- const tokenBalance = formatBalance(getBalanceFor(token));
139
170
  const address = token.address || '';
140
171
  const blockchain = blockchains.find(
141
172
  (blockchain) => blockchain.name === token.blockchain
@@ -172,15 +203,16 @@ export function TokenList(props: PropTypes) {
172
203
  key={`${token.symbol}${token.address}`}
173
204
  id={`${token.symbol}${token.address}`}
174
205
  hasDivider
175
- onClick={() => onChange(tokens[index])}
206
+ onClick={() => onChange && onChange(tokens[index])}
176
207
  start={
177
208
  <ImageSection>
178
209
  <Image src={token.image} size={30} />
179
- {isTokenPinned(token, props.type) && (
180
- <Pin>
181
- <PinIcon size={12} color="gray" />
182
- </Pin>
183
- )}
210
+ {props.type !== 'custom-token' &&
211
+ isTokenPinned(token, props.type) && (
212
+ <Pin>
213
+ <PinIcon size={12} color="gray" />
214
+ </Pin>
215
+ )}
184
216
  </ImageSection>
185
217
  }
186
218
  title={
@@ -219,32 +251,7 @@ export function TokenList(props: PropTypes) {
219
251
  })
220
252
  : token.name || undefined
221
253
  }
222
- end={
223
- loadingWallet ? (
224
- <End>
225
- <Skeleton variant="text" size="large" width={70} />
226
- <Divider size={4} />
227
- <Skeleton variant="text" size="medium" width={50} />
228
- </End>
229
- ) : (
230
- tokenBalance && (
231
- <BalanceContainer>
232
- <TokenBalance variant="title" size="small">
233
- {tokenBalance.amount}
234
- </TokenBalance>
235
- <div />
236
- {tokenBalance.usdValue && (
237
- <Typography
238
- variant="body"
239
- className={usdValueStyles()}
240
- size="xsmall">
241
- {`$${tokenBalance.usdValue}`}
242
- </Typography>
243
- )}
244
- </BalanceContainer>
245
- )
246
- )
247
- }
254
+ end={endRenderer(token)}
248
255
  />
249
256
  </div>
250
257
  );
@@ -256,13 +263,31 @@ export function TokenList(props: PropTypes) {
256
263
  };
257
264
 
258
265
  return (
259
- <Container>
260
- <Typography variant="label" size="large">
261
- {i18n.t('Select Token')}
262
- </Typography>
263
- <Divider size={4} />
264
- {fetchStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
265
- {fetchStatus === 'success' && <List as="ul">{renderList()}</List>}
266
- </Container>
266
+ <>
267
+ {showTitle && (
268
+ <>
269
+ <Typography variant="label" size="large">
270
+ {i18n.t('Select Token')}
271
+ </Typography>
272
+ <Divider size={4} />
273
+ </>
274
+ )}
275
+
276
+ <Container>
277
+ <Divider size={4} />
278
+ {fetchStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
279
+ {fetchStatus === 'success' &&
280
+ (tokens.length ? (
281
+ <List as="ul">{renderList()}</List>
282
+ ) : (
283
+ !!searchedFor && (
284
+ <NotFound
285
+ title={i18n.t('No results found')}
286
+ description={i18n.t('Try using different keywords')}
287
+ />
288
+ )
289
+ ))}
290
+ </Container>
291
+ </>
267
292
  );
268
293
  }
@@ -1,11 +1,14 @@
1
1
  import type { Token } from 'rango-sdk';
2
+ import type { ReactElement } from 'react';
2
3
 
3
4
  export interface PropTypes {
4
5
  list: Token[];
5
6
  searchedFor?: string;
6
- onChange: (token: Token) => void;
7
+ onChange?: (token: Token) => void;
7
8
  selectedBlockchain?: string;
8
- type: 'source' | 'destination';
9
+ type: 'source' | 'destination' | 'custom-token';
10
+ action?: (token: Token) => ReactElement;
11
+ showTitle?: boolean;
9
12
  }
10
13
 
11
14
  export interface LoadingTokenListProps {