@lifi/widget 3.6.0-alpha.5 → 3.6.0

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 (190) hide show
  1. package/App.tsx +3 -3
  2. package/AppProvider.tsx +2 -1
  3. package/CHANGELOG.md +16 -0
  4. package/_esm/App.d.ts +1 -1
  5. package/_esm/App.js +3 -3
  6. package/_esm/App.js.map +1 -1
  7. package/_esm/AppProvider.js +2 -2
  8. package/_esm/AppProvider.js.map +1 -1
  9. package/_esm/components/Card/InputCard.d.ts +1 -1
  10. package/_esm/components/ChainSelect/useChainSelect.js +1 -5
  11. package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
  12. package/_esm/components/FeeBreakdownTooltip.js +1 -4
  13. package/_esm/components/FeeBreakdownTooltip.js.map +1 -1
  14. package/_esm/components/Header/EVMDisconnectIconButton.js +4 -5
  15. package/_esm/components/Header/EVMDisconnectIconButton.js.map +1 -1
  16. package/_esm/components/Header/Header.style.d.ts +0 -3
  17. package/_esm/components/Header/Header.style.js +0 -5
  18. package/_esm/components/Header/Header.style.js.map +1 -1
  19. package/_esm/components/Header/WalletMenu.js +6 -5
  20. package/_esm/components/Header/WalletMenu.js.map +1 -1
  21. package/_esm/components/Header/WalletMenu.style.js +1 -5
  22. package/_esm/components/Header/WalletMenu.style.js.map +1 -1
  23. package/_esm/components/SendToWallet/SendToWalletButton.js +16 -6
  24. package/_esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
  25. package/_esm/components/SendToWallet/SendToWalletExpandButton.js +8 -6
  26. package/_esm/components/SendToWallet/SendToWalletExpandButton.js.map +1 -1
  27. package/_esm/components/Skeleton/WidgetSkeleton.style.d.ts +1 -1
  28. package/_esm/components/Step/StepProcess.js +9 -1
  29. package/_esm/components/Step/StepProcess.js.map +1 -1
  30. package/_esm/components/TokenList/TokenListItem.js +5 -11
  31. package/_esm/components/TokenList/TokenListItem.js.map +1 -1
  32. package/_esm/components/TokenList/VirtualizedTokenList.js +1 -1
  33. package/_esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
  34. package/_esm/components/TokenList/types.d.ts +2 -2
  35. package/_esm/components/TokenRate/TokenRate.js +2 -2
  36. package/_esm/components/TokenRate/TokenRate.js.map +1 -1
  37. package/_esm/components/TransactionDetails.js +2 -1
  38. package/_esm/components/TransactionDetails.js.map +1 -1
  39. package/_esm/config/version.d.ts +1 -1
  40. package/_esm/config/version.js +1 -1
  41. package/_esm/config/version.js.map +1 -1
  42. package/_esm/hooks/useAccount.d.ts +15 -15
  43. package/_esm/hooks/useAccount.js +13 -50
  44. package/_esm/hooks/useAccount.js.map +1 -1
  45. package/_esm/hooks/useAvailableChains.d.ts +1 -2
  46. package/_esm/hooks/useAvailableChains.js +8 -9
  47. package/_esm/hooks/useAvailableChains.js.map +1 -1
  48. package/_esm/hooks/useChains.d.ts +3 -4
  49. package/_esm/hooks/useChains.js +3 -5
  50. package/_esm/hooks/useChains.js.map +1 -1
  51. package/_esm/hooks/useExplorer.d.ts +10 -1
  52. package/_esm/hooks/useExplorer.js +4 -1
  53. package/_esm/hooks/useExplorer.js.map +1 -1
  54. package/_esm/hooks/useGasSufficiency.js +2 -2
  55. package/_esm/hooks/useGasSufficiency.js.map +1 -1
  56. package/_esm/hooks/useHeaderHeight.js +8 -1
  57. package/_esm/hooks/useHeaderHeight.js.map +1 -1
  58. package/_esm/hooks/useTokens.js +1 -1
  59. package/_esm/hooks/useTokens.js.map +1 -1
  60. package/_esm/hooks/useWallets.d.ts +1 -1
  61. package/_esm/hooks/useWallets.js +15 -36
  62. package/_esm/hooks/useWallets.js.map +1 -1
  63. package/_esm/i18n/en.json +1 -1
  64. package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +2 -1
  65. package/_esm/pages/SelectWalletPage/EVMListItemButton.js +14 -15
  66. package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +1 -1
  67. package/_esm/pages/SelectWalletPage/SVMListItemButton.js +0 -3
  68. package/_esm/pages/SelectWalletPage/SVMListItemButton.js.map +1 -1
  69. package/_esm/pages/SelectWalletPage/SelectWalletPage.js +3 -3
  70. package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +1 -1
  71. package/_esm/pages/SendToWallet/SendToWalletPage.style.d.ts +1 -1
  72. package/_esm/pages/TransactionDetailsPage/TransferIdCard.js +1 -1
  73. package/_esm/pages/TransactionDetailsPage/TransferIdCard.js.map +1 -1
  74. package/_esm/pages/TransactionPage/StatusBottomSheet.js +3 -2
  75. package/_esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
  76. package/_esm/providers/I18nProvider/types.d.ts +2 -2
  77. package/_esm/providers/WalletProvider/SDKProviders.js +7 -15
  78. package/_esm/providers/WalletProvider/SDKProviders.js.map +1 -1
  79. package/_esm/providers/WalletProvider/WalletProvider.js +1 -2
  80. package/_esm/providers/WalletProvider/WalletProvider.js.map +1 -1
  81. package/_esm/providers/WalletProvider/useHasExternalWalletProvider.d.ts +1 -1
  82. package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js +3 -8
  83. package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js.map +1 -1
  84. package/_esm/providers/WidgetProvider/WidgetProvider.js +1 -31
  85. package/_esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
  86. package/_esm/stores/StoreProvider.js +2 -2
  87. package/_esm/stores/StoreProvider.js.map +1 -1
  88. package/_esm/stores/form/FormStore.d.ts +6 -1
  89. package/_esm/stores/form/FormStore.js +69 -18
  90. package/_esm/stores/form/FormStore.js.map +1 -1
  91. package/_esm/stores/form/FormUpdater.d.ts +1 -1
  92. package/_esm/stores/form/FormUpdater.js +36 -18
  93. package/_esm/stores/form/FormUpdater.js.map +1 -1
  94. package/_esm/stores/form/URLSearchParamsBuilder.js +44 -4
  95. package/_esm/stores/form/URLSearchParamsBuilder.js.map +1 -1
  96. package/_esm/stores/form/createFormStore.js +9 -0
  97. package/_esm/stores/form/createFormStore.js.map +1 -1
  98. package/_esm/stores/form/types.d.ts +13 -10
  99. package/_esm/stores/form/types.js.map +1 -1
  100. package/_esm/stores/form/useFieldActions.js +1 -0
  101. package/_esm/stores/form/useFieldActions.js.map +1 -1
  102. package/_esm/stores/form/useFormRef.d.ts +3 -0
  103. package/_esm/stores/form/useFormRef.js +51 -0
  104. package/_esm/stores/form/useFormRef.js.map +1 -0
  105. package/_esm/stores/form/useTouchedFields.d.ts +6 -6
  106. package/_esm/stores/settings/types.d.ts +0 -2
  107. package/_esm/stores/settings/useSendToWalletStore.d.ts +0 -1
  108. package/_esm/stores/settings/useSendToWalletStore.js +0 -7
  109. package/_esm/stores/settings/useSendToWalletStore.js.map +1 -1
  110. package/_esm/themes/createTheme.js +1 -2
  111. package/_esm/themes/createTheme.js.map +1 -1
  112. package/_esm/types/widget.d.ts +29 -4
  113. package/_esm/types/widget.js.map +1 -1
  114. package/_esm/utils/chainType.js +3 -2
  115. package/_esm/utils/chainType.js.map +1 -1
  116. package/_esm/utils/fees.js +5 -9
  117. package/_esm/utils/fees.js.map +1 -1
  118. package/_esm/utils/svm.d.ts +1 -0
  119. package/_esm/utils/svm.js +11 -0
  120. package/_esm/utils/svm.js.map +1 -0
  121. package/components/ChainSelect/useChainSelect.ts +1 -10
  122. package/components/FeeBreakdownTooltip.tsx +1 -4
  123. package/components/Header/EVMDisconnectIconButton.tsx +5 -5
  124. package/components/Header/Header.style.ts +0 -6
  125. package/components/Header/WalletMenu.style.tsx +1 -5
  126. package/components/Header/WalletMenu.tsx +5 -6
  127. package/components/SendToWallet/SendToWalletButton.tsx +23 -13
  128. package/components/SendToWallet/SendToWalletExpandButton.tsx +10 -10
  129. package/components/Step/StepProcess.tsx +12 -2
  130. package/components/TokenList/TokenListItem.tsx +7 -15
  131. package/components/TokenList/VirtualizedTokenList.tsx +1 -1
  132. package/components/TokenList/types.ts +2 -2
  133. package/components/TokenRate/TokenRate.tsx +2 -2
  134. package/components/TransactionDetails.tsx +4 -1
  135. package/config/version.ts +1 -1
  136. package/hooks/useAccount.ts +35 -82
  137. package/hooks/useAvailableChains.ts +10 -9
  138. package/hooks/useChains.ts +3 -6
  139. package/hooks/useExplorer.ts +19 -2
  140. package/hooks/useGasSufficiency.ts +2 -4
  141. package/hooks/useHeaderHeight.ts +8 -1
  142. package/hooks/useTokens.ts +1 -2
  143. package/hooks/useWallets.ts +20 -41
  144. package/i18n/en.json +1 -1
  145. package/package.json +8 -8
  146. package/pages/SelectWalletPage/EVMListItemButton.tsx +19 -15
  147. package/pages/SelectWalletPage/SVMListItemButton.tsx +0 -3
  148. package/pages/SelectWalletPage/SelectWalletPage.tsx +4 -9
  149. package/pages/TransactionDetailsPage/TransferIdCard.tsx +1 -1
  150. package/pages/TransactionPage/StatusBottomSheet.tsx +5 -0
  151. package/providers/I18nProvider/types.ts +2 -2
  152. package/providers/WalletProvider/SDKProviders.tsx +7 -25
  153. package/providers/WalletProvider/WalletProvider.tsx +2 -5
  154. package/providers/WalletProvider/useHasExternalWalletProvider.ts +5 -11
  155. package/providers/WidgetProvider/WidgetProvider.tsx +1 -39
  156. package/stores/StoreProvider.tsx +5 -4
  157. package/stores/form/FormStore.tsx +100 -20
  158. package/stores/form/FormUpdater.tsx +52 -22
  159. package/stores/form/URLSearchParamsBuilder.tsx +55 -5
  160. package/stores/form/createFormStore.ts +9 -0
  161. package/stores/form/types.ts +14 -10
  162. package/stores/form/useFieldActions.ts +1 -0
  163. package/stores/form/useFormRef.ts +69 -0
  164. package/stores/settings/types.ts +0 -2
  165. package/stores/settings/useSendToWalletStore.ts +0 -8
  166. package/themes/createTheme.ts +1 -3
  167. package/types/widget.ts +46 -3
  168. package/utils/chainType.ts +3 -2
  169. package/utils/fees.ts +13 -15
  170. package/utils/svm.ts +10 -0
  171. package/_esm/components/Header/UTXODisconnectIconButton.d.ts +0 -4
  172. package/_esm/components/Header/UTXODisconnectIconButton.js +0 -13
  173. package/_esm/components/Header/UTXODisconnectIconButton.js.map +0 -1
  174. package/_esm/pages/SelectWalletPage/UTXOListItemButton.d.ts +0 -8
  175. package/_esm/pages/SelectWalletPage/UTXOListItemButton.js +0 -39
  176. package/_esm/pages/SelectWalletPage/UTXOListItemButton.js.map +0 -1
  177. package/_esm/providers/WalletProvider/UTXOBaseProvider.d.ts +0 -2
  178. package/_esm/providers/WalletProvider/UTXOBaseProvider.js +0 -17
  179. package/_esm/providers/WalletProvider/UTXOBaseProvider.js.map +0 -1
  180. package/_esm/providers/WalletProvider/UTXOExternalContext.d.ts +0 -1
  181. package/_esm/providers/WalletProvider/UTXOExternalContext.js +0 -3
  182. package/_esm/providers/WalletProvider/UTXOExternalContext.js.map +0 -1
  183. package/_esm/providers/WalletProvider/UTXOProvider.d.ts +0 -3
  184. package/_esm/providers/WalletProvider/UTXOProvider.js +0 -18
  185. package/_esm/providers/WalletProvider/UTXOProvider.js.map +0 -1
  186. package/components/Header/UTXODisconnectIconButton.tsx +0 -24
  187. package/pages/SelectWalletPage/UTXOListItemButton.tsx +0 -70
  188. package/providers/WalletProvider/UTXOBaseProvider.tsx +0 -28
  189. package/providers/WalletProvider/UTXOExternalContext.ts +0 -3
  190. package/providers/WalletProvider/UTXOProvider.tsx +0 -26
@@ -30,11 +30,21 @@ export const StepProcess: React.FC<{
30
30
  >
31
31
  {title}
32
32
  </Typography>
33
- {process.txHash ? (
33
+ {process.txHash || process.txLink ? (
34
34
  <CardIconButton
35
35
  size="small"
36
36
  LinkComponent={Link}
37
- href={getTransactionLink(process.txHash, step.action.fromChainId)}
37
+ href={
38
+ process.txHash
39
+ ? getTransactionLink({
40
+ txHash: process.txHash,
41
+ chain: process.chainId,
42
+ })
43
+ : getTransactionLink({
44
+ txLink: process.txLink!,
45
+ chain: process.chainId,
46
+ })
47
+ }
38
48
  target="_blank"
39
49
  rel="nofollow noreferrer"
40
50
  >
@@ -1,4 +1,3 @@
1
- import { ChainType } from '@lifi/sdk';
2
1
  import { OpenInNewRounded } from '@mui/icons-material';
3
2
  import {
4
3
  Avatar,
@@ -27,7 +26,7 @@ export const TokenListItem: React.FC<TokenListItemProps> = ({
27
26
  start,
28
27
  token,
29
28
  chain,
30
- accountAddress,
29
+ showBalance,
31
30
  isBalanceLoading,
32
31
  startAdornment,
33
32
  endAdornment,
@@ -47,7 +46,7 @@ export const TokenListItem: React.FC<TokenListItemProps> = ({
47
46
  <TokenListItemButton
48
47
  token={token}
49
48
  chain={chain}
50
- accountAddress={accountAddress}
49
+ showBalance={showBalance}
51
50
  isBalanceLoading={isBalanceLoading}
52
51
  onClick={handleClick}
53
52
  />
@@ -60,7 +59,7 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
60
59
  onClick,
61
60
  token,
62
61
  chain,
63
- accountAddress,
62
+ showBalance,
64
63
  isBalanceLoading,
65
64
  }) => {
66
65
  const { t } = useTranslation();
@@ -76,15 +75,8 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
76
75
  const timeoutId = useRef<ReturnType<typeof setTimeout>>();
77
76
  const [showAddress, setShowAddress] = useState(false);
78
77
 
79
- const tokenAddress =
80
- chain?.chainType === ChainType.UTXO ? accountAddress : token.address;
81
-
82
78
  const onMouseEnter = () => {
83
- timeoutId.current = setTimeout(() => {
84
- if (tokenAddress) {
85
- setShowAddress(true);
86
- }
87
- }, 350);
79
+ timeoutId.current = setTimeout(() => setShowAddress(true), 350);
88
80
  };
89
81
 
90
82
  const onMouseLeave = () => {
@@ -136,12 +128,12 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
136
128
  >
137
129
  <Box display="flex">
138
130
  <Box display="flex" alignItems="center" pt={0.125}>
139
- {shortenAddress(tokenAddress)}
131
+ {shortenAddress(token.address)}
140
132
  </Box>
141
133
  <IconButton
142
134
  size="small"
143
135
  LinkComponent={Link}
144
- href={getAddressLink(tokenAddress!, chain)}
136
+ href={getAddressLink(token.address, chain)}
145
137
  target="_blank"
146
138
  rel="nofollow noreferrer"
147
139
  onClick={(e) => e.stopPropagation()}
@@ -153,7 +145,7 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
153
145
  </Box>
154
146
  }
155
147
  />
156
- {accountAddress ? (
148
+ {showBalance ? (
157
149
  isBalanceLoading ? (
158
150
  <TokenAmountSkeleton />
159
151
  ) : (
@@ -127,7 +127,7 @@ export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
127
127
  token={currentToken}
128
128
  chain={chain}
129
129
  isBalanceLoading={isBalanceLoading}
130
- accountAddress={account.address}
130
+ showBalance={account.isConnected}
131
131
  startAdornment={
132
132
  startAdornmentLabel ? (
133
133
  <Typography
@@ -30,7 +30,7 @@ export interface TokenListItemBaseProps {
30
30
  }
31
31
 
32
32
  export interface TokenListItemProps extends TokenListItemBaseProps {
33
- accountAddress?: string;
33
+ showBalance?: boolean;
34
34
  token: TokenAmount;
35
35
  chain?: ExtendedChain;
36
36
  isBalanceLoading?: boolean;
@@ -40,7 +40,7 @@ export interface TokenListItemProps extends TokenListItemBaseProps {
40
40
 
41
41
  export interface TokenListItemButtonProps {
42
42
  onClick?: MouseEventHandler<HTMLDivElement>;
43
- accountAddress?: string;
43
+ showBalance?: boolean;
44
44
  token: TokenAmount;
45
45
  chain?: ExtendedChain;
46
46
  isBalanceLoading?: boolean;
@@ -18,13 +18,13 @@ interface TokenRateState {
18
18
  toggleIsForward(): void;
19
19
  }
20
20
 
21
- const useTokenRate = create<TokenRateState>((set) => ({
21
+ const useTokenRateStore = create<TokenRateState>((set) => ({
22
22
  isForward: true,
23
23
  toggleIsForward: () => set((state) => ({ isForward: !state.isForward })),
24
24
  }));
25
25
 
26
26
  export const TokenRate: React.FC<TokenRateProps> = ({ route }) => {
27
- const { isForward, toggleIsForward } = useTokenRate();
27
+ const { isForward, toggleIsForward } = useTokenRateStore();
28
28
 
29
29
  const toggleRate: MouseEventHandler<HTMLSpanElement> = (e) => {
30
30
  e.stopPropagation();
@@ -75,6 +75,9 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
75
75
  parseFloat(feeCollectionStep.action.fromToken.priceUSD);
76
76
  }
77
77
 
78
+ const showIntegratorFeeCollectionDetails =
79
+ feeAmountUSD || Number.isFinite(feeConfig?.fee);
80
+
78
81
  return (
79
82
  <Card selectionColor="secondary" {...props}>
80
83
  <Box display="flex" alignItems="center" px={2} py={1.75}>
@@ -138,7 +141,7 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
138
141
  </FeeBreakdownTooltip>
139
142
  </Box>
140
143
  ) : null}
141
- {feeAmountUSD ? (
144
+ {showIntegratorFeeCollectionDetails ? (
142
145
  <Box display="flex" justifyContent="space-between" mb={0.5}>
143
146
  <Typography variant="body2">
144
147
  {feeConfig?.name
package/config/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '3.6.0-alpha.5';
2
+ export const version = '3.6.0';
@@ -1,21 +1,17 @@
1
1
  import { ChainId, ChainType } from '@lifi/sdk';
2
- import type { CreateConnectorFnExtended } from '@lifi/wallet-management';
3
- import { useConfig as useBigmiConfig } from '@lifi/wallet-management';
4
2
  import type { WalletAdapter } from '@solana/wallet-adapter-base';
5
3
  import { useWallet } from '@solana/wallet-adapter-react';
6
4
  import { useMemo } from 'react';
7
5
  import type { Chain } from 'viem';
8
6
  import type { Connector } from 'wagmi';
9
- import { useAccount as useAccountInternal } from 'wagmi';
10
- import { create } from 'zustand';
7
+ import { useAccount as useWagmiAccount } from 'wagmi';
11
8
 
12
- export interface AccountBase<CT extends ChainType, ConnectorType = undefined> {
9
+ export interface AccountBase {
13
10
  address?: string;
14
11
  addresses?: readonly string[];
15
12
  chain?: Chain;
16
13
  chainId?: number;
17
- chainType: CT;
18
- connector?: ConnectorType;
14
+ chainType?: ChainType;
19
15
  isConnected: boolean;
20
16
  isConnecting: boolean;
21
17
  isDisconnected: boolean;
@@ -23,12 +19,21 @@ export interface AccountBase<CT extends ChainType, ConnectorType = undefined> {
23
19
  status: 'connected' | 'reconnecting' | 'connecting' | 'disconnected';
24
20
  }
25
21
 
26
- export type EVMAccount = AccountBase<ChainType.EVM, Connector>;
27
- export type SVMAccount = AccountBase<ChainType.SVM, WalletAdapter>;
28
- export type UTXOAccount = AccountBase<ChainType.UTXO, Connector>;
29
- export type DefaultAccount = AccountBase<ChainType>;
22
+ export interface EVMAccount extends AccountBase {
23
+ chainType: ChainType.EVM;
24
+ connector?: Connector;
25
+ }
30
26
 
31
- export type Account = EVMAccount | SVMAccount | UTXOAccount | DefaultAccount;
27
+ export interface SVMAccount extends AccountBase {
28
+ chainType: ChainType.SVM;
29
+ connector?: WalletAdapter;
30
+ }
31
+
32
+ export interface DefaultAccount extends AccountBase {
33
+ connector?: never;
34
+ }
35
+
36
+ export type Account = EVMAccount | SVMAccount | DefaultAccount;
32
37
 
33
38
  export interface AccountResult {
34
39
  account: Account;
@@ -42,8 +47,7 @@ interface UseAccountArgs {
42
47
  chainType?: ChainType;
43
48
  }
44
49
 
45
- const defaultAccount: AccountBase<ChainType> = {
46
- chainType: ChainType.EVM,
50
+ const defaultAccount: AccountBase = {
47
51
  isConnected: false,
48
52
  isConnecting: false,
49
53
  isReconnecting: false,
@@ -51,35 +55,18 @@ const defaultAccount: AccountBase<ChainType> = {
51
55
  status: 'disconnected',
52
56
  };
53
57
 
54
- export type LastConnectedAccount =
55
- | WalletAdapter
56
- | Connector
57
- | CreateConnectorFnExtended
58
- | null;
59
-
60
- interface LastConnectedAccountStore {
61
- lastConnectedAccount: LastConnectedAccount;
62
- setLastConnectedAccount: (account: LastConnectedAccount) => void;
63
- }
64
-
65
- export const useLastConnectedAccount = create<LastConnectedAccountStore>(
66
- (set) => ({
67
- lastConnectedAccount: null,
68
- setLastConnectedAccount: (account) =>
69
- set({ lastConnectedAccount: account }),
70
- }),
71
- );
72
-
73
58
  /**
59
+ *
74
60
  * @param args When we provide args we want to return either account with corresponding chainType or default disconnected one
75
61
  * @returns - Account result
76
62
  */
77
63
  export const useAccount = (args?: UseAccountArgs): AccountResult => {
78
- const bigmiConfig = useBigmiConfig();
79
- const bigmiAccount = useAccountInternal({ config: bigmiConfig });
80
- const wagmiAccount = useAccountInternal();
64
+ const account = useWagmiAccount();
81
65
  const { wallet } = useWallet();
82
- const { lastConnectedAccount } = useLastConnectedAccount();
66
+
67
+ // We create a simple variable from the args object
68
+ // to avoid re-render useMemo on every object reference change.
69
+ const hasChainTypeArgs = Boolean(args);
83
70
 
84
71
  return useMemo(() => {
85
72
  const svm: Account = wallet?.adapter.publicKey
@@ -102,55 +89,21 @@ export const useAccount = (args?: UseAccountArgs): AccountResult => {
102
89
  isDisconnected: true,
103
90
  status: 'disconnected',
104
91
  };
105
- const evm: Account = { ...wagmiAccount, chainType: ChainType.EVM };
106
- const utxo: Account = { ...bigmiAccount, chainType: ChainType.UTXO };
107
- const accounts = [evm, svm, utxo];
108
- const connectedAccounts = accounts.filter(
92
+ const evm: Account = { ...account, chainType: ChainType.EVM };
93
+ const accounts = [evm, svm];
94
+ const connectedAccounts = [evm, svm].filter(
109
95
  (account) => account.isConnected && account.address,
110
96
  );
111
-
112
- // If a chainType argument is provided, attempt to find a connected account with the matching chainType.
113
- // If no matching account is found, fallback to the default account.
114
- // If no chainType argument, selectedAccount should be used.
115
- const selectedChainTypeAccount = args?.chainType
116
- ? connectedAccounts.find(
117
- (account) => account.chainType === args?.chainType,
118
- ) || defaultAccount
119
- : undefined;
120
-
121
- // If lastConnectedAccount exists, attempt to find a connected account with a matching connector ID or name.
122
- // If no matching account is found, fallback to the first connected account.
123
- // If lastConnectedAccount is not present, simply select the first connected account.
124
- const selectedAccount = lastConnectedAccount
125
- ? connectedAccounts.find((account) => {
126
- const connectorIdMatch =
127
- (lastConnectedAccount as Connector)?.id ===
128
- (account.connector as Connector)?.id;
129
- const connectorNameMatch =
130
- !(lastConnectedAccount as Connector)?.id &&
131
- (lastConnectedAccount as WalletAdapter)?.name ===
132
- account.connector?.name;
133
- return connectorIdMatch || connectorNameMatch;
134
- }) || connectedAccounts[0]
135
- : connectedAccounts[0];
136
-
137
97
  return {
138
- account: selectedChainTypeAccount || selectedAccount || defaultAccount,
98
+ account:
99
+ accounts.find(
100
+ (account) =>
101
+ (!hasChainTypeArgs || account.chainType === args?.chainType) &&
102
+ account.isConnected &&
103
+ account.address,
104
+ ) ?? defaultAccount,
139
105
  // We need to return only connected account list
140
106
  accounts: connectedAccounts,
141
107
  };
142
- // eslint-disable-next-line react-hooks/exhaustive-deps
143
- }, [
144
- wallet,
145
- wagmiAccount.connector?.uid,
146
- wagmiAccount.connector?.id,
147
- wagmiAccount.status,
148
- wagmiAccount.address,
149
- bigmiAccount.connector?.uid,
150
- bigmiAccount.connector?.id,
151
- bigmiAccount.status,
152
- bigmiAccount.address,
153
- args?.chainType,
154
- lastConnectedAccount,
155
- ]);
108
+ }, [account, args?.chainType, hasChainTypeArgs, wallet]);
156
109
  };
@@ -2,31 +2,32 @@ import type { ExtendedChain } from '@lifi/sdk';
2
2
  import { ChainType, config, getChains } from '@lifi/sdk';
3
3
  import { useQuery } from '@tanstack/react-query';
4
4
  import { useCallback } from 'react';
5
+ import { useHasExternalWalletProvider } from '../providers/WalletProvider/useHasExternalWalletProvider.js';
5
6
  import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
6
7
  import { isItemAllowed } from '../utils/item.js';
7
8
 
8
- const supportedChainTypes = [ChainType.EVM, ChainType.SVM, ChainType.UTXO];
9
+ const supportedChainTypes = [ChainType.EVM, ChainType.SVM];
9
10
 
10
- export const useAvailableChains = (chainTypes?: ChainType[]) => {
11
+ export const useAvailableChains = () => {
11
12
  const { chains } = useWidgetConfig();
12
- // const { providers } = useHasExternalWalletProvider();
13
+ const { providers } = useHasExternalWalletProvider();
13
14
  const { data, isLoading } = useQuery({
14
15
  queryKey: [
15
16
  'chains',
16
- // providers,
17
+ providers,
17
18
  chains?.types,
18
19
  chains?.allow,
19
20
  chains?.deny,
20
21
  chains?.from,
21
22
  chains?.to,
22
23
  ] as const,
23
- queryFn: async ({ queryKey: [, chainTypesConfig] }) => {
24
- const chainTypesRequest = supportedChainTypes
25
- // providers.length > 0 ? providers : supportedChainTypes
26
- .filter((chainType) => isItemAllowed(chainType, chainTypesConfig));
24
+ queryFn: async ({ queryKey: [, providers, chainTypes] }) => {
25
+ const chainTypesRequest = (
26
+ providers.length > 0 ? providers : supportedChainTypes
27
+ ).filter((chainType) => isItemAllowed(chainType, chainTypes));
27
28
 
28
29
  const availableChains = await getChains({
29
- chainTypes: chainTypes || chainTypesRequest,
30
+ chainTypes: chainTypesRequest,
30
31
  });
31
32
  config.setChains(availableChains);
32
33
  return availableChains;
@@ -1,11 +1,10 @@
1
- import type { ChainType } from '@lifi/sdk';
2
1
  import { useMemo } from 'react';
3
2
  import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
4
3
  import type { FormType } from '../stores/form/types.js';
5
4
  import { isItemAllowed } from '../utils/item.js';
6
5
  import { useAvailableChains } from './useAvailableChains.js';
7
6
 
8
- export const useChains = (type?: FormType, chainTypes?: ChainType[]) => {
7
+ export const useChains = (type?: FormType) => {
9
8
  const { chains } = useWidgetConfig();
10
9
  const {
11
10
  chains: availableChains,
@@ -18,13 +17,11 @@ export const useChains = (type?: FormType, chainTypes?: ChainType[]) => {
18
17
  ? availableChains?.filter(
19
18
  (chain) =>
20
19
  isItemAllowed(chain.id, chains) &&
21
- isItemAllowed(chain.id, chains?.[type]) &&
22
- // Check against chain types if they are provided
23
- (chainTypes?.includes(chain.chainType) ?? true),
20
+ isItemAllowed(chain.id, chains?.[type]),
24
21
  )
25
22
  : availableChains?.filter((chain) => isItemAllowed(chain.id, chains));
26
23
  return filteredChains;
27
- }, [availableChains, chainTypes, chains, type]);
24
+ }, [availableChains, chains, type]);
28
25
 
29
26
  return {
30
27
  chains: filteredChains,
@@ -5,6 +5,17 @@ import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
5
5
 
6
6
  const sanitiseBaseUrl = (baseUrl: string) => baseUrl.trim().replace(/\/+$/, '');
7
7
 
8
+ export type TransactionLinkProps = { chain?: Chain | number } & (
9
+ | {
10
+ txHash: string;
11
+ txLink?: never;
12
+ }
13
+ | {
14
+ txHash?: never;
15
+ txLink: string;
16
+ }
17
+ );
18
+
8
19
  export const useExplorer = () => {
9
20
  const { explorerUrls } = useWidgetConfig();
10
21
  const { getChainById } = useAvailableChains();
@@ -20,14 +31,20 @@ export const useExplorer = () => {
20
31
  const resolveChain = (chain: Chain | number) =>
21
32
  Number.isFinite(chain) ? getChainById(chain as number) : (chain as Chain);
22
33
 
23
- const getTransactionLink = (txHash: string, chain?: Chain | number) => {
34
+ const getTransactionLink = ({
35
+ txHash,
36
+ txLink,
37
+ chain,
38
+ }: TransactionLinkProps) => {
39
+ if (!txHash && txLink) {
40
+ return txLink;
41
+ }
24
42
  if (!chain) {
25
43
  const baseUrl = explorerUrls?.internal?.[0]
26
44
  ? sanitiseBaseUrl(explorerUrls?.internal[0])
27
45
  : lifiExplorerUrl;
28
46
  return `${baseUrl}/tx/${txHash}`;
29
47
  }
30
-
31
48
  const resolvedChain = resolveChain(chain);
32
49
  return `${resolvedChain ? getBaseUrl(resolvedChain) : lifiExplorerUrl}/tx/${txHash}`;
33
50
  };
@@ -44,8 +44,7 @@ export const useGasSufficiency = (route?: RouteExtended) => {
44
44
  ) {
45
45
  const { token } = step.estimate.gasCosts[0];
46
46
  const gasCostAmount = step.estimate.gasCosts.reduce(
47
- (amount, gasCost) =>
48
- amount + BigInt(Number(gasCost.amount).toFixed(0)),
47
+ (amount, gasCost) => amount + BigInt(gasCost.amount),
49
48
  0n,
50
49
  );
51
50
  groupedGasCosts[token.chainId] = {
@@ -62,8 +61,7 @@ export const useGasSufficiency = (route?: RouteExtended) => {
62
61
  if (nonIncludedFeeCosts?.length) {
63
62
  const { token } = nonIncludedFeeCosts[0];
64
63
  const feeCostAmount = nonIncludedFeeCosts.reduce(
65
- (amount, feeCost) =>
66
- amount + BigInt(Number(feeCost.amount).toFixed(0)),
64
+ (amount, feeCost) => amount + BigInt(feeCost.amount),
67
65
  0n,
68
66
  );
69
67
  groupedGasCosts[token.chainId] = {
@@ -1,16 +1,23 @@
1
+ import { useHasExternalWalletProvider } from '../providers/WalletProvider/useHasExternalWalletProvider.js';
1
2
  import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
2
3
 
3
4
  export const minHeaderHeight = 64;
4
5
  export const maxHeaderHeight = 108;
5
6
  export const maxHeaderHeightSubvariantSplit = 136;
6
7
 
8
+ // We use fixed position on the header when Widget is in Full Height layout.
9
+ // We do this to get it to work like the sticky header does in the other layout modes.
10
+ // As the header is position fixed its not in the document flow anymore.
11
+ // To prevent the remaining page content from appearing behind the header we need to
12
+ // pass the headers height so that the position of the page content can be adjusted
7
13
  export const useHeaderHeight = () => {
8
14
  const { hiddenUI, subvariant } = useWidgetConfig();
15
+ const { hasExternalProvider } = useHasExternalWalletProvider();
9
16
 
10
17
  const headerHeight =
11
18
  subvariant === 'split'
12
19
  ? maxHeaderHeightSubvariantSplit
13
- : hiddenUI?.includes('walletMenu')
20
+ : hiddenUI?.includes('walletMenu') || hasExternalProvider
14
21
  ? minHeaderHeight
15
22
  : maxHeaderHeight;
16
23
 
@@ -9,8 +9,7 @@ export const useTokens = (selectedChainId?: number) => {
9
9
  const { tokens: configTokens } = useWidgetConfig();
10
10
  const { data, isLoading } = useQuery({
11
11
  queryKey: ['tokens'],
12
- queryFn: () =>
13
- getTokens({ chainTypes: [ChainType.EVM, ChainType.SVM, ChainType.UTXO] }),
12
+ queryFn: () => getTokens({ chainTypes: [ChainType.EVM, ChainType.SVM] }),
14
13
  refetchInterval: 3_600_000,
15
14
  staleTime: 3_600_000,
16
15
  });
@@ -6,7 +6,6 @@ import {
6
6
  createWalletConnectConnector,
7
7
  getWalletPriority,
8
8
  isWalletInstalled,
9
- useConfig as useBigmiConfig,
10
9
  } from '@lifi/wallet-management';
11
10
  import type { Theme } from '@mui/material';
12
11
  import { useMediaQuery } from '@mui/material';
@@ -15,7 +14,7 @@ import type { Wallet } from '@solana/wallet-adapter-react';
15
14
  import { useWallet } from '@solana/wallet-adapter-react';
16
15
  import { useMemo } from 'react';
17
16
  import type { Connector } from 'wagmi';
18
- import { useAccount, useConnect } from 'wagmi';
17
+ import { useConnect, useAccount as useWagmiAccount } from 'wagmi';
19
18
  import { defaultCoinbaseConfig } from '../config/coinbase.js';
20
19
  import { defaultMetaMaskConfig } from '../config/metaMask.js';
21
20
  import { defaultWalletConnectConfig } from '../config/walletConnect.js';
@@ -26,11 +25,8 @@ export const useWallets = (
26
25
  walletConfig?: WidgetWalletConfig,
27
26
  chains?: WidgetChains,
28
27
  ) => {
29
- const bigmiConfig = useBigmiConfig();
30
- const wagmiAccount = useAccount();
31
- const bigmiAccount = useAccount({ config: bigmiConfig });
32
- const { connectors: wagmiConnectors } = useConnect();
33
- const { connectors: bigmiConnectors } = useConnect({ config: bigmiConfig });
28
+ const account = useWagmiAccount();
29
+ const { connectors } = useConnect();
34
30
  const { wallets: solanaWallets } = useWallet();
35
31
 
36
32
  const isDesktopView = useMediaQuery((theme: Theme) =>
@@ -39,9 +35,9 @@ export const useWallets = (
39
35
 
40
36
  const wallets = useMemo(() => {
41
37
  const evmConnectors: (CreateConnectorFnExtended | Connector)[] =
42
- Array.from(wagmiConnectors);
38
+ Array.from(connectors);
43
39
  if (
44
- !wagmiConnectors.some((connector) =>
40
+ !connectors.some((connector) =>
45
41
  connector.id.toLowerCase().includes('walletconnect'),
46
42
  )
47
43
  ) {
@@ -52,7 +48,7 @@ export const useWallets = (
52
48
  );
53
49
  }
54
50
  if (
55
- !wagmiConnectors.some((connector) =>
51
+ !connectors.some((connector) =>
56
52
  connector.id.toLowerCase().includes('coinbase'),
57
53
  ) &&
58
54
  !isWalletInstalled('coinbase')
@@ -64,7 +60,7 @@ export const useWallets = (
64
60
  );
65
61
  }
66
62
  if (
67
- !wagmiConnectors.some((connector) =>
63
+ !connectors.some((connector) =>
68
64
  connector.id.toLowerCase().includes('metamask'),
69
65
  ) &&
70
66
  !isWalletInstalled('metaMask')
@@ -78,24 +74,13 @@ export const useWallets = (
78
74
  const evmInstalled = isItemAllowed(ChainType.EVM, chains?.types)
79
75
  ? evmConnectors.filter(
80
76
  (connector) =>
81
- isWalletInstalled(connector.id) &&
77
+ isWalletInstalled(connector.id!) &&
82
78
  // We should not show already connected connectors
83
- wagmiAccount.connector?.id !== connector.id,
79
+ account.connector?.id !== connector.id,
84
80
  )
85
81
  : [];
86
82
  const evmNotDetected = isItemAllowed(ChainType.EVM, chains?.types)
87
- ? evmConnectors.filter((connector) => !isWalletInstalled(connector.id))
88
- : [];
89
- const utxoInstalled = isItemAllowed(ChainType.UTXO, chains?.types)
90
- ? bigmiConnectors.filter(
91
- (connector) =>
92
- isWalletInstalled(connector.id) &&
93
- // We should not show already connected connectors
94
- bigmiAccount.connector?.id !== connector.id,
95
- )
96
- : [];
97
- const utxoNotDetected = isItemAllowed(ChainType.UTXO, chains?.types)
98
- ? bigmiConnectors.filter((connector) => !isWalletInstalled(connector.id!))
83
+ ? evmConnectors.filter((connector) => !isWalletInstalled(connector.id!))
99
84
  : [];
100
85
  const svmInstalled = isItemAllowed(ChainType.SVM, chains?.types)
101
86
  ? solanaWallets?.filter(
@@ -112,33 +97,27 @@ export const useWallets = (
112
97
  )
113
98
  : [];
114
99
 
115
- const installedWallets = [
116
- ...evmInstalled,
117
- ...svmInstalled,
118
- ...utxoInstalled,
119
- ].sort(walletComparator);
100
+ const installedWallets = [...evmInstalled, ...svmInstalled].sort(
101
+ walletComparator,
102
+ );
120
103
 
121
104
  if (isDesktopView) {
122
- const notDetectedWallets = [
123
- ...evmNotDetected,
124
- ...svmNotDetected,
125
- ...utxoNotDetected,
126
- ].sort(walletComparator);
105
+ const notDetectedWallets = [...evmNotDetected, ...svmNotDetected].sort(
106
+ walletComparator,
107
+ );
127
108
  installedWallets.push(...notDetectedWallets);
128
109
  }
129
110
 
130
111
  return installedWallets;
131
112
  }, [
132
- wagmiConnectors,
113
+ account.connector?.id,
133
114
  chains?.types,
134
- bigmiConnectors,
135
- solanaWallets,
115
+ connectors,
136
116
  isDesktopView,
137
- walletConfig?.walletConnect,
117
+ solanaWallets,
138
118
  walletConfig?.coinbase,
139
119
  walletConfig?.metaMask,
140
- bigmiAccount.connector?.id,
141
- wagmiAccount.connector?.id,
120
+ walletConfig?.walletConnect,
142
121
  ]);
143
122
 
144
123
  return wallets;
package/i18n/en.json CHANGED
@@ -16,10 +16,10 @@
16
16
  "bridgeReview": "Review bridge",
17
17
  "buy": "Buy",
18
18
  "cancel": "Cancel",
19
+ "changeWallet": "Change wallet",
19
20
  "checkoutReview": "Review purchase",
20
21
  "close": "Close",
21
22
  "confirm": "Confirm",
22
- "connectAnotherWallet": "Connect another wallet",
23
23
  "connectWallet": "Connect wallet",
24
24
  "contactSupport": "Contact support",
25
25
  "continue": "Continue",