@lifi/widget 2.0.0-beta.2 → 2.0.0-beta.4

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 (136) hide show
  1. package/cjs/components/ChainSelect/ChainSelect.d.ts +0 -1
  2. package/cjs/components/ChainSelect/ChainSelect.style.js +1 -1
  3. package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +0 -1
  4. package/cjs/components/Header/NavigationHeader.js +18 -5
  5. package/cjs/components/Insurance/InsuranceCard.js +27 -11
  6. package/cjs/components/Insurance/InsuranceCollapsed.js +1 -1
  7. package/cjs/components/Insurance/types.d.ts +1 -2
  8. package/cjs/components/NFT/NFT.js +2 -2
  9. package/cjs/components/NFT/types.d.ts +1 -1
  10. package/cjs/components/PoweredBy/PoweredBy.js +2 -3
  11. package/cjs/components/SelectTokenButton/SelectTokenButton.js +1 -1
  12. package/cjs/components/Step/CircularProgress.d.ts +0 -1
  13. package/cjs/components/Step/Step.js +14 -4
  14. package/cjs/components/Step/StepList.d.ts +0 -1
  15. package/cjs/components/StepActions/StepActions.js +2 -19
  16. package/cjs/components/SwapButton/SwapButton.js +16 -4
  17. package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
  18. package/cjs/components/SwapRouteCard/SwapRouteCard.js +6 -3
  19. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  20. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  21. package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
  22. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
  23. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  24. package/cjs/components/Token/Token.js +1 -1
  25. package/cjs/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  26. package/cjs/components/TokenList/TokenList.js +4 -2
  27. package/cjs/components/TokenList/types.d.ts +2 -3
  28. package/cjs/config/theme.js +14 -1
  29. package/cjs/config/version.d.ts +1 -1
  30. package/cjs/config/version.js +1 -1
  31. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  32. package/cjs/hooks/useProcessMessage.d.ts +2 -1
  33. package/cjs/hooks/useProcessMessage.js +23 -9
  34. package/cjs/hooks/useSwapRoutes.js +24 -11
  35. package/cjs/hooks/useToken.d.ts +1 -1
  36. package/cjs/hooks/useTokenAddressBalance.d.ts +2 -2
  37. package/cjs/hooks/useTokenBalances.d.ts +5 -5
  38. package/cjs/hooks/useTokenBalances.js +3 -14
  39. package/cjs/hooks/useTokenSearch.d.ts +2 -2
  40. package/cjs/hooks/useTokens.d.ts +2 -2
  41. package/cjs/i18n/bn.json +8 -0
  42. package/cjs/i18n/en.json +24 -2
  43. package/cjs/i18n/fr.json +8 -0
  44. package/cjs/i18n/id.json +22 -7
  45. package/cjs/i18n/ko.json +22 -7
  46. package/cjs/i18n/pt.json +8 -0
  47. package/cjs/i18n/th.json +21 -6
  48. package/cjs/i18n/uk.json +20 -12
  49. package/cjs/i18n/zh.json +8 -0
  50. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
  51. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
  52. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
  53. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
  54. package/cjs/pages/SettingsPage/SettingsPage.d.ts +0 -1
  55. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
  56. package/cjs/pages/SettingsPage/SlippageInput.d.ts +0 -1
  57. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -1
  58. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -1
  59. package/cjs/pages/SwapPage/StatusBottomSheet.js +9 -3
  60. package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  61. package/cjs/pages/SwapPage/StatusBottomSheet.style.js +2 -2
  62. package/cjs/pages/SwapPage/SwapPage.js +12 -6
  63. package/cjs/pages/SwapPage/TokenValueBottomSheet.js +1 -1
  64. package/cjs/providers/WalletProvider/types.d.ts +2 -2
  65. package/cjs/types/token.d.ts +2 -2
  66. package/cjs/types/widget.d.ts +7 -6
  67. package/cjs/types/widget.js +1 -0
  68. package/components/ChainSelect/ChainSelect.d.ts +0 -1
  69. package/components/ChainSelect/ChainSelect.style.js +1 -1
  70. package/components/GasMessage/FundsSufficiencyMessage.d.ts +0 -1
  71. package/components/Header/NavigationHeader.js +18 -5
  72. package/components/Insurance/InsuranceCard.js +29 -13
  73. package/components/Insurance/InsuranceCollapsed.js +1 -1
  74. package/components/Insurance/types.d.ts +1 -2
  75. package/components/NFT/NFT.js +2 -2
  76. package/components/NFT/types.d.ts +1 -1
  77. package/components/PoweredBy/PoweredBy.js +2 -3
  78. package/components/SelectTokenButton/SelectTokenButton.js +1 -1
  79. package/components/Step/CircularProgress.d.ts +0 -1
  80. package/components/Step/Step.js +14 -4
  81. package/components/Step/StepList.d.ts +0 -1
  82. package/components/StepActions/StepActions.js +2 -19
  83. package/components/SwapButton/SwapButton.js +16 -4
  84. package/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
  85. package/components/SwapRouteCard/SwapRouteCard.js +7 -4
  86. package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  87. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  88. package/components/SwapRoutes/SwapRoutes.js +1 -1
  89. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
  90. package/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  91. package/components/Token/Token.js +1 -1
  92. package/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  93. package/components/TokenList/TokenList.js +4 -2
  94. package/components/TokenList/types.d.ts +2 -3
  95. package/config/theme.js +14 -1
  96. package/config/version.d.ts +1 -1
  97. package/config/version.js +1 -1
  98. package/hooks/useFeaturedTokens.d.ts +1 -1
  99. package/hooks/useProcessMessage.d.ts +2 -1
  100. package/hooks/useProcessMessage.js +23 -9
  101. package/hooks/useSwapRoutes.js +24 -11
  102. package/hooks/useToken.d.ts +1 -1
  103. package/hooks/useTokenAddressBalance.d.ts +2 -2
  104. package/hooks/useTokenBalances.d.ts +5 -5
  105. package/hooks/useTokenBalances.js +3 -14
  106. package/hooks/useTokenSearch.d.ts +2 -2
  107. package/hooks/useTokens.d.ts +2 -2
  108. package/i18n/bn.json +8 -0
  109. package/i18n/en.json +24 -2
  110. package/i18n/fr.json +8 -0
  111. package/i18n/id.json +22 -7
  112. package/i18n/ko.json +22 -7
  113. package/i18n/pt.json +8 -0
  114. package/i18n/th.json +21 -6
  115. package/i18n/uk.json +20 -12
  116. package/i18n/zh.json +8 -0
  117. package/package.json +7 -7
  118. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
  119. package/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
  120. package/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
  121. package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
  122. package/pages/SettingsPage/SettingsPage.d.ts +0 -1
  123. package/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
  124. package/pages/SettingsPage/SlippageInput.d.ts +0 -1
  125. package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -1
  126. package/pages/SwapPage/ExchangeRateBottomSheet.js +2 -2
  127. package/pages/SwapPage/StatusBottomSheet.js +11 -5
  128. package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  129. package/pages/SwapPage/StatusBottomSheet.style.js +1 -1
  130. package/pages/SwapPage/SwapPage.js +12 -6
  131. package/pages/SwapPage/TokenValueBottomSheet.js +2 -2
  132. package/providers/WalletProvider/types.d.ts +2 -2
  133. package/tsconfig.cjs.tsbuildinfo +1 -1
  134. package/types/token.d.ts +2 -2
  135. package/types/widget.d.ts +7 -6
  136. package/types/widget.js +1 -0
@@ -1,22 +1,38 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import ExpandLessIcon from '@mui/icons-material/ExpandLess';
3
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
2
4
  import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
3
- import { Box, Link, Typography } from '@mui/material';
5
+ import { Box, Collapse, Link, Typography } from '@mui/material';
6
+ import { useState } from 'react';
4
7
  import { useTranslation } from 'react-i18next';
5
8
  import { InsuraceLogo } from '../../icons';
6
9
  import { RouteExecutionStatus } from '../../stores';
7
- import { Card, CardLabel, CardLabelTypography } from '../Card';
10
+ import { Card, CardIconButton, CardLabel, CardLabelTypography } from '../Card';
8
11
  import { Switch } from '../Switch';
9
12
  export const InsuranceCard = ({ status, feeAmountUsd, insuranceCoverageId, onChange, ...props }) => {
10
13
  const { t } = useTranslation();
11
- return (_jsxs(Card, { selectionColor: "secondary", indented: true, ...props, children: [_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, children: [_jsxs(CardLabel, { type: 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), _jsx(CardLabelTypography, { type: "icon", children: status === RouteExecutionStatus.Idle
12
- ? t(`swap.tags.insurance`)
13
- : t(`swap.tags.insured`) })] }), _jsx(InsuraceLogo, {})] }), _jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, children: [_jsx(Typography, { fontSize: 24, fontWeight: 700, lineHeight: 1, children: t('format.currency', {
14
- value: feeAmountUsd,
15
- }) }), status === RouteExecutionStatus.Idle ? (_jsx(Switch, { onChange: onChange })) : null] }), _jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Typography, { fontSize: 12, children: status === RouteExecutionStatus.Idle
16
- ? 'Get 100% coverage for lost tokens.'
17
- : '100% coverage for lost tokens.' }), _jsx(Link, { href: status === RouteExecutionStatus.Idle
18
- ? 'https://docs.insurace.io/landing-page/documentation/cover-products/bridge-cover/li.fi'
19
- : `https://app.insurace.io/bridge-cover?search=${insuranceCoverageId}`, target: "_blank", underline: "none", color: "text.primary", children: _jsx(Typography, { px: 0.5, color: "primary", fontSize: 12, fontWeight: 600, children: status === RouteExecutionStatus.Idle
20
- ? 'Learn more'
21
- : 'View coverage' }) })] })] }));
14
+ const [enabled, setEnabled] = useState(false);
15
+ const [cardExpanded, setCardExpanded] = useState(status === RouteExecutionStatus.Idle);
16
+ const handleExpand = (e) => {
17
+ e.stopPropagation();
18
+ setCardExpanded((expanded) => !expanded);
19
+ };
20
+ const handleSwitch = (_, checked) => {
21
+ setEnabled(checked);
22
+ onChange?.(checked);
23
+ };
24
+ return (_jsxs(Card, { selectionColor: "secondary", indented: true, ...props, children: [_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", children: [_jsxs(CardLabel, { type: 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), _jsx(CardLabelTypography, { type: "icon", children: status === RouteExecutionStatus.Idle
25
+ ? t('swap.tags.insurance')
26
+ : t('swap.tags.insured') })] }), status === RouteExecutionStatus.Idle ? (_jsx(Switch, { onChange: handleSwitch, value: enabled })) : (_jsx(Box, { my: -0.5, children: _jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) }) }))] }), _jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: _jsxs(Box, { mt: 2, children: [_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, children: [_jsx(Typography, { fontSize: 24, fontWeight: 700, lineHeight: 1, children: t('format.currency', {
27
+ value: feeAmountUsd,
28
+ }) }), _jsx(InsuraceLogo, {})] }), _jsxs(Box, { children: [_jsx(Typography, { fontSize: 14, children: status === RouteExecutionStatus.Idle
29
+ ? t('swap.insurance.insure')
30
+ : t('swap.insurance.insured') }), _jsx(Collapse, { timeout: 225, in: enabled || status !== RouteExecutionStatus.Idle, mountOnEnter: true, unmountOnExit: true, children: _jsxs(Box, { sx: {
31
+ listStyleType: 'disc',
32
+ pl: 2,
33
+ }, children: [_jsx(Typography, { fontSize: 14, display: "list-item", children: t('swap.insurance.bridgeExploits') }), _jsx(Typography, { fontSize: 14, display: "list-item", children: t('swap.insurance.slippageError') })] }) }), _jsx(Link, { href: status === RouteExecutionStatus.Idle
34
+ ? 'https://docs.insurace.io/landing-page/documentation/cover-products/bridge-cover/li.fi'
35
+ : `https://app.insurace.io/bridge-cover?search=${insuranceCoverageId}`, target: "_blank", underline: "none", color: "text.primary", children: _jsx(Typography, { pt: 0.5, color: "primary", fontSize: 14, fontWeight: 600, children: status === RouteExecutionStatus.Idle
36
+ ? t('button.learnMore')
37
+ : t('button.viewCoverage') }) })] })] }) })] }));
22
38
  };
@@ -16,7 +16,7 @@ export const InsuranceCollapsed = ({ status, insurableRouteId, insuranceCoverage
16
16
  }
17
17
  },
18
18
  });
19
- const toggleInsurance = (_, checked) => {
19
+ const toggleInsurance = (checked) => {
20
20
  if (insuredRoute) {
21
21
  if (checked) {
22
22
  setExecutableRoute(insuredRoute, insurableRouteId);
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { BoxProps } from '@mui/material';
3
2
  import type { RouteExecutionStatus } from '../../stores';
4
3
  export interface InsuranceProps extends Omit<BoxProps, 'onChange'> {
@@ -12,5 +11,5 @@ export interface InsuranceCardProps {
12
11
  feeAmountUsd?: string;
13
12
  status?: RouteExecutionStatus;
14
13
  insuranceCoverageId?: string;
15
- onChange?: (_: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
14
+ onChange?: (checked: boolean) => void;
16
15
  }
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
6
6
  import { SwapFormKey } from '../../providers';
7
7
  import { Token } from '../Token';
8
8
  import { PreviewAvatar } from './NFT.style';
9
- export const NFT = ({ imageUrl, isLoading, collectonName, assetName, owner, token, contract, ...props }) => {
9
+ export const NFT = ({ imageUrl, isLoading, collectionName, assetName, owner, token, contract, ...props }) => {
10
10
  const { t } = useTranslation();
11
11
  const { setValue } = useFormContext();
12
12
  useEffect(() => {
@@ -21,5 +21,5 @@ export const NFT = ({ imageUrl, isLoading, collectonName, assetName, owner, toke
21
21
  setValue(SwapFormKey.ToContractGasLimit, contract.gasLimit);
22
22
  }
23
23
  }, [contract, setValue, token]);
24
- return (_jsxs(Box, { p: 2, children: [_jsxs(Box, { display: "flex", children: [isLoading ? (_jsx(Skeleton, { width: 96, height: 96, variant: "rectangular", sx: { borderRadius: 1 } })) : (_jsx(PreviewAvatar, { src: imageUrl })), _jsxs(Box, { ml: 2, children: [isLoading ? (_jsx(Skeleton, { width: 144, height: 21, variant: "text" })) : (_jsx(Typography, { fontSize: 14, color: "text.secondary", children: collectonName })), isLoading ? (_jsx(Skeleton, { width: 112, height: 27, variant: "text" })) : (_jsx(Typography, { fontSize: 18, fontWeight: 600, children: assetName })), isLoading ? (_jsx(Skeleton, { width: 128, height: 21, variant: "text" })) : owner ? (_jsxs(Typography, { fontSize: 14, color: "text.secondary", children: [t('swap.ownedBy'), ' ', _jsx(Link, { href: owner.url, target: "_blank", underline: "none", color: "primary", children: owner.name })] })) : null] })] }), _jsx(Token, { token: token, isLoading: isLoading, mt: 2 })] }));
24
+ return (_jsxs(Box, { p: 2, children: [_jsxs(Box, { display: "flex", children: [isLoading ? (_jsx(Skeleton, { width: 96, height: 96, variant: "rectangular", sx: { borderRadius: 1 } })) : (_jsx(PreviewAvatar, { src: imageUrl })), _jsxs(Box, { ml: 2, children: [isLoading ? (_jsx(Skeleton, { width: 144, height: 21, variant: "text" })) : (_jsx(Typography, { fontSize: 14, color: "text.secondary", children: collectionName })), isLoading ? (_jsx(Skeleton, { width: 112, height: 27, variant: "text" })) : (_jsx(Typography, { fontSize: 18, fontWeight: 600, children: assetName })), isLoading ? (_jsx(Skeleton, { width: 128, height: 21, variant: "text" })) : owner ? (_jsxs(Typography, { fontSize: 14, color: "text.secondary", children: [t('swap.ownedBy'), ' ', _jsx(Link, { href: owner.url, target: "_blank", underline: "none", color: "primary", children: owner.name })] })) : null] })] }), _jsx(Token, { token: token, isLoading: isLoading, mt: 2 })] }));
25
25
  };
@@ -2,7 +2,7 @@ import type { TokenAmount } from '@lifi/sdk';
2
2
  import type { WidgetContract } from '../../types';
3
3
  export interface NFTProps {
4
4
  imageUrl?: string;
5
- collectonName?: string;
5
+ collectionName?: string;
6
6
  assetName?: string;
7
7
  isLoading?: boolean;
8
8
  owner?: NFTOwner;
@@ -5,7 +5,6 @@ import { version } from '../../config/version';
5
5
  import { useWidgetConfig } from '../../providers';
6
6
  import { HiddenUI } from '../../types';
7
7
  import { navigationRoutes } from '../../utils';
8
- import { LiFiLogo } from '../LiFiLogo';
9
8
  import { Link } from './PoweredBy.style';
10
9
  export const PoweredBy = () => {
11
10
  const { hiddenUI } = useWidgetConfig();
@@ -14,9 +13,9 @@ export const PoweredBy = () => {
14
13
  pathname.includes(navigationRoutes.toToken)) {
15
14
  return null;
16
15
  }
17
- return (_jsx(Box, { px: 3, py: hiddenUI?.includes(HiddenUI.PoweredBy) ? 1 : 2, sx: {
16
+ return (_jsx(Box, { px: 3, pt: 1, pb: hiddenUI?.includes(HiddenUI.PoweredBy) ? 1 : 2, sx: {
18
17
  display: 'flex',
19
18
  alignItems: 'flex-end',
20
19
  justifyContent: 'flex-end',
21
- }, children: !hiddenUI?.includes(HiddenUI.PoweredBy) ? (_jsx(Tooltip, { title: `v${version}`, placement: "top", enterDelay: 3000, arrow: true, children: _jsxs(Link, { href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary", children: [_jsx(Typography, { color: "text.secondary", fontSize: 12, px: 0.5, children: "Powered by" }), _jsx(LiFiLogo, { variant: "full", style: { height: 16, width: 42 } })] }) })) : null }));
20
+ }, children: !hiddenUI?.includes(HiddenUI.PoweredBy) ? (_jsx(Tooltip, { title: `v${version}`, placement: "top", enterDelay: 1000, arrow: true, children: _jsxs(Link, { href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary", children: [_jsx(Typography, { color: "text.secondary", fontSize: 12, fontWeight: 500, px: 0.5, children: "Powered by" }), _jsx(Typography, { color: "text.primary", fontSize: 12, fontWeight: 500, children: "LI.FI" })] }) })) : null }));
22
21
  };
@@ -32,7 +32,7 @@ export const SelectTokenButton = ({ formType, compact }) => {
32
32
  ? t(`header.selectChain`)
33
33
  : t(`swap.selectChainAndToken`);
34
34
  const cardTitle = formType === 'from' && variant === 'nft'
35
- ? t(`swap.payWith`)
35
+ ? t(`header.payWith`)
36
36
  : t(`swap.${formType}`);
37
37
  return (_jsxs(Card, { flex: 1, onClick: onClick, children: [_jsx(CardTitle, { children: cardTitle }), chainId && tokenAddress && (isChainLoading || isTokenLoading) ? (_jsx(SelectTokenCardHeader, { avatar: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }), title: _jsx(Skeleton, { variant: "text", width: 64, height: 24 }), subheader: _jsx(Skeleton, { variant: "text", width: 64, height: 16 }), compact: compact })) : (_jsx(SelectTokenCardHeader, { avatar: isSelected ? (_jsx(TokenAvatar, { token: token, chain: chain })) : (_jsx(TokenAvatarDefault, {})), title: isSelected ? token.symbol : defaultPlaceholder, subheader: isSelected ? t(`swap.onChain`, { chainName: chain.name }) : null, selected: isSelected, compact: compact }))] }));
38
38
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Process } from '@lifi/sdk';
3
2
  export declare function CircularProgress({ process }: {
4
3
  process: Process;
@@ -5,6 +5,7 @@ import { Card, CardTitle } from '../../components/Card';
5
5
  import { StepActions } from '../../components/StepActions';
6
6
  import { Token } from '../../components/Token';
7
7
  import { useChains } from '../../hooks';
8
+ import { useWidgetConfig } from '../../providers';
8
9
  import { shortenWalletAddress } from '../../utils';
9
10
  import { DestinationWalletAddress } from './DestinationWalletAddress';
10
11
  import { GasStepProcess } from './GasStepProcess';
@@ -13,6 +14,7 @@ import { StepTimer } from './StepTimer';
13
14
  export const Step = ({ step, fromToken, toToken, toAddress }) => {
14
15
  const { t } = useTranslation();
15
16
  const { getChainById } = useChains();
17
+ const { variant } = useWidgetConfig();
16
18
  const stepHasError = step.execution?.process.some((process) => process.status === 'FAILED');
17
19
  const getCardTitle = () => {
18
20
  switch (step.type) {
@@ -20,14 +22,22 @@ export const Step = ({ step, fromToken, toToken, toAddress }) => {
20
22
  const hasCrossStep = step.includedSteps.some((step) => step.type === 'cross');
21
23
  const hasSwapStep = step.includedSteps.some((step) => step.type === 'swap');
22
24
  if (hasCrossStep && hasSwapStep) {
23
- return t('swap.stepSwapAndBridge');
25
+ return variant === 'nft'
26
+ ? t('swap.stepBridgeAndBuy')
27
+ : t('swap.stepSwapAndBridge');
24
28
  }
25
29
  if (hasCrossStep) {
26
- return t('swap.stepBridge');
30
+ return variant === 'nft'
31
+ ? t('swap.stepBridgeAndBuy')
32
+ : t('swap.stepBridge');
27
33
  }
28
- return t('swap.stepSwap');
34
+ return variant === 'nft'
35
+ ? t('swap.stepSwapAndBuy')
36
+ : t('swap.stepSwap');
29
37
  default:
30
- return t('swap.stepSwap');
38
+ return variant === 'nft'
39
+ ? t('swap.stepSwapAndBuy')
40
+ : t('swap.stepSwap');
31
41
  }
32
42
  };
33
43
  const formattedToAddress = shortenWalletAddress(toAddress);
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { Route } from '@lifi/sdk';
3
2
  export declare const getStepList: (route?: Route) => JSX.Element[] | undefined;
@@ -15,27 +15,13 @@ import { SmallAvatar } from '../SmallAvatar';
15
15
  import { StepAvatar, StepConnector, StepContent, StepLabel, } from './StepActions.style';
16
16
  export const StepActions = ({ step, dense, ...other }) => {
17
17
  const { t } = useTranslation();
18
- const { variant, contractTool } = useWidgetConfig();
18
+ const { variant } = useWidgetConfig();
19
19
  const [cardExpanded, setCardExpanded] = useState(false);
20
20
  const handleExpand = (e) => {
21
21
  e.stopPropagation();
22
22
  setCardExpanded((expanded) => !expanded);
23
23
  };
24
- const customStep = variant === 'nft'
25
- ? step.includedSteps?.find((step) => step.type === 'custom')
26
- : undefined;
27
24
  const hasCollapsedSteps = dense && step.includedSteps?.length > 1;
28
- if (customStep && contractTool) {
29
- const toolDetails = {
30
- key: contractTool.name,
31
- name: contractTool.name,
32
- logoURI: contractTool.logoURI,
33
- };
34
- customStep.toolDetails = toolDetails;
35
- if (dense) {
36
- step.toolDetails = toolDetails;
37
- }
38
- }
39
25
  return (_jsxs(Box, { ...other, children: [_jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Badge, { overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: _jsx(SmallAvatar, { children: _jsx(LiFiToolLogo, {}) }), children: _jsx(StepAvatar, { variant: "circular", src: step.toolDetails.logoURI, alt: step.toolDetails.name, children: step.toolDetails.name[0] }) }), _jsx(Typography, { ml: 2, fontSize: 18, fontWeight: "500", flex: 1, children: t(`swap.stepDetails`, {
40
26
  tool: step.toolDetails.name,
41
27
  }) }), hasCollapsedSteps ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), hasCollapsedSteps ? (_jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(IncludedSteps, { step: step, variant: variant }) })) : (_jsx(IncludedSteps, { step: step, variant: variant }))] }));
@@ -69,10 +55,7 @@ export const StepDetailsContent = ({ step, variant }) => {
69
55
  else {
70
56
  fromAmount = formatTokenAmount(step.estimate.fromAmount, step.action.fromToken.decimals);
71
57
  }
72
- const showToAmount = step.type !== 'custom' &&
73
- step.tool !== 'custom' &&
74
- variant !== 'nft' &&
75
- !sameTokenProtocolStep;
58
+ const showToAmount = step.type !== 'custom' && step.tool !== 'custom' && !sameTokenProtocolStep;
76
59
  return (_jsxs(Typography, { fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex", children: [t('format.number', {
77
60
  value: fromAmount,
78
61
  }), ' ', step.action.fromToken.symbol, showToAmount ? (_jsxs(_Fragment, { children: [_jsx(ArrowForwardIcon, { sx: { fontSize: 18, paddingX: 0.5 } }), t('format.number', {
@@ -25,14 +25,26 @@ export const SwapButton = ({ onClick, hasRoute, text, disabled, loading, }) => {
25
25
  const getButtonText = () => {
26
26
  if (account.isActive) {
27
27
  if (!hasRoute) {
28
- return variant !== 'refuel' ? t(`button.swap`) : t(`button.getGas`);
28
+ switch (variant) {
29
+ case 'nft':
30
+ return t(`button.buy`);
31
+ case 'refuel':
32
+ return t(`button.getGas`);
33
+ default:
34
+ return t(`button.swap`);
35
+ }
29
36
  }
30
37
  if (text) {
31
38
  return text;
32
39
  }
33
- return variant !== 'refuel'
34
- ? t(`button.reviewSwap`)
35
- : t(`button.reviewGasSwap`);
40
+ switch (variant) {
41
+ case 'nft':
42
+ return t(`button.reviewPurchase`);
43
+ case 'refuel':
44
+ return t(`button.reviewGasSwap`);
45
+ default:
46
+ return t(`button.reviewSwap`);
47
+ }
36
48
  }
37
49
  return t(`button.connectWallet`);
38
50
  };
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SwapFormTypeProps } from '../../providers';
3
2
  export declare const SwapInputEndAdornment: ({ formType }: SwapFormTypeProps) => JSX.Element;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import ExpandLessIcon from '@mui/icons-material/ExpandLess';
3
3
  import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
4
4
  import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
5
- import { Box, Collapse } from '@mui/material';
5
+ import { Box, Collapse, Tooltip, Typography } from '@mui/material';
6
6
  import { useState } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { useWidgetConfig } from '../../providers';
@@ -22,8 +22,11 @@ export const SwapRouteCard = ({ route, active, variant = 'default', expanded, ..
22
22
  const token = widgetVariant === 'nft'
23
23
  ? { ...route.fromToken, amount: route.fromAmount }
24
24
  : { ...route.toToken, amount: route.toAmount };
25
- const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' && (insurable || route.tags?.length) ? (_jsxs(Box, { display: "flex", alignItems: "center", mb: 2, children: [insurable ? (_jsxs(CardLabel, { type: route.tags?.length && !cardExpanded
26
- ? 'insurance-icon'
27
- : 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), cardExpanded || !route.tags?.length ? (_jsx(CardLabelTypography, { type: "icon", children: t(`swap.tags.insurable`) })) : null] })) : null, route.tags?.length ? (_jsx(CardLabel, { type: active ? 'active' : undefined, children: _jsx(CardLabelTypography, { children: t(`swap.tags.${route.tags[0].toLowerCase()}`) }) })) : null] })) : null, _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [_jsx(Token, { token: token, step: !cardExpanded ? route.steps[0] : undefined }), !expanded ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), _jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) }), _jsx(SwapRouteCardEssentials, { route: route })] }));
25
+ const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' && (insurable || route.tags?.length) ? (_jsxs(Box, { display: "flex", alignItems: "center", mb: 2, children: [insurable ? (_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [_jsx(Typography, { fontSize: 12, children: t('swap.insurance.insure') }), _jsxs(Box, { sx: {
26
+ listStyleType: 'disc',
27
+ pl: 2,
28
+ }, children: [_jsx(Typography, { fontSize: 12, display: "list-item", children: t('swap.insurance.bridgeExploits') }), _jsx(Typography, { fontSize: 12, display: "list-item", children: t('swap.insurance.slippageError') })] })] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(CardLabel, { type: route.tags?.length && !cardExpanded
29
+ ? 'insurance-icon'
30
+ : 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), cardExpanded || !route.tags?.length ? (_jsx(CardLabelTypography, { type: "icon", children: t(`swap.tags.insurable`) })) : null] }) })) : null, route.tags?.length ? (_jsx(CardLabel, { type: active ? 'active' : undefined, children: _jsx(CardLabelTypography, { children: t(`swap.tags.${route.tags[0].toLowerCase()}`) }) })) : null] })) : null, _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [_jsx(Token, { token: token, step: !cardExpanded ? route.steps[0] : undefined }), !expanded ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), _jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) }), _jsx(SwapRouteCardEssentials, { route: route })] }));
28
31
  return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : (_jsx(Card, { variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true, ...other, children: cardContent }));
29
32
  };
@@ -15,7 +15,7 @@ export const SwapRouteCardEssentials = ({ route, dense }) => {
15
15
  const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
16
16
  const gasCosts = getGasCostsBreakdown(route);
17
17
  const feeCosts = getFeeCostsBreakdown(route, false);
18
- return (_jsxs(Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => (_jsxs(Typography, { fontSize: 11, children: [gas.amount?.toFixed(9), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(EvStationIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), _jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => (_jsxs(Typography, { fontSize: 11, children: [fee.amount?.toFixed(9), " ", fee.token.symbol, " (", t(`format.currency`, { value: fee.amountUSD }), ")"] }, `${fee.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(MonetizationOnIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
18
+ return (_jsxs(Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => (_jsxs(Typography, { fontSize: 12, children: [gas.amount?.toFixed(9), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(EvStationIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), _jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => (_jsxs(Typography, { fontSize: 12, children: [fee.amount?.toFixed(9), " ", fee.token.symbol, " (", t(`format.currency`, { value: fee.amountUSD }), ")"] }, `${fee.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(MonetizationOnIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
19
19
  value: feeCosts.reduce((sum, feeCost) => sum + feeCost.amountUSD, 0),
20
20
  }) })] }) }), _jsx(Tooltip, { title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(AccessTimeIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t('swap.estimatedTime', {
21
21
  value: executionTimeMinutes,
@@ -4,7 +4,7 @@ import { useWidgetConfig } from '../../providers';
4
4
  import { Card } from '../Card';
5
5
  export const SwapRouteCardSkeleton = ({ variant, ...other }) => {
6
6
  const { variant: widgetVariant } = useWidgetConfig();
7
- const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' ? (_jsx(Box, { display: "flex", alignItems: "center", mb: 2, children: _jsx(Skeleton, { variant: "rectangular", width: 112, height: 24, sx: (theme) => ({
7
+ const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' && widgetVariant !== 'nft' ? (_jsx(Box, { display: "flex", alignItems: "center", mb: 2, children: _jsx(Skeleton, { variant: "rectangular", width: 112, height: 24, sx: (theme) => ({
8
8
  borderRadius: `${theme.shape.borderRadius}px`,
9
9
  }) }) })) : null, _jsxs(Box, { children: [_jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Box, { mr: 2, children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) }), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] }), _jsxs(Box, { ml: 6, display: "flex", alignItems: "center", children: [_jsx(Skeleton, { variant: "text", width: 102, height: 16 }), _jsx(Skeleton, { variant: "text", width: 72, height: 16, sx: { marginLeft: 1 } })] })] }), _jsxs(Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [_jsx(Skeleton, { variant: "text", width: 64, height: 20 }), _jsx(Skeleton, { variant: "text", width: 64, height: 20 }), _jsx(Skeleton, { variant: "text", width: 48, height: 20 }), _jsx(Skeleton, { variant: "text", width: 32, height: 20 })] })] }));
10
10
  return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : (_jsx(Card, { indented: true, ...other, children: cardContent }));
@@ -25,7 +25,7 @@ export const SwapRoutes = (props) => {
25
25
  const routeNotFound = !currentRoute && !isLoading && !isFetching;
26
26
  const onlyRecommendedRoute = variant === 'refuel' || useRecommendedRoute;
27
27
  const showAll = !onlyRecommendedRoute && !routeNotFound && (routes?.length ?? 0) > 1;
28
- return (_jsxs(Card, { ...props, children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
28
+ return (_jsxs(Card, { ...props, children: [_jsx(CardTitle, { children: variant === 'nft' ? t('swap.fromAmount') : t('header.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
29
29
  position: 'absolute',
30
30
  top: 8,
31
31
  right: 8,
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  export declare const SwapRoutesExpanded: () => JSX.Element;
3
2
  export declare const SwapRoutesExpandedElement: () => JSX.Element;
@@ -19,7 +19,7 @@ export const SwapRoutesExpandedElement = () => {
19
19
  const { t } = useTranslation();
20
20
  const navigate = useNavigate();
21
21
  const setExecutableRoute = useSetExecutableRoute();
22
- const { containerStyle } = useWidgetConfig();
22
+ const { variant, containerStyle } = useWidgetConfig();
23
23
  const { isValid, isValidating } = useFormState();
24
24
  const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
25
25
  const currentRoute = routes?.[0];
@@ -33,5 +33,5 @@ export const SwapRoutesExpandedElement = () => {
33
33
  };
34
34
  const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
35
35
  const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
36
- return (_jsx(Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: _jsx(Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(Container, { sx: containerStyle, enableColorScheme: true, children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
36
+ return (_jsx(Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: _jsx(Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(Container, { sx: containerStyle, enableColorScheme: true, children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: variant === 'nft' ? t('swap.fromAmount') : t('header.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
37
37
  };
@@ -13,7 +13,7 @@ export const Token = ({ token, ...other }) => {
13
13
  }
14
14
  return _jsx(TokenBase, { token: token, ...other });
15
15
  };
16
- export const TokenFallback = ({ token, connected, step, disableDescription, isLoading, ...other }) => {
16
+ export const TokenFallback = ({ token, isLoading, ...other }) => {
17
17
  const { token: chainToken, isLoading: isLoadingToken } = useToken(token?.chainId, token?.address);
18
18
  return (_jsx(TokenBase, { token: { ...token, ...chainToken }, isLoading: isLoading || isLoadingToken, ...other }));
19
19
  };
@@ -1,19 +1,19 @@
1
1
  /// <reference types="react" />
2
- import type { Chain, Token } from '@lifi/sdk';
2
+ import type { Chain, StaticToken } from '@lifi/sdk';
3
3
  import type { SxProps, Theme } from '@mui/material';
4
4
  export declare const TokenAvatarFallback: React.FC<{
5
- token?: Token;
5
+ token?: StaticToken;
6
6
  isLoading?: boolean;
7
7
  sx?: SxProps<Theme>;
8
8
  }>;
9
9
  export declare const TokenAvatarBase: React.FC<{
10
- token?: Token;
10
+ token?: StaticToken;
11
11
  chain?: Chain;
12
12
  isLoading?: boolean;
13
13
  sx?: SxProps<Theme>;
14
14
  }>;
15
15
  export declare const TokenAvatar: React.FC<{
16
- token?: Token;
16
+ token?: StaticToken;
17
17
  chain?: Chain;
18
18
  isLoading?: boolean;
19
19
  sx?: SxProps<Theme>;
@@ -5,8 +5,8 @@ import { useWatch } from 'react-hook-form';
5
5
  import { useDebouncedWatch, useTokenBalances, useTokenSearch, } from '../../hooks';
6
6
  import { SwapFormKey, SwapFormKeyHelper, useWallet } from '../../providers';
7
7
  import { TokenNotFound } from './TokenNotFound';
8
- import { useTokenSelect } from './useTokenSelect';
9
8
  import { VirtualizedTokenList } from './VirtualizedTokenList';
9
+ import { useTokenSelect } from './useTokenSelect';
10
10
  export const TokenList = ({ formType, height, onClick, }) => {
11
11
  const parentRef = useRef(null);
12
12
  const { account } = useWallet();
@@ -15,7 +15,9 @@ export const TokenList = ({ formType, height, onClick, }) => {
15
15
  });
16
16
  const [tokenSearchFilter] = useDebouncedWatch([SwapFormKey.TokenSearchFilter], 320);
17
17
  const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = useTokenBalances(selectedChainId);
18
- let filteredTokens = (tokensWithBalance ?? chainTokens ?? []);
18
+ let filteredTokens = (tokensWithBalance ??
19
+ chainTokens ??
20
+ []);
19
21
  const searchFilter = tokenSearchFilter?.toUpperCase() ?? '';
20
22
  filteredTokens = tokenSearchFilter
21
23
  ? filteredTokens.filter((token) => token.name.toUpperCase().includes(searchFilter) ||
@@ -1,14 +1,13 @@
1
- import type { TokenAmount } from '@lifi/sdk';
2
1
  import type { MutableRefObject } from 'react';
3
2
  import type { SwapFormType } from '../../providers';
4
- import type { Token } from '../../types';
3
+ import type { TokenAmount } from '../../types';
5
4
  export interface TokenListProps {
6
5
  formType: SwapFormType;
7
6
  height: number;
8
7
  onClick?(): void;
9
8
  }
10
9
  export interface VirtualizedTokenListProps {
11
- tokens: Token[];
10
+ tokens: TokenAmount[];
12
11
  featuredTokensLength?: number;
13
12
  scrollElementRef: MutableRefObject<HTMLElement | null>;
14
13
  isLoading: boolean;
package/config/theme.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { loadingButtonClasses } from '@mui/lab/LoadingButton';
2
2
  import { touchRippleClasses } from '@mui/material/ButtonBase';
3
- import { common } from '@mui/material/colors';
4
3
  import { dialogActionsClasses } from '@mui/material/DialogActions';
4
+ import { common } from '@mui/material/colors';
5
5
  import { alpha, createTheme as createMuiTheme, darken, getContrastRatio, lighten, } from '@mui/material/styles';
6
6
  import { keyframes } from '@mui/system';
7
7
  const palette = {
@@ -223,6 +223,19 @@ export const createTheme = (mode, theme = {}) => {
223
223
  }),
224
224
  },
225
225
  },
226
+ MuiTooltip: {
227
+ styleOverrides: {
228
+ tooltip: ({ theme }) => ({
229
+ backgroundColor: 'rgb(0 0 0 / 64%)',
230
+ backdropFilter: 'blur(3px)',
231
+ fontSize: '0.75rem',
232
+ padding: theme.spacing(1, 1.5),
233
+ }),
234
+ arrow: {
235
+ color: 'rgb(0 0 0 / 64%)',
236
+ },
237
+ },
238
+ },
226
239
  },
227
240
  });
228
241
  };
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "2.0.0-beta.2";
2
+ export declare const version = "2.0.0-beta.4";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '2.0.0-beta.2';
2
+ export const version = '2.0.0-beta.4';
@@ -1 +1 @@
1
- export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").Token[] | undefined;
1
+ export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").StaticToken[] | undefined;
@@ -1,10 +1,11 @@
1
1
  import type { EVMChain, LifiStep, Process } from '@lifi/sdk';
2
2
  import type { TFunction } from 'i18next';
3
+ import type { WidgetVariant } from '../types';
3
4
  export declare const useProcessMessage: (step?: LifiStep, process?: Process) => {
4
5
  title?: string | undefined;
5
6
  message?: string | undefined;
6
7
  };
7
- export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LifiStep, process: Process): {
8
+ export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LifiStep, process: Process, variant?: WidgetVariant): {
8
9
  title?: string;
9
10
  message?: string;
10
11
  };
@@ -1,18 +1,21 @@
1
1
  import { LifiErrorCode } from '@lifi/sdk';
2
2
  import { useTranslation } from 'react-i18next';
3
+ import { useWidgetConfig } from '../providers';
3
4
  import { formatTokenAmount } from '../utils';
4
5
  import { useChains } from './useChains';
5
6
  export const useProcessMessage = (step, process) => {
7
+ const { variant } = useWidgetConfig();
6
8
  const { t } = useTranslation();
7
9
  const { getChainById } = useChains();
8
10
  if (!step || !process) {
9
11
  return {};
10
12
  }
11
- return getProcessMessage(t, getChainById, step, process);
13
+ return getProcessMessage(t, getChainById, step, process, variant);
12
14
  };
13
15
  const processStatusMessages = {
14
16
  TOKEN_ALLOWANCE: {
15
17
  STARTED: (t) => t(`swap.process.tokenAllowance.started`),
18
+ ACTION_REQUIRED: (t) => t(`swap.process.tokenAllowance.pending`),
16
19
  PENDING: (t) => t(`swap.process.tokenAllowance.pending`),
17
20
  DONE: (t) => t(`swap.process.tokenAllowance.done`),
18
21
  },
@@ -24,7 +27,9 @@ const processStatusMessages = {
24
27
  STARTED: (t) => t(`swap.process.swap.started`),
25
28
  ACTION_REQUIRED: (t) => t(`swap.process.swap.actionRequired`),
26
29
  PENDING: (t) => t(`swap.process.swap.pending`),
27
- DONE: (t) => t(`swap.process.swap.done`),
30
+ DONE: (t, variant) => variant === 'nft'
31
+ ? t(`swap.process.nft.done`)
32
+ : t(`swap.process.swap.done`),
28
33
  },
29
34
  CROSS_CHAIN: {
30
35
  STARTED: (t) => t(`swap.process.crossChain.started`),
@@ -34,7 +39,9 @@ const processStatusMessages = {
34
39
  },
35
40
  RECEIVING_CHAIN: {
36
41
  PENDING: (t) => t(`swap.process.receivingChain.pending`),
37
- DONE: (t) => t(`swap.process.receivingChain.done`),
42
+ DONE: (t, variant) => variant === 'nft'
43
+ ? t(`swap.process.nft.done`)
44
+ : t(`swap.process.receivingChain.done`),
38
45
  },
39
46
  TRANSACTION: {},
40
47
  };
@@ -64,7 +71,7 @@ const processSubstatusMessages = {
64
71
  INVALID: {},
65
72
  NOT_FOUND: {},
66
73
  };
67
- export function getProcessMessage(t, getChainById, step, process) {
74
+ export function getProcessMessage(t, getChainById, step, process, variant) {
68
75
  if (process.error && process.status === 'FAILED') {
69
76
  const getTransactionNotSentMessage = () => t(`swap.error.message.transactionNotSent`, {
70
77
  amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
@@ -74,6 +81,12 @@ export function getProcessMessage(t, getChainById, step, process) {
74
81
  let title = '';
75
82
  let message = '';
76
83
  switch (process.error.code) {
84
+ case LifiErrorCode.AllowanceRequired:
85
+ title = t(`swap.error.title.allowanceRequired`);
86
+ message = t(`swap.error.message.allowanceRequired`, {
87
+ tokenSymbol: step.action.fromToken.symbol,
88
+ });
89
+ break;
77
90
  case LifiErrorCode.BalanceError:
78
91
  title = t(`swap.error.title.balanceIsTooLow`);
79
92
  message = getTransactionNotSentMessage();
@@ -86,6 +99,10 @@ export function getProcessMessage(t, getChainById, step, process) {
86
99
  title = t(`swap.error.title.gasLimitIsTooLow`);
87
100
  message = getTransactionNotSentMessage();
88
101
  break;
102
+ case LifiErrorCode.SlippageError:
103
+ title = t(`swap.error.title.slippageNotMet`);
104
+ message = t(`swap.error.message.slippageThreshold`);
105
+ break;
89
106
  case LifiErrorCode.TransactionFailed:
90
107
  title = t(`swap.error.title.transactionFailed`);
91
108
  message = t(`swap.error.message.transactionFailed`);
@@ -102,10 +119,6 @@ export function getProcessMessage(t, getChainById, step, process) {
102
119
  title = t(`swap.error.title.transactionCanceled`);
103
120
  message = getTransactionNotSentMessage();
104
121
  break;
105
- case LifiErrorCode.SlippageError:
106
- title = t(`swap.error.title.slippageNotMet`);
107
- message = t(`swap.error.message.slippageThreshold`);
108
- break;
109
122
  case LifiErrorCode.TransactionRejected:
110
123
  title = t(`swap.error.title.transactionRejected`);
111
124
  message = t(`swap.error.message.transactionRejected`, {
@@ -127,6 +140,7 @@ export function getProcessMessage(t, getChainById, step, process) {
127
140
  }
128
141
  return { title, message };
129
142
  }
130
- const title = processSubstatusMessages[process.status]?.[process.substatus]?.(t) ?? processStatusMessages[process.type]?.[process.status]?.(t);
143
+ const title = processSubstatusMessages[process.status]?.[process.substatus]?.(t) ??
144
+ processStatusMessages[process.type]?.[process.status]?.(t, variant);
131
145
  return { title };
132
146
  }