@lifi/widget 1.16.0 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AppDrawer.d.ts +3 -3
- package/AppProvider.d.ts +0 -4
- package/AppProvider.js +2 -10
- package/README.md +1 -1
- package/cjs/AppDrawer.d.ts +3 -3
- package/cjs/AppProvider.d.ts +0 -4
- package/cjs/AppProvider.js +3 -12
- package/cjs/components/AppContainer.js +2 -2
- package/cjs/components/ChainSelect/ChainSelect.style.js +4 -4
- package/cjs/components/ChainSelect/useChainSelect.d.ts +2 -2
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
- package/cjs/components/Header/useHeaderActionStore.d.ts +0 -2
- package/cjs/components/Header/useHeaderActionStore.js +1 -5
- package/cjs/components/SelectChainAndToken.js +5 -5
- package/cjs/components/SwapButton/SwapButton.js +3 -23
- package/cjs/components/TokenList/TokenList.js +1 -1
- package/cjs/components/TokenList/TokenList.style.js +4 -3
- package/cjs/components/TokenList/TokenListItem.js +1 -1
- package/cjs/components/TokenList/TokenNotFound.d.ts +2 -1
- package/cjs/components/TokenList/TokenNotFound.js +12 -2
- package/cjs/components/TokenList/types.d.ts +2 -2
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useChains.js +23 -10
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useFeaturedTokens.js +6 -3
- package/cjs/hooks/useGasSufficiency.d.ts +1 -1
- package/cjs/hooks/useGasSufficiency.js +39 -28
- package/cjs/hooks/useInitializer.js +6 -0
- package/cjs/hooks/useRouteExecution.js +28 -12
- package/cjs/hooks/useSwapRoutes.js +10 -11
- package/cjs/hooks/useToken.d.ts +0 -1
- package/cjs/hooks/useToken.js +1 -2
- package/cjs/hooks/useTokenBalances.d.ts +1 -2
- package/cjs/hooks/useTokenBalances.js +5 -6
- package/cjs/hooks/useTokenSearch.js +3 -2
- package/cjs/hooks/useTokens.d.ts +1 -2
- package/cjs/hooks/useTokens.js +32 -9
- package/cjs/hooks/useTools.js +11 -5
- package/cjs/hooks/useWidgetEvents.d.ts +3 -3
- package/cjs/hooks/useWidgetEvents.js +2 -2
- package/cjs/i18n/en/translation.json +2 -3
- package/cjs/i18n/index.d.ts +1 -2
- package/cjs/index.d.ts +2 -1
- package/cjs/pages/MainPage/MainSwapButton.js +1 -1
- package/cjs/pages/SettingsPage/AdvancedPreferences.js +1 -1
- package/cjs/pages/SettingsPage/GasPriceSelect.js +1 -1
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +1 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.js +1 -1
- package/cjs/pages/SettingsPage/SlippageInput.js +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +2 -3
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -3
- package/cjs/pages/SwapPage/SwapPage.js +11 -2
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +4 -3
- package/cjs/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/cjs/providers/SDKProvider/SDKProvider.js +27 -0
- package/cjs/providers/SDKProvider/index.d.ts +1 -0
- package/cjs/providers/SDKProvider/index.js +17 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +4 -58
- package/cjs/providers/SwapFormProvider/types.d.ts +5 -5
- package/cjs/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/cjs/providers/TelemetryProvider/TelemetryProvider.js +11 -0
- package/cjs/providers/TelemetryProvider/index.d.ts +1 -0
- package/cjs/providers/TelemetryProvider/index.js +17 -0
- package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/cjs/providers/WalletProvider/WalletProvider.js +59 -1
- package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -12
- package/cjs/providers/WidgetProvider/index.d.ts +1 -0
- package/cjs/providers/WidgetProvider/index.js +1 -0
- package/cjs/providers/WidgetProvider/utils.d.ts +4 -0
- package/cjs/providers/WidgetProvider/utils.js +13 -0
- package/cjs/providers/index.d.ts +2 -0
- package/cjs/providers/index.js +2 -0
- package/cjs/stores/chains/index.d.ts +0 -1
- package/cjs/stores/chains/index.js +0 -1
- package/cjs/stores/chains/types.d.ts +1 -1
- package/cjs/stores/chains/useChainOrderStore.js +17 -14
- package/cjs/stores/route/utils.d.ts +2 -1
- package/cjs/stores/route/utils.js +17 -1
- package/cjs/stores/settings/index.d.ts +0 -1
- package/cjs/stores/settings/index.js +0 -1
- package/cjs/stores/settings/useAppearance.js +3 -1
- package/cjs/types/events.d.ts +15 -3
- package/cjs/types/events.js +4 -3
- package/cjs/types/widget.d.ts +29 -22
- package/cjs/utils/colors.d.ts +1 -1
- package/components/AppContainer.js +1 -1
- package/components/ChainSelect/ChainSelect.style.js +4 -4
- package/components/ChainSelect/useChainSelect.d.ts +2 -2
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
- package/components/Header/useHeaderActionStore.d.ts +0 -2
- package/components/Header/useHeaderActionStore.js +0 -3
- package/components/SelectChainAndToken.js +1 -1
- package/components/SwapButton/SwapButton.js +5 -25
- package/components/TokenList/TokenList.js +1 -1
- package/components/TokenList/TokenList.style.js +4 -3
- package/components/TokenList/TokenListItem.js +1 -1
- package/components/TokenList/TokenNotFound.d.ts +2 -1
- package/components/TokenList/TokenNotFound.js +12 -2
- package/components/TokenList/types.d.ts +2 -2
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useChains.js +24 -11
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useFeaturedTokens.js +6 -3
- package/hooks/useGasSufficiency.d.ts +1 -1
- package/hooks/useGasSufficiency.js +35 -24
- package/hooks/useInitializer.js +6 -0
- package/hooks/useRouteExecution.js +28 -12
- package/hooks/useSwapRoutes.js +3 -4
- package/hooks/useToken.d.ts +0 -1
- package/hooks/useToken.js +1 -2
- package/hooks/useTokenBalances.d.ts +1 -2
- package/hooks/useTokenBalances.js +4 -5
- package/hooks/useTokenSearch.js +3 -2
- package/hooks/useTokens.d.ts +1 -2
- package/hooks/useTokens.js +32 -9
- package/hooks/useTools.js +11 -5
- package/hooks/useWidgetEvents.d.ts +3 -3
- package/hooks/useWidgetEvents.js +2 -2
- package/i18n/en/translation.json +2 -3
- package/i18n/index.d.ts +1 -2
- package/index.d.ts +2 -1
- package/package.json +9 -8
- package/pages/MainPage/MainSwapButton.js +1 -1
- package/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/pages/SettingsPage/GasPriceSelect.js +2 -2
- package/pages/SettingsPage/RoutePrioritySelect.js +2 -2
- package/pages/SettingsPage/ShowDestinationWallet.js +2 -2
- package/pages/SettingsPage/SlippageInput.js +2 -2
- package/pages/SwapDetailsPage/SwapDetailsPage.js +3 -4
- package/pages/SwapHistoryPage/SwapHistoryPage.js +3 -4
- package/pages/SwapPage/SwapPage.js +11 -2
- package/pages/SwapRoutesPage/SwapRoutesPage.js +5 -4
- package/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/providers/SDKProvider/SDKProvider.js +19 -0
- package/providers/SDKProvider/index.d.ts +1 -0
- package/providers/SDKProvider/index.js +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +4 -58
- package/providers/SwapFormProvider/types.d.ts +5 -5
- package/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/providers/TelemetryProvider/TelemetryProvider.js +7 -0
- package/providers/TelemetryProvider/index.d.ts +1 -0
- package/providers/TelemetryProvider/index.js +1 -0
- package/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/providers/WalletProvider/WalletProvider.js +59 -1
- package/providers/WidgetProvider/WidgetProvider.js +3 -14
- package/providers/WidgetProvider/index.d.ts +1 -0
- package/providers/WidgetProvider/index.js +1 -0
- package/providers/WidgetProvider/utils.d.ts +4 -0
- package/providers/WidgetProvider/utils.js +9 -0
- package/providers/index.d.ts +2 -0
- package/providers/index.js +2 -0
- package/stores/chains/index.d.ts +0 -1
- package/stores/chains/index.js +0 -1
- package/stores/chains/types.d.ts +1 -1
- package/stores/chains/useChainOrderStore.js +17 -14
- package/stores/route/utils.d.ts +2 -1
- package/stores/route/utils.js +12 -0
- package/stores/settings/index.d.ts +0 -1
- package/stores/settings/index.js +0 -1
- package/stores/settings/useAppearance.js +3 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +15 -3
- package/types/events.js +4 -3
- package/types/widget.d.ts +29 -22
- package/utils/colors.d.ts +1 -1
- package/cjs/config/lifi.d.ts +0 -4
- package/cjs/config/lifi.js +0 -14
- package/cjs/stores/chains/useInitializeChainOrder.d.ts +0 -1
- package/cjs/stores/chains/useInitializeChainOrder.js +0 -12
- package/cjs/stores/settings/useSetSettings.d.ts +0 -5
- package/cjs/stores/settings/useSetSettings.js +0 -12
- package/config/lifi.d.ts +0 -4
- package/config/lifi.js +0 -7
- package/stores/chains/useInitializeChainOrder.d.ts +0 -1
- package/stores/chains/useInitializeChainOrder.js +0 -5
- package/stores/settings/useSetSettings.d.ts +0 -5
- package/stores/settings/useSetSettings.js +0 -5
package/AppDrawer.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { DrawerProps } from '@mui/material';
|
|
2
2
|
import type { RefObject } from 'react';
|
|
3
3
|
import type { WidgetConfig } from './types';
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type WidgetDrawerProps = DrawerProps & {
|
|
5
5
|
elementRef?: RefObject<HTMLDivElement>;
|
|
6
6
|
config?: WidgetConfig;
|
|
7
7
|
};
|
|
8
|
-
export interface
|
|
8
|
+
export interface WidgetDrawer {
|
|
9
9
|
isOpen(): void;
|
|
10
10
|
toggleDrawer(): void;
|
|
11
11
|
openDrawer(): void;
|
|
12
12
|
closeDrawer(): void;
|
|
13
13
|
}
|
|
14
|
-
export declare const AppDrawer: import("react").ForwardRefExoticComponent<Pick<
|
|
14
|
+
export declare const AppDrawer: import("react").ForwardRefExoticComponent<Pick<WidgetDrawerProps, "className" | "style" | "classes" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "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" | "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" | "transitionDuration" | "variant" | "open" | "anchor" | "elementRef" | "components" | "componentsProps" | "BackdropComponent" | "BackdropProps" | "closeAfterTransition" | "container" | "disableAutoFocus" | "disableEnforceFocus" | "disableEscapeKeyDown" | "disablePortal" | "disableRestoreFocus" | "disableScrollLock" | "hideBackdrop" | "keepMounted" | "onBackdropClick" | "onClose" | "config" | "elevation" | "ModalProps" | "PaperProps" | "SlideProps"> & import("react").RefAttributes<WidgetDrawer>>;
|
package/AppProvider.d.ts
CHANGED
|
@@ -5,7 +5,3 @@ export interface AppProps {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const AppProvider: React.FC<PropsWithChildren<AppProps>>;
|
|
7
7
|
export declare const AppRouter: React.FC<PropsWithChildren<{}>>;
|
|
8
|
-
export declare const TelemetryProvider: React.FC<{
|
|
9
|
-
children: React.ReactElement<any, any> | null;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
}>;
|
package/AppProvider.js
CHANGED
|
@@ -3,21 +3,13 @@ import { QueryClientProvider } from '@tanstack/react-query';
|
|
|
3
3
|
import { Fragment } from 'react';
|
|
4
4
|
import { MemoryRouter, useInRouterContext } from 'react-router-dom';
|
|
5
5
|
import { queryClient } from './config/queryClient';
|
|
6
|
-
import {
|
|
7
|
-
import { SwapFormProvider } from './providers/SwapFormProvider';
|
|
8
|
-
import { ThemeProvider } from './providers/ThemeProvider';
|
|
9
|
-
import { WalletProvider } from './providers/WalletProvider';
|
|
10
|
-
import { WidgetProvider } from './providers/WidgetProvider';
|
|
6
|
+
import { SDKProvider, SwapFormProvider, TelemetryProvider, ThemeProvider, WalletProvider, WidgetProvider, } from './providers';
|
|
11
7
|
const QueryProvider = QueryClientProvider;
|
|
12
8
|
export const AppProvider = ({ children, config, }) => {
|
|
13
|
-
return (_jsx(QueryProvider, Object.assign({ client: queryClient }, { children: _jsx(
|
|
9
|
+
return (_jsx(QueryProvider, Object.assign({ client: queryClient }, { children: _jsx(WidgetProvider, Object.assign({ config: config }, { children: _jsx(SDKProvider, { children: _jsx(TelemetryProvider, { children: _jsx(SwapFormProvider, { children: _jsx(ThemeProvider, { children: _jsx(WalletProvider, { children: _jsx(AppRouter, { children: children }) }) }) }) }) }) })) })));
|
|
14
10
|
};
|
|
15
11
|
export const AppRouter = ({ children }) => {
|
|
16
12
|
const inRouterContext = useInRouterContext();
|
|
17
13
|
const Router = inRouterContext ? Fragment : MemoryRouter;
|
|
18
14
|
return _jsx(Router, { children: children });
|
|
19
15
|
};
|
|
20
|
-
export const TelemetryProvider = ({ children, disabled }) => {
|
|
21
|
-
useTelemetry(disabled);
|
|
22
|
-
return children;
|
|
23
|
-
};
|
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ Visit our [playground](https://testing.li.finance) to see how you can customize
|
|
|
83
83
|
|
|
84
84
|
## Documentation
|
|
85
85
|
|
|
86
|
-
[LI.FI Documentation](https://docs.li.fi)
|
|
86
|
+
[LI.FI Widget Documentation](https://docs.li.fi/integrate-li.fi-widget/li.fi-widget-overview)
|
|
87
87
|
|
|
88
88
|
## Changelog
|
|
89
89
|
|
package/cjs/AppDrawer.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { DrawerProps } from '@mui/material';
|
|
2
2
|
import type { RefObject } from 'react';
|
|
3
3
|
import type { WidgetConfig } from './types';
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type WidgetDrawerProps = DrawerProps & {
|
|
5
5
|
elementRef?: RefObject<HTMLDivElement>;
|
|
6
6
|
config?: WidgetConfig;
|
|
7
7
|
};
|
|
8
|
-
export interface
|
|
8
|
+
export interface WidgetDrawer {
|
|
9
9
|
isOpen(): void;
|
|
10
10
|
toggleDrawer(): void;
|
|
11
11
|
openDrawer(): void;
|
|
12
12
|
closeDrawer(): void;
|
|
13
13
|
}
|
|
14
|
-
export declare const AppDrawer: import("react").ForwardRefExoticComponent<Pick<
|
|
14
|
+
export declare const AppDrawer: import("react").ForwardRefExoticComponent<Pick<WidgetDrawerProps, "className" | "style" | "classes" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "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" | "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" | "transitionDuration" | "variant" | "open" | "anchor" | "elementRef" | "components" | "componentsProps" | "BackdropComponent" | "BackdropProps" | "closeAfterTransition" | "container" | "disableAutoFocus" | "disableEnforceFocus" | "disableEscapeKeyDown" | "disablePortal" | "disableRestoreFocus" | "disableScrollLock" | "hideBackdrop" | "keepMounted" | "onBackdropClick" | "onClose" | "config" | "elevation" | "ModalProps" | "PaperProps" | "SlideProps"> & import("react").RefAttributes<WidgetDrawer>>;
|
package/cjs/AppProvider.d.ts
CHANGED
|
@@ -5,7 +5,3 @@ export interface AppProps {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const AppProvider: React.FC<PropsWithChildren<AppProps>>;
|
|
7
7
|
export declare const AppRouter: React.FC<PropsWithChildren<{}>>;
|
|
8
|
-
export declare const TelemetryProvider: React.FC<{
|
|
9
|
-
children: React.ReactElement<any, any> | null;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
}>;
|
package/cjs/AppProvider.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AppRouter = exports.AppProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const react_router_dom_1 = require("react-router-dom");
|
|
8
8
|
const queryClient_1 = require("./config/queryClient");
|
|
9
|
-
const
|
|
10
|
-
const SwapFormProvider_1 = require("./providers/SwapFormProvider");
|
|
11
|
-
const ThemeProvider_1 = require("./providers/ThemeProvider");
|
|
12
|
-
const WalletProvider_1 = require("./providers/WalletProvider");
|
|
13
|
-
const WidgetProvider_1 = require("./providers/WidgetProvider");
|
|
9
|
+
const providers_1 = require("./providers");
|
|
14
10
|
const QueryProvider = react_query_1.QueryClientProvider;
|
|
15
11
|
const AppProvider = ({ children, config, }) => {
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(QueryProvider, Object.assign({ client: queryClient_1.queryClient }, { children: (0, jsx_runtime_1.jsx)(
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(QueryProvider, Object.assign({ client: queryClient_1.queryClient }, { children: (0, jsx_runtime_1.jsx)(providers_1.WidgetProvider, Object.assign({ config: config }, { children: (0, jsx_runtime_1.jsx)(providers_1.SDKProvider, { children: (0, jsx_runtime_1.jsx)(providers_1.TelemetryProvider, { children: (0, jsx_runtime_1.jsx)(providers_1.SwapFormProvider, { children: (0, jsx_runtime_1.jsx)(providers_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(providers_1.WalletProvider, { children: (0, jsx_runtime_1.jsx)(exports.AppRouter, { children: children }) }) }) }) }) }) })) })));
|
|
17
13
|
};
|
|
18
14
|
exports.AppProvider = AppProvider;
|
|
19
15
|
const AppRouter = ({ children }) => {
|
|
@@ -22,8 +18,3 @@ const AppRouter = ({ children }) => {
|
|
|
22
18
|
return (0, jsx_runtime_1.jsx)(Router, { children: children });
|
|
23
19
|
};
|
|
24
20
|
exports.AppRouter = AppRouter;
|
|
25
|
-
const TelemetryProvider = ({ children, disabled }) => {
|
|
26
|
-
(0, hooks_1.useTelemetry)(disabled);
|
|
27
|
-
return children;
|
|
28
|
-
};
|
|
29
|
-
exports.TelemetryProvider = TelemetryProvider;
|
|
@@ -6,7 +6,7 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const styles_1 = require("@mui/material/styles");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const react_router_dom_1 = require("react-router-dom");
|
|
9
|
-
const
|
|
9
|
+
const providers_1 = require("../providers");
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const CssBaselineContainer = (0, styles_1.styled)(material_1.ScopedCssBaseline)(({ theme }) => ({
|
|
12
12
|
// height: '100%',
|
|
@@ -44,7 +44,7 @@ exports.FlexContainer = (0, styles_1.styled)(material_1.Container)({
|
|
|
44
44
|
});
|
|
45
45
|
const AppContainer = ({ children }) => {
|
|
46
46
|
const ref = (0, react_1.useRef)(null);
|
|
47
|
-
const { containerStyle } = (0,
|
|
47
|
+
const { containerStyle } = (0, providers_1.useWidgetConfig)();
|
|
48
48
|
return ((0, jsx_runtime_1.jsxs)(RelativeContainer, Object.assign({ sx: containerStyle }, { children: [(0, jsx_runtime_1.jsx)(ScrollableContainer, Object.assign({ id: utils_1.ElementId.ScrollableContainer, ref: ref }, { children: (0, jsx_runtime_1.jsx)(CssBaselineContainer, Object.assign({ enableColorScheme: true }, { children: (0, jsx_runtime_1.jsx)(exports.FlexContainer, Object.assign({ disableGutters: true }, { children: children })) })) })), (0, jsx_runtime_1.jsx)(exports.ScrollToLocation, { elementRef: ref })] })));
|
|
49
49
|
};
|
|
50
50
|
exports.AppContainer = AppContainer;
|
|
@@ -4,15 +4,15 @@ exports.ChainContainer = exports.ChainCard = void 0;
|
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
const Card_1 = require("../../components/Card");
|
|
7
|
-
exports.ChainCard = (0, styles_1.styled)(Card_1.Card)(
|
|
7
|
+
exports.ChainCard = (0, styles_1.styled)(Card_1.Card)({
|
|
8
8
|
display: 'grid',
|
|
9
9
|
placeItems: 'center',
|
|
10
|
-
|
|
10
|
+
minWidth: 56,
|
|
11
11
|
height: 56,
|
|
12
|
-
})
|
|
12
|
+
});
|
|
13
13
|
exports.ChainContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
14
14
|
display: 'grid',
|
|
15
|
-
gridTemplateColumns: 'repeat(auto-fit, 56px)',
|
|
15
|
+
gridTemplateColumns: 'repeat(auto-fit, minmax(56px, 1fr))',
|
|
16
16
|
gridAutoRows: '56px',
|
|
17
17
|
justifyContent: 'space-between',
|
|
18
18
|
gap: theme.spacing(1.5),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EVMChain } from '@lifi/sdk';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const useChainSelect: (formType:
|
|
2
|
+
import type { SwapFormType } from '../../providers';
|
|
3
|
+
export declare const useChainSelect: (formType: SwapFormType) => {
|
|
4
4
|
chains: EVMChain[] | undefined;
|
|
5
5
|
getChains: () => EVMChain[];
|
|
6
6
|
setCurrentChain: (chainId: number) => void;
|
|
@@ -23,15 +23,15 @@ const GasSufficiencyMessage = (_a) => {
|
|
|
23
23
|
var { route } = _a, props = __rest(_a, ["route"]);
|
|
24
24
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
25
25
|
const { insufficientFunds, insufficientGas } = (0, hooks_1.useGasSufficiency)(route);
|
|
26
|
-
if (!insufficientFunds && !insufficientGas.length) {
|
|
26
|
+
if (!insufficientFunds && !(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)) {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
return ((0, jsx_runtime_1.jsxs)(GasSufficiencyMessage_style_1.MessageCard, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.WarningAmber, { sx: {
|
|
30
30
|
marginTop: 2,
|
|
31
31
|
marginLeft: 2,
|
|
32
|
-
} }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [insufficientGas.length ? ((0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`swap.warning.title.insufficientGas`) })) : null, insufficientFunds ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length ? 0 : 2, pt: insufficientGas.length ? 1 : 2 }, { children: insufficientFunds
|
|
32
|
+
} }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? ((0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`swap.warning.title.insufficientGas`) })) : null, insufficientFunds ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", px: 2, pb: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 0 : 2, pt: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 1 : 2 }, { children: insufficientFunds
|
|
33
33
|
? t(`swap.warning.message.insufficientFunds`)
|
|
34
|
-
: null }))) : null, insufficientGas.length ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", px: 2, pt: 1 }, { children: t(`swap.warning.message.insufficientGas`) }))) : null, insufficientGas.length
|
|
34
|
+
: null }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", px: 2, pt: 1 }, { children: t(`swap.warning.message.insufficientGas`) }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)
|
|
35
35
|
? insufficientGas.map((item, index) => {
|
|
36
36
|
var _a, _b;
|
|
37
37
|
return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length - 1 === index ? 2 : 0, pt: 0.5 }, { children: t(`swap.tokenOnChainAmount`, {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { HeaderActionStore } from './types';
|
|
3
2
|
export declare const useHeaderActionStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<HeaderActionStore>, "setState"> & {
|
|
4
3
|
setState(nextStateOrUpdater: HeaderActionStore | Partial<HeaderActionStore> | ((state: import("immer/dist/internal").WritableDraft<HeaderActionStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
5
4
|
}>;
|
|
6
|
-
export declare const useSetHeaderAction: () => (element?: import("react").ReactNode) => () => void;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.useHeaderActionStore = void 0;
|
|
7
7
|
/* eslint-disable no-underscore-dangle */
|
|
8
8
|
const zustand_1 = __importDefault(require("zustand"));
|
|
9
9
|
const immer_1 = require("zustand/middleware/immer");
|
|
@@ -20,7 +20,3 @@ exports.useHeaderActionStore = (0, zustand_1.default)()((0, immer_1.immer)((set,
|
|
|
20
20
|
});
|
|
21
21
|
},
|
|
22
22
|
})));
|
|
23
|
-
const useSetHeaderAction = () => {
|
|
24
|
-
return (0, exports.useHeaderActionStore)((state) => state.setAction);
|
|
25
|
-
};
|
|
26
|
-
exports.useSetHeaderAction = useSetHeaderAction;
|
|
@@ -6,15 +6,15 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
7
|
const ReverseTokensButton_1 = require("../components/ReverseTokensButton");
|
|
8
8
|
const SelectTokenButton_1 = require("../components/SelectTokenButton");
|
|
9
|
-
const
|
|
9
|
+
const providers_1 = require("../providers");
|
|
10
10
|
const SelectChainAndToken = (props) => {
|
|
11
11
|
const prefersNarrowView = (0, material_1.useMediaQuery)((theme) => theme.breakpoints.down('sm'));
|
|
12
12
|
const [fromChain, toChain, fromToken, toToken] = (0, react_hook_form_1.useWatch)({
|
|
13
13
|
name: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
providers_1.SwapFormKey.FromChain,
|
|
15
|
+
providers_1.SwapFormKey.ToChain,
|
|
16
|
+
providers_1.SwapFormKey.FromToken,
|
|
17
|
+
providers_1.SwapFormKey.ToToken,
|
|
18
18
|
],
|
|
19
19
|
});
|
|
20
20
|
const isCompact = fromChain && toChain && fromToken && toToken && !prefersNarrowView;
|
|
@@ -11,51 +11,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SwapButton = void 0;
|
|
13
13
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
-
const sdk_1 = require("@lifi/sdk");
|
|
15
14
|
const material_1 = require("@mui/material");
|
|
16
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
17
15
|
const react_i18next_1 = require("react-i18next");
|
|
18
16
|
const react_router_dom_1 = require("react-router-dom");
|
|
19
17
|
const hooks_1 = require("../../hooks");
|
|
20
18
|
const providers_1 = require("../../providers");
|
|
21
19
|
const utils_1 = require("../../utils");
|
|
22
20
|
const SwapButton = ({ onClick, currentRoute, text, disable, }) => {
|
|
23
|
-
var _a;
|
|
24
21
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
25
22
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
26
|
-
const { getChainById } = (0, hooks_1.useChains)();
|
|
27
23
|
const config = (0, providers_1.useWidgetConfig)();
|
|
28
|
-
const { account,
|
|
24
|
+
const { account, connect } = (0, providers_1.useWallet)();
|
|
29
25
|
const { insufficientFunds, insufficientGas } = (0, hooks_1.useGasSufficiency)(currentRoute);
|
|
30
|
-
const [chainId] = (0, react_hook_form_1.useWatch)({
|
|
31
|
-
name: [providers_1.SwapFormKeyHelper.getChainKey('from')],
|
|
32
|
-
});
|
|
33
|
-
// Allow switching chain only if execution is not started
|
|
34
|
-
const switchChainAllowed = ((_a = getChainById(chainId || sdk_1.ChainId.ETH)) === null || _a === void 0 ? void 0 : _a.id) !== account.chainId &&
|
|
35
|
-
currentRoute &&
|
|
36
|
-
!currentRoute.steps.some((step) => step.execution);
|
|
37
26
|
const handleSwapButtonClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
27
|
if (!account.isActive) {
|
|
39
28
|
if (config.walletManagement) {
|
|
40
|
-
yield
|
|
29
|
+
yield connect();
|
|
41
30
|
}
|
|
42
31
|
else {
|
|
43
32
|
navigate(utils_1.navigationRoutes.selectWallet);
|
|
44
33
|
}
|
|
45
34
|
}
|
|
46
|
-
else if (switchChainAllowed) {
|
|
47
|
-
yield switchChain(chainId);
|
|
48
|
-
// check that the current route exists in the up to date route list
|
|
49
|
-
}
|
|
50
35
|
else {
|
|
51
36
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
52
37
|
}
|
|
53
38
|
});
|
|
54
39
|
const getButtonText = () => {
|
|
55
40
|
if (account.isActive) {
|
|
56
|
-
if (switchChainAllowed) {
|
|
57
|
-
return t(`button.switchChain`);
|
|
58
|
-
}
|
|
59
41
|
if (!currentRoute) {
|
|
60
42
|
return t(`button.swap`);
|
|
61
43
|
}
|
|
@@ -63,8 +45,6 @@ const SwapButton = ({ onClick, currentRoute, text, disable, }) => {
|
|
|
63
45
|
}
|
|
64
46
|
return t(`button.connectWallet`);
|
|
65
47
|
};
|
|
66
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled:
|
|
67
|
-
!switchChainAllowed &&
|
|
68
|
-
(insufficientFunds || !!insufficientGas.length || disable), fullWidth: true }, { children: getButtonText() })));
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled: insufficientFunds || !!(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) || disable, fullWidth: true }, { children: getButtonText() })));
|
|
69
49
|
};
|
|
70
50
|
exports.SwapButton = SwapButton;
|
|
@@ -53,6 +53,6 @@ const TokenList = ({ formType, height, onClick, }) => {
|
|
|
53
53
|
}
|
|
54
54
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
55
55
|
}, [formType, getValues, onClick, setValue]);
|
|
56
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!tokens.length && !isLoading ? (0, jsx_runtime_1.jsx)(TokenNotFound_1.TokenNotFound, {}) : null, (0, jsx_runtime_1.jsx)(VirtualizedTokenList_1.VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] })));
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!tokens.length && !isLoading ? ((0, jsx_runtime_1.jsx)(TokenNotFound_1.TokenNotFound, { formType: formType })) : null, (0, jsx_runtime_1.jsx)(VirtualizedTokenList_1.VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] })));
|
|
57
57
|
};
|
|
58
58
|
exports.TokenList = TokenList;
|
|
@@ -7,7 +7,8 @@ const styles_1 = require("@mui/material/styles");
|
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
8
|
exports.ListItemButton = (0, styles_1.styled)(material_1.ListItemButton)(({ theme }) => ({
|
|
9
9
|
borderRadius: theme.shape.borderRadiusSecondary,
|
|
10
|
-
paddingLeft: theme.spacing(
|
|
10
|
+
paddingLeft: theme.spacing(1.5),
|
|
11
|
+
paddingRight: theme.spacing(1.5),
|
|
11
12
|
height: 64,
|
|
12
13
|
width: '100%',
|
|
13
14
|
'&:hover': {
|
|
@@ -21,8 +22,8 @@ exports.ListItem = (0, styles_1.styled)(material_1.ListItem)(({ theme }) => ({
|
|
|
21
22
|
height: 64,
|
|
22
23
|
flexDirection: 'column',
|
|
23
24
|
alignItems: 'flex-start',
|
|
24
|
-
padding: theme.spacing(0,
|
|
25
|
+
padding: theme.spacing(0, 1.5),
|
|
25
26
|
[`.${ListItemSecondaryAction_1.listItemSecondaryActionClasses.root}`]: {
|
|
26
|
-
right: theme.spacing(
|
|
27
|
+
right: theme.spacing(3),
|
|
27
28
|
},
|
|
28
29
|
}));
|
|
@@ -19,7 +19,7 @@ exports.TokenListItem = (0, react_1.memo)(({ onClick, size, start, token, showBa
|
|
|
19
19
|
}) }))) : null] })))) : null] })), endAdornment] })));
|
|
20
20
|
});
|
|
21
21
|
const TokenListItemSkeleton = () => {
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItem, Object.assign({ secondaryAction: (0, jsx_runtime_1.jsx)(exports.TokenAmountSkeleton, {}), disablePadding: true, sx: { position: 'relative', flexDirection: 'row', alignItems: 'center' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "circular", width: 32, height: 32, sx: { marginLeft:
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItem, Object.assign({ secondaryAction: (0, jsx_runtime_1.jsx)(exports.TokenAmountSkeleton, {}), disablePadding: true, sx: { position: 'relative', flexDirection: 'row', alignItems: 'center' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "circular", width: 32, height: 32, sx: { marginLeft: 1.5, marginRight: 2 } }) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 48, height: 20 }), secondary: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 96, height: 20 }) })] })));
|
|
23
23
|
};
|
|
24
24
|
exports.TokenListItemSkeleton = TokenListItemSkeleton;
|
|
25
25
|
const TokenAmountSkeleton = () => {
|
|
@@ -4,9 +4,17 @@ exports.TokenNotFound = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
7
8
|
const react_i18next_1 = require("react-i18next");
|
|
8
|
-
const
|
|
9
|
+
const hooks_1 = require("../../hooks");
|
|
10
|
+
const providers_1 = require("../../providers");
|
|
11
|
+
const TokenNotFound = ({ formType }) => {
|
|
12
|
+
var _a;
|
|
9
13
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
14
|
+
const [selectedChainId] = (0, react_hook_form_1.useWatch)({
|
|
15
|
+
name: [providers_1.SwapFormKeyHelper.getChainKey(formType)],
|
|
16
|
+
});
|
|
17
|
+
const { getChainById } = (0, hooks_1.useChains)();
|
|
10
18
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
|
|
11
19
|
display: 'flex',
|
|
12
20
|
justifyContent: 'center',
|
|
@@ -14,6 +22,8 @@ const TokenNotFound = () => {
|
|
|
14
22
|
flexDirection: 'column',
|
|
15
23
|
flex: 1,
|
|
16
24
|
padding: 3,
|
|
17
|
-
} }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 48, lineHeight: 1 }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SearchOff, { fontSize: "inherit" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2, px: 2 }, { children: t('swap.
|
|
25
|
+
} }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 48, lineHeight: 1 }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SearchOff, { fontSize: "inherit" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2, px: 2 }, { children: t('swap.info.message.emptyTokenList', {
|
|
26
|
+
chainName: (_a = getChainById(selectedChainId)) === null || _a === void 0 ? void 0 : _a.name,
|
|
27
|
+
}) }))] })));
|
|
18
28
|
};
|
|
19
29
|
exports.TokenNotFound = TokenNotFound;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TokenAmount } from '@lifi/sdk';
|
|
2
2
|
import type { MutableRefObject } from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SwapFormType } from '../../providers';
|
|
4
4
|
import type { Token } from '../../types';
|
|
5
5
|
export interface TokenListProps {
|
|
6
|
-
formType:
|
|
6
|
+
formType: SwapFormType;
|
|
7
7
|
height: number;
|
|
8
8
|
onClick?(): void;
|
|
9
9
|
}
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.17.1";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/useChains.js
CHANGED
|
@@ -12,25 +12,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.useChains = void 0;
|
|
13
13
|
const react_query_1 = require("@tanstack/react-query");
|
|
14
14
|
const react_1 = require("react");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
16
|
+
const providers_1 = require("../providers");
|
|
17
17
|
const chains_1 = require("../stores/chains");
|
|
18
18
|
const useChains = () => {
|
|
19
|
-
const { disabledChains } = (0,
|
|
20
|
-
const
|
|
19
|
+
const { disabledChains, chains } = (0, providers_1.useWidgetConfig)();
|
|
20
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
21
|
+
const { getValues, setValue } = (0, react_hook_form_1.useFormContext)();
|
|
21
22
|
const { data, isLoading } = (0, react_query_1.useQuery)(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
const
|
|
23
|
-
const filteredChains =
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const availableChains = yield lifi.getChains();
|
|
24
|
+
const filteredChains = availableChains.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains, disabledChains));
|
|
25
|
+
const chainOrder = chains_1.useChainOrderStore
|
|
26
|
+
.getState()
|
|
27
|
+
.initializeChains(filteredChains.map((chain) => chain.id));
|
|
28
|
+
const [fromChainValue, toChainValue] = getValues([
|
|
29
|
+
providers_1.SwapFormKey.FromChain,
|
|
30
|
+
providers_1.SwapFormKey.ToChain,
|
|
31
|
+
]);
|
|
32
|
+
if (!fromChainValue) {
|
|
33
|
+
setValue(providers_1.SwapFormKey.FromChain, chainOrder[0]);
|
|
34
|
+
}
|
|
35
|
+
if (!toChainValue) {
|
|
36
|
+
setValue(providers_1.SwapFormKey.ToChain, chainOrder[0]);
|
|
37
|
+
}
|
|
38
|
+
return { availableChains, filteredChains };
|
|
26
39
|
}));
|
|
27
40
|
const getChainById = (0, react_1.useCallback)((chainId) => {
|
|
28
|
-
const chain = data === null || data === void 0 ? void 0 : data.find((chain) => chain.id === chainId);
|
|
41
|
+
const chain = data === null || data === void 0 ? void 0 : data.availableChains.find((chain) => chain.id === chainId);
|
|
29
42
|
// if (!chain) {
|
|
30
43
|
// throw new Error('Chain not found or chainId is invalid.');
|
|
31
44
|
// }
|
|
32
45
|
return chain;
|
|
33
46
|
}, [data]);
|
|
34
|
-
return { chains: data, getChainById, isLoading };
|
|
47
|
+
return { chains: data === null || data === void 0 ? void 0 : data.filteredChains, getChainById, isLoading };
|
|
35
48
|
};
|
|
36
49
|
exports.useChains = useChains;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useFeaturedTokens: (selectedChainId
|
|
1
|
+
export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").Token[];
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useFeaturedTokens = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const providers_1 = require("../providers");
|
|
6
6
|
const useFeaturedTokens = (selectedChainId) => {
|
|
7
|
-
const { featuredTokens } = (0,
|
|
8
|
-
return (0, react_1.useMemo)(() =>
|
|
7
|
+
const { featuredTokens, tokens } = (0, providers_1.useWidgetConfig)();
|
|
8
|
+
return (0, react_1.useMemo)(() => {
|
|
9
|
+
var _a;
|
|
10
|
+
return [...((_a = tokens === null || tokens === void 0 ? void 0 : tokens.featured) !== null && _a !== void 0 ? _a : []), ...(featuredTokens !== null && featuredTokens !== void 0 ? featuredTokens : [])].filter((token) => token.chainId === selectedChainId);
|
|
11
|
+
}, [featuredTokens, selectedChainId, tokens === null || tokens === void 0 ? void 0 : tokens.featured]);
|
|
9
12
|
};
|
|
10
13
|
exports.useFeaturedTokens = useFeaturedTokens;
|