@rango-dev/widget-embedded 0.14.1-next.16 → 0.14.1-next.18

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.
@@ -57,7 +57,7 @@ export declare const useSettingsStore: {
57
57
  infiniteApprove: () => boolean;
58
58
  disabledLiquiditySources: () => string[];
59
59
  theme: () => ThemeMode;
60
- language: () => "en" | "es" | "jp" | "fr";
60
+ language: () => "en" | "es" | "ja" | "fr";
61
61
  affiliateRef: () => string | null;
62
62
  affiliatePercent: () => number | null;
63
63
  affiliateWallets: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.14.1-next.16",
3
+ "version": "0.14.1-next.18",
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.10",
26
+ "@rango-dev/ui": "^0.17.1-next.11",
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",
@@ -13,7 +13,7 @@ export const LANGUAGES: LanguageItem[] = [
13
13
  { title: 'English', label: 'English', local: 'en', SVGFlag: English },
14
14
  { title: 'Spanish', label: 'Español', local: 'es', SVGFlag: Spanish },
15
15
  { title: 'French', label: 'Français', local: 'fr', SVGFlag: French },
16
- { title: 'Japanese', label: '日本語', local: 'jp', SVGFlag: Japanese },
16
+ { title: 'Japanese', label: '日本語', local: 'ja', SVGFlag: Japanese },
17
17
  ];
18
18
 
19
19
  export const DEFAULT_LANGUAGE = 'en';
@@ -1,7 +1,7 @@
1
1
  import type { WidgetConfig } from '../types';
2
2
  import type { Asset } from 'rango-sdk';
3
3
 
4
- import { useEffect, useRef } from 'react';
4
+ import { useEffect, useMemo, useRef } from 'react';
5
5
 
6
6
  import { useBestRouteStore } from '../store/bestRoute';
7
7
  import { useMetaStore } from '../store/meta';
@@ -15,6 +15,10 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
15
15
  setToBlockchain,
16
16
  setFromBlockchain,
17
17
  setFromToken,
18
+ fromToken,
19
+ toToken,
20
+ fromBlockchain,
21
+ toBlockchain,
18
22
  } = useBestRouteStore();
19
23
 
20
24
  const {
@@ -25,6 +29,22 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
25
29
  const { setAffiliateRef, setAffiliatePercent, setAffiliateWallets } =
26
30
  useSettingsStore();
27
31
 
32
+ const fromTokensConfig = useMemo(
33
+ () => config?.from?.tokens,
34
+ [config?.from?.tokens]
35
+ );
36
+ const fromBlockchainsConfig = useMemo(
37
+ () => config?.from?.blockchains,
38
+ [config?.from?.blockchains]
39
+ );
40
+ const toTokensConfig = useMemo(
41
+ () => config?.to?.tokens,
42
+ [config?.to?.tokens]
43
+ );
44
+ const toBlockchainsConfig = useMemo(
45
+ () => config?.to?.blockchains,
46
+ [config?.to?.blockchains]
47
+ );
28
48
  const prevConfigFromToken = useRef<Asset | undefined>(undefined);
29
49
  const prevConfigToToken = useRef<Asset | undefined>(undefined);
30
50
  const prevConfigFromBlockchain = useRef<string | undefined>(undefined);
@@ -62,6 +82,34 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
62
82
  loadingMetaStatus,
63
83
  ]);
64
84
 
85
+ useEffect(() => {
86
+ if (fromToken && fromTokensConfig) {
87
+ if (!fromTokensConfig.some((token) => tokensAreEqual(token, fromToken))) {
88
+ setFromToken(null);
89
+ }
90
+ }
91
+
92
+ if (fromBlockchain && fromBlockchainsConfig) {
93
+ if (!fromBlockchainsConfig.includes(fromBlockchain.name)) {
94
+ setFromBlockchain(null);
95
+ }
96
+ }
97
+ }, [fromTokensConfig, fromBlockchainsConfig]);
98
+
99
+ useEffect(() => {
100
+ if (toToken && toTokensConfig) {
101
+ if (!toTokensConfig.some((token) => tokensAreEqual(token, toToken))) {
102
+ setToToken(null);
103
+ }
104
+ }
105
+
106
+ if (toBlockchain && toBlockchainsConfig) {
107
+ if (!toBlockchainsConfig.includes(toBlockchain.name)) {
108
+ setToBlockchain(null);
109
+ }
110
+ }
111
+ }, [toTokensConfig, toBlockchainsConfig]);
112
+
65
113
  useEffect(() => {
66
114
  if (loadingMetaStatus === 'success') {
67
115
  const chain = blockchains.find(