@rango-dev/widget-embedded 0.14.1-next.9 → 0.15.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.
- package/CHANGELOG.md +29 -0
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts +2 -0
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +15 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +3 -0
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +4 -0
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts +3 -0
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -0
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +3 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/NoRoutes/NoRoutes.styles.d.ts +3 -0
- package/dist/components/NoRoutes/NoRoutes.styles.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +4 -0
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts +1 -0
- package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +4 -0
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +4 -0
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +6 -0
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +1 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +4 -0
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +10 -0
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts +4 -0
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
- package/dist/constants/configs.d.ts +2 -0
- package/dist/constants/configs.d.ts.map +1 -0
- package/dist/constants/errors.d.ts +1 -1
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/constants/languages.d.ts +11 -0
- package/dist/constants/languages.d.ts.map +1 -0
- package/dist/constants/messages.d.ts +1 -1
- package/dist/constants/messages.d.ts.map +1 -1
- package/dist/hooks/useLanguage.d.ts +11 -0
- package/dist/hooks/useLanguage.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList/index.d.ts +2 -0
- package/dist/hooks/usePrepareBlockchainList/index.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts +2 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts.map +1 -0
- package/dist/hooks/{usePrepareBlockchainList.d.ts → usePrepareBlockchainList/usePrepareBlockchainList.d.ts} +1 -9
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +10 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +3 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.d.ts +2 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +11 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -0
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LanguagePage.d.ts.map +1 -1
- package/dist/store/settings.d.ts +15 -6
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/types/config.d.ts +7 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/colors.d.ts +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +2 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/ui.d.ts +13 -0
- package/dist/utils/ui.d.ts.map +1 -0
- package/dist/utils/wallets.d.ts +0 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/Widget.tsx +14 -2
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +21 -6
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -11
- package/src/components/ConfirmWalletsModal/WalletList.tsx +35 -24
- package/src/components/Layout/Layout.styles.ts +7 -2
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +1 -1
- package/src/components/NoRoutes/NoRoutes.helper.ts +4 -4
- package/src/components/NoRoutes/NoRoutes.tsx +2 -2
- package/src/components/NotificationContent/NotificationContent.tsx +1 -1
- package/src/components/NotificationContent/NotificationNotFound.tsx +1 -1
- package/src/components/RouteErrors/RouteErrors.tsx +2 -2
- package/src/components/RouteErrors/RouteErrorsModal.tsx +6 -6
- package/src/components/RouteErrors/RouteErrorsModalItem.tsx +1 -1
- package/src/components/Slippage/SlippageTooltipContent.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +5 -6
- package/src/components/SwapDetails/SwapDetails.tsx +6 -10
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +1 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +2 -2
- package/src/components/TokenList/TokenList.styles.ts +1 -1
- package/src/components/TokenList/TokenList.tsx +1 -1
- package/src/constants/configs.ts +1 -0
- package/src/constants/errors.ts +44 -41
- package/src/constants/languages.ts +19 -0
- package/src/constants/messages.ts +7 -5
- package/src/hooks/useConfirmSwap.ts +1 -1
- package/src/hooks/useLanguage.ts +27 -0
- package/src/hooks/usePrepareBlockchainList/index.ts +1 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +108 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +3101 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +273 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +38 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +12 -0
- package/src/hooks/useSyncStoresWithConfig.ts +49 -1
- package/src/hooks/useTheme.ts +34 -56
- package/src/pages/ConfirmSwapPage.tsx +9 -18
- package/src/pages/Home.tsx +6 -7
- package/src/pages/LanguagePage.tsx +16 -39
- package/src/pages/SettingsPage.tsx +1 -1
- package/src/store/settings.ts +46 -4
- package/src/types/config.ts +6 -2
- package/src/utils/colors.ts +16 -0
- package/src/utils/configs.ts +3 -0
- package/src/utils/hash.ts +27 -0
- package/src/utils/settings.ts +1 -1
- package/src/utils/swap.ts +15 -20
- package/src/utils/time.ts +2 -4
- package/src/utils/ui.ts +72 -0
- package/src/utils/wallets.ts +4 -25
- package/dist/hooks/usePrepareBlockchainList.d.ts.map +0 -1
- package/src/hooks/usePrepareBlockchainList.ts +0 -125
|
@@ -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="
|
|
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="$
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
54
|
+
<Typography variant="label" size="large" color="neutral700">
|
|
55
55
|
{`${i18n.t('Created at')}:`}
|
|
56
56
|
</Typography>
|
|
57
|
-
<Typography variant="label" size="small" color="
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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="
|
|
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="
|
|
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="
|
|
295
|
+
<Typography variant="label" size="large" color="neutral700">
|
|
300
296
|
{`${i18n.t('Created at')}:`}
|
|
301
297
|
</Typography>
|
|
302
|
-
<Typography variant="label" size="small" color="
|
|
298
|
+
<Typography variant="label" size="small" color="neutral700">
|
|
303
299
|
{swapDate}
|
|
304
300
|
</Typography>
|
|
305
301
|
</div>
|
|
@@ -34,7 +34,7 @@ export function SwapsGroup(props: PropTypes) {
|
|
|
34
34
|
<Typography
|
|
35
35
|
variant="label"
|
|
36
36
|
size="medium"
|
|
37
|
-
color="
|
|
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="
|
|
71
|
+
color="neutral600"
|
|
72
72
|
className="group-title">
|
|
73
73
|
{i18n.t(group.title)}
|
|
74
74
|
</Typography>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const BLOCKCHAIN_LIST_SIZE = 10;
|
package/src/constants/errors.ts
CHANGED
|
@@ -4,54 +4,57 @@ import { i18n } from '@lingui/core';
|
|
|
4
4
|
|
|
5
5
|
import { ConfirmSwapErrorTypes } from '../types';
|
|
6
6
|
|
|
7
|
-
export const errorMessages = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
'USD Price Unknown, Cannot calculate Price Impact.
|
|
42
|
-
|
|
43
|
-
|
|
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,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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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'];
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { PrepareListOptions } from './usePrepareBlockchainList.types';
|
|
2
|
+
import type { BlockchainMeta } from 'rango-sdk';
|
|
3
|
+
|
|
4
|
+
import { MOST_USED_BLOCKChAINS } from './usePrepareBlockchainList.constants';
|
|
5
|
+
|
|
6
|
+
export function prepare(
|
|
7
|
+
blockchains: BlockchainMeta[],
|
|
8
|
+
preferredBlockchains: string[],
|
|
9
|
+
options?: PrepareListOptions
|
|
10
|
+
) {
|
|
11
|
+
/*
|
|
12
|
+
* TODO:
|
|
13
|
+
* We copying the `blockchains` which can causes performance penalties but we should because we are mutating the original object.
|
|
14
|
+
* A better way to solve the problem maybe is using new JS features like Use toSpliced() but
|
|
15
|
+
* we can not use it right now because we need to upgrade our toolings first.
|
|
16
|
+
*/
|
|
17
|
+
const list: BlockchainMeta[] = JSON.parse(JSON.stringify(blockchains));
|
|
18
|
+
let more: BlockchainMeta[] = [];
|
|
19
|
+
|
|
20
|
+
list.sort(sortByMostUsedBlockchains);
|
|
21
|
+
|
|
22
|
+
// Checking `limit` has set and it should be more than of the list items.
|
|
23
|
+
if (!!options?.limit && blockchains.length > options.limit) {
|
|
24
|
+
const start = options.limit;
|
|
25
|
+
let preferredBlockchainsWithoutMainList = preferredBlockchains;
|
|
26
|
+
|
|
27
|
+
if (preferredBlockchains.length <= options.limit) {
|
|
28
|
+
/*
|
|
29
|
+
* For first X (limit) numbers, we need to remove them from preferred if exists.
|
|
30
|
+
*/
|
|
31
|
+
for (let i = 0; i < options.limit; i++) {
|
|
32
|
+
const blockchain = list[i];
|
|
33
|
+
preferredBlockchainsWithoutMainList =
|
|
34
|
+
preferredBlockchainsWithoutMainList.filter((preferredBlockchain) => {
|
|
35
|
+
return blockchain.name !== preferredBlockchain;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
list.sort(
|
|
40
|
+
generateSortByPreferredBlockchainsFor(preferredBlockchainsWithoutMainList)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
* Splice will modify the original list and returns the deleted items
|
|
45
|
+
* We use the deleted items as `more`
|
|
46
|
+
*/
|
|
47
|
+
more = list.splice(start);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
list,
|
|
51
|
+
more,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** There is a hardcoded list of blockchains that we want to show them first in the list. */
|
|
56
|
+
export function sortByMostUsedBlockchains(
|
|
57
|
+
a: BlockchainMeta,
|
|
58
|
+
b: BlockchainMeta
|
|
59
|
+
) {
|
|
60
|
+
const mostUsed = MOST_USED_BLOCKChAINS;
|
|
61
|
+
const aIndexInMostUsed = mostUsed.findIndex((token) => token === a.name);
|
|
62
|
+
const bIndexInMostUsed = mostUsed.findIndex((token) => token === b.name);
|
|
63
|
+
const aIsMostUsed = aIndexInMostUsed > -1;
|
|
64
|
+
const bIsMostUsed = bIndexInMostUsed > -1;
|
|
65
|
+
|
|
66
|
+
if (aIsMostUsed && bIsMostUsed) {
|
|
67
|
+
return aIndexInMostUsed > bIndexInMostUsed ? 1 : -1;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (aIsMostUsed) {
|
|
71
|
+
return -1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (bIsMostUsed) {
|
|
75
|
+
return 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function generateSortByPreferredBlockchainsFor(
|
|
82
|
+
preferredBlockchains: string[]
|
|
83
|
+
) {
|
|
84
|
+
return function sortByPreferred(a: BlockchainMeta, b: BlockchainMeta) {
|
|
85
|
+
const aIndexInPreferred = preferredBlockchains.findIndex(
|
|
86
|
+
(blockchain) => blockchain === a.name
|
|
87
|
+
);
|
|
88
|
+
const bIndexInPreferred = preferredBlockchains.findIndex(
|
|
89
|
+
(blockchain) => blockchain === b.name
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const aIsPreferred = aIndexInPreferred > -1;
|
|
93
|
+
const bIsPreferred = bIndexInPreferred > -1;
|
|
94
|
+
|
|
95
|
+
if (aIsPreferred && bIsPreferred) {
|
|
96
|
+
return aIndexInPreferred > bIndexInPreferred ? 1 : -1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (preferredBlockchains.includes(a.name)) {
|
|
100
|
+
return -1;
|
|
101
|
+
}
|
|
102
|
+
if (preferredBlockchains.includes(b.name)) {
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return 0;
|
|
107
|
+
};
|
|
108
|
+
}
|