@rango-dev/widget-embedded 0.5.1-next.17 → 0.5.1-next.19
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/dist/Wallets.d.ts +0 -1
- package/dist/Wallets.d.ts.map +1 -1
- package/dist/Widget.d.ts +0 -1
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/BottomLogo.d.ts.map +1 -1
- package/dist/components/ChangeSlippageButton.d.ts.map +1 -1
- package/dist/components/ConfirmSwapWarnings.d.ts +2 -2
- package/dist/components/ConfirmSwapWarnings.d.ts.map +1 -1
- package/dist/components/HeaderButtons.d.ts.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/components/TokenPreview.d.ts.map +1 -1
- package/dist/components/warnings/HighSlippageWarning.d.ts.map +1 -1
- package/dist/components/warnings/MinRequiredSlippage.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap.d.ts +1 -1
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +2 -2
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/swap.d.ts +1 -1
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +1 -1
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/package.json +1 -4
- package/src/Wallets.tsx +0 -1
- package/src/Widget.tsx +18 -23
- package/src/components/BottomLogo.tsx +2 -4
- package/src/components/ChangeSlippageButton.tsx +3 -3
- package/src/components/ConfirmSwapWarnings.tsx +10 -13
- package/src/components/HeaderButtons.tsx +7 -9
- package/src/components/Layout.tsx +10 -11
- package/src/components/SwapDetailsPlaceholder.tsx +10 -2
- package/src/components/TokenInfo.tsx +26 -23
- package/src/components/TokenPreview.tsx +11 -12
- package/src/components/WidgetEvents.tsx +4 -4
- package/src/components/warnings/BalanceErrors.tsx +3 -3
- package/src/components/warnings/HighSlippageWarning.tsx +9 -2
- package/src/components/warnings/MinRequiredSlippage.tsx +11 -4
- package/src/hooks/useConfirmSwap.ts +6 -3
- package/src/pages/ConfirmSwapPage.tsx +5 -5
- package/src/pages/Home.tsx +2 -1
- package/src/pages/WalletsPage.tsx +2 -3
- package/src/store/wallets.ts +39 -13
- package/src/types/config.ts +2 -1
- package/src/types/swap.ts +1 -1
- package/src/utils/routing.ts +1 -1
- package/src/utils/swap.ts +13 -10
- package/dist/hooks/useSelectLanguage.d.ts +0 -5
- package/dist/hooks/useSelectLanguage.d.ts.map +0 -1
- package/dist/i18n.d.ts +0 -3
- package/dist/i18n.d.ts.map +0 -1
- package/src/hooks/useSelectLanguage.ts +0 -17
- package/src/i18n.js +0 -30
|
@@ -10,7 +10,7 @@ import { useWalletsStore } from '../store/wallets';
|
|
|
10
10
|
|
|
11
11
|
export function WidgetEvents() {
|
|
12
12
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
13
|
-
const
|
|
13
|
+
const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
|
|
14
14
|
|
|
15
15
|
const widgetEvents = useEvents();
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ export function WidgetEvents() {
|
|
|
20
20
|
const shouldRefetchBalance =
|
|
21
21
|
(event.type === StepEventType.TX_EXECUTION &&
|
|
22
22
|
event.status === StepExecutionEventStatus.TX_SENT &&
|
|
23
|
-
isApprovalTX(step)) ||
|
|
23
|
+
!isApprovalTX(step)) ||
|
|
24
24
|
event.type === StepEventType.SUCCEEDED;
|
|
25
25
|
|
|
26
26
|
if (shouldRefetchBalance) {
|
|
@@ -33,8 +33,8 @@ export function WidgetEvents() {
|
|
|
33
33
|
(wallet) => wallet.chain === step?.toBlockchain
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
fromAccount &&
|
|
37
|
-
toAccount &&
|
|
36
|
+
fromAccount && getWalletsDetails([fromAccount]);
|
|
37
|
+
toAccount && getWalletsDetails([toAccount]);
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Divider, styled, Typography } from '@rango-dev/ui';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
4
|
interface PropTypes {
|
|
5
5
|
messages: string[];
|
|
6
6
|
}
|
|
@@ -32,7 +32,7 @@ export function BalanceErrors({ messages }: PropTypes) {
|
|
|
32
32
|
return (
|
|
33
33
|
<>
|
|
34
34
|
<Typography className="title" variant="title" color={'error'}>
|
|
35
|
-
Insufficent Balance:
|
|
35
|
+
{i18n.t('Insufficent Balance:')}
|
|
36
36
|
</Typography>
|
|
37
37
|
<Divider size={8} />
|
|
38
38
|
<List showListStyle={showListStyle}>
|
|
@@ -44,4 +44,4 @@ export function BalanceErrors({ messages }: PropTypes) {
|
|
|
44
44
|
</List>
|
|
45
45
|
</>
|
|
46
46
|
);
|
|
47
|
-
}
|
|
47
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Alert } from '@rango-dev/ui';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ChangeSlippageButton } from '../ChangeSlippageButton';
|
|
4
|
+
import { i18n } from '@lingui/core';
|
|
4
5
|
|
|
5
6
|
interface PropTypes {
|
|
6
7
|
selectedSlippage: number;
|
|
@@ -11,8 +12,14 @@ export function HighSlippageWarning(props: PropTypes) {
|
|
|
11
12
|
|
|
12
13
|
return (
|
|
13
14
|
<Alert type="warning" footer={<ChangeSlippageButton />}>
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
{i18n.t(
|
|
16
|
+
'highSlippage',
|
|
17
|
+
{ selectedSlippage },
|
|
18
|
+
{
|
|
19
|
+
message:
|
|
20
|
+
' Caution, your slippage is high (={selectedSlippage}). Your trade may be front run.',
|
|
21
|
+
}
|
|
22
|
+
)}
|
|
16
23
|
</Alert>
|
|
17
24
|
);
|
|
18
25
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Divider, Typography, styled } from '@rango-dev/ui';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ChangeSlippageButton } from '../ChangeSlippageButton';
|
|
4
|
+
import { i18n } from '@lingui/core';
|
|
4
5
|
|
|
5
6
|
interface PropTypes {
|
|
6
7
|
minRequiredSlippage: string | null;
|
|
@@ -13,10 +14,16 @@ const StyledMessage = styled(Typography, {
|
|
|
13
14
|
export function MinRequiredSlippage({ minRequiredSlippage }: PropTypes) {
|
|
14
15
|
return (
|
|
15
16
|
<StyledMessage variant="body2">
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
{i18n.t(
|
|
18
|
+
'increaseSlippage',
|
|
19
|
+
{ minRequiredSlippage },
|
|
20
|
+
{
|
|
21
|
+
message:
|
|
22
|
+
'We recommend you to increase slippage to at least {minRequiredSlippage} for this route.',
|
|
23
|
+
}
|
|
24
|
+
)}
|
|
25
|
+
|
|
26
|
+
<Divider size={8} />
|
|
20
27
|
<ChangeSlippageButton />
|
|
21
28
|
</StyledMessage>
|
|
22
29
|
);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
ConfirmSwapWarnings,
|
|
11
11
|
PendingSwapSettings,
|
|
12
12
|
} from '../types';
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
import {
|
|
15
15
|
createBestRouteRequestBody,
|
|
16
16
|
getBalanceWarnings,
|
|
@@ -33,7 +33,10 @@ import {
|
|
|
33
33
|
} from '../utils/routing';
|
|
34
34
|
import { numberToString } from '../utils/numbers';
|
|
35
35
|
import { BestRouteResponse } from 'rango-sdk';
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
calculatePendingSwap,
|
|
38
|
+
PendingSwap,
|
|
39
|
+
} from '@rango-dev/queue-manager-rango-preset';
|
|
37
40
|
|
|
38
41
|
type ConfirmSwap = {
|
|
39
42
|
loading: boolean;
|
|
@@ -63,7 +66,7 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
63
66
|
const userSlippage = customSlippage || slippage;
|
|
64
67
|
const proceedAnywayRef = useRef(false);
|
|
65
68
|
const confiremedRouteRef = useRef<BestRouteResponse | null>(null);
|
|
66
|
-
|
|
69
|
+
const abortControllerRef = useRef<AbortController | null>(null);
|
|
67
70
|
|
|
68
71
|
const [loading, setLoading] = useState(false);
|
|
69
72
|
const [errors, setErrors] = useState<ConfirmSwapError[]>([]);
|
|
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
|
|
|
3
3
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
4
4
|
import { useWalletsStore } from '../store/wallets';
|
|
5
5
|
import { useWallets } from '@rango-dev/wallets-core';
|
|
6
|
+
import { i18n } from '@lingui/core';
|
|
6
7
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
7
8
|
import {
|
|
8
9
|
getKeplrCompatibleConnectedWallets,
|
|
@@ -20,7 +21,6 @@ import { useMetaStore } from '../store/meta';
|
|
|
20
21
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
21
22
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
22
23
|
import { TokenPreview } from '../components/TokenPreview';
|
|
23
|
-
import { t } from 'i18next';
|
|
24
24
|
import { Divider, ConfirmSwap, LoadingFailedAlert } from '@rango-dev/ui';
|
|
25
25
|
import RoutesOverview from '../components/RoutesOverview';
|
|
26
26
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
@@ -179,7 +179,7 @@ export function ConfirmSwapPage({
|
|
|
179
179
|
}}
|
|
180
180
|
usdValue={inputUsdValue}
|
|
181
181
|
amount={fromAmount}
|
|
182
|
-
label={t('From')}
|
|
182
|
+
label={i18n.t('From')}
|
|
183
183
|
loadingStatus={
|
|
184
184
|
loadingMetaStatus !== 'success'
|
|
185
185
|
? loadingMetaStatus
|
|
@@ -198,7 +198,7 @@ export function ConfirmSwapPage({
|
|
|
198
198
|
}}
|
|
199
199
|
usdValue={outputUsdValue}
|
|
200
200
|
amount={toAmount}
|
|
201
|
-
label={t('To')}
|
|
201
|
+
label={i18n.t('To')}
|
|
202
202
|
loadingStatus={
|
|
203
203
|
loadingMetaStatus !== 'success'
|
|
204
204
|
? loadingMetaStatus
|
|
@@ -239,8 +239,8 @@ export function ConfirmSwapPage({
|
|
|
239
239
|
}
|
|
240
240
|
confirmButtonTitle={
|
|
241
241
|
warnings.length > 0 || errors.length > 0
|
|
242
|
-
? 'Proceed anyway!'
|
|
243
|
-
: 'Confirm swap!'
|
|
242
|
+
? `${i18n.t('Proceed anyway!')}`
|
|
243
|
+
: `${i18n.t('Confirm swap!')}`
|
|
244
244
|
}
|
|
245
245
|
/>
|
|
246
246
|
);
|
package/src/pages/Home.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Header,
|
|
9
9
|
} from '@rango-dev/ui';
|
|
10
10
|
import React, { useEffect, useState } from 'react';
|
|
11
|
+
import { i18n } from '@lingui/core';
|
|
11
12
|
import { useInRouterContext, useNavigate } from 'react-router-dom';
|
|
12
13
|
import { TokenInfo } from '../components/TokenInfo';
|
|
13
14
|
import { fetchBestRoute, useBestRouteStore } from '../store/bestRoute';
|
|
@@ -136,7 +137,7 @@ export function Home() {
|
|
|
136
137
|
return (
|
|
137
138
|
<Container>
|
|
138
139
|
<Header
|
|
139
|
-
title=
|
|
140
|
+
title={i18n.t('SWAP')}
|
|
140
141
|
suffix={
|
|
141
142
|
<HeaderButtons
|
|
142
143
|
onClickRefresh={
|
|
@@ -18,7 +18,7 @@ import { useWallets } from '@rango-dev/wallets-core';
|
|
|
18
18
|
import { useUiStore } from '../store/ui';
|
|
19
19
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
20
20
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
21
|
-
import {
|
|
21
|
+
import { i18n } from '@lingui/core';
|
|
22
22
|
import { useMetaStore } from '../store/meta';
|
|
23
23
|
import { Spinner } from '@rango-dev/ui';
|
|
24
24
|
import { LoadingFailedAlert } from '@rango-dev/ui';
|
|
@@ -71,7 +71,6 @@ export function WalletsPage({ supportedWallets, multiWallets }: PropTypes) {
|
|
|
71
71
|
const toggleConnectWalletsButton =
|
|
72
72
|
useUiStore.use.toggleConnectWalletsButton();
|
|
73
73
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
74
|
-
const { t } = useTranslation();
|
|
75
74
|
|
|
76
75
|
const onSelectWallet = async (type: WalletType) => {
|
|
77
76
|
const wallet = state(type);
|
|
@@ -115,7 +114,7 @@ export function WalletsPage({ supportedWallets, multiWallets }: PropTypes) {
|
|
|
115
114
|
|
|
116
115
|
return (
|
|
117
116
|
<SecondaryPage
|
|
118
|
-
title={t('Select Wallet') || ''}
|
|
117
|
+
title={i18n.t('Select Wallet') || ''}
|
|
119
118
|
textField={false}
|
|
120
119
|
onBack={navigateBackFrom.bind(null, navigationRoutes.wallets)}>
|
|
121
120
|
<>
|
package/src/store/wallets.ts
CHANGED
|
@@ -45,7 +45,7 @@ interface WalletsStore {
|
|
|
45
45
|
initSelectedWallets: () => void;
|
|
46
46
|
setSelectedWallet: (wallet: SelectableWallet) => void;
|
|
47
47
|
clearConnectedWallet: () => void;
|
|
48
|
-
|
|
48
|
+
getWalletsDetails: (accounts: Wallet[], shouldRetry?: boolean) => void;
|
|
49
49
|
setCustomDestination: (customDestination: string) => void;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -56,7 +56,7 @@ export const useWalletsStore = createSelectors(
|
|
|
56
56
|
selectedWallets: [],
|
|
57
57
|
customDestination: '',
|
|
58
58
|
connectWallet: (accounts) => {
|
|
59
|
-
const
|
|
59
|
+
const getWalletsDetails = get().getWalletsDetails;
|
|
60
60
|
set((state) => ({
|
|
61
61
|
connectedWallets: state.connectedWallets
|
|
62
62
|
.filter((wallet) => wallet.walletType !== accounts[0].walletType)
|
|
@@ -72,7 +72,7 @@ export const useWalletsStore = createSelectors(
|
|
|
72
72
|
}))
|
|
73
73
|
),
|
|
74
74
|
}));
|
|
75
|
-
accounts
|
|
75
|
+
getWalletsDetails(accounts);
|
|
76
76
|
},
|
|
77
77
|
disconnectWallet: (walletType) => {
|
|
78
78
|
set((state) => ({
|
|
@@ -131,26 +131,50 @@ export const useWalletsStore = createSelectors(
|
|
|
131
131
|
connectedWallets: [],
|
|
132
132
|
selectedWallets: [],
|
|
133
133
|
})),
|
|
134
|
-
|
|
135
|
-
const
|
|
134
|
+
getWalletsDetails: async (accounts, shouldRetry = true) => {
|
|
135
|
+
const getWalletsDetails = get().getWalletsDetails;
|
|
136
|
+
const { tokens } = useMetaStore.getState().meta;
|
|
136
137
|
set((state) => ({
|
|
137
138
|
connectedWallets: state.connectedWallets.map((wallet) => {
|
|
138
|
-
return
|
|
139
|
+
return accounts.find((account) =>
|
|
140
|
+
isAccountAndWalletMatched(account, wallet)
|
|
141
|
+
)
|
|
139
142
|
? { ...wallet, loading: true }
|
|
140
143
|
: wallet;
|
|
141
144
|
}),
|
|
142
145
|
}));
|
|
143
146
|
try {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
const data = accounts.map(({ address, chain }) => ({
|
|
148
|
+
address,
|
|
149
|
+
blockchain: chain,
|
|
150
|
+
}));
|
|
151
|
+
const response = await httpService().getWalletsDetails(data);
|
|
152
|
+
const retrivedBalance = response.wallets;
|
|
148
153
|
if (retrivedBalance) {
|
|
149
154
|
set((state) => ({
|
|
150
155
|
connectedWallets: state.connectedWallets.map(
|
|
151
156
|
(connectedWallet) => {
|
|
152
|
-
|
|
153
|
-
|
|
157
|
+
const matchedAccount = accounts.find((account) =>
|
|
158
|
+
isAccountAndWalletMatched(account, connectedWallet)
|
|
159
|
+
);
|
|
160
|
+
const retrivedBalanceAccount = retrivedBalance.find(
|
|
161
|
+
(balance) =>
|
|
162
|
+
balance.address === connectedWallet.address &&
|
|
163
|
+
balance.blockChain === connectedWallet.chain
|
|
164
|
+
);
|
|
165
|
+
if (
|
|
166
|
+
retrivedBalanceAccount?.failed &&
|
|
167
|
+
matchedAccount &&
|
|
168
|
+
shouldRetry
|
|
169
|
+
) {
|
|
170
|
+
getWalletsDetails([matchedAccount], false);
|
|
171
|
+
}
|
|
172
|
+
return matchedAccount && retrivedBalanceAccount
|
|
173
|
+
? makeBalanceFor(
|
|
174
|
+
matchedAccount,
|
|
175
|
+
retrivedBalanceAccount,
|
|
176
|
+
tokens
|
|
177
|
+
)
|
|
154
178
|
: connectedWallet;
|
|
155
179
|
}
|
|
156
180
|
),
|
|
@@ -159,7 +183,9 @@ export const useWalletsStore = createSelectors(
|
|
|
159
183
|
} catch (error) {
|
|
160
184
|
set((state) => ({
|
|
161
185
|
connectedWallets: state.connectedWallets.map((balance) => {
|
|
162
|
-
return
|
|
186
|
+
return accounts.find((account) =>
|
|
187
|
+
isAccountAndWalletMatched(account, balance)
|
|
188
|
+
)
|
|
163
189
|
? resetConnectedWalletState(balance)
|
|
164
190
|
: balance;
|
|
165
191
|
}),
|
package/src/types/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Asset } from 'rango-sdk';
|
|
2
2
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
3
3
|
import { ProviderInterface } from '@rango-dev/wallets-core';
|
|
4
|
+
import { Language } from '@rango-dev/ui';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The above type defines a set of optional color properties for a widget.
|
|
@@ -115,7 +116,7 @@ export type WidgetConfig = {
|
|
|
115
116
|
wallets?: (WalletType | ProviderInterface)[];
|
|
116
117
|
multiWallets?: boolean;
|
|
117
118
|
customDestination?: boolean;
|
|
118
|
-
language?:
|
|
119
|
+
language?: Language;
|
|
119
120
|
theme?: WidgetTheme;
|
|
120
121
|
externalWallets?: boolean;
|
|
121
122
|
};
|
package/src/types/swap.ts
CHANGED
package/src/utils/routing.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SimulationAssetAndAmount,
|
|
3
3
|
SimulationValidationStatus,
|
|
4
|
-
} from '@rango-dev/ui/dist/types/swaps';
|
|
4
|
+
} from '@rango-dev/ui/dist/widget/ui/src/types/swaps';
|
|
5
5
|
import BigNumber from 'bignumber.js';
|
|
6
6
|
import { BestRouteResponse, BlockchainMeta, Token } from 'rango-sdk';
|
|
7
7
|
import { areEqual } from './common';
|
package/src/utils/swap.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
SwapResult,
|
|
7
7
|
Token,
|
|
8
8
|
} from 'rango-sdk';
|
|
9
|
+
import { i18n } from '@lingui/core';
|
|
9
10
|
import { ConnectedWallet } from '../store/wallets';
|
|
10
11
|
import { ZERO } from '../constants/numbers';
|
|
11
12
|
import { numberToString } from './numbers';
|
|
@@ -132,30 +133,32 @@ export function getSwapButtonState(
|
|
|
132
133
|
inputAmount: string
|
|
133
134
|
): SwapButtonState {
|
|
134
135
|
if (loadingMetaStatus !== 'success')
|
|
135
|
-
return { title: 'Connect Wallet'
|
|
136
|
+
return { title: `${i18n.t('Connect Wallet')}`, disabled: true };
|
|
136
137
|
if (connectedWallets.length == 0)
|
|
137
|
-
return { title: 'Connect Wallet'
|
|
138
|
-
if (loading)
|
|
138
|
+
return { title: `${i18n.t('Connect Wallet')}`, disabled: false };
|
|
139
|
+
if (loading)
|
|
140
|
+
return { title: `${i18n.t('Finding Best Route...')}`, disabled: true };
|
|
139
141
|
else if (!inputAmount || inputAmount === '0')
|
|
140
|
-
return { title: 'Enter an amount'
|
|
142
|
+
return { title: `${i18n.t('Enter an amount')}`, disabled: true };
|
|
141
143
|
else if (!bestRoute || !bestRoute.result)
|
|
142
|
-
return { title: 'Swap'
|
|
143
|
-
else if (hasLimitError)
|
|
144
|
+
return { title: `${i18n.t('Swap')}`, disabled: true };
|
|
145
|
+
else if (hasLimitError)
|
|
146
|
+
return { title: `${i18n.t('Limit Error')}`, disabled: true };
|
|
144
147
|
else if (highValueLoss)
|
|
145
|
-
return { title: 'Price impact is too high!'
|
|
148
|
+
return { title: `${i18n.t('Price impact is too high!')}`, disabled: true };
|
|
146
149
|
else if (priceImpactCanNotBeComputed)
|
|
147
150
|
return {
|
|
148
|
-
title: 'USD price is unknown, price impact might be high!'
|
|
151
|
+
title: `${i18n.t('USD price is unknown, price impact might be high!')}`,
|
|
149
152
|
disabled: false,
|
|
150
153
|
hasWarning: true,
|
|
151
154
|
};
|
|
152
155
|
else if (needsToWarnEthOnPath)
|
|
153
156
|
return {
|
|
154
|
-
title: 'The route goes through Ethereum. Continue?'
|
|
157
|
+
title: `${i18n.t('The route goes through Ethereum. Continue?')}`,
|
|
155
158
|
disabled: false,
|
|
156
159
|
hasWarning: true,
|
|
157
160
|
};
|
|
158
|
-
else return { title: 'Swap'
|
|
161
|
+
else return { title: `${i18n.t('Swap')}`, disabled: false };
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
export function canComputePriceImpact(
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSelectLanguage.d.ts","sourceRoot":"","sources":["../../src/hooks/useSelectLanguage.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,iBAAiB;4BAKR,MAAM;;EAStC"}
|
package/dist/i18n.d.ts
DELETED
package/dist/i18n.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.js"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useTranslation } from 'react-i18next';
|
|
2
|
-
|
|
3
|
-
export default function useSelectLanguage() {
|
|
4
|
-
const { i18n } = useTranslation();
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
const currentLanguage = i18n?.language || 'en';
|
|
8
|
-
const changeLanguage = (value: string) => {
|
|
9
|
-
if (currentLanguage !== value) {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
i18n.changeLanguage(value);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return { changeLanguage, currentLanguage };
|
|
17
|
-
}
|
package/src/i18n.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import i18n from 'i18next';
|
|
2
|
-
import { initReactI18next } from 'react-i18next';
|
|
3
|
-
import en from './languages/en.json';
|
|
4
|
-
import tr from './languages/tr.json';
|
|
5
|
-
import Backend from 'i18next-http-backend';
|
|
6
|
-
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
7
|
-
|
|
8
|
-
const languages = ['en', 'tr'];
|
|
9
|
-
|
|
10
|
-
i18n
|
|
11
|
-
.use(Backend)
|
|
12
|
-
// detect user language
|
|
13
|
-
.use(LanguageDetector)
|
|
14
|
-
// pass the i18n instance to react-i18next.
|
|
15
|
-
.use(initReactI18next)
|
|
16
|
-
.init({
|
|
17
|
-
resources: {
|
|
18
|
-
en: {
|
|
19
|
-
translation: en,
|
|
20
|
-
},
|
|
21
|
-
tr: {
|
|
22
|
-
translation: tr,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
fallbackLng: 'en',
|
|
26
|
-
debug: true,
|
|
27
|
-
whitelist: languages,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export default i18n;
|