@rango-dev/widget-embedded 0.5.1-next.18 → 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.
Files changed (56) hide show
  1. package/dist/Wallets.d.ts +0 -1
  2. package/dist/Wallets.d.ts.map +1 -1
  3. package/dist/Widget.d.ts +0 -1
  4. package/dist/Widget.d.ts.map +1 -1
  5. package/dist/components/BottomLogo.d.ts.map +1 -1
  6. package/dist/components/ChangeSlippageButton.d.ts.map +1 -1
  7. package/dist/components/ConfirmSwapWarnings.d.ts +2 -2
  8. package/dist/components/ConfirmSwapWarnings.d.ts.map +1 -1
  9. package/dist/components/HeaderButtons.d.ts.map +1 -1
  10. package/dist/components/Layout.d.ts.map +1 -1
  11. package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -1
  12. package/dist/components/TokenInfo.d.ts.map +1 -1
  13. package/dist/components/TokenPreview.d.ts.map +1 -1
  14. package/dist/components/warnings/HighSlippageWarning.d.ts.map +1 -1
  15. package/dist/components/warnings/MinRequiredSlippage.d.ts.map +1 -1
  16. package/dist/hooks/useConfirmSwap.d.ts +1 -1
  17. package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/index.js.map +4 -4
  20. package/dist/pages/Home.d.ts.map +1 -1
  21. package/dist/pages/WalletsPage.d.ts.map +1 -1
  22. package/dist/types/config.d.ts +2 -1
  23. package/dist/types/config.d.ts.map +1 -1
  24. package/dist/types/swap.d.ts +1 -1
  25. package/dist/types/swap.d.ts.map +1 -1
  26. package/dist/utils/routing.d.ts +1 -1
  27. package/dist/utils/routing.d.ts.map +1 -1
  28. package/dist/utils/swap.d.ts.map +1 -1
  29. package/package.json +1 -4
  30. package/src/Wallets.tsx +0 -1
  31. package/src/Widget.tsx +18 -23
  32. package/src/components/BottomLogo.tsx +2 -4
  33. package/src/components/ChangeSlippageButton.tsx +3 -3
  34. package/src/components/ConfirmSwapWarnings.tsx +10 -13
  35. package/src/components/HeaderButtons.tsx +7 -9
  36. package/src/components/Layout.tsx +10 -11
  37. package/src/components/SwapDetailsPlaceholder.tsx +10 -2
  38. package/src/components/TokenInfo.tsx +26 -23
  39. package/src/components/TokenPreview.tsx +11 -12
  40. package/src/components/warnings/BalanceErrors.tsx +3 -3
  41. package/src/components/warnings/HighSlippageWarning.tsx +9 -2
  42. package/src/components/warnings/MinRequiredSlippage.tsx +11 -4
  43. package/src/hooks/useConfirmSwap.ts +6 -3
  44. package/src/pages/ConfirmSwapPage.tsx +5 -5
  45. package/src/pages/Home.tsx +2 -1
  46. package/src/pages/WalletsPage.tsx +2 -3
  47. package/src/types/config.ts +2 -1
  48. package/src/types/swap.ts +1 -1
  49. package/src/utils/routing.ts +1 -1
  50. package/src/utils/swap.ts +13 -10
  51. package/dist/hooks/useSelectLanguage.d.ts +0 -5
  52. package/dist/hooks/useSelectLanguage.d.ts.map +0 -1
  53. package/dist/i18n.d.ts +0 -3
  54. package/dist/i18n.d.ts.map +0 -1
  55. package/src/hooks/useSelectLanguage.ts +0 -17
  56. package/src/i18n.js +0 -30
@@ -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
- We recommend you to increase slippage to at least &nbsp;
17
- {minRequiredSlippage}
18
- &nbsp; for this route.
19
- <Divider size={8}/>
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
- import { PendingSwap } from '@rango-dev/ui/dist/containers/History/types';
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 { calculatePendingSwap } from '@rango-dev/queue-manager-rango-preset';
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
- let abortControllerRef = useRef<AbortController | null>(null);
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
  );
@@ -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="SWAP"
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 { useTranslation } from 'react-i18next';
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
  <>
@@ -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?: string;
119
+ language?: Language;
119
120
  theme?: WidgetTheme;
120
121
  externalWallets?: boolean;
121
122
  };
package/src/types/swap.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SwapSavedSettings } from '@rango-dev/ui/dist/types/swaps';
1
+ import { SwapSavedSettings } from 'rango-types/lib';
2
2
 
3
3
  export type PendingSwapSettings = Omit<
4
4
  SwapSavedSettings,
@@ -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', disabled: true };
136
+ return { title: `${i18n.t('Connect Wallet')}`, disabled: true };
136
137
  if (connectedWallets.length == 0)
137
- return { title: 'Connect Wallet', disabled: false };
138
- if (loading) return { title: 'Finding Best Route...', disabled: true };
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', disabled: true };
142
+ return { title: `${i18n.t('Enter an amount')}`, disabled: true };
141
143
  else if (!bestRoute || !bestRoute.result)
142
- return { title: 'Swap', disabled: true };
143
- else if (hasLimitError) return { title: 'Limit Error', disabled: true };
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!', disabled: true };
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', disabled: false };
161
+ else return { title: `${i18n.t('Swap')}`, disabled: false };
159
162
  }
160
163
 
161
164
  export function canComputePriceImpact(
@@ -1,5 +0,0 @@
1
- export default function useSelectLanguage(): {
2
- changeLanguage: (value: string) => void;
3
- currentLanguage: string;
4
- };
5
- //# sourceMappingURL=useSelectLanguage.d.ts.map
@@ -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
@@ -1,3 +0,0 @@
1
- export default i18n;
2
- import i18n from "i18next";
3
- //# sourceMappingURL=i18n.d.ts.map
@@ -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;