@rango-dev/widget-embedded 0.14.1-next.13 → 0.14.1-next.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"LanguagePage.d.ts","sourceRoot":"","sources":["../../src/pages/LanguagePage.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAYxC,wBAAgB,YAAY,sBA8D3B"}
1
+ {"version":3,"file":"LanguagePage.d.ts","sourceRoot":"","sources":["../../src/pages/LanguagePage.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,wBAAgB,YAAY,sBA2C3B"}
@@ -1,10 +1,12 @@
1
- type Theme = 'auto' | 'dark' | 'light';
1
+ import { type Language } from '@rango-dev/ui';
2
+ export type ThemeMode = 'auto' | 'dark' | 'light';
2
3
  export interface SettingsState {
3
4
  slippage: number;
4
5
  customSlippage: number | null;
5
6
  infiniteApprove: boolean;
6
7
  disabledLiquiditySources: string[];
7
- theme: Theme;
8
+ theme: ThemeMode;
9
+ language: Language;
8
10
  affiliateRef: string | null;
9
11
  affiliatePercent: number | null;
10
12
  affiliateWallets: {
@@ -14,7 +16,8 @@ export interface SettingsState {
14
16
  setCustomSlippage: (customSlippage: number | null) => void;
15
17
  toggleInfiniteApprove: () => void;
16
18
  toggleLiquiditySource: (name: string) => void;
17
- setTheme: (theme: Theme) => void;
19
+ setTheme: (theme: ThemeMode) => void;
20
+ setLanguage: (language: Language) => void;
18
21
  toggleAllLiquiditySources: (shouldReset?: boolean) => void;
19
22
  setAffiliateRef: (affiliateRef: string | null) => void;
20
23
  setAffiliatePercent: (affiliatePercent: number | null) => void;
@@ -49,7 +52,8 @@ export declare const useSettingsStore: {
49
52
  customSlippage: () => number | null;
50
53
  infiniteApprove: () => boolean;
51
54
  disabledLiquiditySources: () => string[];
52
- theme: () => Theme;
55
+ theme: () => ThemeMode;
56
+ language: () => "en" | "es" | "jp" | "fr";
53
57
  affiliateRef: () => string | null;
54
58
  affiliatePercent: () => number | null;
55
59
  affiliateWallets: () => {
@@ -59,7 +63,8 @@ export declare const useSettingsStore: {
59
63
  setCustomSlippage: () => (customSlippage: number | null) => void;
60
64
  toggleInfiniteApprove: () => () => void;
61
65
  toggleLiquiditySource: () => (name: string) => void;
62
- setTheme: () => (theme: Theme) => void;
66
+ setTheme: () => (theme: ThemeMode) => void;
67
+ setLanguage: () => (language: Language) => void;
63
68
  toggleAllLiquiditySources: () => (shouldReset?: boolean) => void;
64
69
  setAffiliateRef: () => (affiliateRef: string | null) => void;
65
70
  setAffiliatePercent: () => (affiliatePercent: number | null) => void;
@@ -68,5 +73,4 @@ export declare const useSettingsStore: {
68
73
  } | null) => void;
69
74
  };
70
75
  };
71
- export {};
72
76
  //# sourceMappingURL=settings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/store/settings.ts"],"names":[],"mappings":"AASA,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACnD,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,iBAAiB,EAAE,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,qBAAqB,EAAE,MAAM,IAAI,CA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,CAAC"}
@@ -121,6 +121,8 @@ export type BlockchainAndTokenConfig = {
121
121
  * If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
122
122
  * @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
123
123
  * you could use to pin tokens of your choice to the top of the token list.
124
+ * @property {boolean} includeNewLiquiditySources - The `includeNewLiquiditySources` property is a boolean value that when you
125
+ * set it to true, whenever a new liquidity source is added, it will be added to your list as well.
124
126
  */
125
127
  export type WidgetConfig = {
126
128
  apiKey: string;
@@ -137,5 +139,6 @@ export type WidgetConfig = {
137
139
  theme?: WidgetTheme;
138
140
  externalWallets?: boolean;
139
141
  pinnedTokens?: Asset[];
142
+ includeNewLiquiditySources?: boolean;
140
143
  };
141
144
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC;AAClD,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO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.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.14.1-next.13",
3
+ "version": "0.14.1-next.15",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "@rango-dev/queue-manager-core": "^0.17.0",
24
24
  "@rango-dev/queue-manager-rango-preset": "^0.17.1-next.2",
25
25
  "@rango-dev/queue-manager-react": "^0.17.0",
26
- "@rango-dev/ui": "^0.17.1-next.9",
26
+ "@rango-dev/ui": "^0.17.1-next.10",
27
27
  "@rango-dev/wallets-react": "^0.3.1-next.1",
28
28
  "@rango-dev/wallets-shared": "^0.17.1-next.0",
29
29
  "bignumber.js": "^9.1.1",
package/src/Widget.tsx CHANGED
@@ -9,6 +9,7 @@ import { AppRouter } from './components/AppRouter';
9
9
  import { AppRoutes } from './components/AppRoutes';
10
10
  import { WidgetEvents } from './components/WidgetEvents';
11
11
  import { globalFont } from './globalStyles';
12
+ import { useLanguage } from './hooks/useLanguage';
12
13
  import { useTheme } from './hooks/useTheme';
13
14
  import QueueManager from './QueueManager';
14
15
  import { useAppStore } from './store/app';
@@ -44,6 +45,8 @@ export function Main(props: PropsWithChildren<WidgetProps>) {
44
45
  globalFont();
45
46
 
46
47
  const { activeTheme } = useTheme(config?.theme || {});
48
+ const { activeLanguage, changeLanguage } = useLanguage();
49
+
47
50
  const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
48
51
  useState<string>('');
49
52
  const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
@@ -65,8 +68,14 @@ export function Main(props: PropsWithChildren<WidgetProps>) {
65
68
  widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
66
69
  }, []);
67
70
 
71
+ useEffect(() => {
72
+ if (config?.language) {
73
+ changeLanguage(config.language);
74
+ }
75
+ }, [config?.language]);
76
+
68
77
  return (
69
- <I18nManager language={config?.language}>
78
+ <I18nManager language={activeLanguage}>
70
79
  <MainContainer id="swap-container" className={activeTheme()}>
71
80
  <QueueManager>
72
81
  <WidgetEvents />
@@ -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,7 +40,7 @@ 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
@@ -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
  );
@@ -4,54 +4,56 @@ 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:
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
+ bridgeLimitErrors: {
22
+ increaseAmount: i18n.t('Bridge Limit Error: Please increase your amount'),
23
+ decreaseAmount: i18n.t('Bridge Limit Error: Please decrease your amount'),
24
+ },
25
+ highValueLossError: {
26
+ impactTitle: i18n.t('High Price Impact'),
27
+ title: i18n.t('Price impact is too high!'),
28
+ description: i18n.t(
29
+ 'The price impact is significantly higher than the allowed amount. If you are sure, continue, otherwise, change the swap.'
30
+ ),
31
+ confirmMessage: i18n.t('Confirm High price impact'),
32
+ },
33
+ routeUpdatedWithHighValueLoss: {
34
+ title: i18n.t(
35
+ 'Route updated and price impact is too high, try again later!'
36
+ ),
37
+ },
38
+ unknownPriceError: {
39
+ impactTitle: i18n.t('USD Price Unknown'),
40
+ title: i18n.t('USD Price Unknown, Cannot calculate Price Impact.'),
41
+ description: i18n.t(
42
+ 'USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?'
43
+ ),
44
+ confirmMessage: i18n.t('Confirm USD Price Unknown'),
45
+ },
46
+ };
45
47
  };
46
48
 
47
49
  export function getConfirmSwapErrorMessage(error: ConfirmSwapError) {
48
50
  switch (error.type) {
49
51
  case ConfirmSwapErrorTypes.NO_ROUTE:
50
- return error.diagnosisMessage ?? errorMessages.noRoutesError.title;
52
+ return error.diagnosisMessage ?? errorMessages().noRoutesError.title;
51
53
  case ConfirmSwapErrorTypes.REQUEST_FAILED:
52
- return errorMessages.genericServerError;
54
+ return errorMessages().genericServerError;
53
55
  case ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS:
54
- return errorMessages.routeUpdatedWithHighValueLoss.title;
56
+ return errorMessages().routeUpdatedWithHighValueLoss.title;
55
57
  default:
56
58
  return '';
57
59
  }
@@ -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: 'jp', 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
+ }
@@ -347,7 +347,7 @@ export function Home() {
347
347
  USD_VALUE_MAX_DECIMALS
348
348
  ),
349
349
  error: priceImpactInputCanNotBeComputed
350
- ? errorMessages.unknownPriceError.impactTitle
350
+ ? errorMessages().unknownPriceError.impactTitle
351
351
  : undefined,
352
352
  }}
353
353
  disabled={loadingMetaStatus === 'failed'}
@@ -398,7 +398,7 @@ export function Home() {
398
398
  USD_VALUE_MAX_DECIMALS
399
399
  ),
400
400
  error: priceImpactOutputCanNotBeComputed
401
- ? errorMessages.unknownPriceError.impactTitle
401
+ ? errorMessages().unknownPriceError.impactTitle
402
402
  : undefined,
403
403
  }}
404
404
  onClickToken={() => navigate('to-swap')}
@@ -6,57 +6,34 @@ import {
6
6
  RadioRoot,
7
7
  Typography,
8
8
  } from '@rango-dev/ui';
9
- import React, { useState } from 'react';
9
+ import React from 'react';
10
10
 
11
11
  import { Layout } from '../components/Layout';
12
12
  import { SettingsContainer } from '../components/SettingsContainer';
13
13
  import { navigationRoutes } from '../constants/navigationRoutes';
14
+ import { useLanguage } from '../hooks/useLanguage';
14
15
  import { useNavigateBack } from '../hooks/useNavigateBack';
15
16
 
16
- enum Languages {
17
- ENGLISH = 'english',
18
- FRENCH = 'french',
19
- SPANISH = 'spanish',
20
- }
21
17
  export function LanguagePage() {
22
18
  const { navigateBackFrom } = useNavigateBack();
23
- const [language, setLanguage] = useState(Languages.ENGLISH);
24
19
 
25
- const languageList = [
26
- {
27
- id: Languages.ENGLISH,
28
- value: Languages.ENGLISH,
29
- title: (
30
- <Typography variant="title" size="xmedium">
31
- {i18n.t('English')}
32
- </Typography>
33
- ),
34
- onClick: () => setLanguage(Languages.ENGLISH),
35
- end: <Radio value={Languages.ENGLISH} />,
36
- },
37
- {
38
- id: Languages.FRENCH,
39
- value: Languages.FRENCH,
40
- title: (
41
- <Typography variant="title" size="xmedium">
42
- {i18n.t('French')}
43
- </Typography>
44
- ),
45
- onClick: () => setLanguage(Languages.FRENCH),
46
- end: <Radio value={Languages.FRENCH} />,
47
- },
48
- {
49
- id: Languages.SPANISH,
50
- value: Languages.SPANISH,
20
+ const { activeLanguage, changeLanguage, languages } = useLanguage();
21
+
22
+ const languageList = languages.map((languageItem) => {
23
+ const { local, label, SVGFlag } = languageItem;
24
+ return {
25
+ id: local,
26
+ value: local,
51
27
  title: (
52
28
  <Typography variant="title" size="xmedium">
53
- {i18n.t('Spanish')}
29
+ {label}
54
30
  </Typography>
55
31
  ),
56
- onClick: () => setLanguage(Languages.SPANISH),
57
- end: <Radio value={Languages.SPANISH} />,
58
- },
59
- ];
32
+ onClick: () => changeLanguage(languageItem.local),
33
+ end: <Radio value={local} />,
34
+ start: <SVGFlag />,
35
+ };
36
+ });
60
37
 
61
38
  return (
62
39
  <Layout
@@ -65,7 +42,7 @@ export function LanguagePage() {
65
42
  title: i18n.t('Language'),
66
43
  }}>
67
44
  <SettingsContainer>
68
- <RadioRoot value={language}>
45
+ <RadioRoot value={activeLanguage}>
69
46
  <List
70
47
  type={
71
48
  <ListItemButton
@@ -1,20 +1,23 @@
1
+ import { type Language } from '@rango-dev/ui';
1
2
  import { create } from 'zustand';
2
3
  import { persist, subscribeWithSelector } from 'zustand/middleware';
3
4
 
5
+ import { DEFAULT_LANGUAGE } from '../constants/languages';
4
6
  import { DEFAULT_SLIPPAGE } from '../constants/swapSettings';
5
7
  import { removeDuplicateFrom } from '../utils/common';
6
8
 
7
9
  import { useMetaStore } from './meta';
8
10
  import createSelectors from './selectors';
9
11
 
10
- type Theme = 'auto' | 'dark' | 'light';
12
+ export type ThemeMode = 'auto' | 'dark' | 'light';
11
13
 
12
14
  export interface SettingsState {
13
15
  slippage: number;
14
16
  customSlippage: number | null;
15
17
  infiniteApprove: boolean;
16
18
  disabledLiquiditySources: string[];
17
- theme: Theme;
19
+ theme: ThemeMode;
20
+ language: Language;
18
21
  affiliateRef: string | null;
19
22
  affiliatePercent: number | null;
20
23
  affiliateWallets: { [key: string]: string } | null;
@@ -22,7 +25,8 @@ export interface SettingsState {
22
25
  setCustomSlippage: (customSlippage: number | null) => void;
23
26
  toggleInfiniteApprove: () => void;
24
27
  toggleLiquiditySource: (name: string) => void;
25
- setTheme: (theme: Theme) => void;
28
+ setTheme: (theme: ThemeMode) => void;
29
+ setLanguage: (language: Language) => void;
26
30
  toggleAllLiquiditySources: (shouldReset?: boolean) => void;
27
31
  setAffiliateRef: (affiliateRef: string | null) => void;
28
32
  setAffiliatePercent: (affiliatePercent: number | null) => void;
@@ -43,6 +47,7 @@ export const useSettingsStore = createSelectors(
43
47
  affiliateWallets: null,
44
48
  disabledLiquiditySources: [],
45
49
  theme: 'auto',
50
+ language: DEFAULT_LANGUAGE,
46
51
  setSlippage: (slippage) =>
47
52
  set(() => ({
48
53
  slippage: slippage,
@@ -106,6 +111,10 @@ export const useSettingsStore = createSelectors(
106
111
  set(() => ({
107
112
  theme,
108
113
  })),
114
+ setLanguage: (language) =>
115
+ set(() => ({
116
+ language,
117
+ })),
109
118
  })),
110
119
  {
111
120
  name: 'user-settings',
@@ -121,6 +121,8 @@ export type BlockchainAndTokenConfig = {
121
121
  * If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
122
122
  * @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
123
123
  * you could use to pin tokens of your choice to the top of the token list.
124
+ * @property {boolean} includeNewLiquiditySources - The `includeNewLiquiditySources` property is a boolean value that when you
125
+ * set it to true, whenever a new liquidity source is added, it will be added to your list as well.
124
126
  */
125
127
  export type WidgetConfig = {
126
128
  apiKey: string;
@@ -137,4 +139,5 @@ export type WidgetConfig = {
137
139
  theme?: WidgetTheme;
138
140
  externalWallets?: boolean;
139
141
  pinnedTokens?: Asset[];
142
+ includeNewLiquiditySources?: boolean;
140
143
  };
@@ -33,7 +33,7 @@ export function getUniqueSwappersGroups(
33
33
  let isSupportedSwapper = true;
34
34
  if (supportedSwappers) {
35
35
  isSupportedSwapper = supportedSwappers.some(
36
- (supportedItem) => supportedItem === swapperItem.title
36
+ (supportedItem) => supportedItem === swapperItem.swapperGroup
37
37
  );
38
38
  }
39
39