@lifi/widget 1.26.1 → 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/BottomSheet/BottomSheet.js +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/useRouteExecution.js +2 -0
- 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/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -1
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +11 -4
- package/cjs/pages/SwapPage/SwapPage.js +1 -1
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +3 -3
- 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/BottomSheet/BottomSheet.js +2 -2
- 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/useRouteExecution.js +3 -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 +9 -10
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -1
- package/pages/SwapPage/ExchangeRateBottomSheet.js +12 -5
- package/pages/SwapPage/StatusBottomSheet.js +3 -3
- package/pages/SwapPage/SwapPage.js +2 -2
- package/pages/SwapPage/TokenValueBottomSheet.js +4 -4
- 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
|
@@ -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;
|
|
@@ -15,7 +15,6 @@ exports.setDefaultSettings = exports.useSettingsStore = exports.defaultSettings
|
|
|
15
15
|
/* eslint-disable no-underscore-dangle */
|
|
16
16
|
const zustand_1 = require("zustand");
|
|
17
17
|
const middleware_1 = require("zustand/middleware");
|
|
18
|
-
const immer_1 = require("zustand/middleware/immer");
|
|
19
18
|
const types_1 = require("./types");
|
|
20
19
|
exports.defaultConfigurableSettings = {
|
|
21
20
|
routePriority: 'RECOMMENDED',
|
|
@@ -27,45 +26,51 @@ exports.defaultSettings = {
|
|
|
27
26
|
advancedPreferences: false,
|
|
28
27
|
showDestinationWallet: true,
|
|
29
28
|
};
|
|
30
|
-
exports.useSettingsStore = (0, zustand_1.default)()((0, middleware_1.persist)((
|
|
31
|
-
|
|
32
|
-
}), setValues: (values) => set((state) => {
|
|
29
|
+
exports.useSettingsStore = (0, zustand_1.default)()((0, middleware_1.persist)((set) => (Object.assign(Object.assign({}, exports.defaultSettings), { setValue: (key, value) => set(() => ({
|
|
30
|
+
[key]: value,
|
|
31
|
+
})), setValues: (values) => set((state) => {
|
|
32
|
+
const updatedState = Object.assign({}, state);
|
|
33
33
|
for (const key in values) {
|
|
34
34
|
if (Object.prototype.hasOwnProperty.call(state, key)) {
|
|
35
|
-
|
|
35
|
+
updatedState[key] = values[key];
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
return updatedState;
|
|
39
|
+
}), initializeTools: (toolType, tools) => {
|
|
39
40
|
if (!tools.length) {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
set((state) => {
|
|
44
|
+
const updatedState = Object.assign({}, state);
|
|
45
|
+
if (updatedState[`_enabled${toolType}`]) {
|
|
46
|
+
// Add a new tools
|
|
47
|
+
const enabledTools = tools
|
|
48
|
+
.filter((tool) => !Object.prototype.hasOwnProperty.call(updatedState[`_enabled${toolType}`], tool))
|
|
49
|
+
.reduce((values, tool) => {
|
|
50
|
+
values[tool] = true;
|
|
51
|
+
return values;
|
|
52
|
+
}, updatedState[`_enabled${toolType}`]);
|
|
53
|
+
// Filter tools we no longer have
|
|
54
|
+
updatedState[`_enabled${toolType}`] = Object.fromEntries(Object.entries(enabledTools).filter(([key]) => tools.includes(key)));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
updatedState[`_enabled${toolType}`] = tools.reduce((values, tool) => {
|
|
58
|
+
values[tool] = true;
|
|
59
|
+
return values;
|
|
60
|
+
}, {});
|
|
61
|
+
}
|
|
62
|
+
updatedState[`enabled${toolType}`] = Object.entries(updatedState[`_enabled${toolType}`])
|
|
63
|
+
.filter(([_, value]) => value)
|
|
64
|
+
.map(([key]) => key);
|
|
65
|
+
return updatedState;
|
|
66
|
+
});
|
|
67
|
+
}, setTools: (toolType, tools, availableTools) => set(() => ({
|
|
68
|
+
[`enabled${toolType}`]: tools,
|
|
69
|
+
[`_enabled${toolType}`]: availableTools.reduce((values, tool) => {
|
|
65
70
|
values[tool.key] = tools.includes(tool.key);
|
|
66
71
|
return values;
|
|
67
|
-
}, {})
|
|
68
|
-
}) }))
|
|
72
|
+
}, {}),
|
|
73
|
+
})) })), {
|
|
69
74
|
name: 'li.fi-widget-settings',
|
|
70
75
|
version: 2,
|
|
71
76
|
partialize: (state) => {
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Drawer } from '@mui/material';
|
|
3
|
-
import { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
3
|
+
import { forwardRef, useCallback, useImperativeHandle, useRef, useState, } from 'react';
|
|
4
4
|
import { getScrollableContainer } from '../../hooks';
|
|
5
5
|
import { backdropProps, modalProps, paperProps } from '../Dialog';
|
|
6
6
|
export const BottomSheet = forwardRef(({ elementRef, children, open, onClose }, ref) => {
|
|
@@ -10,7 +10,7 @@ export const BottomSheet = forwardRef(({ elementRef, children, open, onClose },
|
|
|
10
10
|
setDrawerOpen(false);
|
|
11
11
|
openRef.current = false;
|
|
12
12
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
13
|
-
}, []);
|
|
13
|
+
}, [onClose]);
|
|
14
14
|
useImperativeHandle(ref, () => ({
|
|
15
15
|
isOpen: () => openRef.current,
|
|
16
16
|
open: () => {
|
|
@@ -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>>;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
import create from 'zustand';
|
|
3
|
-
|
|
4
|
-
export const useHeaderActionStore = create()(immer((set, get) => ({
|
|
3
|
+
export const useHeaderActionStore = create((set, get) => ({
|
|
5
4
|
setAction: (element) => {
|
|
6
|
-
set((
|
|
7
|
-
|
|
8
|
-
});
|
|
5
|
+
set(() => ({
|
|
6
|
+
element,
|
|
7
|
+
}));
|
|
9
8
|
return get().removeAction;
|
|
10
9
|
},
|
|
11
10
|
removeAction: () => {
|
|
12
|
-
set((
|
|
13
|
-
|
|
14
|
-
});
|
|
11
|
+
set(() => ({
|
|
12
|
+
element: null,
|
|
13
|
+
}));
|
|
15
14
|
},
|
|
16
|
-
}))
|
|
15
|
+
}));
|
|
@@ -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;
|
|
@@ -46,7 +46,7 @@ export const SendToWallet = forwardRef((props, ref) => {
|
|
|
46
46
|
}),
|
|
47
47
|
onBlur: () => trigger(SwapFormKey.ToAddress),
|
|
48
48
|
});
|
|
49
|
-
return (_jsx(Collapse, Object.assign({ timeout: 225, in: showSendToWallet, mountOnEnter: true, unmountOnExit: true }, { children: _jsxs(Card, Object.assign({}, props, { ref: ref }, { children: [_jsx(CardTitle, { children: t('swap.sendToWallet') }), _jsxs(FormControl, Object.assign({ 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')
|
|
49
|
+
return (_jsx(Collapse, Object.assign({ timeout: 225, in: showSendToWallet, mountOnEnter: true, unmountOnExit: true }, { children: _jsxs(Card, Object.assign({}, props, { ref: ref }, { children: [_jsx(CardTitle, { children: t('swap.sendToWallet') }), _jsxs(FormControl, Object.assign({ 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') }), _jsx(SendToWalletFormHelperText, {})] }))] })) })));
|
|
50
50
|
});
|
|
51
51
|
export const SendToWalletFormHelperText = () => {
|
|
52
52
|
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>>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import create from 'zustand';
|
|
2
|
-
|
|
3
|
-
export const useSendToWalletStore = create()(immer((set) => ({
|
|
2
|
+
export const useSendToWalletStore = create((set) => ({
|
|
4
3
|
showSendToWallet: false,
|
|
5
4
|
toggleSendToWallet: () => {
|
|
6
|
-
set((state) => {
|
|
7
|
-
|
|
8
|
-
});
|
|
5
|
+
set((state) => ({
|
|
6
|
+
showSendToWallet: !state.showSendToWallet,
|
|
7
|
+
}));
|
|
9
8
|
},
|
|
10
|
-
}))
|
|
9
|
+
}));
|
|
@@ -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/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/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.26.
|
|
2
|
+
export const version = '1.26.3';
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { useMutation } from '@tanstack/react-query';
|
|
10
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
11
11
|
import { useCallback, useEffect, useRef } from 'react';
|
|
12
12
|
import shallow from 'zustand/shallow';
|
|
13
13
|
import { useLiFi, useWallet } from '../providers';
|
|
@@ -17,6 +17,7 @@ import { deepClone } from '../utils';
|
|
|
17
17
|
import { useWidgetEvents } from './useWidgetEvents';
|
|
18
18
|
export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateUpdate, }) => {
|
|
19
19
|
const lifi = useLiFi();
|
|
20
|
+
const queryClient = useQueryClient();
|
|
20
21
|
const { account, switchChain } = useWallet();
|
|
21
22
|
const resumedAfterMount = useRef(false);
|
|
22
23
|
const emitter = useWidgetEvents();
|
|
@@ -74,6 +75,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
74
75
|
if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
|
|
75
76
|
throw Error('Execution route not found.');
|
|
76
77
|
}
|
|
78
|
+
queryClient.removeQueries(['routes']);
|
|
77
79
|
return lifi.executeRoute(account.signer, routeExecution.route, {
|
|
78
80
|
updateCallback,
|
|
79
81
|
switchChainHook,
|
|
@@ -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>;
|
package/hooks/useWidgetEvents.js
CHANGED
package/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/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { App } from './App';
|
|
2
2
|
import { AppDrawer } from './AppDrawer';
|
|
3
3
|
import './fonts/inter.css';
|
|
4
|
-
export { useWidgetEvents } from './hooks';
|
|
4
|
+
export { useWidgetEvents, widgetEvents } from './hooks';
|
|
5
5
|
export * from './types';
|
|
6
6
|
// ClassNameGenerator.configure((componentName) =>
|
|
7
7
|
// componentName.replace('Mui', 'LiFi'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.3",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -44,23 +44,22 @@
|
|
|
44
44
|
"@ethersproject/providers": "^5.7.2",
|
|
45
45
|
"@lifi/sdk": "^1.7.0",
|
|
46
46
|
"@lifi/wallet-management": "^1.2.1",
|
|
47
|
-
"@mui/icons-material": "^5.10.
|
|
48
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
49
|
-
"@mui/material": "^5.10.
|
|
50
|
-
"@sentry/integrations": "^7.
|
|
51
|
-
"@sentry/react": "^7.
|
|
52
|
-
"@sentry/tracing": "^7.
|
|
53
|
-
"@tanstack/react-query": "^4.
|
|
47
|
+
"@mui/icons-material": "^5.10.16",
|
|
48
|
+
"@mui/lab": "^5.0.0-alpha.110",
|
|
49
|
+
"@mui/material": "^5.10.16",
|
|
50
|
+
"@sentry/integrations": "^7.22.0",
|
|
51
|
+
"@sentry/react": "^7.22.0",
|
|
52
|
+
"@sentry/tracing": "^7.22.0",
|
|
53
|
+
"@tanstack/react-query": "^4.18.0",
|
|
54
54
|
"@tanstack/react-virtual": "^3.0.0-beta.23",
|
|
55
55
|
"big.js": "^6.2.1",
|
|
56
56
|
"i18next": "22.0.4",
|
|
57
57
|
"i18next-browser-languagedetector": "^7.0.1",
|
|
58
|
-
"immer": "^9.0.16",
|
|
59
58
|
"microdiff": "^1.3.1",
|
|
60
59
|
"mitt": "^3.0.0",
|
|
61
60
|
"react": "^18.2.0",
|
|
62
61
|
"react-dom": "^18.2.0",
|
|
63
|
-
"react-hook-form": "^7.39.
|
|
62
|
+
"react-hook-form": "^7.39.7",
|
|
64
63
|
"react-i18next": "^12.0.0",
|
|
65
64
|
"react-router-dom": "^6.4.3",
|
|
66
65
|
"react-timer-hook": "^3.0.5",
|
|
@@ -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;
|
|
@@ -3,7 +3,7 @@ import type { ExchangeRateUpdateParams, Route } from '@lifi/sdk';
|
|
|
3
3
|
export interface ExchangeRateBottomSheetBase {
|
|
4
4
|
isOpen(): void;
|
|
5
5
|
open(resolver: (value: boolean) => void, data: ExchangeRateUpdateParams): void;
|
|
6
|
-
close(value?: boolean): void;
|
|
6
|
+
close(value?: boolean, bottomSheetClose?: boolean): void;
|
|
7
7
|
}
|
|
8
8
|
interface ExchangeRateBottomSheetProps {
|
|
9
9
|
data?: ExchangeRateUpdateParams;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { WarningRounded as WarningIcon } from '@mui/icons-material';
|
|
3
3
|
import { Box, Button, Typography } from '@mui/material';
|
|
4
4
|
import Big from 'big.js';
|
|
5
|
-
import { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
5
|
+
import { forwardRef, useCallback, useImperativeHandle, useRef, useState, } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { BottomSheet } from '../../components/BottomSheet';
|
|
8
8
|
import { useSetContentHeight } from '../../hooks';
|
|
@@ -21,7 +21,12 @@ export const ExchangeRateBottomSheet = forwardRef(({ onContinue, onCancel }, ref
|
|
|
21
21
|
var _a;
|
|
22
22
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(false);
|
|
23
23
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
24
|
-
}, []);
|
|
24
|
+
}, [onCancel, ref]);
|
|
25
|
+
const handleClose = useCallback(() => {
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(false, false);
|
|
28
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
29
|
+
}, [onCancel, ref]);
|
|
25
30
|
useImperativeHandle(ref, () => ({
|
|
26
31
|
isOpen: () => { var _a; return (_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen(); },
|
|
27
32
|
open: (resolver, data) => {
|
|
@@ -30,13 +35,15 @@ export const ExchangeRateBottomSheet = forwardRef(({ onContinue, onCancel }, ref
|
|
|
30
35
|
resolverRef.current = resolver;
|
|
31
36
|
(_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.open();
|
|
32
37
|
},
|
|
33
|
-
close: (value = false) => {
|
|
38
|
+
close: (value = false, bottomSheetClose = true) => {
|
|
34
39
|
var _a, _b;
|
|
35
40
|
(_a = resolverRef.current) === null || _a === void 0 ? void 0 : _a.call(resolverRef, value);
|
|
36
|
-
(
|
|
41
|
+
if (bottomSheetClose) {
|
|
42
|
+
(_b = bottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
|
|
43
|
+
}
|
|
37
44
|
},
|
|
38
45
|
}), []);
|
|
39
|
-
return (_jsx(BottomSheet, Object.assign({ ref: bottomSheetRef, onClose:
|
|
46
|
+
return (_jsx(BottomSheet, Object.assign({ ref: bottomSheetRef, onClose: handleClose }, { children: _jsx(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
|
|
40
47
|
});
|
|
41
48
|
const ExchangeRateBottomSheetContent = ({ data, onCancel, onContinue }) => {
|
|
42
49
|
const { t } = useTranslation();
|