@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.
Files changed (169) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +5 -3
  3. package/_esm/App.d.ts +0 -1
  4. package/_esm/AppDrawer.d.ts +1 -2
  5. package/_esm/AppDrawer.style.d.ts +1 -2
  6. package/_esm/AppDrawerContext.d.ts +0 -1
  7. package/_esm/AppRoutes.d.ts +0 -1
  8. package/_esm/components/ActiveTransactions/ActiveTransactionItem.d.ts +0 -1
  9. package/_esm/components/ActiveTransactions/ActiveTransactions.d.ts +0 -1
  10. package/_esm/components/ActiveTransactions/ActiveTransactions.style.d.ts +4 -5
  11. package/_esm/components/AlertMessage/AlertMessage.style.d.ts +2 -3
  12. package/_esm/components/AmountInput/AmountInput.style.d.ts +2 -3
  13. package/_esm/components/AmountInput/AmountInputAdornment.style.d.ts +2 -3
  14. package/_esm/components/AmountInput/AmountInputStartAdornment.d.ts +0 -1
  15. package/_esm/components/AmountInput/PriceFormHelperText.d.ts +0 -1
  16. package/_esm/components/AppContainer.d.ts +5 -5
  17. package/_esm/components/Avatar/Avatar.d.ts +0 -1
  18. package/_esm/components/Avatar/Avatar.style.d.ts +4 -5
  19. package/_esm/components/Avatar/TokenAvatar.d.ts +0 -1
  20. package/_esm/components/BaseTransactionButton/BaseTransactionButton.d.ts +0 -1
  21. package/_esm/components/BottomSheet/BottomSheet.d.ts +0 -1
  22. package/_esm/components/ButtonTertiary.d.ts +1 -2
  23. package/_esm/components/Card/Card.d.ts +1 -2
  24. package/_esm/components/Card/CardButton.style.d.ts +4 -5
  25. package/_esm/components/Card/CardHeader.d.ts +1 -2
  26. package/_esm/components/Card/CardIconButton.d.ts +1 -2
  27. package/_esm/components/Card/CardLabel.d.ts +4 -5
  28. package/_esm/components/Card/CardTitle.d.ts +2 -3
  29. package/_esm/components/Card/InputCard.d.ts +1 -2
  30. package/_esm/components/ChainSelect/ChainSelect.style.d.ts +2 -3
  31. package/_esm/components/ContractComponent/ItemPrice.d.ts +0 -1
  32. package/_esm/components/ContractComponent/NFT/NFT.d.ts +0 -1
  33. package/_esm/components/ContractComponent/NFT/NFT.style.d.ts +1 -2
  34. package/_esm/components/ContractComponent/NFT/NFTBase.d.ts +0 -1
  35. package/_esm/components/GasMessage/GasMessage.d.ts +0 -1
  36. package/_esm/components/GasMessage/GasRefuelMessage.d.ts +0 -1
  37. package/_esm/components/GasMessage/GasSufficiencyMessage.d.ts +0 -1
  38. package/_esm/components/Header/BackButton.d.ts +0 -1
  39. package/_esm/components/Header/Header.style.d.ts +8 -9
  40. package/_esm/components/Header/NavigationHeader.d.ts +0 -1
  41. package/_esm/components/Header/SettingsButton.style.d.ts +2 -3
  42. package/_esm/components/Header/WalletHeader.d.ts +0 -1
  43. package/_esm/components/Initializer.d.ts +0 -1
  44. package/_esm/components/Insurance/Insurance.d.ts +0 -1
  45. package/_esm/components/Insurance/InsuranceCard.d.ts +0 -1
  46. package/_esm/components/Insurance/InsuranceCollapsed.d.ts +0 -1
  47. package/_esm/components/ListItem/ListItem.d.ts +2 -3
  48. package/_esm/components/ListItem/ListItemButton.d.ts +1 -2
  49. package/_esm/components/ListItemButton.d.ts +1 -2
  50. package/_esm/components/ListItemText.d.ts +0 -1
  51. package/_esm/components/NotFound.d.ts +0 -1
  52. package/_esm/components/PageContainer.d.ts +1 -2
  53. package/_esm/components/PoweredBy/PoweredBy.d.ts +0 -1
  54. package/_esm/components/PoweredBy/PoweredBy.style.d.ts +1 -2
  55. package/_esm/components/ProgressToNextUpdate.d.ts +0 -1
  56. package/_esm/components/ReverseTokensButton/ReverseTokensButton.d.ts +0 -1
  57. package/_esm/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +3 -4
  58. package/_esm/components/RouteCard/RouteCard.d.ts +0 -1
  59. package/_esm/components/RouteCard/RouteCard.style.d.ts +2 -3
  60. package/_esm/components/RouteCard/RouteCardEssentials.d.ts +0 -1
  61. package/_esm/components/RouteCard/RouteCardEssentialsExpanded.d.ts +0 -1
  62. package/_esm/components/RouteCard/RouteCardSkeleton.d.ts +0 -1
  63. package/_esm/components/RouteCard/RouteNotFoundCard.d.ts +0 -1
  64. package/_esm/components/Routes/Routes.d.ts +0 -1
  65. package/_esm/components/Routes/RoutesExpanded.style.d.ts +4 -5
  66. package/_esm/components/Select.d.ts +1 -1
  67. package/_esm/components/SelectChainAndToken.d.ts +0 -1
  68. package/_esm/components/SelectTokenButton/SelectTokenButton.d.ts +0 -1
  69. package/_esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +5 -6
  70. package/_esm/components/SendToWallet/SendToWallet.style.d.ts +2 -3
  71. package/_esm/components/SendToWallet/SendToWalletButton.d.ts +0 -1
  72. package/_esm/components/SendToWallet/SendToWalletExpandButton.d.ts +0 -1
  73. package/_esm/components/SettingsListItemButton.d.ts +1 -2
  74. package/_esm/components/Skeleton/WidgetSkeleton.style.d.ts +10 -11
  75. package/_esm/components/SmallAvatar.d.ts +3 -4
  76. package/_esm/components/Step/CircularProgress.style.d.ts +3 -4
  77. package/_esm/components/Step/DestinationWalletAddress.d.ts +0 -1
  78. package/_esm/components/Step/Step.d.ts +0 -1
  79. package/_esm/components/Step/StepProcess.d.ts +0 -1
  80. package/_esm/components/Step/StepProcess.style.d.ts +4 -5
  81. package/_esm/components/Step/StepTimer.d.ts +0 -1
  82. package/_esm/components/StepActions/StepActions.d.ts +0 -1
  83. package/_esm/components/StepActions/StepActions.style.d.ts +4 -5
  84. package/_esm/components/StepActions/StepFeeBreakdown.d.ts +0 -1
  85. package/_esm/components/StepActions/StepFees.d.ts +0 -1
  86. package/_esm/components/StepDivider/StepDivider.d.ts +0 -1
  87. package/_esm/components/StepDivider/StepDivider.style.d.ts +1 -2
  88. package/_esm/components/Tabs/Tabs.style.d.ts +4 -5
  89. package/_esm/components/ToAddressRequiredMessage.d.ts +0 -1
  90. package/_esm/components/Token/Token.style.d.ts +4 -5
  91. package/_esm/components/TokenList/TokenList.style.d.ts +6 -7
  92. package/_esm/components/TokenList/TokenListItem.d.ts +0 -1
  93. package/_esm/components/TokenList/TokenNotFound.d.ts +0 -1
  94. package/_esm/config/version.d.ts +1 -1
  95. package/_esm/config/version.js +1 -1
  96. package/_esm/config/version.js.map +1 -1
  97. package/_esm/hooks/useChains.d.ts +1 -1
  98. package/_esm/hooks/useDebouncedWatch.d.ts +2 -1
  99. package/_esm/hooks/useProcessMessage.d.ts +2 -2
  100. package/_esm/hooks/useRoutes.d.ts +1 -1
  101. package/_esm/hooks/useRoutes.js +24 -13
  102. package/_esm/hooks/useRoutes.js.map +1 -1
  103. package/_esm/hooks/useTokenAddressBalance.d.ts +1 -1
  104. package/_esm/hooks/useTokenBalance.d.ts +1 -1
  105. package/_esm/hooks/useTokenBalances.d.ts +1 -1
  106. package/_esm/pages/ActiveTransactionsPage/ActiveTransactionsEmpty.d.ts +0 -1
  107. package/_esm/pages/LanguagesPage.d.ts +0 -1
  108. package/_esm/pages/MainPage/MainMessages.d.ts +0 -1
  109. package/_esm/pages/MainPage/MainPage.d.ts +0 -1
  110. package/_esm/pages/MainPage/MainPage.style.d.ts +1 -2
  111. package/_esm/pages/MainPage/ReviewButton.d.ts +0 -1
  112. package/_esm/pages/RoutesPage/RoutesPage.d.ts +0 -1
  113. package/_esm/pages/RoutesPage/RoutesPage.style.d.ts +1 -2
  114. package/_esm/pages/SelectChainPage/SelectChainPage.d.ts +0 -1
  115. package/_esm/pages/SelectEnabledToolsPage.d.ts +0 -1
  116. package/_esm/pages/SelectEnabledToolsPage.js +1 -1
  117. package/_esm/pages/SelectEnabledToolsPage.js.map +1 -1
  118. package/_esm/pages/SelectNativeTokenPage.d.ts +0 -1
  119. package/_esm/pages/SendToWallet/BookmarkAddressSheet.d.ts +0 -1
  120. package/_esm/pages/SendToWallet/ConfirmAddressSheet.d.ts +0 -1
  121. package/_esm/pages/SendToWallet/SendToWalletPage.style.d.ts +13 -14
  122. package/_esm/pages/SettingsPage/BridgeAndExchangeSettings.d.ts +0 -1
  123. package/_esm/pages/SettingsPage/GasPriceSettings.d.ts +0 -1
  124. package/_esm/pages/SettingsPage/LanguageSetting.d.ts +0 -1
  125. package/_esm/pages/SettingsPage/ResetSettingsButton.d.ts +0 -1
  126. package/_esm/pages/SettingsPage/ResetSettingsButton.style.d.ts +1 -2
  127. package/_esm/pages/SettingsPage/RoutePrioritySettings.d.ts +0 -1
  128. package/_esm/pages/SettingsPage/SettingsCard/SettingCard.style.d.ts +2 -3
  129. package/_esm/pages/SettingsPage/SlippageSettings/SlippageSettings.d.ts +0 -1
  130. package/_esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.d.ts +3 -4
  131. package/_esm/pages/SettingsPage/ThemeSettings.d.ts +0 -1
  132. package/_esm/pages/TransactionDetailsPage/TransactionDetailsPage.d.ts +0 -1
  133. package/_esm/pages/TransactionHistoryPage/TransactionHistoryEmpty.d.ts +0 -1
  134. package/_esm/pages/TransactionHistoryPage/TransactionHistoryItem.d.ts +0 -1
  135. package/_esm/pages/TransactionHistoryPage/TransactionHistoryPage.d.ts +0 -1
  136. package/_esm/pages/TransactionPage/ExchangeRateBottomSheet.d.ts +0 -1
  137. package/_esm/pages/TransactionPage/StartTransactionButton.d.ts +0 -1
  138. package/_esm/pages/TransactionPage/StatusBottomSheet.d.ts +0 -1
  139. package/_esm/pages/TransactionPage/StatusBottomSheet.style.d.ts +3 -4
  140. package/_esm/pages/TransactionPage/TokenValueBottomSheet.d.ts +0 -1
  141. package/_esm/pages/TransactionPage/TransactionPage.d.ts +0 -1
  142. package/_esm/providers/I18nProvider/I18nProvider.d.ts +0 -1
  143. package/_esm/providers/ThemeProvider/ThemeProvider.d.ts +0 -1
  144. package/_esm/providers/WalletProvider/EVMExternalContext.d.ts +0 -1
  145. package/_esm/providers/WalletProvider/SVMExternalContext.d.ts +0 -1
  146. package/_esm/providers/WidgetProvider/WidgetProvider.d.ts +0 -1
  147. package/_esm/stores/bookmarks/BookmarkStore.d.ts +0 -1
  148. package/_esm/stores/chains/ChainOrderStore.d.ts +0 -1
  149. package/_esm/stores/form/FormStoreContext.d.ts +0 -1
  150. package/_esm/stores/form/FormUpdater.d.ts +0 -1
  151. package/_esm/stores/form/types.d.ts +3 -3
  152. package/_esm/stores/form/useFieldValues.d.ts +2 -2
  153. package/_esm/stores/form/useValidation.d.ts +1 -1
  154. package/_esm/stores/header/types.d.ts +0 -1
  155. package/_esm/stores/header/useHeaderStore.d.ts +0 -1
  156. package/_esm/stores/routes/RouteExecutionStore.d.ts +0 -1
  157. package/_esm/stores/routes/useSetExecutableRoute.d.ts +1 -1
  158. package/_esm/stores/settings/types.d.ts +4 -2
  159. package/_esm/stores/settings/useAppearance.d.ts +1 -4
  160. package/_esm/stores/settings/useSettings.d.ts +1 -1
  161. package/_esm/stores/settings/useSettingsStore.js +23 -14
  162. package/_esm/stores/settings/useSettingsStore.js.map +1 -1
  163. package/_esm/stores/settings/useSplitSubvariantStore.d.ts +0 -1
  164. package/config/version.ts +1 -1
  165. package/hooks/useRoutes.ts +30 -11
  166. package/package.json +15 -15
  167. package/pages/SelectEnabledToolsPage.tsx +1 -1
  168. package/stores/settings/types.ts +4 -2
  169. 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 { Route } from '@lifi/sdk';
3
2
  import type { BottomSheetBase } from '../../components/BottomSheet/types.js';
4
3
  interface TokenValueBottomSheetProps {
@@ -1,2 +1 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  export declare const TransactionPage: React.FC;
@@ -1,2 +1 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  export declare const I18nProvider: React.FC<React.PropsWithChildren>;
@@ -1,2 +1 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  export declare const ThemeProvider: React.FC<React.PropsWithChildren<{}>>;
@@ -1,2 +1 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  export declare const EVMExternalContext: import("react").Context<boolean>;
@@ -1,2 +1 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  export declare const SVMExternalContext: import("react").Context<boolean>;
@@ -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>>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  import { shallow } from 'zustand/shallow';
3
2
  import type { PersistStoreProviderProps } from '../types.js';
4
3
  import type { BookmarkState, BookmarkStore } from './types.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  import type { StoreApi } from 'zustand';
3
2
  import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
4
3
  import type { PersistStoreProviderProps } from '../types.js';
@@ -1,3 +1,2 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  import type { FormStoreStore } from './types.js';
3
2
  export declare const FormStoreContext: import("react").Context<FormStoreStore | null>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  import type { DefaultValues } from './types.js';
3
2
  export declare const FormUpdater: React.FC<{
4
3
  defaultValues: Partial<DefaultValues>;
@@ -74,8 +74,8 @@ export interface FormTypeProps {
74
74
  formType: FormType;
75
75
  }
76
76
  export declare const FormKeyHelper: {
77
- getChainKey: (formType: FormType) => 'fromChain' | 'toChain';
78
- getTokenKey: (formType: FormType) => 'fromToken' | 'toToken';
79
- getAmountKey: (formType: FormType) => 'fromAmount' | 'toAmount';
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 (keyof import("./types.js").DefaultValues)[]>(...names: T) => FormFieldArray<T>;
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, 'validation'>;
2
+ export declare const useValidation: () => Omit<ValidationProps, "validation">;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  import type { StoreApi } from 'zustand';
3
2
  import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
4
3
  export type HeaderStore = UseBoundStoreWithEqualityFn<StoreApi<HeaderState>>;
@@ -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,4 +1,3 @@
1
- /// <reference types="react" resolution-mode="require"/>
2
1
  import type { StoreApi } from 'zustand';
3
2
  import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
4
3
  import type { PersistStoreProviderProps } from '../types.js';
@@ -1 +1 @@
1
- export declare const useSetExecutableRoute: () => (route: import("@lifi/types").Route, insurableRouteId?: string | undefined) => void;
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: Record<string, boolean>;
18
+ enabledBridges: string[];
19
+ _enabledBridges: Record<string, boolean>;
19
20
  disabledExchanges: string[];
20
- enabledExchanges: Record<string, boolean>;
21
+ enabledExchanges: string[];
22
+ _enabledExchanges: Record<string, boolean>;
21
23
  }
22
24
  export interface SettingsState extends SettingsProps {
23
25
  setValue: ValueSetter<SettingsProps>;
@@ -1,5 +1,2 @@
1
1
  import type { Appearance } from '../../types/widget.js';
2
- export declare const useAppearance: () => [
3
- Appearance,
4
- (appearance: Appearance) => void
5
- ];
2
+ export declare const useAppearance: () => [Appearance, (appearance: Appearance) => void];
@@ -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, K>;
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[`enabled${toolType}`], tool)) {
43
- updatedState[`enabled${toolType}`][tool] = true;
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[`enabled${toolType}`] = Object.fromEntries(Object.entries(updatedState[`enabled${toolType}`]).filter(([key]) => tools.includes(key)));
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[`enabled${toolType}`][tool] = true;
53
+ updatedState[`_enabled${toolType}`][tool] = true;
52
54
  });
53
55
  }
54
- updatedState[`disabled${toolType}`] = Object.keys(updatedState[`enabled${toolType}`]).filter((key) => !updatedState[`enabled${toolType}`][key]);
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[`enabled${toolType}`],
64
+ ...state[`_enabled${toolType}`],
61
65
  [tool]: value,
62
66
  };
67
+ const enabledToolKeys = Object.keys(enabledTools);
63
68
  return {
64
- [`enabled${toolType}`]: enabledTools,
65
- [`disabled${toolType}`]: Object.keys(enabledTools).filter((key) => !enabledTools[key]),
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[`enabled${toolType}`] };
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
- [`enabled${toolType}`]: enabledTools,
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
- state[`disabled${toolType}`] = Object.keys(persistedState[`enabled${toolType}`]).filter((key) => !persistedState[`enabled${toolType}`][key]);
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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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.0-beta.4';
2
+ export const version = '3.0.1';
@@ -24,19 +24,24 @@ interface RoutesProps {
24
24
  }
25
25
 
26
26
  export const useRoutes = ({ insurableRoute }: RoutesProps = {}) => {
27
- const { subvariant, sdkConfig, insurance, contractTool } = useWidgetConfig();
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 allowedBridges = swapOnly
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
- : undefined;
190
+ : allowedBridges;
172
191
 
173
- const allowedExchanges = insurableRoute
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
- : undefined;
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: allowedBridges,
200
- allowExchanges: allowedExchanges,
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
- allowedBridges?.length || disabledBridges.length
285
+ allowBridges?.length || disabledBridges.length
267
286
  ? {
268
- allow: allowedBridges,
287
+ allow: allowBridges,
269
288
  deny: disabledBridges.length
270
289
  ? disabledBridges
271
290
  : undefined,
272
291
  }
273
292
  : undefined,
274
293
  exchanges:
275
- allowedExchanges?.length || disabledExchanges.length
294
+ allowExchanges?.length || disabledExchanges.length
276
295
  ? {
277
- allow: allowedExchanges,
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.0-beta.4",
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-beta.1",
38
- "@lifi/wallet-management": "^3.0.0-beta.4",
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.0",
45
- "@tanstack/react-query": "^5.45.1",
46
- "@tanstack/react-virtual": "^3.5.1",
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.23.1",
54
+ "react-router-dom": "^6.24.0",
55
55
  "react-timer-hook": "^3.0.7",
56
56
  "uuid": "^10.0.0",
57
- "viem": "^2.15.1",
58
- "wagmi": "^2.10.2",
59
- "zustand": "^4.5.2"
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-beta.0",
65
- "@lifi/wallet-management": "^3.0.0-beta.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.91.0",
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.12.0",
79
- "wagmi": "^2.9.0",
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[`enabled${type}`],
70
+ state[`_enabled${type}`],
71
71
  state[`disabled${type}`],
72
72
  state.setToolValue,
73
73
  state.toggleTools,
@@ -24,9 +24,11 @@ export interface SettingsProps {
24
24
  enabledAutoRefuel: boolean;
25
25
  slippage?: string;
26
26
  disabledBridges: string[];
27
- enabledBridges: Record<string, boolean>;
27
+ enabledBridges: string[];
28
+ _enabledBridges: Record<string, boolean>;
28
29
  disabledExchanges: string[];
29
- enabledExchanges: Record<string, boolean>;
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[`enabled${toolType}`], tool)) {
57
- updatedState[`enabled${toolType}`][tool] = true;
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[`enabled${toolType}`] = Object.fromEntries(
62
- Object.entries(updatedState[`enabled${toolType}`]).filter(
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[`enabled${toolType}`][tool] = true;
70
+ updatedState[`_enabled${toolType}`][tool] = true;
69
71
  });
70
72
  }
71
- updatedState[`disabled${toolType}`] = Object.keys(
72
- updatedState[`enabled${toolType}`],
73
- ).filter((key) => !updatedState[`enabled${toolType}`][key]);
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[`enabled${toolType}`],
88
+ ...state[`_enabled${toolType}`],
81
89
  [tool]: value,
82
90
  };
91
+ const enabledToolKeys = Object.keys(enabledTools);
83
92
  return {
84
- [`enabled${toolType}`]: enabledTools,
85
- [`disabled${toolType}`]: Object.keys(enabledTools).filter(
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[`enabled${toolType}`] };
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
- [`enabled${toolType}`]: enabledTools,
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 { disabledBridges, disabledExchanges, ...partializedState } =
117
- state;
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
- state[`disabled${toolType}`] = Object.keys(
124
- persistedState[`enabled${toolType}`],
125
- ).filter((key) => !persistedState[`enabled${toolType}`][key]);
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
  },