@rango-dev/widget-embedded 0.1.10-next.100
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/App.d.ts +9 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/QueueManager.d.ts +4 -0
- package/dist/QueueManager.d.ts.map +1 -0
- package/dist/components/AppRouter.d.ts +9 -0
- package/dist/components/AppRouter.d.ts.map +1 -0
- package/dist/components/AppRoutes.d.ts +8 -0
- package/dist/components/AppRoutes.d.ts.map +1 -0
- package/dist/components/BottomLogo.d.ts +3 -0
- package/dist/components/BottomLogo.d.ts.map +1 -0
- package/dist/components/ChangeSlippageButton.d.ts +3 -0
- package/dist/components/ChangeSlippageButton.d.ts.map +1 -0
- package/dist/components/ConfirmSwapErrors.d.ts +4 -0
- package/dist/components/ConfirmSwapErrors.d.ts.map +1 -0
- package/dist/components/ConfirmSwapWarnings.d.ts +4 -0
- package/dist/components/ConfirmSwapWarnings.d.ts.map +1 -0
- package/dist/components/Footer.d.ts +2 -0
- package/dist/components/Footer.d.ts.map +1 -0
- package/dist/components/Header.d.ts +10 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/HeaderButtons.d.ts +4 -0
- package/dist/components/HeaderButtons.d.ts.map +1 -0
- package/dist/components/Layout.d.ts +7 -0
- package/dist/components/Layout.d.ts.map +1 -0
- package/dist/components/RoutesOverview.d.ts +10 -0
- package/dist/components/RoutesOverview.d.ts.map +1 -0
- package/dist/components/SwitchFromAndTo.d.ts +4 -0
- package/dist/components/SwitchFromAndTo.d.ts.map +1 -0
- package/dist/components/TokenInfo.d.ts +18 -0
- package/dist/components/TokenInfo.d.ts.map +1 -0
- package/dist/components/TokenPreview.d.ts +20 -0
- package/dist/components/TokenPreview.d.ts.map +1 -0
- package/dist/components/UpdateUrl.d.ts +2 -0
- package/dist/components/UpdateUrl.d.ts.map +1 -0
- package/dist/components/warnings/BalanceWarnings.d.ts +7 -0
- package/dist/components/warnings/BalanceWarnings.d.ts.map +1 -0
- package/dist/components/warnings/ConfirmSwapExtraMessages.d.ts +7 -0
- package/dist/components/warnings/ConfirmSwapExtraMessages.d.ts.map +1 -0
- package/dist/components/warnings/HighSlippageWarning.d.ts +7 -0
- package/dist/components/warnings/HighSlippageWarning.d.ts.map +1 -0
- package/dist/components/warnings/MinRequiredSlippage.d.ts +7 -0
- package/dist/components/warnings/MinRequiredSlippage.d.ts.map +1 -0
- package/dist/constants/errors.d.ts +4 -0
- package/dist/constants/errors.d.ts.map +1 -0
- package/dist/constants/navigationRoutes.d.ts +15 -0
- package/dist/constants/navigationRoutes.d.ts.map +1 -0
- package/dist/constants/numbers.d.ts +3 -0
- package/dist/constants/numbers.d.ts.map +1 -0
- package/dist/constants/searchParams.d.ts +8 -0
- package/dist/constants/searchParams.d.ts.map +1 -0
- package/dist/constants/swapSettings.d.ts +6 -0
- package/dist/constants/swapSettings.d.ts.map +1 -0
- package/dist/globalStyles.d.ts +3 -0
- package/dist/globalStyles.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap.d.ts +11 -0
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/useCopyToClipboard.d.ts +2 -0
- package/dist/hooks/useCopyToClipboard.d.ts.map +1 -0
- package/dist/hooks/useNavigateBack.d.ts +4 -0
- package/dist/hooks/useNavigateBack.d.ts.map +1 -0
- package/dist/hooks/usePrevious.d.ts +2 -0
- package/dist/hooks/usePrevious.d.ts.map +1 -0
- package/dist/hooks/useSelectLanguage.d.ts +5 -0
- package/dist/hooks/useSelectLanguage.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts +8 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/i18n.d.ts +3 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/lib.d.ts +8 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/mockData/pendingSwap.d.ts +2 -0
- package/dist/mockData/pendingSwap.d.ts.map +1 -0
- package/dist/pages/ConfirmSwapPage.d.ts +3 -0
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -0
- package/dist/pages/ConfirmWalletsPage.d.ts +3 -0
- package/dist/pages/ConfirmWalletsPage.d.ts.map +1 -0
- package/dist/pages/HistoryPage.d.ts +3 -0
- package/dist/pages/HistoryPage.d.ts.map +1 -0
- package/dist/pages/Home.d.ts +9 -0
- package/dist/pages/Home.d.ts.map +1 -0
- package/dist/pages/LiquiditySourcesPage.d.ts +8 -0
- package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -0
- package/dist/pages/SelectChainPage.d.ts +9 -0
- package/dist/pages/SelectChainPage.d.ts.map +1 -0
- package/dist/pages/SelectTokenPage.d.ts +15 -0
- package/dist/pages/SelectTokenPage.d.ts.map +1 -0
- package/dist/pages/SettingsPage.d.ts +8 -0
- package/dist/pages/SettingsPage.d.ts.map +1 -0
- package/dist/pages/SwapDetailsPage.d.ts +3 -0
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -0
- package/dist/pages/WalletsPage.d.ts +9 -0
- package/dist/pages/WalletsPage.d.ts.map +1 -0
- package/dist/services/httpService.d.ts +3 -0
- package/dist/services/httpService.d.ts.map +1 -0
- package/dist/store/bestRoute.d.ts +28 -0
- package/dist/store/bestRoute.d.ts.map +1 -0
- package/dist/store/meta.d.ts +9 -0
- package/dist/store/meta.d.ts.map +1 -0
- package/dist/store/selectors.d.ts +11 -0
- package/dist/store/selectors.d.ts.map +1 -0
- package/dist/store/settings.d.ts +17 -0
- package/dist/store/settings.d.ts.map +1 -0
- package/dist/store/ui.d.ts +2 -0
- package/dist/store/ui.d.ts.map +1 -0
- package/dist/store/wallets.d.ts +28 -0
- package/dist/store/wallets.d.ts.map +1 -0
- package/dist/types/config.d.ts +40 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/routing.d.ts +45 -0
- package/dist/types/routing.d.ts.map +1 -0
- package/dist/types/swap.d.ts +11 -0
- package/dist/types/swap.d.ts.map +1 -0
- package/dist/utils/common.d.ts +4 -0
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/numbers.d.ts +14 -0
- package/dist/utils/numbers.d.ts.map +1 -0
- package/dist/utils/queue.d.ts +4 -0
- package/dist/utils/queue.d.ts.map +1 -0
- package/dist/utils/routing.d.ts +18 -0
- package/dist/utils/routing.d.ts.map +1 -0
- package/dist/utils/swap.d.ts +45 -0
- package/dist/utils/swap.d.ts.map +1 -0
- package/dist/utils/wallets.d.ts +29 -0
- package/dist/utils/wallets.d.ts.map +1 -0
- package/dist/widget-embedded.cjs.development.js +3101 -0
- package/dist/widget-embedded.cjs.development.js.map +1 -0
- package/dist/widget-embedded.cjs.production.min.js +3101 -0
- package/dist/widget-embedded.cjs.production.min.js.map +1 -0
- package/dist/widget-embedded.esm.js +3092 -0
- package/dist/widget-embedded.esm.js.map +1 -0
- package/package.json +55 -0
- package/readme.md +2 -0
- package/src/App.tsx +91 -0
- package/src/QueueManager.tsx +94 -0
- package/src/app.css +27 -0
- package/src/components/AppRouter.tsx +60 -0
- package/src/components/AppRoutes.tsx +105 -0
- package/src/components/BottomLogo.tsx +47 -0
- package/src/components/ChangeSlippageButton.tsx +19 -0
- package/src/components/ConfirmSwapErrors.tsx +38 -0
- package/src/components/ConfirmSwapWarnings.tsx +35 -0
- package/src/components/Footer.tsx +8 -0
- package/src/components/Header.tsx +37 -0
- package/src/components/HeaderButtons.tsx +47 -0
- package/src/components/Layout.tsx +96 -0
- package/src/components/RoutesOverview.tsx +60 -0
- package/src/components/SwitchFromAndTo.tsx +30 -0
- package/src/components/TokenInfo.tsx +311 -0
- package/src/components/TokenPreview.tsx +175 -0
- package/src/components/UpdateUrl.tsx +162 -0
- package/src/components/warnings/BalanceWarnings.tsx +39 -0
- package/src/components/warnings/ConfirmSwapExtraMessages.tsx +20 -0
- package/src/components/warnings/HighSlippageWarning.tsx +18 -0
- package/src/components/warnings/MinRequiredSlippage.tsx +18 -0
- package/src/constants/errors.ts +3 -0
- package/src/constants/navigationRoutes.ts +14 -0
- package/src/constants/numbers.ts +3 -0
- package/src/constants/searchParams.ts +7 -0
- package/src/constants/swapSettings.ts +9 -0
- package/src/globalStyles.ts +26 -0
- package/src/hooks/useConfirmSwap.ts +260 -0
- package/src/hooks/useCopyToClipboard.ts +23 -0
- package/src/hooks/useNavigateBack.ts +40 -0
- package/src/hooks/usePrevious.ts +13 -0
- package/src/hooks/useSelectLanguage.ts +15 -0
- package/src/hooks/useTheme.ts +127 -0
- package/src/i18n.js +30 -0
- package/src/index.tsx +14 -0
- package/src/languages/en.json +14 -0
- package/src/languages/tr.json +11 -0
- package/src/lib.tsx +119 -0
- package/src/mockData/pendingSwap.ts +607 -0
- package/src/pages/ConfirmSwapPage.tsx +72 -0
- package/src/pages/ConfirmWalletsPage.tsx +127 -0
- package/src/pages/HistoryPage.tsx +29 -0
- package/src/pages/Home.tsx +228 -0
- package/src/pages/LiquiditySourcesPage.tsx +64 -0
- package/src/pages/SelectChainPage.tsx +42 -0
- package/src/pages/SelectTokenPage.tsx +64 -0
- package/src/pages/SettingsPage.tsx +98 -0
- package/src/pages/SwapDetailsPage.tsx +38 -0
- package/src/pages/WalletsPage.tsx +119 -0
- package/src/services/httpService.ts +5 -0
- package/src/store/bestRoute.ts +245 -0
- package/src/store/meta.ts +35 -0
- package/src/store/selectors.ts +19 -0
- package/src/store/settings.ts +84 -0
- package/src/store/ui.ts +21 -0
- package/src/store/wallets.ts +190 -0
- package/src/types/config.ts +44 -0
- package/src/types/index.ts +3 -0
- package/src/types/routing.ts +60 -0
- package/src/types/swap.ts +13 -0
- package/src/utils/common.ts +35 -0
- package/src/utils/numbers.ts +133 -0
- package/src/utils/queue.ts +24 -0
- package/src/utils/routing.ts +150 -0
- package/src/utils/swap.ts +552 -0
- package/src/utils/wallets.ts +481 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { createTheme } from '@rango-dev/ui';
|
|
2
|
+
import { useState, useEffect, useLayoutEffect } from 'react';
|
|
3
|
+
import { useMetaStore } from '../store/meta';
|
|
4
|
+
import { useSettingsStore } from '../store/settings';
|
|
5
|
+
import { Colors } from '../types';
|
|
6
|
+
import { shadeColor } from '../utils/common';
|
|
7
|
+
import usePrevious from './usePrevious';
|
|
8
|
+
|
|
9
|
+
export function useTheme({
|
|
10
|
+
primary = '#5FA425',
|
|
11
|
+
background = '#fff',
|
|
12
|
+
foreground = '#000',
|
|
13
|
+
error = '#FF0000',
|
|
14
|
+
warning = '#F5A623',
|
|
15
|
+
success = '#0070F3',
|
|
16
|
+
fontFamily = 'Robot',
|
|
17
|
+
borderRadius = 8,
|
|
18
|
+
}: Colors & { borderRadius?: number; fontFamily?: string }) {
|
|
19
|
+
const theme = useSettingsStore.use.theme();
|
|
20
|
+
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
21
|
+
const colors = {
|
|
22
|
+
neutrals200: '#FAFAFA',
|
|
23
|
+
neutrals300: '#f2f2f2',
|
|
24
|
+
neutrals400: '#dedede',
|
|
25
|
+
neutrals500: '#cccccc',
|
|
26
|
+
neutrals600: '#acacac',
|
|
27
|
+
neutrals700: '#444444',
|
|
28
|
+
neutrals800: '#333333',
|
|
29
|
+
neutrals900: '#111111',
|
|
30
|
+
primary,
|
|
31
|
+
primary100: shadeColor(primary, 15),
|
|
32
|
+
primary200: shadeColor(primary, -10),
|
|
33
|
+
primary300: shadeColor(primary, -15),
|
|
34
|
+
primary400: shadeColor(primary, -20),
|
|
35
|
+
primary500: shadeColor(primary, -25),
|
|
36
|
+
primary600: shadeColor(primary, -30),
|
|
37
|
+
primary700: shadeColor(primary, -35),
|
|
38
|
+
primary800: shadeColor(primary, -40),
|
|
39
|
+
primary900: shadeColor(primary, -45),
|
|
40
|
+
background,
|
|
41
|
+
foreground,
|
|
42
|
+
error,
|
|
43
|
+
error100: shadeColor(error, 50),
|
|
44
|
+
error300: shadeColor(error, -10),
|
|
45
|
+
error500: shadeColor(error, -20),
|
|
46
|
+
error700: shadeColor(error, -30),
|
|
47
|
+
warning,
|
|
48
|
+
warning100: shadeColor(warning, 50),
|
|
49
|
+
warning300: shadeColor(warning, -10),
|
|
50
|
+
warning500: shadeColor(warning, -20),
|
|
51
|
+
warning700: shadeColor(warning, -30),
|
|
52
|
+
success,
|
|
53
|
+
success100: shadeColor(success, 50),
|
|
54
|
+
success300: shadeColor(success, -10),
|
|
55
|
+
success500: shadeColor(success, -20),
|
|
56
|
+
success700: shadeColor(success, -30),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const customeLightTheme = createTheme({
|
|
60
|
+
colors,
|
|
61
|
+
radii: {
|
|
62
|
+
5: `${borderRadius}px`,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const customeDarkTheme = createTheme({
|
|
67
|
+
colors: {
|
|
68
|
+
...colors,
|
|
69
|
+
neutrals200: '#111111',
|
|
70
|
+
neutrals300: '#333333',
|
|
71
|
+
neutrals400: '#444444',
|
|
72
|
+
neutrals500: '#acacac',
|
|
73
|
+
neutrals600: '#cccccc',
|
|
74
|
+
neutrals700: '#dedede',
|
|
75
|
+
neutrals800: '#f2f2f2',
|
|
76
|
+
neutrals900: '#FAFAFA',
|
|
77
|
+
foreground: background,
|
|
78
|
+
background: foreground,
|
|
79
|
+
},
|
|
80
|
+
radii: {
|
|
81
|
+
5: `${borderRadius}px`,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
const [OSTheme, setOSTheme] = useState(customeLightTheme);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
(async () => {
|
|
87
|
+
await fetchMeta();
|
|
88
|
+
})();
|
|
89
|
+
|
|
90
|
+
const switchTheme = (event: MediaQueryListEvent) => {
|
|
91
|
+
if (event.matches) setOSTheme(customeDarkTheme);
|
|
92
|
+
else setOSTheme(customeLightTheme);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
if (
|
|
96
|
+
window.matchMedia &&
|
|
97
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
98
|
+
) {
|
|
99
|
+
setOSTheme(customeDarkTheme);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
window
|
|
103
|
+
.matchMedia('(prefers-color-scheme: dark)')
|
|
104
|
+
.addEventListener('change', switchTheme);
|
|
105
|
+
return () => {
|
|
106
|
+
window
|
|
107
|
+
.matchMedia('(prefers-color-scheme: dark)')
|
|
108
|
+
.removeEventListener('change', switchTheme);
|
|
109
|
+
};
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
112
|
+
const prevFont = usePrevious(fontFamily);
|
|
113
|
+
|
|
114
|
+
useLayoutEffect(() => {
|
|
115
|
+
const { classList } = document.body;
|
|
116
|
+
|
|
117
|
+
if (prevFont) classList.remove(`font_${prevFont.replace(/ /g, '')}`);
|
|
118
|
+
classList.add(`font_${fontFamily.replace(/ /g, '')}`);
|
|
119
|
+
}, [fontFamily]);
|
|
120
|
+
|
|
121
|
+
const getActiveTheme = () => {
|
|
122
|
+
if (theme === 'auto') return OSTheme;
|
|
123
|
+
else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return { activeTheme: getActiveTheme() };
|
|
127
|
+
}
|
package/src/i18n.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
4
|
+
import { App } from './App';
|
|
5
|
+
|
|
6
|
+
const container = document.getElementById('app')!;
|
|
7
|
+
const root = createRoot(container);
|
|
8
|
+
root.render(
|
|
9
|
+
<BrowserRouter>
|
|
10
|
+
<App />,
|
|
11
|
+
</BrowserRouter>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export { SwapBox } from './lib';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"swap": "SWAP",
|
|
3
|
+
"Connect Wallet": "Connect Wallet",
|
|
4
|
+
"Powered By": "Powered By",
|
|
5
|
+
"From": "You sell",
|
|
6
|
+
"To": "You receive",
|
|
7
|
+
"Balance": "Balance",
|
|
8
|
+
"Max": "Max",
|
|
9
|
+
"Chain": "Chain",
|
|
10
|
+
"Token": "Token",
|
|
11
|
+
"Source": "Source",
|
|
12
|
+
"Destination": "Destination",
|
|
13
|
+
"Select Wallet": "Connect Your Wallet"
|
|
14
|
+
}
|
package/src/lib.tsx
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { SwapContainer } from '@rango-dev/ui';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { AppRouter } from './components/AppRouter';
|
|
4
|
+
import { useMetaStore } from './store/meta';
|
|
5
|
+
import { Events, Provider } from '@rango-dev/wallets-core';
|
|
6
|
+
import { allProviders } from '@rango-dev/provider-all';
|
|
7
|
+
import { EventHandler } from '@rango-dev/wallets-core/dist/wallet';
|
|
8
|
+
import { Network } from '@rango-dev/wallets-shared';
|
|
9
|
+
import {
|
|
10
|
+
prepareAccountsForWalletStore,
|
|
11
|
+
walletAndSupportedChainsNames,
|
|
12
|
+
} from './utils/wallets';
|
|
13
|
+
import { useWalletsStore } from './store/wallets';
|
|
14
|
+
import { Layout } from './components/Layout';
|
|
15
|
+
import { globalFont, globalStyles } from './globalStyles';
|
|
16
|
+
import { useTheme } from './hooks/useTheme';
|
|
17
|
+
import { isEvmBlockchain } from 'rango-sdk';
|
|
18
|
+
import { Configs } from './types';
|
|
19
|
+
import { useSettingsStore } from './store/settings';
|
|
20
|
+
import useSelectLanguage from './hooks/useSelectLanguage';
|
|
21
|
+
import './i18n';
|
|
22
|
+
import QueueManager from './QueueManager';
|
|
23
|
+
|
|
24
|
+
export type WidgetProps = {
|
|
25
|
+
configs: Configs;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const SwapBox: React.FC<WidgetProps> = ({ configs }) => {
|
|
29
|
+
globalStyles();
|
|
30
|
+
globalFont(configs?.fontFamily || 'Roboto');
|
|
31
|
+
|
|
32
|
+
const { activeTheme } = useTheme({
|
|
33
|
+
...configs.colors,
|
|
34
|
+
borderRadius: configs?.borderRadius,
|
|
35
|
+
fontFamily: configs?.fontFamily,
|
|
36
|
+
});
|
|
37
|
+
const { blockchains } = useMetaStore.use.meta();
|
|
38
|
+
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
39
|
+
const connectWallet = useWalletsStore.use.connectWallet();
|
|
40
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
41
|
+
const { changeLanguage } = useSelectLanguage();
|
|
42
|
+
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
43
|
+
|
|
44
|
+
const evmBasedChainNames = blockchains
|
|
45
|
+
.filter(isEvmBlockchain)
|
|
46
|
+
.map((chain) => chain.name);
|
|
47
|
+
|
|
48
|
+
const onUpdateState: EventHandler = (
|
|
49
|
+
type,
|
|
50
|
+
event,
|
|
51
|
+
value,
|
|
52
|
+
_,
|
|
53
|
+
supportedChains
|
|
54
|
+
) => {
|
|
55
|
+
if (event === Events.ACCOUNTS) {
|
|
56
|
+
if (value) {
|
|
57
|
+
const supportedChainNames: Network[] | null =
|
|
58
|
+
walletAndSupportedChainsNames(supportedChains);
|
|
59
|
+
const data = prepareAccountsForWalletStore(
|
|
60
|
+
type,
|
|
61
|
+
value,
|
|
62
|
+
evmBasedChainNames,
|
|
63
|
+
supportedChainNames
|
|
64
|
+
);
|
|
65
|
+
connectWallet(data);
|
|
66
|
+
} else {
|
|
67
|
+
disconnectWallet(type);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
let providers = allProviders();
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (configs.theme !== 'auto') setTheme(configs.theme);
|
|
75
|
+
}, [configs.theme]);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const wallets = configs.wallets;
|
|
79
|
+
clearConnectedWallet();
|
|
80
|
+
providers =
|
|
81
|
+
wallets === 'all'
|
|
82
|
+
? allProviders()
|
|
83
|
+
: allProviders().filter((provider) => {
|
|
84
|
+
const type = provider.config.type;
|
|
85
|
+
return wallets.find((w) => w === type);
|
|
86
|
+
});
|
|
87
|
+
}, [configs?.wallets]);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
changeLanguage(configs?.languege);
|
|
91
|
+
}, [configs?.languege]);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Provider
|
|
95
|
+
allBlockChains={blockchains}
|
|
96
|
+
providers={providers}
|
|
97
|
+
onUpdateState={onUpdateState}
|
|
98
|
+
>
|
|
99
|
+
<div id="pageContainer" className={activeTheme}>
|
|
100
|
+
<QueueManager>
|
|
101
|
+
<SwapContainer
|
|
102
|
+
style={{
|
|
103
|
+
width: configs?.width || 'auto',
|
|
104
|
+
height: configs?.height || 'auto',
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<AppRouter
|
|
108
|
+
title={configs.title}
|
|
109
|
+
titleSize={configs.titleSize}
|
|
110
|
+
titleWeight={configs.titleWeight}
|
|
111
|
+
>
|
|
112
|
+
<Layout configs={configs} />
|
|
113
|
+
</AppRouter>
|
|
114
|
+
</SwapContainer>
|
|
115
|
+
</QueueManager>
|
|
116
|
+
</div>
|
|
117
|
+
</Provider>
|
|
118
|
+
);
|
|
119
|
+
};
|