@lifi/widget 1.32.8 → 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/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/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 +1 -0
- package/cjs/stores/settings/useSettingsStore.js +1 -0
- 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/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 +10 -10
- 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/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 +1 -0
- package/stores/settings/useSettingsStore.js +1 -0
- 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
|
@@ -6,7 +6,7 @@ export declare const Link: import("@emotion/styled").StyledComponent<Omit<import
|
|
|
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;
|
|
9
|
-
variant?: "
|
|
9
|
+
variant?: import("@mui/types").OverridableStringUnion<"inherit" | import("@mui/material").TypographyVariant, import("@mui/material").TypographyPropsVariantOverrides> | undefined;
|
|
10
10
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & {
|
|
11
11
|
ref?: ((instance: HTMLAnchorElement | null) => void) | import("react").RefObject<HTMLAnchorElement> | null | undefined;
|
|
12
12
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "p" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "download" | "href" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "referrerPolicy" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint" | "variant" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping" | "underline" | "TypographyClasses"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "default" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
5
|
+
color?: import("@mui/types").OverridableStringUnion<"inherit" | "default" | "success" | "warning" | "error" | "primary" | "secondary" | "info", import("@mui/material").IconButtonPropsColorOverrides> | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
9
|
-
size?: "small" | "medium" | "large" | undefined;
|
|
9
|
+
size?: import("@mui/types").OverridableStringUnion<"small" | "medium" | "large", import("@mui/material").IconButtonPropsSizeOverrides> | undefined;
|
|
10
10
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
11
11
|
} & Omit<{
|
|
12
12
|
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { isAddress } from '@ethersproject/address';
|
|
3
3
|
import { Collapse, FormHelperText } from '@mui/material';
|
|
4
|
-
import { forwardRef, useEffect } from 'react';
|
|
5
|
-
import { useFormContext, useFormState } from 'react-hook-form';
|
|
4
|
+
import { forwardRef, useEffect, useRef } from 'react';
|
|
5
|
+
import { useController, useFormContext, useFormState } from 'react-hook-form';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { SwapFormKey, useWallet, useWidgetConfig } from '../../providers';
|
|
8
8
|
import { useSendToWalletStore, useSettings } from '../../stores';
|
|
9
|
-
import { DisabledUI, HiddenUI } from '../../types';
|
|
9
|
+
import { DisabledUI, HiddenUI, RequiredUI } from '../../types';
|
|
10
10
|
import { Card, CardTitle } from '../Card';
|
|
11
11
|
import { FormControl, Input } from './SendToWallet.style';
|
|
12
12
|
export const SendToWallet = forwardRef((props, ref) => {
|
|
13
13
|
const { t } = useTranslation();
|
|
14
|
-
const {
|
|
14
|
+
const { trigger, getValues, clearErrors } = useFormContext();
|
|
15
15
|
const { account, provider } = useWallet();
|
|
16
16
|
const { disabledUI, hiddenUI, requiredUI, toAddress } = useWidgetConfig();
|
|
17
17
|
const { showSendToWallet, showSendToWalletDirty, setSendToWallet } = useSendToWalletStore();
|
|
18
18
|
const { showDestinationWallet } = useSettings(['showDestinationWallet']);
|
|
19
19
|
const hiddenToAddress = hiddenUI?.includes(HiddenUI.ToAddress);
|
|
20
20
|
const disabledToAddress = disabledUI?.includes(DisabledUI.ToAddress);
|
|
21
|
-
const requiredToAddress = requiredUI?.includes(
|
|
21
|
+
const requiredToAddress = requiredUI?.includes(RequiredUI.ToAddress);
|
|
22
|
+
const requiredToAddressRef = useRef(requiredToAddress);
|
|
23
|
+
const { field: { onChange, onBlur, name, value }, } = useController({
|
|
24
|
+
name: SwapFormKey.ToAddress,
|
|
25
|
+
rules: {
|
|
26
|
+
required: requiredToAddress &&
|
|
27
|
+
t('swap.error.title.walletAddressRequired'),
|
|
28
|
+
validate: async (value) => {
|
|
29
|
+
try {
|
|
30
|
+
if (!value) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const address = await provider?.resolveName(value);
|
|
34
|
+
return (isAddress(address || value) ||
|
|
35
|
+
t('swap.error.title.walletAddressInvalid'));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return t('swap.error.title.walletEnsAddressInvalid');
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
onBlur: () => trigger(SwapFormKey.ToAddress),
|
|
42
|
+
},
|
|
43
|
+
});
|
|
22
44
|
// We want to show toAddress field if it is set via widget configuration and not hidden
|
|
23
45
|
const showInstantly = Boolean(!showSendToWalletDirty &&
|
|
24
46
|
showDestinationWallet &&
|
|
@@ -33,33 +55,17 @@ export const SendToWallet = forwardRef((props, ref) => {
|
|
|
33
55
|
const value = getValues(SwapFormKey.ToAddress);
|
|
34
56
|
if (value) {
|
|
35
57
|
trigger(SwapFormKey.ToAddress);
|
|
58
|
+
// Trigger validation if we change requiredToAddress in the runtime
|
|
36
59
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
60
|
+
else if (requiredToAddressRef.current !== requiredToAddress) {
|
|
61
|
+
requiredToAddressRef.current = requiredToAddress;
|
|
62
|
+
trigger(SwapFormKey.ToAddress).then(() => clearErrors(SwapFormKey.ToAddress));
|
|
63
|
+
}
|
|
64
|
+
}, [account.chainId, clearErrors, getValues, requiredToAddress, trigger]);
|
|
41
65
|
if (hiddenToAddress) {
|
|
42
66
|
return null;
|
|
43
67
|
}
|
|
44
|
-
|
|
45
|
-
required: requiredToAddress &&
|
|
46
|
-
t('swap.error.title.walletAddressRequired'),
|
|
47
|
-
validate: async (value) => {
|
|
48
|
-
try {
|
|
49
|
-
if (!value) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
const address = await provider?.resolveName(value);
|
|
53
|
-
return (isAddress(address || value) ||
|
|
54
|
-
t('swap.error.title.walletAddressInvalid'));
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
return t('swap.error.title.walletEnsAddressInvalid');
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
onBlur: () => trigger(SwapFormKey.ToAddress),
|
|
61
|
-
});
|
|
62
|
-
return (_jsx(Collapse, { timeout: showInstantly ? 0 : 225, in: showSendToWallet || showInstantly, mountOnEnter: true, unmountOnExit: true, children: _jsxs(Card, { ...props, ref: ref, children: [_jsx(CardTitle, { required: requiredToAddress, children: t('swap.sendToWallet') }), _jsxs(FormControl, { fullWidth: true, sx: { paddingTop: '6px', paddingBottom: '5px' }, children: [_jsx(Input, { ref: inputRef, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns'), disabled: Boolean(toAddress && disabledToAddress) }), _jsx(SendToWalletFormHelperText, {})] })] }) }));
|
|
68
|
+
return (_jsx(Collapse, { timeout: showInstantly ? 0 : 225, in: showSendToWallet || showInstantly, mountOnEnter: true, unmountOnExit: true, children: _jsxs(Card, { ...props, ref: ref, children: [_jsx(CardTitle, { required: requiredToAddress, children: t('swap.sendToWallet') }), _jsxs(FormControl, { fullWidth: true, sx: { paddingTop: '6px', paddingBottom: '5px' }, children: [_jsx(Input, { size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, value: value, placeholder: t('swap.walletAddressOrEns'), disabled: Boolean(toAddress && disabledToAddress) }), _jsx(SendToWalletFormHelperText, {})] })] }) }));
|
|
63
69
|
});
|
|
64
70
|
export const SendToWalletFormHelperText = () => {
|
|
65
71
|
const { errors } = useFormState();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").FormControlClasses> | undefined;
|
|
5
|
-
color?: "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
5
|
+
color?: import("@mui/types").OverridableStringUnion<"success" | "warning" | "error" | "primary" | "secondary" | "info", import("@mui/material").FormControlPropsColorOverrides> | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
error?: boolean | undefined;
|
|
8
8
|
fullWidth?: boolean | undefined;
|
|
@@ -10,7 +10,7 @@ export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
|
10
10
|
hiddenLabel?: boolean | undefined;
|
|
11
11
|
margin?: "normal" | "none" | "dense" | undefined;
|
|
12
12
|
required?: boolean | undefined;
|
|
13
|
-
size?: "small" | "medium" | undefined;
|
|
13
|
+
size?: import("@mui/types").OverridableStringUnion<"small" | "medium", import("@mui/material").FormControlPropsSizeOverrides> | undefined;
|
|
14
14
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
15
15
|
variant?: "outlined" | "filled" | "standard" | undefined;
|
|
16
16
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import WalletIcon from '@mui/icons-material/Wallet';
|
|
3
3
|
import { Button, Tooltip } from '@mui/material';
|
|
4
4
|
import { useFormContext } from 'react-hook-form';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { SwapFormKey, useWallet, useWidgetConfig } from '../../providers';
|
|
7
7
|
import { useSendToWalletStore, useSettings } from '../../stores';
|
|
8
|
-
import { DisabledUI, HiddenUI } from '../../types';
|
|
8
|
+
import { DisabledUI, HiddenUI, RequiredUI } from '../../types';
|
|
9
9
|
export const SendToWalletButton = () => {
|
|
10
10
|
const { t } = useTranslation();
|
|
11
11
|
const { setValue } = useFormContext();
|
|
@@ -16,7 +16,7 @@ export const SendToWalletButton = () => {
|
|
|
16
16
|
if (!showDestinationWallet ||
|
|
17
17
|
!account.isActive ||
|
|
18
18
|
hiddenUI?.includes(HiddenUI.ToAddress) ||
|
|
19
|
-
requiredUI?.includes(
|
|
19
|
+
requiredUI?.includes(RequiredUI.ToAddress)) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
const handleClick = () => {
|
|
@@ -28,5 +28,5 @@ export const SendToWalletButton = () => {
|
|
|
28
28
|
return (_jsx(Tooltip, { title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay: 400, arrow: true, children: _jsx(Button, { variant: showSendToWallet ? 'contained' : 'text', onClick: handleClick, sx: {
|
|
29
29
|
minWidth: 48,
|
|
30
30
|
marginLeft: 1,
|
|
31
|
-
}, children: _jsx(
|
|
31
|
+
}, children: _jsx(WalletIcon, {}) }) }));
|
|
32
32
|
};
|
|
@@ -10,7 +10,7 @@ export declare const SmallAvatar: import("@emotion/styled").StyledComponent<{
|
|
|
10
10
|
src?: string | undefined;
|
|
11
11
|
srcSet?: string | undefined;
|
|
12
12
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
13
|
-
variant?: "square" | "circular" | "rounded" | undefined;
|
|
13
|
+
variant?: import("@mui/types").OverridableStringUnion<"square" | "circular" | "rounded", import("@mui/material").AvatarPropsVariantOverrides> | undefined;
|
|
14
14
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
15
15
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
16
16
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "alt" | "imgProps" | "sizes" | "src" | "srcSet"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -20,7 +20,7 @@ export declare const SmallAvatarSkeletonBase: import("@emotion/styled").StyledCo
|
|
|
20
20
|
classes?: Partial<import("@mui/material").SkeletonClasses> | undefined;
|
|
21
21
|
height?: string | number | undefined;
|
|
22
22
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
23
|
-
variant?: "text" | "circular" | "rounded" | "rectangular" | undefined;
|
|
23
|
+
variant?: import("@mui/types").OverridableStringUnion<"text" | "circular" | "rounded" | "rectangular", import("@mui/material").SkeletonPropsVariantOverrides> | undefined;
|
|
24
24
|
width?: string | number | undefined;
|
|
25
25
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
26
26
|
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Status, Substatus } from '@lifi/sdk';
|
|
3
|
-
import { Theme } from '@mui/material';
|
|
3
|
+
import type { Theme } from '@mui/material';
|
|
4
4
|
export declare const CircularIcon: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
|
|
5
5
|
children?: import("react").ReactNode;
|
|
6
6
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import LinkRoundedIcon from '@mui/icons-material/LinkRounded';
|
|
3
|
-
import
|
|
3
|
+
import WalletIcon from '@mui/icons-material/Wallet';
|
|
4
4
|
import { Box, Link, Typography } from '@mui/material';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { CircularIcon } from './CircularProgress.style';
|
|
@@ -11,7 +11,7 @@ export const DestinationWalletAddress = ({ step, toAddress, toAddressLink }) =>
|
|
|
11
11
|
return (_jsx(Box, { px: 2, py: 1, children: _jsxs(Box, { sx: {
|
|
12
12
|
display: 'flex',
|
|
13
13
|
alignItems: 'center',
|
|
14
|
-
}, children: [_jsx(CircularIcon, { status: isDone ? 'DONE' : 'NOT_STARTED', children: _jsx(
|
|
14
|
+
}, children: [_jsx(CircularIcon, { status: isDone ? 'DONE' : 'NOT_STARTED', children: _jsx(WalletIcon, { color: isDone ? 'success' : 'inherit', sx: {
|
|
15
15
|
position: 'absolute',
|
|
16
16
|
fontSize: '1rem',
|
|
17
17
|
} }) }), _jsx(Typography, { ml: 2, fontSize: 14, fontWeight: 400, children: isDone
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import EvStationIcon from '@mui/icons-material/EvStation';
|
|
3
3
|
import { Box, Typography } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { CircularIcon } from './CircularProgress.style';
|
|
@@ -9,7 +9,7 @@ export const GasStepProcess = ({ step }) => {
|
|
|
9
9
|
return (_jsx(Box, { px: 2, py: 1, children: _jsxs(Box, { sx: {
|
|
10
10
|
display: 'flex',
|
|
11
11
|
alignItems: 'center',
|
|
12
|
-
}, children: [_jsx(CircularIcon, { status: isDone ? 'DONE' : 'NOT_STARTED', children: _jsx(
|
|
12
|
+
}, children: [_jsx(CircularIcon, { status: isDone ? 'DONE' : 'NOT_STARTED', children: _jsx(EvStationIcon, { color: isDone ? 'success' : 'inherit', sx: {
|
|
13
13
|
position: 'absolute',
|
|
14
14
|
fontSize: '1rem',
|
|
15
15
|
} }) }), _jsxs(Typography, { ml: 2, fontSize: 14, fontWeight: 400, children: [t('format.currency', {
|
package/components/Step/Step.js
CHANGED
|
@@ -17,13 +17,15 @@ export const Step = ({ step, fromToken, toToken, toAddress }) => {
|
|
|
17
17
|
const getCardTitle = () => {
|
|
18
18
|
switch (step.type) {
|
|
19
19
|
case 'lifi':
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const hasCrossStep = step.includedSteps.some((step) => step.type === 'cross');
|
|
21
|
+
const hasSwapStep = step.includedSteps.some((step) => step.type === 'swap');
|
|
22
|
+
if (hasCrossStep && hasSwapStep) {
|
|
23
|
+
return t('swap.stepSwapAndBridge');
|
|
22
24
|
}
|
|
23
|
-
if (
|
|
24
|
-
return t('swap.
|
|
25
|
+
if (hasCrossStep) {
|
|
26
|
+
return t('swap.stepBridge');
|
|
25
27
|
}
|
|
26
|
-
return t('swap.
|
|
28
|
+
return t('swap.stepSwap');
|
|
27
29
|
case 'swap':
|
|
28
30
|
return t('swap.stepSwap');
|
|
29
31
|
case 'cross':
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Route } from '@lifi/sdk';
|
|
1
|
+
import type { Route } from '@lifi/sdk';
|
|
2
2
|
export declare const getStepList: (route?: Route) => JSX.Element[] | undefined;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
export declare const LinkButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "default" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
5
|
+
color?: import("@mui/types").OverridableStringUnion<"inherit" | "default" | "success" | "warning" | "error" | "primary" | "secondary" | "info", import("@mui/material").IconButtonPropsColorOverrides> | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
9
|
-
size?: "small" | "medium" | "large" | undefined;
|
|
9
|
+
size?: import("@mui/types").OverridableStringUnion<"small" | "medium" | "large", import("@mui/material").IconButtonPropsSizeOverrides> | undefined;
|
|
10
10
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
11
11
|
} & Omit<{
|
|
12
12
|
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
@@ -33,7 +33,7 @@ export declare const LinkButton: import("@emotion/styled").StyledComponent<{
|
|
|
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;
|
|
36
|
-
variant?: "
|
|
36
|
+
variant?: import("@mui/types").OverridableStringUnion<"inherit" | import("@mui/material").TypographyVariant, import("@mui/material").TypographyPropsVariantOverrides> | undefined;
|
|
37
37
|
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & {
|
|
38
38
|
ref?: ((instance: HTMLAnchorElement | null) => void) | import("react").RefObject<HTMLAnchorElement> | null | undefined;
|
|
39
39
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "p" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "download" | "href" | "hrefLang" | "media" | "ping" | "rel" | "target" | "type" | "referrerPolicy" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint" | "variant" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping" | "underline" | "TypographyClasses">, {}, {}>;
|
|
@@ -3,6 +3,10 @@ import type { Step } from '@lifi/sdk';
|
|
|
3
3
|
import type { WidgetVariant } from '../../types';
|
|
4
4
|
import type { StepActionsProps, StepDetailsLabelProps } from './types';
|
|
5
5
|
export declare const StepActions: React.FC<StepActionsProps>;
|
|
6
|
+
export declare const IncludedSteps: React.FC<{
|
|
7
|
+
step: Step;
|
|
8
|
+
variant?: WidgetVariant;
|
|
9
|
+
}>;
|
|
6
10
|
export declare const StepDetailsContent: React.FC<{
|
|
7
11
|
step: Step;
|
|
8
12
|
variant?: WidgetVariant;
|
|
@@ -10,3 +14,4 @@ export declare const StepDetailsContent: React.FC<{
|
|
|
10
14
|
export declare const CustomStepDetailsLabel: React.FC<StepDetailsLabelProps>;
|
|
11
15
|
export declare const CrossStepDetailsLabel: React.FC<Omit<StepDetailsLabelProps, 'variant'>>;
|
|
12
16
|
export declare const SwapStepDetailsLabel: React.FC<Omit<StepDetailsLabelProps, 'variant'>>;
|
|
17
|
+
export declare const ProtocolStepDetailsLabel: React.FC<Omit<StepDetailsLabelProps, 'variant'>>;
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
|
|
3
|
-
import
|
|
3
|
+
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
4
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
5
|
+
import { Badge, Box, Collapse, Step as MuiStep, Stepper, Typography, } from '@mui/material';
|
|
6
|
+
import Big from 'big.js';
|
|
7
|
+
import { useState } from 'react';
|
|
4
8
|
import { useTranslation } from 'react-i18next';
|
|
5
9
|
import { useChains } from '../../hooks';
|
|
6
10
|
import { LiFiToolLogo } from '../../icons';
|
|
7
11
|
import { useWidgetConfig } from '../../providers';
|
|
8
12
|
import { formatTokenAmount } from '../../utils';
|
|
13
|
+
import { CardIconButton } from '../Card';
|
|
9
14
|
import { SmallAvatar } from '../SmallAvatar';
|
|
10
15
|
import { StepAvatar, StepConnector, StepContent, StepLabel, } from './StepActions.style';
|
|
11
16
|
export const StepActions = ({ step, dense, ...other }) => {
|
|
17
|
+
const { t } = useTranslation();
|
|
12
18
|
const { variant, contractTool } = useWidgetConfig();
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
? CrossStepDetailsLabel
|
|
19
|
-
: SwapStepDetailsLabel;
|
|
20
|
-
const isFullView = !dense && step.includedSteps?.length > 1;
|
|
19
|
+
const [cardExpanded, setCardExpanded] = useState(false);
|
|
20
|
+
const handleExpand = (e) => {
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
setCardExpanded((expanded) => !expanded);
|
|
23
|
+
};
|
|
21
24
|
const customStep = variant === 'nft'
|
|
22
25
|
? step.includedSteps?.find((step) => step.type === 'custom')
|
|
23
26
|
: undefined;
|
|
27
|
+
const hasCollapsedSteps = dense && step.includedSteps?.length > 1;
|
|
24
28
|
if (customStep && contractTool) {
|
|
25
29
|
const toolDetails = {
|
|
26
30
|
key: contractTool.name,
|
|
@@ -28,10 +32,15 @@ export const StepActions = ({ step, dense, ...other }) => {
|
|
|
28
32
|
logoURI: contractTool.logoURI,
|
|
29
33
|
};
|
|
30
34
|
customStep.toolDetails = toolDetails;
|
|
31
|
-
if (
|
|
35
|
+
if (dense) {
|
|
32
36
|
step.toolDetails = toolDetails;
|
|
33
37
|
}
|
|
34
38
|
}
|
|
39
|
+
return (_jsxs(Box, { ...other, children: [_jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Badge, { overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: _jsx(SmallAvatar, { children: _jsx(LiFiToolLogo, {}) }), children: _jsx(StepAvatar, { variant: "circular", src: step.toolDetails.logoURI, alt: step.toolDetails.name, children: step.toolDetails.name[0] }) }), _jsx(Typography, { ml: 2, fontSize: 18, fontWeight: "500", flex: 1, children: t(`swap.stepDetails`, {
|
|
40
|
+
tool: step.toolDetails.name,
|
|
41
|
+
}) }), hasCollapsedSteps ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), hasCollapsedSteps ? (_jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(IncludedSteps, { step: step, variant: variant }) })) : (_jsx(IncludedSteps, { step: step, variant: variant }))] }));
|
|
42
|
+
};
|
|
43
|
+
export const IncludedSteps = ({ step, variant }) => {
|
|
35
44
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
36
45
|
const StepIconComponent = ({ icon }) => {
|
|
37
46
|
const tool = step.includedSteps?.[Number(icon) - 1];
|
|
@@ -39,16 +48,35 @@ export const StepActions = ({ step, dense, ...other }) => {
|
|
|
39
48
|
boxSizing: 'content-box',
|
|
40
49
|
}, children: tool.toolDetails.name[0] })) : null;
|
|
41
50
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
const StepDetailsLabel = step.tool === 'custom' && variant === 'nft'
|
|
52
|
+
? CustomStepDetailsLabel
|
|
53
|
+
: step.type === 'cross' ||
|
|
54
|
+
(step.type === 'lifi' &&
|
|
55
|
+
step.includedSteps.some((step) => step.type === 'cross'))
|
|
56
|
+
? CrossStepDetailsLabel
|
|
57
|
+
: SwapStepDetailsLabel;
|
|
58
|
+
return step.includedSteps.length > 1 ? (_jsx(Box, { mt: 1.5, children: _jsx(Stepper, { orientation: "vertical", connector: _jsx(StepConnector, {}), activeStep: -1, children: step.includedSteps.map((step, i) => (_jsxs(MuiStep, { expanded: true, children: [_jsx(StepLabel, { StepIconComponent: StepIconComponent, children: step.type === 'custom' && variant === 'nft' ? (_jsx(CustomStepDetailsLabel, { step: step, variant: variant })) : step.type === 'cross' || step.type === 'lifi' ? (_jsx(CrossStepDetailsLabel, { step: step })) : step.type === 'protocol' ? (_jsx(ProtocolStepDetailsLabel, { step: step })) : (_jsx(SwapStepDetailsLabel, { step: step })) }), _jsx(StepContent, { children: _jsx(StepDetailsContent, { step: step, variant: variant }) })] }, step.id))) }) })) : (_jsxs(Box, { ml: 6, children: [_jsx(StepDetailsLabel, { step: step, variant: variant === 'nft' ? variant : undefined }), _jsx(StepDetailsContent, { step: step, variant: variant })] }));
|
|
45
59
|
};
|
|
46
60
|
export const StepDetailsContent = ({ step, variant }) => {
|
|
47
61
|
const { t } = useTranslation();
|
|
62
|
+
const sameTokenProtocolStep = step.action.fromToken.chainId === step.action.toToken.chainId &&
|
|
63
|
+
step.action.fromToken.address === step.action.toToken.address;
|
|
64
|
+
let fromAmount;
|
|
65
|
+
if (sameTokenProtocolStep) {
|
|
66
|
+
fromAmount = Big(step.estimate.fromAmount)
|
|
67
|
+
.div(10 ** step.action.fromToken.decimals)
|
|
68
|
+
.minus(Big(step.estimate.toAmount).div(10 ** step.action.toToken.decimals));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
fromAmount = formatTokenAmount(step.estimate.fromAmount, step.action.fromToken.decimals);
|
|
72
|
+
}
|
|
73
|
+
const showToAmount = step.type !== 'custom' &&
|
|
74
|
+
step.tool !== 'custom' &&
|
|
75
|
+
variant !== 'nft' &&
|
|
76
|
+
!sameTokenProtocolStep;
|
|
48
77
|
return (_jsxs(Typography, { fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex", children: [t('format.number', {
|
|
49
|
-
value:
|
|
50
|
-
}), ' ', step.action.fromToken.symbol,
|
|
51
|
-
variant === 'nft') ? (_jsxs(_Fragment, { children: [_jsx(ArrowForwardIcon, { sx: { fontSize: 18, paddingX: 0.5 } }), t('format.number', {
|
|
78
|
+
value: fromAmount,
|
|
79
|
+
}), ' ', step.action.fromToken.symbol, showToAmount ? (_jsxs(_Fragment, { children: [_jsx(ArrowForwardIcon, { sx: { fontSize: 18, paddingX: 0.5 } }), t('format.number', {
|
|
52
80
|
value: formatTokenAmount(step.execution?.toAmount ?? step.estimate.toAmount, step.execution?.toToken?.decimals ?? step.action.toToken.decimals),
|
|
53
81
|
}), ' ', step.execution?.toToken?.symbol ?? step.action.toToken.symbol] })) : null] }));
|
|
54
82
|
};
|
|
@@ -78,3 +106,11 @@ export const SwapStepDetailsLabel = ({ step }) => {
|
|
|
78
106
|
tool: step.toolDetails.name,
|
|
79
107
|
}) }));
|
|
80
108
|
};
|
|
109
|
+
export const ProtocolStepDetailsLabel = ({ step }) => {
|
|
110
|
+
const { t } = useTranslation();
|
|
111
|
+
return (_jsx(Typography, { fontSize: 12, fontWeight: "500", color: "text.secondary", children: step.toolDetails.key === 'lifuelProtocol'
|
|
112
|
+
? t('swap.refuelStepDetails', {
|
|
113
|
+
tool: step.toolDetails.name,
|
|
114
|
+
})
|
|
115
|
+
: step.toolDetails.name }));
|
|
116
|
+
};
|
|
@@ -14,7 +14,7 @@ export declare const StepAvatar: import("@emotion/styled").StyledComponent<{
|
|
|
14
14
|
src?: string | undefined;
|
|
15
15
|
srcSet?: string | undefined;
|
|
16
16
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
17
|
-
variant?: "square" | "circular" | "rounded" | undefined;
|
|
17
|
+
variant?: import("@mui/types").OverridableStringUnion<"square" | "circular" | "rounded", import("@mui/material").AvatarPropsVariantOverrides> | undefined;
|
|
18
18
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
19
19
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
20
20
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "alt" | "imgProps" | "sizes" | "src" | "srcSet"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import { useNavigate } from 'react-router-dom';
|
|
5
5
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
6
6
|
import { navigationRoutes } from '../../utils';
|
|
7
|
-
export const SwapButton = ({ onClick,
|
|
7
|
+
export const SwapButton = ({ onClick, hasRoute, text, disabled, loading, }) => {
|
|
8
8
|
const { t } = useTranslation();
|
|
9
9
|
const navigate = useNavigate();
|
|
10
10
|
const { variant, walletManagement } = useWidgetConfig();
|
|
@@ -24,7 +24,7 @@ export const SwapButton = ({ onClick, currentRoute, text, disabled, loading, })
|
|
|
24
24
|
};
|
|
25
25
|
const getButtonText = () => {
|
|
26
26
|
if (account.isActive) {
|
|
27
|
-
if (!
|
|
27
|
+
if (!hasRoute) {
|
|
28
28
|
return variant !== 'refuel' ? t(`button.swap`) : t(`button.getGas`);
|
|
29
29
|
}
|
|
30
30
|
if (text) {
|
|
@@ -4,7 +4,7 @@ export declare const minInputFontSize = 14;
|
|
|
4
4
|
export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
5
5
|
children?: import("react").ReactNode;
|
|
6
6
|
classes?: Partial<import("@mui/material").FormControlClasses> | undefined;
|
|
7
|
-
color?: "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
7
|
+
color?: import("@mui/types").OverridableStringUnion<"success" | "warning" | "error" | "primary" | "secondary" | "info", import("@mui/material").FormControlPropsColorOverrides> | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
error?: boolean | undefined;
|
|
10
10
|
fullWidth?: boolean | undefined;
|
|
@@ -12,7 +12,7 @@ export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
|
12
12
|
hiddenLabel?: boolean | undefined;
|
|
13
13
|
margin?: "normal" | "none" | "dense" | undefined;
|
|
14
14
|
required?: boolean | undefined;
|
|
15
|
-
size?: "small" | "medium" | undefined;
|
|
15
|
+
size?: import("@mui/types").OverridableStringUnion<"small" | "medium", import("@mui/material").FormControlPropsSizeOverrides> | undefined;
|
|
16
16
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
17
17
|
variant?: "outlined" | "filled" | "standard" | undefined;
|
|
18
18
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
5
|
+
color?: import("@mui/types").OverridableStringUnion<"inherit" | "success" | "warning" | "error" | "primary" | "secondary" | "info", import("@mui/material").ButtonPropsColorOverrides> | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
|
9
9
|
endIcon?: import("react").ReactNode;
|
|
10
10
|
fullWidth?: boolean | undefined;
|
|
11
11
|
href?: string | undefined;
|
|
12
|
-
size?: "small" | "medium" | "large" | undefined;
|
|
12
|
+
size?: import("@mui/types").OverridableStringUnion<"small" | "medium" | "large", import("@mui/material").ButtonPropsSizeOverrides> | undefined;
|
|
13
13
|
startIcon?: import("react").ReactNode;
|
|
14
14
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
15
|
-
variant?: "text" | "outlined" | "contained" | undefined;
|
|
15
|
+
variant?: import("@mui/types").OverridableStringUnion<"text" | "outlined" | "contained", import("@mui/material").ButtonPropsVariantOverrides> | undefined;
|
|
16
16
|
} & Omit<{
|
|
17
17
|
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
18
18
|
centerRipple?: boolean | undefined;
|
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { InputAdornment, Skeleton } from '@mui/material';
|
|
3
|
+
import Big from 'big.js';
|
|
3
4
|
import { useFormContext, useWatch } from 'react-hook-form';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { useTokenAddressBalance } from '../../hooks';
|
|
6
|
+
import { useChains, useGasRecommendation, useTokenAddressBalance, } from '../../hooks';
|
|
6
7
|
import { SwapFormKeyHelper } from '../../providers';
|
|
8
|
+
import { formatTokenAmount } from '../../utils';
|
|
7
9
|
import { Button } from './SwapInputAdornment.style';
|
|
8
10
|
export const SwapInputEndAdornment = ({ formType }) => {
|
|
9
11
|
const { t } = useTranslation();
|
|
10
12
|
const { setValue } = useFormContext();
|
|
13
|
+
const { getChainById } = useChains();
|
|
11
14
|
const [chainId, tokenAddress] = useWatch({
|
|
12
15
|
name: [
|
|
13
16
|
SwapFormKeyHelper.getChainKey(formType),
|
|
14
17
|
SwapFormKeyHelper.getTokenKey(formType),
|
|
15
18
|
],
|
|
16
19
|
});
|
|
20
|
+
const { data } = useGasRecommendation(chainId);
|
|
17
21
|
const { token, isLoading } = useTokenAddressBalance(chainId, tokenAddress);
|
|
18
22
|
const handleMax = () => {
|
|
19
|
-
|
|
23
|
+
const chain = getChainById(chainId);
|
|
24
|
+
let maxAmount;
|
|
25
|
+
if (chain?.nativeToken.address === tokenAddress &&
|
|
26
|
+
data?.available &&
|
|
27
|
+
data?.recommended) {
|
|
28
|
+
const tokenAmount = Big(token?.amount ?? 0);
|
|
29
|
+
const recommendedAmount = Big(data.recommended.amount)
|
|
30
|
+
.div(10 ** data.recommended.token.decimals)
|
|
31
|
+
.div(2);
|
|
32
|
+
if (tokenAmount.gt(recommendedAmount)) {
|
|
33
|
+
maxAmount = formatTokenAmount(tokenAmount.minus(recommendedAmount).toString());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
setValue(SwapFormKeyHelper.getAmountKey(formType), maxAmount || token?.amount || '', {
|
|
20
37
|
shouldTouch: true,
|
|
21
38
|
});
|
|
22
39
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CardProps } from '../Card';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SwapRouteCardProps } from './types';
|
|
4
4
|
export declare const SwapRouteCard: React.FC<SwapRouteCardProps & Omit<CardProps, 'variant'>>;
|
|
5
|
-
export declare const SwapRouteCardEssentials: React.FC<SwapRouteCardEssentialsProps>;
|