@lifi/widget 1.14.1 → 1.16.0
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/cjs/App.js +21 -0
- package/cjs/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/cjs/components/ActiveSwaps/ActiveSwapItem.js +45 -0
- package/cjs/components/{SwapInProgress/SwapInProgress.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/Card/Card.d.ts +7 -4
- package/cjs/components/Card/Card.js +38 -28
- package/cjs/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.js +35 -0
- package/cjs/components/{SwapInProgress/SwapInProgress.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 +3 -11
- package/cjs/components/Header/NavigationHeader.js +10 -17
- package/cjs/components/Header/WalletHeader.js +4 -5
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +10 -10
- package/cjs/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +3 -3
- package/{components/SwapInProgress/SwapInProgress.d.ts → cjs/components/SendToWallet/SendToWallet.d.ts} +1 -1
- package/cjs/components/SendToWallet/SendToWallet.js +53 -0
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +19 -0
- package/cjs/components/SendToWallet/SendToWallet.style.js +15 -0
- package/cjs/components/SendToWallet/index.d.ts +1 -0
- package/cjs/components/{SwapInProgress → SendToWallet}/index.js +1 -1
- 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 +10 -14
- package/cjs/components/SwapButton/types.d.ts +2 -2
- package/cjs/components/SwapInput/FormPriceHelperText.d.ts +1 -1
- package/cjs/components/SwapInput/FormPriceHelperText.js +4 -4
- package/cjs/components/SwapInput/SwapInput.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInput.js +4 -4
- package/cjs/components/SwapInput/SwapInputAdornment.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.js +4 -4
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +5 -4
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
- package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/cjs/components/TokenList/TokenList.js +14 -11
- package/cjs/components/TokenList/types.d.ts +1 -1
- 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 +3 -0
- package/cjs/hooks/index.js +3 -0
- package/cjs/hooks/useChains.d.ts +1 -97
- package/cjs/hooks/useChains.js +8 -15
- package/cjs/hooks/useNavigateBack.d.ts +4 -0
- package/cjs/hooks/useNavigateBack.js +18 -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 +20 -29
- package/cjs/hooks/useSwapRoutes.js +18 -7
- package/cjs/hooks/useWidgetEvents.d.ts +3 -0
- package/cjs/hooks/useWidgetEvents.js +13 -0
- package/cjs/i18n/en/translation.json +25 -15
- package/cjs/i18n/index.d.ts +20 -10
- 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/pages/ActiveSwapsPage/index.js +17 -0
- package/cjs/pages/MainPage/MainPage.js +2 -2
- 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/SearchTokenInput.js +3 -3
- package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +4 -8
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +10 -10
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/cjs/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
- 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/SettingsPage/SettingsPage.js +2 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
- package/cjs/pages/SettingsPage/ShowDestinationWallet.js +22 -0
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -3
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/cjs/pages/SwapPage/StatusBottomSheet.js +29 -41
- package/cjs/pages/SwapPage/SwapPage.js +7 -3
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/cjs/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +43 -9
- package/cjs/providers/SwapFormProvider/types.d.ts +3 -1
- package/cjs/providers/SwapFormProvider/types.js +1 -0
- package/cjs/providers/WalletProvider/WalletProvider.js +10 -4
- package/cjs/providers/WalletProvider/types.d.ts +4 -2
- package/cjs/providers/WidgetProvider/WidgetProvider.js +3 -7
- package/cjs/providers/index.d.ts +4 -0
- package/cjs/providers/index.js +20 -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/types.d.ts +2 -1
- package/cjs/stores/settings/useSettingsStore.d.ts +4 -2
- package/cjs/stores/settings/useSettingsStore.js +6 -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 +3 -1
- package/cjs/utils/format.js +7 -2
- 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/ActiveSwaps/ActiveSwaps.d.ts +3 -0
- 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/Card/Card.d.ts +7 -4
- package/components/Card/Card.js +39 -29
- package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +1 -1
- package/components/ChainSelect/ChainSelect.js +31 -0
- package/components/{SwapInProgress/SwapInProgress.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 +2 -10
- package/components/Header/NavigationHeader.js +11 -18
- package/components/Header/WalletHeader.js +1 -2
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.style.js +1 -0
- package/components/ReverseTokensButton/ReverseTokensButton.js +1 -1
- package/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
- package/components/SelectTokenButton/SelectTokenButton.js +1 -1
- package/components/SendToWallet/SendToWallet.d.ts +3 -0
- package/components/SendToWallet/SendToWallet.js +49 -0
- package/components/SendToWallet/SendToWallet.style.d.ts +19 -0
- package/components/SendToWallet/SendToWallet.style.js +12 -0
- package/components/SendToWallet/index.d.ts +1 -0
- package/components/SendToWallet/index.js +1 -0
- 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 +7 -11
- package/components/SwapButton/types.d.ts +2 -2
- package/components/SwapInput/FormPriceHelperText.d.ts +1 -1
- package/components/SwapInput/FormPriceHelperText.js +1 -1
- package/components/SwapInput/SwapInput.d.ts +1 -1
- package/components/SwapInput/SwapInput.js +1 -1
- package/components/SwapInput/SwapInputAdornment.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.js +1 -1
- package/components/SwapRouteCard/SwapRouteCard.js +5 -4
- package/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
- package/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/components/TokenList/TokenList.js +7 -4
- package/components/TokenList/types.d.ts +1 -1
- package/config/theme.js +24 -23
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +3 -0
- package/hooks/index.js +3 -0
- package/hooks/useChains.d.ts +1 -97
- package/hooks/useChains.js +8 -15
- package/hooks/useNavigateBack.d.ts +4 -0
- package/hooks/useNavigateBack.js +14 -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 +21 -30
- package/hooks/useSwapRoutes.js +18 -7
- package/hooks/useWidgetEvents.d.ts +3 -0
- package/hooks/useWidgetEvents.js +6 -0
- package/i18n/en/translation.json +25 -15
- package/i18n/index.d.ts +20 -10
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +17 -19
- 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 -2
- 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/SearchTokenInput.js +1 -1
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/pages/SelectTokenPage/SelectTokenPage.js +5 -9
- package/pages/SelectWalletPage/SelectWalletPage.js +10 -10
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +1 -1
- 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/SettingsPage/SettingsPage.js +2 -1
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
- package/pages/SettingsPage/ShowDestinationWallet.js +18 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.js +5 -4
- package/pages/SwapHistoryPage/SwapHistoryPage.js +1 -1
- package/pages/SwapPage/StatusBottomSheet.js +30 -42
- package/pages/SwapPage/SwapPage.js +9 -5
- package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +43 -9
- package/providers/SwapFormProvider/types.d.ts +3 -1
- package/providers/SwapFormProvider/types.js +1 -0
- package/providers/WalletProvider/WalletProvider.js +10 -4
- package/providers/WalletProvider/types.d.ts +4 -2
- package/providers/WidgetProvider/WidgetProvider.js +3 -7
- package/providers/index.d.ts +4 -0
- package/providers/index.js +4 -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/types.d.ts +2 -1
- package/stores/settings/useSettingsStore.d.ts +4 -2
- package/stores/settings/useSettingsStore.js +6 -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 +3 -1
- package/utils/format.js +7 -2
- 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/SwapInProgress/SwapInProgress.js +0 -29
- package/cjs/components/SwapInProgress/SwapInProgress.style.js +0 -17
- package/cjs/components/SwapInProgress/index.d.ts +0 -1
- package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -32
- 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/SwapInProgress/SwapInProgress.js +0 -25
- package/components/SwapInProgress/SwapInProgress.style.js +0 -14
- package/components/SwapInProgress/index.d.ts +0 -1
- package/components/SwapInProgress/index.js +0 -1
- package/pages/SelectTokenPage/ChainSelect.js +0 -28
- package/pages/SwapPage/utils.d.ts +0 -6
- package/stores/route/useExecutingRoutes.d.ts +0 -2
- package/stores/route/useExecutingRoutes.js +0 -6
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useChainSelect = void 0;
|
|
4
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
5
|
+
const hooks_1 = require("../../hooks");
|
|
6
|
+
const providers_1 = require("../../providers");
|
|
7
|
+
const chains_1 = require("../../stores/chains");
|
|
8
|
+
const useChainSelect = (formType) => {
|
|
9
|
+
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
10
|
+
const { chains, isLoading } = (0, hooks_1.useChains)();
|
|
11
|
+
const [chainOrder, setChainOrder] = (0, chains_1.useChainOrder)();
|
|
12
|
+
const chainKey = providers_1.SwapFormKeyHelper.getChainKey(formType);
|
|
13
|
+
const getChains = () => {
|
|
14
|
+
if (!chains) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const selectedChains = chainOrder
|
|
18
|
+
.map((chainId) => chains.find((chain) => chain.id === chainId))
|
|
19
|
+
.filter((chain) => chain);
|
|
20
|
+
return selectedChains;
|
|
21
|
+
};
|
|
22
|
+
const setCurrentChain = (chainId) => {
|
|
23
|
+
setValue(chainKey, chainId, { shouldDirty: true });
|
|
24
|
+
setValue(providers_1.SwapFormKeyHelper.getTokenKey(formType), '', {
|
|
25
|
+
shouldDirty: false,
|
|
26
|
+
});
|
|
27
|
+
setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), '');
|
|
28
|
+
setValue(providers_1.SwapFormKey.TokenSearchFilter, '');
|
|
29
|
+
setChainOrder(chainId);
|
|
30
|
+
};
|
|
31
|
+
return { chains, getChains, setCurrentChain, isLoading };
|
|
32
|
+
};
|
|
33
|
+
exports.useChainSelect = useChainSelect;
|
|
@@ -3,25 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Header = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const
|
|
6
|
+
const providers_1 = require("../../providers");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
8
|
const Header_style_1 = require("./Header.style");
|
|
9
9
|
const NavigationHeader_1 = require("./NavigationHeader");
|
|
10
10
|
const WalletHeader_1 = require("./WalletHeader");
|
|
11
|
-
const stickyHeaderRoutes = [
|
|
12
|
-
utils_1.navigationRoutes.selectWallet,
|
|
13
|
-
utils_1.navigationRoutes.settings,
|
|
14
|
-
utils_1.navigationRoutes.swapRoutes,
|
|
15
|
-
utils_1.navigationRoutes.swapExecution,
|
|
16
|
-
utils_1.navigationRoutes.swapHistory,
|
|
17
|
-
utils_1.navigationRoutes.swapDetails,
|
|
18
|
-
];
|
|
19
11
|
const HeaderContainer = ({ children }) => {
|
|
20
12
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)(Header_style_1.Container, Object.assign({ id: utils_1.ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(Header_style_1.Container, Object.assign({ id: utils_1.ElementId.Header, sticky: utils_1.stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
22
14
|
};
|
|
23
15
|
const Header = () => {
|
|
24
|
-
const { walletManagement } = (0,
|
|
16
|
+
const { walletManagement } = (0, providers_1.useWidgetConfig)();
|
|
25
17
|
return ((0, jsx_runtime_1.jsxs)(HeaderContainer, { children: [!walletManagement ? (0, jsx_runtime_1.jsx)(WalletHeader_1.WalletHeader, {}) : null, (0, jsx_runtime_1.jsx)(NavigationHeader_1.NavigationHeader, {})] }));
|
|
26
18
|
};
|
|
27
19
|
exports.Header = Header;
|
|
@@ -6,31 +6,19 @@ const icons_material_1 = require("@mui/icons-material");
|
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const react_router_dom_1 = require("react-router-dom");
|
|
9
|
-
const
|
|
9
|
+
const hooks_1 = require("../../hooks");
|
|
10
|
+
const providers_1 = require("../../providers");
|
|
10
11
|
const utils_1 = require("../../utils");
|
|
11
12
|
const Header_style_1 = require("./Header.style");
|
|
12
13
|
const useHeaderActionStore_1 = require("./useHeaderActionStore");
|
|
13
|
-
const backButtonRoutes = [
|
|
14
|
-
utils_1.navigationRoutes.selectWallet,
|
|
15
|
-
utils_1.navigationRoutes.settings,
|
|
16
|
-
utils_1.navigationRoutes.swapHistory,
|
|
17
|
-
utils_1.navigationRoutes.fromToken,
|
|
18
|
-
utils_1.navigationRoutes.toToken,
|
|
19
|
-
utils_1.navigationRoutes.swapRoutes,
|
|
20
|
-
utils_1.navigationRoutes.swapExecution,
|
|
21
|
-
utils_1.navigationRoutes.swapDetails,
|
|
22
|
-
];
|
|
23
14
|
const NavigationHeader = () => {
|
|
24
15
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
25
|
-
const navigate = (0,
|
|
26
|
-
const { account } = (0,
|
|
16
|
+
const { navigate, navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
17
|
+
const { account } = (0, providers_1.useWallet)();
|
|
27
18
|
const { element } = (0, useHeaderActionStore_1.useHeaderActionStore)();
|
|
28
19
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
29
20
|
const path = pathname.substring(pathname.lastIndexOf('/') + 1);
|
|
30
21
|
const hasPath = utils_1.navigationRoutesValues.includes(path);
|
|
31
|
-
const handleBack = () => {
|
|
32
|
-
navigate(-1);
|
|
33
|
-
};
|
|
34
22
|
const handleHeaderTitle = () => {
|
|
35
23
|
switch (path) {
|
|
36
24
|
case utils_1.navigationRoutes.selectWallet:
|
|
@@ -43,8 +31,13 @@ const NavigationHeader = () => {
|
|
|
43
31
|
return t(`header.from`);
|
|
44
32
|
case utils_1.navigationRoutes.toToken:
|
|
45
33
|
return t(`header.to`);
|
|
34
|
+
case utils_1.navigationRoutes.fromChain:
|
|
35
|
+
case utils_1.navigationRoutes.toChain:
|
|
36
|
+
return t(`header.selectChain`);
|
|
46
37
|
case utils_1.navigationRoutes.swapRoutes:
|
|
47
38
|
return t(`header.routes`);
|
|
39
|
+
case utils_1.navigationRoutes.activeSwaps:
|
|
40
|
+
return t(`header.activeSwaps`);
|
|
48
41
|
case utils_1.navigationRoutes.swapExecution:
|
|
49
42
|
return t(`header.swap`);
|
|
50
43
|
case utils_1.navigationRoutes.swapDetails:
|
|
@@ -53,6 +46,6 @@ const NavigationHeader = () => {
|
|
|
53
46
|
return t(`header.swap`);
|
|
54
47
|
}
|
|
55
48
|
};
|
|
56
|
-
return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick:
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: navigateBack }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBack, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: utils_1.navigationRoutes.home, element: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [account.isActive ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "swap-history", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.History, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: () => navigate(utils_1.navigationRoutes.settings) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SettingsOutlined, {}) }))] }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "*", element: element || (0, jsx_runtime_1.jsx)(material_1.Box, { width: 28, height: 40 }) })] })] })));
|
|
57
50
|
};
|
|
58
51
|
exports.NavigationHeader = NavigationHeader;
|
|
@@ -15,13 +15,12 @@ const icons_material_1 = require("@mui/icons-material");
|
|
|
15
15
|
const material_1 = require("@mui/material");
|
|
16
16
|
const react_i18next_1 = require("react-i18next");
|
|
17
17
|
const react_router_dom_1 = require("react-router-dom");
|
|
18
|
-
const
|
|
19
|
-
const WidgetProvider_1 = require("../../providers/WidgetProvider");
|
|
18
|
+
const providers_1 = require("../../providers");
|
|
20
19
|
const utils_1 = require("../../utils");
|
|
21
20
|
const Header_style_1 = require("./Header.style");
|
|
22
21
|
const WalletHeader = () => {
|
|
23
22
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
24
|
-
const { account, disconnect } = (0,
|
|
23
|
+
const { account, disconnect } = (0, providers_1.useWallet)();
|
|
25
24
|
const walletAddress = account.address
|
|
26
25
|
? `${account.address.substring(0, 7)}...${account.address.substring(account.address.length - 7)}`
|
|
27
26
|
: null;
|
|
@@ -34,8 +33,8 @@ const WalletHeader = () => {
|
|
|
34
33
|
exports.WalletHeader = WalletHeader;
|
|
35
34
|
const ConnectButton = () => {
|
|
36
35
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
37
|
-
const config = (0,
|
|
38
|
-
const { connect: walletConnect } = (0,
|
|
36
|
+
const config = (0, providers_1.useWidgetConfig)();
|
|
37
|
+
const { connect: walletConnect } = (0, providers_1.useWallet)();
|
|
39
38
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
40
39
|
const connect = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
40
|
if (config.walletManagement) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const Link: import("@emotion/styled").StyledComponent<Omit<import("@mui/material").LinkBaseProps, "classes"> & {
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").LinkClasses> | undefined;
|
|
5
|
-
color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<
|
|
5
|
+
color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined> | ((theme: import("@mui/material").Theme) => import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined>);
|
|
6
6
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
7
7
|
TypographyClasses?: (Partial<import("@mui/material").TypographyClasses> & Partial<import("@mui/material").ClassNameMap<never>>) | undefined;
|
|
8
8
|
underline?: "none" | "always" | "hover" | undefined;
|
|
@@ -4,22 +4,22 @@ exports.ReverseTokensButton = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
|
-
const
|
|
7
|
+
const providers_1 = require("../../providers");
|
|
8
8
|
const ReverseTokensButton_style_1 = require("./ReverseTokensButton.style");
|
|
9
9
|
const ReverseTokensButton = ({ vertical, }) => {
|
|
10
10
|
const { setValue, getValues } = (0, react_hook_form_1.useFormContext)();
|
|
11
11
|
const handleClick = () => {
|
|
12
12
|
const [fromChain, fromToken, toChain, toToken] = getValues([
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
providers_1.SwapFormKey.FromChain,
|
|
14
|
+
providers_1.SwapFormKey.FromToken,
|
|
15
|
+
providers_1.SwapFormKey.ToChain,
|
|
16
|
+
providers_1.SwapFormKey.ToToken,
|
|
17
17
|
]);
|
|
18
|
-
setValue(
|
|
19
|
-
setValue(
|
|
20
|
-
setValue(
|
|
21
|
-
setValue(
|
|
22
|
-
setValue(
|
|
18
|
+
setValue(providers_1.SwapFormKey.FromAmount, '');
|
|
19
|
+
setValue(providers_1.SwapFormKey.FromChain, toChain);
|
|
20
|
+
setValue(providers_1.SwapFormKey.FromToken, toToken);
|
|
21
|
+
setValue(providers_1.SwapFormKey.ToChain, fromChain);
|
|
22
|
+
setValue(providers_1.SwapFormKey.ToToken, fromToken);
|
|
23
23
|
};
|
|
24
24
|
return ((0, jsx_runtime_1.jsx)(ReverseTokensButton_style_1.IconButton, Object.assign({ onClick: handleClick, size: "small", "aria-label": "swap-destinations" }, { children: vertical ? (0, jsx_runtime_1.jsx)(icons_material_1.SwapVert, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.SwapHoriz, {}) })));
|
|
25
25
|
};
|
|
@@ -8,7 +8,7 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
8
8
|
const react_i18next_1 = require("react-i18next");
|
|
9
9
|
const react_router_dom_1 = require("react-router-dom");
|
|
10
10
|
const hooks_1 = require("../../hooks");
|
|
11
|
-
const
|
|
11
|
+
const providers_1 = require("../../providers");
|
|
12
12
|
const utils_1 = require("../../utils");
|
|
13
13
|
const Card_1 = require("../Card");
|
|
14
14
|
const TokenAvatar_1 = require("../TokenAvatar");
|
|
@@ -18,8 +18,8 @@ const SelectTokenButton = ({ formType, compact }) => {
|
|
|
18
18
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
19
19
|
const [chainId, tokenAddress] = (0, react_hook_form_1.useWatch)({
|
|
20
20
|
name: [
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
providers_1.SwapFormKeyHelper.getChainKey(formType),
|
|
22
|
+
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
23
23
|
],
|
|
24
24
|
});
|
|
25
25
|
const { chain, isLoading: isChainLoading } = (0, hooks_1.useChain)(chainId);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SendToWallet = void 0;
|
|
13
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
+
const address_1 = require("@ethersproject/address");
|
|
15
|
+
const material_1 = require("@mui/material");
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
18
|
+
const react_i18next_1 = require("react-i18next");
|
|
19
|
+
const providers_1 = require("../../providers");
|
|
20
|
+
const stores_1 = require("../../stores");
|
|
21
|
+
const Card_1 = require("../Card");
|
|
22
|
+
const SendToWallet_style_1 = require("./SendToWallet.style");
|
|
23
|
+
const SendToWallet = (props) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
26
|
+
const { showDestinationWallet } = (0, stores_1.useSettings)(['showDestinationWallet']);
|
|
27
|
+
const { account, provider } = (0, providers_1.useWallet)();
|
|
28
|
+
const { register, trigger, formState: { errors }, } = (0, react_hook_form_1.useFormContext)();
|
|
29
|
+
(0, react_1.useEffect)(() => {
|
|
30
|
+
trigger(providers_1.SwapFormKey.ToAddress);
|
|
31
|
+
}, [account.chainId, trigger]);
|
|
32
|
+
if (!showDestinationWallet) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const { onChange, onBlur, name, ref } = register(providers_1.SwapFormKey.ToAddress, {
|
|
36
|
+
validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
try {
|
|
38
|
+
if (!value) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
const address = yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(value));
|
|
42
|
+
return ((0, address_1.isAddress)(address || value) ||
|
|
43
|
+
t('swap.error.title.walletAddressInvalid'));
|
|
44
|
+
}
|
|
45
|
+
catch (_b) {
|
|
46
|
+
return t('swap.error.title.walletEnsAddressInvalid');
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
onBlur: () => trigger(providers_1.SwapFormKey.ToAddress),
|
|
50
|
+
});
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.sendToWallet') }), (0, jsx_runtime_1.jsxs)(SendToWallet_style_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_style_1.Input, { ref: ref, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns') }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message }))] }))] })));
|
|
52
|
+
};
|
|
53
|
+
exports.SendToWallet = SendToWallet;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
classes?: Partial<import("@mui/material").FormControlClasses> | undefined;
|
|
5
|
+
color?: "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
|
|
6
|
+
disabled?: boolean | undefined;
|
|
7
|
+
error?: boolean | undefined;
|
|
8
|
+
fullWidth?: boolean | undefined;
|
|
9
|
+
focused?: boolean | undefined;
|
|
10
|
+
hiddenLabel?: boolean | undefined;
|
|
11
|
+
margin?: "none" | "normal" | "dense" | undefined;
|
|
12
|
+
required?: boolean | undefined;
|
|
13
|
+
size?: "small" | "medium" | undefined;
|
|
14
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
15
|
+
variant?: "outlined" | "filled" | "standard" | undefined;
|
|
16
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
17
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
18
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "color" | "children" | "disabled" | "sx" | "margin" | "fullWidth" | "size" | "variant" | "error" | "required" | "focused" | "hiddenLabel"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
19
|
+
export declare const Input: import("@emotion/styled").StyledComponent<import("@mui/material").InputBaseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Input = exports.FormControl = void 0;
|
|
4
|
+
const material_1 = require("@mui/material");
|
|
5
|
+
const InputBase_1 = require("@mui/material/InputBase");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
exports.FormControl = (0, styles_1.styled)(material_1.FormControl)(({ theme }) => ({
|
|
8
|
+
padding: theme.spacing(1.5, 2, 1.5, 0),
|
|
9
|
+
}));
|
|
10
|
+
exports.Input = (0, styles_1.styled)(material_1.InputBase)(({ theme }) => ({
|
|
11
|
+
[`.${InputBase_1.inputBaseClasses.input}`]: {
|
|
12
|
+
height: 32,
|
|
13
|
+
padding: theme.spacing(0, 0, 0, 2),
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SendToWallet';
|
|
@@ -14,4 +14,4 @@ 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("./
|
|
17
|
+
__exportStar(require("./SendToWallet"), exports);
|
|
@@ -10,7 +10,7 @@ function CircularProgress({ status }) {
|
|
|
10
10
|
display: 'grid',
|
|
11
11
|
position: 'relative',
|
|
12
12
|
placeItems: 'center',
|
|
13
|
-
} }, { children: [(0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgress, { variant: "determinate", status: status, size: 32, thickness: 3, value: 100 }), status === 'STARTED' || status === 'PENDING' ? ((0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgressPending, { size: 32, thickness: 3 })) : null, status === 'ACTION_REQUIRED' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "
|
|
13
|
+
} }, { children: [(0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgress, { variant: "determinate", status: status, size: 32, thickness: 3, value: 100 }), status === 'STARTED' || status === 'PENDING' ? ((0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgressPending, { size: 32, thickness: 3 })) : null, status === 'ACTION_REQUIRED' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "info", sx: {
|
|
14
14
|
position: 'absolute',
|
|
15
15
|
fontSize: '1rem',
|
|
16
16
|
} })) : null, status === 'DONE' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success", sx: {
|
|
@@ -21,7 +21,7 @@ const circleAnimation = (0, styles_1.keyframes)({
|
|
|
21
21
|
const getStatusColor = (status, theme) => {
|
|
22
22
|
switch (status) {
|
|
23
23
|
case 'ACTION_REQUIRED':
|
|
24
|
-
return theme.palette.
|
|
24
|
+
return theme.palette.info.main;
|
|
25
25
|
case 'DONE':
|
|
26
26
|
return theme.palette.success.main;
|
|
27
27
|
case 'FAILED':
|
|
@@ -4,15 +4,11 @@ exports.StepProcess = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
|
-
const react_i18next_1 = require("react-i18next");
|
|
8
7
|
const hooks_1 = require("../../hooks");
|
|
9
8
|
const CircularProgress_1 = require("./CircularProgress");
|
|
10
9
|
const StepProcess_style_1 = require("./StepProcess.style");
|
|
11
|
-
const utils_1 = require("./utils");
|
|
12
10
|
const StepProcess = ({ step, process }) => {
|
|
13
|
-
const {
|
|
14
|
-
const { getChainById } = (0, hooks_1.useChains)();
|
|
15
|
-
const { title, message } = (0, utils_1.getProcessMessage)(t, getChainById, step, process);
|
|
11
|
+
const { title, message } = (0, hooks_1.useProcessMessage)(step, process);
|
|
16
12
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ px: 2, py: 1 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
|
|
17
13
|
display: 'flex',
|
|
18
14
|
alignItems: 'center',
|
|
@@ -29,7 +29,7 @@ export declare const LinkButton: import("@emotion/styled").StyledComponent<{
|
|
|
29
29
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "size" | "edge"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & Omit<import("@mui/material").LinkBaseProps, "classes"> & {
|
|
30
30
|
children?: import("react").ReactNode;
|
|
31
31
|
classes?: Partial<import("@mui/material").LinkClasses> | undefined;
|
|
32
|
-
color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<
|
|
32
|
+
color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined> | ((theme: import("@mui/material").Theme) => import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined>);
|
|
33
33
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
34
34
|
TypographyClasses?: (Partial<import("@mui/material").TypographyClasses> & Partial<import("@mui/material").ClassNameMap<never>>) | undefined;
|
|
35
35
|
underline?: "none" | "always" | "hover" | undefined;
|
|
@@ -10,7 +10,7 @@ const getExpiryTimestamp = (step) => {
|
|
|
10
10
|
return new Date(((_c = (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.process[0]) === null || _b === void 0 ? void 0 : _b.startedAt) !== null && _c !== void 0 ? _c : Date.now()) +
|
|
11
11
|
step.estimate.executionDuration * 1000);
|
|
12
12
|
};
|
|
13
|
-
const StepTimer = ({ step }) => {
|
|
13
|
+
const StepTimer = ({ step, hideInProgress, }) => {
|
|
14
14
|
var _a, _b;
|
|
15
15
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
16
16
|
const [isExpired, setExpired] = (0, react_1.useState)(false);
|
|
@@ -29,9 +29,7 @@ const StepTimer = ({ step }) => {
|
|
|
29
29
|
setExecutionStarted(true);
|
|
30
30
|
restart(getExpiryTimestamp(step));
|
|
31
31
|
}
|
|
32
|
-
const shouldBePaused = step.execution.process.some((process) => process.status === 'ACTION_REQUIRED' ||
|
|
33
|
-
process.status === 'CHAIN_SWITCH_REQUIRED' ||
|
|
34
|
-
process.status === 'FAILED');
|
|
32
|
+
const shouldBePaused = step.execution.process.some((process) => process.status === 'ACTION_REQUIRED' || process.status === 'FAILED');
|
|
35
33
|
if (isRunning && shouldBePaused) {
|
|
36
34
|
pause();
|
|
37
35
|
}
|
|
@@ -53,11 +51,13 @@ const StepTimer = ({ step }) => {
|
|
|
53
51
|
value: (step.estimate.executionDuration / 60).toFixed(0),
|
|
54
52
|
}) }));
|
|
55
53
|
}
|
|
54
|
+
const isTimerExpired = isExpired || (!minutes && !seconds);
|
|
56
55
|
if (((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE' ||
|
|
57
|
-
((_b = step.execution) === null || _b === void 0 ? void 0 : _b.status) === 'FAILED'
|
|
56
|
+
((_b = step.execution) === null || _b === void 0 ? void 0 : _b.status) === 'FAILED' ||
|
|
57
|
+
(isTimerExpired && hideInProgress)) {
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
|
-
return
|
|
60
|
+
return isTimerExpired ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: t('swap.inProgress') })) : (
|
|
61
61
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
62
62
|
(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: `${minutes}:${seconds < 10 ? `0${seconds}` : seconds}` }));
|
|
63
63
|
};
|
|
@@ -12,25 +12,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.SwapButton = void 0;
|
|
13
13
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
14
|
const sdk_1 = require("@lifi/sdk");
|
|
15
|
+
const material_1 = require("@mui/material");
|
|
15
16
|
const react_hook_form_1 = require("react-hook-form");
|
|
16
17
|
const react_i18next_1 = require("react-i18next");
|
|
17
18
|
const react_router_dom_1 = require("react-router-dom");
|
|
18
19
|
const hooks_1 = require("../../hooks");
|
|
19
|
-
const
|
|
20
|
-
const WalletProvider_1 = require("../../providers/WalletProvider");
|
|
21
|
-
const WidgetProvider_1 = require("../../providers/WidgetProvider");
|
|
20
|
+
const providers_1 = require("../../providers");
|
|
22
21
|
const utils_1 = require("../../utils");
|
|
23
|
-
const
|
|
24
|
-
const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
22
|
+
const SwapButton = ({ onClick, currentRoute, text, disable, }) => {
|
|
25
23
|
var _a;
|
|
26
|
-
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
27
24
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
25
|
+
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
28
26
|
const { getChainById } = (0, hooks_1.useChains)();
|
|
29
|
-
const config = (0,
|
|
30
|
-
const { account, switchChain, connect: walletConnect } = (0,
|
|
27
|
+
const config = (0, providers_1.useWidgetConfig)();
|
|
28
|
+
const { account, switchChain, connect: walletConnect } = (0, providers_1.useWallet)();
|
|
31
29
|
const { insufficientFunds, insufficientGas } = (0, hooks_1.useGasSufficiency)(currentRoute);
|
|
32
30
|
const [chainId] = (0, react_hook_form_1.useWatch)({
|
|
33
|
-
name: [
|
|
31
|
+
name: [providers_1.SwapFormKeyHelper.getChainKey('from')],
|
|
34
32
|
});
|
|
35
33
|
// Allow switching chain only if execution is not started
|
|
36
34
|
const switchChainAllowed = ((_a = getChainById(chainId || sdk_1.ChainId.ETH)) === null || _a === void 0 ? void 0 : _a.id) !== account.chainId &&
|
|
@@ -65,10 +63,8 @@ const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
65
63
|
}
|
|
66
64
|
return t(`button.connectWallet`);
|
|
67
65
|
};
|
|
68
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
currentRoute &&
|
|
72
|
-
!switchChainAllowed, fullWidth: true }, { children: getButtonText() })));
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled: currentRoute &&
|
|
67
|
+
!switchChainAllowed &&
|
|
68
|
+
(insufficientFunds || !!insufficientGas.length || disable), fullWidth: true }, { children: getButtonText() })));
|
|
73
69
|
};
|
|
74
70
|
exports.SwapButton = SwapButton;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { SwapFormTypeProps } from '../../providers
|
|
2
|
+
import type { SwapFormTypeProps } from '../../providers';
|
|
3
3
|
export declare const FormPriceHelperText: React.FC<SwapFormTypeProps & {
|
|
4
4
|
selected: boolean;
|
|
5
5
|
}>;
|
|
@@ -6,15 +6,15 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
|
-
const
|
|
9
|
+
const providers_1 = require("../../providers");
|
|
10
10
|
const utils_1 = require("../../utils");
|
|
11
11
|
const FormPriceHelperText = ({ formType, selected }) => {
|
|
12
12
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
13
|
const [amount, chainId, tokenAddress] = (0, react_hook_form_1.useWatch)({
|
|
14
14
|
name: [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
providers_1.SwapFormKeyHelper.getAmountKey(formType),
|
|
16
|
+
providers_1.SwapFormKeyHelper.getChainKey(formType),
|
|
17
|
+
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
18
18
|
],
|
|
19
19
|
});
|
|
20
20
|
const { token, isLoading } = (0, hooks_1.useTokenBalance)(chainId, tokenAddress);
|
|
@@ -6,7 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
|
-
const
|
|
9
|
+
const providers_1 = require("../../providers");
|
|
10
10
|
const utils_1 = require("../../utils");
|
|
11
11
|
const Card_1 = require("../Card");
|
|
12
12
|
const TokenAvatar_1 = require("../TokenAvatar");
|
|
@@ -17,12 +17,12 @@ const SwapInput = ({ formType }) => {
|
|
|
17
17
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
18
|
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
19
19
|
const ref = (0, react_1.useRef)(null);
|
|
20
|
-
const amountKey =
|
|
20
|
+
const amountKey = providers_1.SwapFormKeyHelper.getAmountKey(formType);
|
|
21
21
|
const [amount, chainId, tokenAddress] = (0, react_hook_form_1.useWatch)({
|
|
22
22
|
name: [
|
|
23
23
|
amountKey,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
providers_1.SwapFormKeyHelper.getChainKey(formType),
|
|
25
|
+
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
26
26
|
],
|
|
27
27
|
});
|
|
28
28
|
const { chain } = (0, hooks_1.useChain)(chainId);
|
|
@@ -6,21 +6,21 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
|
-
const
|
|
9
|
+
const providers_1 = require("../../providers");
|
|
10
10
|
const SwapInputAdornment_style_1 = require("./SwapInputAdornment.style");
|
|
11
11
|
const SwapInputAdornment = ({ formType }) => {
|
|
12
12
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
13
|
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
14
14
|
const [chainId, tokenAddress] = (0, react_hook_form_1.useWatch)({
|
|
15
15
|
name: [
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
providers_1.SwapFormKeyHelper.getChainKey(formType),
|
|
17
|
+
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
18
18
|
],
|
|
19
19
|
});
|
|
20
20
|
const { token, isLoading } = (0, hooks_1.useTokenBalance)(chainId, tokenAddress);
|
|
21
21
|
const handleMax = () => {
|
|
22
22
|
var _a;
|
|
23
|
-
setValue(
|
|
23
|
+
setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), (_a = token === null || token === void 0 ? void 0 : token.amount) !== null && _a !== void 0 ? _a : '');
|
|
24
24
|
};
|
|
25
25
|
return ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: isLoading && tokenAddress ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 46, height: 20, sx: { borderRadius: 0.5 } })) : formType === 'from' && (token === null || token === void 0 ? void 0 : token.amount) ? ((0, jsx_runtime_1.jsx)(SwapInputAdornment_style_1.Button, Object.assign({ onClick: handleMax, variant: "outlined" }, { children: t('button.max') }))) : null })));
|
|
26
26
|
};
|