@lifi/widget 2.4.5 → 2.4.6
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/cjs/components/Card/CardLabel.d.ts +1 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/i18n/en.json +2 -1
- package/cjs/pages/SettingsPage/ResetSettingsButton.js +29 -1
- package/cjs/pages/SettingsPage/ResetSettingsButton.style.d.ts +4 -0
- package/cjs/pages/SettingsPage/ResetSettingsButton.style.js +13 -0
- package/cjs/stores/StoreProvider.js +3 -1
- package/cjs/stores/routes/createRouteExecutionStore.js +1 -1
- package/cjs/stores/settings/types.d.ts +4 -3
- package/cjs/stores/settings/useSettingsStore.d.ts +1 -1
- package/cjs/stores/settings/useSettingsStore.js +7 -3
- package/cjs/stores/settings/useSplitSubvariantStore.js +1 -1
- package/cjs/types/widget.d.ts +2 -0
- package/components/Card/CardLabel.d.ts +1 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/i18n/en.json +2 -1
- package/package.json +1 -1
- package/pages/SettingsPage/ResetSettingsButton.js +30 -2
- package/pages/SettingsPage/ResetSettingsButton.style.d.ts +4 -0
- package/pages/SettingsPage/ResetSettingsButton.style.js +10 -0
- package/stores/StoreProvider.js +3 -1
- package/stores/routes/createRouteExecutionStore.js +1 -1
- package/stores/settings/types.d.ts +4 -3
- package/stores/settings/useSettingsStore.d.ts +1 -1
- package/stores/settings/useSettingsStore.js +7 -3
- package/stores/settings/useSplitSubvariantStore.js +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +2 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const CardLabel: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3
3
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
4
4
|
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
5
|
-
type?: "
|
|
5
|
+
type?: "active" | "insurance" | "insurance-icon" | undefined;
|
|
6
6
|
}, {}, {}>;
|
|
7
7
|
export declare const CardLabelTypography: import("@emotion/styled").StyledComponent<import("@mui/material").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
8
8
|
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | 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 = "2.4.
|
|
2
|
+
export declare const version = "2.4.6";
|
package/cjs/config/version.js
CHANGED
package/cjs/i18n/en.json
CHANGED
|
@@ -255,7 +255,8 @@
|
|
|
255
255
|
},
|
|
256
256
|
"routePriority": "Route priority",
|
|
257
257
|
"showDestinationWallet": "Show destination wallet",
|
|
258
|
-
"slippage": "Slippage"
|
|
258
|
+
"slippage": "Slippage",
|
|
259
|
+
"resetSettings": "You're using custom setting limiting the number of available routes."
|
|
259
260
|
},
|
|
260
261
|
"wallet": {
|
|
261
262
|
"extensionNotFound": "Please make sure that only the {{name}} browser extension is active before choosing this wallet."
|
|
@@ -9,7 +9,17 @@ const Dialog_1 = require("../../components/Dialog");
|
|
|
9
9
|
const hooks_1 = require("../../hooks");
|
|
10
10
|
const providers_1 = require("../../providers");
|
|
11
11
|
const stores_1 = require("../../stores");
|
|
12
|
+
const ResetSettingsButton_style_1 = require("./ResetSettingsButton.style");
|
|
13
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
14
|
+
const shallow_1 = require("zustand/shallow");
|
|
12
15
|
const ResetSettingsButton = () => {
|
|
16
|
+
const [enabledBridges, enabledExchanges, routePriority, slippage, gasPrice] = (0, stores_1.useSettingsStore)((state) => [
|
|
17
|
+
state.enabledBridges,
|
|
18
|
+
state.enabledExchanges,
|
|
19
|
+
state.routePriority,
|
|
20
|
+
state.slippage,
|
|
21
|
+
state.gasPrice,
|
|
22
|
+
], shallow_1.shallow);
|
|
13
23
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
14
24
|
const { tools } = (0, hooks_1.useTools)();
|
|
15
25
|
const config = (0, providers_1.useWidgetConfig)();
|
|
@@ -21,9 +31,27 @@ const ResetSettingsButton = () => {
|
|
|
21
31
|
const handleReset = () => {
|
|
22
32
|
if (tools) {
|
|
23
33
|
resetSettings(config, tools.bridges.map((tool) => tool.key), tools.exchanges.map((tool) => tool.key));
|
|
34
|
+
(0, stores_1.setDefaultSettings)(config);
|
|
24
35
|
}
|
|
25
36
|
toggleDialog();
|
|
26
37
|
};
|
|
27
|
-
|
|
38
|
+
const isSlippageChanged = config.slippage
|
|
39
|
+
? Number(slippage) !== config.slippage * 100
|
|
40
|
+
: slippage !== stores_1.defaultConfigurableSettings.slippage;
|
|
41
|
+
const isRoutePriorityChanged = config.routePriority
|
|
42
|
+
? routePriority !== config.routePriority
|
|
43
|
+
: routePriority !== stores_1.defaultConfigurableSettings.routePriority;
|
|
44
|
+
const isGasPriceChanged = gasPrice !== stores_1.defaultConfigurableSettings.gasPrice;
|
|
45
|
+
const isCustomRouteSettings = tools?.bridges?.length !== enabledBridges?.length ||
|
|
46
|
+
tools?.exchanges?.length !== enabledExchanges?.length ||
|
|
47
|
+
isSlippageChanged ||
|
|
48
|
+
isRoutePriorityChanged ||
|
|
49
|
+
isGasPriceChanged;
|
|
50
|
+
if (!isCustomRouteSettings) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { px: 3, mt: 1.5, mb: 1, children: (0, jsx_runtime_1.jsxs)(ResetSettingsButton_style_1.ResetButtonContainer, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", marginBottom: "12px", children: [(0, jsx_runtime_1.jsx)(icons_material_1.InfoRounded, { sx: {
|
|
54
|
+
marginRight: '8px',
|
|
55
|
+
} }), (0, jsx_runtime_1.jsx)(material_1.Box, { fontSize: 14, children: t(`settings.resetSettings`) })] }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: toggleDialog, fullWidth: true, children: t('button.resetSettings') }), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, { open: open, onClose: toggleDialog, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('warning.title.resetSettings') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('warning.message.resetSettings') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { onClick: toggleDialog, children: t('button.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: handleReset, autoFocus: true, children: t('button.reset') })] })] })] }) }));
|
|
28
56
|
};
|
|
29
57
|
exports.ResetSettingsButton = ResetSettingsButton;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ResetButtonContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
4
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResetButtonContainer = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
exports.ResetButtonContainer = (0, material_1.styled)(material_1.Box)(({ theme }) => ({
|
|
7
|
+
background: (0, utils_1.getContrastAlphaColor)(theme.palette.mode, '4%'),
|
|
8
|
+
borderRadius: '16px',
|
|
9
|
+
padding: '16px',
|
|
10
|
+
[`svg`]: {
|
|
11
|
+
fill: (0, utils_1.getContrastAlphaColor)(theme.palette.mode, '40%'),
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
@@ -7,6 +7,8 @@ const header_1 = require("./header");
|
|
|
7
7
|
const routes_1 = require("./routes");
|
|
8
8
|
const settings_1 = require("./settings");
|
|
9
9
|
const StoreProvider = ({ children, config, }) => {
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)(settings_1.SplitSubvariantStoreProvider, { state: config.subvariant === 'split'
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(settings_1.SplitSubvariantStoreProvider, { state: config.subvariant === 'split'
|
|
11
|
+
? config.subvariantOptions || 'swap'
|
|
12
|
+
: undefined, children: (0, jsx_runtime_1.jsx)(header_1.HeaderStoreProvider, { namePrefix: config?.keyPrefix, children: (0, jsx_runtime_1.jsx)(chains_1.ChainOrderStoreProvider, { namePrefix: config?.keyPrefix, children: (0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: config?.keyPrefix, children: children }) }) }) }));
|
|
11
13
|
};
|
|
12
14
|
exports.StoreProvider = StoreProvider;
|
|
@@ -35,12 +35,13 @@ export interface SendToWalletStore extends SendToWalletState {
|
|
|
35
35
|
toggleSendToWallet(): void;
|
|
36
36
|
setSendToWallet(value: boolean): void;
|
|
37
37
|
}
|
|
38
|
+
export type SplitSubvariantOptions = 'bridge' | 'swap';
|
|
38
39
|
export interface SplitSubvariantState {
|
|
39
|
-
state?:
|
|
40
|
-
setState(state:
|
|
40
|
+
state?: SplitSubvariantOptions;
|
|
41
|
+
setState(state: SplitSubvariantOptions): void;
|
|
41
42
|
}
|
|
42
43
|
export type SplitSubvariantStore = UseBoundStoreWithEqualityFn<StoreApi<SplitSubvariantState>>;
|
|
43
44
|
export interface SplitSubvariantProps {
|
|
44
|
-
state?:
|
|
45
|
+
state?: SplitSubvariantOptions;
|
|
45
46
|
}
|
|
46
47
|
export type SplitSubvariantProviderProps = PropsWithChildren<SplitSubvariantProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WidgetConfig } from '../../types';
|
|
2
2
|
import type { SettingsProps, SettingsState } from './types';
|
|
3
|
-
export declare const defaultConfigurableSettings: Pick<SettingsState, 'routePriority' | 'slippage'>;
|
|
3
|
+
export declare const defaultConfigurableSettings: Pick<SettingsState, 'routePriority' | 'slippage' | 'gasPrice'>;
|
|
4
4
|
export declare const defaultSettings: SettingsProps;
|
|
5
5
|
export declare const useSettingsStore: import("zustand/traditional").UseBoundStoreWithEqualityFn<import("zustand").StoreApi<SettingsState>>;
|
|
6
6
|
export declare const setDefaultSettings: (config?: WidgetConfig) => void;
|
|
@@ -7,6 +7,7 @@ const types_1 = require("./types");
|
|
|
7
7
|
exports.defaultConfigurableSettings = {
|
|
8
8
|
routePriority: 'RECOMMENDED',
|
|
9
9
|
slippage: '0.5',
|
|
10
|
+
gasPrice: 'normal',
|
|
10
11
|
};
|
|
11
12
|
exports.defaultSettings = {
|
|
12
13
|
appearance: 'auto',
|
|
@@ -67,10 +68,10 @@ exports.useSettingsStore = (0, traditional_1.createWithEqualityFn)((0, middlewar
|
|
|
67
68
|
}, {}),
|
|
68
69
|
})),
|
|
69
70
|
reset: (config, bridges, exchanges) => {
|
|
71
|
+
const { appearance, ...restDefaultSettings } = exports.defaultSettings;
|
|
70
72
|
set(() => ({
|
|
71
|
-
...
|
|
73
|
+
...restDefaultSettings,
|
|
72
74
|
...exports.defaultConfigurableSettings,
|
|
73
|
-
appearance: config.appearance ?? exports.defaultSettings.appearance,
|
|
74
75
|
}));
|
|
75
76
|
get().initializeTools('Bridges', bridges, true);
|
|
76
77
|
get().initializeTools('Exchanges', exchanges, true);
|
|
@@ -102,7 +103,7 @@ exports.useSettingsStore = (0, traditional_1.createWithEqualityFn)((0, middlewar
|
|
|
102
103
|
},
|
|
103
104
|
}), Object.is);
|
|
104
105
|
const setDefaultSettings = (config) => {
|
|
105
|
-
const { slippage, routePriority, setValue } = exports.useSettingsStore.getState();
|
|
106
|
+
const { slippage, routePriority, setValue, gasPrice } = exports.useSettingsStore.getState();
|
|
106
107
|
const defaultSlippage = (config?.slippage ||
|
|
107
108
|
config?.sdkConfig?.defaultRouteOptions?.slippage ||
|
|
108
109
|
0) * 100;
|
|
@@ -116,5 +117,8 @@ const setDefaultSettings = (config) => {
|
|
|
116
117
|
if (!routePriority) {
|
|
117
118
|
setValue('routePriority', exports.defaultConfigurableSettings.routePriority);
|
|
118
119
|
}
|
|
120
|
+
if (!gasPrice) {
|
|
121
|
+
setValue('gasPrice', exports.defaultConfigurableSettings.gasPrice);
|
|
122
|
+
}
|
|
119
123
|
};
|
|
120
124
|
exports.setDefaultSettings = setDefaultSettings;
|
|
@@ -7,7 +7,7 @@ const traditional_1 = require("zustand/traditional");
|
|
|
7
7
|
exports.SplitSubvariantStoreContext = (0, react_1.createContext)(null);
|
|
8
8
|
const shouldRecreateStore = (store, props) => {
|
|
9
9
|
const { state } = store.getState();
|
|
10
|
-
return
|
|
10
|
+
return state !== props.state;
|
|
11
11
|
};
|
|
12
12
|
function SplitSubvariantStoreProvider({ children, ...props }) {
|
|
13
13
|
const storeRef = (0, react_1.useRef)();
|
package/cjs/types/widget.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Components, PaletteMode, PaletteOptions, Shape, Theme } from '@mui
|
|
|
4
4
|
import type { TypographyOptions } from '@mui/material/styles/createTypography';
|
|
5
5
|
import type { CSSProperties, ReactNode, RefObject } from 'react';
|
|
6
6
|
import type { LanguageKey, LanguageResources } from '../providers';
|
|
7
|
+
import type { SplitSubvariantOptions } from '../stores';
|
|
7
8
|
export type WidgetVariant = 'default' | 'expandable' | 'drawer';
|
|
8
9
|
export type WidgetSubvariant = 'default' | 'split' | 'nft' | 'refuel';
|
|
9
10
|
export declare enum DisabledUI {
|
|
@@ -79,6 +80,7 @@ export interface WidgetConfig {
|
|
|
79
80
|
insurance?: boolean;
|
|
80
81
|
variant?: WidgetVariant;
|
|
81
82
|
subvariant?: WidgetSubvariant;
|
|
83
|
+
subvariantOptions?: SplitSubvariantOptions;
|
|
82
84
|
appearance?: Appearance;
|
|
83
85
|
theme?: ThemeConfig;
|
|
84
86
|
containerStyle?: CSSProperties;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const CardLabel: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3
3
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
4
4
|
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
5
|
-
type?: "
|
|
5
|
+
type?: "active" | "insurance" | "insurance-icon" | undefined;
|
|
6
6
|
}, {}, {}>;
|
|
7
7
|
export declare const CardLabelTypography: import("@emotion/styled").StyledComponent<import("@mui/material").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
8
8
|
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "2.4.
|
|
2
|
+
export declare const version = "2.4.6";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '2.4.
|
|
2
|
+
export const version = '2.4.6';
|
package/i18n/en.json
CHANGED
|
@@ -255,7 +255,8 @@
|
|
|
255
255
|
},
|
|
256
256
|
"routePriority": "Route priority",
|
|
257
257
|
"showDestinationWallet": "Show destination wallet",
|
|
258
|
-
"slippage": "Slippage"
|
|
258
|
+
"slippage": "Slippage",
|
|
259
|
+
"resetSettings": "You're using custom setting limiting the number of available routes."
|
|
259
260
|
},
|
|
260
261
|
"wallet": {
|
|
261
262
|
"extensionNotFound": "Please make sure that only the {{name}} browser extension is active before choosing this wallet."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.6",
|
|
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",
|
|
@@ -5,8 +5,18 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { Dialog } from '../../components/Dialog';
|
|
6
6
|
import { useTools } from '../../hooks';
|
|
7
7
|
import { useWidgetConfig } from '../../providers';
|
|
8
|
-
import { useSettingsStore } from '../../stores';
|
|
8
|
+
import { defaultConfigurableSettings, setDefaultSettings, useSettingsStore, } from '../../stores';
|
|
9
|
+
import { ResetButtonContainer } from './ResetSettingsButton.style';
|
|
10
|
+
import { InfoRounded } from '@mui/icons-material';
|
|
11
|
+
import { shallow } from 'zustand/shallow';
|
|
9
12
|
export const ResetSettingsButton = () => {
|
|
13
|
+
const [enabledBridges, enabledExchanges, routePriority, slippage, gasPrice] = useSettingsStore((state) => [
|
|
14
|
+
state.enabledBridges,
|
|
15
|
+
state.enabledExchanges,
|
|
16
|
+
state.routePriority,
|
|
17
|
+
state.slippage,
|
|
18
|
+
state.gasPrice,
|
|
19
|
+
], shallow);
|
|
10
20
|
const { t } = useTranslation();
|
|
11
21
|
const { tools } = useTools();
|
|
12
22
|
const config = useWidgetConfig();
|
|
@@ -18,8 +28,26 @@ export const ResetSettingsButton = () => {
|
|
|
18
28
|
const handleReset = () => {
|
|
19
29
|
if (tools) {
|
|
20
30
|
resetSettings(config, tools.bridges.map((tool) => tool.key), tools.exchanges.map((tool) => tool.key));
|
|
31
|
+
setDefaultSettings(config);
|
|
21
32
|
}
|
|
22
33
|
toggleDialog();
|
|
23
34
|
};
|
|
24
|
-
|
|
35
|
+
const isSlippageChanged = config.slippage
|
|
36
|
+
? Number(slippage) !== config.slippage * 100
|
|
37
|
+
: slippage !== defaultConfigurableSettings.slippage;
|
|
38
|
+
const isRoutePriorityChanged = config.routePriority
|
|
39
|
+
? routePriority !== config.routePriority
|
|
40
|
+
: routePriority !== defaultConfigurableSettings.routePriority;
|
|
41
|
+
const isGasPriceChanged = gasPrice !== defaultConfigurableSettings.gasPrice;
|
|
42
|
+
const isCustomRouteSettings = tools?.bridges?.length !== enabledBridges?.length ||
|
|
43
|
+
tools?.exchanges?.length !== enabledExchanges?.length ||
|
|
44
|
+
isSlippageChanged ||
|
|
45
|
+
isRoutePriorityChanged ||
|
|
46
|
+
isGasPriceChanged;
|
|
47
|
+
if (!isCustomRouteSettings) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return (_jsx(Box, { px: 3, mt: 1.5, mb: 1, children: _jsxs(ResetButtonContainer, { children: [_jsxs(Box, { display: "flex", marginBottom: "12px", children: [_jsx(InfoRounded, { sx: {
|
|
51
|
+
marginRight: '8px',
|
|
52
|
+
} }), _jsx(Box, { fontSize: 14, children: t(`settings.resetSettings`) })] }), _jsx(Button, { onClick: toggleDialog, fullWidth: true, children: t('button.resetSettings') }), _jsxs(Dialog, { open: open, onClose: toggleDialog, children: [_jsx(DialogTitle, { children: t('warning.title.resetSettings') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('warning.message.resetSettings') }) }), _jsxs(DialogActions, { children: [_jsx(Button, { onClick: toggleDialog, children: t('button.cancel') }), _jsx(Button, { variant: "contained", onClick: handleReset, autoFocus: true, children: t('button.reset') })] })] })] }) }));
|
|
25
53
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ResetButtonContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
4
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getContrastAlphaColor } from '../../utils';
|
|
2
|
+
import { Box, styled } from '@mui/material';
|
|
3
|
+
export const ResetButtonContainer = styled(Box)(({ theme }) => ({
|
|
4
|
+
background: getContrastAlphaColor(theme.palette.mode, '4%'),
|
|
5
|
+
borderRadius: '16px',
|
|
6
|
+
padding: '16px',
|
|
7
|
+
[`svg`]: {
|
|
8
|
+
fill: getContrastAlphaColor(theme.palette.mode, '40%'),
|
|
9
|
+
},
|
|
10
|
+
}));
|
package/stores/StoreProvider.js
CHANGED
|
@@ -4,5 +4,7 @@ import { HeaderStoreProvider } from './header';
|
|
|
4
4
|
import { RouteExecutionStoreProvider } from './routes';
|
|
5
5
|
import { SplitSubvariantStoreProvider } from './settings';
|
|
6
6
|
export const StoreProvider = ({ children, config, }) => {
|
|
7
|
-
return (_jsx(SplitSubvariantStoreProvider, { state: config.subvariant === 'split'
|
|
7
|
+
return (_jsx(SplitSubvariantStoreProvider, { state: config.subvariant === 'split'
|
|
8
|
+
? config.subvariantOptions || 'swap'
|
|
9
|
+
: undefined, children: _jsx(HeaderStoreProvider, { namePrefix: config?.keyPrefix, children: _jsx(ChainOrderStoreProvider, { namePrefix: config?.keyPrefix, children: _jsx(RouteExecutionStoreProvider, { namePrefix: config?.keyPrefix, children: children }) }) }) }));
|
|
8
10
|
};
|
|
@@ -35,12 +35,13 @@ export interface SendToWalletStore extends SendToWalletState {
|
|
|
35
35
|
toggleSendToWallet(): void;
|
|
36
36
|
setSendToWallet(value: boolean): void;
|
|
37
37
|
}
|
|
38
|
+
export type SplitSubvariantOptions = 'bridge' | 'swap';
|
|
38
39
|
export interface SplitSubvariantState {
|
|
39
|
-
state?:
|
|
40
|
-
setState(state:
|
|
40
|
+
state?: SplitSubvariantOptions;
|
|
41
|
+
setState(state: SplitSubvariantOptions): void;
|
|
41
42
|
}
|
|
42
43
|
export type SplitSubvariantStore = UseBoundStoreWithEqualityFn<StoreApi<SplitSubvariantState>>;
|
|
43
44
|
export interface SplitSubvariantProps {
|
|
44
|
-
state?:
|
|
45
|
+
state?: SplitSubvariantOptions;
|
|
45
46
|
}
|
|
46
47
|
export type SplitSubvariantProviderProps = PropsWithChildren<SplitSubvariantProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WidgetConfig } from '../../types';
|
|
2
2
|
import type { SettingsProps, SettingsState } from './types';
|
|
3
|
-
export declare const defaultConfigurableSettings: Pick<SettingsState, 'routePriority' | 'slippage'>;
|
|
3
|
+
export declare const defaultConfigurableSettings: Pick<SettingsState, 'routePriority' | 'slippage' | 'gasPrice'>;
|
|
4
4
|
export declare const defaultSettings: SettingsProps;
|
|
5
5
|
export declare const useSettingsStore: import("zustand/traditional").UseBoundStoreWithEqualityFn<import("zustand").StoreApi<SettingsState>>;
|
|
6
6
|
export declare const setDefaultSettings: (config?: WidgetConfig) => void;
|
|
@@ -4,6 +4,7 @@ import { SettingsToolTypes } from './types';
|
|
|
4
4
|
export const defaultConfigurableSettings = {
|
|
5
5
|
routePriority: 'RECOMMENDED',
|
|
6
6
|
slippage: '0.5',
|
|
7
|
+
gasPrice: 'normal',
|
|
7
8
|
};
|
|
8
9
|
export const defaultSettings = {
|
|
9
10
|
appearance: 'auto',
|
|
@@ -64,10 +65,10 @@ export const useSettingsStore = createWithEqualityFn(persist((set, get) => ({
|
|
|
64
65
|
}, {}),
|
|
65
66
|
})),
|
|
66
67
|
reset: (config, bridges, exchanges) => {
|
|
68
|
+
const { appearance, ...restDefaultSettings } = defaultSettings;
|
|
67
69
|
set(() => ({
|
|
68
|
-
...
|
|
70
|
+
...restDefaultSettings,
|
|
69
71
|
...defaultConfigurableSettings,
|
|
70
|
-
appearance: config.appearance ?? defaultSettings.appearance,
|
|
71
72
|
}));
|
|
72
73
|
get().initializeTools('Bridges', bridges, true);
|
|
73
74
|
get().initializeTools('Exchanges', exchanges, true);
|
|
@@ -99,7 +100,7 @@ export const useSettingsStore = createWithEqualityFn(persist((set, get) => ({
|
|
|
99
100
|
},
|
|
100
101
|
}), Object.is);
|
|
101
102
|
export const setDefaultSettings = (config) => {
|
|
102
|
-
const { slippage, routePriority, setValue } = useSettingsStore.getState();
|
|
103
|
+
const { slippage, routePriority, setValue, gasPrice } = useSettingsStore.getState();
|
|
103
104
|
const defaultSlippage = (config?.slippage ||
|
|
104
105
|
config?.sdkConfig?.defaultRouteOptions?.slippage ||
|
|
105
106
|
0) * 100;
|
|
@@ -113,4 +114,7 @@ export const setDefaultSettings = (config) => {
|
|
|
113
114
|
if (!routePriority) {
|
|
114
115
|
setValue('routePriority', defaultConfigurableSettings.routePriority);
|
|
115
116
|
}
|
|
117
|
+
if (!gasPrice) {
|
|
118
|
+
setValue('gasPrice', defaultConfigurableSettings.gasPrice);
|
|
119
|
+
}
|
|
116
120
|
};
|
|
@@ -4,7 +4,7 @@ import { createWithEqualityFn } from 'zustand/traditional';
|
|
|
4
4
|
export const SplitSubvariantStoreContext = createContext(null);
|
|
5
5
|
const shouldRecreateStore = (store, props) => {
|
|
6
6
|
const { state } = store.getState();
|
|
7
|
-
return
|
|
7
|
+
return state !== props.state;
|
|
8
8
|
};
|
|
9
9
|
export function SplitSubvariantStoreProvider({ children, ...props }) {
|
|
10
10
|
const storeRef = useRef();
|