@lifi/widget 3.0.0-beta.4 → 3.0.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/CHANGELOG.md +9 -0
- package/README.md +5 -3
- package/_esm/App.d.ts +0 -1
- package/_esm/AppDrawer.d.ts +1 -2
- package/_esm/AppDrawer.style.d.ts +1 -2
- package/_esm/AppDrawerContext.d.ts +0 -1
- package/_esm/AppRoutes.d.ts +0 -1
- package/_esm/components/ActiveTransactions/ActiveTransactionItem.d.ts +0 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.d.ts +0 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.style.d.ts +4 -5
- package/_esm/components/AlertMessage/AlertMessage.style.d.ts +2 -3
- package/_esm/components/AmountInput/AmountInput.style.d.ts +2 -3
- package/_esm/components/AmountInput/AmountInputAdornment.style.d.ts +2 -3
- package/_esm/components/AmountInput/AmountInputStartAdornment.d.ts +0 -1
- package/_esm/components/AmountInput/PriceFormHelperText.d.ts +0 -1
- package/_esm/components/AppContainer.d.ts +5 -5
- package/_esm/components/Avatar/Avatar.d.ts +0 -1
- package/_esm/components/Avatar/Avatar.style.d.ts +4 -5
- package/_esm/components/Avatar/TokenAvatar.d.ts +0 -1
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.d.ts +0 -1
- package/_esm/components/BottomSheet/BottomSheet.d.ts +0 -1
- package/_esm/components/ButtonTertiary.d.ts +1 -2
- package/_esm/components/Card/Card.d.ts +1 -2
- package/_esm/components/Card/CardButton.style.d.ts +4 -5
- package/_esm/components/Card/CardHeader.d.ts +1 -2
- package/_esm/components/Card/CardIconButton.d.ts +1 -2
- package/_esm/components/Card/CardLabel.d.ts +4 -5
- package/_esm/components/Card/CardTitle.d.ts +2 -3
- package/_esm/components/Card/InputCard.d.ts +1 -2
- package/_esm/components/ChainSelect/ChainSelect.style.d.ts +2 -3
- package/_esm/components/ContractComponent/ItemPrice.d.ts +0 -1
- package/_esm/components/ContractComponent/NFT/NFT.d.ts +0 -1
- package/_esm/components/ContractComponent/NFT/NFT.style.d.ts +1 -2
- package/_esm/components/ContractComponent/NFT/NFTBase.d.ts +0 -1
- package/_esm/components/GasMessage/GasMessage.d.ts +0 -1
- package/_esm/components/GasMessage/GasRefuelMessage.d.ts +0 -1
- package/_esm/components/GasMessage/GasSufficiencyMessage.d.ts +0 -1
- package/_esm/components/Header/BackButton.d.ts +0 -1
- package/_esm/components/Header/Header.style.d.ts +8 -9
- package/_esm/components/Header/NavigationHeader.d.ts +0 -1
- package/_esm/components/Header/SettingsButton.style.d.ts +2 -3
- package/_esm/components/Header/WalletHeader.d.ts +0 -1
- package/_esm/components/Initializer.d.ts +0 -1
- package/_esm/components/Insurance/Insurance.d.ts +0 -1
- package/_esm/components/Insurance/InsuranceCard.d.ts +0 -1
- package/_esm/components/Insurance/InsuranceCollapsed.d.ts +0 -1
- package/_esm/components/ListItem/ListItem.d.ts +2 -3
- package/_esm/components/ListItem/ListItemButton.d.ts +1 -2
- package/_esm/components/ListItemButton.d.ts +1 -2
- package/_esm/components/ListItemText.d.ts +0 -1
- package/_esm/components/NotFound.d.ts +0 -1
- package/_esm/components/PageContainer.d.ts +1 -2
- package/_esm/components/PoweredBy/PoweredBy.d.ts +0 -1
- package/_esm/components/PoweredBy/PoweredBy.style.d.ts +1 -2
- package/_esm/components/ProgressToNextUpdate.d.ts +0 -1
- package/_esm/components/ReverseTokensButton/ReverseTokensButton.d.ts +0 -1
- package/_esm/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +3 -4
- package/_esm/components/RouteCard/RouteCard.d.ts +0 -1
- package/_esm/components/RouteCard/RouteCard.style.d.ts +2 -3
- package/_esm/components/RouteCard/RouteCardEssentials.d.ts +0 -1
- package/_esm/components/RouteCard/RouteCardEssentialsExpanded.d.ts +0 -1
- package/_esm/components/RouteCard/RouteCardSkeleton.d.ts +0 -1
- package/_esm/components/RouteCard/RouteNotFoundCard.d.ts +0 -1
- package/_esm/components/Routes/Routes.d.ts +0 -1
- package/_esm/components/Routes/RoutesExpanded.style.d.ts +4 -5
- package/_esm/components/Select.d.ts +1 -1
- package/_esm/components/SelectChainAndToken.d.ts +0 -1
- package/_esm/components/SelectTokenButton/SelectTokenButton.d.ts +0 -1
- package/_esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +5 -6
- package/_esm/components/SendToWallet/SendToWallet.style.d.ts +2 -3
- package/_esm/components/SendToWallet/SendToWalletButton.d.ts +0 -1
- package/_esm/components/SendToWallet/SendToWalletExpandButton.d.ts +0 -1
- package/_esm/components/SettingsListItemButton.d.ts +1 -2
- package/_esm/components/Skeleton/WidgetSkeleton.style.d.ts +10 -11
- package/_esm/components/SmallAvatar.d.ts +3 -4
- package/_esm/components/Step/CircularProgress.style.d.ts +3 -4
- package/_esm/components/Step/DestinationWalletAddress.d.ts +0 -1
- package/_esm/components/Step/Step.d.ts +0 -1
- package/_esm/components/Step/StepProcess.d.ts +0 -1
- package/_esm/components/Step/StepProcess.style.d.ts +4 -5
- package/_esm/components/Step/StepTimer.d.ts +0 -1
- package/_esm/components/StepActions/StepActions.d.ts +0 -1
- package/_esm/components/StepActions/StepActions.style.d.ts +4 -5
- package/_esm/components/StepActions/StepFeeBreakdown.d.ts +0 -1
- package/_esm/components/StepActions/StepFees.d.ts +0 -1
- package/_esm/components/StepDivider/StepDivider.d.ts +0 -1
- package/_esm/components/StepDivider/StepDivider.style.d.ts +1 -2
- package/_esm/components/Tabs/Tabs.style.d.ts +4 -5
- package/_esm/components/ToAddressRequiredMessage.d.ts +0 -1
- package/_esm/components/Token/Token.style.d.ts +4 -5
- package/_esm/components/TokenList/TokenList.style.d.ts +6 -7
- package/_esm/components/TokenList/TokenListItem.d.ts +0 -1
- package/_esm/components/TokenList/TokenNotFound.d.ts +0 -1
- package/_esm/config/version.d.ts +1 -1
- package/_esm/config/version.js +1 -1
- package/_esm/config/version.js.map +1 -1
- package/_esm/hooks/useChains.d.ts +1 -1
- package/_esm/hooks/useDebouncedWatch.d.ts +2 -1
- package/_esm/hooks/useProcessMessage.d.ts +2 -2
- package/_esm/hooks/useRoutes.d.ts +1 -1
- package/_esm/hooks/useRoutes.js +24 -13
- package/_esm/hooks/useRoutes.js.map +1 -1
- package/_esm/hooks/useTokenAddressBalance.d.ts +1 -1
- package/_esm/hooks/useTokenBalance.d.ts +1 -1
- package/_esm/hooks/useTokenBalances.d.ts +1 -1
- package/_esm/pages/ActiveTransactionsPage/ActiveTransactionsEmpty.d.ts +0 -1
- package/_esm/pages/LanguagesPage.d.ts +0 -1
- package/_esm/pages/MainPage/MainMessages.d.ts +0 -1
- package/_esm/pages/MainPage/MainPage.d.ts +0 -1
- package/_esm/pages/MainPage/MainPage.style.d.ts +1 -2
- package/_esm/pages/MainPage/ReviewButton.d.ts +0 -1
- package/_esm/pages/RoutesPage/RoutesPage.d.ts +0 -1
- package/_esm/pages/RoutesPage/RoutesPage.style.d.ts +1 -2
- package/_esm/pages/SelectChainPage/SelectChainPage.d.ts +0 -1
- package/_esm/pages/SelectEnabledToolsPage.d.ts +0 -1
- package/_esm/pages/SelectEnabledToolsPage.js +1 -1
- package/_esm/pages/SelectEnabledToolsPage.js.map +1 -1
- package/_esm/pages/SelectNativeTokenPage.d.ts +0 -1
- package/_esm/pages/SendToWallet/BookmarkAddressSheet.d.ts +0 -1
- package/_esm/pages/SendToWallet/ConfirmAddressSheet.d.ts +0 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.style.d.ts +13 -14
- package/_esm/pages/SettingsPage/BridgeAndExchangeSettings.d.ts +0 -1
- package/_esm/pages/SettingsPage/GasPriceSettings.d.ts +0 -1
- package/_esm/pages/SettingsPage/LanguageSetting.d.ts +0 -1
- package/_esm/pages/SettingsPage/ResetSettingsButton.d.ts +0 -1
- package/_esm/pages/SettingsPage/ResetSettingsButton.style.d.ts +1 -2
- package/_esm/pages/SettingsPage/RoutePrioritySettings.d.ts +0 -1
- package/_esm/pages/SettingsPage/SettingsCard/SettingCard.style.d.ts +2 -3
- package/_esm/pages/SettingsPage/SlippageSettings/SlippageSettings.d.ts +0 -1
- package/_esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.d.ts +3 -4
- package/_esm/pages/SettingsPage/ThemeSettings.d.ts +0 -1
- package/_esm/pages/TransactionDetailsPage/TransactionDetailsPage.d.ts +0 -1
- package/_esm/pages/TransactionHistoryPage/TransactionHistoryEmpty.d.ts +0 -1
- package/_esm/pages/TransactionHistoryPage/TransactionHistoryItem.d.ts +0 -1
- package/_esm/pages/TransactionHistoryPage/TransactionHistoryPage.d.ts +0 -1
- package/_esm/pages/TransactionPage/ExchangeRateBottomSheet.d.ts +0 -1
- package/_esm/pages/TransactionPage/StartTransactionButton.d.ts +0 -1
- package/_esm/pages/TransactionPage/StatusBottomSheet.d.ts +0 -1
- package/_esm/pages/TransactionPage/StatusBottomSheet.style.d.ts +3 -4
- package/_esm/pages/TransactionPage/TokenValueBottomSheet.d.ts +0 -1
- package/_esm/pages/TransactionPage/TransactionPage.d.ts +0 -1
- package/_esm/providers/I18nProvider/I18nProvider.d.ts +0 -1
- package/_esm/providers/ThemeProvider/ThemeProvider.d.ts +0 -1
- package/_esm/providers/WalletProvider/EVMExternalContext.d.ts +0 -1
- package/_esm/providers/WalletProvider/SVMExternalContext.d.ts +0 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.d.ts +0 -1
- package/_esm/stores/bookmarks/BookmarkStore.d.ts +0 -1
- package/_esm/stores/chains/ChainOrderStore.d.ts +0 -1
- package/_esm/stores/form/FormStoreContext.d.ts +0 -1
- package/_esm/stores/form/FormUpdater.d.ts +0 -1
- package/_esm/stores/form/types.d.ts +3 -3
- package/_esm/stores/form/useFieldValues.d.ts +2 -2
- package/_esm/stores/form/useValidation.d.ts +1 -1
- package/_esm/stores/header/types.d.ts +0 -1
- package/_esm/stores/header/useHeaderStore.d.ts +0 -1
- package/_esm/stores/routes/RouteExecutionStore.d.ts +0 -1
- package/_esm/stores/routes/useSetExecutableRoute.d.ts +1 -1
- package/_esm/stores/settings/types.d.ts +4 -2
- package/_esm/stores/settings/useAppearance.d.ts +1 -4
- package/_esm/stores/settings/useSettings.d.ts +1 -1
- package/_esm/stores/settings/useSettingsStore.js +23 -14
- package/_esm/stores/settings/useSettingsStore.js.map +1 -1
- package/_esm/stores/settings/useSplitSubvariantStore.d.ts +0 -1
- package/config/version.ts +1 -1
- package/hooks/useRoutes.ts +30 -11
- package/package.json +15 -15
- package/pages/SelectEnabledToolsPage.tsx +1 -1
- package/stores/settings/types.ts +4 -2
- package/stores/settings/useSettingsStore.ts +44 -20
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
/// <reference types="react" resolution-mode="require"/>
|
|
2
1
|
import type { Theme } from '@mui/material';
|
|
3
2
|
import { RouteExecutionStatus } from '../../stores/routes/types.js';
|
|
4
3
|
type StatusColor = RouteExecutionStatus | 'warning';
|
|
5
4
|
export declare const CenterContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
6
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
5
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
7
6
|
}, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
8
7
|
export declare const IconCircle: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
9
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
8
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
10
9
|
}, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme> & {
|
|
11
10
|
status: StatusColor;
|
|
12
11
|
}, {}, {}>;
|
|
13
12
|
export declare const MessageSkeletonContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
14
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
13
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
15
14
|
}, keyof import("@mui/system").BoxOwnProps<Theme>> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
16
15
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" resolution-mode="require"/>
|
|
2
1
|
import type { WidgetContextProps, WidgetProviderProps } from './types.js';
|
|
3
2
|
export declare const useWidgetConfig: () => WidgetContextProps;
|
|
4
3
|
export declare const WidgetProvider: React.FC<React.PropsWithChildren<WidgetProviderProps>>;
|
|
@@ -74,8 +74,8 @@ export interface FormTypeProps {
|
|
|
74
74
|
formType: FormType;
|
|
75
75
|
}
|
|
76
76
|
export declare const FormKeyHelper: {
|
|
77
|
-
getChainKey: (formType: FormType) =>
|
|
78
|
-
getTokenKey: (formType: FormType) =>
|
|
79
|
-
getAmountKey: (formType: FormType) =>
|
|
77
|
+
getChainKey: (formType: FormType) => "fromChain" | "toChain";
|
|
78
|
+
getTokenKey: (formType: FormType) => "fromToken" | "toToken";
|
|
79
|
+
getAmountKey: (formType: FormType) => "fromAmount" | "toAmount";
|
|
80
80
|
};
|
|
81
81
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { FormFieldArray } from './types.js';
|
|
2
|
-
export declare const useFieldValues: <T extends
|
|
1
|
+
import type { FormFieldArray, FormFieldNames } from './types.js';
|
|
2
|
+
export declare const useFieldValues: <T extends FormFieldNames[]>(...names: T) => FormFieldArray<T>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ValidationProps } from './types.js';
|
|
2
|
-
export declare const useValidation: () => Omit<ValidationProps,
|
|
2
|
+
export declare const useValidation: () => Omit<ValidationProps, "validation">;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" resolution-mode="require"/>
|
|
2
1
|
import type { PersistStoreProps, PersistStoreProviderProps } from '../types.js';
|
|
3
2
|
import type { HeaderState, HeaderStore } from './types.js';
|
|
4
3
|
export declare const HeaderStoreContext: import("react").Context<HeaderStore | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useSetExecutableRoute: () => (route: import("@lifi/types").Route, insurableRouteId?: string
|
|
1
|
+
export declare const useSetExecutableRoute: () => (route: import("@lifi/types").Route, insurableRouteId?: string) => void;
|
|
@@ -15,9 +15,11 @@ export interface SettingsProps {
|
|
|
15
15
|
enabledAutoRefuel: boolean;
|
|
16
16
|
slippage?: string;
|
|
17
17
|
disabledBridges: string[];
|
|
18
|
-
enabledBridges:
|
|
18
|
+
enabledBridges: string[];
|
|
19
|
+
_enabledBridges: Record<string, boolean>;
|
|
19
20
|
disabledExchanges: string[];
|
|
20
|
-
enabledExchanges:
|
|
21
|
+
enabledExchanges: string[];
|
|
22
|
+
_enabledExchanges: Record<string, boolean>;
|
|
21
23
|
}
|
|
22
24
|
export interface SettingsState extends SettingsProps {
|
|
23
25
|
setValue: ValueSetter<SettingsProps>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SettingsState } from './types.js';
|
|
2
|
-
export declare const useSettings: <K extends keyof SettingsState>(keys: Array<K>) => Pick<SettingsState,
|
|
2
|
+
export declare const useSettings: <K extends keyof SettingsState>(keys: Array<K>) => Pick<SettingsState, (typeof keys)[number]>;
|
|
@@ -13,8 +13,10 @@ export const defaultSettings = {
|
|
|
13
13
|
enabledAutoRefuel: true,
|
|
14
14
|
disabledBridges: [],
|
|
15
15
|
disabledExchanges: [],
|
|
16
|
-
enabledBridges:
|
|
17
|
-
enabledExchanges:
|
|
16
|
+
enabledBridges: [],
|
|
17
|
+
enabledExchanges: [],
|
|
18
|
+
_enabledBridges: {},
|
|
19
|
+
_enabledExchanges: {},
|
|
18
20
|
};
|
|
19
21
|
export const useSettingsStore = createWithEqualityFn(persist((set, get) => ({
|
|
20
22
|
...defaultSettings,
|
|
@@ -39,40 +41,45 @@ export const useSettingsStore = createWithEqualityFn(persist((set, get) => ({
|
|
|
39
41
|
if (!reset) {
|
|
40
42
|
// Add new tools
|
|
41
43
|
tools.forEach((tool) => {
|
|
42
|
-
if (!Object.hasOwn(updatedState[`
|
|
43
|
-
updatedState[`
|
|
44
|
+
if (!Object.hasOwn(updatedState[`_enabled${toolType}`], tool)) {
|
|
45
|
+
updatedState[`_enabled${toolType}`][tool] = true;
|
|
44
46
|
}
|
|
45
47
|
});
|
|
46
48
|
// Filter tools we no longer have
|
|
47
|
-
updatedState[`
|
|
49
|
+
updatedState[`_enabled${toolType}`] = Object.fromEntries(Object.entries(updatedState[`_enabled${toolType}`]).filter(([key]) => tools.includes(key)));
|
|
48
50
|
}
|
|
49
51
|
else {
|
|
50
52
|
tools.forEach((tool) => {
|
|
51
|
-
updatedState[`
|
|
53
|
+
updatedState[`_enabled${toolType}`][tool] = true;
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
|
-
|
|
56
|
+
const enabledToolKeys = Object.keys(updatedState[`_enabled${toolType}`]);
|
|
57
|
+
updatedState[`enabled${toolType}`] = enabledToolKeys.filter((key) => updatedState[`_enabled${toolType}`][key]);
|
|
58
|
+
updatedState[`disabled${toolType}`] = enabledToolKeys.filter((key) => !updatedState[`_enabled${toolType}`][key]);
|
|
55
59
|
return updatedState;
|
|
56
60
|
});
|
|
57
61
|
},
|
|
58
62
|
setToolValue: (toolType, tool, value) => set((state) => {
|
|
59
63
|
const enabledTools = {
|
|
60
|
-
...state[`
|
|
64
|
+
...state[`_enabled${toolType}`],
|
|
61
65
|
[tool]: value,
|
|
62
66
|
};
|
|
67
|
+
const enabledToolKeys = Object.keys(enabledTools);
|
|
63
68
|
return {
|
|
64
|
-
[`
|
|
65
|
-
[`
|
|
69
|
+
[`_enabled${toolType}`]: enabledTools,
|
|
70
|
+
[`enabled${toolType}`]: enabledToolKeys.filter((key) => enabledTools[key]),
|
|
71
|
+
[`disabled${toolType}`]: enabledToolKeys.filter((key) => !enabledTools[key]),
|
|
66
72
|
};
|
|
67
73
|
}),
|
|
68
74
|
toggleTools: (toolType) => set((state) => {
|
|
69
|
-
const enabledTools = { ...state[`
|
|
75
|
+
const enabledTools = { ...state[`_enabled${toolType}`] };
|
|
70
76
|
const enableAll = Boolean(state[`disabled${toolType}`].length);
|
|
71
77
|
for (const toolKey in enabledTools) {
|
|
72
78
|
enabledTools[toolKey] = enableAll;
|
|
73
79
|
}
|
|
74
80
|
return {
|
|
75
|
-
[`
|
|
81
|
+
[`_enabled${toolType}`]: enabledTools,
|
|
82
|
+
[`enabled${toolType}`]: enableAll ? Object.keys(enabledTools) : [],
|
|
76
83
|
[`disabled${toolType}`]: enableAll ? [] : Object.keys(enabledTools),
|
|
77
84
|
};
|
|
78
85
|
}),
|
|
@@ -89,13 +96,15 @@ export const useSettingsStore = createWithEqualityFn(persist((set, get) => ({
|
|
|
89
96
|
name: `li.fi-widget-settings`,
|
|
90
97
|
version: 4,
|
|
91
98
|
partialize: (state) => {
|
|
92
|
-
const { disabledBridges, disabledExchanges, ...partializedState } = state;
|
|
99
|
+
const { disabledBridges, disabledExchanges, enabledBridges, enabledExchanges, ...partializedState } = state;
|
|
93
100
|
return partializedState;
|
|
94
101
|
},
|
|
95
102
|
merge: (persistedState, currentState) => {
|
|
96
103
|
const state = { ...currentState, ...persistedState };
|
|
97
104
|
SettingsToolTypes.forEach((toolType) => {
|
|
98
|
-
|
|
105
|
+
const enabledToolKeys = Object.keys(persistedState[`_enabled${toolType}`]);
|
|
106
|
+
state[`enabled${toolType}`] = enabledToolKeys.filter((key) => persistedState[`_enabled${toolType}`][key]);
|
|
107
|
+
state[`disabled${toolType}`] = enabledToolKeys.filter((key) => !persistedState[`_enabled${toolType}`][key]);
|
|
99
108
|
});
|
|
100
109
|
return state;
|
|
101
110
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSettingsStore.js","sourceRoot":"","sources":["../../../stores/settings/useSettingsStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAErC,MAAM,CAAC,MAAM,2BAA2B,GAGpC;IACF,aAAa,EAAE,UAAU;IACzB,QAAQ,EAAE,eAAe;IACzB,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,QAAQ;IAClB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,EAAE;IACrB,cAAc,EAAE,EAAE;IAClB,g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B,GAAG,CAAC,MAAqB,EAAE,EAAE;IAC1D,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,GACnD,gBAAgB,CAAC,QAAQ,EAAE,CAAC;IAC9B,MAAM,eAAe,GACnB,CAAC,MAAM,EAAE,QAAQ,IAAI,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;IAC7E,MAAM,oBAAoB,GACxB,MAAM,EAAE,aAAa,IAAI,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC;IAClE,2BAA2B,CAAC,QAAQ,GAAG,CACrC,eAAe,IAAI,2BAA2B,CAAC,QAAQ,CACxD,EAAE,QAAQ,EAAE,CAAC;IACd,2BAA2B,CAAC,aAAa;QACvC,oBAAoB,IAAI,2BAA2B,CAAC,aAAa,CAAC;IACpE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,QAAQ,CAAC,eAAe,EAAE,2BAA2B,CAAC,aAAa,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" resolution-mode="require"/>
|
|
2
1
|
import type { SplitSubvariantProps, SplitSubvariantProviderProps, SplitSubvariantState, SplitSubvariantStore } from './types.js';
|
|
3
2
|
export declare const SplitSubvariantStoreContext: import("react").Context<SplitSubvariantStore | null>;
|
|
4
3
|
export declare function SplitSubvariantStoreProvider({ children, ...props }: SplitSubvariantProviderProps): import("react/jsx-runtime").JSX.Element;
|
package/config/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '3.0.
|
|
2
|
+
export const version = '3.0.1';
|
package/hooks/useRoutes.ts
CHANGED
|
@@ -24,19 +24,24 @@ interface RoutesProps {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
|
|
27
|
-
const { subvariant, sdkConfig, insurance, contractTool } =
|
|
27
|
+
const { subvariant, sdkConfig, insurance, contractTool, bridges, exchanges } =
|
|
28
|
+
useWidgetConfig();
|
|
28
29
|
const queryClient = useQueryClient();
|
|
29
30
|
const emitter = useWidgetEvents();
|
|
30
31
|
const swapOnly = useSwapOnly();
|
|
31
32
|
const {
|
|
32
33
|
disabledBridges,
|
|
33
34
|
disabledExchanges,
|
|
35
|
+
enabledBridges,
|
|
36
|
+
enabledExchanges,
|
|
34
37
|
enabledAutoRefuel,
|
|
35
38
|
routePriority,
|
|
36
39
|
slippage,
|
|
37
40
|
} = useSettings([
|
|
38
41
|
'disabledBridges',
|
|
39
42
|
'disabledExchanges',
|
|
43
|
+
'enabledBridges',
|
|
44
|
+
'enabledExchanges',
|
|
40
45
|
'enabledAutoRefuel',
|
|
41
46
|
'routePriority',
|
|
42
47
|
'slippage',
|
|
@@ -87,6 +92,16 @@ export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
|
|
|
87
92
|
// toAddress might be an empty string, but we need to pass undefined if there is no value
|
|
88
93
|
const toWalletAddress = toAddress || undefined;
|
|
89
94
|
|
|
95
|
+
// We need to send the full allowed tools array if custom tool settings are applied
|
|
96
|
+
const allowedBridges =
|
|
97
|
+
bridges?.allow?.length || bridges?.deny?.length
|
|
98
|
+
? enabledBridges
|
|
99
|
+
: undefined;
|
|
100
|
+
const allowedExchanges =
|
|
101
|
+
exchanges?.allow?.length || exchanges?.deny?.length
|
|
102
|
+
? enabledExchanges
|
|
103
|
+
: undefined;
|
|
104
|
+
|
|
90
105
|
const isEnabled =
|
|
91
106
|
Boolean(Number(fromChainId)) &&
|
|
92
107
|
Boolean(Number(toChainId)) &&
|
|
@@ -113,6 +128,8 @@ export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
|
|
|
113
128
|
swapOnly,
|
|
114
129
|
disabledBridges,
|
|
115
130
|
disabledExchanges,
|
|
131
|
+
allowedBridges,
|
|
132
|
+
allowedExchanges,
|
|
116
133
|
routePriority,
|
|
117
134
|
subvariant,
|
|
118
135
|
sdkConfig?.routeOptions?.allowSwitchChain,
|
|
@@ -141,6 +158,8 @@ export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
|
|
|
141
158
|
swapOnly,
|
|
142
159
|
disabledBridges,
|
|
143
160
|
disabledExchanges,
|
|
161
|
+
allowedBridges,
|
|
162
|
+
allowedExchanges,
|
|
144
163
|
routePriority,
|
|
145
164
|
subvariant,
|
|
146
165
|
allowSwitchChain,
|
|
@@ -157,7 +176,7 @@ export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
|
|
|
157
176
|
).toString();
|
|
158
177
|
const formattedSlippage = parseFloat(slippage) / 100;
|
|
159
178
|
|
|
160
|
-
const
|
|
179
|
+
const allowBridges = swapOnly
|
|
161
180
|
? []
|
|
162
181
|
: insurableRoute
|
|
163
182
|
? insurableRoute.steps.flatMap((step) =>
|
|
@@ -168,9 +187,9 @@ export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
|
|
|
168
187
|
return toolKeys;
|
|
169
188
|
}, [] as string[]),
|
|
170
189
|
)
|
|
171
|
-
:
|
|
190
|
+
: allowedBridges;
|
|
172
191
|
|
|
173
|
-
const
|
|
192
|
+
const allowExchanges = insurableRoute
|
|
174
193
|
? insurableRoute.steps.flatMap((step) =>
|
|
175
194
|
step.includedSteps.reduce((toolKeys, includedStep) => {
|
|
176
195
|
if (includedStep.type === 'swap') {
|
|
@@ -179,7 +198,7 @@ export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
|
|
|
179
198
|
return toolKeys;
|
|
180
199
|
}, [] as string[]),
|
|
181
200
|
)
|
|
182
|
-
:
|
|
201
|
+
: allowedExchanges;
|
|
183
202
|
|
|
184
203
|
if (subvariant === 'custom' && contractCalls && toTokenAmount) {
|
|
185
204
|
const contractCallQuote = await getContractCallsQuote(
|
|
@@ -196,8 +215,8 @@ export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
|
|
|
196
215
|
denyExchanges: disabledExchanges.length
|
|
197
216
|
? disabledExchanges
|
|
198
217
|
: undefined,
|
|
199
|
-
allowBridges
|
|
200
|
-
allowExchanges
|
|
218
|
+
allowBridges,
|
|
219
|
+
allowExchanges,
|
|
201
220
|
toFallbackAddress: toAddress,
|
|
202
221
|
slippage: formattedSlippage,
|
|
203
222
|
},
|
|
@@ -263,18 +282,18 @@ export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
|
|
|
263
282
|
allowSwitchChain:
|
|
264
283
|
subvariant === 'refuel' ? false : allowSwitchChain,
|
|
265
284
|
bridges:
|
|
266
|
-
|
|
285
|
+
allowBridges?.length || disabledBridges.length
|
|
267
286
|
? {
|
|
268
|
-
allow:
|
|
287
|
+
allow: allowBridges,
|
|
269
288
|
deny: disabledBridges.length
|
|
270
289
|
? disabledBridges
|
|
271
290
|
: undefined,
|
|
272
291
|
}
|
|
273
292
|
: undefined,
|
|
274
293
|
exchanges:
|
|
275
|
-
|
|
294
|
+
allowExchanges?.length || disabledExchanges.length
|
|
276
295
|
? {
|
|
277
|
-
allow:
|
|
296
|
+
allow: allowExchanges,
|
|
278
297
|
deny: disabledExchanges.length
|
|
279
298
|
? disabledExchanges
|
|
280
299
|
: undefined,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
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
|
"type": "module",
|
|
6
6
|
"main": "./_esm/index.js",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@emotion/react": "^11.11.4",
|
|
36
36
|
"@emotion/styled": "^11.11.5",
|
|
37
|
-
"@lifi/sdk": "^3.0.0
|
|
38
|
-
"@lifi/wallet-management": "^3.0.0
|
|
37
|
+
"@lifi/sdk": "^3.0.0",
|
|
38
|
+
"@lifi/wallet-management": "^3.0.0",
|
|
39
39
|
"@mui/icons-material": "^5.15.20",
|
|
40
40
|
"@mui/lab": "^5.0.0-alpha.170",
|
|
41
41
|
"@mui/material": "^5.15.20",
|
|
42
42
|
"@solana/wallet-adapter-base": "^0.9.23",
|
|
43
43
|
"@solana/wallet-adapter-react": "^0.15.35",
|
|
44
|
-
"@solana/web3.js": "^1.93.
|
|
45
|
-
"@tanstack/react-query": "^5.
|
|
46
|
-
"@tanstack/react-virtual": "^3.
|
|
44
|
+
"@solana/web3.js": "^1.93.2",
|
|
45
|
+
"@tanstack/react-query": "^5.48.0",
|
|
46
|
+
"@tanstack/react-virtual": "^3.7.0",
|
|
47
47
|
"i18next": "^23.11.5",
|
|
48
48
|
"microdiff": "^1.4.0",
|
|
49
49
|
"mitt": "^3.0.1",
|
|
@@ -51,23 +51,23 @@
|
|
|
51
51
|
"react-dom": "^18.3.1",
|
|
52
52
|
"react-i18next": "^14.1.2",
|
|
53
53
|
"react-intersection-observer": "^9.10.3",
|
|
54
|
-
"react-router-dom": "^6.
|
|
54
|
+
"react-router-dom": "^6.24.0",
|
|
55
55
|
"react-timer-hook": "^3.0.7",
|
|
56
56
|
"uuid": "^10.0.0",
|
|
57
|
-
"viem": "^2.
|
|
58
|
-
"wagmi": "^2.10.
|
|
59
|
-
"zustand": "^4.5.
|
|
57
|
+
"viem": "^2.16.2",
|
|
58
|
+
"wagmi": "^2.10.7",
|
|
59
|
+
"zustand": "^4.5.3"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@emotion/react": "^11.11.0",
|
|
63
63
|
"@emotion/styled": "^11.11.0",
|
|
64
|
-
"@lifi/sdk": "^3.0.0
|
|
65
|
-
"@lifi/wallet-management": "^3.0.0
|
|
64
|
+
"@lifi/sdk": "^3.0.0",
|
|
65
|
+
"@lifi/wallet-management": "^3.0.0",
|
|
66
66
|
"@mui/icons-material": "^5.15.0",
|
|
67
67
|
"@mui/material": "^5.15.0",
|
|
68
68
|
"@solana/wallet-adapter-base": "^0.9.0",
|
|
69
69
|
"@solana/wallet-adapter-react": "^0.15.0",
|
|
70
|
-
"@solana/web3.js": "^1.
|
|
70
|
+
"@solana/web3.js": "^1.93.0",
|
|
71
71
|
"@tanstack/react-query": "^5.17.0",
|
|
72
72
|
"@types/react": "^18.2.0",
|
|
73
73
|
"i18next": "^23.11.0",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"react-dom": "^18.2.0",
|
|
76
76
|
"react-i18next": "^14.1.0",
|
|
77
77
|
"react-router-dom": "^6.22.0",
|
|
78
|
-
"viem": "^2.
|
|
79
|
-
"wagmi": "^2.
|
|
78
|
+
"viem": "^2.16.0",
|
|
79
|
+
"wagmi": "^2.10.0",
|
|
80
80
|
"zustand": "^4.5.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependenciesMeta": {
|
|
@@ -67,7 +67,7 @@ export const SelectEnabledToolsPage: React.FC<{
|
|
|
67
67
|
const [enabledTools, disabledTools, setToolValue, toggleTools] =
|
|
68
68
|
useSettingsStore(
|
|
69
69
|
(state) => [
|
|
70
|
-
state[`
|
|
70
|
+
state[`_enabled${type}`],
|
|
71
71
|
state[`disabled${type}`],
|
|
72
72
|
state.setToolValue,
|
|
73
73
|
state.toggleTools,
|
package/stores/settings/types.ts
CHANGED
|
@@ -24,9 +24,11 @@ export interface SettingsProps {
|
|
|
24
24
|
enabledAutoRefuel: boolean;
|
|
25
25
|
slippage?: string;
|
|
26
26
|
disabledBridges: string[];
|
|
27
|
-
enabledBridges:
|
|
27
|
+
enabledBridges: string[];
|
|
28
|
+
_enabledBridges: Record<string, boolean>;
|
|
28
29
|
disabledExchanges: string[];
|
|
29
|
-
enabledExchanges:
|
|
30
|
+
enabledExchanges: string[];
|
|
31
|
+
_enabledExchanges: Record<string, boolean>;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export interface SettingsState extends SettingsProps {
|
|
@@ -22,8 +22,10 @@ export const defaultSettings: SettingsProps = {
|
|
|
22
22
|
enabledAutoRefuel: true,
|
|
23
23
|
disabledBridges: [],
|
|
24
24
|
disabledExchanges: [],
|
|
25
|
-
enabledBridges:
|
|
26
|
-
enabledExchanges:
|
|
25
|
+
enabledBridges: [],
|
|
26
|
+
enabledExchanges: [],
|
|
27
|
+
_enabledBridges: {},
|
|
28
|
+
_enabledExchanges: {},
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
export const useSettingsStore = createWithEqualityFn<SettingsState>(
|
|
@@ -53,49 +55,60 @@ export const useSettingsStore = createWithEqualityFn<SettingsState>(
|
|
|
53
55
|
if (!reset) {
|
|
54
56
|
// Add new tools
|
|
55
57
|
tools.forEach((tool) => {
|
|
56
|
-
if (!Object.hasOwn(updatedState[`
|
|
57
|
-
updatedState[`
|
|
58
|
+
if (!Object.hasOwn(updatedState[`_enabled${toolType}`], tool)) {
|
|
59
|
+
updatedState[`_enabled${toolType}`][tool] = true;
|
|
58
60
|
}
|
|
59
61
|
});
|
|
60
62
|
// Filter tools we no longer have
|
|
61
|
-
updatedState[`
|
|
62
|
-
Object.entries(updatedState[`
|
|
63
|
+
updatedState[`_enabled${toolType}`] = Object.fromEntries(
|
|
64
|
+
Object.entries(updatedState[`_enabled${toolType}`]).filter(
|
|
63
65
|
([key]) => tools.includes(key),
|
|
64
66
|
),
|
|
65
67
|
);
|
|
66
68
|
} else {
|
|
67
69
|
tools.forEach((tool) => {
|
|
68
|
-
updatedState[`
|
|
70
|
+
updatedState[`_enabled${toolType}`][tool] = true;
|
|
69
71
|
});
|
|
70
72
|
}
|
|
71
|
-
|
|
72
|
-
updatedState[`
|
|
73
|
-
)
|
|
73
|
+
const enabledToolKeys = Object.keys(
|
|
74
|
+
updatedState[`_enabled${toolType}`],
|
|
75
|
+
);
|
|
76
|
+
updatedState[`enabled${toolType}`] = enabledToolKeys.filter(
|
|
77
|
+
(key) => updatedState[`_enabled${toolType}`][key],
|
|
78
|
+
);
|
|
79
|
+
updatedState[`disabled${toolType}`] = enabledToolKeys.filter(
|
|
80
|
+
(key) => !updatedState[`_enabled${toolType}`][key],
|
|
81
|
+
);
|
|
74
82
|
return updatedState;
|
|
75
83
|
});
|
|
76
84
|
},
|
|
77
85
|
setToolValue: (toolType, tool, value) =>
|
|
78
86
|
set((state) => {
|
|
79
87
|
const enabledTools = {
|
|
80
|
-
...state[`
|
|
88
|
+
...state[`_enabled${toolType}`],
|
|
81
89
|
[tool]: value,
|
|
82
90
|
};
|
|
91
|
+
const enabledToolKeys = Object.keys(enabledTools);
|
|
83
92
|
return {
|
|
84
|
-
[`
|
|
85
|
-
[`
|
|
93
|
+
[`_enabled${toolType}`]: enabledTools,
|
|
94
|
+
[`enabled${toolType}`]: enabledToolKeys.filter(
|
|
95
|
+
(key) => enabledTools[key],
|
|
96
|
+
),
|
|
97
|
+
[`disabled${toolType}`]: enabledToolKeys.filter(
|
|
86
98
|
(key) => !enabledTools[key],
|
|
87
99
|
),
|
|
88
100
|
};
|
|
89
101
|
}),
|
|
90
102
|
toggleTools: (toolType) =>
|
|
91
103
|
set((state) => {
|
|
92
|
-
const enabledTools = { ...state[`
|
|
104
|
+
const enabledTools = { ...state[`_enabled${toolType}`] };
|
|
93
105
|
const enableAll = Boolean(state[`disabled${toolType}`].length);
|
|
94
106
|
for (const toolKey in enabledTools) {
|
|
95
107
|
enabledTools[toolKey] = enableAll;
|
|
96
108
|
}
|
|
97
109
|
return {
|
|
98
|
-
[`
|
|
110
|
+
[`_enabled${toolType}`]: enabledTools,
|
|
111
|
+
[`enabled${toolType}`]: enableAll ? Object.keys(enabledTools) : [],
|
|
99
112
|
[`disabled${toolType}`]: enableAll ? [] : Object.keys(enabledTools),
|
|
100
113
|
};
|
|
101
114
|
}),
|
|
@@ -113,16 +126,27 @@ export const useSettingsStore = createWithEqualityFn<SettingsState>(
|
|
|
113
126
|
name: `li.fi-widget-settings`,
|
|
114
127
|
version: 4,
|
|
115
128
|
partialize: (state) => {
|
|
116
|
-
const {
|
|
117
|
-
|
|
129
|
+
const {
|
|
130
|
+
disabledBridges,
|
|
131
|
+
disabledExchanges,
|
|
132
|
+
enabledBridges,
|
|
133
|
+
enabledExchanges,
|
|
134
|
+
...partializedState
|
|
135
|
+
} = state;
|
|
118
136
|
return partializedState;
|
|
119
137
|
},
|
|
120
138
|
merge: (persistedState: any, currentState: SettingsState) => {
|
|
121
139
|
const state = { ...currentState, ...persistedState };
|
|
122
140
|
SettingsToolTypes.forEach((toolType) => {
|
|
123
|
-
|
|
124
|
-
persistedState[`
|
|
125
|
-
)
|
|
141
|
+
const enabledToolKeys = Object.keys(
|
|
142
|
+
persistedState[`_enabled${toolType}`],
|
|
143
|
+
);
|
|
144
|
+
state[`enabled${toolType}`] = enabledToolKeys.filter(
|
|
145
|
+
(key) => persistedState[`_enabled${toolType}`][key],
|
|
146
|
+
);
|
|
147
|
+
state[`disabled${toolType}`] = enabledToolKeys.filter(
|
|
148
|
+
(key) => !persistedState[`_enabled${toolType}`][key],
|
|
149
|
+
);
|
|
126
150
|
});
|
|
127
151
|
return state;
|
|
128
152
|
},
|