@lifi/widget 1.15.0 → 1.16.1
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/App.js +21 -0
- package/AppProvider.d.ts +0 -4
- package/AppProvider.js +2 -10
- package/cjs/App.js +21 -0
- package/cjs/AppProvider.d.ts +0 -4
- package/cjs/AppProvider.js +3 -12
- package/cjs/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/cjs/components/ActiveSwaps/ActiveSwapItem.js +45 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/cjs/components/ActiveSwaps/ActiveSwaps.js +30 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +40 -0
- package/cjs/components/ActiveSwaps/index.d.ts +2 -0
- package/cjs/components/ActiveSwaps/index.js +18 -0
- package/cjs/components/AppContainer.js +2 -2
- package/cjs/components/Card/Card.d.ts +7 -4
- package/cjs/components/Card/Card.js +38 -28
- package/cjs/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/cjs/components/ChainSelect/ChainSelect.js +35 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/cjs/components/ChainSelect/ChainSelect.style.js +19 -0
- package/cjs/components/ChainSelect/index.d.ts +2 -0
- package/cjs/components/ChainSelect/index.js +18 -0
- package/cjs/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/cjs/components/ChainSelect/useChainSelect.js +33 -0
- package/cjs/components/Header/Header.js +1 -9
- package/cjs/components/Header/NavigationHeader.js +6 -11
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
- package/cjs/components/SelectChainAndToken.js +5 -5
- package/cjs/components/SendToWallet/SendToWallet.js +6 -6
- package/cjs/components/Step/CircularProgress.js +1 -1
- package/cjs/components/Step/CircularProgress.style.js +1 -1
- package/cjs/components/Step/StepProcess.js +1 -5
- package/cjs/components/Step/StepProcess.style.d.ts +1 -1
- package/cjs/components/Step/StepTimer.d.ts +1 -0
- package/cjs/components/Step/StepTimer.js +6 -6
- package/cjs/components/SwapButton/SwapButton.js +5 -12
- package/cjs/components/SwapButton/types.d.ts +2 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/cjs/components/TokenList/TokenList.js +6 -2
- package/cjs/config/theme.js +24 -23
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +2 -0
- package/cjs/hooks/index.js +2 -0
- package/cjs/hooks/useChains.d.ts +1 -97
- package/cjs/hooks/useChains.js +12 -19
- package/cjs/hooks/useFeaturedTokens.js +2 -2
- package/cjs/hooks/useGasSufficiency.js +6 -7
- package/cjs/hooks/useInitializer.js +6 -0
- package/cjs/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/cjs/{components/Step/utils.js → hooks/useProcessMessage.js} +16 -10
- package/cjs/hooks/useRouteExecution.d.ts +1 -1
- package/cjs/hooks/useRouteExecution.js +26 -35
- package/cjs/hooks/useSwapRoutes.js +10 -11
- package/cjs/hooks/useTokenBalances.js +4 -4
- package/cjs/hooks/useTokenSearch.js +3 -2
- package/cjs/hooks/useTokens.js +3 -2
- package/cjs/hooks/useTools.js +3 -2
- package/cjs/hooks/useWidgetEvents.d.ts +3 -0
- package/cjs/hooks/useWidgetEvents.js +13 -0
- package/cjs/i18n/en/translation.json +13 -8
- package/cjs/i18n/index.d.ts +10 -5
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +18 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -0
- package/cjs/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/cjs/{components/SwapsInProgress → pages/ActiveSwapsPage}/index.js +1 -1
- package/cjs/pages/MainPage/MainPage.js +2 -3
- package/cjs/pages/MainPage/MainSwapButton.js +3 -1
- package/cjs/pages/MainPage/SwapRoutes.js +4 -1
- package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.js +33 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.js +20 -0
- package/cjs/pages/SelectChainPage/index.d.ts +1 -0
- package/cjs/pages/SelectChainPage/index.js +17 -0
- package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +4 -4
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +3 -6
- package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +3 -5
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +5 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +25 -36
- package/cjs/pages/SwapPage/SwapPage.js +5 -1
- package/cjs/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/cjs/providers/SDKProvider/SDKProvider.js +27 -0
- package/cjs/providers/SDKProvider/index.d.ts +1 -0
- package/cjs/providers/SDKProvider/index.js +17 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +39 -11
- package/cjs/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/cjs/providers/TelemetryProvider/TelemetryProvider.js +11 -0
- package/cjs/providers/TelemetryProvider/index.d.ts +1 -0
- package/cjs/providers/TelemetryProvider/index.js +17 -0
- package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/cjs/providers/WalletProvider/WalletProvider.js +10 -3
- package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -16
- package/cjs/providers/index.d.ts +2 -0
- package/cjs/providers/index.js +2 -0
- package/cjs/stores/chains/index.d.ts +4 -0
- package/cjs/stores/chains/index.js +20 -0
- package/cjs/stores/chains/types.d.ts +8 -0
- package/cjs/stores/chains/types.js +2 -0
- package/cjs/stores/chains/useChainOrder.d.ts +1 -0
- package/cjs/stores/chains/useChainOrder.js +12 -0
- package/cjs/stores/chains/useChainOrderStore.d.ts +19 -0
- package/cjs/stores/chains/useChainOrderStore.js +42 -0
- package/cjs/stores/chains/useInitializeChainOrder.d.ts +1 -0
- package/cjs/stores/chains/useInitializeChainOrder.js +12 -0
- package/cjs/stores/route/index.d.ts +2 -1
- package/cjs/stores/route/index.js +2 -1
- package/cjs/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/cjs/stores/route/useExecutingRoutesIds.js +20 -0
- package/cjs/stores/route/useRouteStore.js +5 -4
- package/cjs/stores/route/utils.d.ts +4 -0
- package/cjs/stores/route/utils.js +21 -0
- package/cjs/stores/settings/useSettingsStore.js +5 -2
- package/cjs/types/events.d.ts +5 -0
- package/cjs/types/events.js +9 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/widget.d.ts +2 -1
- package/cjs/utils/colors.d.ts +1 -1
- package/cjs/utils/navigationRoutes.d.ts +5 -0
- package/cjs/utils/navigationRoutes.js +31 -4
- package/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/components/ActiveSwaps/ActiveSwapItem.js +41 -0
- package/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/components/ActiveSwaps/ActiveSwaps.js +26 -0
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/components/ActiveSwaps/ActiveSwaps.style.js +37 -0
- package/components/ActiveSwaps/index.d.ts +2 -0
- package/components/ActiveSwaps/index.js +2 -0
- package/components/AppContainer.js +1 -1
- package/components/Card/Card.d.ts +7 -4
- package/components/Card/Card.js +39 -29
- package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/components/ChainSelect/ChainSelect.js +31 -0
- package/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/components/ChainSelect/ChainSelect.style.js +16 -0
- package/components/ChainSelect/index.d.ts +2 -0
- package/components/ChainSelect/index.js +2 -0
- package/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/components/ChainSelect/useChainSelect.js +29 -0
- package/components/Header/Header.js +1 -9
- package/components/Header/NavigationHeader.js +6 -11
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.style.js +1 -0
- package/components/SelectChainAndToken.js +1 -1
- package/components/SendToWallet/SendToWallet.js +6 -6
- package/components/Step/CircularProgress.js +3 -3
- package/components/Step/CircularProgress.style.js +1 -1
- package/components/Step/StepProcess.js +2 -6
- package/components/Step/StepProcess.style.d.ts +1 -1
- package/components/Step/StepTimer.d.ts +1 -0
- package/components/Step/StepTimer.js +6 -6
- package/components/SwapButton/SwapButton.js +6 -13
- package/components/SwapButton/types.d.ts +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/components/TokenList/TokenList.js +6 -2
- package/config/theme.js +24 -23
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +2 -0
- package/hooks/useChains.d.ts +1 -97
- package/hooks/useChains.js +11 -18
- package/hooks/useFeaturedTokens.js +1 -1
- package/hooks/useGasSufficiency.js +1 -2
- package/hooks/useInitializer.js +6 -0
- package/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/{pages/SwapPage/utils.js → hooks/useProcessMessage.js} +15 -10
- package/hooks/useRouteExecution.d.ts +1 -1
- package/hooks/useRouteExecution.js +26 -35
- package/hooks/useSwapRoutes.js +3 -4
- package/hooks/useTokenBalances.js +3 -3
- package/hooks/useTokenSearch.js +3 -2
- package/hooks/useTokens.js +3 -2
- package/hooks/useTools.js +3 -2
- package/hooks/useWidgetEvents.d.ts +3 -0
- package/hooks/useWidgetEvents.js +6 -0
- package/i18n/en/translation.json +13 -8
- package/i18n/index.d.ts +10 -5
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +14 -13
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +14 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +17 -0
- package/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/pages/ActiveSwapsPage/index.js +1 -0
- package/pages/MainPage/MainPage.js +2 -3
- package/pages/MainPage/MainSwapButton.js +3 -1
- package/pages/MainPage/SwapRoutes.js +4 -1
- package/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/pages/SelectChainPage/SelectChainPage.js +29 -0
- package/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/pages/SelectChainPage/SelectChainPage.style.js +17 -0
- package/pages/SelectChainPage/index.d.ts +1 -0
- package/pages/SelectChainPage/index.js +1 -0
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/EnabledBridgesSelect.js +4 -7
- package/pages/SettingsPage/EnabledExchangesSelect.js +4 -6
- package/pages/SettingsPage/RoutePrioritySelect.js +5 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/pages/SwapPage/StatusBottomSheet.js +27 -38
- package/pages/SwapPage/SwapPage.js +5 -1
- package/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/providers/SDKProvider/SDKProvider.js +19 -0
- package/providers/SDKProvider/index.d.ts +1 -0
- package/providers/SDKProvider/index.js +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +39 -11
- package/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/providers/TelemetryProvider/TelemetryProvider.js +7 -0
- package/providers/TelemetryProvider/index.d.ts +1 -0
- package/providers/TelemetryProvider/index.js +1 -0
- package/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/providers/WalletProvider/WalletProvider.js +10 -3
- package/providers/WidgetProvider/WidgetProvider.js +3 -18
- package/providers/index.d.ts +2 -0
- package/providers/index.js +2 -0
- package/stores/chains/index.d.ts +4 -0
- package/stores/chains/index.js +4 -0
- package/stores/chains/types.d.ts +8 -0
- package/stores/chains/types.js +1 -0
- package/stores/chains/useChainOrder.d.ts +1 -0
- package/stores/chains/useChainOrder.js +5 -0
- package/stores/chains/useChainOrderStore.d.ts +19 -0
- package/stores/chains/useChainOrderStore.js +36 -0
- package/stores/chains/useInitializeChainOrder.d.ts +1 -0
- package/stores/chains/useInitializeChainOrder.js +5 -0
- package/stores/route/index.d.ts +2 -1
- package/stores/route/index.js +2 -1
- package/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/stores/route/useExecutingRoutesIds.js +13 -0
- package/stores/route/useRouteStore.js +5 -4
- package/stores/route/utils.d.ts +4 -0
- package/stores/route/utils.js +15 -0
- package/stores/settings/useSettingsStore.js +5 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +5 -0
- package/types/events.js +6 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/widget.d.ts +2 -1
- package/utils/colors.d.ts +1 -1
- package/utils/navigationRoutes.d.ts +5 -0
- package/utils/navigationRoutes.js +30 -3
- package/cjs/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/cjs/components/SwapButton/SwapButton.style.js +0 -15
- package/cjs/components/SwapsInProgress/SwapsInProgress.js +0 -29
- package/cjs/components/SwapsInProgress/SwapsInProgress.style.js +0 -17
- package/cjs/components/SwapsInProgress/index.d.ts +0 -1
- package/cjs/config/lifi.d.ts +0 -4
- package/cjs/config/lifi.js +0 -14
- package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -31
- package/cjs/pages/SwapPage/utils.d.ts +0 -6
- package/cjs/pages/SwapPage/utils.js +0 -93
- package/cjs/stores/route/useExecutingRoutes.d.ts +0 -2
- package/cjs/stores/route/useExecutingRoutes.js +0 -13
- package/components/Step/utils.js +0 -89
- package/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/components/SwapButton/SwapButton.style.js +0 -12
- package/components/SwapsInProgress/SwapsInProgress.js +0 -25
- package/components/SwapsInProgress/SwapsInProgress.style.js +0 -14
- package/components/SwapsInProgress/index.d.ts +0 -1
- package/components/SwapsInProgress/index.js +0 -1
- package/config/lifi.d.ts +0 -4
- package/config/lifi.js +0 -7
- package/pages/SelectTokenPage/ChainSelect.js +0 -27
- package/pages/SwapPage/utils.d.ts +0 -6
- package/stores/route/useExecutingRoutes.d.ts +0 -2
- package/stores/route/useExecutingRoutes.js +0 -6
|
@@ -14,17 +14,14 @@ const Select_1 = require("../../components/Select");
|
|
|
14
14
|
const hooks_1 = require("../../hooks");
|
|
15
15
|
const stores_1 = require("../../stores");
|
|
16
16
|
const EnabledBridgesSelect = () => {
|
|
17
|
-
var _a;
|
|
18
17
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
19
18
|
const { tools, formattedTools } = (0, hooks_1.useTools)();
|
|
20
19
|
const [enabledBridges, setTools] = (0, stores_1.useSettingsStore)((state) => [state.enabledBridges, state.setTools], shallow_1.default);
|
|
21
|
-
return (tools === null || tools === void 0 ? void 0 : tools.bridges.length) ? ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.enabledBridges`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledBridges`), MenuProps: { elevation: 2 }, IconComponent: icons_material_1.KeyboardArrowDown, value: enabledBridges !== null && enabledBridges !== void 0 ? enabledBridges : [], onChange: (event) => {
|
|
22
|
-
|
|
23
|
-
setTools('Bridges', event.target.value, tools.bridges);
|
|
24
|
-
}
|
|
20
|
+
return (tools === null || tools === void 0 ? void 0 : tools.bridges.length) ? ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.enabledBridges`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledBridges`), MenuProps: { elevation: 2, PaperProps: { sx: { maxHeight: 320 } } }, IconComponent: icons_material_1.KeyboardArrowDown, value: enabledBridges !== null && enabledBridges !== void 0 ? enabledBridges : [], onChange: (event) => {
|
|
21
|
+
setTools('Bridges', event.target.value, tools.bridges);
|
|
25
22
|
}, renderValue: (selected) => ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
|
|
26
23
|
var _a, _b, _c;
|
|
27
24
|
return ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: (_c = (_b = (_a = formattedTools.bridges) === null || _a === void 0 ? void 0 : _a[value]) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : value }, value));
|
|
28
|
-
}) }))) }, { children: (
|
|
25
|
+
}) }))) }, { children: tools.bridges.map((bridge) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: bridge.key, sx: { paddingTop: 0, paddingBottom: 0 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: enabledBridges === null || enabledBridges === void 0 ? void 0 : enabledBridges.includes(bridge.key) }), bridge.name] }), bridge.key))) })) }))] })) : ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: "100%", height: 134, sx: { borderRadius: 1 } }));
|
|
29
26
|
};
|
|
30
27
|
exports.EnabledBridgesSelect = EnabledBridgesSelect;
|
|
@@ -18,12 +18,10 @@ const EnabledExchangesSelect = () => {
|
|
|
18
18
|
const { tools, formattedTools } = (0, hooks_1.useTools)();
|
|
19
19
|
const [enabledExchanges, setTools] = (0, stores_1.useSettingsStore)((state) => [state.enabledExchanges, state.setTools], shallow_1.default);
|
|
20
20
|
return (tools === null || tools === void 0 ? void 0 : tools.exchanges.length) ? ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.enabledExchanges`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledExchanges`), value: enabledExchanges !== null && enabledExchanges !== void 0 ? enabledExchanges : [], onChange: (event) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
}, MenuProps: { elevation: 2 }, IconComponent: icons_material_1.KeyboardArrowDown, renderValue: (selected) => ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
|
|
21
|
+
setTools('Exchanges', event.target.value, tools.exchanges);
|
|
22
|
+
}, MenuProps: { elevation: 2, PaperProps: { sx: { maxHeight: 320 } } }, IconComponent: icons_material_1.KeyboardArrowDown, renderValue: (selected) => ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
|
|
25
23
|
var _a, _b, _c;
|
|
26
24
|
return ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: (_c = (_b = (_a = formattedTools.exchanges) === null || _a === void 0 ? void 0 : _a[value]) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : value }, value));
|
|
27
|
-
}) }))) }, { children: tools
|
|
25
|
+
}) }))) }, { children: tools.exchanges.map((exchange) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: exchange.key, sx: { paddingTop: 0, paddingBottom: 0 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: enabledExchanges === null || enabledExchanges === void 0 ? void 0 : enabledExchanges.includes(exchange.key) }), exchange.name] }), exchange.key))) })) }))] })) : ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: "100%", height: 206, sx: { borderRadius: 1 } }));
|
|
28
26
|
};
|
|
29
27
|
exports.EnabledExchangesSelect = EnabledExchangesSelect;
|
|
@@ -13,6 +13,10 @@ const RoutePrioritySelect = () => {
|
|
|
13
13
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
14
14
|
const [setValue] = (0, stores_1.useSetSettings)();
|
|
15
15
|
const { routePriority } = (0, stores_1.useSettings)(['routePriority']);
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.routePriority`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ MenuProps: { elevation: 2 }, value: routePriority, onChange: (event) => setValue('routePriority', event.target.value), IconComponent: icons_material_1.KeyboardArrowDown, dense: true }, { children: sdk_1.Orders.map((order) =>
|
|
16
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.routePriority`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ MenuProps: { elevation: 2 }, value: routePriority, onChange: (event) => setValue('routePriority', event.target.value), IconComponent: icons_material_1.KeyboardArrowDown, dense: true }, { children: sdk_1.Orders.map((order) => {
|
|
17
|
+
const tag = t(`swap.tags.${order.toUpperCase()}`);
|
|
18
|
+
const tagName = `${tag[0]}${tag.slice(1).toLowerCase()}`;
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: order }, { children: tagName }), order));
|
|
20
|
+
}) })) }))] }));
|
|
17
21
|
};
|
|
18
22
|
exports.RoutePrioritySelect = RoutePrioritySelect;
|
|
@@ -65,6 +65,6 @@ const SwapDetailsPage = () => {
|
|
|
65
65
|
}), (0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({ mt: 2 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
|
|
66
66
|
display: 'flex',
|
|
67
67
|
flex: 1,
|
|
68
|
-
} }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, Object.assign({ flex: 1 }, { children: t('swap.
|
|
68
|
+
} }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, Object.assign({ flex: 1 }, { children: t('swap.supportId') })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mr: 1, mt: 1 }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", onClick: copyRouteId }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, { fontSize: "small" }) })) }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' } }, { children: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('swap.warning.title.deleteSwap') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
|
|
69
69
|
};
|
|
70
70
|
exports.SwapDetailsPage = SwapDetailsPage;
|
|
@@ -12,9 +12,8 @@ const Token_1 = require("../../components/Token");
|
|
|
12
12
|
const hooks_1 = require("../../hooks");
|
|
13
13
|
const providers_1 = require("../../providers");
|
|
14
14
|
const StatusBottomSheet_style_1 = require("./StatusBottomSheet.style");
|
|
15
|
-
const utils_1 = require("./utils");
|
|
16
15
|
const StatusBottomSheet = ({ status, route, }) => {
|
|
17
|
-
var _a, _b, _c, _d, _e;
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
17
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
19
18
|
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
20
19
|
const ref = (0, react_1.useRef)(null);
|
|
@@ -34,41 +33,31 @@ const StatusBottomSheet = ({ status, route, }) => {
|
|
|
34
33
|
clearFromAmount();
|
|
35
34
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.closeDrawer();
|
|
36
35
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
const process = (_b = step === null || step === void 0 ? void 0 : step.execution) === null || _b === void 0 ? void 0 : _b.process.find((process) => process.status === 'FAILED');
|
|
55
|
-
if (!step || !process) {
|
|
56
|
-
return {};
|
|
57
|
-
}
|
|
58
|
-
return (0, utils_1.getProcessMessage)(t, getChainById, step, process);
|
|
36
|
+
let title;
|
|
37
|
+
let message;
|
|
38
|
+
switch (status) {
|
|
39
|
+
case 'success':
|
|
40
|
+
title = t('swap.success.title.fundsReceived');
|
|
41
|
+
message = t('swap.success.message.fundsReceived', {
|
|
42
|
+
amount: token === null || token === void 0 ? void 0 : token.amount,
|
|
43
|
+
tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
|
|
44
|
+
chainName: (_a = getChainById(route.toChainId)) === null || _a === void 0 ? void 0 : _a.name,
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
case 'error': {
|
|
48
|
+
const step = route.steps.find((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
|
|
49
|
+
const process = (_b = step === null || step === void 0 ? void 0 : step.execution) === null || _b === void 0 ? void 0 : _b.process.find((process) => process.status === 'FAILED');
|
|
50
|
+
if (!step || !process) {
|
|
51
|
+
break;
|
|
59
52
|
}
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
const processMessage = (0, hooks_1.getProcessMessage)(t, getChainById, step, process);
|
|
54
|
+
title = processMessage.title;
|
|
55
|
+
message = processMessage.message;
|
|
56
|
+
break;
|
|
62
57
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
route.toChainId,
|
|
67
|
-
status,
|
|
68
|
-
t,
|
|
69
|
-
token === null || token === void 0 ? void 0 : token.amount,
|
|
70
|
-
token === null || token === void 0 ? void 0 : token.symbol,
|
|
71
|
-
]);
|
|
58
|
+
default:
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
72
61
|
(0, react_1.useEffect)(() => {
|
|
73
62
|
var _a, _b;
|
|
74
63
|
if ((status === 'success' || status === 'error') &&
|
|
@@ -77,6 +66,6 @@ const StatusBottomSheet = ({ status, route, }) => {
|
|
|
77
66
|
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
|
|
78
67
|
}
|
|
79
68
|
}, [refetchBalance, status]);
|
|
80
|
-
return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3 }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "primary", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'success' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'error' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error", sx: StatusBottomSheet_style_1.iconStyles })) : null] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? ((0, jsx_runtime_1.jsx)(Token_1.Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3 }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "primary", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'success' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'error' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error", sx: StatusBottomSheet_style_1.iconStyles })) : null] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? ((0, jsx_runtime_1.jsx)(Token_1.Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_g = (_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : (_f = route.steps.at(-1)) === null || _f === void 0 ? void 0 : _f.estimate.toAmount) !== null && _g !== void 0 ? _g : route.toAmount }), py: 1 })) : null] }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Button, Object.assign({ variant: "contained", fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })) })), status === 'success' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleClose }, { children: t('button.seeDetails') })) }))) : null] })) })));
|
|
81
70
|
};
|
|
82
71
|
exports.StatusBottomSheet = StatusBottomSheet;
|
|
@@ -4,6 +4,7 @@ exports.SwapPage = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
7
8
|
const react_i18next_1 = require("react-i18next");
|
|
8
9
|
const react_router_dom_1 = require("react-router-dom");
|
|
9
10
|
const GasSufficiencyMessage_1 = require("../../components/GasSufficiencyMessage");
|
|
@@ -11,12 +12,14 @@ const Step_1 = require("../../components/Step");
|
|
|
11
12
|
const StepDivider_1 = require("../../components/StepDivider");
|
|
12
13
|
const SwapButton_1 = require("../../components/SwapButton");
|
|
13
14
|
const hooks_1 = require("../../hooks");
|
|
15
|
+
const providers_1 = require("../../providers");
|
|
14
16
|
const StatusBottomSheet_1 = require("./StatusBottomSheet");
|
|
15
17
|
const SwapPage_style_1 = require("./SwapPage.style");
|
|
16
18
|
const SwapPage = () => {
|
|
17
19
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
20
|
const { state } = (0, react_router_dom_1.useLocation)();
|
|
19
21
|
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
22
|
+
const { setValue, formState: { isValid, isValidating }, } = (0, react_hook_form_1.useFormContext)();
|
|
20
23
|
const { route, status, executeRoute, restartRoute, deleteRoute } = (0, hooks_1.useRouteExecution)(state === null || state === void 0 ? void 0 : state.routeId);
|
|
21
24
|
const handleRemoveRoute = () => {
|
|
22
25
|
navigateBack();
|
|
@@ -25,6 +28,7 @@ const SwapPage = () => {
|
|
|
25
28
|
const handleSwapClick = () => {
|
|
26
29
|
if (status === 'idle') {
|
|
27
30
|
executeRoute();
|
|
31
|
+
setValue(providers_1.SwapFormKey.FromAmount, '');
|
|
28
32
|
}
|
|
29
33
|
if (status === 'error') {
|
|
30
34
|
restartRoute();
|
|
@@ -44,6 +48,6 @@ const SwapPage = () => {
|
|
|
44
48
|
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Step_1.Step, { step: step, fromToken: index === 0
|
|
45
49
|
? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
|
|
46
50
|
? Object.assign(Object.assign({}, step.action.toToken), { amount: (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? ((0, jsx_runtime_1.jsx)(StepDivider_1.StepDivider, {})) : null] }, step.id));
|
|
47
|
-
}), status === 'idle' ? ((0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route }) }))) : null, status === 'error' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null] }));
|
|
51
|
+
}), status === 'idle' ? ((0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route, disable: status === 'idle' && (isValidating || !isValid) }) }))) : null, status === 'error' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null] }));
|
|
48
52
|
};
|
|
49
53
|
exports.SwapPage = SwapPage;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SDKProvider = exports.useLiFi = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const sdk_1 = __importDefault(require("@lifi/sdk"));
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const WidgetProvider_1 = require("../WidgetProvider");
|
|
11
|
+
let lifi;
|
|
12
|
+
const SDKContext = (0, react_1.createContext)(null);
|
|
13
|
+
const useLiFi = () => (0, react_1.useContext)(SDKContext);
|
|
14
|
+
exports.useLiFi = useLiFi;
|
|
15
|
+
const SDKProvider = ({ children, }) => {
|
|
16
|
+
const { sdkConfig, integrator } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
17
|
+
const value = (0, react_1.useMemo)(() => {
|
|
18
|
+
const config = Object.assign(Object.assign({}, sdkConfig), { defaultRouteOptions: Object.assign(Object.assign({}, sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.defaultRouteOptions), { integrator: integrator !== null && integrator !== void 0 ? integrator : window.location.hostname }) });
|
|
19
|
+
if (!lifi) {
|
|
20
|
+
lifi = new sdk_1.default(Object.assign({ disableVersionCheck: true }, config));
|
|
21
|
+
}
|
|
22
|
+
lifi.setConfig(config);
|
|
23
|
+
return lifi;
|
|
24
|
+
}, [integrator, sdkConfig]);
|
|
25
|
+
return (0, jsx_runtime_1.jsx)(SDKContext.Provider, Object.assign({ value: value }, { children: children }));
|
|
26
|
+
};
|
|
27
|
+
exports.SDKProvider = SDKProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SDKProvider';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./SDKProvider"), exports);
|
|
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const sdk_1 = require("@lifi/sdk");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const react_hook_form_1 = require("react-hook-form");
|
|
8
|
+
const chains_1 = require("../../stores/chains");
|
|
8
9
|
const WalletProvider_1 = require("../WalletProvider");
|
|
9
10
|
const WidgetProvider_1 = require("../WidgetProvider");
|
|
10
11
|
const types_1 = require("./types");
|
|
@@ -14,6 +15,7 @@ exports.formDefaultValues = {
|
|
|
14
15
|
[types_1.SwapFormKey.TokenSearchFilter]: '',
|
|
15
16
|
};
|
|
16
17
|
const SwapFormProvider = ({ children, }) => {
|
|
18
|
+
const [setChain] = (0, chains_1.useSetChainOrder)();
|
|
17
19
|
const { account } = (0, WalletProvider_1.useWallet)();
|
|
18
20
|
const { fromChain, fromToken, fromAmount, toChain, toToken, toAddress } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
19
21
|
const methods = (0, react_hook_form_1.useForm)({
|
|
@@ -27,25 +29,51 @@ const SwapFormProvider = ({ children, }) => {
|
|
|
27
29
|
if (!account.isActive || !account.chainId) {
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const [fromChainValue, toChainValue] = methods.getValues([
|
|
33
|
+
types_1.SwapFormKey.FromChain,
|
|
34
|
+
types_1.SwapFormKey.ToChain,
|
|
35
|
+
]);
|
|
36
|
+
const { isDirty: isFromChainDirty } = methods.getFieldState(types_1.SwapFormKey.FromChain, methods.formState);
|
|
37
|
+
const { isDirty: isToChainDirty } = methods.getFieldState(types_1.SwapFormKey.ToChain, methods.formState);
|
|
38
|
+
const { isDirty: isFromTokenDirty } = methods.getFieldState(types_1.SwapFormKey.FromToken, methods.formState);
|
|
39
|
+
const { isDirty: isToTokenDirty } = methods.getFieldState(types_1.SwapFormKey.ToToken, methods.formState);
|
|
40
|
+
// Users can switch chains in the wallet.
|
|
41
|
+
// If we don't have a chain in the ordered chain list we should add it.
|
|
42
|
+
setChain(account.chainId);
|
|
43
|
+
// If we ran out of slots for the ordered chain list and the current chain isn't there
|
|
44
|
+
// we should make a recently switched chain as current.
|
|
45
|
+
const { chainOrder } = chains_1.useChainOrderStore.getState();
|
|
46
|
+
const hasFromChainInOrderedList = chainOrder.includes(fromChainValue);
|
|
47
|
+
const hasToChainInOrderedList = chainOrder.includes(toChainValue);
|
|
48
|
+
if ((!fromChain && !isFromChainDirty && !isFromTokenDirty) ||
|
|
49
|
+
!hasFromChainInOrderedList) {
|
|
33
50
|
methods.setValue(types_1.SwapFormKey.FromChain, account.chainId, {
|
|
34
51
|
shouldDirty: false,
|
|
35
|
-
|
|
52
|
+
});
|
|
53
|
+
methods.setValue(types_1.SwapFormKey.FromToken, '', {
|
|
54
|
+
shouldDirty: false,
|
|
55
|
+
});
|
|
56
|
+
methods.setValue(types_1.SwapFormKey.FromAmount, '', {
|
|
57
|
+
shouldDirty: false,
|
|
36
58
|
});
|
|
37
59
|
}
|
|
38
|
-
if (!toChain &&
|
|
39
|
-
!
|
|
40
|
-
!isToChainTouched &&
|
|
41
|
-
!isFromChainDirty &&
|
|
42
|
-
!isFromChainTouched) {
|
|
60
|
+
if ((!toChain && !isToChainDirty && !isToTokenDirty) ||
|
|
61
|
+
!hasToChainInOrderedList) {
|
|
43
62
|
methods.setValue(types_1.SwapFormKey.ToChain, account.chainId, {
|
|
44
63
|
shouldDirty: false,
|
|
45
|
-
|
|
64
|
+
});
|
|
65
|
+
methods.setValue(types_1.SwapFormKey.ToToken, '', {
|
|
66
|
+
shouldDirty: false,
|
|
46
67
|
});
|
|
47
68
|
}
|
|
48
|
-
}, [
|
|
69
|
+
}, [
|
|
70
|
+
account.chainId,
|
|
71
|
+
account.isActive,
|
|
72
|
+
fromChain,
|
|
73
|
+
methods,
|
|
74
|
+
setChain,
|
|
75
|
+
toChain,
|
|
76
|
+
]);
|
|
49
77
|
return (0, jsx_runtime_1.jsx)(react_hook_form_1.FormProvider, Object.assign({}, methods, { children: children }));
|
|
50
78
|
};
|
|
51
79
|
exports.SwapFormProvider = SwapFormProvider;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TelemetryProvider = void 0;
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const hooks_1 = require("../../hooks");
|
|
6
|
+
const TelemetryProvider = ({ children }) => {
|
|
7
|
+
const config = (0, __1.useWidgetConfig)();
|
|
8
|
+
(0, hooks_1.useTelemetry)(config === null || config === void 0 ? void 0 : config.disableTelemetry);
|
|
9
|
+
return children;
|
|
10
|
+
};
|
|
11
|
+
exports.TelemetryProvider = TelemetryProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TelemetryProvider';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./TelemetryProvider"), exports);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { Signer } from 'ethers';
|
|
2
2
|
import type { FC, PropsWithChildren } from 'react';
|
|
3
|
-
import type { WidgetWalletManagement } from '../../types';
|
|
4
3
|
import type { WalletContextProps } from './types';
|
|
5
4
|
export declare const useWallet: () => WalletContextProps;
|
|
6
|
-
export declare const WalletProvider: FC<PropsWithChildren
|
|
7
|
-
walletManagement?: WidgetWalletManagement;
|
|
8
|
-
}>>;
|
|
5
|
+
export declare const WalletProvider: FC<PropsWithChildren>;
|
|
9
6
|
export declare const extractAccountFromSigner: (signer?: Signer) => Promise<{
|
|
10
7
|
address: string | undefined;
|
|
11
8
|
isActive: boolean;
|
|
@@ -13,6 +13,7 @@ exports.extractAccountFromSigner = exports.WalletProvider = exports.useWallet =
|
|
|
13
13
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
14
|
const wallet_management_1 = require("@lifi/wallet-management");
|
|
15
15
|
const react_1 = require("react");
|
|
16
|
+
const WidgetProvider_1 = require("../WidgetProvider");
|
|
16
17
|
const stub = () => {
|
|
17
18
|
throw new Error('You forgot to wrap your component in <WalletProvider>.');
|
|
18
19
|
};
|
|
@@ -27,7 +28,8 @@ const initialContext = {
|
|
|
27
28
|
const WalletContext = (0, react_1.createContext)(initialContext);
|
|
28
29
|
const useWallet = () => (0, react_1.useContext)(WalletContext);
|
|
29
30
|
exports.useWallet = useWallet;
|
|
30
|
-
const WalletProvider = ({ children
|
|
31
|
+
const WalletProvider = ({ children }) => {
|
|
32
|
+
const { walletManagement } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
31
33
|
const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, provider, } = (0, wallet_management_1.useLiFiWalletManagement)();
|
|
32
34
|
const [account, setAccount] = (0, react_1.useState)({});
|
|
33
35
|
const connect = (0, react_1.useCallback)((wallet) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -72,8 +74,13 @@ const WalletProvider = ({ children, walletManagement }) => {
|
|
|
72
74
|
// keep account information up to date
|
|
73
75
|
(0, react_1.useEffect)(() => {
|
|
74
76
|
const updateAccount = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
let account;
|
|
78
|
+
if (walletManagement) {
|
|
79
|
+
account = yield (0, exports.extractAccountFromSigner)(walletManagement === null || walletManagement === void 0 ? void 0 : walletManagement.signer);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
account = yield (0, exports.extractAccountFromSigner)(signer);
|
|
83
|
+
}
|
|
77
84
|
setAccount(account);
|
|
78
85
|
});
|
|
79
86
|
updateAccount();
|
|
@@ -15,11 +15,6 @@ exports.WidgetProvider = exports.useWidgetConfig = void 0;
|
|
|
15
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
const sdk_1 = require("@lifi/sdk");
|
|
17
17
|
const react_1 = require("react");
|
|
18
|
-
const lifi_1 = require("../../config/lifi");
|
|
19
|
-
const version_1 = require("../../config/version");
|
|
20
|
-
const stub = () => {
|
|
21
|
-
throw new Error('You forgot to wrap your component in <WidgetProvider>.');
|
|
22
|
-
};
|
|
23
18
|
const initialContext = {
|
|
24
19
|
disabledChains: [],
|
|
25
20
|
};
|
|
@@ -27,7 +22,7 @@ const WidgetContext = (0, react_1.createContext)(initialContext);
|
|
|
27
22
|
const useWidgetConfig = () => (0, react_1.useContext)(WidgetContext);
|
|
28
23
|
exports.useWidgetConfig = useWidgetConfig;
|
|
29
24
|
const WidgetProvider = (_a) => {
|
|
30
|
-
var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount
|
|
25
|
+
var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "fromAmount"]);
|
|
31
26
|
const value = (0, react_1.useMemo)(() => {
|
|
32
27
|
var _a, _b, _c, _d;
|
|
33
28
|
try {
|
|
@@ -57,16 +52,6 @@ const WidgetProvider = (_a) => {
|
|
|
57
52
|
return config;
|
|
58
53
|
}
|
|
59
54
|
}, [config, fromAmount, fromChain, fromToken, toChain, toToken]);
|
|
60
|
-
(0, react_1.useEffect)(() => {
|
|
61
|
-
(0, lifi_1.updateLiFiConfig)({
|
|
62
|
-
defaultRouteOptions: {
|
|
63
|
-
integrator: integrator !== null && integrator !== void 0 ? integrator : window.location.hostname,
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
}, [integrator]);
|
|
67
|
-
(0, react_1.useEffect)(() => {
|
|
68
|
-
(0, sdk_1.checkPackageUpdates)(version_1.name, version_1.version);
|
|
69
|
-
}, []);
|
|
70
55
|
return ((0, jsx_runtime_1.jsx)(WidgetContext.Provider, Object.assign({ value: value }, { children: children })));
|
|
71
56
|
};
|
|
72
57
|
exports.WidgetProvider = WidgetProvider;
|
package/cjs/providers/index.d.ts
CHANGED
package/cjs/providers/index.js
CHANGED
|
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./SDKProvider"), exports);
|
|
17
18
|
__exportStar(require("./SwapFormProvider"), exports);
|
|
19
|
+
__exportStar(require("./TelemetryProvider"), exports);
|
|
18
20
|
__exportStar(require("./ThemeProvider"), exports);
|
|
19
21
|
__exportStar(require("./WalletProvider"), exports);
|
|
20
22
|
__exportStar(require("./WidgetProvider"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./useChainOrder"), exports);
|
|
19
|
+
__exportStar(require("./useChainOrderStore"), exports);
|
|
20
|
+
__exportStar(require("./useInitializeChainOrder"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useChainOrder: () => [number[], (chainId: number) => void];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useChainOrder = void 0;
|
|
7
|
+
const shallow_1 = __importDefault(require("zustand/shallow"));
|
|
8
|
+
const useChainOrderStore_1 = require("./useChainOrderStore");
|
|
9
|
+
const useChainOrder = () => {
|
|
10
|
+
return (0, useChainOrderStore_1.useChainOrderStore)((state) => [state.chainOrder, state.setChain], shallow_1.default);
|
|
11
|
+
};
|
|
12
|
+
exports.useChainOrder = useChainOrder;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ChainOrderStore } from './types';
|
|
2
|
+
export declare const maxChainToOrder = 9;
|
|
3
|
+
export declare const useChainOrderStore: import("zustand").UseBoundStore<Omit<Omit<import("zustand").StoreApi<ChainOrderStore>, "persist"> & {
|
|
4
|
+
persist: {
|
|
5
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<ChainOrderStore, {
|
|
6
|
+
chainOrder: number[];
|
|
7
|
+
}>>) => void;
|
|
8
|
+
clearStorage: () => void;
|
|
9
|
+
rehydrate: () => Promise<void>;
|
|
10
|
+
hasHydrated: () => boolean;
|
|
11
|
+
onHydrate: (fn: (state: ChainOrderStore) => void) => () => void;
|
|
12
|
+
onFinishHydration: (fn: (state: ChainOrderStore) => void) => () => void;
|
|
13
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<ChainOrderStore, {
|
|
14
|
+
chainOrder: number[];
|
|
15
|
+
}>>;
|
|
16
|
+
};
|
|
17
|
+
}, "setState"> & {
|
|
18
|
+
setState(nextStateOrUpdater: ChainOrderStore | Partial<ChainOrderStore> | ((state: import("immer/dist/internal").WritableDraft<ChainOrderStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useChainOrderStore = exports.maxChainToOrder = void 0;
|
|
7
|
+
/* eslint-disable no-underscore-dangle */
|
|
8
|
+
const zustand_1 = __importDefault(require("zustand"));
|
|
9
|
+
const middleware_1 = require("zustand/middleware");
|
|
10
|
+
const immer_1 = require("zustand/middleware/immer");
|
|
11
|
+
exports.maxChainToOrder = 9;
|
|
12
|
+
exports.useChainOrderStore = (0, zustand_1.default)()((0, middleware_1.persist)((0, immer_1.immer)((set) => ({
|
|
13
|
+
chainOrder: [],
|
|
14
|
+
availableChains: [],
|
|
15
|
+
initializeChains: (chainIds) => set((state) => {
|
|
16
|
+
state.availableChains = chainIds;
|
|
17
|
+
state.chainOrder = state.chainOrder.filter((chainId) => chainIds.includes(chainId));
|
|
18
|
+
const chainsToAdd = chainIds.filter((chainId) => !state.chainOrder.includes(chainId));
|
|
19
|
+
if (state.chainOrder.length === exports.maxChainToOrder ||
|
|
20
|
+
!chainsToAdd.length) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const chainsToAddLength = exports.maxChainToOrder - state.chainOrder.length;
|
|
24
|
+
for (let index = 0; index < chainsToAddLength; index++) {
|
|
25
|
+
state.chainOrder.push(chainsToAdd[index]);
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
setChain: (chainId) => set((state) => {
|
|
29
|
+
if (state.chainOrder.includes(chainId) ||
|
|
30
|
+
!state.availableChains.includes(chainId)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
state.chainOrder.unshift(chainId);
|
|
34
|
+
if (state.chainOrder.length > exports.maxChainToOrder) {
|
|
35
|
+
state.chainOrder.pop();
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
})), {
|
|
39
|
+
name: 'li.fi-widget-chains-order',
|
|
40
|
+
version: 0,
|
|
41
|
+
partialize: (state) => ({ chainOrder: state.chainOrder }),
|
|
42
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useSetChainOrder: () => [(chainId: number) => void, (chainIds: number[]) => void];
|