@lifi/widget 3.20.4 → 3.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/esm/components/Messages/useMessageQueue.js +4 -6
- package/dist/esm/components/Messages/useMessageQueue.js.map +1 -1
- package/dist/esm/components/TokenList/TokenListItem.d.ts +2 -1
- package/dist/esm/components/TokenList/TokenListItem.js +5 -1
- package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
- package/dist/esm/components/TokenList/types.d.ts +3 -0
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/hooks/useToAddressRequirements.d.ts +5 -0
- package/dist/esm/hooks/useToAddressRequirements.js +24 -7
- package/dist/esm/hooks/useToAddressRequirements.js.map +1 -1
- package/package.json +5 -5
- package/package.json.tmp +4 -4
- package/src/components/Messages/useMessageQueue.ts +8 -8
- package/src/components/TokenList/TokenListItem.tsx +24 -4
- package/src/components/TokenList/types.ts +4 -0
- package/src/config/version.ts +1 -1
- package/src/hooks/useToAddressRequirements.ts +39 -11
- package/dist/esm/hooks/useIsCompatibleDestinationAccount.d.ts +0 -8
- package/dist/esm/hooks/useIsCompatibleDestinationAccount.js +0 -37
- package/dist/esm/hooks/useIsCompatibleDestinationAccount.js.map +0 -1
- package/src/hooks/useIsCompatibleDestinationAccount.ts +0 -58
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [3.20.5](https://github.com/lifinance/widget/compare/v3.20.4...v3.20.5) (2025-05-12)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* add timeout for getCapabilities call ([#392](https://github.com/lifinance/widget/issues/392)) ([2b73bf6](https://github.com/lifinance/widget/commit/2b73bf67499f2443ff2da268b4dec8f8ca59c131))
|
|
11
|
+
* **avatar-icon:** add skeleton for token image ([#390](https://github.com/lifinance/widget/issues/390)) ([d9054ce](https://github.com/lifinance/widget/commit/d9054cecbdf10bf79741f706fbee33a4a53af4e7))
|
|
12
|
+
* should not require destination address for 7702 accounts ([#393](https://github.com/lifinance/widget/issues/393)) ([00faad2](https://github.com/lifinance/widget/commit/00faad276adbbbdc9c14d444d5e598cce553d52f))
|
|
13
|
+
|
|
5
14
|
### [3.20.4](https://github.com/lifinance/widget/compare/v3.20.3...v3.20.4) (2025-05-06)
|
|
6
15
|
|
|
7
16
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useFromTokenSufficiency } from '../../hooks/useFromTokenSufficiency.js';
|
|
3
3
|
import { useGasSufficiency } from '../../hooks/useGasSufficiency.js';
|
|
4
|
-
import { useIsCompatibleDestinationAccount } from '../../hooks/useIsCompatibleDestinationAccount.js';
|
|
5
4
|
import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js';
|
|
6
5
|
export const useMessageQueue = (route, allowInteraction) => {
|
|
7
|
-
const { requiredToAddress, toAddress } = useToAddressRequirements(route);
|
|
8
|
-
const { isCompatibleDestinationAccount, isLoading: isCompatibleDestinationAccountLoading, } = useIsCompatibleDestinationAccount(route);
|
|
6
|
+
const { requiredToAddress, toAddress, accountNotDeployedAtDestination, isLoading: isToAddressRequirementsLoading, } = useToAddressRequirements(route);
|
|
9
7
|
const { insufficientFromToken, isLoading: isFromTokenSufficiencyLoading } = useFromTokenSufficiency(route);
|
|
10
8
|
const { insufficientGas, isLoading: isGasSufficiencyLoading } = useGasSufficiency(route);
|
|
11
9
|
const messageQueue = useMemo(() => {
|
|
@@ -23,7 +21,7 @@ export const useMessageQueue = (route, allowInteraction) => {
|
|
|
23
21
|
props: { insufficientGas },
|
|
24
22
|
});
|
|
25
23
|
}
|
|
26
|
-
if (
|
|
24
|
+
if (accountNotDeployedAtDestination && !allowInteraction) {
|
|
27
25
|
queue.push({
|
|
28
26
|
id: 'ACCOUNT_NOT_DEPLOYED',
|
|
29
27
|
priority: 3,
|
|
@@ -40,7 +38,7 @@ export const useMessageQueue = (route, allowInteraction) => {
|
|
|
40
38
|
allowInteraction,
|
|
41
39
|
insufficientFromToken,
|
|
42
40
|
insufficientGas,
|
|
43
|
-
|
|
41
|
+
accountNotDeployedAtDestination,
|
|
44
42
|
requiredToAddress,
|
|
45
43
|
toAddress,
|
|
46
44
|
]);
|
|
@@ -49,7 +47,7 @@ export const useMessageQueue = (route, allowInteraction) => {
|
|
|
49
47
|
hasMessages: messageQueue.length > 0,
|
|
50
48
|
isLoading: isGasSufficiencyLoading ||
|
|
51
49
|
isFromTokenSufficiencyLoading ||
|
|
52
|
-
|
|
50
|
+
isToAddressRequirementsLoading,
|
|
53
51
|
};
|
|
54
52
|
};
|
|
55
53
|
//# sourceMappingURL=useMessageQueue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessageQueue.js","sourceRoot":"","sources":["../../../../src/components/Messages/useMessageQueue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useMessageQueue.js","sourceRoot":"","sources":["../../../../src/components/Messages/useMessageQueue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAQlF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,K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C,CAAA;IACtD,CAAC,EAAE;QACD,gBAAgB;QAChB,qBAAqB;QACrB,eAAe;QACf,+BAA+B;QAC/B,iBAAiB;QACjB,SAAS;KACV,CAAC,CAAA;IAEF,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,WAAW,EAAE,YAAY,CAAC,MAAM,GAAG,CAAC;QACpC,SAAS,EACP,uBAAuB;YACvB,6BAA6B;YAC7B,8BAA8B;KACjC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { TokenListItemButtonProps, TokenListItemProps } from './types.js';
|
|
1
|
+
import type { TokenListItemAvatarProps, TokenListItemButtonProps, TokenListItemProps } from './types.js';
|
|
2
2
|
export declare const TokenListItem: React.FC<TokenListItemProps>;
|
|
3
|
+
export declare const TokenListItemAvatar: React.FC<TokenListItemAvatarProps>;
|
|
3
4
|
export declare const TokenListItemButton: React.FC<TokenListItemButtonProps>;
|
|
4
5
|
export declare const TokenListItemSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
5
6
|
export declare const TokenAmountSkeleton: React.FC;
|
|
@@ -19,6 +19,10 @@ export const TokenListItem = ({ onClick, size, start, token, chain, accountAddre
|
|
|
19
19
|
transform: `translateY(${start}px)`,
|
|
20
20
|
}, children: [startAdornment, _jsx(TokenListItemButton, { token: token, chain: chain, accountAddress: accountAddress, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] }));
|
|
21
21
|
};
|
|
22
|
+
export const TokenListItemAvatar = ({ token, }) => {
|
|
23
|
+
const [isImageLoading, setIsImageLoading] = useState(true);
|
|
24
|
+
return (_jsx(Avatar, { src: token.logoURI, alt: token.symbol, sx: (theme) => isImageLoading ? { bgcolor: theme.vars.palette.grey[300] } : null, onLoad: () => setIsImageLoading(false), children: token.symbol?.[0] }));
|
|
25
|
+
};
|
|
22
26
|
export const TokenListItemButton = ({ onClick, token, chain, accountAddress, isBalanceLoading, }) => {
|
|
23
27
|
const { t } = useTranslation();
|
|
24
28
|
const { getAddressLink } = useExplorer();
|
|
@@ -41,7 +45,7 @@ export const TokenListItemButton = ({ onClick, token, chain, accountAddress, isB
|
|
|
41
45
|
};
|
|
42
46
|
const tokenAmount = formatTokenAmount(token.amount, token.decimals);
|
|
43
47
|
const tokenPrice = formatTokenPrice(token.amount, token.priceUSD, token.decimals);
|
|
44
|
-
return (_jsxs(ListItemButton, { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, dense: true, children: [_jsx(ListItemAvatar, { children: _jsx(
|
|
48
|
+
return (_jsxs(ListItemButton, { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, dense: true, children: [_jsx(ListItemAvatar, { children: _jsx(TokenListItemAvatar, { token: token }) }), _jsx(ListItemText, { primary: token.symbol, slotProps: {
|
|
45
49
|
secondary: {
|
|
46
50
|
component: 'div',
|
|
47
51
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenListItem.js","sourceRoot":"","sources":["../../../../src/components/TokenList/TokenListItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,gBAAgB,MAAM,sCAAsC,CAAA;AACnE,OAAO,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,UAAU,GACX,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"TokenListItem.js","sourceRoot":"","sources":["../../../../src/components/TokenList/TokenListItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,gBAAgB,MAAM,sCAAsC,CAAA;AACnE,OAAO,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,UAAU,GACX,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAO3D,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EAC1D,OAAO,EACP,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,YAAY,GACb,EAAE,EAAE;IACH,MAAM,WAAW,GAAsC,CAAC,CAAC,EAAE,EAAE;QAC3D,CAAC,CAAC,eAAe,EAAE,CAAA;QACnB,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC,CAAA;IACD,OAAO,CACL,MAAC,QAAQ,IACP,KAAK,EAAE;YACL,MAAM,EAAE,GAAG,IAAI,IAAI;YACnB,SAAS,EAAE,cAAc,KAAK,KAAK;SACpC,aAEA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YACF,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,QAAQ;YACvB,UAAU,EAAE,UAAU;SACvB,aAED,KAAC,QAAQ,IAAC,OAAO,EAAC,MAAM,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAI,EAClD,KAAC,QAAQ,IAAC,OAAO,EAAC,MAAM,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAI,IAC9C,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "3.20.
|
|
2
|
+
export declare const version = "3.20.5";
|
|
@@ -2,5 +2,10 @@ import type { RouteExtended } from '@lifi/sdk';
|
|
|
2
2
|
export declare const useToAddressRequirements: (route?: RouteExtended) => {
|
|
3
3
|
requiredToAddress: boolean;
|
|
4
4
|
requiredToChainType: import("@lifi/sdk").ChainType | undefined;
|
|
5
|
+
accountNotDeployedAtDestination: boolean;
|
|
5
6
|
toAddress: string | undefined;
|
|
7
|
+
isFromContractAddress: boolean;
|
|
8
|
+
isToContractAddress: boolean;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
isFetched: boolean;
|
|
6
11
|
};
|
|
@@ -3,32 +3,49 @@ import { useChain } from '../hooks/useChain.js';
|
|
|
3
3
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
|
|
4
4
|
import { useFieldValues } from '../stores/form/useFieldValues.js';
|
|
5
5
|
import { RequiredUI } from '../types/widget.js';
|
|
6
|
+
import { isDelegationDesignatorCode } from '../utils/eip7702.js';
|
|
6
7
|
import { useIsContractAddress } from './useIsContractAddress.js';
|
|
7
8
|
export const useToAddressRequirements = (route) => {
|
|
8
9
|
const { requiredUI } = useWidgetConfig();
|
|
9
10
|
const [formFromChainId, formToChainId, formToAddress] = useFieldValues('fromChain', 'toChain', 'toAddress');
|
|
10
11
|
const fromChainId = route?.fromChainId ?? formFromChainId;
|
|
11
12
|
const toChainId = route?.toChainId ?? formToChainId;
|
|
12
|
-
const toAddress = route
|
|
13
|
-
? route.fromAddress !== route.toAddress
|
|
14
|
-
? route.toAddress
|
|
15
|
-
: formToAddress
|
|
16
|
-
: formToAddress;
|
|
17
13
|
const { chain: fromChain } = useChain(fromChainId);
|
|
18
14
|
const { chain: toChain } = useChain(toChainId);
|
|
19
15
|
const { account } = useAccount({
|
|
20
16
|
chainType: fromChain?.chainType,
|
|
21
17
|
});
|
|
22
|
-
const
|
|
18
|
+
const fromAddress = route?.fromAddress ?? account.address;
|
|
19
|
+
const toAddress = route
|
|
20
|
+
? route.fromAddress !== route.toAddress
|
|
21
|
+
? route.toAddress
|
|
22
|
+
: formToAddress
|
|
23
|
+
: formToAddress;
|
|
24
|
+
const { isContractAddress: isFromContractAddress, contractCode: fromContractCode, isLoading: isFromContractLoading, isFetched: isFromContractFetched, } = useIsContractAddress(account.address, fromChainId, account.chainType);
|
|
25
|
+
const { isContractAddress: isToContractAddress, isLoading: isToContractLoading, isFetched: isToContractFetched, } = useIsContractAddress(toAddress, toChainId, toChain?.chainType);
|
|
23
26
|
const isDifferentChainType = fromChain && toChain && fromChain.chainType !== toChain.chainType;
|
|
24
|
-
|
|
27
|
+
// We don't want to block transfers for EIP-7702 accounts since they are designed
|
|
28
|
+
// to maintain EOA-like properties while delegating execution.
|
|
29
|
+
const fromContractCodeHasDelegationIndicator = isDelegationDesignatorCode(fromContractCode);
|
|
30
|
+
const isCrossChainContractAddress = isFromContractAddress &&
|
|
31
|
+
fromChainId !== toChainId &&
|
|
32
|
+
!fromContractCodeHasDelegationIndicator;
|
|
25
33
|
const requiredToAddress = requiredUI?.includes(RequiredUI.ToAddress) ||
|
|
26
34
|
isDifferentChainType ||
|
|
27
35
|
isCrossChainContractAddress;
|
|
36
|
+
const accountNotDeployedAtDestination = isFromContractAddress &&
|
|
37
|
+
!fromContractCodeHasDelegationIndicator &&
|
|
38
|
+
!isToContractAddress &&
|
|
39
|
+
fromAddress?.toLowerCase() === toAddress?.toLowerCase();
|
|
28
40
|
return {
|
|
29
41
|
requiredToAddress,
|
|
30
42
|
requiredToChainType: toChain?.chainType,
|
|
43
|
+
accountNotDeployedAtDestination,
|
|
31
44
|
toAddress,
|
|
45
|
+
isFromContractAddress,
|
|
46
|
+
isToContractAddress,
|
|
47
|
+
isLoading: isFromContractLoading || isToContractLoading,
|
|
48
|
+
isFetched: isFromContractFetched && isToContractFetched,
|
|
32
49
|
};
|
|
33
50
|
};
|
|
34
51
|
//# sourceMappingURL=useToAddressRequirements.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToAddressRequirements.js","sourceRoot":"","sources":["../../../src/hooks/useToAddressRequirements.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAqB,EAAE,EAAE;IAChE,MAAM,EAAE,UAAU,EAAE,GAAG,eAAe,EAAE,CAAA;IACxC,MAAM,CAAC,eAAe,EAAE,aAAa,EAAE,aAAa,CAAC,GAAG,cAAc,CACpE,WAAW,EACX,SAAS,EACT,WAAW,CACZ,CAAA;IAED,MAAM,WAAW,GAAG,KAAK,EAAE,WAAW,IAAI,eAAe,CAAA;IACzD,MAAM,SAAS,GAAG,KAAK,EAAE,SAAS,IAAI,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"useToAddressRequirements.js","sourceRoot":"","sources":["../../../src/hooks/useToAddressRequirements.ts"],"names":[],"mappings":"AACA,O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widget",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.5",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -34,22 +34,22 @@
|
|
|
34
34
|
"@bigmi/core": "^0.1.1",
|
|
35
35
|
"@emotion/react": "^11.14.0",
|
|
36
36
|
"@emotion/styled": "^11.14.0",
|
|
37
|
-
"@lifi/sdk": "^3.6.
|
|
37
|
+
"@lifi/sdk": "^3.6.14",
|
|
38
38
|
"@mui/icons-material": "^7.1.0",
|
|
39
39
|
"@mui/material": "^7.1.0",
|
|
40
40
|
"@mui/system": "^7.1.0",
|
|
41
41
|
"@solana/wallet-adapter-base": "^0.9.24",
|
|
42
42
|
"@solana/web3.js": "^1.98.0",
|
|
43
43
|
"@tanstack/react-virtual": "^3.13.8",
|
|
44
|
-
"i18next": "^25.1.
|
|
44
|
+
"i18next": "^25.1.2",
|
|
45
45
|
"microdiff": "^1.5.0",
|
|
46
46
|
"mitt": "^3.0.1",
|
|
47
47
|
"react-i18next": "^15.5.1",
|
|
48
48
|
"react-intersection-observer": "^9.16.0",
|
|
49
49
|
"react-router-dom": "^6.30.0",
|
|
50
|
-
"viem": "^2.29.
|
|
50
|
+
"viem": "^2.29.2",
|
|
51
51
|
"zustand": "^5.0.4",
|
|
52
|
-
"@lifi/wallet-management": "^3.8.
|
|
52
|
+
"@lifi/wallet-management": "^3.8.2"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@bigmi/react": ">=0.1.0",
|
package/package.json.tmp
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.5",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@bigmi/core": "^0.1.1",
|
|
54
54
|
"@emotion/react": "^11.14.0",
|
|
55
55
|
"@emotion/styled": "^11.14.0",
|
|
56
|
-
"@lifi/sdk": "^3.6.
|
|
56
|
+
"@lifi/sdk": "^3.6.14",
|
|
57
57
|
"@lifi/wallet-management": "workspace:^",
|
|
58
58
|
"@mui/icons-material": "^7.1.0",
|
|
59
59
|
"@mui/material": "^7.1.0",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"@solana/wallet-adapter-base": "^0.9.24",
|
|
62
62
|
"@solana/web3.js": "^1.98.0",
|
|
63
63
|
"@tanstack/react-virtual": "^3.13.8",
|
|
64
|
-
"i18next": "^25.1.
|
|
64
|
+
"i18next": "^25.1.2",
|
|
65
65
|
"microdiff": "^1.5.0",
|
|
66
66
|
"mitt": "^3.0.1",
|
|
67
67
|
"react-i18next": "^15.5.1",
|
|
68
68
|
"react-intersection-observer": "^9.16.0",
|
|
69
69
|
"react-router-dom": "^6.30.0",
|
|
70
|
-
"viem": "^2.29.
|
|
70
|
+
"viem": "^2.29.2",
|
|
71
71
|
"zustand": "^5.0.4"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
@@ -2,7 +2,6 @@ import type { Route } from '@lifi/sdk'
|
|
|
2
2
|
import { useMemo } from 'react'
|
|
3
3
|
import { useFromTokenSufficiency } from '../../hooks/useFromTokenSufficiency.js'
|
|
4
4
|
import { useGasSufficiency } from '../../hooks/useGasSufficiency.js'
|
|
5
|
-
import { useIsCompatibleDestinationAccount } from '../../hooks/useIsCompatibleDestinationAccount.js'
|
|
6
5
|
import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'
|
|
7
6
|
|
|
8
7
|
interface QueuedMessage {
|
|
@@ -12,11 +11,12 @@ interface QueuedMessage {
|
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export const useMessageQueue = (route?: Route, allowInteraction?: boolean) => {
|
|
15
|
-
const { requiredToAddress, toAddress } = useToAddressRequirements(route)
|
|
16
14
|
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
requiredToAddress,
|
|
16
|
+
toAddress,
|
|
17
|
+
accountNotDeployedAtDestination,
|
|
18
|
+
isLoading: isToAddressRequirementsLoading,
|
|
19
|
+
} = useToAddressRequirements(route)
|
|
20
20
|
const { insufficientFromToken, isLoading: isFromTokenSufficiencyLoading } =
|
|
21
21
|
useFromTokenSufficiency(route)
|
|
22
22
|
const { insufficientGas, isLoading: isGasSufficiencyLoading } =
|
|
@@ -40,7 +40,7 @@ export const useMessageQueue = (route?: Route, allowInteraction?: boolean) => {
|
|
|
40
40
|
})
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
if (
|
|
43
|
+
if (accountNotDeployedAtDestination && !allowInteraction) {
|
|
44
44
|
queue.push({
|
|
45
45
|
id: 'ACCOUNT_NOT_DEPLOYED',
|
|
46
46
|
priority: 3,
|
|
@@ -59,7 +59,7 @@ export const useMessageQueue = (route?: Route, allowInteraction?: boolean) => {
|
|
|
59
59
|
allowInteraction,
|
|
60
60
|
insufficientFromToken,
|
|
61
61
|
insufficientGas,
|
|
62
|
-
|
|
62
|
+
accountNotDeployedAtDestination,
|
|
63
63
|
requiredToAddress,
|
|
64
64
|
toAddress,
|
|
65
65
|
])
|
|
@@ -70,6 +70,6 @@ export const useMessageQueue = (route?: Route, allowInteraction?: boolean) => {
|
|
|
70
70
|
isLoading:
|
|
71
71
|
isGasSufficiencyLoading ||
|
|
72
72
|
isFromTokenSufficiencyLoading ||
|
|
73
|
-
|
|
73
|
+
isToAddressRequirementsLoading,
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -18,7 +18,11 @@ import { formatTokenAmount, formatTokenPrice } from '../../utils/format.js'
|
|
|
18
18
|
import { shortenAddress } from '../../utils/wallet.js'
|
|
19
19
|
import { ListItemButton } from '../ListItem/ListItemButton.js'
|
|
20
20
|
import { IconButton, ListItem } from './TokenList.style.js'
|
|
21
|
-
import type {
|
|
21
|
+
import type {
|
|
22
|
+
TokenListItemAvatarProps,
|
|
23
|
+
TokenListItemButtonProps,
|
|
24
|
+
TokenListItemProps,
|
|
25
|
+
} from './types.js'
|
|
22
26
|
|
|
23
27
|
export const TokenListItem: React.FC<TokenListItemProps> = ({
|
|
24
28
|
onClick,
|
|
@@ -55,6 +59,24 @@ export const TokenListItem: React.FC<TokenListItemProps> = ({
|
|
|
55
59
|
)
|
|
56
60
|
}
|
|
57
61
|
|
|
62
|
+
export const TokenListItemAvatar: React.FC<TokenListItemAvatarProps> = ({
|
|
63
|
+
token,
|
|
64
|
+
}) => {
|
|
65
|
+
const [isImageLoading, setIsImageLoading] = useState(true)
|
|
66
|
+
return (
|
|
67
|
+
<Avatar
|
|
68
|
+
src={token.logoURI}
|
|
69
|
+
alt={token.symbol}
|
|
70
|
+
sx={(theme) =>
|
|
71
|
+
isImageLoading ? { bgcolor: theme.vars.palette.grey[300] } : null
|
|
72
|
+
}
|
|
73
|
+
onLoad={() => setIsImageLoading(false)}
|
|
74
|
+
>
|
|
75
|
+
{token.symbol?.[0]}
|
|
76
|
+
</Avatar>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
58
80
|
export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
59
81
|
onClick,
|
|
60
82
|
token,
|
|
@@ -101,9 +123,7 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
101
123
|
dense
|
|
102
124
|
>
|
|
103
125
|
<ListItemAvatar>
|
|
104
|
-
<
|
|
105
|
-
{token.symbol?.[0]}
|
|
106
|
-
</Avatar>
|
|
126
|
+
<TokenListItemAvatar token={token} />
|
|
107
127
|
</ListItemAvatar>
|
|
108
128
|
<ListItemText
|
|
109
129
|
primary={token.symbol}
|
package/src/config/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget'
|
|
2
|
-
export const version = '3.20.
|
|
2
|
+
export const version = '3.20.5'
|
|
@@ -4,6 +4,7 @@ import { useChain } from '../hooks/useChain.js'
|
|
|
4
4
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'
|
|
5
5
|
import { useFieldValues } from '../stores/form/useFieldValues.js'
|
|
6
6
|
import { RequiredUI } from '../types/widget.js'
|
|
7
|
+
import { isDelegationDesignatorCode } from '../utils/eip7702.js'
|
|
7
8
|
import { useIsContractAddress } from './useIsContractAddress.js'
|
|
8
9
|
|
|
9
10
|
export const useToAddressRequirements = (route?: RouteExtended) => {
|
|
@@ -16,37 +17,64 @@ export const useToAddressRequirements = (route?: RouteExtended) => {
|
|
|
16
17
|
|
|
17
18
|
const fromChainId = route?.fromChainId ?? formFromChainId
|
|
18
19
|
const toChainId = route?.toChainId ?? formToChainId
|
|
19
|
-
const toAddress = route
|
|
20
|
-
? route.fromAddress !== route.toAddress
|
|
21
|
-
? route.toAddress
|
|
22
|
-
: formToAddress
|
|
23
|
-
: formToAddress
|
|
24
20
|
|
|
25
21
|
const { chain: fromChain } = useChain(fromChainId)
|
|
26
22
|
const { chain: toChain } = useChain(toChainId)
|
|
27
23
|
const { account } = useAccount({
|
|
28
24
|
chainType: fromChain?.chainType,
|
|
29
25
|
})
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
|
|
27
|
+
const fromAddress = route?.fromAddress ?? account.address
|
|
28
|
+
const toAddress = route
|
|
29
|
+
? route.fromAddress !== route.toAddress
|
|
30
|
+
? route.toAddress
|
|
31
|
+
: formToAddress
|
|
32
|
+
: formToAddress
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
isContractAddress: isFromContractAddress,
|
|
36
|
+
contractCode: fromContractCode,
|
|
37
|
+
isLoading: isFromContractLoading,
|
|
38
|
+
isFetched: isFromContractFetched,
|
|
39
|
+
} = useIsContractAddress(account.address, fromChainId, account.chainType)
|
|
40
|
+
const {
|
|
41
|
+
isContractAddress: isToContractAddress,
|
|
42
|
+
isLoading: isToContractLoading,
|
|
43
|
+
isFetched: isToContractFetched,
|
|
44
|
+
} = useIsContractAddress(toAddress, toChainId, toChain?.chainType)
|
|
35
45
|
|
|
36
46
|
const isDifferentChainType =
|
|
37
47
|
fromChain && toChain && fromChain.chainType !== toChain.chainType
|
|
38
48
|
|
|
49
|
+
// We don't want to block transfers for EIP-7702 accounts since they are designed
|
|
50
|
+
// to maintain EOA-like properties while delegating execution.
|
|
51
|
+
const fromContractCodeHasDelegationIndicator =
|
|
52
|
+
isDelegationDesignatorCode(fromContractCode)
|
|
53
|
+
|
|
39
54
|
const isCrossChainContractAddress =
|
|
40
|
-
isFromContractAddress &&
|
|
55
|
+
isFromContractAddress &&
|
|
56
|
+
fromChainId !== toChainId &&
|
|
57
|
+
!fromContractCodeHasDelegationIndicator
|
|
41
58
|
|
|
42
59
|
const requiredToAddress =
|
|
43
60
|
requiredUI?.includes(RequiredUI.ToAddress) ||
|
|
44
61
|
isDifferentChainType ||
|
|
45
62
|
isCrossChainContractAddress
|
|
46
63
|
|
|
64
|
+
const accountNotDeployedAtDestination =
|
|
65
|
+
isFromContractAddress &&
|
|
66
|
+
!fromContractCodeHasDelegationIndicator &&
|
|
67
|
+
!isToContractAddress &&
|
|
68
|
+
fromAddress?.toLowerCase() === toAddress?.toLowerCase()
|
|
69
|
+
|
|
47
70
|
return {
|
|
48
71
|
requiredToAddress,
|
|
49
72
|
requiredToChainType: toChain?.chainType,
|
|
73
|
+
accountNotDeployedAtDestination,
|
|
50
74
|
toAddress,
|
|
75
|
+
isFromContractAddress,
|
|
76
|
+
isToContractAddress,
|
|
77
|
+
isLoading: isFromContractLoading || isToContractLoading,
|
|
78
|
+
isFetched: isFromContractFetched && isToContractFetched,
|
|
51
79
|
}
|
|
52
80
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { RouteExtended } from '@lifi/sdk';
|
|
2
|
-
export declare const useIsCompatibleDestinationAccount: (route?: RouteExtended) => {
|
|
3
|
-
isCompatibleDestinationAccount: boolean;
|
|
4
|
-
isFromContractAddress: boolean;
|
|
5
|
-
isToContractAddress: boolean;
|
|
6
|
-
isLoading: boolean;
|
|
7
|
-
isFetched: boolean;
|
|
8
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useAccount } from '@lifi/wallet-management';
|
|
2
|
-
import { useFieldValues } from '../stores/form/useFieldValues.js';
|
|
3
|
-
import { isDelegationDesignatorCode } from '../utils/eip7702.js';
|
|
4
|
-
import { useChain } from './useChain.js';
|
|
5
|
-
import { useIsContractAddress } from './useIsContractAddress.js';
|
|
6
|
-
export const useIsCompatibleDestinationAccount = (route) => {
|
|
7
|
-
const [formFromChainId, formToChainId, formToAddress] = useFieldValues('fromChain', 'toChain', 'toAddress');
|
|
8
|
-
const fromChainId = route?.fromChainId ?? formFromChainId;
|
|
9
|
-
const toChainId = route?.toChainId ?? formToChainId;
|
|
10
|
-
const { chain: fromChain } = useChain(fromChainId);
|
|
11
|
-
const { chain: toChain } = useChain(toChainId);
|
|
12
|
-
const { account } = useAccount({
|
|
13
|
-
chainType: fromChain?.chainType,
|
|
14
|
-
});
|
|
15
|
-
const fromAddress = route?.fromAddress ?? account.address;
|
|
16
|
-
const toAddress = route
|
|
17
|
-
? route.fromAddress !== route.toAddress
|
|
18
|
-
? route.toAddress
|
|
19
|
-
: formToAddress
|
|
20
|
-
: formToAddress;
|
|
21
|
-
const { isContractAddress: isFromContractAddress, contractCode: fromContractCode, isLoading: isFromContractLoading, isFetched: isFromContractFetched, } = useIsContractAddress(fromAddress, fromChainId, fromChain?.chainType);
|
|
22
|
-
const { isContractAddress: isToContractAddress, isLoading: isToContractLoading, isFetched: isToContractFetched, } = useIsContractAddress(toAddress, toChainId, toChain?.chainType);
|
|
23
|
-
const accountNotDeployedAtDestination = isFromContractAddress &&
|
|
24
|
-
// We don't want to block transfers for EIP-7702 accounts since they are designed
|
|
25
|
-
// to maintain EOA-like properties while delegating execution.
|
|
26
|
-
!isDelegationDesignatorCode(fromContractCode) &&
|
|
27
|
-
!isToContractAddress &&
|
|
28
|
-
fromAddress?.toLowerCase() === toAddress?.toLowerCase();
|
|
29
|
-
return {
|
|
30
|
-
isCompatibleDestinationAccount: !accountNotDeployedAtDestination,
|
|
31
|
-
isFromContractAddress,
|
|
32
|
-
isToContractAddress,
|
|
33
|
-
isLoading: isFromContractLoading || isToContractLoading,
|
|
34
|
-
isFetched: isFromContractFetched && isToContractFetched,
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=useIsCompatibleDestinationAccount.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsCompatibleDestinationAccount.js","sourceRoot":"","sources":["../../../src/hooks/useIsCompatibleDestinationAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,KAAqB,EAAE,EAAE;IACzE,MAAM,CAAC,eAAe,EAAE,aAAa,EAAE,aAAa,CAAC,GAAG,cAAc,CACpE,WAAW,EACX,SAAS,EACT,WAAW,CACZ,CAAA;IAED,MAAM,WAAW,GAAG,KAAK,EAAE,WAAW,IAAI,eAAe,CAAA;IACzD,MAAM,SAAS,GAAG,KAAK,EAAE,SAAS,IAAI,aAAa,CAAA;IAEnD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAA;IAClD,MAAM,EAAE,KAAK,EAA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dk'
|
|
2
|
-
import { useAccount } from '@lifi/wallet-management'
|
|
3
|
-
import { useFieldValues } from '../stores/form/useFieldValues.js'
|
|
4
|
-
import { isDelegationDesignatorCode } from '../utils/eip7702.js'
|
|
5
|
-
import { useChain } from './useChain.js'
|
|
6
|
-
import { useIsContractAddress } from './useIsContractAddress.js'
|
|
7
|
-
|
|
8
|
-
export const useIsCompatibleDestinationAccount = (route?: RouteExtended) => {
|
|
9
|
-
const [formFromChainId, formToChainId, formToAddress] = useFieldValues(
|
|
10
|
-
'fromChain',
|
|
11
|
-
'toChain',
|
|
12
|
-
'toAddress'
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
const fromChainId = route?.fromChainId ?? formFromChainId
|
|
16
|
-
const toChainId = route?.toChainId ?? formToChainId
|
|
17
|
-
|
|
18
|
-
const { chain: fromChain } = useChain(fromChainId)
|
|
19
|
-
const { chain: toChain } = useChain(toChainId)
|
|
20
|
-
const { account } = useAccount({
|
|
21
|
-
chainType: fromChain?.chainType,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const fromAddress = route?.fromAddress ?? account.address
|
|
25
|
-
const toAddress = route
|
|
26
|
-
? route.fromAddress !== route.toAddress
|
|
27
|
-
? route.toAddress
|
|
28
|
-
: formToAddress
|
|
29
|
-
: formToAddress
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
isContractAddress: isFromContractAddress,
|
|
33
|
-
contractCode: fromContractCode,
|
|
34
|
-
isLoading: isFromContractLoading,
|
|
35
|
-
isFetched: isFromContractFetched,
|
|
36
|
-
} = useIsContractAddress(fromAddress, fromChainId, fromChain?.chainType)
|
|
37
|
-
const {
|
|
38
|
-
isContractAddress: isToContractAddress,
|
|
39
|
-
isLoading: isToContractLoading,
|
|
40
|
-
isFetched: isToContractFetched,
|
|
41
|
-
} = useIsContractAddress(toAddress, toChainId, toChain?.chainType)
|
|
42
|
-
|
|
43
|
-
const accountNotDeployedAtDestination =
|
|
44
|
-
isFromContractAddress &&
|
|
45
|
-
// We don't want to block transfers for EIP-7702 accounts since they are designed
|
|
46
|
-
// to maintain EOA-like properties while delegating execution.
|
|
47
|
-
!isDelegationDesignatorCode(fromContractCode) &&
|
|
48
|
-
!isToContractAddress &&
|
|
49
|
-
fromAddress?.toLowerCase() === toAddress?.toLowerCase()
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
isCompatibleDestinationAccount: !accountNotDeployedAtDestination,
|
|
53
|
-
isFromContractAddress,
|
|
54
|
-
isToContractAddress,
|
|
55
|
-
isLoading: isFromContractLoading || isToContractLoading,
|
|
56
|
-
isFetched: isFromContractFetched && isToContractFetched,
|
|
57
|
-
}
|
|
58
|
-
}
|