@lifi/widget 1.32.7 → 2.0.0-alpha.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 +3 -3
- package/AppDrawer.js +4 -3
- package/AppDrawer.style.d.ts +5 -5
- package/cjs/App.js +3 -3
- package/cjs/AppDrawer.js +4 -3
- package/cjs/AppDrawer.style.d.ts +5 -5
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +3 -3
- package/cjs/components/Card/CardIconButton.d.ts +29 -0
- package/cjs/components/Card/CardIconButton.js +17 -0
- package/cjs/components/Card/CardLabel.d.ts +26 -0
- package/cjs/components/Card/CardLabel.js +45 -0
- package/cjs/components/Card/CardTitle.d.ts +2 -2
- package/cjs/components/Card/index.d.ts +2 -0
- package/cjs/components/Card/index.js +2 -0
- package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -0
- package/cjs/components/GasMessage/FundsSufficiencyMessage.js +16 -0
- package/cjs/components/{GasSufficiencyMessage/GasSufficiencyMessage.d.ts → GasMessage/GasMessage.d.ts} +4 -2
- package/cjs/components/GasMessage/GasMessage.js +19 -0
- package/cjs/components/GasMessage/GasMessage.style.d.ts +34 -0
- package/cjs/components/GasMessage/GasMessage.style.js +48 -0
- package/cjs/components/GasMessage/GasRefuelMessage.d.ts +3 -0
- package/cjs/components/GasMessage/GasRefuelMessage.js +26 -0
- package/cjs/components/GasMessage/GasSufficiencyMessage.d.ts +7 -0
- package/cjs/components/GasMessage/GasSufficiencyMessage.js +21 -0
- package/cjs/components/GasMessage/index.d.ts +2 -0
- package/cjs/components/GasMessage/index.js +18 -0
- package/cjs/components/Header/Header.style.d.ts +5 -5
- package/cjs/components/Header/NavigationHeader.js +4 -4
- package/cjs/components/Header/WalletHeader.js +5 -5
- package/cjs/components/Insurance/Insurance.d.ts +3 -0
- package/cjs/components/Insurance/Insurance.js +11 -0
- package/cjs/components/Insurance/InsuranceCard.d.ts +3 -0
- package/cjs/components/Insurance/InsuranceCard.js +20 -0
- package/cjs/components/Insurance/InsuranceCollapsed.d.ts +3 -0
- package/cjs/components/Insurance/InsuranceCollapsed.js +32 -0
- package/cjs/components/Insurance/index.d.ts +1 -0
- package/cjs/components/{GasSufficiencyMessage → Insurance}/index.js +1 -1
- package/cjs/components/Insurance/types.d.ts +14 -0
- package/cjs/components/Insurance/types.js +2 -0
- package/cjs/components/NFT/NFT.style.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
- package/cjs/components/SendToWallet/SendToWallet.js +31 -25
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +2 -2
- package/cjs/components/SendToWallet/SendToWalletButton.js +3 -3
- package/cjs/components/SmallAvatar.d.ts +2 -2
- package/cjs/components/Step/CircularProgress.style.d.ts +1 -1
- package/cjs/components/Step/DestinationWalletAddress.js +2 -2
- package/cjs/components/Step/GasStepProcess.js +2 -2
- package/cjs/components/Step/Step.js +7 -5
- package/cjs/components/Step/StepList.d.ts +1 -1
- package/cjs/components/Step/StepProcess.style.d.ts +3 -3
- package/cjs/components/StepActions/StepActions.d.ts +5 -0
- package/cjs/components/StepActions/StepActions.js +55 -17
- package/cjs/components/StepActions/StepActions.style.d.ts +1 -1
- package/cjs/components/SwapButton/SwapButton.js +2 -2
- package/cjs/components/SwapButton/types.d.ts +1 -2
- package/cjs/components/SwapInput/SwapInput.style.d.ts +2 -2
- package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +3 -3
- package/cjs/components/SwapInput/SwapInputEndAdornment.js +18 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.d.ts +1 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +10 -26
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +4 -36
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +7 -38
- package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.d.ts +3 -0
- package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +27 -0
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +5 -5
- package/cjs/components/SwapRouteCard/types.d.ts +2 -2
- package/cjs/components/SwapRouteCard/utils.d.ts +5 -0
- package/cjs/components/SwapRouteCard/utils.js +32 -2
- package/cjs/components/SwapRoutes/SwapRoutes.js +3 -12
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +3 -5
- package/cjs/components/SwapRoutes/{SwapRoutes.style.d.ts → SwapRoutesExpanded.style.d.ts} +0 -9
- package/cjs/components/SwapRoutes/{SwapRoutes.style.js → SwapRoutesExpanded.style.js} +1 -12
- package/cjs/components/Switch.js +4 -4
- package/cjs/components/TextFitter/TextFitter.js +9 -3
- package/cjs/components/Token/Token.style.d.ts +2 -2
- package/cjs/config/theme.js +1 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +4 -0
- package/cjs/hooks/index.js +4 -0
- package/cjs/hooks/useChains.js +2 -2
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useFeaturedTokens.js +2 -2
- package/cjs/hooks/useFundsSufficiency.d.ts +5 -0
- package/cjs/hooks/useFundsSufficiency.js +73 -0
- package/cjs/hooks/useGasRecommendation.d.ts +2 -0
- package/cjs/hooks/useGasRecommendation.js +23 -0
- package/cjs/hooks/useGasRefuel.d.ts +7 -0
- package/cjs/hooks/useGasRefuel.js +61 -0
- package/cjs/hooks/useGasSufficiency.d.ts +2 -3
- package/cjs/hooks/useGasSufficiency.js +6 -37
- package/cjs/hooks/useGetTokenBalancesWithRetry.d.ts +3 -0
- package/cjs/hooks/useGetTokenBalancesWithRetry.js +33 -0
- package/cjs/hooks/useSwapRoutes.d.ts +7 -2
- package/cjs/hooks/useSwapRoutes.js +31 -11
- package/cjs/hooks/useTokenAddressBalance.js +4 -2
- package/cjs/hooks/useTokenBalance.js +4 -22
- package/cjs/hooks/useTokenBalances.d.ts +1 -1
- package/cjs/hooks/useTokenSearch.js +2 -2
- package/cjs/hooks/useTokens.js +2 -3
- package/cjs/i18n/en.json +14 -7
- package/cjs/i18n/it.json +6 -2
- package/cjs/i18n/pt.json +234 -0
- package/cjs/i18n/uk.json +5 -1
- package/cjs/icons/InsuraceLogo.d.ts +2 -0
- package/cjs/icons/InsuraceLogo.js +11 -0
- package/cjs/icons/index.d.ts +1 -0
- package/cjs/icons/index.js +1 -0
- package/cjs/index.d.ts +0 -6
- package/cjs/index.js +1 -6
- package/cjs/pages/MainPage/MainGasMessage.d.ts +3 -0
- package/cjs/pages/MainPage/MainGasMessage.js +12 -0
- package/cjs/pages/MainPage/MainPage.js +3 -2
- package/cjs/pages/MainPage/MainSwapButton.js +1 -1
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
- package/cjs/pages/SettingsPage/ResetSettingsButton.js +3 -1
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -3
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -2
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -14
- package/cjs/pages/SwapPage/StartSwapButton.d.ts +3 -2
- package/cjs/pages/SwapPage/StartSwapButton.js +14 -4
- package/cjs/pages/SwapPage/SwapPage.js +18 -7
- package/cjs/pages/SwapPage/types.d.ts +9 -0
- package/cjs/pages/SwapPage/types.js +2 -0
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/cjs/providers/SDKProvider/SDKProvider.d.ts +2 -2
- package/cjs/providers/SDKProvider/SDKProvider.js +2 -1
- package/cjs/providers/SwapFormProvider/FormUpdater.js +2 -3
- package/cjs/providers/WidgetProvider/WidgetProvider.js +17 -4
- package/cjs/providers/WidgetProvider/utils.d.ts +1 -1
- package/cjs/providers/WidgetProvider/utils.js +2 -4
- package/cjs/stores/StoreProvider.js +1 -1
- package/cjs/stores/routes/createRouteExecutionStore.js +3 -2
- package/cjs/stores/routes/index.d.ts +0 -1
- package/cjs/stores/routes/index.js +0 -1
- package/cjs/stores/routes/types.d.ts +1 -5
- package/cjs/stores/routes/useSetExecutableRoute.d.ts +1 -1
- package/cjs/stores/settings/types.d.ts +3 -2
- package/cjs/stores/settings/useSettingsStore.js +3 -1
- package/cjs/types/widget.d.ts +5 -10
- package/cjs/utils/format.js +4 -1
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +3 -3
- package/components/Card/CardIconButton.d.ts +29 -0
- package/components/Card/CardIconButton.js +14 -0
- package/components/Card/CardLabel.d.ts +26 -0
- package/components/Card/CardLabel.js +42 -0
- package/components/Card/CardTitle.d.ts +2 -2
- package/components/Card/index.d.ts +2 -0
- package/components/Card/index.js +2 -0
- package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -0
- package/components/GasMessage/FundsSufficiencyMessage.js +12 -0
- package/components/{GasSufficiencyMessage/GasSufficiencyMessage.d.ts → GasMessage/GasMessage.d.ts} +4 -2
- package/components/GasMessage/GasMessage.js +15 -0
- package/components/GasMessage/GasMessage.style.d.ts +34 -0
- package/components/GasMessage/GasMessage.style.js +45 -0
- package/components/GasMessage/GasRefuelMessage.d.ts +3 -0
- package/components/GasMessage/GasRefuelMessage.js +22 -0
- package/components/GasMessage/GasSufficiencyMessage.d.ts +7 -0
- package/components/GasMessage/GasSufficiencyMessage.js +17 -0
- package/components/GasMessage/index.d.ts +2 -0
- package/components/GasMessage/index.js +2 -0
- package/components/Header/Header.style.d.ts +5 -5
- package/components/Header/NavigationHeader.js +4 -4
- package/components/Header/WalletHeader.js +6 -6
- package/components/Insurance/Insurance.d.ts +3 -0
- package/components/Insurance/Insurance.js +7 -0
- package/components/Insurance/InsuranceCard.d.ts +3 -0
- package/components/Insurance/InsuranceCard.js +16 -0
- package/components/Insurance/InsuranceCollapsed.d.ts +3 -0
- package/components/Insurance/InsuranceCollapsed.js +28 -0
- package/components/Insurance/index.d.ts +1 -0
- package/components/Insurance/index.js +1 -0
- package/components/Insurance/types.d.ts +14 -0
- package/components/Insurance/types.js +1 -0
- package/components/NFT/NFT.style.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
- package/components/SendToWallet/SendToWallet.js +34 -28
- package/components/SendToWallet/SendToWallet.style.d.ts +2 -2
- package/components/SendToWallet/SendToWalletButton.js +4 -4
- package/components/SmallAvatar.d.ts +2 -2
- package/components/Step/CircularProgress.style.d.ts +1 -1
- package/components/Step/DestinationWalletAddress.js +2 -2
- package/components/Step/GasStepProcess.js +2 -2
- package/components/Step/Step.js +7 -5
- package/components/Step/StepList.d.ts +1 -1
- package/components/Step/StepProcess.style.d.ts +3 -3
- package/components/StepActions/StepActions.d.ts +5 -0
- package/components/StepActions/StepActions.js +52 -16
- package/components/StepActions/StepActions.style.d.ts +1 -1
- package/components/SwapButton/SwapButton.js +2 -2
- package/components/SwapButton/types.d.ts +1 -2
- package/components/SwapInput/SwapInput.style.d.ts +2 -2
- package/components/SwapInput/SwapInputAdornment.style.d.ts +3 -3
- package/components/SwapInput/SwapInputEndAdornment.js +19 -2
- package/components/SwapRouteCard/SwapRouteCard.d.ts +1 -2
- package/components/SwapRouteCard/SwapRouteCard.js +11 -26
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +4 -36
- package/components/SwapRouteCard/SwapRouteCard.style.js +7 -38
- package/components/SwapRouteCard/SwapRouteCardEssentials.d.ts +3 -0
- package/components/SwapRouteCard/SwapRouteCardEssentials.js +23 -0
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +5 -5
- package/components/SwapRouteCard/types.d.ts +2 -2
- package/components/SwapRouteCard/utils.d.ts +5 -0
- package/components/SwapRouteCard/utils.js +30 -1
- package/components/SwapRoutes/SwapRoutes.js +5 -14
- package/components/SwapRoutes/SwapRoutesExpanded.js +2 -4
- package/components/SwapRoutes/{SwapRoutes.style.d.ts → SwapRoutesExpanded.style.d.ts} +0 -9
- package/components/SwapRoutes/{SwapRoutes.style.js → SwapRoutesExpanded.style.js} +1 -12
- package/components/Switch.js +5 -5
- package/components/TextFitter/TextFitter.js +9 -3
- package/components/Token/Token.style.d.ts +2 -2
- package/config/theme.js +1 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +4 -0
- package/hooks/index.js +4 -0
- package/hooks/useChains.js +2 -2
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useFeaturedTokens.js +2 -2
- package/hooks/useFundsSufficiency.d.ts +5 -0
- package/hooks/useFundsSufficiency.js +69 -0
- package/hooks/useGasRecommendation.d.ts +2 -0
- package/hooks/useGasRecommendation.js +19 -0
- package/hooks/useGasRefuel.d.ts +7 -0
- package/hooks/useGasRefuel.js +57 -0
- package/hooks/useGasSufficiency.d.ts +2 -3
- package/hooks/useGasSufficiency.js +7 -38
- package/hooks/useGetTokenBalancesWithRetry.d.ts +3 -0
- package/hooks/useGetTokenBalancesWithRetry.js +29 -0
- package/hooks/useSwapRoutes.d.ts +7 -2
- package/hooks/useSwapRoutes.js +32 -12
- package/hooks/useTokenAddressBalance.js +4 -2
- package/hooks/useTokenBalance.js +5 -23
- package/hooks/useTokenBalances.d.ts +1 -1
- package/hooks/useTokenSearch.js +2 -2
- package/hooks/useTokens.js +2 -3
- package/i18n/en.json +14 -7
- package/i18n/it.json +6 -2
- package/i18n/pt.json +234 -0
- package/i18n/uk.json +5 -1
- package/icons/InsuraceLogo.d.ts +2 -0
- package/icons/InsuraceLogo.js +7 -0
- package/icons/index.d.ts +1 -0
- package/icons/index.js +1 -0
- package/index.d.ts +0 -6
- package/index.js +0 -5
- package/package.json +12 -11
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +2 -2
- package/pages/MainPage/MainGasMessage.d.ts +3 -0
- package/pages/MainPage/MainGasMessage.js +8 -0
- package/pages/MainPage/MainPage.js +3 -2
- package/pages/MainPage/MainSwapButton.js +1 -1
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
- package/pages/SettingsPage/ResetSettingsButton.js +3 -1
- package/pages/SettingsPage/RoutePrioritySelect.js +1 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +5 -4
- package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -2
- package/pages/SwapPage/ExchangeRateBottomSheet.js +0 -12
- package/pages/SwapPage/StartSwapButton.d.ts +3 -2
- package/pages/SwapPage/StartSwapButton.js +13 -4
- package/pages/SwapPage/SwapPage.js +21 -10
- package/pages/SwapPage/types.d.ts +9 -0
- package/pages/SwapPage/types.js +1 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/providers/SDKProvider/SDKProvider.d.ts +2 -2
- package/providers/SDKProvider/SDKProvider.js +3 -2
- package/providers/SwapFormProvider/FormUpdater.js +2 -3
- package/providers/WidgetProvider/WidgetProvider.js +17 -4
- package/providers/WidgetProvider/utils.d.ts +1 -1
- package/providers/WidgetProvider/utils.js +2 -4
- package/stores/StoreProvider.js +2 -2
- package/stores/routes/createRouteExecutionStore.js +3 -2
- package/stores/routes/index.d.ts +0 -1
- package/stores/routes/index.js +0 -1
- package/stores/routes/types.d.ts +1 -5
- package/stores/routes/useSetExecutableRoute.d.ts +1 -1
- package/stores/settings/types.d.ts +3 -2
- package/stores/settings/useSettingsStore.js +3 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +5 -10
- package/utils/format.js +4 -1
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +0 -31
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +0 -9
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.js +0 -14
- package/cjs/components/GasSufficiencyMessage/index.d.ts +0 -1
- package/cjs/components/SwapRoutes/useSetRecommendedRoute.d.ts +0 -2
- package/cjs/components/SwapRoutes/useSetRecommendedRoute.js +0 -13
- package/cjs/config/env.d.ts +0 -3
- package/cjs/config/env.js +0 -6
- package/cjs/stores/routes/useRecommendedRouteStore.d.ts +0 -10
- package/cjs/stores/routes/useRecommendedRouteStore.js +0 -39
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +0 -27
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +0 -9
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.js +0 -11
- package/components/GasSufficiencyMessage/index.d.ts +0 -1
- package/components/GasSufficiencyMessage/index.js +0 -1
- package/components/SwapRoutes/useSetRecommendedRoute.d.ts +0 -2
- package/components/SwapRoutes/useSetRecommendedRoute.js +0 -9
- package/config/env.d.ts +0 -3
- package/config/env.js +0 -3
- package/stores/routes/useRecommendedRouteStore.d.ts +0 -10
- package/stores/routes/useRecommendedRouteStore.js +0 -32
package/cjs/index.d.ts
CHANGED
|
@@ -7,9 +7,3 @@ export { useWidgetEvents, widgetEvents } from './hooks';
|
|
|
7
7
|
export { useWallet } from './providers/WalletProvider';
|
|
8
8
|
export * from './types';
|
|
9
9
|
export declare const LiFiWidget: import("react").FC<import("./types").WidgetProps>;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Use configuration { variant: 'drawer' } instead
|
|
12
|
-
*/
|
|
13
|
-
export declare const LiFiWidgetDrawer: import("react").ForwardRefExoticComponent<import("./types").WidgetDrawerProps & import("./types").WidgetConfig & {
|
|
14
|
-
config?: import("./types").WidgetConfig | undefined;
|
|
15
|
-
} & import("react").RefAttributes<import("./AppDrawer").WidgetDrawer>>;
|
package/cjs/index.js
CHANGED
|
@@ -14,9 +14,8 @@ 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
|
-
exports.
|
|
17
|
+
exports.LiFiWidget = exports.useWallet = exports.widgetEvents = exports.useWidgetEvents = void 0;
|
|
18
18
|
const App_1 = require("./App");
|
|
19
|
-
const AppDrawer_1 = require("./AppDrawer");
|
|
20
19
|
// TODO: remove or make optional
|
|
21
20
|
require("./fonts/inter.css");
|
|
22
21
|
__exportStar(require("./components/NFT"), exports);
|
|
@@ -31,7 +30,3 @@ __exportStar(require("./types"), exports);
|
|
|
31
30
|
// componentName.replace('Mui', 'LiFi'),
|
|
32
31
|
// );
|
|
33
32
|
exports.LiFiWidget = App_1.App;
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated Use configuration { variant: 'drawer' } instead
|
|
36
|
-
*/
|
|
37
|
-
exports.LiFiWidgetDrawer = AppDrawer_1.AppDrawer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MainGasMessage = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const GasMessage_1 = require("../../components/GasMessage");
|
|
6
|
+
const hooks_1 = require("../../hooks");
|
|
7
|
+
const MainGasMessage = (props) => {
|
|
8
|
+
const { routes } = (0, hooks_1.useSwapRoutes)();
|
|
9
|
+
const currentRoute = routes?.[0];
|
|
10
|
+
return (0, jsx_runtime_1.jsx)(GasMessage_1.GasMessage, { route: currentRoute, ...props });
|
|
11
|
+
};
|
|
12
|
+
exports.MainGasMessage = MainGasMessage;
|
|
@@ -5,19 +5,20 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const ActiveSwaps_1 = require("../../components/ActiveSwaps");
|
|
7
7
|
const ContractComponent_1 = require("../../components/ContractComponent");
|
|
8
|
-
const
|
|
8
|
+
const GasMessage_1 = require("../../components/GasMessage");
|
|
9
9
|
const SelectChainAndToken_1 = require("../../components/SelectChainAndToken");
|
|
10
10
|
const SendToWallet_1 = require("../../components/SendToWallet");
|
|
11
11
|
const SwapInput_1 = require("../../components/SwapInput");
|
|
12
12
|
const SwapRoutes_1 = require("../../components/SwapRoutes");
|
|
13
13
|
const hooks_1 = require("../../hooks");
|
|
14
14
|
const providers_1 = require("../../providers");
|
|
15
|
+
const MainGasMessage_1 = require("./MainGasMessage");
|
|
15
16
|
const MainPage_style_1 = require("./MainPage.style");
|
|
16
17
|
const MainSwapButton_1 = require("./MainSwapButton");
|
|
17
18
|
const MainPage = () => {
|
|
18
19
|
const expandable = (0, hooks_1.useExpandableVariant)();
|
|
19
20
|
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
20
21
|
const nft = variant === 'nft';
|
|
21
|
-
return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, { disableGutters: true, children: [(0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwaps, { mx: 3, mt: 1, mb:
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, { disableGutters: true, children: [(0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwaps, { mx: 3, mt: 1, mb: 1 }), nft ? (0, jsx_runtime_1.jsx)(ContractComponent_1.ContractComponent, { mx: 3, mt: 1, mb: 1 }) : null, (0, jsx_runtime_1.jsx)(SelectChainAndToken_1.SelectChainAndToken, { mt: 1, mx: 3, mb: 2 }), !nft ? (0, jsx_runtime_1.jsx)(SwapInput_1.SwapInput, { formType: "from", mx: 3, mb: 2 }) : null, !expandable ? (0, jsx_runtime_1.jsx)(SwapRoutes_1.SwapRoutes, { mx: 3, mb: 2 }) : null, (0, jsx_runtime_1.jsx)(GasMessage_1.GasRefuelMessage, { mx: 3, mb: 2 }), (0, jsx_runtime_1.jsx)(MainGasMessage_1.MainGasMessage, { mx: 3, mb: 2 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { mx: 3, mb: 1, children: [(0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWallet, { mb: 2 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(MainSwapButton_1.MainSwapButton, {}), (0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWalletButton, {})] })] })] }));
|
|
22
23
|
};
|
|
23
24
|
exports.MainPage = MainPage;
|
|
@@ -22,6 +22,6 @@ const MainSwapButton = () => {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { onClick: handleClick,
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { onClick: handleClick, hasRoute: Boolean(currentRoute), disabled: currentRoute && (isLoading || isFetching || isValidating || !isValid) }));
|
|
26
26
|
};
|
|
27
27
|
exports.MainSwapButton = MainSwapButton;
|
|
@@ -13,9 +13,9 @@ const types_1 = require("../../types");
|
|
|
13
13
|
const ColorSchemeButtonGroup_style_1 = require("./ColorSchemeButtonGroup.style");
|
|
14
14
|
const ColorSchemeButtonGroup = () => {
|
|
15
15
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
16
|
-
const {
|
|
16
|
+
const { hiddenUI } = (0, providers_1.useWidgetConfig)();
|
|
17
17
|
const [appearance, setAppearance] = (0, stores_1.useAppearance)();
|
|
18
|
-
if (
|
|
18
|
+
if (hiddenUI?.includes(types_1.HiddenUI.Appearance)) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, { pb: 2, children: (0, jsx_runtime_1.jsxs)(material_1.ToggleButtonGroup, { color: "primary", value: appearance, onChange: (_, value) => {
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
export declare const ToggleButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ToggleButtonClasses> | undefined;
|
|
5
|
-
color?: "success" | "warning" | "error" | "primary" | "secondary" | "info" | "standard" | undefined;
|
|
5
|
+
color?: import("@mui/types").OverridableStringUnion<"success" | "warning" | "error" | "primary" | "secondary" | "info" | "standard", import("@mui/material").ToggleButtonPropsColorOverrides> | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
fullWidth?: boolean | undefined;
|
|
9
9
|
onChange?: ((event: import("react").MouseEvent<HTMLElement, MouseEvent>, value: any) => void) | undefined;
|
|
10
10
|
onClick?: ((event: import("react").MouseEvent<HTMLElement, MouseEvent>, value: any) => void) | undefined;
|
|
11
11
|
selected?: boolean | undefined;
|
|
12
|
-
size?: "small" | "medium" | "large" | undefined;
|
|
12
|
+
size?: import("@mui/types").OverridableStringUnion<"small" | "medium" | "large", import("@mui/material").ToggleButtonPropsSizeOverrides> | undefined;
|
|
13
13
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
14
14
|
value: {};
|
|
15
15
|
} & Omit<{
|
|
@@ -7,10 +7,12 @@ const react_1 = require("react");
|
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const Dialog_1 = require("../../components/Dialog");
|
|
9
9
|
const hooks_1 = require("../../hooks");
|
|
10
|
+
const providers_1 = require("../../providers");
|
|
10
11
|
const stores_1 = require("../../stores");
|
|
11
12
|
const ResetSettingsButton = () => {
|
|
12
13
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
14
|
const { tools } = (0, hooks_1.useTools)();
|
|
15
|
+
const config = (0, providers_1.useWidgetConfig)();
|
|
14
16
|
const resetSettings = (0, stores_1.useSettingsStore)((state) => state.reset);
|
|
15
17
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
16
18
|
const toggleDialog = (0, react_1.useCallback)(() => {
|
|
@@ -18,7 +20,7 @@ const ResetSettingsButton = () => {
|
|
|
18
20
|
}, []);
|
|
19
21
|
const handleReset = () => {
|
|
20
22
|
if (tools) {
|
|
21
|
-
resetSettings(tools.bridges.map((tool) => tool.key), tools.exchanges.map((tool) => tool.key));
|
|
23
|
+
resetSettings(config, tools.bridges.map((tool) => tool.key), tools.exchanges.map((tool) => tool.key));
|
|
22
24
|
}
|
|
23
25
|
toggleDialog();
|
|
24
26
|
};
|
|
@@ -15,7 +15,7 @@ const RoutePrioritySelect = () => {
|
|
|
15
15
|
const { routePriority } = (0, stores_1.useSettings)(['routePriority']);
|
|
16
16
|
const value = routePriority ?? '';
|
|
17
17
|
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, { fullWidth: true, children: (0, jsx_runtime_1.jsx)(Select_1.Select, { MenuProps: { elevation: 2 }, value: value, onChange: (event) => setValue('routePriority', event.target.value), IconComponent: KeyboardArrowDown_1.default, dense: true, children: sdk_1.Orders.map((order) => {
|
|
18
|
-
const tag = t(`swap.tags.${order.
|
|
18
|
+
const tag = t(`swap.tags.${order.toLowerCase()}`);
|
|
19
19
|
const tagName = `${tag[0]}${tag.slice(1).toLowerCase()}`;
|
|
20
20
|
return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: order, children: tagName }, order));
|
|
21
21
|
}) }) })] }));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SwapDetailsPage = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
5
|
+
const ContentCopyRounded_1 = require("@mui/icons-material/ContentCopyRounded");
|
|
6
6
|
const DeleteOutline_1 = require("@mui/icons-material/DeleteOutline");
|
|
7
7
|
const material_1 = require("@mui/material");
|
|
8
8
|
const react_1 = require("react");
|
|
@@ -12,6 +12,7 @@ const shallow_1 = require("zustand/shallow");
|
|
|
12
12
|
const Card_1 = require("../../components/Card");
|
|
13
13
|
const Dialog_1 = require("../../components/Dialog");
|
|
14
14
|
const Header_1 = require("../../components/Header");
|
|
15
|
+
const Insurance_1 = require("../../components/Insurance");
|
|
15
16
|
const Step_1 = require("../../components/Step");
|
|
16
17
|
const hooks_1 = require("../../hooks");
|
|
17
18
|
const stores_1 = require("../../stores");
|
|
@@ -50,9 +51,9 @@ const SwapDetailsPage = () => {
|
|
|
50
51
|
justifyContent: 'space-between',
|
|
51
52
|
}, pb: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, children: new Intl.DateTimeFormat(i18n.language, { dateStyle: 'long' }).format(startedAt) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, children: new Intl.DateTimeFormat(i18n.language, {
|
|
52
53
|
timeStyle: 'short',
|
|
53
|
-
}).format(startedAt) })] }), (0, Step_1.getStepList)(routeExecution?.route), (0, jsx_runtime_1.jsxs)(Card_1.Card, { mt: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
54
|
+
}).format(startedAt) })] }), (0, Step_1.getStepList)(routeExecution?.route), routeExecution?.route?.insurance?.state === 'INSURED' ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: routeExecution.status, feeAmountUsd: routeExecution.route.insurance.feeAmountUsd, insurableRouteId: routeExecution.route.id })) : null, (0, jsx_runtime_1.jsxs)(Card_1.Card, { mt: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
54
55
|
display: 'flex',
|
|
55
56
|
flex: 1,
|
|
56
|
-
}, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { flex: 1, children: t('swap.supportId') }), (0, jsx_runtime_1.jsx)(material_1.Box, { mr: 1, mt: 1, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", onClick: copySupportId, children: (0, jsx_runtime_1.jsx)(
|
|
57
|
+
}, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { flex: 1, children: t('swap.supportId') }), (0, jsx_runtime_1.jsx)(material_1.Box, { mr: 1, mt: 1, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", onClick: copySupportId, children: (0, jsx_runtime_1.jsx)(ContentCopyRounded_1.default, { fontSize: "small" }) }) })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' }, children: supportId })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsx)(material_1.Button, { 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, { 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.deleteSwapHistory') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { onClick: toggleDialog, children: t('button.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: handleDeleteRoute, autoFocus: true, children: t('button.delete') })] })] })] }));
|
|
57
58
|
};
|
|
58
59
|
exports.SwapDetailsPage = SwapDetailsPage;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { ExchangeRateUpdateParams
|
|
2
|
+
import type { ExchangeRateUpdateParams } from '@lifi/sdk';
|
|
3
3
|
export interface ExchangeRateBottomSheetBase {
|
|
4
4
|
isOpen(): void;
|
|
5
5
|
open(resolver: (value: boolean) => void, data: ExchangeRateUpdateParams): void;
|
|
@@ -11,5 +11,4 @@ interface ExchangeRateBottomSheetProps {
|
|
|
11
11
|
onCancel?(): void;
|
|
12
12
|
}
|
|
13
13
|
export declare const ExchangeRateBottomSheet: import("react").ForwardRefExoticComponent<ExchangeRateBottomSheetProps & import("react").RefAttributes<ExchangeRateBottomSheetBase>>;
|
|
14
|
-
export declare const getTokenValueLossThreshold: (route?: Route) => boolean;
|
|
15
14
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ExchangeRateBottomSheet = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const WarningRounded_1 = require("@mui/icons-material/WarningRounded");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
@@ -58,16 +58,3 @@ const ExchangeRateBottomSheetContent = ({ data, onCancel, onContinue }) => {
|
|
|
58
58
|
.round(2, big_js_1.default.roundUp)
|
|
59
59
|
.toString(), "%"] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", mt: 3, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: onCancel, fullWidth: true, children: t('button.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", p: 1 }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: onContinue, fullWidth: true, children: t('button.continue') })] })] }));
|
|
60
60
|
};
|
|
61
|
-
const getTokenValueLossThreshold = (route) => {
|
|
62
|
-
if (!route) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
const fromAmountUSD = (0, big_js_1.default)(route?.fromAmountUSD || 0);
|
|
66
|
-
const toAmountUSD = (0, big_js_1.default)(route?.toAmountUSD || 0);
|
|
67
|
-
const gasCostUSD = (0, big_js_1.default)(route?.gasCostUSD || 0);
|
|
68
|
-
if (fromAmountUSD.eq(0) && toAmountUSD.eq(0)) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
return toAmountUSD.div(fromAmountUSD.plus(gasCostUSD)).lt(0.9);
|
|
72
|
-
};
|
|
73
|
-
exports.getTokenValueLossThreshold = getTokenValueLossThreshold;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
export declare const StartSwapButton: React.FC<
|
|
2
|
+
import type { StartSwapButtonProps } from './types';
|
|
3
|
+
export declare const StartSwapButton: React.FC<StartSwapButtonProps>;
|
|
4
|
+
export declare const StartIdleSwapButton: React.FC<StartSwapButtonProps>;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StartSwapButton = void 0;
|
|
3
|
+
exports.StartIdleSwapButton = exports.StartSwapButton = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const SwapButton_1 = require("../../components/SwapButton");
|
|
6
6
|
const hooks_1 = require("../../hooks");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const stores_1 = require("../../stores");
|
|
8
|
+
const StartSwapButton = ({ onClick, route, text, loading, }) => {
|
|
9
|
+
const { insufficientGas, isInitialLoading: isGasSufficiencyLoading } = (0, hooks_1.useGasSufficiency)(route);
|
|
10
|
+
const { insufficientFunds, isInitialLoading: isFundsSufficiencyLoading } = (0, hooks_1.useFundsSufficiency)(route);
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { onClick: onClick, text: text, hasRoute: Boolean(route), disabled: insufficientFunds || !!insufficientGas?.length, loading: isFundsSufficiencyLoading || isGasSufficiencyLoading || loading }));
|
|
10
12
|
};
|
|
11
13
|
exports.StartSwapButton = StartSwapButton;
|
|
14
|
+
const StartIdleSwapButton = ({ onClick, route, text, loading, disabled, insurableRouteId, }) => {
|
|
15
|
+
const routeExecution = (0, stores_1.useRouteExecutionStore)((state) => state.routes[insurableRouteId]);
|
|
16
|
+
const { isFetching } = (0, hooks_1.useSwapRoutes)({
|
|
17
|
+
insurableRoute: routeExecution?.route,
|
|
18
|
+
});
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(exports.StartSwapButton, { onClick: onClick, text: text, route: route, disabled: disabled, loading: loading || isFetching, insurableRouteId: insurableRouteId }));
|
|
20
|
+
};
|
|
21
|
+
exports.StartIdleSwapButton = StartIdleSwapButton;
|
|
@@ -8,7 +8,8 @@ const react_1 = require("react");
|
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
const react_i18next_1 = require("react-i18next");
|
|
10
10
|
const react_router_dom_1 = require("react-router-dom");
|
|
11
|
-
const
|
|
11
|
+
const GasMessage_1 = require("../../components/GasMessage");
|
|
12
|
+
const Insurance_1 = require("../../components/Insurance");
|
|
12
13
|
const Step_1 = require("../../components/Step");
|
|
13
14
|
const hooks_1 = require("../../hooks");
|
|
14
15
|
const providers_1 = require("../../providers");
|
|
@@ -20,14 +21,16 @@ const SwapPage_style_1 = require("./SwapPage.style");
|
|
|
20
21
|
const TokenValueBottomSheet_1 = require("./TokenValueBottomSheet");
|
|
21
22
|
const SwapPage = () => {
|
|
22
23
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
23
|
-
const {
|
|
24
|
-
const { state } = (0, react_router_dom_1.useLocation)();
|
|
24
|
+
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
25
25
|
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
26
|
+
const { variant, insurance } = (0, providers_1.useWidgetConfig)();
|
|
27
|
+
const { state } = (0, react_router_dom_1.useLocation)();
|
|
28
|
+
const stateRouteId = state?.routeId;
|
|
29
|
+
const [routeId, setRouteId] = (0, react_1.useState)(stateRouteId);
|
|
26
30
|
const tokenValueBottomSheetRef = (0, react_1.useRef)(null);
|
|
27
31
|
const exchangeRateBottomSheetRef = (0, react_1.useRef)(null);
|
|
28
|
-
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
29
32
|
const { route, status, executeRoute, restartRoute, deleteRoute } = (0, hooks_1.useRouteExecution)({
|
|
30
|
-
routeId:
|
|
33
|
+
routeId: routeId,
|
|
31
34
|
onAcceptExchangeRateUpdate: exchangeRateBottomSheetRef.current?.open,
|
|
32
35
|
});
|
|
33
36
|
const handleExecuteRoute = (0, react_1.useCallback)(() => {
|
|
@@ -67,8 +70,16 @@ const SwapPage = () => {
|
|
|
67
70
|
return '';
|
|
68
71
|
}
|
|
69
72
|
};
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
const SwapButton = insurance && status === stores_1.RouteExecutionStatus.Idle
|
|
74
|
+
? StartSwapButton_1.StartIdleSwapButton
|
|
75
|
+
: StartSwapButton_1.StartSwapButton;
|
|
76
|
+
const insuranceAvailable = insurance &&
|
|
77
|
+
variant !== 'refuel' &&
|
|
78
|
+
(route?.insurance?.state === 'INSURED' ||
|
|
79
|
+
(status === stores_1.RouteExecutionStatus.Idle &&
|
|
80
|
+
route?.insurance?.state === 'INSURABLE'));
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)(SwapPage_style_1.Container, { children: [(0, Step_1.getStepList)(route), insuranceAvailable ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: status, insurableRouteId: stateRouteId, feeAmountUsd: route?.insurance.feeAmountUsd, onChange: setRouteId })) : null, status === stores_1.RouteExecutionStatus.Idle ||
|
|
82
|
+
status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GasMessage_1.GasMessage, { mt: 2, route: route }), (0, jsx_runtime_1.jsxs)(material_1.Box, { mt: 2, display: "flex", children: [(0, jsx_runtime_1.jsx)(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, route: route, insurableRouteId: stateRouteId }), status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: handleRemoveRoute, sx: {
|
|
72
83
|
minWidth: 48,
|
|
73
84
|
marginLeft: 1,
|
|
74
85
|
}, children: (0, jsx_runtime_1.jsx)(Delete_1.default, {}) }) })) : null] })] })) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null, route ? ((0, jsx_runtime_1.jsx)(TokenValueBottomSheet_1.TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null, route ? ((0, jsx_runtime_1.jsx)(ExchangeRateBottomSheet_1.ExchangeRateBottomSheet, { ref: exchangeRateBottomSheetRef })) : null] }));
|
|
@@ -33,6 +33,6 @@ const SwapRoutesPage = () => {
|
|
|
33
33
|
.setAction((0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
|
|
34
34
|
}, [dataUpdatedAt, isFetching, refetch, refetchTime]);
|
|
35
35
|
const routeNotFound = !swapRoutes?.length && !isLoading && !isFetching;
|
|
36
|
-
return ((0, jsx_runtime_1.jsx)(SwapRoutesPage_style_1.Stack, { direction: "column", spacing: 2, flex: 1, children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, {}, index)))) : (swapRoutes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0 }, route.id)))) }));
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(SwapRoutesPage_style_1.Stack, { direction: "column", spacing: 2, flex: 1, children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, {}, index)))) : (swapRoutes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: swapRoutes?.length <= 2 }, route.id)))) }));
|
|
37
37
|
};
|
|
38
38
|
exports.SwapRoutesPage = SwapRoutesPage;
|
|
@@ -14,6 +14,7 @@ const SDKProvider = ({ children, }) => {
|
|
|
14
14
|
const value = (0, react_1.useMemo)(() => {
|
|
15
15
|
const config = {
|
|
16
16
|
...sdkConfig,
|
|
17
|
+
integrator: integrator ?? window.location.hostname,
|
|
17
18
|
defaultRouteOptions: {
|
|
18
19
|
fee,
|
|
19
20
|
integrator: integrator ?? window.location.hostname,
|
|
@@ -24,7 +25,7 @@ const SDKProvider = ({ children, }) => {
|
|
|
24
25
|
},
|
|
25
26
|
};
|
|
26
27
|
if (!lifi) {
|
|
27
|
-
lifi = new sdk_1.
|
|
28
|
+
lifi = new sdk_1.LiFi({
|
|
28
29
|
disableVersionCheck: true,
|
|
29
30
|
...config,
|
|
30
31
|
});
|
|
@@ -8,7 +8,7 @@ const SwapFormProvider_1 = require("../SwapFormProvider");
|
|
|
8
8
|
const WalletProvider_1 = require("../WalletProvider");
|
|
9
9
|
const WidgetProvider_1 = require("../WidgetProvider");
|
|
10
10
|
const FormUpdater = ({ defaultValues }) => {
|
|
11
|
-
const { fromChain, toChain, chains
|
|
11
|
+
const { fromChain, toChain, chains } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
12
12
|
const { account } = (0, WalletProvider_1.useWallet)();
|
|
13
13
|
const { setValue, getValues, getFieldState, resetField,
|
|
14
14
|
// Subscription to touchedFields is required by getFieldState to work
|
|
@@ -16,7 +16,7 @@ const FormUpdater = ({ defaultValues }) => {
|
|
|
16
16
|
const previousDefaultValues = (0, react_1.useRef)(defaultValues);
|
|
17
17
|
// Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
|
|
18
18
|
(0, react_1.useEffect)(() => {
|
|
19
|
-
const chainAllowed = account.chainId && (0, WidgetProvider_1.isItemAllowed)(account.chainId, chains
|
|
19
|
+
const chainAllowed = account.chainId && (0, WidgetProvider_1.isItemAllowed)(account.chainId, chains);
|
|
20
20
|
if (!account.isActive || !account.chainId || !chainAllowed) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -40,7 +40,6 @@ const FormUpdater = ({ defaultValues }) => {
|
|
|
40
40
|
account.chainId,
|
|
41
41
|
account.isActive,
|
|
42
42
|
chains,
|
|
43
|
-
disabledChains,
|
|
44
43
|
fromChain,
|
|
45
44
|
getFieldState,
|
|
46
45
|
getValues,
|
|
@@ -7,14 +7,17 @@ const react_1 = require("react");
|
|
|
7
7
|
const stores_1 = require("../../stores");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
9
|
const initialContext = {
|
|
10
|
-
disabledChains: [],
|
|
11
10
|
elementId: '',
|
|
11
|
+
integrator: '',
|
|
12
12
|
};
|
|
13
13
|
const WidgetContext = (0, react_1.createContext)(initialContext);
|
|
14
14
|
const useWidgetConfig = () => (0, react_1.useContext)(WidgetContext);
|
|
15
15
|
exports.useWidgetConfig = useWidgetConfig;
|
|
16
|
-
const WidgetProvider = ({ children, config: { fromChain, fromToken, toChain, toToken, fromAmount, ...config } = {}, }) => {
|
|
16
|
+
const WidgetProvider = ({ children, config: { fromChain, fromToken, toChain, toToken, fromAmount, integrator, ...config } = {}, }) => {
|
|
17
17
|
const elementId = (0, react_1.useId)();
|
|
18
|
+
if (!integrator) {
|
|
19
|
+
throw Error('Required property "integrator" is missing.');
|
|
20
|
+
}
|
|
18
21
|
const value = (0, react_1.useMemo)(() => {
|
|
19
22
|
try {
|
|
20
23
|
const searchParams = Object.fromEntries(new URLSearchParams(window?.location.search));
|
|
@@ -50,15 +53,25 @@ const WidgetProvider = ({ children, config: { fromChain, fromToken, toChain, toT
|
|
|
50
53
|
? (0, utils_1.formatAmount)(searchParams.fromAmount)
|
|
51
54
|
: fromAmount,
|
|
52
55
|
elementId,
|
|
56
|
+
integrator,
|
|
53
57
|
};
|
|
54
58
|
(0, stores_1.setDefaultSettings)(value);
|
|
55
59
|
return value;
|
|
56
60
|
}
|
|
57
61
|
catch (e) {
|
|
58
62
|
console.warn(e);
|
|
59
|
-
return { ...config, elementId };
|
|
63
|
+
return { ...config, elementId, integrator };
|
|
60
64
|
}
|
|
61
|
-
}, [
|
|
65
|
+
}, [
|
|
66
|
+
config,
|
|
67
|
+
elementId,
|
|
68
|
+
fromAmount,
|
|
69
|
+
fromChain,
|
|
70
|
+
fromToken,
|
|
71
|
+
integrator,
|
|
72
|
+
toChain,
|
|
73
|
+
toToken,
|
|
74
|
+
]);
|
|
62
75
|
return ((0, jsx_runtime_1.jsx)(WidgetContext.Provider, { value: value, children: children }));
|
|
63
76
|
};
|
|
64
77
|
exports.WidgetProvider = WidgetProvider;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isItemAllowed = void 0;
|
|
4
|
-
const isItemAllowed = (itemId, items
|
|
5
|
-
/** @deprecated Remove in the next major release */
|
|
6
|
-
disabledChains) => {
|
|
4
|
+
const isItemAllowed = (itemId, items) => {
|
|
7
5
|
if (items?.allow?.length) {
|
|
8
6
|
return items.allow.includes(itemId);
|
|
9
7
|
}
|
|
10
|
-
return !
|
|
8
|
+
return !items?.deny?.includes(itemId);
|
|
11
9
|
};
|
|
12
10
|
exports.isItemAllowed = isItemAllowed;
|
|
@@ -4,6 +4,6 @@ exports.StoreProvider = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const routes_1 = require("./routes");
|
|
6
6
|
const StoreProvider = ({ children, namePrefix }) => {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: namePrefix, children:
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: namePrefix, children: children }));
|
|
8
8
|
};
|
|
9
9
|
exports.StoreProvider = StoreProvider;
|
|
@@ -8,13 +8,14 @@ const types_1 = require("./types");
|
|
|
8
8
|
const utils_2 = require("./utils");
|
|
9
9
|
const createRouteExecutionStore = ({ namePrefix }) => (0, zustand_1.create)((0, middleware_1.persist)((set, get) => ({
|
|
10
10
|
routes: {},
|
|
11
|
-
setExecutableRoute: (route) => {
|
|
11
|
+
setExecutableRoute: (route, insurableRouteId) => {
|
|
12
12
|
if (!get().routes[route.id]) {
|
|
13
13
|
set((state) => {
|
|
14
14
|
const routes = { ...state.routes };
|
|
15
15
|
// clean previous idle routes that were not executed
|
|
16
16
|
Object.keys(routes)
|
|
17
|
-
.filter((routeId) =>
|
|
17
|
+
.filter((routeId) => routeId !== insurableRouteId &&
|
|
18
|
+
routes[routeId]?.status === types_1.RouteExecutionStatus.Idle)
|
|
18
19
|
.forEach((routeId) => delete routes[routeId]);
|
|
19
20
|
routes[route.id] = {
|
|
20
21
|
route,
|
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./RouteExecutionStore"), exports);
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
__exportStar(require("./useExecutingRoutesIds"), exports);
|
|
20
|
-
__exportStar(require("./useRecommendedRouteStore"), exports);
|
|
21
20
|
__exportStar(require("./useSetExecutableRoute"), exports);
|
|
22
21
|
__exportStar(require("./useSwapHistory"), exports);
|
|
23
22
|
__exportStar(require("./utils"), exports);
|
|
@@ -5,7 +5,7 @@ export interface RouteExecution {
|
|
|
5
5
|
}
|
|
6
6
|
export interface RouteExecutionState {
|
|
7
7
|
routes: Partial<Record<string, RouteExecution>>;
|
|
8
|
-
setExecutableRoute: (route: Route) => void;
|
|
8
|
+
setExecutableRoute: (route: Route, insurableRouteId?: string) => void;
|
|
9
9
|
updateRoute: (route: Route) => void;
|
|
10
10
|
restartRoute: (routeId: string) => void;
|
|
11
11
|
deleteRoute: (routeId: string) => void;
|
|
@@ -19,7 +19,3 @@ export declare enum RouteExecutionStatus {
|
|
|
19
19
|
Partial = 8,
|
|
20
20
|
Refunded = 16
|
|
21
21
|
}
|
|
22
|
-
export interface RecommendedRouteState {
|
|
23
|
-
recommendedRoute?: Route;
|
|
24
|
-
setRecommendedRoute: (route?: Route) => void;
|
|
25
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useSetExecutableRoute: () => (route: import("@lifi/types").Route) => void;
|
|
1
|
+
export declare const useSetExecutableRoute: () => (route: import("@lifi/types").Route, insurableRouteId?: string | undefined) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Order } from '@lifi/sdk';
|
|
2
|
-
import type { Appearance } from '../../types';
|
|
2
|
+
import type { Appearance, WidgetConfig } from '../../types';
|
|
3
3
|
export type ValueSetter<S> = <K extends keyof S>(key: K, value: S[Extract<K, string>]) => void;
|
|
4
4
|
export type ValuesSetter<S> = <K extends keyof S>(values: Record<K, S[Extract<K, string>]>) => void;
|
|
5
5
|
export type SettingsToolType = 'Bridges' | 'Exchanges';
|
|
@@ -9,6 +9,7 @@ export interface SettingsProps {
|
|
|
9
9
|
gasPrice?: string;
|
|
10
10
|
language?: string;
|
|
11
11
|
routePriority?: Order;
|
|
12
|
+
enabledAutoRefuel: boolean;
|
|
12
13
|
showDestinationWallet: boolean;
|
|
13
14
|
slippage?: string;
|
|
14
15
|
enabledBridges: string[];
|
|
@@ -21,7 +22,7 @@ export interface SettingsState extends SettingsProps {
|
|
|
21
22
|
setValues: ValuesSetter<SettingsProps>;
|
|
22
23
|
initializeTools(toolType: SettingsToolType, tools: string[], reset?: boolean): void;
|
|
23
24
|
setTools(toolType: SettingsToolType, tools: string[], availableTools: string[]): void;
|
|
24
|
-
reset(bridges: string[], exchanges: string[]): void;
|
|
25
|
+
reset(config: WidgetConfig, bridges: string[], exchanges: string[]): void;
|
|
25
26
|
}
|
|
26
27
|
export interface SendToWalletState {
|
|
27
28
|
showSendToWallet: boolean;
|
|
@@ -11,6 +11,7 @@ exports.defaultConfigurableSettings = {
|
|
|
11
11
|
exports.defaultSettings = {
|
|
12
12
|
appearance: 'auto',
|
|
13
13
|
gasPrice: 'normal',
|
|
14
|
+
enabledAutoRefuel: true,
|
|
14
15
|
showDestinationWallet: true,
|
|
15
16
|
enabledBridges: [],
|
|
16
17
|
enabledExchanges: [],
|
|
@@ -65,10 +66,11 @@ exports.useSettingsStore = (0, zustand_1.create)((0, middleware_1.persist)((set,
|
|
|
65
66
|
return values;
|
|
66
67
|
}, {}),
|
|
67
68
|
})),
|
|
68
|
-
reset: (bridges, exchanges) => {
|
|
69
|
+
reset: (config, bridges, exchanges) => {
|
|
69
70
|
set(() => ({
|
|
70
71
|
...exports.defaultSettings,
|
|
71
72
|
...exports.defaultConfigurableSettings,
|
|
73
|
+
appearance: config.appearance ?? exports.defaultSettings.appearance,
|
|
72
74
|
}));
|
|
73
75
|
get().initializeTools('Bridges', bridges, true);
|
|
74
76
|
get().initializeTools('Exchanges', exchanges, true);
|
package/cjs/types/widget.d.ts
CHANGED
|
@@ -38,8 +38,8 @@ export interface WidgetWalletManagement {
|
|
|
38
38
|
addChain?(chainId: number): Promise<boolean>;
|
|
39
39
|
signer?: Signer;
|
|
40
40
|
}
|
|
41
|
-
export interface SDKConfig extends Omit<ConfigUpdate, 'defaultExecutionSettings' | 'defaultRouteOptions' | 'disableVersionCheck'> {
|
|
42
|
-
defaultRouteOptions?: Omit<RouteOptions, 'bridges' | 'exchanges'>;
|
|
41
|
+
export interface SDKConfig extends Omit<ConfigUpdate, 'defaultExecutionSettings' | 'defaultRouteOptions' | 'disableVersionCheck' | 'integrator'> {
|
|
42
|
+
defaultRouteOptions?: Omit<RouteOptions, 'bridges' | 'exchanges' | 'insurance'>;
|
|
43
43
|
}
|
|
44
44
|
export interface WidgetContractTool {
|
|
45
45
|
logoURI: string;
|
|
@@ -66,10 +66,11 @@ export interface WidgetConfig {
|
|
|
66
66
|
contractCompactComponent?: ReactNode;
|
|
67
67
|
contractTool?: WidgetContractTool;
|
|
68
68
|
fee?: number;
|
|
69
|
-
integrator
|
|
69
|
+
integrator: string;
|
|
70
70
|
referrer?: string;
|
|
71
|
-
slippage?: number;
|
|
72
71
|
routePriority?: Order;
|
|
72
|
+
slippage?: number;
|
|
73
|
+
insurance?: boolean;
|
|
73
74
|
variant?: WidgetVariant;
|
|
74
75
|
appearance?: Appearance;
|
|
75
76
|
theme?: ThemeConfig;
|
|
@@ -107,12 +108,6 @@ export interface WidgetConfig {
|
|
|
107
108
|
};
|
|
108
109
|
languageResources?: LanguageResources;
|
|
109
110
|
disableI18n?: boolean;
|
|
110
|
-
/** @deprecated Use hiddenUI: ['appearance'] instead */
|
|
111
|
-
disableAppearance?: boolean;
|
|
112
|
-
/** @deprecated Use chains.deny instead */
|
|
113
|
-
disabledChains?: number[];
|
|
114
|
-
/** @deprecated Use tokens.featured instead */
|
|
115
|
-
featuredTokens?: Token[];
|
|
116
111
|
}
|
|
117
112
|
export type WidgetDrawerProps = {
|
|
118
113
|
elementRef?: RefObject<HTMLDivElement>;
|