@lifi/widget 3.5.1 → 3.6.0-alpha.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 (112) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/_esm/components/AppContainer.js +4 -7
  3. package/_esm/components/AppContainer.js.map +1 -1
  4. package/_esm/components/FeeBreakdownTooltip.js +4 -1
  5. package/_esm/components/FeeBreakdownTooltip.js.map +1 -1
  6. package/_esm/components/Header/EVMDisconnectIconButton.js +5 -4
  7. package/_esm/components/Header/EVMDisconnectIconButton.js.map +1 -1
  8. package/_esm/components/Header/Header.d.ts +0 -2
  9. package/_esm/components/Header/Header.js +2 -7
  10. package/_esm/components/Header/Header.js.map +1 -1
  11. package/_esm/components/Header/UTXODisconnectIconButton.d.ts +4 -0
  12. package/_esm/components/Header/UTXODisconnectIconButton.js +13 -0
  13. package/_esm/components/Header/UTXODisconnectIconButton.js.map +1 -0
  14. package/_esm/components/Header/WalletMenu.js +5 -6
  15. package/_esm/components/Header/WalletMenu.js.map +1 -1
  16. package/_esm/components/Header/WalletMenu.style.js +5 -1
  17. package/_esm/components/Header/WalletMenu.style.js.map +1 -1
  18. package/_esm/components/TokenList/TokenListItem.js +11 -5
  19. package/_esm/components/TokenList/TokenListItem.js.map +1 -1
  20. package/_esm/components/TokenList/VirtualizedTokenList.js +1 -1
  21. package/_esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
  22. package/_esm/components/TokenList/types.d.ts +2 -2
  23. package/_esm/config/version.d.ts +1 -1
  24. package/_esm/config/version.js +1 -1
  25. package/_esm/config/version.js.map +1 -1
  26. package/_esm/hooks/useAccount.d.ts +8 -14
  27. package/_esm/hooks/useAccount.js +11 -6
  28. package/_esm/hooks/useAccount.js.map +1 -1
  29. package/_esm/hooks/useAvailableChains.d.ts +2 -1
  30. package/_esm/hooks/useAvailableChains.js +9 -8
  31. package/_esm/hooks/useAvailableChains.js.map +1 -1
  32. package/_esm/hooks/useGasSufficiency.js +2 -2
  33. package/_esm/hooks/useGasSufficiency.js.map +1 -1
  34. package/_esm/hooks/useHeaderHeight.d.ts +6 -0
  35. package/_esm/hooks/useHeaderHeight.js +16 -0
  36. package/_esm/hooks/useHeaderHeight.js.map +1 -0
  37. package/_esm/hooks/useTokens.js +1 -1
  38. package/_esm/hooks/useTokens.js.map +1 -1
  39. package/_esm/hooks/useWallets.js +36 -15
  40. package/_esm/hooks/useWallets.js.map +1 -1
  41. package/_esm/i18n/en.json +1 -1
  42. package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +1 -2
  43. package/_esm/pages/SelectWalletPage/EVMListItemButton.js +12 -14
  44. package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +1 -1
  45. package/_esm/pages/SelectWalletPage/SelectWalletPage.js +3 -3
  46. package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +1 -1
  47. package/_esm/pages/SelectWalletPage/UTXOListItemButton.d.ts +8 -0
  48. package/_esm/pages/SelectWalletPage/UTXOListItemButton.js +36 -0
  49. package/_esm/pages/SelectWalletPage/UTXOListItemButton.js.map +1 -0
  50. package/_esm/providers/I18nProvider/types.d.ts +2 -2
  51. package/_esm/providers/WalletProvider/SDKProviders.js +15 -7
  52. package/_esm/providers/WalletProvider/SDKProviders.js.map +1 -1
  53. package/_esm/providers/WalletProvider/UTXOBaseProvider.d.ts +2 -0
  54. package/_esm/providers/WalletProvider/UTXOBaseProvider.js +17 -0
  55. package/_esm/providers/WalletProvider/UTXOBaseProvider.js.map +1 -0
  56. package/_esm/providers/WalletProvider/UTXOExternalContext.d.ts +1 -0
  57. package/_esm/providers/WalletProvider/UTXOExternalContext.js +3 -0
  58. package/_esm/providers/WalletProvider/UTXOExternalContext.js.map +1 -0
  59. package/_esm/providers/WalletProvider/UTXOProvider.d.ts +3 -0
  60. package/_esm/providers/WalletProvider/UTXOProvider.js +18 -0
  61. package/_esm/providers/WalletProvider/UTXOProvider.js.map +1 -0
  62. package/_esm/providers/WalletProvider/WalletProvider.js +2 -1
  63. package/_esm/providers/WalletProvider/WalletProvider.js.map +1 -1
  64. package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js +6 -1
  65. package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js.map +1 -1
  66. package/_esm/providers/WidgetProvider/WidgetProvider.js +1 -1
  67. package/_esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
  68. package/_esm/stores/form/types.d.ts +4 -4
  69. package/_esm/themes/createTheme.js +2 -1
  70. package/_esm/themes/createTheme.js.map +1 -1
  71. package/_esm/utils/chainType.js +2 -3
  72. package/_esm/utils/chainType.js.map +1 -1
  73. package/_esm/utils/fees.js +9 -5
  74. package/_esm/utils/fees.js.map +1 -1
  75. package/components/AppContainer.tsx +4 -11
  76. package/components/FeeBreakdownTooltip.tsx +4 -1
  77. package/components/Header/EVMDisconnectIconButton.tsx +5 -5
  78. package/components/Header/Header.tsx +2 -9
  79. package/components/Header/UTXODisconnectIconButton.tsx +24 -0
  80. package/components/Header/WalletMenu.style.tsx +5 -1
  81. package/components/Header/WalletMenu.tsx +6 -5
  82. package/components/TokenList/TokenListItem.tsx +15 -7
  83. package/components/TokenList/VirtualizedTokenList.tsx +1 -1
  84. package/components/TokenList/types.ts +2 -2
  85. package/config/version.ts +1 -1
  86. package/hooks/useAccount.ts +21 -23
  87. package/hooks/useAvailableChains.ts +9 -10
  88. package/hooks/useGasSufficiency.ts +4 -2
  89. package/hooks/useHeaderHeight.ts +20 -0
  90. package/hooks/useTokens.ts +2 -1
  91. package/hooks/useWallets.ts +41 -20
  92. package/i18n/en.json +1 -1
  93. package/package.json +5 -5
  94. package/pages/SelectWalletPage/EVMListItemButton.tsx +12 -19
  95. package/pages/SelectWalletPage/SelectWalletPage.tsx +9 -4
  96. package/pages/SelectWalletPage/UTXOListItemButton.tsx +67 -0
  97. package/providers/I18nProvider/types.ts +2 -2
  98. package/providers/WalletProvider/SDKProviders.tsx +25 -7
  99. package/providers/WalletProvider/UTXOBaseProvider.tsx +28 -0
  100. package/providers/WalletProvider/UTXOExternalContext.ts +3 -0
  101. package/providers/WalletProvider/UTXOProvider.tsx +26 -0
  102. package/providers/WalletProvider/WalletProvider.tsx +5 -2
  103. package/providers/WalletProvider/useHasExternalWalletProvider.ts +6 -1
  104. package/providers/WidgetProvider/WidgetProvider.tsx +1 -1
  105. package/stores/form/types.ts +4 -4
  106. package/themes/createTheme.ts +3 -1
  107. package/utils/chainType.ts +2 -3
  108. package/utils/fees.ts +15 -13
  109. package/_esm/utils/svm.d.ts +0 -1
  110. package/_esm/utils/svm.js +0 -11
  111. package/_esm/utils/svm.js.map +0 -1
  112. package/utils/svm.ts +0 -10
@@ -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: () => getTokens({ chainTypes: [ChainType.EVM, ChainType.SVM] }),
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
  });
@@ -6,6 +6,7 @@ import {
6
6
  createWalletConnectConnector,
7
7
  getWalletPriority,
8
8
  isWalletInstalled,
9
+ useConfig as useBigmiConfig,
9
10
  } from '@lifi/wallet-management';
10
11
  import type { Theme } from '@mui/material';
11
12
  import { useMediaQuery } from '@mui/material';
@@ -14,7 +15,7 @@ import type { Wallet } from '@solana/wallet-adapter-react';
14
15
  import { useWallet } from '@solana/wallet-adapter-react';
15
16
  import { useMemo } from 'react';
16
17
  import type { Connector } from 'wagmi';
17
- import { useConnect, useAccount as useWagmiAccount } from 'wagmi';
18
+ import { useAccount, useConnect } from 'wagmi';
18
19
  import { defaultCoinbaseConfig } from '../config/coinbase.js';
19
20
  import { defaultMetaMaskConfig } from '../config/metaMask.js';
20
21
  import { defaultWalletConnectConfig } from '../config/walletConnect.js';
@@ -25,8 +26,11 @@ export const useWallets = (
25
26
  walletConfig?: WidgetWalletConfig,
26
27
  chains?: WidgetChains,
27
28
  ) => {
28
- const account = useWagmiAccount();
29
- const { connectors } = useConnect();
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 });
30
34
  const { wallets: solanaWallets } = useWallet();
31
35
 
32
36
  const isDesktopView = useMediaQuery((theme: Theme) =>
@@ -35,9 +39,9 @@ export const useWallets = (
35
39
 
36
40
  const wallets = useMemo(() => {
37
41
  const evmConnectors: (CreateConnectorFnExtended | Connector)[] =
38
- Array.from(connectors);
42
+ Array.from(wagmiConnectors);
39
43
  if (
40
- !connectors.some((connector) =>
44
+ !wagmiConnectors.some((connector) =>
41
45
  connector.id.toLowerCase().includes('walletconnect'),
42
46
  )
43
47
  ) {
@@ -48,7 +52,7 @@ export const useWallets = (
48
52
  );
49
53
  }
50
54
  if (
51
- !connectors.some((connector) =>
55
+ !wagmiConnectors.some((connector) =>
52
56
  connector.id.toLowerCase().includes('coinbase'),
53
57
  ) &&
54
58
  !isWalletInstalled('coinbase')
@@ -60,7 +64,7 @@ export const useWallets = (
60
64
  );
61
65
  }
62
66
  if (
63
- !connectors.some((connector) =>
67
+ !wagmiConnectors.some((connector) =>
64
68
  connector.id.toLowerCase().includes('metamask'),
65
69
  ) &&
66
70
  !isWalletInstalled('metaMask')
@@ -71,16 +75,27 @@ export const useWallets = (
71
75
  ),
72
76
  );
73
77
  }
78
+ const utxoInstalled = isItemAllowed(ChainType.UTXO, chains?.types)
79
+ ? bigmiConnectors.filter(
80
+ (connector) =>
81
+ isWalletInstalled(connector.id) &&
82
+ // We should not show already connected connectors
83
+ bigmiAccount.connector?.id !== connector.id,
84
+ )
85
+ : [];
86
+ const utxoNotDetected = isItemAllowed(ChainType.UTXO, chains?.types)
87
+ ? bigmiConnectors.filter((connector) => !isWalletInstalled(connector.id!))
88
+ : [];
74
89
  const evmInstalled = isItemAllowed(ChainType.EVM, chains?.types)
75
90
  ? evmConnectors.filter(
76
91
  (connector) =>
77
- isWalletInstalled(connector.id!) &&
92
+ isWalletInstalled(connector.id) &&
78
93
  // We should not show already connected connectors
79
- account.connector?.id !== connector.id,
94
+ wagmiAccount.connector?.id !== connector.id,
80
95
  )
81
96
  : [];
82
97
  const evmNotDetected = isItemAllowed(ChainType.EVM, chains?.types)
83
- ? evmConnectors.filter((connector) => !isWalletInstalled(connector.id!))
98
+ ? evmConnectors.filter((connector) => !isWalletInstalled(connector.id))
84
99
  : [];
85
100
  const svmInstalled = isItemAllowed(ChainType.SVM, chains?.types)
86
101
  ? solanaWallets?.filter(
@@ -97,27 +112,33 @@ export const useWallets = (
97
112
  )
98
113
  : [];
99
114
 
100
- const installedWallets = [...evmInstalled, ...svmInstalled].sort(
101
- walletComparator,
102
- );
115
+ const installedWallets = [
116
+ ...evmInstalled,
117
+ ...svmInstalled,
118
+ ...utxoInstalled,
119
+ ].sort(walletComparator);
103
120
 
104
121
  if (isDesktopView) {
105
- const notDetectedWallets = [...evmNotDetected, ...svmNotDetected].sort(
106
- walletComparator,
107
- );
122
+ const notDetectedWallets = [
123
+ ...evmNotDetected,
124
+ ...svmNotDetected,
125
+ ...utxoNotDetected,
126
+ ].sort(walletComparator);
108
127
  installedWallets.push(...notDetectedWallets);
109
128
  }
110
129
 
111
130
  return installedWallets;
112
131
  }, [
113
- account.connector?.id,
132
+ wagmiConnectors,
114
133
  chains?.types,
115
- connectors,
116
- isDesktopView,
134
+ bigmiConnectors,
117
135
  solanaWallets,
136
+ isDesktopView,
137
+ walletConfig?.walletConnect,
118
138
  walletConfig?.coinbase,
119
139
  walletConfig?.metaMask,
120
- walletConfig?.walletConnect,
140
+ bigmiAccount.connector?.id,
141
+ wagmiAccount.connector?.id,
121
142
  ]);
122
143
 
123
144
  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",
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "3.5.1",
3
+ "version": "3.6.0-alpha.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.2.0",
38
- "@lifi/wallet-management": "^3.1.4",
37
+ "@lifi/sdk": "^3.3.0-alpha.1",
38
+ "@lifi/wallet-management": "^3.2.0-alpha.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.4",
57
- "wagmi": "^2.12.9",
56
+ "viem": "^2.21.5",
57
+ "wagmi": "^2.12.10",
58
58
  "zustand": "^4.5.5"
59
59
  },
60
60
  "peerDependencies": {
@@ -6,7 +6,8 @@ import {
6
6
  } from '@lifi/wallet-management';
7
7
  import { Avatar, ListItemAvatar } from '@mui/material';
8
8
  import type { Connector } from 'wagmi';
9
- import { useConnect, useDisconnect } from 'wagmi';
9
+ import { useConfig } from 'wagmi';
10
+ import { connect, disconnect, getAccount } from 'wagmi/actions';
10
11
  import { ListItemButton } from '../../components/ListItemButton.js';
11
12
  import { ListItemText } from '../../components/ListItemText.js';
12
13
  import { useNavigateBack } from '../../hooks/useNavigateBack.js';
@@ -14,20 +15,17 @@ import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
14
15
  import { WidgetEvent } from '../../types/events.js';
15
16
 
16
17
  interface EVMListItemButtonProps {
17
- connectedConnector?: Connector;
18
18
  connector: CreateConnectorFnExtended | Connector;
19
19
  onNotInstalled(connector: Connector): void;
20
20
  }
21
21
 
22
22
  export const EVMListItemButton = ({
23
- connectedConnector,
24
23
  connector,
25
24
  onNotInstalled,
26
25
  }: EVMListItemButtonProps) => {
27
26
  const { navigateBack } = useNavigateBack();
28
27
  const emitter = useWidgetEvents();
29
- const { connectAsync } = useConnect();
30
- const { disconnectAsync } = useDisconnect();
28
+ const config = useConfig();
31
29
 
32
30
  const handleEVMConnect = async () => {
33
31
  const identityCheckPassed = await isWalletInstalledAsync(
@@ -37,21 +35,16 @@ export const EVMListItemButton = ({
37
35
  onNotInstalled(connector as Connector);
38
36
  return;
39
37
  }
40
- if (connectedConnector) {
41
- await disconnectAsync({ connector: connectedConnector });
38
+ const connectedAccount = getAccount(config);
39
+ if (connectedAccount.connector) {
40
+ await disconnect(config, { connector: connectedAccount.connector });
42
41
  }
43
- await connectAsync(
44
- { connector },
45
- {
46
- onSuccess(data) {
47
- emitter.emit(WidgetEvent.WalletConnected, {
48
- address: data.accounts[0],
49
- chainId: data.chainId,
50
- chainType: ChainType.EVM,
51
- });
52
- },
53
- },
54
- );
42
+ const data = await connect(config, { connector });
43
+ emitter.emit(WidgetEvent.WalletConnected, {
44
+ address: data.accounts[0],
45
+ chainId: data.chainId,
46
+ chainType: ChainType.EVM,
47
+ });
55
48
  navigateBack();
56
49
  };
57
50
 
@@ -1,3 +1,4 @@
1
+ import { ChainType } from '@lifi/sdk';
1
2
  import {
2
3
  Button,
3
4
  DialogActions,
@@ -9,7 +10,6 @@ import type { Wallet } from '@solana/wallet-adapter-react';
9
10
  import { useCallback, useState } from 'react';
10
11
  import { useTranslation } from 'react-i18next';
11
12
  import type { Connector } from 'wagmi';
12
- import { useAccount as useWagmiAccount } from 'wagmi';
13
13
  import { Dialog } from '../../components/Dialog.js';
14
14
  import { PageContainer } from '../../components/PageContainer.js';
15
15
  import { useHeader } from '../../hooks/useHeader.js';
@@ -17,11 +17,11 @@ import { useWallets } from '../../hooks/useWallets.js';
17
17
  import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
18
18
  import { EVMListItemButton } from './EVMListItemButton.js';
19
19
  import { SVMListItemButton } from './SVMListItemButton.js';
20
+ import { UTXOListItemButton } from './UTXOListItemButton.js';
20
21
 
21
22
  export const SelectWalletPage = () => {
22
23
  const { t } = useTranslation();
23
24
  const { chains, walletConfig } = useWidgetConfig();
24
- const account = useWagmiAccount();
25
25
  const [walletIdentity, setWalletIdentity] = useState<{
26
26
  show: boolean;
27
27
  connector?: Connector;
@@ -56,11 +56,16 @@ export const SelectWalletPage = () => {
56
56
  }}
57
57
  >
58
58
  {wallets?.map((connector) =>
59
- (connector as Connector).id ? (
59
+ (connector as Connector).type === ChainType.UTXO ? (
60
+ <UTXOListItemButton
61
+ key={(connector as Connector).id}
62
+ connector={connector as Connector}
63
+ onNotInstalled={handleNotInstalled}
64
+ />
65
+ ) : (connector as Connector).id ? (
60
66
  <EVMListItemButton
61
67
  key={(connector as Connector).id}
62
68
  connector={connector as Connector}
63
- connectedConnector={account.connector}
64
69
  onNotInstalled={handleNotInstalled}
65
70
  />
66
71
  ) : (
@@ -0,0 +1,67 @@
1
+ import { ChainType } from '@lifi/sdk';
2
+ import type { CreateConnectorFnExtended } from '@lifi/wallet-management';
3
+ import {
4
+ getConnectorIcon,
5
+ isWalletInstalledAsync,
6
+ useConfig,
7
+ } from '@lifi/wallet-management';
8
+ import { Avatar, ListItemAvatar } from '@mui/material';
9
+ import type { Connector } from 'wagmi';
10
+ import { connect, disconnect, getAccount } from 'wagmi/actions';
11
+ import { ListItemButton } from '../../components/ListItemButton.js';
12
+ import { ListItemText } from '../../components/ListItemText.js';
13
+ import { useNavigateBack } from '../../hooks/useNavigateBack.js';
14
+ import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
15
+ import { WidgetEvent } from '../../types/events.js';
16
+
17
+ interface UTXOListItemButtonProps {
18
+ connector: CreateConnectorFnExtended | Connector;
19
+ onNotInstalled(connector: Connector): void;
20
+ }
21
+
22
+ export const UTXOListItemButton = ({
23
+ connector,
24
+ onNotInstalled,
25
+ }: UTXOListItemButtonProps) => {
26
+ const { navigateBack } = useNavigateBack();
27
+ const emitter = useWidgetEvents();
28
+ const config = useConfig();
29
+
30
+ const handleUTXOConnect = async () => {
31
+ const identityCheckPassed = await isWalletInstalledAsync(
32
+ (connector as Connector).id,
33
+ );
34
+ if (!identityCheckPassed) {
35
+ onNotInstalled(connector as Connector);
36
+ return;
37
+ }
38
+ const connectedAccount = getAccount(config);
39
+ if (connectedAccount.connector) {
40
+ await disconnect(config, { connector: connectedAccount.connector });
41
+ }
42
+ const data = await connect(config, { connector });
43
+ emitter.emit(WidgetEvent.WalletConnected, {
44
+ address: data.accounts[0],
45
+ chainId: data.chainId,
46
+ chainType: ChainType.UTXO,
47
+ });
48
+ navigateBack();
49
+ };
50
+
51
+ const connectorName: string =
52
+ (connector as CreateConnectorFnExtended).displayName || connector.name;
53
+
54
+ return (
55
+ <ListItemButton key={connector.id} onClick={handleUTXOConnect}>
56
+ <ListItemAvatar>
57
+ <Avatar
58
+ src={getConnectorIcon(connector as Connector)}
59
+ alt={connectorName}
60
+ >
61
+ {connectorName?.[0]}
62
+ </Avatar>
63
+ </ListItemAvatar>
64
+ <ListItemText primary={`${connectorName} (Bitcoin)`} />
65
+ </ListItemButton>
66
+ );
67
+ };
@@ -12,14 +12,14 @@ export type LanguageResource = typeof languages.en;
12
12
 
13
13
  export type LanguageResources =
14
14
  | {
15
- [language in LanguageKey]?: PartialResource<LanguageResource>;
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
- [namespace in 'translation']: PartialResource<LanguageResource>;
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 { getWalletClient, switchChain } from '@wagmi/core';
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 = useConfig();
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: () => getWalletClient(wagmiConfig),
38
+ getWalletClient: () => getWagmiConnectorClient(wagmiConfig),
28
39
  switchChain: async (chainId: number) => {
29
40
  const chain = await switchChain(wagmiConfig, { chainId });
30
- return getWalletClient(wagmiConfig, { chainId: chain.id });
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
+ wagmiConfig: {
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,3 @@
1
+ import { createContext } from 'react';
2
+
3
+ export const UTXOExternalContext = createContext<boolean>(false);
@@ -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
+ };
@@ -2,13 +2,16 @@ import { type FC, type PropsWithChildren } from 'react';
2
2
  import { EVMProvider } from './EVMProvider.js';
3
3
  import { SDKProviders } from './SDKProviders.js';
4
4
  import { SVMProvider } from './SVMProvider.js';
5
+ import { UTXOProvider } from './UTXOProvider.js';
5
6
 
6
7
  export const WalletProvider: FC<PropsWithChildren> = ({ children }) => {
7
8
  return (
8
9
  <EVMProvider>
9
10
  <SVMProvider>
10
- <SDKProviders />
11
- {children}
11
+ <UTXOProvider>
12
+ <SDKProviders />
13
+ {children}
14
+ </UTXOProvider>
12
15
  </SVMProvider>
13
16
  </EVMProvider>
14
17
  );
@@ -2,6 +2,7 @@ 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;
@@ -11,6 +12,7 @@ interface ExternalWalletProvider {
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
18
  const providers = [];
@@ -20,8 +22,11 @@ export function useHasExternalWalletProvider(): ExternalWalletProvider {
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
32
  hasExternalProvider: hasExternalEVMContext || hasExternalSVMContext,
@@ -88,7 +88,7 @@ export const WidgetProvider: React.FC<
88
88
  },
89
89
  disableVersionCheck: true,
90
90
  widgetVersion: version,
91
- preloadChains: false,
91
+ // preloadChains: false,
92
92
  };
93
93
  if (!sdkInitialized) {
94
94
  createConfig(_config);
@@ -32,17 +32,17 @@ export type FormFieldArray<T extends FormFieldNames[]> = {
32
32
  [K in keyof T]: ExtractValueType<FormValues[T[K]]>;
33
33
  };
34
34
 
35
- export type TouchedFields = { [key in FormFieldNames]?: boolean };
35
+ export type TouchedFields = { [K in FormFieldNames]?: boolean };
36
36
 
37
37
  type ValidationFn = (value: any) => Promise<boolean | string>;
38
38
  export interface ValidationProps {
39
39
  isValid: boolean;
40
40
  isValidating: boolean;
41
41
  errors: {
42
- [key in FormFieldNames]?: string;
42
+ [K in FormFieldNames]?: string;
43
43
  };
44
44
  validation: {
45
- [key in FormFieldNames]?: ValidationFn;
45
+ [K in FormFieldNames]?: ValidationFn;
46
46
  };
47
47
  }
48
48
 
@@ -58,7 +58,7 @@ export interface ValidationActions {
58
58
  export interface FormProps {
59
59
  defaultValues: FormValues;
60
60
  userValues: FormValues;
61
- touchedFields: { [key in FormFieldNames]?: boolean };
61
+ touchedFields: { [K in FormFieldNames]?: boolean };
62
62
  }
63
63
 
64
64
  interface ResetOptions {
@@ -63,7 +63,7 @@ export const createTheme = (
63
63
  const borderRadiusSecondary =
64
64
  widgetTheme.shape?.borderRadiusSecondary ?? shape.borderRadiusSecondary;
65
65
 
66
- return createMuiTheme({
66
+ const theme = createMuiTheme({
67
67
  container: widgetTheme.container,
68
68
  header: widgetTheme.header,
69
69
  navigation: {
@@ -409,4 +409,6 @@ export const createTheme = (
409
409
  },
410
410
  },
411
411
  });
412
+
413
+ return theme;
412
414
  };
@@ -1,11 +1,10 @@
1
- import { ChainId, ChainType } from '@lifi/sdk';
1
+ import { ChainId, ChainType, isSVMAddress, isUTXOAddress } from '@lifi/sdk';
2
2
  import { isAddress as isEVMAddress } from 'viem';
3
- import { isSVMAddress } from './svm.js';
4
3
 
5
4
  const chainTypeAddressValidation = {
6
5
  [ChainType.EVM]: isEVMAddress,
7
6
  [ChainType.SVM]: isSVMAddress,
8
- [ChainType.UTXO]: () => false,
7
+ [ChainType.UTXO]: isUTXOAddress,
9
8
  };
10
9
 
11
10
  export const getChainTypeFromAddress = (
package/utils/fees.ts CHANGED
@@ -104,20 +104,22 @@ export const getFeeCostsBreakdown = (
104
104
  export const getStepFeeCostsBreakdown = (
105
105
  feeCosts: FeeCost[] | GasCost[],
106
106
  ): FeesBreakdown => {
107
- const token = feeCosts[0].token;
108
- const amount = feeCosts.reduce(
109
- (amount, feeCost) => amount + BigInt(feeCost.amount || 0),
110
- 0n,
111
- );
112
- const amountUSD = feeCosts.reduce(
113
- (amount, feeCost) =>
114
- amount +
115
- parseFloat(feeCost.token.priceUSD || '0') *
116
- parseFloat(
117
- formatUnits(BigInt(feeCost.amount || 0), feeCost.token.decimals),
118
- ),
119
- 0,
107
+ const { token } = feeCosts[0];
108
+
109
+ const { amount, amountUSD } = feeCosts.reduce(
110
+ (acc, feeCost) => {
111
+ const feeAmount = BigInt(Number(feeCost.amount).toFixed(0) || 0);
112
+ const amountUSD =
113
+ parseFloat(feeCost.token.priceUSD || '0') *
114
+ parseFloat(formatUnits(feeAmount, feeCost.token.decimals));
115
+
116
+ acc.amount += feeAmount;
117
+ acc.amountUSD += amountUSD;
118
+ return acc;
119
+ },
120
+ { amount: 0n, amountUSD: 0 },
120
121
  );
122
+
121
123
  return {
122
124
  amount,
123
125
  amountUSD,
@@ -1 +0,0 @@
1
- export declare const isSVMAddress: (address: string) => boolean;