@lifi/widget 1.12.0 → 1.13.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 (102) hide show
  1. package/AppDrawer.style.d.ts +1 -1
  2. package/AppDrawer.style.js +6 -2
  3. package/AppProvider.d.ts +4 -0
  4. package/AppProvider.js +5 -2
  5. package/components/Header/Header.js +1 -0
  6. package/components/Initializer.js +1 -1
  7. package/components/LiFiLogo.js +1 -2
  8. package/components/PoweredBy/PoweredBy.js +3 -2
  9. package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
  10. package/components/Step/CircularProgress.d.ts +0 -1
  11. package/components/Step/Step.js +4 -1
  12. package/components/Step/StepProcess.style.d.ts +1 -1
  13. package/components/StepActions/StepActions.js +5 -3
  14. package/components/SwapButton/ButtonTooltip.d.ts +0 -1
  15. package/components/SwapButton/SwapButton.js +7 -4
  16. package/components/SwapButton/SwapButton.style.d.ts +1 -1
  17. package/components/SwapInput/FormPriceHelperText.js +2 -2
  18. package/components/SwapInput/SwapInput.style.d.ts +1 -1
  19. package/components/SwapInput/SwapInputAdornment.d.ts +0 -1
  20. package/components/SwapInput/SwapInputAdornment.js +2 -2
  21. package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
  22. package/components/SwapRouteCard/SwapRouteCard.style.js +4 -1
  23. package/components/TokenAvatar/TokenAvatar.js +3 -2
  24. package/components/TokenList/TokenList.js +25 -42
  25. package/components/TokenList/TokenList.style.d.ts +2 -2
  26. package/components/TokenList/TokenList.style.js +5 -2
  27. package/components/TokenList/TokenListItem.d.ts +2 -2
  28. package/components/TokenList/TokenListItem.js +7 -10
  29. package/components/TokenList/TokenNotFound.d.ts +2 -0
  30. package/components/TokenList/TokenNotFound.js +15 -0
  31. package/components/TokenList/VirtualizedTokenList.d.ts +3 -0
  32. package/components/TokenList/VirtualizedTokenList.js +53 -0
  33. package/components/TokenList/types.d.ts +16 -1
  34. package/config/lifi.d.ts +1 -1
  35. package/config/lifi.js +2 -8
  36. package/config/sentry.d.ts +1 -1
  37. package/config/sentry.js +33 -18
  38. package/config/theme.js +14 -11
  39. package/config/version.d.ts +1 -1
  40. package/config/version.js +1 -1
  41. package/hooks/index.d.ts +3 -0
  42. package/hooks/index.js +3 -0
  43. package/hooks/useFeaturedTokens.d.ts +1 -0
  44. package/hooks/useFeaturedTokens.js +6 -0
  45. package/hooks/useGasSufficiency.js +11 -4
  46. package/hooks/useRouteExecution.js +31 -17
  47. package/hooks/useSwapRoutes.js +2 -2
  48. package/hooks/useToken.d.ts +2 -1
  49. package/hooks/useToken.js +2 -1
  50. package/hooks/useTokenBalance.d.ts +2 -4
  51. package/hooks/useTokenBalance.js +11 -42
  52. package/hooks/useTokenBalances.d.ts +6 -3
  53. package/hooks/useTokenBalances.js +46 -22
  54. package/hooks/useTokenSearch.d.ts +7 -0
  55. package/hooks/useTokenSearch.js +37 -0
  56. package/hooks/useTokens.d.ts +2 -1
  57. package/hooks/useTokens.js +12 -4
  58. package/i18n/en/translation.json +2 -0
  59. package/i18n/index.d.ts +2 -0
  60. package/icons/LiFiFullLogo.d.ts +2 -0
  61. package/icons/LiFiFullLogo.js +2 -0
  62. package/icons/LiFiLogo.d.ts +2 -0
  63. package/icons/LiFiLogo.js +2 -0
  64. package/icons/LiFiToolLogo.d.ts +2 -0
  65. package/icons/LiFiToolLogo.js +2 -0
  66. package/icons/index.d.ts +3 -0
  67. package/icons/index.js +3 -0
  68. package/package.json +13 -14
  69. package/pages/MainPage/SwapRoutes.style.d.ts +1 -1
  70. package/pages/SelectTokenPage/ChainSelect.d.ts +0 -1
  71. package/pages/SelectTokenPage/ChainSelect.js +8 -5
  72. package/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
  73. package/pages/SelectTokenPage/SearchTokenInput.js +2 -2
  74. package/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
  75. package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -2
  76. package/pages/SettingsPage/AdvancedPreferences.d.ts +0 -1
  77. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  78. package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
  79. package/pages/SettingsPage/SettingsPage.d.ts +0 -1
  80. package/pages/SettingsPage/SlippageInput.d.ts +0 -1
  81. package/pages/SwapPage/StatusBottomSheet.js +2 -2
  82. package/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +1 -1
  83. package/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -1
  84. package/providers/SwapFormProvider/SwapFormProvider.js +28 -5
  85. package/providers/SwapFormProvider/types.d.ts +2 -3
  86. package/providers/SwapFormProvider/types.js +1 -2
  87. package/providers/WalletProvider/WalletProvider.d.ts +11 -1
  88. package/providers/WalletProvider/WalletProvider.js +24 -33
  89. package/providers/WidgetProvider/WidgetProvider.js +24 -12
  90. package/stores/route/useRouteStore.js +0 -12
  91. package/types/index.d.ts +1 -0
  92. package/types/index.js +1 -0
  93. package/types/token.d.ts +4 -0
  94. package/types/token.js +1 -0
  95. package/types/widget.d.ts +4 -3
  96. package/utils/colors.d.ts +1 -0
  97. package/utils/colors.js +5 -0
  98. package/components/TokenList/utils.d.ts +0 -15
  99. package/components/TokenList/utils.js +0 -10
  100. package/icons/LiFiFullLogo.svg +0 -10
  101. package/icons/LiFiLogo.svg +0 -5
  102. package/icons/LiFiToolLogo.svg +0 -6
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const LiFiFullLogo = (props) => (_jsxs("svg", Object.assign({ width: "84", height: "32", viewBox: "0 0 84 32", fill: "inherit", xmlns: "http://www.w3.org/2000/svg" }, props, { children: [_jsx("path", { d: "M50.6689 20.5714H42.6849V8H39V24H50.6689V20.5714Z" }), _jsx("path", { d: "M53.0717 24H56.7566V8H53.0717V24Z" }), _jsx("path", { d: "M59.5088 24H63.0117V20.48H59.5088V24Z" }), _jsx("path", { d: "M69.4396 17.76H77.1506V14.6057H69.4396V11.2457H77.8103V8H65.7547V24H69.4396V17.76Z" }), _jsx("path", { d: "M80.3151 24H84V8H80.3151V24Z" }), _jsx("path", { d: "M14.6163 21.6947L5.1336 23.89C4.78772 23.9766 4.52832 24.3232 4.52832 24.6698V31.1978C4.52832 31.7467 4.96066 32.0933 5.50829 31.9777L18.7379 28.9159C19.2856 28.8004 19.5162 28.2805 19.2856 27.7894L16.8933 22.8501C16.5186 22.0702 16.8933 21.2614 17.7291 21.0881L26.376 19.0084C26.9813 18.864 27.5001 18.2285 27.5001 17.593V11.5561C27.5001 11.0073 27.0677 10.6318 26.5201 10.7762L14.0398 13.7514C13.2616 13.9247 12.9157 14.6757 13.2616 15.3978L15.4521 19.9327C15.8268 20.7126 15.4521 21.4925 14.6163 21.6947Z" }), _jsx("path", { d: "M8.36225 5.3748L10.841 10.4585C11.1581 11.1229 10.841 11.8161 10.1204 11.9606L5.53762 13.0293C4.96116 13.1737 4.5 13.7514 4.5 14.3291V19.7884C4.5 20.7127 5.24939 21.2904 6.1429 21.0882L10.4087 20.1061C10.9851 19.9906 11.4463 19.384 11.4463 18.8063L11.4751 13.2026C11.4751 12.4227 12.1092 11.6428 12.8586 11.4695L26.8376 8.11886C27.1835 8.03221 27.4429 7.68559 27.4429 7.33897V0.810981C27.4429 0.262168 27.0106 -0.113336 26.4629 0.0310883L8.90988 4.24829C8.36225 4.36383 8.13167 4.88375 8.36225 5.3748Z" })] })));
@@ -0,0 +1,2 @@
1
+ import { SVGProps } from 'react';
2
+ export declare const LiFiLogo: (props: SVGProps<SVGSVGElement>) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const LiFiLogo = (props) => (_jsxs("svg", Object.assign({ width: "32", height: "32", viewBox: "0 0 32 32", fill: "inherit", xmlns: "http://www.w3.org/2000/svg" }, props, { children: [_jsx("path", { d: "M14.6163 21.6947L5.1336 23.89C4.78772 23.9766 4.52832 24.3232 4.52832 24.6698V31.1978C4.52832 31.7467 4.96066 32.0933 5.50829 31.9777L18.7379 28.9159C19.2856 28.8004 19.5162 28.2805 19.2856 27.7894L16.8933 22.8501C16.5186 22.0702 16.8933 21.2614 17.7291 21.0881L26.376 19.0084C26.9813 18.864 27.5001 18.2285 27.5001 17.593V11.5561C27.5001 11.0073 27.0677 10.6318 26.5201 10.7762L14.0398 13.7514C13.2616 13.9247 12.9157 14.6757 13.2616 15.3978L15.4521 19.9327C15.8268 20.7126 15.4521 21.4925 14.6163 21.6947Z" }), _jsx("path", { d: "M8.36225 5.3748L10.841 10.4585C11.1581 11.1229 10.841 11.8161 10.1204 11.9606L5.53762 13.0293C4.96116 13.1737 4.5 13.7514 4.5 14.3291V19.7884C4.5 20.7127 5.24939 21.2904 6.1429 21.0882L10.4087 20.1061C10.9851 19.9906 11.4463 19.384 11.4463 18.8063L11.4751 13.2026C11.4751 12.4227 12.1092 11.6428 12.8586 11.4695L26.8376 8.11886C27.1835 8.03221 27.4429 7.68559 27.4429 7.33897V0.810981C27.4429 0.262168 27.0106 -0.113336 26.4629 0.0310883L8.90988 4.24829C8.36225 4.36383 8.13167 4.88375 8.36225 5.3748Z" })] })));
@@ -0,0 +1,2 @@
1
+ import { SVGProps } from 'react';
2
+ export declare const LiFiToolLogo: (props: SVGProps<SVGSVGElement>) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const LiFiToolLogo = (props) => (_jsxs("svg", Object.assign({ width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props, { children: [_jsx("circle", { cx: "16", cy: "16", r: "16", fill: "#F5B5FF" }), _jsx("path", { d: "M15.5031 19.2031L10.1691 20.4379C9.97453 20.4867 9.82861 20.6816 9.82861 20.8766V24.5486C9.82861 24.8573 10.0718 25.0523 10.3798 24.9873L17.8215 23.265C18.1296 23.2 18.2593 22.9076 18.1296 22.6314L16.7839 19.853C16.5731 19.4143 16.7839 18.9594 17.2541 18.8619L22.1179 17.692C22.4584 17.6108 22.7502 17.2534 22.7502 16.8959V13.5001C22.7502 13.1914 22.507 12.9802 22.199 13.0614L15.1788 14.735C14.7411 14.8324 14.5465 15.2549 14.7411 15.6611L15.9733 18.212C16.184 18.6507 15.9733 19.0893 15.5031 19.2031Z", fill: "black" }), _jsx("path", { d: "M11.985 10.0233L13.3793 12.8829C13.5577 13.2566 13.3793 13.6466 12.974 13.7278L10.3962 14.329C10.0719 14.4102 9.8125 14.7352 9.8125 15.0601V18.1309C9.8125 18.6509 10.234 18.9758 10.7366 18.8621L13.1361 18.3097C13.4604 18.2447 13.7198 17.9035 13.7198 17.5785L13.736 14.4265C13.736 13.9878 14.0927 13.5491 14.5142 13.4516L22.3774 11.5669C22.572 11.5181 22.7179 11.3231 22.7179 11.1282V7.45618C22.7179 7.14747 22.4747 6.93625 22.1666 7.01749L12.2931 9.38966C11.985 9.45465 11.8553 9.74711 11.985 10.0233Z", fill: "black" })] })));
@@ -0,0 +1,3 @@
1
+ export * from './LiFiFullLogo';
2
+ export * from './LiFiLogo';
3
+ export * from './LiFiToolLogo';
package/icons/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './LiFiFullLogo';
2
+ export * from './LiFiLogo';
3
+ export * from './LiFiToolLogo';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.12.0",
3
+ "version": "1.13.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
  "sideEffects": false,
6
6
  "main": "./index.js",
@@ -37,30 +37,29 @@
37
37
  "lifi"
38
38
  ],
39
39
  "dependencies": {
40
- "@emotion/react": "^11.9.3",
41
- "@emotion/styled": "^11.9.3",
40
+ "@emotion/react": "^11.10.0",
41
+ "@emotion/styled": "^11.10.0",
42
42
  "@ethersproject/experimental": "^5.6.3",
43
43
  "@ethersproject/providers": "^5.6.8",
44
- "@lifi/sdk": "^1.0.2",
45
- "@lifi/wallet-management": "^1.1.2",
44
+ "@lifi/sdk": "^1.1.3",
45
+ "@lifi/wallet-management": "^1.1.3",
46
46
  "@mui/icons-material": "^5.8.4",
47
- "@mui/lab": "^5.0.0-alpha.92",
48
- "@mui/material": "^5.9.2",
49
- "@sentry/integrations": "^7.8.0",
50
- "@sentry/react": "^7.8.0",
51
- "@sentry/tracing": "^7.8.0",
47
+ "@mui/lab": "^5.0.0-alpha.94",
48
+ "@mui/material": "^5.10.0",
49
+ "@sentry/integrations": "^7.10.0",
50
+ "@sentry/react": "^7.10.0",
51
+ "@sentry/tracing": "^7.10.0",
52
52
  "@tanstack/react-query": "^4.0.10",
53
+ "@tanstack/react-virtual": "^3.0.0-beta.17",
53
54
  "big.js": "^6.2.1",
54
- "i18next": "^21.8.14",
55
+ "i18next": "^21.9.0",
55
56
  "immer": "^9.0.15",
56
57
  "react": "^18.2.0",
57
58
  "react-dom": "^18.2.0",
58
- "react-hook-form": "^7.33.1",
59
+ "react-hook-form": "^7.34.0",
59
60
  "react-i18next": "^11.18.3",
60
- "react-resize-detector": "^7.1.2",
61
61
  "react-router-dom": "^6.3.0",
62
62
  "react-timer-hook": "^3.0.5",
63
- "react-virtual": "^2.10.4",
64
63
  "zustand": "^4.0.0"
65
64
  },
66
65
  "eslintConfig": {
@@ -8,4 +8,4 @@ export declare const Stack: import("@emotion/styled").StyledComponent<import("@m
8
8
  sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
9
9
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
10
10
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
11
- }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | "direction" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "spacing" | "divider"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
11
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | "direction" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "divider" | "spacing"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { SwapFormTypeProps } from '../../providers/SwapFormProvider';
3
2
  export declare const ChainSelect: ({ formType }: SwapFormTypeProps) => JSX.Element;
@@ -6,20 +6,23 @@ import { useTranslation } from 'react-i18next';
6
6
  import { Card, CardTitle } from '../../components/Card';
7
7
  import { Select } from '../../components/Select';
8
8
  import { useChains } from '../../hooks';
9
- import { SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
9
+ import { SwapFormKey, SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
10
10
  import { useWidgetConfig } from '../../providers/WidgetProvider';
11
11
  export const ChainSelect = ({ formType }) => {
12
12
  const { t } = useTranslation();
13
- const { setValue } = useFormContext();
13
+ const { setValue, register } = useFormContext();
14
14
  const { fromChain, toChain } = useWidgetConfig();
15
15
  const { chains, isLoading } = useChains();
16
+ const chainKey = SwapFormKeyHelper.getChainKey(formType);
16
17
  const [chainId] = useWatch({
17
- name: [SwapFormKeyHelper.getChainKey(formType)],
18
+ name: [chainKey],
18
19
  });
20
+ const { onChange, onBlur, name, ref } = register(chainKey);
19
21
  const handleChain = (event) => {
20
- setValue(SwapFormKeyHelper.getChainKey(formType), event.target.value);
22
+ onChange(event);
21
23
  setValue(SwapFormKeyHelper.getTokenKey(formType), '');
22
24
  setValue(SwapFormKeyHelper.getAmountKey(formType), '');
25
+ setValue(SwapFormKey.TokenSearchFilter, '');
23
26
  };
24
- return !isLoading ? (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`swap.selectChain`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ labelId: "label", MenuProps: { elevation: 2 }, defaultValue: formType === 'from' ? fromChain : toChain, value: chainId, onChange: handleChain, IconComponent: KeyboardArrowDownIcon }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => (_jsxs(MenuItem, Object.assign({ value: chain.id }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: chain.logoURI, alt: chain.key }, { children: chain.name[0] })) }), chain.name] }), chain.key))) })) }))] })) : (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 98, sx: { borderRadius: 1 } }));
27
+ return !isLoading ? (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`swap.selectChain`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ ref: ref, labelId: chainKey, name: name, MenuProps: { elevation: 2 }, defaultValue: formType === 'from' ? fromChain : toChain, value: chainId, onChange: handleChain, onBlur: onBlur, IconComponent: KeyboardArrowDownIcon }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => (_jsxs(MenuItem, Object.assign({ value: chain.id }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: chain.logoURI, alt: chain.key }, { children: chain.name[0] })) }), chain.name] }), chain.key))) })) }))] })) : (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 98, sx: { borderRadius: 1 } }));
25
28
  };
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SearchTokenInput: () => JSX.Element;
@@ -11,7 +11,7 @@ export const SearchTokenInput = () => {
11
11
  const { t } = useTranslation();
12
12
  const { register, setValue } = useFormContext();
13
13
  useEffect(() => () => {
14
- setValue(SwapFormKey.SearchTokensFilter, '');
14
+ setValue(SwapFormKey.TokenSearchFilter, '');
15
15
  }, [setValue]);
16
- return (_jsx(Card, { children: _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Input, { size: "small", placeholder: t(`swap.tokenSearch`), defaultValue: "", endAdornment: _jsx(InputAdornment, Object.assign({ position: "end" }, { children: _jsx(SearchIcon, {}) })), inputProps: Object.assign({ inputMode: 'search' }, register(SwapFormKey.SearchTokensFilter)), autoComplete: "off" }) })) }));
16
+ return (_jsx(Card, { children: _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Input, { size: "small", placeholder: t(`swap.tokenSearch`), defaultValue: "", endAdornment: _jsx(InputAdornment, Object.assign({ position: "end" }, { children: _jsx(SearchIcon, {}) })), inputProps: Object.assign({ inputMode: 'search' }, register(SwapFormKey.TokenSearchFilter)), autoComplete: "off" }) })) }));
17
17
  };
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SelectWalletPage: () => JSX.Element;
@@ -17,7 +17,7 @@ export declare const WalletListItemButton: import("@emotion/styled").StyledCompo
17
17
  touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
18
18
  }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
19
19
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
20
- }, "className" | "style" | "classes" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "autoFocus" | "dense" | "selected" | "disableGutters" | "divider"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
20
+ }, "className" | "style" | "classes" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "autoFocus" | "dense" | "divider" | "selected" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
21
21
  export declare const WalletListItem: import("@emotion/styled").StyledComponent<{
22
22
  button?: false | undefined;
23
23
  } & import("@mui/material").ListItemBaseProps & {
@@ -29,7 +29,7 @@ export declare const WalletListItem: import("@emotion/styled").StyledComponent<{
29
29
  } | undefined;
30
30
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "key" | keyof import("react").LiHTMLAttributes<HTMLLIElement>> & {
31
31
  ref?: ((instance: HTMLLIElement | null) => void) | import("react").RefObject<HTMLLIElement> | null | undefined;
32
- }, "button" | "className" | "style" | "classes" | "children" | "disabled" | "sx" | "alignItems" | "autoFocus" | "dense" | "components" | "componentsProps" | "selected" | "disableGutters" | "divider" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
32
+ }, "button" | "className" | "style" | "classes" | "children" | "disabled" | "sx" | "alignItems" | "autoFocus" | "dense" | "divider" | "components" | "componentsProps" | "selected" | "disableGutters" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
33
33
  export declare const WalletListItemText: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemTextProps<import("react").ElementType<any>, import("react").ElementType<any>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
34
34
  export declare const WalletIdentityPopoverContent: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
35
35
  align?: "inherit" | "left" | "right" | "center" | "justify" | undefined;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const AdvancedPreferences: () => JSX.Element;
@@ -2,7 +2,7 @@
2
2
  export declare const ToggleButton: import("@emotion/styled").StyledComponent<{
3
3
  children?: import("react").ReactNode;
4
4
  classes?: Partial<import("@mui/material").ToggleButtonClasses> | undefined;
5
- color?: "success" | "info" | "warning" | "error" | "primary" | "secondary" | "standard" | undefined;
5
+ color?: "primary" | "secondary" | "error" | "warning" | "info" | "success" | "standard" | undefined;
6
6
  disabled?: boolean | undefined;
7
7
  disableFocusRipple?: boolean | undefined;
8
8
  fullWidth?: boolean | undefined;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const GasPriceSelect: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SettingsPage: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SlippageInput: () => JSX.Element;
@@ -17,10 +17,10 @@ export const StatusBottomSheet = ({ status, route, }) => {
17
17
  const navigate = useNavigate();
18
18
  const ref = useRef(null);
19
19
  const { getChainById } = useChains();
20
- const { token, refetchBalance } = useTokenBalance(route.toChainId, route.toToken.address);
20
+ const { token, refetch: refetchBalance } = useTokenBalance(route.toChainId, route.toToken.address);
21
21
  const { setValue } = useFormContext();
22
22
  const clearFromAmount = () => {
23
- refetchBalance(route.fromChainId, route.fromToken.address);
23
+ refetchBalance();
24
24
  setValue(SwapFormKey.FromAmount, '');
25
25
  };
26
26
  const handleDone = () => {
@@ -8,4 +8,4 @@ export declare const Stack: import("@emotion/styled").StyledComponent<import("@m
8
8
  sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
9
9
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
10
10
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
11
- }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | "direction" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "spacing" | "divider"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
11
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | "direction" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "divider" | "spacing"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export declare const formDefaultValues: {
3
3
  fromAmount: string;
4
- searchTokensFilter: string;
4
+ tokenSearchFilter: string;
5
5
  };
6
6
  export declare const SwapFormProvider: React.FC<React.PropsWithChildren<{}>>;
@@ -1,18 +1,41 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ChainId } from '@lifi/sdk';
3
+ import { useEffect } from 'react';
2
4
  import { FormProvider, useForm } from 'react-hook-form';
5
+ import { useWallet } from '../WalletProvider';
3
6
  import { useWidgetConfig } from '../WidgetProvider';
4
7
  import { SwapFormKey } from './types';
5
8
  export const formDefaultValues = {
6
9
  [SwapFormKey.FromAmount]: '',
7
- [SwapFormKey.SearchTokensFilter]: '',
10
+ [SwapFormKey.TokenSearchFilter]: '',
8
11
  };
9
12
  export const SwapFormProvider = ({ children, }) => {
10
- var _a;
13
+ const { account } = useWallet();
11
14
  const { fromChain, fromToken, fromAmount, toChain, toToken } = useWidgetConfig();
12
15
  const methods = useForm({
13
- defaultValues: Object.assign(Object.assign({}, formDefaultValues), { fromChain,
14
- fromToken, fromAmount: (_a = fromAmount === null || fromAmount === void 0 ? void 0 : fromAmount.toPrecision()) !== null && _a !== void 0 ? _a : formDefaultValues.fromAmount, toChain,
15
- toToken }),
16
+ defaultValues: Object.assign(Object.assign({}, formDefaultValues), { fromChain: fromChain !== null && fromChain !== void 0 ? fromChain : ChainId.ETH, fromToken, fromAmount: (typeof fromAmount === 'number'
17
+ ? fromAmount === null || fromAmount === void 0 ? void 0 : fromAmount.toPrecision()
18
+ : fromAmount) || formDefaultValues.fromAmount, toChain: toChain !== null && toChain !== void 0 ? toChain : ChainId.ETH, toToken }),
16
19
  });
20
+ // Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
21
+ useEffect(() => {
22
+ if (!account.isActive || !account.chainId) {
23
+ return;
24
+ }
25
+ const { isDirty: isFromChainDirty, isTouched: isFromChainTouched } = methods.getFieldState(SwapFormKey.FromChain, methods.formState);
26
+ if (!fromChain && !isFromChainDirty && !isFromChainTouched) {
27
+ methods.setValue(SwapFormKey.FromChain, account.chainId, {
28
+ shouldDirty: false,
29
+ shouldTouch: false,
30
+ });
31
+ }
32
+ const { isDirty: isToChainDirty, isTouched: isToChainTouched } = methods.getFieldState(SwapFormKey.ToChain, methods.formState);
33
+ if (!toChain && !isToChainDirty && !isToChainTouched) {
34
+ methods.setValue(SwapFormKey.ToChain, account.chainId, {
35
+ shouldDirty: false,
36
+ shouldTouch: false,
37
+ });
38
+ }
39
+ }, [account.chainId, account.isActive, fromChain, methods, toChain]);
17
40
  return _jsx(FormProvider, Object.assign({}, methods, { children: children }));
18
41
  };
@@ -2,7 +2,7 @@ export declare enum SwapFormKey {
2
2
  FromAmount = "fromAmount",
3
3
  FromChain = "fromChain",
4
4
  FromToken = "fromToken",
5
- SearchTokensFilter = "searchTokensFilter",
5
+ TokenSearchFilter = "tokenSearchFilter",
6
6
  ToChain = "toChain",
7
7
  ToToken = "toToken"
8
8
  }
@@ -10,7 +10,7 @@ export declare type SwapFormValues = {
10
10
  [SwapFormKey.FromAmount]: string;
11
11
  [SwapFormKey.FromChain]: number;
12
12
  [SwapFormKey.FromToken]: string;
13
- [SwapFormKey.SearchTokensFilter]: string;
13
+ [SwapFormKey.TokenSearchFilter]: string;
14
14
  [SwapFormKey.ToChain]: number;
15
15
  [SwapFormKey.ToToken]: string;
16
16
  };
@@ -19,7 +19,6 @@ export declare const SwapFormKeyHelper: {
19
19
  getChainKey: (formType: SwapFormDirection) => 'fromChain' | 'toChain';
20
20
  getTokenKey: (formType: SwapFormDirection) => 'fromToken' | 'toToken';
21
21
  getAmountKey: (formType: SwapFormDirection) => 'fromAmount' | 'toAmount';
22
- getSearchTokensFilterKey: (formType: SwapFormDirection) => string;
23
22
  };
24
23
  export interface SwapFormTypeProps {
25
24
  formType: SwapFormDirection;
@@ -3,7 +3,7 @@ export var SwapFormKey;
3
3
  SwapFormKey["FromAmount"] = "fromAmount";
4
4
  SwapFormKey["FromChain"] = "fromChain";
5
5
  SwapFormKey["FromToken"] = "fromToken";
6
- SwapFormKey["SearchTokensFilter"] = "searchTokensFilter";
6
+ SwapFormKey["TokenSearchFilter"] = "tokenSearchFilter";
7
7
  SwapFormKey["ToChain"] = "toChain";
8
8
  SwapFormKey["ToToken"] = "toToken";
9
9
  })(SwapFormKey || (SwapFormKey = {}));
@@ -11,5 +11,4 @@ export const SwapFormKeyHelper = {
11
11
  getChainKey: (formType) => `${formType}Chain`,
12
12
  getTokenKey: (formType) => `${formType}Token`,
13
13
  getAmountKey: (formType) => `${formType}Amount`,
14
- getSearchTokensFilterKey: (formType) => `${formType}SearchTokensFilter`,
15
14
  };
@@ -1,4 +1,14 @@
1
+ import { Signer } from 'ethers';
1
2
  import { FC, PropsWithChildren } from 'react';
3
+ import { WidgetWalletManagement } from '../../types';
2
4
  import type { WalletContextProps } from './types';
3
5
  export declare const useWallet: () => WalletContextProps;
4
- export declare const WalletProvider: FC<PropsWithChildren<{}>>;
6
+ export declare const WalletProvider: FC<PropsWithChildren<{
7
+ walletManagement?: WidgetWalletManagement;
8
+ }>>;
9
+ export declare const extractAccountFromSigner: (signer?: Signer) => Promise<{
10
+ address: string | undefined;
11
+ isActive: boolean;
12
+ signer: Signer | undefined;
13
+ chainId: number | undefined;
14
+ }>;
@@ -8,9 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
- import { addChain as walletAddChain, switchChain as walletSwitchChain, switchChainAndAddToken, useLifiWalletManagement, } from '@lifi/wallet-management';
11
+ import { addChain as walletAddChain, switchChain as walletSwitchChain, switchChainAndAddToken, useLiFiWalletManagement, } from '@lifi/wallet-management';
12
12
  import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from 'react';
13
- import { useWidgetConfig } from '../WidgetProvider';
14
13
  const stub = () => {
15
14
  throw new Error('You forgot to wrap your component in <WalletProvider>.');
16
15
  };
@@ -24,65 +23,57 @@ const initialContext = {
24
23
  };
25
24
  const WalletContext = createContext(initialContext);
26
25
  export const useWallet = () => useContext(WalletContext);
27
- export const WalletProvider = ({ children }) => {
28
- const config = useWidgetConfig();
29
- const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, } = useLifiWalletManagement();
26
+ export const WalletProvider = ({ children, walletManagement }) => {
27
+ const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, } = useLiFiWalletManagement();
30
28
  const [account, setAccount] = useState({});
31
29
  const connect = useCallback((wallet) => __awaiter(void 0, void 0, void 0, function* () {
32
- if (config.walletManagement) {
33
- const signer = yield config.walletManagement.connect();
30
+ if (walletManagement) {
31
+ const signer = yield walletManagement.connect();
34
32
  const account = yield extractAccountFromSigner(signer);
35
33
  setAccount(account);
36
34
  return;
37
35
  }
38
36
  yield walletManagementConnect(wallet);
39
- }), [config.walletManagement, walletManagementConnect]);
37
+ }), [walletManagement, walletManagementConnect]);
40
38
  const disconnect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
41
- if (config.walletManagement) {
42
- yield config.walletManagement.disconnect();
39
+ if (walletManagement) {
40
+ yield walletManagement.disconnect();
43
41
  setAccount({});
44
42
  return;
45
43
  }
46
44
  yield walletManagementDisconnect();
47
- }), [config.walletManagement, walletManagementDisconnect]);
45
+ }), [walletManagement, walletManagementDisconnect]);
48
46
  // only for injected wallets
49
47
  const switchChain = useCallback((chainId) => __awaiter(void 0, void 0, void 0, function* () {
50
- var _a;
51
- if ((_a = config.walletManagement) === null || _a === void 0 ? void 0 : _a.switchChain) {
52
- const signer = yield config.walletManagement.switchChain(chainId);
48
+ if (walletManagement === null || walletManagement === void 0 ? void 0 : walletManagement.switchChain) {
49
+ const signer = yield walletManagement.switchChain(chainId);
53
50
  const account = yield extractAccountFromSigner(signer);
54
51
  setAccount(account);
52
+ return true;
55
53
  }
56
54
  return walletSwitchChain(chainId);
57
- }), [config.walletManagement]);
55
+ }), [walletManagement]);
58
56
  const addChain = useCallback((chainId) => __awaiter(void 0, void 0, void 0, function* () {
59
- var _b;
60
- if ((_b = config.walletManagement) === null || _b === void 0 ? void 0 : _b.addChain) {
61
- return config.walletManagement.addChain(chainId);
57
+ if (walletManagement === null || walletManagement === void 0 ? void 0 : walletManagement.addChain) {
58
+ return walletManagement.addChain(chainId);
62
59
  }
63
60
  return walletAddChain(chainId);
64
- }), [config.walletManagement]);
61
+ }), [walletManagement]);
65
62
  const addToken = useCallback((chainId, token) => __awaiter(void 0, void 0, void 0, function* () {
66
- var _c;
67
- if ((_c = config.walletManagement) === null || _c === void 0 ? void 0 : _c.addToken) {
68
- return config.walletManagement.addToken(token, chainId);
63
+ if (walletManagement === null || walletManagement === void 0 ? void 0 : walletManagement.addToken) {
64
+ return walletManagement.addToken(token, chainId);
69
65
  }
70
66
  return switchChainAndAddToken(chainId, token);
71
- }), [config.walletManagement]);
67
+ }), [walletManagement]);
72
68
  // keep account information up to date
73
69
  useEffect(() => {
74
70
  const updateAccount = () => __awaiter(void 0, void 0, void 0, function* () {
75
- if (config.walletManagement) {
76
- const account = yield extractAccountFromSigner(config.walletManagement.signer);
77
- setAccount(account);
78
- }
79
- else {
80
- const account = yield extractAccountFromSigner(signer);
81
- setAccount(account);
82
- }
71
+ var _a;
72
+ const account = yield extractAccountFromSigner((_a = walletManagement === null || walletManagement === void 0 ? void 0 : walletManagement.signer) !== null && _a !== void 0 ? _a : signer);
73
+ setAccount(account);
83
74
  });
84
75
  updateAccount();
85
- }, [signer, config.walletManagement]);
76
+ }, [signer, walletManagement]);
86
77
  const value = useMemo(() => ({
87
78
  connect,
88
79
  disconnect,
@@ -93,7 +84,7 @@ export const WalletProvider = ({ children }) => {
93
84
  }), [account, addChain, addToken, connect, disconnect, switchChain]);
94
85
  return (_jsx(WalletContext.Provider, Object.assign({ value: value }, { children: children })));
95
86
  };
96
- const extractAccountFromSigner = (signer) => __awaiter(void 0, void 0, void 0, function* () {
87
+ export const extractAccountFromSigner = (signer) => __awaiter(void 0, void 0, void 0, function* () {
97
88
  return ({
98
89
  address: (yield (signer === null || signer === void 0 ? void 0 : signer.getAddress())) || undefined,
99
90
  isActive: (signer && !!(yield signer.getAddress()) === null) || !!signer,
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { ChainId, getChainByKey } from '@lifi/sdk';
13
+ import { getChainByKey } from '@lifi/sdk';
14
14
  import { createContext, useContext, useEffect, useMemo } from 'react';
15
15
  import { updateLiFiConfig } from '../../config/lifi';
16
16
  const stub = () => {
@@ -22,24 +22,36 @@ const initialContext = {
22
22
  const WidgetContext = createContext(initialContext);
23
23
  export const useWidgetConfig = () => useContext(WidgetContext);
24
24
  export const WidgetProvider = (_a) => {
25
- var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, integrator } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "integrator"]);
25
+ var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount, integrator } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "fromAmount", "integrator"]);
26
26
  const value = useMemo(() => {
27
+ var _a, _b, _c, _d;
27
28
  try {
28
- return Object.assign(Object.assign({}, config), { fromChain: typeof fromChain === 'number'
29
- ? fromChain
30
- : typeof fromChain === 'string'
31
- ? getChainByKey(fromChain.toLowerCase()).id
32
- : ChainId.ETH, toChain: typeof toChain === 'number'
33
- ? toChain
34
- : typeof toChain === 'string'
35
- ? getChainByKey(toChain.toLowerCase()).id
36
- : ChainId.ETH, fromToken: fromToken === null || fromToken === void 0 ? void 0 : fromToken.toLowerCase(), toToken: toToken === null || toToken === void 0 ? void 0 : toToken.toLowerCase() });
29
+ const searchParams = Object.fromEntries(new URLSearchParams(window === null || window === void 0 ? void 0 : window.location.search));
30
+ return Object.assign(Object.assign({}, config), { fromChain: (searchParams.fromChain &&
31
+ isNaN(parseInt(searchParams.fromChain, 10))) ||
32
+ typeof fromChain === 'string'
33
+ ? getChainByKey((_a = (searchParams.fromChain || fromChain)) === null || _a === void 0 ? void 0 : _a.toLowerCase()).id
34
+ : (searchParams.fromChain &&
35
+ !isNaN(parseInt(searchParams.fromChain, 10))) ||
36
+ typeof fromChain === 'number'
37
+ ? parseInt(searchParams.fromChain, 10) || fromChain
38
+ : undefined, toChain: (searchParams.toChain && isNaN(parseInt(searchParams.toChain, 10))) ||
39
+ typeof toChain === 'string'
40
+ ? getChainByKey((_b = (searchParams.toChain || toChain)) === null || _b === void 0 ? void 0 : _b.toLowerCase()).id
41
+ : (searchParams.toChain &&
42
+ !isNaN(parseInt(searchParams.toChain, 10))) ||
43
+ typeof toChain === 'number'
44
+ ? parseInt(searchParams.toChain, 10) || toChain
45
+ : undefined, fromToken: ((_c = searchParams.fromToken) === null || _c === void 0 ? void 0 : _c.toLowerCase()) || (fromToken === null || fromToken === void 0 ? void 0 : fromToken.toLowerCase()), toToken: ((_d = searchParams.toToken) === null || _d === void 0 ? void 0 : _d.toLowerCase()) || (toToken === null || toToken === void 0 ? void 0 : toToken.toLowerCase()), fromAmount: typeof searchParams.fromAmount === 'string' &&
46
+ !isNaN(parseFloat(searchParams.fromAmount))
47
+ ? searchParams.fromAmount
48
+ : fromAmount });
37
49
  }
38
50
  catch (e) {
39
51
  console.warn(e);
40
52
  return config;
41
53
  }
42
- }, [config, fromChain, fromToken, toChain, toToken]);
54
+ }, [config, fromAmount, fromChain, fromToken, toChain, toToken]);
43
55
  useEffect(() => {
44
56
  updateLiFiConfig({
45
57
  defaultRouteOptions: {
@@ -35,18 +35,6 @@ export const useRouteStore = create()(persist(immer((set) => ({
35
35
  }
36
36
  }),
37
37
  restartRoute: (routeId) => set((state) => {
38
- var _a;
39
- (_a = state.routes[routeId]) === null || _a === void 0 ? void 0 : _a.route.steps.forEach((step) => {
40
- var _a, _b;
41
- const stepHasFailed = ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED';
42
- // check if the step has been cancelled which is a "failed" state
43
- const stepHasBeenCancelled = (_b = step.execution) === null || _b === void 0 ? void 0 : _b.process.some((process) => process.status === 'CANCELLED');
44
- if (step.execution && (stepHasFailed || stepHasBeenCancelled)) {
45
- step.execution.status = 'RESUME';
46
- // remove last (failed) process
47
- step.execution.process.pop();
48
- }
49
- });
50
38
  state.routes[routeId].status = 'loading';
51
39
  }),
52
40
  deleteRoute: (routeId) => set((state) => {
package/types/index.d.ts CHANGED
@@ -1 +1,2 @@
1
+ export * from './token';
1
2
  export * from './widget';
package/types/index.js CHANGED
@@ -1 +1,2 @@
1
+ export * from './token';
1
2
  export * from './widget';
@@ -0,0 +1,4 @@
1
+ import { TokenAmount } from '@lifi/sdk';
2
+ export interface Token extends TokenAmount {
3
+ featured?: boolean;
4
+ }
package/types/token.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/types/widget.d.ts CHANGED
@@ -5,7 +5,7 @@ import { Signer } from 'ethers';
5
5
  import { CSSProperties } from 'react';
6
6
  export declare type Appearance = PaletteMode | 'auto';
7
7
  export declare type ThemeConfig = {
8
- palette?: PaletteOptions;
8
+ palette?: Pick<PaletteOptions, 'primary' | 'secondary'>;
9
9
  shape?: Shape;
10
10
  typography?: TypographyOptions;
11
11
  };
@@ -18,8 +18,7 @@ export interface WidgetWalletManagement {
18
18
  signer?: Signer;
19
19
  }
20
20
  interface WidgetConfigBase {
21
- fromAmount?: number;
22
- disabledChains?: number[];
21
+ fromAmount?: number | string;
23
22
  containerStyle?: CSSProperties;
24
23
  theme?: ThemeConfig;
25
24
  appearance?: Appearance;
@@ -27,6 +26,8 @@ interface WidgetConfigBase {
27
26
  disableTelemetry?: boolean;
28
27
  walletManagement?: WidgetWalletManagement;
29
28
  integrator?: string;
29
+ disabledChains?: number[];
30
+ featuredTokens?: Token[];
30
31
  }
31
32
  declare type WidgetFromTokenConfig = {
32
33
  fromChain: `${ChainKey}` | number;
package/utils/colors.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { Theme } from '@mui/material';
2
2
  export declare const getContrastAlphaColor: (theme: Theme, alpha: string | number) => string;
3
+ export declare const getContrastTextColor: (theme: Theme, background?: string) => string;