@rango-dev/widget-embedded 0.14.1-next.2 → 0.14.1-next.21

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 (167) hide show
  1. package/dist/Widget.d.ts.map +1 -1
  2. package/dist/components/BlockchainList/BlockchainList.styles.d.ts +8 -0
  3. package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
  4. package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
  5. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +4 -0
  6. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  7. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +60 -0
  8. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  9. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  10. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  11. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +12 -0
  12. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
  13. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +16 -0
  14. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  15. package/dist/components/Layout/Layout.styles.d.ts +12 -0
  16. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  17. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +4 -0
  18. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  19. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +12 -0
  20. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
  21. package/dist/components/NoRoutes/NoRoutes.styles.d.ts +12 -0
  22. package/dist/components/NoRoutes/NoRoutes.styles.d.ts.map +1 -1
  23. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +16 -0
  24. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  25. package/dist/components/RouteErrors/RouteErrors.styles.d.ts +16 -0
  26. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -1
  27. package/dist/components/SearchInput/SearchInput.styles.d.ts +4 -0
  28. package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  29. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +16 -0
  30. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  31. package/dist/components/Slippage/Slippage.styles.d.ts +16 -0
  32. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  33. package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
  34. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  35. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +24 -0
  36. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  37. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +4 -0
  38. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
  39. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +4 -0
  40. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
  41. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +16 -0
  42. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
  43. package/dist/components/TokenList/TokenList.styles.d.ts +40 -0
  44. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  45. package/dist/components/WalletModal/WalletModalContent.styles.d.ts +16 -0
  46. package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
  47. package/dist/constants/configs.d.ts +2 -0
  48. package/dist/constants/configs.d.ts.map +1 -0
  49. package/dist/constants/errors.d.ts +1 -1
  50. package/dist/constants/errors.d.ts.map +1 -1
  51. package/dist/constants/fonts.d.ts +2 -0
  52. package/dist/constants/fonts.d.ts.map +1 -0
  53. package/dist/{constants.d.ts → constants/index.d.ts} +1 -1
  54. package/dist/constants/index.d.ts.map +1 -0
  55. package/dist/constants/languages.d.ts +11 -0
  56. package/dist/constants/languages.d.ts.map +1 -0
  57. package/dist/constants/messages.d.ts +1 -1
  58. package/dist/constants/messages.d.ts.map +1 -1
  59. package/dist/hooks/useLanguage.d.ts +11 -0
  60. package/dist/hooks/useLanguage.d.ts.map +1 -0
  61. package/dist/hooks/usePrepareBlockchainList/index.d.ts +2 -0
  62. package/dist/hooks/usePrepareBlockchainList/index.d.ts.map +1 -0
  63. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts +2 -0
  64. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts.map +1 -0
  65. package/dist/hooks/{usePrepareBlockchainList.d.ts → usePrepareBlockchainList/usePrepareBlockchainList.d.ts} +1 -9
  66. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts.map +1 -0
  67. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +10 -0
  68. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -0
  69. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +3 -0
  70. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -0
  71. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.d.ts +2 -0
  72. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.d.ts.map +1 -0
  73. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +11 -0
  74. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -0
  75. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  76. package/dist/hooks/useTheme.d.ts +2 -2
  77. package/dist/hooks/useTheme.d.ts.map +1 -1
  78. package/dist/index.d.ts +9 -6
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +1 -1
  81. package/dist/index.js.map +4 -4
  82. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  83. package/dist/pages/Home.d.ts.map +1 -1
  84. package/dist/pages/LanguagePage.d.ts.map +1 -1
  85. package/dist/store/bestRoute.d.ts.map +1 -1
  86. package/dist/store/settings.d.ts +15 -6
  87. package/dist/store/settings.d.ts.map +1 -1
  88. package/dist/types/config.d.ts +11 -13
  89. package/dist/types/config.d.ts.map +1 -1
  90. package/dist/utils/colors.d.ts +11 -0
  91. package/dist/utils/colors.d.ts.map +1 -0
  92. package/dist/utils/common.d.ts +0 -4
  93. package/dist/utils/common.d.ts.map +1 -1
  94. package/dist/utils/configs.d.ts +2 -0
  95. package/dist/utils/configs.d.ts.map +1 -1
  96. package/dist/utils/hash.d.ts +2 -0
  97. package/dist/utils/hash.d.ts.map +1 -0
  98. package/dist/utils/meta.d.ts +3 -1
  99. package/dist/utils/meta.d.ts.map +1 -1
  100. package/dist/utils/routing.d.ts +8 -1
  101. package/dist/utils/routing.d.ts.map +1 -1
  102. package/dist/utils/swap.d.ts.map +1 -1
  103. package/dist/utils/time.d.ts.map +1 -1
  104. package/dist/utils/ui.d.ts +13 -0
  105. package/dist/utils/ui.d.ts.map +1 -0
  106. package/dist/utils/wallets.d.ts +0 -1
  107. package/dist/utils/wallets.d.ts.map +1 -1
  108. package/package.json +6 -6
  109. package/src/Widget.tsx +15 -3
  110. package/src/components/BlockchainsSection/BlockchainsSection.tsx +21 -6
  111. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -11
  112. package/src/components/ConfirmWalletsModal/WalletList.tsx +35 -24
  113. package/src/components/Layout/Layout.styles.ts +7 -2
  114. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +1 -1
  115. package/src/components/NoRoutes/NoRoutes.helper.ts +4 -4
  116. package/src/components/NoRoutes/NoRoutes.tsx +2 -2
  117. package/src/components/NotificationContent/NotificationContent.tsx +1 -1
  118. package/src/components/NotificationContent/NotificationNotFound.tsx +1 -1
  119. package/src/components/RouteErrors/RouteErrors.tsx +2 -2
  120. package/src/components/RouteErrors/RouteErrorsModal.tsx +6 -6
  121. package/src/components/RouteErrors/RouteErrorsModalItem.tsx +1 -1
  122. package/src/components/Slippage/SlippageTooltipContent.tsx +1 -1
  123. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +5 -6
  124. package/src/components/SwapDetails/SwapDetails.tsx +6 -10
  125. package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +1 -1
  126. package/src/components/SwapsGroup/SwapsGroup.tsx +2 -2
  127. package/src/components/TokenList/TokenList.styles.ts +1 -1
  128. package/src/components/TokenList/TokenList.tsx +2 -2
  129. package/src/constants/configs.ts +1 -0
  130. package/src/constants/errors.ts +44 -41
  131. package/src/constants/fonts.ts +1 -0
  132. package/src/constants/languages.ts +19 -0
  133. package/src/constants/messages.ts +7 -5
  134. package/src/hooks/useConfirmSwap.ts +1 -1
  135. package/src/hooks/useLanguage.ts +27 -0
  136. package/src/hooks/usePrepareBlockchainList/index.ts +1 -0
  137. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -0
  138. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +108 -0
  139. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +3101 -0
  140. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +273 -0
  141. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +38 -0
  142. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +12 -0
  143. package/src/hooks/useSyncStoresWithConfig.ts +49 -1
  144. package/src/hooks/useTheme.ts +44 -26
  145. package/src/index.ts +33 -26
  146. package/src/pages/ConfirmSwapPage.tsx +9 -18
  147. package/src/pages/Home.tsx +6 -7
  148. package/src/pages/LanguagePage.tsx +16 -39
  149. package/src/pages/SettingsPage.tsx +1 -1
  150. package/src/store/bestRoute.ts +12 -38
  151. package/src/store/settings.ts +46 -4
  152. package/src/types/config.ts +10 -12
  153. package/src/utils/colors.ts +109 -0
  154. package/src/utils/common.ts +0 -49
  155. package/src/utils/configs.ts +3 -0
  156. package/src/utils/hash.ts +27 -0
  157. package/src/utils/meta.ts +11 -1
  158. package/src/utils/routing.ts +58 -0
  159. package/src/utils/settings.ts +1 -1
  160. package/src/utils/swap.ts +15 -20
  161. package/src/utils/time.ts +2 -4
  162. package/src/utils/ui.ts +72 -0
  163. package/src/utils/wallets.ts +4 -25
  164. package/dist/constants.d.ts.map +0 -1
  165. package/dist/hooks/usePrepareBlockchainList.d.ts.map +0 -1
  166. package/src/hooks/usePrepareBlockchainList.ts +0 -125
  167. /package/src/{constants.ts → constants/index.ts} +0 -0
@@ -52,8 +52,8 @@ export function WalletList(props: PropTypes) {
52
52
  const [showExperimentalChainModal, setShowExperimentalChainModal] =
53
53
  useState(false);
54
54
  const [addingExperimentalChainStatus, setAddingExperimentalChainStatus] =
55
- useState<'in-progress' | 'completed' | null>(null);
56
- const { connect } = useWallets();
55
+ useState<'in-progress' | 'completed' | 'rejected' | null>(null);
56
+ const { suggestAndConnect } = useWallets();
57
57
  let modalTimerId: ReturnType<typeof setTimeout> | null = null;
58
58
  const { list, error, handleClick } = useWalletList({
59
59
  config,
@@ -79,8 +79,12 @@ export function WalletList(props: PropTypes) {
79
79
  const addExperimentalChain = async (wallet: Wallet) => {
80
80
  setShowExperimentalChainModal(false);
81
81
  setAddingExperimentalChainStatus('in-progress');
82
- await connect(wallet.walletType, wallet.chain);
83
- setAddingExperimentalChainStatus('completed');
82
+ try {
83
+ await suggestAndConnect(wallet.walletType, wallet.chain);
84
+ setAddingExperimentalChainStatus('completed');
85
+ } catch (e) {
86
+ setAddingExperimentalChainStatus('rejected');
87
+ }
84
88
  };
85
89
 
86
90
  useEffect(() => {
@@ -106,7 +110,10 @@ export function WalletList(props: PropTypes) {
106
110
 
107
111
  useEffect(() => {
108
112
  let timeout: ReturnType<typeof setTimeout> | null = null;
109
- if (addingExperimentalChainStatus === 'completed') {
113
+ if (
114
+ addingExperimentalChainStatus === 'completed' ||
115
+ addingExperimentalChainStatus === 'rejected'
116
+ ) {
110
117
  timeout = setTimeout(
111
118
  () => setAddingExperimentalChainStatus(null),
112
119
  TIME_TO_CLOSE_MODAL
@@ -145,8 +152,7 @@ export function WalletList(props: PropTypes) {
145
152
 
146
153
  const connectedWalletDescription = couldAddExperimentalChain
147
154
  ? i18n.t({
148
- id: 'addChain',
149
- message: 'Add {chain} chain',
155
+ id: 'Add {chain} chain',
150
156
  values: { chain },
151
157
  })
152
158
  : conciseAddress;
@@ -195,15 +201,12 @@ export function WalletList(props: PropTypes) {
195
201
  }}>
196
202
  <MessageBox
197
203
  title={i18n.t({
198
- id: 'addBlockchain',
199
- message: 'Add {blockchainDisplayName} Chain',
204
+ id: 'Add {blockchainDisplayName} Chain',
200
205
  values: { blockchainDisplayName },
201
206
  })}
202
207
  type="warning"
203
208
  description={i18n.t({
204
- id: 'addBlockchainDescription',
205
- message:
206
- 'You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address',
209
+ id: 'You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address',
207
210
  values: { blockchainDisplayName },
208
211
  })}>
209
212
  <Divider size={18} />
@@ -227,18 +230,15 @@ export function WalletList(props: PropTypes) {
227
230
  open={!!addingExperimentalChainStatus}
228
231
  onClose={setAddingExperimentalChainStatus.bind(null, null)}
229
232
  container={modalContainer}>
230
- {addingExperimentalChainStatus === 'in-progress' ? (
233
+ {addingExperimentalChainStatus === 'in-progress' && (
231
234
  <MessageBox
232
235
  type="loading"
233
236
  title={i18n.t({
234
- id: 'addBlockchain',
235
- message: 'Add {blockchainDisplayName} Chain',
237
+ id: 'Add {blockchainDisplayName} Chain',
236
238
  values: { blockchainDisplayName },
237
239
  })}
238
240
  description={i18n.t({
239
- id: 'addBlockchainDescription',
240
- message:
241
- 'You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address',
241
+ id: 'You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address',
242
242
  values: { blockchainDisplayName },
243
243
  })}
244
244
  icon={
@@ -250,22 +250,33 @@ export function WalletList(props: PropTypes) {
250
250
  </LogoContainer>
251
251
  }
252
252
  />
253
- ) : (
253
+ )}
254
+
255
+ {addingExperimentalChainStatus === 'completed' && (
254
256
  <MessageBox
255
257
  type="success"
256
258
  title={i18n.t({
257
- id: 'blockchainAdded',
258
- message: '{blockchainDisplayName} Chain Added',
259
+ id: '{blockchainDisplayName} Chain Added',
259
260
  values: { blockchainDisplayName },
260
261
  })}
261
262
  description={i18n.t({
262
- id: 'blockchainAddedDescription',
263
- message:
264
- '{blockchainDisplayName} is added to your wallet, you can use it to swap.',
263
+ id: '{blockchainDisplayName} is added to your wallet, you can use it to swap.',
265
264
  values: { blockchainDisplayName },
266
265
  })}
267
266
  />
268
267
  )}
268
+
269
+ {addingExperimentalChainStatus === 'rejected' && (
270
+ <MessageBox
271
+ type="error"
272
+ title={i18n.t('Request Rejected')}
273
+ description={i18n.t({
274
+ id: "You've rejected adding {blockchainDisplayName} chain to your wallet.",
275
+ values: { blockchainDisplayName },
276
+ })}
277
+ />
278
+ )}
279
+
269
280
  <Divider direction="vertical" size={32} />
270
281
  </Modal>
271
282
  )}
@@ -1,4 +1,4 @@
1
- import { styled } from '@rango-dev/ui';
1
+ import { darkTheme, styled } from '@rango-dev/ui';
2
2
 
3
3
  export const Container = styled('div', {
4
4
  position: 'relative',
@@ -10,7 +10,11 @@ export const Container = styled('div', {
10
10
  width: '95vw',
11
11
  maxWidth: '390px',
12
12
  maxHeight: '700px',
13
- backgroundColor: '$neutral100',
13
+ $$color: '$colors$neutral100',
14
+ [`.${darkTheme} &`]: {
15
+ $$color: '$colors$neutral300',
16
+ },
17
+ backgroundColor: '$$color',
14
18
  variants: {
15
19
  fixedHeight: {
16
20
  true: {
@@ -22,6 +26,7 @@ export const Container = styled('div', {
22
26
  },
23
27
  },
24
28
  });
29
+
25
30
  export const Content = styled('div', {
26
31
  borderTopLeftRadius: '20px',
27
32
  borderTopRightRadius: '20px',
@@ -73,6 +73,6 @@ export const StepContainer = styled('div', {
73
73
  export const StepSeparator = styled('div', {
74
74
  width: '0px',
75
75
  height: '$20',
76
- borderLeft: '1px dashed $neutral900',
76
+ borderLeft: '1px dashed $neutral700',
77
77
  marginLeft: '25px',
78
78
  });
@@ -15,7 +15,7 @@ export function makeInfo(
15
15
  return {
16
16
  alert: {
17
17
  type: 'warning',
18
- text: errorMessages.genericServerError,
18
+ text: errorMessages().genericServerError,
19
19
  action: {
20
20
  onClick: refetchBestRoute,
21
21
  title: i18n.t('Retry'),
@@ -36,17 +36,17 @@ export function makeInfo(
36
36
  return {
37
37
  alert: {
38
38
  type: 'warning',
39
- text: errorMessages.liquiditySourcesError.title,
39
+ text: errorMessages().liquiditySourcesError.title,
40
40
  action: {
41
41
  onClick: () => toggleAllLiquiditySources(true),
42
42
  title: i18n.t('Reset'),
43
43
  },
44
44
  },
45
- description: errorMessages.liquiditySourcesError.description,
45
+ description: errorMessages().liquiditySourcesError.description,
46
46
  };
47
47
  }
48
48
  return {
49
49
  alert: null,
50
- description: errorMessages.noRoutesError.description,
50
+ description: errorMessages().noRoutesError.description,
51
51
  };
52
52
  }
@@ -40,14 +40,14 @@ export function NoRoutes(props: PropTypes) {
40
40
  <NoRouteIcon size={24} color="gray" />
41
41
  <Divider size={4} />
42
42
  <Typography variant="title" size="small">
43
- {errorMessages.noRoutesError.title}
43
+ {errorMessages().noRoutesError.title}
44
44
  </Typography>
45
45
  {!!info.description && (
46
46
  <Typography
47
47
  variant="body"
48
48
  size="small"
49
49
  align="center"
50
- color="neutral900">
50
+ color="neutral700">
51
51
  {info.description}
52
52
  </Typography>
53
53
  )}
@@ -72,7 +72,7 @@ export function NotificationContent() {
72
72
  key={notificationItem.requestId}
73
73
  onClick={() => handleOnClick(notificationItem.requestId)}
74
74
  title={
75
- <Typography variant="body" size="small" color="$neutral900">
75
+ <Typography variant="body" size="small" color="$neutral700">
76
76
  {i18n.t(notificationItem.event.message)}
77
77
  </Typography>
78
78
  }
@@ -9,7 +9,7 @@ export function NotificationNotFound() {
9
9
  <NotFoundContainer>
10
10
  <NoNotificationIcon color="secondary" size={26} />
11
11
  <Divider size={12} />
12
- <Typography variant="body" size="medium" color="neutral900">
12
+ <Typography variant="body" size="medium" color="neutral700">
13
13
  {i18n.t('You have no notification')}
14
14
  </Typography>
15
15
  </NotFoundContainer>
@@ -42,8 +42,8 @@ export function RouteErrors(props: PropTypes) {
42
42
  <Alert
43
43
  title={
44
44
  highValueLoss
45
- ? errorMessages.highValueLossError.title
46
- : errorMessages.unknownPriceError.title
45
+ ? errorMessages().highValueLossError.title
46
+ : errorMessages().unknownPriceError.title
47
47
  }
48
48
  type={
49
49
  highValueLoss && !!percentageChange?.lt(WARNING_LEVEL_LIMIT)
@@ -87,14 +87,14 @@ export function RouteErrorsModal(props: ModalPropTypes) {
87
87
  {highValueLoss ? (
88
88
  <MessageBox
89
89
  type={type}
90
- title={errorMessages.highValueLossError.impactTitle}
91
- description={errorMessages.highValueLossError.description}
90
+ title={errorMessages().highValueLossError.impactTitle}
91
+ description={errorMessages().highValueLossError.description}
92
92
  />
93
93
  ) : (
94
94
  <MessageBox
95
95
  type={type}
96
- title={errorMessages.unknownPriceError.impactTitle}
97
- description={errorMessages.unknownPriceError.description}
96
+ title={errorMessages().unknownPriceError.impactTitle}
97
+ description={errorMessages().unknownPriceError.description}
98
98
  />
99
99
  )}
100
100
  {highValueLoss && (
@@ -121,8 +121,8 @@ export function RouteErrorsModal(props: ModalPropTypes) {
121
121
  navigate(navigationRoutes.confirmSwap);
122
122
  }}>
123
123
  {highValueLoss
124
- ? errorMessages.highValueLossError.confirmMessage
125
- : errorMessages.unknownPriceError.confirmMessage}
124
+ ? errorMessages().highValueLossError.confirmMessage
125
+ : errorMessages().unknownPriceError.confirmMessage}
126
126
  </Button>
127
127
  </Modal>
128
128
  );
@@ -10,7 +10,7 @@ export function RouteErrorsModalItem(props: ModalContentData) {
10
10
 
11
11
  return (
12
12
  <Item>
13
- <Typography size="medium" variant="label" color="neutral800">
13
+ <Typography size="medium" variant="label" color="neutral600">
14
14
  {title}
15
15
  </Typography>
16
16
  <Typography
@@ -7,7 +7,7 @@ import { SlippageTooltipContainer } from './Slippage.styles';
7
7
  export function SlippageTooltipContent() {
8
8
  return (
9
9
  <SlippageTooltipContainer>
10
- <Typography variant="label" size="medium" color="neutral900">
10
+ <Typography variant="label" size="medium" color="neutral700">
11
11
  {i18n.t(
12
12
  'Your transaction will be reverted if the price changes unfavorably by more than this percentage'
13
13
  )}
@@ -38,11 +38,11 @@ export function SwapDetailsPlaceholder(props: SwapDetailsPlaceholderPropTypes) {
38
38
  <Container>
39
39
  <HeaderDetails>
40
40
  <div className="row">
41
- <Typography variant="label" size="large" color="neutral900">
41
+ <Typography variant="label" size="large" color="neutral700">
42
42
  {`${i18n.t('Request ID')}:`}
43
43
  </Typography>
44
44
  <div className="request-id">
45
- <Typography variant="label" size="small" color="neutral900">
45
+ <Typography variant="label" size="small" color="neutral700">
46
46
  <Skeleton width={60} height={10} variant="rounded" />
47
47
  </Typography>
48
48
  <IconButton variant="ghost">
@@ -51,10 +51,10 @@ export function SwapDetailsPlaceholder(props: SwapDetailsPlaceholderPropTypes) {
51
51
  </div>
52
52
  </div>
53
53
  <div className="row">
54
- <Typography variant="label" size="large" color="neutral900">
54
+ <Typography variant="label" size="large" color="neutral700">
55
55
  {`${i18n.t('Created at')}:`}
56
56
  </Typography>
57
- <Typography variant="label" size="small" color="neutral900">
57
+ <Typography variant="label" size="small" color="neutral700">
58
58
  <Skeleton width={60} height={10} variant="rounded" />
59
59
  </Typography>
60
60
  </div>
@@ -67,9 +67,8 @@ export function SwapDetailsPlaceholder(props: SwapDetailsPlaceholderPropTypes) {
67
67
  <NotFound
68
68
  title={i18n.t('Not found')}
69
69
  description={i18n.t({
70
- id: 'swapNotFound',
70
+ id: 'Swap with request ID = {requestId} not found.',
71
71
  values: { requestId },
72
- message: 'Swap with request ID = {requestId} not found.',
73
72
  })}
74
73
  />
75
74
  </PlaceholderContainer>
@@ -206,9 +206,7 @@ export function SwapDetails(props: SwapDetailsProps) {
206
206
  const completeModalDesc =
207
207
  swap.status === 'success'
208
208
  ? i18n.t({
209
- id: 'receivedMessage',
210
- message:
211
- 'You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.',
209
+ id: 'You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.',
212
210
  values: {
213
211
  amount: numberToString(
214
212
  outputAmount,
@@ -226,9 +224,7 @@ export function SwapDetails(props: SwapDetailsProps) {
226
224
  : `${i18n.t('Transaction was not sent.')} ${
227
225
  lastConvertedTokenInFailedSwap
228
226
  ? i18n.t({
229
- id: 'remainSymbol',
230
- message:
231
- '{amount} {symbol} on {blockchain} remain in your wallet',
227
+ id: '{amount} {symbol} on {blockchain} remain in your wallet',
232
228
  values: {
233
229
  amount: lastConvertedTokenInFailedSwap.outputAmount,
234
230
  symbol: lastConvertedTokenInFailedSwap.symbol,
@@ -281,11 +277,11 @@ export function SwapDetails(props: SwapDetailsProps) {
281
277
  <Container>
282
278
  <HeaderDetails>
283
279
  <div className="row">
284
- <Typography variant="label" size="large" color="neutral900">
280
+ <Typography variant="label" size="large" color="neutral700">
285
281
  {`${i18n.t('Request ID')}:`}
286
282
  </Typography>
287
283
  <div className="request-id">
288
- <Typography variant="label" size="small" color="neutral900">
284
+ <Typography variant="label" size="small" color="neutral700">
289
285
  {requestId}
290
286
  </Typography>
291
287
  <IconButton
@@ -296,10 +292,10 @@ export function SwapDetails(props: SwapDetailsProps) {
296
292
  </div>
297
293
  </div>
298
294
  <div className="row">
299
- <Typography variant="label" size="large" color="neutral900">
295
+ <Typography variant="label" size="large" color="neutral700">
300
296
  {`${i18n.t('Created at')}:`}
301
297
  </Typography>
302
- <Typography variant="label" size="small" color="neutral900">
298
+ <Typography variant="label" size="small" color="neutral700">
303
299
  {swapDate}
304
300
  </Typography>
305
301
  </div>
@@ -52,7 +52,7 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
52
52
  <Typography
53
53
  variant="body"
54
54
  size="medium"
55
- color="neutral900"
55
+ color="neutral700"
56
56
  align="center">
57
57
  {description}
58
58
  </Typography>
@@ -34,7 +34,7 @@ export function SwapsGroup(props: PropTypes) {
34
34
  <Typography
35
35
  variant="label"
36
36
  size="medium"
37
- color="neutral800"
37
+ color="neutral600"
38
38
  className="group-title">
39
39
  {i18n.t(group.title)}
40
40
  </Typography>
@@ -68,7 +68,7 @@ export function SwapsGroup(props: PropTypes) {
68
68
  <Typography
69
69
  variant="label"
70
70
  size="medium"
71
- color="neutral800"
71
+ color="neutral600"
72
72
  className="group-title">
73
73
  {i18n.t(group.title)}
74
74
  </Typography>
@@ -40,7 +40,7 @@ export const List = styled('ul', {
40
40
  '& a': {
41
41
  fontSize: '$12',
42
42
  lineHeight: '$16',
43
- color: '$neutral800',
43
+ color: '$neutral600',
44
44
  textDecoration: 'none',
45
45
  },
46
46
  },
@@ -24,7 +24,7 @@ import React, { forwardRef, useEffect, useState } from 'react';
24
24
  import { useAppStore } from '../../store/app';
25
25
  import { useMetaStore } from '../../store/meta';
26
26
  import { useWalletsStore } from '../../store/wallets';
27
- import { generateRangeColors } from '../../utils/common';
27
+ import { generateRangeColors } from '../../utils/colors';
28
28
 
29
29
  import { LoadingTokenList } from './LoadingTokenList';
30
30
  import {
@@ -239,7 +239,7 @@ export function TokenList(props: PropTypes) {
239
239
  {token.balance?.usdValue && (
240
240
  <Typography
241
241
  variant="body"
242
- color="neutral800"
242
+ color="neutral600"
243
243
  size="xsmall">
244
244
  {`$${token.balance?.usdValue}`}
245
245
  </Typography>
@@ -0,0 +1 @@
1
+ export const BLOCKCHAIN_LIST_SIZE = 10;
@@ -4,54 +4,57 @@ import { i18n } from '@lingui/core';
4
4
 
5
5
  import { ConfirmSwapErrorTypes } from '../types';
6
6
 
7
- export const errorMessages = {
8
- genericServerError: i18n.t('Failed Network, Please retry your swap.'),
9
- liquiditySourcesError: {
10
- title: i18n.t('Please reset your liquidity sources.'),
11
- description: i18n.t(
12
- 'You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources'
13
- ),
14
- },
15
- noRoutesError: {
16
- title: i18n.t('No Routes Found'),
17
- description:
18
- "Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.",
19
- },
20
- bridgeLimitErrors: {
21
- increaseAmount: i18n.t('Bridge Limit Error: Please increase your amount'),
22
- decreaseAmount: i18n.t('Bridge Limit Error: Please decrease your amount'),
23
- },
24
- highValueLossError: {
25
- impactTitle: i18n.t('High Price Impact'),
26
- title: i18n.t('Price impact is too high!'),
27
- description: i18n.t(
28
- 'The price impact is significantly higher than the allowed amount. If you are sure, continue, otherwise, change the swap.'
29
- ),
30
- confirmMessage: i18n.t('Confirm High price impact'),
31
- },
32
- routeUpdatedWithHighValueLoss: {
33
- title: i18n.t(
34
- 'Route updated and price impact is too high, try again later!'
35
- ),
36
- },
37
- unknownPriceError: {
38
- impactTitle: i18n.t('USD Price Unknown'),
39
- title: i18n.t('USD Price Unknown, Cannot calculate Price Impact.'),
40
- description: i18n.t(
41
- 'USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?'
42
- ),
43
- confirmMessage: i18n.t('Confirm USD Price Unknown'),
44
- },
7
+ export const errorMessages = () => {
8
+ return {
9
+ genericServerError: i18n.t('Failed Network, Please retry your swap.'),
10
+ liquiditySourcesError: {
11
+ title: i18n.t('Please reset your liquidity sources.'),
12
+ description: i18n.t(
13
+ 'You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources'
14
+ ),
15
+ },
16
+ noRoutesError: {
17
+ title: i18n.t('No Routes Found'),
18
+ description: i18n.t(
19
+ "Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination."
20
+ ),
21
+ },
22
+ bridgeLimitErrors: {
23
+ increaseAmount: i18n.t('Bridge Limit Error: Please increase your amount'),
24
+ decreaseAmount: i18n.t('Bridge Limit Error: Please decrease your amount'),
25
+ },
26
+ highValueLossError: {
27
+ impactTitle: i18n.t('High Price Impact'),
28
+ title: i18n.t('Price impact is too high!'),
29
+ description: i18n.t(
30
+ 'The price impact is significantly higher than the allowed amount. If you are sure, continue, otherwise, change the swap.'
31
+ ),
32
+ confirmMessage: i18n.t('Confirm High price impact'),
33
+ },
34
+ routeUpdatedWithHighValueLoss: {
35
+ title: i18n.t(
36
+ 'Route updated and price impact is too high, try again later!'
37
+ ),
38
+ },
39
+ unknownPriceError: {
40
+ impactTitle: i18n.t('USD Price Unknown'),
41
+ title: i18n.t('USD Price Unknown, Cannot calculate Price Impact.'),
42
+ description: i18n.t(
43
+ 'USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?'
44
+ ),
45
+ confirmMessage: i18n.t('Confirm USD Price Unknown'),
46
+ },
47
+ };
45
48
  };
46
49
 
47
50
  export function getConfirmSwapErrorMessage(error: ConfirmSwapError) {
48
51
  switch (error.type) {
49
52
  case ConfirmSwapErrorTypes.NO_ROUTE:
50
- return error.diagnosisMessage ?? errorMessages.noRoutesError.title;
53
+ return error.diagnosisMessage ?? errorMessages().noRoutesError.title;
51
54
  case ConfirmSwapErrorTypes.REQUEST_FAILED:
52
- return errorMessages.genericServerError;
55
+ return errorMessages().genericServerError;
53
56
  case ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS:
54
- return errorMessages.routeUpdatedWithHighValueLoss.title;
57
+ return errorMessages().routeUpdatedWithHighValueLoss.title;
55
58
  default:
56
59
  return '';
57
60
  }
@@ -0,0 +1 @@
1
+ export const DEFAULT_FONT_FAMILY = 'Roboto';
@@ -0,0 +1,19 @@
1
+ import type { FlagPropTypes, Language } from '@rango-dev/ui';
2
+
3
+ import { English, French, Japanese, Spanish } from '@rango-dev/ui';
4
+
5
+ export type LanguageItem = {
6
+ title: string;
7
+ label: string;
8
+ local: Language;
9
+ SVGFlag: React.ComponentType<FlagPropTypes>;
10
+ };
11
+
12
+ export const LANGUAGES: LanguageItem[] = [
13
+ { title: 'English', label: 'English', local: 'en', SVGFlag: English },
14
+ { title: 'Spanish', label: 'Español', local: 'es', SVGFlag: Spanish },
15
+ { title: 'French', label: 'Français', local: 'fr', SVGFlag: French },
16
+ { title: 'Japanese', label: '日本語', local: 'ja', SVGFlag: Japanese },
17
+ ];
18
+
19
+ export const DEFAULT_LANGUAGE = 'en';
@@ -1,8 +1,10 @@
1
1
  import { i18n } from '@lingui/core';
2
2
 
3
- export const swapButtonTitles = {
4
- connectWallet: i18n.t('Connect Wallet'),
5
- swap: i18n.t('Swap'),
6
- swapAnyway: i18n.t('Swap anyway'),
7
- ethRouteWarning: i18n.t('The route goes through Ethereum. Continue?'),
3
+ export const swapButtonTitles = () => {
4
+ return {
5
+ connectWallet: i18n.t('Connect Wallet'),
6
+ swap: i18n.t('Swap'),
7
+ swapAnyway: i18n.t('Swap anyway'),
8
+ ethRouteWarning: i18n.t('The route goes through Ethereum. Continue?'),
9
+ };
8
10
  };
@@ -70,7 +70,7 @@ function throwErrorIfResponseIsNotValid(
70
70
  params: { inputUsdValue: BigNumber | null; outputUsdValue: number | null }
71
71
  ) {
72
72
  if (!response.result) {
73
- throw new Error(errorMessages.noRoutesError.title, {
73
+ throw new Error(errorMessages().noRoutesError.title, {
74
74
  cause: {
75
75
  type: ConfirmSwapErrorTypes.NO_ROUTE,
76
76
  diagnosisMessage: response.diagnosisMessages?.[0],
@@ -0,0 +1,27 @@
1
+ import type { LanguageItem } from '../constants/languages';
2
+
3
+ import { type Language } from '@rango-dev/ui';
4
+
5
+ import { DEFAULT_LANGUAGE, LANGUAGES } from '../constants/languages';
6
+ import { useSettingsStore } from '../store/settings';
7
+
8
+ interface UseLanguage {
9
+ languages: LanguageItem[];
10
+ defaultLanguage: Language;
11
+ activeLanguage: Language;
12
+ changeLanguage: (language: Language) => void;
13
+ }
14
+
15
+ export function useLanguage(): UseLanguage {
16
+ const language = useSettingsStore.use.language();
17
+ const setLanguage = useSettingsStore.use.setLanguage();
18
+ const languages = LANGUAGES;
19
+ const defaultLanguage = DEFAULT_LANGUAGE;
20
+
21
+ return {
22
+ activeLanguage: language,
23
+ languages,
24
+ defaultLanguage,
25
+ changeLanguage: setLanguage,
26
+ };
27
+ }
@@ -0,0 +1 @@
1
+ export { usePrepareBlockchainList } from './usePrepareBlockchainList';
@@ -0,0 +1 @@
1
+ export const MOST_USED_BLOCKChAINS = ['ETH', 'COSMOS', 'OSMOSIS'];