@lifi/widget 1.26.2 → 1.26.3
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.style.d.ts +1 -1
- package/cjs/AppDrawer.style.d.ts +1 -1
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
- package/cjs/components/Header/Header.style.d.ts +1 -1
- package/cjs/components/Header/useHeaderActionStore.d.ts +1 -3
- package/cjs/components/Header/useHeaderActionStore.js +8 -9
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/cjs/components/SendToWallet/SendToWallet.js +1 -1
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/cjs/components/SendToWallet/store.d.ts +1 -3
- package/cjs/components/SendToWallet/store.js +5 -6
- package/cjs/components/Step/StepProcess.style.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useWidgetEvents.d.ts +2 -2
- package/cjs/hooks/useWidgetEvents.js +3 -4
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +2 -1
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/cjs/stores/chains/useChainOrderStore.d.ts +1 -3
- package/cjs/stores/chains/useChainOrderStore.js +28 -17
- package/cjs/stores/routes/useRecommendedRouteStore.d.ts +1 -3
- package/cjs/stores/routes/useRecommendedRouteStore.js +6 -7
- package/cjs/stores/routes/useRouteExecutionStore.d.ts +1 -3
- package/cjs/stores/routes/useRouteExecutionStore.js +75 -47
- package/cjs/stores/settings/useSettingsStore.d.ts +1 -3
- package/cjs/stores/settings/useSettingsStore.js +36 -31
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
- package/components/Header/Header.style.d.ts +1 -1
- package/components/Header/useHeaderActionStore.d.ts +1 -3
- package/components/Header/useHeaderActionStore.js +8 -9
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/components/SendToWallet/SendToWallet.js +1 -1
- package/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/components/SendToWallet/store.d.ts +1 -3
- package/components/SendToWallet/store.js +5 -6
- package/components/Step/StepProcess.style.d.ts +1 -1
- package/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useWidgetEvents.d.ts +2 -2
- package/hooks/useWidgetEvents.js +2 -3
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +7 -8
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/stores/chains/useChainOrderStore.d.ts +1 -3
- package/stores/chains/useChainOrderStore.js +28 -17
- package/stores/routes/useRecommendedRouteStore.d.ts +1 -3
- package/stores/routes/useRecommendedRouteStore.js +6 -7
- package/stores/routes/useRouteExecutionStore.d.ts +1 -3
- package/stores/routes/useRouteExecutionStore.js +75 -47
- package/stores/settings/useSettingsStore.d.ts +1 -3
- package/stores/settings/useSettingsStore.js +36 -31
- package/tsconfig.cjs.tsbuildinfo +1 -1
package/AppDrawer.style.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const DrawerButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "
|
|
5
|
+
color?: "inherit" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
package/cjs/AppDrawer.style.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const DrawerButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "
|
|
5
|
+
color?: "inherit" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -39,7 +39,7 @@ export declare const ListItem: import("@emotion/styled").StyledComponent<{
|
|
|
39
39
|
export declare const ShowAllButton: import("@emotion/styled").StyledComponent<{
|
|
40
40
|
children?: import("react").ReactNode;
|
|
41
41
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
42
|
-
color?: "inherit" | "
|
|
42
|
+
color?: "inherit" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
43
43
|
disabled?: boolean | undefined;
|
|
44
44
|
disableElevation?: boolean | undefined;
|
|
45
45
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -21,7 +21,7 @@ export declare const Container: import("@emotion/styled").StyledComponent<import
|
|
|
21
21
|
export declare const WalletButton: import("@emotion/styled").StyledComponent<{
|
|
22
22
|
children?: import("react").ReactNode;
|
|
23
23
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
24
|
-
color?: "inherit" | "
|
|
24
|
+
color?: "inherit" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
25
25
|
disabled?: boolean | undefined;
|
|
26
26
|
disableElevation?: boolean | undefined;
|
|
27
27
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import type { HeaderActionStore } from './types';
|
|
2
|
-
export declare const useHeaderActionStore: import("zustand").UseBoundStore<
|
|
3
|
-
setState(nextStateOrUpdater: HeaderActionStore | Partial<HeaderActionStore> | ((state: import("immer/dist/internal").WritableDraft<HeaderActionStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
4
|
-
}>;
|
|
2
|
+
export declare const useHeaderActionStore: import("zustand").UseBoundStore<import("zustand").StoreApi<HeaderActionStore>>;
|
|
@@ -3,17 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useHeaderActionStore = void 0;
|
|
4
4
|
/* eslint-disable no-underscore-dangle */
|
|
5
5
|
const zustand_1 = require("zustand");
|
|
6
|
-
|
|
7
|
-
exports.useHeaderActionStore = (0, zustand_1.default)()((0, immer_1.immer)((set, get) => ({
|
|
6
|
+
exports.useHeaderActionStore = (0, zustand_1.default)((set, get) => ({
|
|
8
7
|
setAction: (element) => {
|
|
9
|
-
set((
|
|
10
|
-
|
|
11
|
-
});
|
|
8
|
+
set(() => ({
|
|
9
|
+
element,
|
|
10
|
+
}));
|
|
12
11
|
return get().removeAction;
|
|
13
12
|
},
|
|
14
13
|
removeAction: () => {
|
|
15
|
-
set((
|
|
16
|
-
|
|
17
|
-
});
|
|
14
|
+
set(() => ({
|
|
15
|
+
element: null,
|
|
16
|
+
}));
|
|
18
17
|
},
|
|
19
|
-
}))
|
|
18
|
+
}));
|
|
@@ -2,7 +2,7 @@
|
|
|
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" | "
|
|
5
|
+
color?: "inherit" | "default" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
@@ -49,7 +49,7 @@ exports.SendToWallet = (0, react_1.forwardRef)((props, ref) => {
|
|
|
49
49
|
}),
|
|
50
50
|
onBlur: () => trigger(providers_1.SwapFormKey.ToAddress),
|
|
51
51
|
});
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ timeout: 225, in: showSendToWallet, mountOnEnter: true, unmountOnExit: true }, { children: (0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { ref: ref }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.sendToWallet') }), (0, jsx_runtime_1.jsxs)(SendToWallet_style_1.FormControl, Object.assign({ fullWidth: true, sx: { paddingTop: '6px', paddingBottom: '5px' } }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_style_1.Input, { ref: inputRef, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns')
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ timeout: 225, in: showSendToWallet, mountOnEnter: true, unmountOnExit: true }, { children: (0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { ref: ref }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.sendToWallet') }), (0, jsx_runtime_1.jsxs)(SendToWallet_style_1.FormControl, Object.assign({ fullWidth: true, sx: { paddingTop: '6px', paddingBottom: '5px' } }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_style_1.Input, { ref: inputRef, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns') }), (0, jsx_runtime_1.jsx)(exports.SendToWalletFormHelperText, {})] }))] })) })));
|
|
53
53
|
});
|
|
54
54
|
const SendToWalletFormHelperText = () => {
|
|
55
55
|
var _a;
|
|
@@ -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?: "
|
|
5
|
+
color?: "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
error?: boolean | undefined;
|
|
8
8
|
fullWidth?: boolean | undefined;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import type { SendToWalletStore } from './types';
|
|
2
|
-
export declare const useSendToWalletStore: import("zustand").UseBoundStore<
|
|
3
|
-
setState(nextStateOrUpdater: SendToWalletStore | Partial<SendToWalletStore> | ((state: import("immer/dist/internal").WritableDraft<SendToWalletStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
4
|
-
}>;
|
|
2
|
+
export declare const useSendToWalletStore: import("zustand").UseBoundStore<import("zustand").StoreApi<SendToWalletStore>>;
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSendToWalletStore = void 0;
|
|
4
4
|
const zustand_1 = require("zustand");
|
|
5
|
-
|
|
6
|
-
exports.useSendToWalletStore = (0, zustand_1.default)()((0, immer_1.immer)((set) => ({
|
|
5
|
+
exports.useSendToWalletStore = (0, zustand_1.default)((set) => ({
|
|
7
6
|
showSendToWallet: false,
|
|
8
7
|
toggleSendToWallet: () => {
|
|
9
|
-
set((state) => {
|
|
10
|
-
|
|
11
|
-
});
|
|
8
|
+
set((state) => ({
|
|
9
|
+
showSendToWallet: !state.showSendToWallet,
|
|
10
|
+
}));
|
|
12
11
|
},
|
|
13
|
-
}))
|
|
12
|
+
}));
|
|
@@ -2,7 +2,7 @@
|
|
|
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" | "
|
|
5
|
+
color?: "inherit" | "default" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
@@ -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?: "
|
|
7
|
+
color?: "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
error?: boolean | undefined;
|
|
10
10
|
fullWidth?: boolean | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
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" | "
|
|
5
|
+
color?: "inherit" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -17,7 +17,7 @@ export declare const Label: import("@emotion/styled").StyledComponent<import("@m
|
|
|
17
17
|
export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
18
18
|
children?: import("react").ReactNode;
|
|
19
19
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
20
|
-
color?: "inherit" | "default" | "
|
|
20
|
+
color?: "inherit" | "default" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
21
21
|
disabled?: boolean | undefined;
|
|
22
22
|
disableFocusRipple?: boolean | undefined;
|
|
23
23
|
edge?: false | "end" | "start" | undefined;
|
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.26.
|
|
2
|
+
export declare const version = "1.26.3";
|
package/cjs/config/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Emitter } from 'mitt';
|
|
2
1
|
import type { WidgetEvents } from '../types';
|
|
3
|
-
export declare const
|
|
2
|
+
export declare const widgetEvents: import("mitt").Emitter<WidgetEvents>;
|
|
3
|
+
export declare const useWidgetEvents: () => import("mitt").Emitter<WidgetEvents>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useWidgetEvents = void 0;
|
|
3
|
+
exports.useWidgetEvents = exports.widgetEvents = void 0;
|
|
4
4
|
const mitt_1 = require("mitt");
|
|
5
|
-
|
|
6
|
-
const emitterStore = (0, zustand_1.default)()(() => (0, mitt_1.default)());
|
|
5
|
+
exports.widgetEvents = (0, mitt_1.default)();
|
|
7
6
|
const useWidgetEvents = () => {
|
|
8
|
-
return
|
|
7
|
+
return exports.widgetEvents;
|
|
9
8
|
};
|
|
10
9
|
exports.useWidgetEvents = useWidgetEvents;
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './fonts/inter.css';
|
|
3
3
|
export type { WidgetDrawer } from './AppDrawer';
|
|
4
|
-
export { useWidgetEvents } from './hooks';
|
|
4
|
+
export { useWidgetEvents, widgetEvents } from './hooks';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export declare const LiFiWidget: import("react").FC<import("./types").WidgetProps>;
|
|
7
7
|
/**
|
package/cjs/index.js
CHANGED
|
@@ -14,12 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.LiFiWidgetDrawer = exports.LiFiWidget = exports.useWidgetEvents = void 0;
|
|
17
|
+
exports.LiFiWidgetDrawer = exports.LiFiWidget = exports.widgetEvents = exports.useWidgetEvents = void 0;
|
|
18
18
|
const App_1 = require("./App");
|
|
19
19
|
const AppDrawer_1 = require("./AppDrawer");
|
|
20
20
|
require("./fonts/inter.css");
|
|
21
21
|
var hooks_1 = require("./hooks");
|
|
22
22
|
Object.defineProperty(exports, "useWidgetEvents", { enumerable: true, get: function () { return hooks_1.useWidgetEvents; } });
|
|
23
|
+
Object.defineProperty(exports, "widgetEvents", { enumerable: true, get: function () { return hooks_1.widgetEvents; } });
|
|
23
24
|
__exportStar(require("./types"), exports);
|
|
24
25
|
// ClassNameGenerator.configure((componentName) =>
|
|
25
26
|
// componentName.replace('Mui', 'LiFi'),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const ToggleButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ToggleButtonClasses> | undefined;
|
|
5
|
-
color?: "
|
|
5
|
+
color?: "success" | "warning" | "error" | "primary" | "secondary" | "info" | "standard" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
fullWidth?: boolean | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChainOrderStore } from './types';
|
|
2
2
|
export declare const maxChainToOrder = 9;
|
|
3
|
-
export declare const useChainOrderStore: import("zustand").UseBoundStore<Omit<
|
|
3
|
+
export declare const useChainOrderStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<ChainOrderStore>, "persist"> & {
|
|
4
4
|
persist: {
|
|
5
5
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<ChainOrderStore, {
|
|
6
6
|
chainOrder: number[];
|
|
@@ -14,6 +14,4 @@ export declare const useChainOrderStore: import("zustand").UseBoundStore<Omit<Om
|
|
|
14
14
|
chainOrder: number[];
|
|
15
15
|
}>>;
|
|
16
16
|
};
|
|
17
|
-
}, "setState"> & {
|
|
18
|
-
setState(nextStateOrUpdater: ChainOrderStore | Partial<ChainOrderStore> | ((state: import("immer/dist/internal").WritableDraft<ChainOrderStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
19
17
|
}>;
|
|
@@ -4,38 +4,49 @@ exports.useChainOrderStore = exports.maxChainToOrder = void 0;
|
|
|
4
4
|
/* eslint-disable no-underscore-dangle */
|
|
5
5
|
const zustand_1 = require("zustand");
|
|
6
6
|
const middleware_1 = require("zustand/middleware");
|
|
7
|
-
const immer_1 = require("zustand/middleware/immer");
|
|
8
7
|
exports.maxChainToOrder = 9;
|
|
9
|
-
exports.useChainOrderStore = (0, zustand_1.default)()((0, middleware_1.persist)((
|
|
8
|
+
exports.useChainOrderStore = (0, zustand_1.default)()((0, middleware_1.persist)((set, get) => ({
|
|
10
9
|
chainOrder: [],
|
|
11
10
|
availableChains: [],
|
|
12
11
|
initializeChains: (chainIds) => {
|
|
13
12
|
set((state) => {
|
|
14
|
-
state.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const chainOrder = state.chainOrder.filter((chainId) => chainIds.includes(chainId));
|
|
14
|
+
const chainsToAdd = chainIds.filter((chainId) => !chainOrder.includes(chainId));
|
|
15
|
+
if (chainOrder.length === exports.maxChainToOrder || !chainsToAdd.length) {
|
|
16
|
+
return {
|
|
17
|
+
availableChains: chainIds,
|
|
18
|
+
chainOrder,
|
|
19
|
+
};
|
|
20
20
|
}
|
|
21
|
-
const chainsToAddLength = exports.maxChainToOrder -
|
|
21
|
+
const chainsToAddLength = exports.maxChainToOrder - chainOrder.length;
|
|
22
22
|
for (let index = 0; index < chainsToAddLength; index++) {
|
|
23
|
-
|
|
23
|
+
chainOrder.push(chainsToAdd[index]);
|
|
24
24
|
}
|
|
25
|
+
return {
|
|
26
|
+
availableChains: chainIds,
|
|
27
|
+
chainOrder,
|
|
28
|
+
};
|
|
25
29
|
});
|
|
26
30
|
return get().chainOrder;
|
|
27
31
|
},
|
|
28
|
-
setChain: (chainId) =>
|
|
32
|
+
setChain: (chainId) => {
|
|
33
|
+
const state = get();
|
|
29
34
|
if (state.chainOrder.includes(chainId) ||
|
|
30
35
|
!state.availableChains.includes(chainId)) {
|
|
31
36
|
return;
|
|
32
37
|
}
|
|
33
|
-
state
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
38
|
+
set((state) => {
|
|
39
|
+
const chainOrder = state.chainOrder.slice();
|
|
40
|
+
chainOrder.unshift(chainId);
|
|
41
|
+
if (chainOrder.length > exports.maxChainToOrder) {
|
|
42
|
+
chainOrder.pop();
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
chainOrder,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
}), {
|
|
39
50
|
name: 'li.fi-widget-chains-order',
|
|
40
51
|
version: 0,
|
|
41
52
|
partialize: (state) => ({ chainOrder: state.chainOrder }),
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import type { RecommendedRouteStore } from './types';
|
|
2
|
-
export declare const useRecommendedRouteStore: import("zustand").UseBoundStore<
|
|
3
|
-
setState(nextStateOrUpdater: RecommendedRouteStore | Partial<RecommendedRouteStore> | ((state: import("immer/dist/internal").WritableDraft<RecommendedRouteStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
4
|
-
}>;
|
|
2
|
+
export declare const useRecommendedRouteStore: import("zustand").UseBoundStore<import("zustand").StoreApi<RecommendedRouteStore>>;
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRecommendedRouteStore = void 0;
|
|
4
4
|
const zustand_1 = require("zustand");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
5
|
+
exports.useRecommendedRouteStore = (0, zustand_1.default)((set) => ({
|
|
6
|
+
setRecommendedRoute: (recommendedRoute) => {
|
|
7
|
+
set(() => ({
|
|
8
|
+
recommendedRoute,
|
|
9
|
+
}));
|
|
11
10
|
},
|
|
12
|
-
}))
|
|
11
|
+
}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RouteExecutionStore } from './types';
|
|
2
|
-
export declare const useRouteExecutionStore: import("zustand").UseBoundStore<Omit<
|
|
2
|
+
export declare const useRouteExecutionStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<RouteExecutionStore>, "persist"> & {
|
|
3
3
|
persist: {
|
|
4
4
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<RouteExecutionStore, {
|
|
5
5
|
routes: Partial<Record<string, import("./types").RouteExecution>>;
|
|
@@ -13,6 +13,4 @@ export declare const useRouteExecutionStore: import("zustand").UseBoundStore<Omi
|
|
|
13
13
|
routes: Partial<Record<string, import("./types").RouteExecution>>;
|
|
14
14
|
}>>;
|
|
15
15
|
};
|
|
16
|
-
}, "setState"> & {
|
|
17
|
-
setState(nextStateOrUpdater: RouteExecutionStore | Partial<RouteExecutionStore> | ((state: import("immer/dist/internal").WritableDraft<RouteExecutionStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
18
16
|
}>;
|
|
@@ -3,68 +3,96 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useRouteExecutionStore = void 0;
|
|
4
4
|
const zustand_1 = require("zustand");
|
|
5
5
|
const middleware_1 = require("zustand/middleware");
|
|
6
|
-
const immer_1 = require("zustand/middleware/immer");
|
|
7
6
|
const utils_1 = require("../../utils");
|
|
8
7
|
const types_1 = require("./types");
|
|
9
8
|
const utils_2 = require("./utils");
|
|
10
|
-
exports.useRouteExecutionStore = (0, zustand_1.default)()((0, middleware_1.persist)((
|
|
9
|
+
exports.useRouteExecutionStore = (0, zustand_1.default)()((0, middleware_1.persist)((set, get) => ({
|
|
11
10
|
routes: {},
|
|
12
|
-
setExecutableRoute: (route) =>
|
|
13
|
-
if (!
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
setExecutableRoute: (route) => {
|
|
12
|
+
if (!get().routes[route.id]) {
|
|
13
|
+
set((state) => {
|
|
14
|
+
const routes = Object.assign({}, state.routes);
|
|
15
|
+
// clean previous idle routes that were not executed
|
|
16
|
+
Object.keys(routes)
|
|
17
|
+
.filter((routeId) => { var _a; return ((_a = routes[routeId]) === null || _a === void 0 ? void 0 : _a.status) === types_1.RouteExecutionStatus.Idle; })
|
|
18
|
+
.forEach((routeId) => delete routes[routeId]);
|
|
19
|
+
routes[route.id] = {
|
|
20
|
+
route,
|
|
21
|
+
status: types_1.RouteExecutionStatus.Idle,
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
routes,
|
|
25
|
+
};
|
|
26
|
+
});
|
|
22
27
|
}
|
|
23
|
-
}
|
|
24
|
-
updateRoute: (route) =>
|
|
25
|
-
if (
|
|
26
|
-
state
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if ((0, utils_2.isRoutePartiallyDone)(route)) {
|
|
36
|
-
state.routes[route.id].status |= types_1.RouteExecutionStatus.Partial;
|
|
28
|
+
},
|
|
29
|
+
updateRoute: (route) => {
|
|
30
|
+
if (get().routes[route.id]) {
|
|
31
|
+
set((state) => {
|
|
32
|
+
const updatedState = {
|
|
33
|
+
routes: Object.assign(Object.assign({}, state.routes), { [route.id]: Object.assign(Object.assign({}, state.routes[route.id]), { route }) }),
|
|
34
|
+
};
|
|
35
|
+
const isFailed = (0, utils_2.isRouteFailed)(route);
|
|
36
|
+
if (isFailed) {
|
|
37
|
+
updatedState.routes[route.id].status =
|
|
38
|
+
types_1.RouteExecutionStatus.Failed;
|
|
39
|
+
return updatedState;
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
const isDone = (0, utils_2.isRouteDone)(route);
|
|
42
|
+
if (isDone) {
|
|
43
|
+
updatedState.routes[route.id].status = types_1.RouteExecutionStatus.Done;
|
|
44
|
+
if ((0, utils_2.isRoutePartiallyDone)(route)) {
|
|
45
|
+
updatedState.routes[route.id].status |=
|
|
46
|
+
types_1.RouteExecutionStatus.Partial;
|
|
47
|
+
}
|
|
48
|
+
else if ((0, utils_2.isRouteRefunded)(route)) {
|
|
49
|
+
updatedState.routes[route.id].status |=
|
|
50
|
+
types_1.RouteExecutionStatus.Refunded;
|
|
51
|
+
}
|
|
52
|
+
return updatedState;
|
|
40
53
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
const isLoading = route.steps.some((step) => step.execution);
|
|
55
|
+
if (isLoading) {
|
|
56
|
+
updatedState.routes[route.id].status =
|
|
57
|
+
types_1.RouteExecutionStatus.Pending;
|
|
58
|
+
}
|
|
59
|
+
return updatedState;
|
|
60
|
+
});
|
|
47
61
|
}
|
|
48
|
-
}
|
|
49
|
-
restartRoute: (routeId) =>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
delete state.routes[routeId];
|
|
62
|
+
},
|
|
63
|
+
restartRoute: (routeId) => {
|
|
64
|
+
if (get().routes[routeId]) {
|
|
65
|
+
set((state) => ({
|
|
66
|
+
routes: Object.assign(Object.assign({}, state.routes), { [routeId]: Object.assign(Object.assign({}, state.routes[routeId]), { status: types_1.RouteExecutionStatus.Pending }) }),
|
|
67
|
+
}));
|
|
55
68
|
}
|
|
56
|
-
}
|
|
69
|
+
},
|
|
70
|
+
deleteRoute: (routeId) => {
|
|
71
|
+
if (get().routes[routeId]) {
|
|
72
|
+
set((state) => {
|
|
73
|
+
const routes = Object.assign({}, state.routes);
|
|
74
|
+
delete routes[routeId];
|
|
75
|
+
return {
|
|
76
|
+
routes,
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
},
|
|
57
81
|
deleteRoutes: (type) => set((state) => {
|
|
58
|
-
Object.
|
|
82
|
+
const routes = Object.assign({}, state.routes);
|
|
83
|
+
Object.keys(routes)
|
|
59
84
|
.filter((routeId) => {
|
|
60
85
|
var _a, _b, _c, _d;
|
|
61
86
|
return type === 'completed'
|
|
62
|
-
? (0, utils_1.hasEnumFlag)((_b = (_a =
|
|
63
|
-
: !(0, utils_1.hasEnumFlag)((_d = (_c =
|
|
87
|
+
? (0, utils_1.hasEnumFlag)((_b = (_a = routes[routeId]) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 0, types_1.RouteExecutionStatus.Done)
|
|
88
|
+
: !(0, utils_1.hasEnumFlag)((_d = (_c = routes[routeId]) === null || _c === void 0 ? void 0 : _c.status) !== null && _d !== void 0 ? _d : 0, types_1.RouteExecutionStatus.Done);
|
|
64
89
|
})
|
|
65
|
-
.forEach((routeId) => delete
|
|
90
|
+
.forEach((routeId) => delete routes[routeId]);
|
|
91
|
+
return {
|
|
92
|
+
routes,
|
|
93
|
+
};
|
|
66
94
|
}),
|
|
67
|
-
})
|
|
95
|
+
}), {
|
|
68
96
|
name: 'li.fi-widget-routes',
|
|
69
97
|
version: 1,
|
|
70
98
|
partialize: (state) => ({ routes: state.routes }),
|
|
@@ -2,7 +2,7 @@ import type { WidgetConfig } from '../../types';
|
|
|
2
2
|
import type { SettingsState, SettingsStore } from './types';
|
|
3
3
|
export declare const defaultConfigurableSettings: Pick<SettingsState, 'routePriority' | 'slippage'>;
|
|
4
4
|
export declare const defaultSettings: SettingsState;
|
|
5
|
-
export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<
|
|
5
|
+
export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<SettingsStore>, "persist"> & {
|
|
6
6
|
persist: {
|
|
7
7
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<SettingsStore, {
|
|
8
8
|
setValue: import("./types").ValueSetter<SettingsState>;
|
|
@@ -40,7 +40,5 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<Omit
|
|
|
40
40
|
_enabledExchanges?: Record<string, boolean> | undefined;
|
|
41
41
|
}>>;
|
|
42
42
|
};
|
|
43
|
-
}, "setState"> & {
|
|
44
|
-
setState(nextStateOrUpdater: SettingsStore | Partial<SettingsStore> | ((state: import("immer/dist/internal").WritableDraft<SettingsStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
45
43
|
}>;
|
|
46
44
|
export declare const setDefaultSettings: (config?: WidgetConfig) => void;
|