@lifi/widget 3.6.1 → 3.7.0-beta.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.
- package/AppProvider.tsx +4 -4
- package/AppRoutes.tsx +2 -14
- package/CHANGELOG.md +0 -7
- package/_esm/AppProvider.js +1 -1
- package/_esm/AppProvider.js.map +1 -1
- package/_esm/AppRoutes.js +2 -9
- package/_esm/AppRoutes.js.map +1 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.style.js +1 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.style.js.map +1 -1
- package/_esm/components/AmountInput/AmountInputEndAdornment.js +1 -3
- package/_esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/_esm/components/Avatar/AccountAvatar.d.ts +1 -1
- package/_esm/components/Avatar/AccountAvatar.js +1 -1
- package/_esm/components/Avatar/AccountAvatar.js.map +1 -1
- package/_esm/components/Avatar/Avatar.d.ts +1 -0
- package/_esm/components/Avatar/Avatar.js +7 -4
- package/_esm/components/Avatar/Avatar.js.map +1 -1
- package/_esm/components/Avatar/Avatar.style.d.ts +6 -3
- package/_esm/components/Avatar/Avatar.style.js +19 -6
- package/_esm/components/Avatar/Avatar.style.js.map +1 -1
- package/_esm/components/Avatar/SmallAvatar.d.ts +4 -0
- package/_esm/components/Avatar/SmallAvatar.js +12 -0
- package/_esm/components/Avatar/SmallAvatar.js.map +1 -0
- package/_esm/components/Avatar/TokenAvatar.js +1 -1
- package/_esm/components/Avatar/TokenAvatar.js.map +1 -1
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js +3 -5
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/_esm/components/ChainSelect/useChainSelect.js +5 -1
- package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/_esm/components/FeeBreakdownTooltip.js +4 -1
- package/_esm/components/FeeBreakdownTooltip.js.map +1 -1
- package/_esm/components/Header/EVMDisconnectIconButton.js +5 -4
- package/_esm/components/Header/EVMDisconnectIconButton.js.map +1 -1
- package/_esm/components/Header/NavigationHeader.js +1 -1
- package/_esm/components/Header/NavigationHeader.js.map +1 -1
- package/_esm/components/Header/UTXODisconnectIconButton.d.ts +4 -0
- package/_esm/components/Header/UTXODisconnectIconButton.js +13 -0
- package/_esm/components/Header/UTXODisconnectIconButton.js.map +1 -0
- package/_esm/components/Header/WalletHeader.js +5 -9
- package/_esm/components/Header/WalletHeader.js.map +1 -1
- package/_esm/components/Header/WalletMenu.js +10 -15
- package/_esm/components/Header/WalletMenu.js.map +1 -1
- package/_esm/components/Header/WalletMenu.style.js +5 -1
- package/_esm/components/Header/WalletMenu.style.js.map +1 -1
- package/_esm/components/Routes/RoutesExpanded.js +1 -1
- package/_esm/components/Routes/RoutesExpanded.js.map +1 -1
- package/_esm/components/SendToWallet/SendToWalletButton.js +1 -1
- package/_esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/_esm/components/StepActions/StepActions.js +1 -1
- package/_esm/components/StepActions/StepActions.js.map +1 -1
- package/_esm/components/Tabs/Tabs.style.d.ts +1 -1
- package/_esm/components/Token/Token.js +1 -1
- package/_esm/components/Token/Token.js.map +1 -1
- package/_esm/components/TokenList/TokenList.js +1 -1
- package/_esm/components/TokenList/TokenList.js.map +1 -1
- package/_esm/components/TokenList/TokenListItem.js +11 -5
- package/_esm/components/TokenList/TokenListItem.js.map +1 -1
- package/_esm/components/TokenList/VirtualizedTokenList.js +1 -1
- package/_esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
- package/_esm/components/TokenList/types.d.ts +3 -3
- package/_esm/components/TokenRate/TokenRate.js +2 -2
- package/_esm/components/TokenRate/TokenRate.js.map +1 -1
- package/_esm/config/version.d.ts +1 -1
- package/_esm/config/version.js +1 -1
- package/_esm/config/version.js.map +1 -1
- package/_esm/hooks/useAvailableChains.d.ts +2 -1
- package/_esm/hooks/useAvailableChains.js +9 -8
- package/_esm/hooks/useAvailableChains.js.map +1 -1
- package/_esm/hooks/useChains.d.ts +4 -3
- package/_esm/hooks/useChains.js +5 -3
- package/_esm/hooks/useChains.js.map +1 -1
- package/_esm/hooks/useFromTokenSufficiency.js +1 -1
- package/_esm/hooks/useFromTokenSufficiency.js.map +1 -1
- package/_esm/hooks/useGasSufficiency.js +3 -3
- package/_esm/hooks/useGasSufficiency.js.map +1 -1
- package/_esm/hooks/useProcessMessage.js +4 -0
- package/_esm/hooks/useProcessMessage.js.map +1 -1
- package/_esm/hooks/useRouteExecution.js +1 -1
- package/_esm/hooks/useRouteExecution.js.map +1 -1
- package/_esm/hooks/useRoutes.js +1 -1
- package/_esm/hooks/useRoutes.js.map +1 -1
- package/_esm/hooks/useTokenBalance.js +1 -1
- package/_esm/hooks/useTokenBalance.js.map +1 -1
- package/_esm/hooks/useTokenBalances.js +1 -1
- package/_esm/hooks/useTokenBalances.js.map +1 -1
- package/_esm/hooks/useTokens.js +1 -1
- package/_esm/hooks/useTokens.js.map +1 -1
- package/_esm/hooks/useTransactionDetails.js +1 -1
- package/_esm/hooks/useTransactionDetails.js.map +1 -1
- package/_esm/hooks/useTransactionHistory.js +1 -1
- package/_esm/hooks/useTransactionHistory.js.map +1 -1
- package/_esm/i18n/en.json +3 -4
- package/_esm/index.d.ts +0 -2
- package/_esm/index.js +0 -2
- package/_esm/index.js.map +1 -1
- package/_esm/pages/RoutesPage/RoutesPage.js +1 -1
- package/_esm/pages/RoutesPage/RoutesPage.js.map +1 -1
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js +1 -1
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js.map +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.js +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
- package/_esm/providers/I18nProvider/types.d.ts +2 -2
- package/_esm/providers/WalletProvider/SDKProviders.js +15 -7
- package/_esm/providers/WalletProvider/SDKProviders.js.map +1 -1
- package/_esm/providers/WalletProvider/UTXOBaseProvider.d.ts +2 -0
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js +17 -0
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js.map +1 -0
- package/_esm/providers/WalletProvider/UTXOExternalContext.d.ts +1 -0
- package/_esm/providers/WalletProvider/UTXOExternalContext.js +3 -0
- package/_esm/providers/WalletProvider/UTXOExternalContext.js.map +1 -0
- package/_esm/providers/WalletProvider/UTXOProvider.d.ts +3 -0
- package/_esm/providers/WalletProvider/UTXOProvider.js +18 -0
- package/_esm/providers/WalletProvider/UTXOProvider.js.map +1 -0
- package/_esm/providers/WalletProvider/WalletProvider.d.ts +1 -0
- package/_esm/providers/WalletProvider/WalletProvider.js +14 -1
- package/_esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.d.ts +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js +8 -3
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.js +2 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/types.d.ts +0 -2
- package/_esm/stores/form/FormUpdater.js +1 -1
- package/_esm/stores/form/FormUpdater.js.map +1 -1
- package/_esm/stores/form/types.d.ts +4 -4
- package/_esm/stores/routes/useExecutingRoutesIds.js +1 -1
- package/_esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/_esm/themes/createTheme.js +2 -1
- package/_esm/themes/createTheme.js.map +1 -1
- package/_esm/types/events.d.ts +6 -0
- package/_esm/types/events.js +3 -0
- package/_esm/types/events.js.map +1 -1
- package/_esm/utils/chainType.js +2 -3
- package/_esm/utils/chainType.js.map +1 -1
- package/_esm/utils/fees.js +9 -5
- package/_esm/utils/fees.js.map +1 -1
- package/_esm/utils/format.js +1 -1
- package/_esm/utils/format.js.map +1 -1
- package/_esm/utils/navigationRoutes.d.ts +0 -1
- package/_esm/utils/navigationRoutes.js +0 -3
- package/_esm/utils/navigationRoutes.js.map +1 -1
- package/_esm/utils/wallet.js +1 -1
- package/components/ActiveTransactions/ActiveTransactions.style.ts +1 -1
- package/components/AmountInput/AmountInputEndAdornment.tsx +1 -5
- package/components/Avatar/AccountAvatar.tsx +2 -2
- package/components/Avatar/Avatar.style.tsx +20 -7
- package/components/Avatar/Avatar.tsx +12 -4
- package/components/Avatar/SmallAvatar.tsx +16 -0
- package/components/Avatar/TokenAvatar.tsx +1 -1
- package/components/BaseTransactionButton/BaseTransactionButton.tsx +3 -5
- package/components/ChainSelect/useChainSelect.ts +10 -1
- package/components/FeeBreakdownTooltip.tsx +4 -1
- package/components/Header/EVMDisconnectIconButton.tsx +5 -5
- package/components/Header/NavigationHeader.tsx +1 -1
- package/components/Header/UTXODisconnectIconButton.tsx +24 -0
- package/components/Header/WalletHeader.tsx +11 -12
- package/components/Header/WalletMenu.style.tsx +5 -1
- package/components/Header/WalletMenu.tsx +23 -24
- package/components/Routes/RoutesExpanded.tsx +1 -2
- package/components/SendToWallet/SendToWalletButton.tsx +1 -1
- package/components/StepActions/StepActions.tsx +1 -1
- package/components/Token/Token.tsx +1 -1
- package/components/TokenList/TokenList.tsx +1 -1
- package/components/TokenList/TokenListItem.tsx +15 -7
- package/components/TokenList/VirtualizedTokenList.tsx +1 -1
- package/components/TokenList/types.ts +3 -3
- package/components/TokenRate/TokenRate.tsx +2 -2
- package/config/version.ts +1 -1
- package/hooks/useAvailableChains.ts +9 -10
- package/hooks/useChains.ts +6 -3
- package/hooks/useFromTokenSufficiency.ts +1 -1
- package/hooks/useGasSufficiency.ts +5 -3
- package/hooks/useProcessMessage.ts +4 -0
- package/hooks/useRouteExecution.ts +1 -1
- package/hooks/useRoutes.ts +1 -1
- package/hooks/useTokenBalance.ts +1 -1
- package/hooks/useTokenBalances.ts +1 -1
- package/hooks/useTokens.ts +2 -1
- package/hooks/useTransactionDetails.ts +1 -1
- package/hooks/useTransactionHistory.ts +1 -1
- package/i18n/en.json +3 -4
- package/index.ts +0 -2
- package/package.json +5 -5
- package/pages/RoutesPage/RoutesPage.tsx +1 -1
- package/pages/SendToWallet/ConnectedWalletsPage.tsx +2 -2
- package/pages/SendToWallet/SendToWalletPage.tsx +1 -1
- package/providers/I18nProvider/types.ts +2 -2
- package/providers/WalletProvider/SDKProviders.tsx +25 -7
- package/providers/WalletProvider/UTXOBaseProvider.tsx +28 -0
- package/providers/WalletProvider/UTXOExternalContext.ts +3 -0
- package/providers/WalletProvider/UTXOProvider.tsx +26 -0
- package/providers/WalletProvider/WalletProvider.tsx +24 -3
- package/providers/WalletProvider/useHasExternalWalletProvider.ts +11 -5
- package/providers/WidgetProvider/WidgetProvider.tsx +2 -1
- package/providers/WidgetProvider/types.ts +0 -2
- package/stores/form/FormUpdater.tsx +1 -1
- package/stores/form/types.ts +4 -4
- package/stores/routes/useExecutingRoutesIds.ts +1 -1
- package/themes/createTheme.ts +3 -1
- package/types/events.ts +6 -0
- package/utils/chainType.ts +2 -3
- package/utils/fees.ts +15 -13
- package/utils/format.ts +1 -1
- package/utils/navigationRoutes.ts +0 -3
- package/utils/wallet.ts +1 -1
- package/_esm/components/SmallAvatar.d.ts +0 -10
- package/_esm/components/SmallAvatar.js +0 -19
- package/_esm/components/SmallAvatar.js.map +0 -1
- package/_esm/hooks/useAccount.d.ts +0 -45
- package/_esm/hooks/useAccount.js +0 -56
- package/_esm/hooks/useAccount.js.map +0 -1
- package/_esm/hooks/useWallets.d.ts +0 -6
- package/_esm/hooks/useWallets.js +0 -80
- package/_esm/hooks/useWallets.js.map +0 -1
- package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +0 -9
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js +0 -39
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +0 -1
- package/_esm/pages/SelectWalletPage/SVMListItemButton.d.ts +0 -6
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js +0 -32
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js.map +0 -1
- package/_esm/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js +0 -41
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +0 -1
- package/_esm/utils/svm.d.ts +0 -1
- package/_esm/utils/svm.js +0 -11
- package/_esm/utils/svm.js.map +0 -1
- package/components/SmallAvatar.tsx +0 -25
- package/hooks/useAccount.ts +0 -109
- package/hooks/useWallets.ts +0 -147
- package/pages/SelectWalletPage/EVMListItemButton.tsx +0 -74
- package/pages/SelectWalletPage/SVMListItemButton.tsx +0 -47
- package/pages/SelectWalletPage/SelectWalletPage.tsx +0 -90
- package/utils/svm.ts +0 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExtendedChain } from '@lifi/sdk';
|
|
2
|
+
import type { Account } from '@lifi/wallet-management';
|
|
2
3
|
import type { MouseEventHandler, MutableRefObject } from 'react';
|
|
3
|
-
import type { Account } from '../../hooks/useAccount.js';
|
|
4
4
|
import type { FormType } from '../../stores/form/types.js';
|
|
5
5
|
import type { TokenAmount } from '../../types/token.js';
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ export interface TokenListItemBaseProps {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface TokenListItemProps extends TokenListItemBaseProps {
|
|
33
|
-
|
|
33
|
+
accountAddress?: string;
|
|
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
|
-
|
|
43
|
+
accountAddress?: string;
|
|
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
|
|
21
|
+
const useTokenRate = 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 } =
|
|
27
|
+
const { isForward, toggleIsForward } = useTokenRate();
|
|
28
28
|
|
|
29
29
|
const toggleRate: MouseEventHandler<HTMLSpanElement> = (e) => {
|
|
30
30
|
e.stopPropagation();
|
package/config/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '3.
|
|
2
|
+
export const version = '3.7.0-beta.0';
|
|
@@ -2,32 +2,31 @@ 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';
|
|
6
5
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
|
|
7
6
|
import { isItemAllowed } from '../utils/item.js';
|
|
8
7
|
|
|
9
|
-
const supportedChainTypes = [ChainType.EVM, ChainType.SVM];
|
|
8
|
+
const supportedChainTypes = [ChainType.EVM, ChainType.SVM, ChainType.UTXO];
|
|
10
9
|
|
|
11
|
-
export const useAvailableChains = () => {
|
|
10
|
+
export const useAvailableChains = (chainTypes?: ChainType[]) => {
|
|
12
11
|
const { chains } = useWidgetConfig();
|
|
13
|
-
const { providers } = useHasExternalWalletProvider();
|
|
12
|
+
// const { providers } = useHasExternalWalletProvider();
|
|
14
13
|
const { data, isLoading } = useQuery({
|
|
15
14
|
queryKey: [
|
|
16
15
|
'chains',
|
|
17
|
-
providers,
|
|
16
|
+
// providers,
|
|
18
17
|
chains?.types,
|
|
19
18
|
chains?.allow,
|
|
20
19
|
chains?.deny,
|
|
21
20
|
chains?.from,
|
|
22
21
|
chains?.to,
|
|
23
22
|
] as const,
|
|
24
|
-
queryFn: async ({ queryKey: [,
|
|
25
|
-
const chainTypesRequest =
|
|
26
|
-
providers.length > 0 ? providers : supportedChainTypes
|
|
27
|
-
|
|
23
|
+
queryFn: async ({ queryKey: [, chainTypesConfig] }) => {
|
|
24
|
+
const chainTypesRequest = supportedChainTypes
|
|
25
|
+
// providers.length > 0 ? providers : supportedChainTypes
|
|
26
|
+
.filter((chainType) => isItemAllowed(chainType, chainTypesConfig));
|
|
28
27
|
|
|
29
28
|
const availableChains = await getChains({
|
|
30
|
-
chainTypes: chainTypesRequest,
|
|
29
|
+
chainTypes: chainTypes || chainTypesRequest,
|
|
31
30
|
});
|
|
32
31
|
config.setChains(availableChains);
|
|
33
32
|
return availableChains;
|
package/hooks/useChains.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { ChainType } from '@lifi/sdk';
|
|
1
2
|
import { useMemo } from 'react';
|
|
2
3
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
|
|
3
4
|
import type { FormType } from '../stores/form/types.js';
|
|
4
5
|
import { isItemAllowed } from '../utils/item.js';
|
|
5
6
|
import { useAvailableChains } from './useAvailableChains.js';
|
|
6
7
|
|
|
7
|
-
export const useChains = (type?: FormType) => {
|
|
8
|
+
export const useChains = (type?: FormType, chainTypes?: ChainType[]) => {
|
|
8
9
|
const { chains } = useWidgetConfig();
|
|
9
10
|
const {
|
|
10
11
|
chains: availableChains,
|
|
@@ -17,11 +18,13 @@ export const useChains = (type?: FormType) => {
|
|
|
17
18
|
? availableChains?.filter(
|
|
18
19
|
(chain) =>
|
|
19
20
|
isItemAllowed(chain.id, chains) &&
|
|
20
|
-
isItemAllowed(chain.id, chains?.[type])
|
|
21
|
+
isItemAllowed(chain.id, chains?.[type]) &&
|
|
22
|
+
// Check against chain types if they are provided
|
|
23
|
+
(chainTypes?.includes(chain.chainType) ?? true),
|
|
21
24
|
)
|
|
22
25
|
: availableChains?.filter((chain) => isItemAllowed(chain.id, chains));
|
|
23
26
|
return filteredChains;
|
|
24
|
-
}, [availableChains, chains, type]);
|
|
27
|
+
}, [availableChains, chainTypes, chains, type]);
|
|
25
28
|
|
|
26
29
|
return {
|
|
27
30
|
chains: filteredChains,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { RouteExtended } from '@lifi/sdk';
|
|
2
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
2
3
|
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
|
3
4
|
import { parseUnits } from 'viem';
|
|
4
5
|
import { useFieldValues } from '../stores/form/useFieldValues.js';
|
|
5
6
|
import { isRouteDone } from '../stores/routes/utils.js';
|
|
6
|
-
import { useAccount } from './useAccount.js';
|
|
7
7
|
import { useTokenAddressBalance } from './useTokenAddressBalance.js';
|
|
8
8
|
import { getTokenBalancesWithRetry } from './useTokenBalance.js';
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type EVMChain, type RouteExtended, type Token } from '@lifi/sdk';
|
|
2
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
2
3
|
import { useQuery } from '@tanstack/react-query';
|
|
3
4
|
import type { Connector } from 'wagmi';
|
|
4
|
-
import { useAccount } from './useAccount.js';
|
|
5
5
|
import { useAvailableChains } from './useAvailableChains.js';
|
|
6
6
|
import { getTokenBalancesWithRetry } from './useTokenBalance.js';
|
|
7
7
|
|
|
@@ -44,7 +44,8 @@ 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) =>
|
|
47
|
+
(amount, gasCost) =>
|
|
48
|
+
amount + BigInt(Number(gasCost.amount).toFixed(0)),
|
|
48
49
|
0n,
|
|
49
50
|
);
|
|
50
51
|
groupedGasCosts[token.chainId] = {
|
|
@@ -61,7 +62,8 @@ export const useGasSufficiency = (route?: RouteExtended) => {
|
|
|
61
62
|
if (nonIncludedFeeCosts?.length) {
|
|
62
63
|
const { token } = nonIncludedFeeCosts[0];
|
|
63
64
|
const feeCostAmount = nonIncludedFeeCosts.reduce(
|
|
64
|
-
(amount, feeCost) =>
|
|
65
|
+
(amount, feeCost) =>
|
|
66
|
+
amount + BigInt(Number(feeCost.amount).toFixed(0)),
|
|
65
67
|
0n,
|
|
66
68
|
);
|
|
67
69
|
groupedGasCosts[token.chainId] = {
|
|
@@ -193,6 +193,10 @@ export function getProcessMessage(
|
|
|
193
193
|
title = t(`error.title.transactionCanceled`);
|
|
194
194
|
message = getDefaultErrorMessage('error.message.transactionCanceled');
|
|
195
195
|
break;
|
|
196
|
+
case LiFiErrorCode.TransactionConflict:
|
|
197
|
+
title = t(`error.title.transactionConflict`);
|
|
198
|
+
message = getDefaultErrorMessage('error.message.transactionConflict');
|
|
199
|
+
break;
|
|
196
200
|
case LiFiErrorCode.ExchangeRateUpdateCanceled:
|
|
197
201
|
title = t(`error.title.exchangeRateUpdateCanceled`);
|
|
198
202
|
message = getDefaultErrorMessage();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import type { ExchangeRateUpdateParams, Route } from '@lifi/sdk';
|
|
3
3
|
import { executeRoute, resumeRoute, updateRouteExecution } from '@lifi/sdk';
|
|
4
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
4
5
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
5
6
|
import { useCallback, useEffect, useRef } from 'react';
|
|
6
7
|
import { shallow } from 'zustand/shallow';
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
isRouteFailed,
|
|
16
17
|
} from '../stores/routes/utils.js';
|
|
17
18
|
import { WidgetEvent } from '../types/events.js';
|
|
18
|
-
import { useAccount } from './useAccount.js';
|
|
19
19
|
import { useWidgetEvents } from './useWidgetEvents.js';
|
|
20
20
|
|
|
21
21
|
interface RouteExecutionProps {
|
package/hooks/useRoutes.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Route, RoutesResponse, Token } from '@lifi/sdk';
|
|
2
2
|
import { LiFiErrorCode, getContractCallsQuote, getRoutes } from '@lifi/sdk';
|
|
3
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
4
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
6
|
import { parseUnits } from 'viem';
|
|
@@ -10,7 +11,6 @@ import { useSettings } from '../stores/settings/useSettings.js';
|
|
|
10
11
|
import { defaultSlippage } from '../stores/settings/useSettingsStore.js';
|
|
11
12
|
import { WidgetEvent } from '../types/events.js';
|
|
12
13
|
import { getChainTypeFromAddress } from '../utils/chainType.js';
|
|
13
|
-
import { useAccount } from './useAccount.js';
|
|
14
14
|
import { useChain } from './useChain.js';
|
|
15
15
|
import { useDebouncedWatch } from './useDebouncedWatch.js';
|
|
16
16
|
import { useGasRefuel } from './useGasRefuel.js';
|
package/hooks/useTokenBalance.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ExtendedChain } from '@lifi/sdk';
|
|
2
2
|
import { getTokenBalances, type Token, type TokenAmount } from '@lifi/sdk';
|
|
3
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
4
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
5
|
import { useCallback, useMemo } from 'react';
|
|
5
|
-
import { useAccount } from './useAccount.js';
|
|
6
6
|
|
|
7
7
|
const defaultRefetchInterval = 30_000;
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getTokenBalances } from '@lifi/sdk';
|
|
2
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
2
3
|
import { useQuery } from '@tanstack/react-query';
|
|
3
4
|
import { formatUnits } from 'viem';
|
|
4
5
|
import type { TokenAmount } from '../types/token.js';
|
|
5
|
-
import { useAccount } from './useAccount.js';
|
|
6
6
|
import { useTokens } from './useTokens.js';
|
|
7
7
|
|
|
8
8
|
const defaultRefetchInterval = 32_000;
|
package/hooks/useTokens.ts
CHANGED
|
@@ -9,7 +9,8 @@ export const useTokens = (selectedChainId?: number) => {
|
|
|
9
9
|
const { tokens: configTokens } = useWidgetConfig();
|
|
10
10
|
const { data, isLoading } = useQuery({
|
|
11
11
|
queryKey: ['tokens'],
|
|
12
|
-
queryFn: () =>
|
|
12
|
+
queryFn: () =>
|
|
13
|
+
getTokens({ chainTypes: [ChainType.EVM, ChainType.SVM, ChainType.UTXO] }),
|
|
13
14
|
refetchInterval: 3_600_000,
|
|
14
15
|
staleTime: 3_600_000,
|
|
15
16
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { FullStatusData } from '@lifi/sdk';
|
|
2
2
|
import { getStatus, type StatusResponse } from '@lifi/sdk';
|
|
3
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
4
|
import {
|
|
4
5
|
keepPreviousData,
|
|
5
6
|
useQuery,
|
|
6
7
|
useQueryClient,
|
|
7
8
|
} from '@tanstack/react-query';
|
|
8
|
-
import { useAccount } from './useAccount.js';
|
|
9
9
|
|
|
10
10
|
export const useTransactionDetails = (transactionHash?: string) => {
|
|
11
11
|
const { account, accounts } = useAccount();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { FullStatusData, StatusResponse } from '@lifi/sdk';
|
|
2
2
|
import { getTransactionHistory, type ExtendedTransactionInfo } from '@lifi/sdk';
|
|
3
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
4
|
import type { QueryFunction } from '@tanstack/react-query';
|
|
4
5
|
import { useQueries } from '@tanstack/react-query';
|
|
5
|
-
import { useAccount } from './useAccount.js';
|
|
6
6
|
|
|
7
7
|
export const useTransactionHistory = () => {
|
|
8
8
|
const { accounts } = useAccount();
|
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",
|
|
20
19
|
"checkoutReview": "Review purchase",
|
|
21
20
|
"close": "Close",
|
|
22
21
|
"confirm": "Confirm",
|
|
22
|
+
"connectAnotherWallet": "Connect another wallet",
|
|
23
23
|
"connectWallet": "Connect wallet",
|
|
24
24
|
"contactSupport": "Contact support",
|
|
25
25
|
"continue": "Continue",
|
|
@@ -139,6 +139,7 @@
|
|
|
139
139
|
"signatureRejected": "Your signature is required to complete the transaction. {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
|
|
140
140
|
"slippageThreshold": "The slippage is larger than the defined threshold. Please request a new quote.",
|
|
141
141
|
"transactionCanceled": "Transaction was canceled.",
|
|
142
|
+
"transactionConflict": "Transaction couldn't be processed because it's conflicting with another pending transaction using the same funds. Please wait for the pending transaction to be confirmed or check your transaction history before trying again.",
|
|
142
143
|
"transactionExpired": "The block height has exceeded the maximum allowed limit or blockhash is no longer recent enough.",
|
|
143
144
|
"transactionFailed": "Please check the block explorer for more information.",
|
|
144
145
|
"transactionNotSent": "Transaction was not sent.",
|
|
@@ -158,6 +159,7 @@
|
|
|
158
159
|
"signatureRejected": "Signature required",
|
|
159
160
|
"slippageNotMet": "Slippage conditions not met",
|
|
160
161
|
"transactionCanceled": "Transaction canceled",
|
|
162
|
+
"transactionConflict": "Transaction conflict",
|
|
161
163
|
"transactionExpired": "Transaction expired",
|
|
162
164
|
"transactionFailed": "Transaction failed",
|
|
163
165
|
"transactionSimulationFailed": "Transaction simulation failed",
|
|
@@ -303,8 +305,5 @@
|
|
|
303
305
|
"noBookmarkedWallets": "No bookmarked wallets",
|
|
304
306
|
"noConnectedWallets": "No connected wallets",
|
|
305
307
|
"noRecentWallets": "No recent wallets"
|
|
306
|
-
},
|
|
307
|
-
"wallet": {
|
|
308
|
-
"extensionNotFound": "Please make sure that only the {{name}} browser extension is active before choosing this wallet."
|
|
309
308
|
}
|
|
310
309
|
}
|
package/index.ts
CHANGED
|
@@ -8,9 +8,7 @@ export * from './components/ContractComponent/NFT/types.js';
|
|
|
8
8
|
export * from './components/Skeleton/WidgetSkeleton.js';
|
|
9
9
|
export { defaultMaxHeight } from './config/constants.js';
|
|
10
10
|
export * from './config/version.js';
|
|
11
|
-
export { useAccount } from './hooks/useAccount.js';
|
|
12
11
|
export { useAvailableChains } from './hooks/useAvailableChains.js';
|
|
13
|
-
export { useWallets, walletComparator } from './hooks/useWallets.js';
|
|
14
12
|
export { useWidgetEvents, widgetEvents } from './hooks/useWidgetEvents.js';
|
|
15
13
|
export * from './stores/form/types.js';
|
|
16
14
|
export { useFieldActions } from './stores/form/useFieldActions.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0-beta.0",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./_esm/index.js",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@emotion/react": "^11.13.3",
|
|
36
36
|
"@emotion/styled": "^11.13.0",
|
|
37
|
-
"@lifi/sdk": "^3.
|
|
38
|
-
"@lifi/wallet-management": "^3.
|
|
37
|
+
"@lifi/sdk": "^3.3.0-beta.0",
|
|
38
|
+
"@lifi/wallet-management": "^3.3.0-beta.0",
|
|
39
39
|
"@mui/icons-material": "^5.16.7",
|
|
40
40
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
41
41
|
"@mui/material": "^5.16.7",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"react-intersection-observer": "^9.13.1",
|
|
54
54
|
"react-router-dom": "^6.26.2",
|
|
55
55
|
"uuid": "^10.0.0",
|
|
56
|
-
"viem": "^2.21.
|
|
57
|
-
"wagmi": "^2.12.
|
|
56
|
+
"viem": "^2.21.14",
|
|
57
|
+
"wagmi": "^2.12.14",
|
|
58
58
|
"zustand": "^4.5.5"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable react/no-array-index-key */
|
|
2
2
|
import type { Route } from '@lifi/sdk';
|
|
3
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
4
|
import type { BoxProps } from '@mui/material';
|
|
4
5
|
import { useMemo } from 'react';
|
|
5
6
|
import { useTranslation } from 'react-i18next';
|
|
@@ -7,7 +8,6 @@ import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate.js';
|
|
|
7
8
|
import { RouteCard } from '../../components/RouteCard/RouteCard.js';
|
|
8
9
|
import { RouteCardSkeleton } from '../../components/RouteCard/RouteCardSkeleton.js';
|
|
9
10
|
import { RouteNotFoundCard } from '../../components/RouteCard/RouteNotFoundCard.js';
|
|
10
|
-
import { useAccount } from '../../hooks/useAccount.js';
|
|
11
11
|
import { useHeader } from '../../hooks/useHeader.js';
|
|
12
12
|
import { useNavigateBack } from '../../hooks/useNavigateBack.js';
|
|
13
13
|
import { useRoutes } from '../../hooks/useRoutes.js';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Account } from '@lifi/wallet-management';
|
|
2
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
1
3
|
import {
|
|
2
4
|
ContentCopyRounded,
|
|
3
5
|
MoreHoriz,
|
|
@@ -12,8 +14,6 @@ import { AccountAvatar } from '../../components/Avatar/AccountAvatar.js';
|
|
|
12
14
|
import { ListItem } from '../../components/ListItem/ListItem.js';
|
|
13
15
|
import { ListItemButton } from '../../components/ListItem/ListItemButton.js';
|
|
14
16
|
import { Menu } from '../../components/Menu.js';
|
|
15
|
-
import type { Account } from '../../hooks/useAccount.js';
|
|
16
|
-
import { useAccount } from '../../hooks/useAccount.js';
|
|
17
17
|
import { useExplorer } from '../../hooks/useExplorer.js';
|
|
18
18
|
import { useHeader } from '../../hooks/useHeader.js';
|
|
19
19
|
import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
1
2
|
import { Error, History, TurnedIn, Wallet } from '@mui/icons-material';
|
|
2
3
|
import { Box, Tooltip, Typography } from '@mui/material';
|
|
3
4
|
import type { ChangeEvent } from 'react';
|
|
@@ -7,7 +8,6 @@ import { useNavigate } from 'react-router-dom';
|
|
|
7
8
|
import type { BottomSheetBase } from '../../components/BottomSheet/types.js';
|
|
8
9
|
import { ButtonTertiary } from '../../components/ButtonTertiary.js';
|
|
9
10
|
import { CardButton } from '../../components/Card/CardButton.js';
|
|
10
|
-
import { useAccount } from '../../hooks/useAccount.js';
|
|
11
11
|
import {
|
|
12
12
|
AddressType,
|
|
13
13
|
useAddressValidation,
|
|
@@ -12,14 +12,14 @@ export type LanguageResource = typeof languages.en;
|
|
|
12
12
|
|
|
13
13
|
export type LanguageResources =
|
|
14
14
|
| {
|
|
15
|
-
[
|
|
15
|
+
[K in LanguageKey]?: PartialResource<LanguageResource>;
|
|
16
16
|
}
|
|
17
17
|
| {
|
|
18
18
|
[language: string]: PartialResource<LanguageResource>;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export type LanguageTranslationResource = {
|
|
22
|
-
[
|
|
22
|
+
[N in 'translation']: PartialResource<LanguageResource>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type LanguageTranslationResources = {
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import type { SDKProvider } from '@lifi/sdk';
|
|
2
|
-
import { ChainType, EVM, Solana, config } from '@lifi/sdk';
|
|
2
|
+
import { ChainType, EVM, Solana, UTXO, config } from '@lifi/sdk';
|
|
3
|
+
import {
|
|
4
|
+
getConnectorClient as getBigmiConnectorClient,
|
|
5
|
+
useConfig as useBigmiConfig,
|
|
6
|
+
} from '@lifi/wallet-management';
|
|
3
7
|
import type { SignerWalletAdapter } from '@solana/wallet-adapter-base';
|
|
4
8
|
import { useWallet } from '@solana/wallet-adapter-react';
|
|
5
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
getConnectorClient as getWagmiConnectorClient,
|
|
11
|
+
switchChain,
|
|
12
|
+
} from '@wagmi/core';
|
|
6
13
|
import { useEffect } from 'react';
|
|
7
|
-
import { useConfig } from 'wagmi';
|
|
14
|
+
import { useConfig as useWagmiConfig } from 'wagmi';
|
|
8
15
|
import { useWidgetConfig } from '../WidgetProvider/WidgetProvider.js';
|
|
9
16
|
|
|
10
17
|
export const SDKProviders = () => {
|
|
11
18
|
const { sdkConfig } = useWidgetConfig();
|
|
12
19
|
const { wallet } = useWallet();
|
|
13
|
-
const wagmiConfig =
|
|
20
|
+
const wagmiConfig = useWagmiConfig();
|
|
21
|
+
const bigmiConfig = useBigmiConfig();
|
|
14
22
|
|
|
15
23
|
useEffect(() => {
|
|
16
24
|
// Configure SDK Providers
|
|
@@ -21,13 +29,16 @@ export const SDKProviders = () => {
|
|
|
21
29
|
const hasConfiguredSVMProvider = sdkConfig?.providers?.some(
|
|
22
30
|
(provider) => provider.type === ChainType.SVM,
|
|
23
31
|
);
|
|
32
|
+
const hasConfiguredUTXOProvider = sdkConfig?.providers?.some(
|
|
33
|
+
(provider) => provider.type === ChainType.UTXO,
|
|
34
|
+
);
|
|
24
35
|
if (!hasConfiguredEVMProvider) {
|
|
25
36
|
providers.push(
|
|
26
37
|
EVM({
|
|
27
|
-
getWalletClient: () =>
|
|
38
|
+
getWalletClient: () => getWagmiConnectorClient(wagmiConfig),
|
|
28
39
|
switchChain: async (chainId: number) => {
|
|
29
40
|
const chain = await switchChain(wagmiConfig, { chainId });
|
|
30
|
-
return
|
|
41
|
+
return getWagmiConnectorClient(wagmiConfig, { chainId: chain.id });
|
|
31
42
|
},
|
|
32
43
|
}),
|
|
33
44
|
);
|
|
@@ -41,11 +52,18 @@ export const SDKProviders = () => {
|
|
|
41
52
|
}),
|
|
42
53
|
);
|
|
43
54
|
}
|
|
55
|
+
if (!hasConfiguredUTXOProvider) {
|
|
56
|
+
providers.push(
|
|
57
|
+
UTXO({
|
|
58
|
+
getWalletClient: () => getBigmiConnectorClient(bigmiConfig),
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
61
|
+
}
|
|
44
62
|
if (sdkConfig?.providers?.length) {
|
|
45
63
|
providers.push(...sdkConfig?.providers);
|
|
46
64
|
}
|
|
47
65
|
config.setProviders(providers);
|
|
48
|
-
}, [sdkConfig?.providers, wagmiConfig, wallet?.adapter]);
|
|
66
|
+
}, [bigmiConfig, sdkConfig?.providers, wagmiConfig, wallet?.adapter]);
|
|
49
67
|
|
|
50
68
|
return null;
|
|
51
69
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DefaultWagmiConfigResult } from '@lifi/wallet-management';
|
|
2
|
+
import {
|
|
3
|
+
BigmiProvider,
|
|
4
|
+
createDefaultBigmiConfig,
|
|
5
|
+
useReconnect,
|
|
6
|
+
} from '@lifi/wallet-management';
|
|
7
|
+
import { useRef, type FC, type PropsWithChildren } from 'react';
|
|
8
|
+
|
|
9
|
+
export const UTXOBaseProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
10
|
+
const bigmi = useRef<DefaultWagmiConfigResult>();
|
|
11
|
+
|
|
12
|
+
if (!bigmi.current) {
|
|
13
|
+
bigmi.current = createDefaultBigmiConfig({
|
|
14
|
+
bigmiConfig: {
|
|
15
|
+
ssr: true,
|
|
16
|
+
multiInjectedProviderDiscovery: false,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
useReconnect(bigmi.current.config);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<BigmiProvider config={bigmi.current.config} reconnectOnMount={false}>
|
|
25
|
+
{children}
|
|
26
|
+
</BigmiProvider>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChainType } from '@lifi/sdk';
|
|
2
|
+
import { BigmiContext } from '@lifi/wallet-management';
|
|
3
|
+
import { useContext, type FC, type PropsWithChildren } from 'react';
|
|
4
|
+
import { isItemAllowed } from '../../utils/item.js';
|
|
5
|
+
import { useWidgetConfig } from '../WidgetProvider/WidgetProvider.js';
|
|
6
|
+
import { UTXOBaseProvider } from './UTXOBaseProvider.js';
|
|
7
|
+
import { UTXOExternalContext } from './UTXOExternalContext.js';
|
|
8
|
+
|
|
9
|
+
export function useInBigmiContext(): boolean {
|
|
10
|
+
const { chains } = useWidgetConfig();
|
|
11
|
+
const context = useContext(BigmiContext);
|
|
12
|
+
|
|
13
|
+
return Boolean(context) && isItemAllowed(ChainType.UTXO, chains?.types);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const UTXOProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
17
|
+
const inBigmiContext = useInBigmiContext();
|
|
18
|
+
|
|
19
|
+
return inBigmiContext ? (
|
|
20
|
+
<UTXOExternalContext.Provider value={inBigmiContext}>
|
|
21
|
+
{children}
|
|
22
|
+
</UTXOExternalContext.Provider>
|
|
23
|
+
) : (
|
|
24
|
+
<UTXOBaseProvider>{children}</UTXOBaseProvider>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -1,15 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { WalletManagementConfig } from '@lifi/wallet-management';
|
|
2
|
+
import { WalletManagementProvider } from '@lifi/wallet-management';
|
|
3
|
+
import { useMemo, type FC, type PropsWithChildren } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { useWidgetConfig } from '../WidgetProvider/WidgetProvider.js';
|
|
2
6
|
import { EVMProvider } from './EVMProvider.js';
|
|
3
7
|
import { SDKProviders } from './SDKProviders.js';
|
|
4
8
|
import { SVMProvider } from './SVMProvider.js';
|
|
9
|
+
import { UTXOProvider } from './UTXOProvider.js';
|
|
5
10
|
|
|
6
11
|
export const WalletProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
7
12
|
return (
|
|
8
13
|
<EVMProvider>
|
|
9
14
|
<SVMProvider>
|
|
10
|
-
<
|
|
11
|
-
|
|
15
|
+
<UTXOProvider>
|
|
16
|
+
<SDKProviders />
|
|
17
|
+
<WalletMenuProvider>{children}</WalletMenuProvider>
|
|
18
|
+
</UTXOProvider>
|
|
12
19
|
</SVMProvider>
|
|
13
20
|
</EVMProvider>
|
|
14
21
|
);
|
|
15
22
|
};
|
|
23
|
+
|
|
24
|
+
export const WalletMenuProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
25
|
+
const { walletConfig } = useWidgetConfig();
|
|
26
|
+
const { i18n } = useTranslation();
|
|
27
|
+
|
|
28
|
+
const config: WalletManagementConfig = useMemo(() => {
|
|
29
|
+
return { locale: i18n.resolvedLanguage as never, ...walletConfig };
|
|
30
|
+
}, [i18n.resolvedLanguage, walletConfig]);
|
|
31
|
+
return (
|
|
32
|
+
<WalletManagementProvider config={config}>
|
|
33
|
+
{children}
|
|
34
|
+
</WalletManagementProvider>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -2,29 +2,35 @@ import { ChainType } from '@lifi/sdk';
|
|
|
2
2
|
import { useContext, useMemo } from 'react';
|
|
3
3
|
import { EVMExternalContext } from './EVMExternalContext.js';
|
|
4
4
|
import { SVMExternalContext } from './SVMExternalContext.js';
|
|
5
|
+
import { UTXOExternalContext } from './UTXOExternalContext.js';
|
|
5
6
|
|
|
6
7
|
interface ExternalWalletProvider {
|
|
7
8
|
hasExternalProvider: boolean;
|
|
8
|
-
|
|
9
|
+
availableChainTypes: ChainType[];
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function useHasExternalWalletProvider(): ExternalWalletProvider {
|
|
12
13
|
const hasExternalEVMContext = useContext(EVMExternalContext);
|
|
13
14
|
const hasExternalSVMContext = useContext(SVMExternalContext);
|
|
15
|
+
const hasExternalUTXOContext = useContext(UTXOExternalContext);
|
|
14
16
|
|
|
15
17
|
const providers = useMemo(() => {
|
|
16
|
-
const providers = [];
|
|
18
|
+
const providers: ChainType[] = [];
|
|
17
19
|
if (hasExternalEVMContext) {
|
|
18
20
|
providers.push(ChainType.EVM);
|
|
19
21
|
}
|
|
20
22
|
if (hasExternalSVMContext) {
|
|
21
23
|
providers.push(ChainType.SVM);
|
|
22
24
|
}
|
|
25
|
+
if (hasExternalUTXOContext) {
|
|
26
|
+
providers.push(ChainType.UTXO);
|
|
27
|
+
}
|
|
23
28
|
return providers;
|
|
24
|
-
}, [hasExternalEVMContext, hasExternalSVMContext]);
|
|
29
|
+
}, [hasExternalEVMContext, hasExternalSVMContext, hasExternalUTXOContext]);
|
|
25
30
|
|
|
26
31
|
return {
|
|
27
|
-
hasExternalProvider:
|
|
28
|
-
|
|
32
|
+
hasExternalProvider:
|
|
33
|
+
hasExternalEVMContext || hasExternalSVMContext || hasExternalUTXOContext,
|
|
34
|
+
availableChainTypes: providers,
|
|
29
35
|
};
|
|
30
36
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
2
3
|
import { useEffect } from 'react';
|
|
3
|
-
import { useAccount } from '../../hooks/useAccount.js';
|
|
4
4
|
import { useChains } from '../../hooks/useChains.js';
|
|
5
5
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
6
6
|
import { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js';
|