@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.
- package/App.tsx +3 -3
- package/AppProvider.tsx +2 -1
- package/CHANGELOG.md +16 -0
- package/_esm/App.d.ts +1 -1
- package/_esm/App.js +3 -3
- package/_esm/App.js.map +1 -1
- package/_esm/AppProvider.js +2 -2
- package/_esm/AppProvider.js.map +1 -1
- package/_esm/components/Card/InputCard.d.ts +1 -1
- package/_esm/components/ChainSelect/useChainSelect.js +1 -5
- package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/_esm/components/FeeBreakdownTooltip.js +1 -4
- package/_esm/components/FeeBreakdownTooltip.js.map +1 -1
- package/_esm/components/Header/EVMDisconnectIconButton.js +4 -5
- package/_esm/components/Header/EVMDisconnectIconButton.js.map +1 -1
- package/_esm/components/Header/Header.style.d.ts +0 -3
- package/_esm/components/Header/Header.style.js +0 -5
- package/_esm/components/Header/Header.style.js.map +1 -1
- package/_esm/components/Header/WalletMenu.js +6 -5
- package/_esm/components/Header/WalletMenu.js.map +1 -1
- package/_esm/components/Header/WalletMenu.style.js +1 -5
- package/_esm/components/Header/WalletMenu.style.js.map +1 -1
- package/_esm/components/SendToWallet/SendToWalletButton.js +16 -6
- package/_esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/_esm/components/SendToWallet/SendToWalletExpandButton.js +8 -6
- package/_esm/components/SendToWallet/SendToWalletExpandButton.js.map +1 -1
- package/_esm/components/Skeleton/WidgetSkeleton.style.d.ts +1 -1
- package/_esm/components/Step/StepProcess.js +9 -1
- package/_esm/components/Step/StepProcess.js.map +1 -1
- package/_esm/components/TokenList/TokenListItem.js +5 -11
- 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 +2 -2
- package/_esm/components/TokenRate/TokenRate.js +2 -2
- package/_esm/components/TokenRate/TokenRate.js.map +1 -1
- package/_esm/components/TransactionDetails.js +2 -1
- package/_esm/components/TransactionDetails.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/useAccount.d.ts +15 -15
- package/_esm/hooks/useAccount.js +13 -50
- package/_esm/hooks/useAccount.js.map +1 -1
- package/_esm/hooks/useAvailableChains.d.ts +1 -2
- package/_esm/hooks/useAvailableChains.js +8 -9
- package/_esm/hooks/useAvailableChains.js.map +1 -1
- package/_esm/hooks/useChains.d.ts +3 -4
- package/_esm/hooks/useChains.js +3 -5
- package/_esm/hooks/useChains.js.map +1 -1
- package/_esm/hooks/useExplorer.d.ts +10 -1
- package/_esm/hooks/useExplorer.js +4 -1
- package/_esm/hooks/useExplorer.js.map +1 -1
- package/_esm/hooks/useGasSufficiency.js +2 -2
- package/_esm/hooks/useGasSufficiency.js.map +1 -1
- package/_esm/hooks/useHeaderHeight.js +8 -1
- package/_esm/hooks/useHeaderHeight.js.map +1 -1
- package/_esm/hooks/useTokens.js +1 -1
- package/_esm/hooks/useTokens.js.map +1 -1
- package/_esm/hooks/useWallets.d.ts +1 -1
- package/_esm/hooks/useWallets.js +15 -36
- package/_esm/hooks/useWallets.js.map +1 -1
- package/_esm/i18n/en.json +1 -1
- package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +2 -1
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js +14 -15
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +1 -1
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js +0 -3
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js.map +1 -1
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js +3 -3
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.style.d.ts +1 -1
- package/_esm/pages/TransactionDetailsPage/TransferIdCard.js +1 -1
- package/_esm/pages/TransactionDetailsPage/TransferIdCard.js.map +1 -1
- package/_esm/pages/TransactionPage/StatusBottomSheet.js +3 -2
- package/_esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
- package/_esm/providers/I18nProvider/types.d.ts +2 -2
- package/_esm/providers/WalletProvider/SDKProviders.js +7 -15
- package/_esm/providers/WalletProvider/SDKProviders.js.map +1 -1
- package/_esm/providers/WalletProvider/WalletProvider.js +1 -2
- package/_esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.d.ts +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js +3 -8
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.js +1 -31
- package/_esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/_esm/stores/StoreProvider.js +2 -2
- package/_esm/stores/StoreProvider.js.map +1 -1
- package/_esm/stores/form/FormStore.d.ts +6 -1
- package/_esm/stores/form/FormStore.js +69 -18
- package/_esm/stores/form/FormStore.js.map +1 -1
- package/_esm/stores/form/FormUpdater.d.ts +1 -1
- package/_esm/stores/form/FormUpdater.js +36 -18
- package/_esm/stores/form/FormUpdater.js.map +1 -1
- package/_esm/stores/form/URLSearchParamsBuilder.js +44 -4
- package/_esm/stores/form/URLSearchParamsBuilder.js.map +1 -1
- package/_esm/stores/form/createFormStore.js +9 -0
- package/_esm/stores/form/createFormStore.js.map +1 -1
- package/_esm/stores/form/types.d.ts +13 -10
- package/_esm/stores/form/types.js.map +1 -1
- package/_esm/stores/form/useFieldActions.js +1 -0
- package/_esm/stores/form/useFieldActions.js.map +1 -1
- package/_esm/stores/form/useFormRef.d.ts +3 -0
- package/_esm/stores/form/useFormRef.js +51 -0
- package/_esm/stores/form/useFormRef.js.map +1 -0
- package/_esm/stores/form/useTouchedFields.d.ts +6 -6
- package/_esm/stores/settings/types.d.ts +0 -2
- package/_esm/stores/settings/useSendToWalletStore.d.ts +0 -1
- package/_esm/stores/settings/useSendToWalletStore.js +0 -7
- package/_esm/stores/settings/useSendToWalletStore.js.map +1 -1
- package/_esm/themes/createTheme.js +1 -2
- package/_esm/themes/createTheme.js.map +1 -1
- package/_esm/types/widget.d.ts +29 -4
- package/_esm/types/widget.js.map +1 -1
- package/_esm/utils/chainType.js +3 -2
- package/_esm/utils/chainType.js.map +1 -1
- package/_esm/utils/fees.js +5 -9
- package/_esm/utils/fees.js.map +1 -1
- package/_esm/utils/svm.d.ts +1 -0
- package/_esm/utils/svm.js +11 -0
- package/_esm/utils/svm.js.map +1 -0
- package/components/ChainSelect/useChainSelect.ts +1 -10
- package/components/FeeBreakdownTooltip.tsx +1 -4
- package/components/Header/EVMDisconnectIconButton.tsx +5 -5
- package/components/Header/Header.style.ts +0 -6
- package/components/Header/WalletMenu.style.tsx +1 -5
- package/components/Header/WalletMenu.tsx +5 -6
- package/components/SendToWallet/SendToWalletButton.tsx +23 -13
- package/components/SendToWallet/SendToWalletExpandButton.tsx +10 -10
- package/components/Step/StepProcess.tsx +12 -2
- package/components/TokenList/TokenListItem.tsx +7 -15
- package/components/TokenList/VirtualizedTokenList.tsx +1 -1
- package/components/TokenList/types.ts +2 -2
- package/components/TokenRate/TokenRate.tsx +2 -2
- package/components/TransactionDetails.tsx +4 -1
- package/config/version.ts +1 -1
- package/hooks/useAccount.ts +35 -82
- package/hooks/useAvailableChains.ts +10 -9
- package/hooks/useChains.ts +3 -6
- package/hooks/useExplorer.ts +19 -2
- package/hooks/useGasSufficiency.ts +2 -4
- package/hooks/useHeaderHeight.ts +8 -1
- package/hooks/useTokens.ts +1 -2
- package/hooks/useWallets.ts +20 -41
- package/i18n/en.json +1 -1
- package/package.json +8 -8
- package/pages/SelectWalletPage/EVMListItemButton.tsx +19 -15
- package/pages/SelectWalletPage/SVMListItemButton.tsx +0 -3
- package/pages/SelectWalletPage/SelectWalletPage.tsx +4 -9
- package/pages/TransactionDetailsPage/TransferIdCard.tsx +1 -1
- package/pages/TransactionPage/StatusBottomSheet.tsx +5 -0
- package/providers/I18nProvider/types.ts +2 -2
- package/providers/WalletProvider/SDKProviders.tsx +7 -25
- package/providers/WalletProvider/WalletProvider.tsx +2 -5
- package/providers/WalletProvider/useHasExternalWalletProvider.ts +5 -11
- package/providers/WidgetProvider/WidgetProvider.tsx +1 -39
- package/stores/StoreProvider.tsx +5 -4
- package/stores/form/FormStore.tsx +100 -20
- package/stores/form/FormUpdater.tsx +52 -22
- package/stores/form/URLSearchParamsBuilder.tsx +55 -5
- package/stores/form/createFormStore.ts +9 -0
- package/stores/form/types.ts +14 -10
- package/stores/form/useFieldActions.ts +1 -0
- package/stores/form/useFormRef.ts +69 -0
- package/stores/settings/types.ts +0 -2
- package/stores/settings/useSendToWalletStore.ts +0 -8
- package/themes/createTheme.ts +1 -3
- package/types/widget.ts +46 -3
- package/utils/chainType.ts +3 -2
- package/utils/fees.ts +13 -15
- package/utils/svm.ts +10 -0
- package/_esm/components/Header/UTXODisconnectIconButton.d.ts +0 -4
- package/_esm/components/Header/UTXODisconnectIconButton.js +0 -13
- package/_esm/components/Header/UTXODisconnectIconButton.js.map +0 -1
- package/_esm/pages/SelectWalletPage/UTXOListItemButton.d.ts +0 -8
- package/_esm/pages/SelectWalletPage/UTXOListItemButton.js +0 -39
- package/_esm/pages/SelectWalletPage/UTXOListItemButton.js.map +0 -1
- package/_esm/providers/WalletProvider/UTXOBaseProvider.d.ts +0 -2
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js +0 -17
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js.map +0 -1
- package/_esm/providers/WalletProvider/UTXOExternalContext.d.ts +0 -1
- package/_esm/providers/WalletProvider/UTXOExternalContext.js +0 -3
- package/_esm/providers/WalletProvider/UTXOExternalContext.js.map +0 -1
- package/_esm/providers/WalletProvider/UTXOProvider.d.ts +0 -3
- package/_esm/providers/WalletProvider/UTXOProvider.js +0 -18
- package/_esm/providers/WalletProvider/UTXOProvider.js.map +0 -1
- package/components/Header/UTXODisconnectIconButton.tsx +0 -24
- package/pages/SelectWalletPage/UTXOListItemButton.tsx +0 -70
- package/providers/WalletProvider/UTXOBaseProvider.tsx +0 -28
- package/providers/WalletProvider/UTXOExternalContext.ts +0 -3
- package/providers/WalletProvider/UTXOProvider.tsx +0 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "3.6.0
|
|
3
|
+
"version": "3.6.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,27 +34,27 @@
|
|
|
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.2.3",
|
|
38
|
+
"@lifi/wallet-management": "^3.1.6",
|
|
39
39
|
"@mui/icons-material": "^5.16.7",
|
|
40
40
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
41
41
|
"@mui/material": "^5.16.7",
|
|
42
42
|
"@solana/wallet-adapter-base": "^0.9.23",
|
|
43
43
|
"@solana/wallet-adapter-react": "^0.15.35",
|
|
44
44
|
"@solana/web3.js": "^1.95.3",
|
|
45
|
-
"@tanstack/react-query": "^5.56.
|
|
46
|
-
"@tanstack/react-virtual": "^3.10.
|
|
45
|
+
"@tanstack/react-query": "^5.56.2",
|
|
46
|
+
"@tanstack/react-virtual": "^3.10.8",
|
|
47
47
|
"i18next": "^23.15.1",
|
|
48
48
|
"microdiff": "^1.4.0",
|
|
49
49
|
"mitt": "^3.0.1",
|
|
50
50
|
"react": "^18.3.1",
|
|
51
51
|
"react-dom": "^18.3.1",
|
|
52
|
-
"react-i18next": "^15.0.
|
|
52
|
+
"react-i18next": "^15.0.2",
|
|
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.9",
|
|
57
|
+
"wagmi": "^2.12.12",
|
|
58
58
|
"zustand": "^4.5.5"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -6,28 +6,28 @@ import {
|
|
|
6
6
|
} from '@lifi/wallet-management';
|
|
7
7
|
import { Avatar, ListItemAvatar } from '@mui/material';
|
|
8
8
|
import type { Connector } from 'wagmi';
|
|
9
|
-
import {
|
|
10
|
-
import { connect, disconnect, getAccount } from 'wagmi/actions';
|
|
9
|
+
import { useConnect, useDisconnect } from 'wagmi';
|
|
11
10
|
import { ListItemButton } from '../../components/ListItemButton.js';
|
|
12
11
|
import { ListItemText } from '../../components/ListItemText.js';
|
|
13
|
-
import { useLastConnectedAccount } from '../../hooks/useAccount.js';
|
|
14
12
|
import { useNavigateBack } from '../../hooks/useNavigateBack.js';
|
|
15
13
|
import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
|
|
16
14
|
import { WidgetEvent } from '../../types/events.js';
|
|
17
15
|
|
|
18
16
|
interface EVMListItemButtonProps {
|
|
17
|
+
connectedConnector?: Connector;
|
|
19
18
|
connector: CreateConnectorFnExtended | Connector;
|
|
20
19
|
onNotInstalled(connector: Connector): void;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
export const EVMListItemButton = ({
|
|
23
|
+
connectedConnector,
|
|
24
24
|
connector,
|
|
25
25
|
onNotInstalled,
|
|
26
26
|
}: EVMListItemButtonProps) => {
|
|
27
27
|
const { navigateBack } = useNavigateBack();
|
|
28
28
|
const emitter = useWidgetEvents();
|
|
29
|
-
const
|
|
30
|
-
const {
|
|
29
|
+
const { connectAsync } = useConnect();
|
|
30
|
+
const { disconnectAsync } = useDisconnect();
|
|
31
31
|
|
|
32
32
|
const handleEVMConnect = async () => {
|
|
33
33
|
const identityCheckPassed = await isWalletInstalledAsync(
|
|
@@ -37,17 +37,21 @@ export const EVMListItemButton = ({
|
|
|
37
37
|
onNotInstalled(connector as Connector);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
await disconnect(config, { connector: connectedAccount.connector });
|
|
40
|
+
if (connectedConnector) {
|
|
41
|
+
await disconnectAsync({ connector: connectedConnector });
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
+
);
|
|
51
55
|
navigateBack();
|
|
52
56
|
};
|
|
53
57
|
|
|
@@ -4,7 +4,6 @@ import type { Wallet } from '@solana/wallet-adapter-react';
|
|
|
4
4
|
import { useWallet } from '@solana/wallet-adapter-react';
|
|
5
5
|
import { ListItemButton } from '../../components/ListItemButton.js';
|
|
6
6
|
import { ListItemText } from '../../components/ListItemText.js';
|
|
7
|
-
import { useLastConnectedAccount } from '../../hooks/useAccount.js';
|
|
8
7
|
import { useNavigateBack } from '../../hooks/useNavigateBack.js';
|
|
9
8
|
import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
|
|
10
9
|
import { WidgetEvent } from '../../types/events.js';
|
|
@@ -17,7 +16,6 @@ export const SVMListItemButton = ({ wallet }: SVMListItemButtonProps) => {
|
|
|
17
16
|
const { navigateBack } = useNavigateBack();
|
|
18
17
|
const emitter = useWidgetEvents();
|
|
19
18
|
const { select, disconnect, connected } = useWallet();
|
|
20
|
-
const { setLastConnectedAccount } = useLastConnectedAccount();
|
|
21
19
|
|
|
22
20
|
const connect = async () => {
|
|
23
21
|
if (connected) {
|
|
@@ -27,7 +25,6 @@ export const SVMListItemButton = ({ wallet }: SVMListItemButtonProps) => {
|
|
|
27
25
|
// We use autoConnect on wallet selection
|
|
28
26
|
// await solanaConnect();
|
|
29
27
|
wallet.adapter.once('connect', (publicKey) => {
|
|
30
|
-
setLastConnectedAccount(wallet.adapter);
|
|
31
28
|
emitter.emit(WidgetEvent.WalletConnected, {
|
|
32
29
|
address: publicKey?.toString(),
|
|
33
30
|
chainId: ChainId.SOL,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ChainType } from '@lifi/sdk';
|
|
2
1
|
import {
|
|
3
2
|
Button,
|
|
4
3
|
DialogActions,
|
|
@@ -10,6 +9,7 @@ import type { Wallet } from '@solana/wallet-adapter-react';
|
|
|
10
9
|
import { useCallback, useState } from 'react';
|
|
11
10
|
import { useTranslation } from 'react-i18next';
|
|
12
11
|
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';
|
|
21
20
|
|
|
22
21
|
export const SelectWalletPage = () => {
|
|
23
22
|
const { t } = useTranslation();
|
|
24
23
|
const { chains, walletConfig } = useWidgetConfig();
|
|
24
|
+
const account = useWagmiAccount();
|
|
25
25
|
const [walletIdentity, setWalletIdentity] = useState<{
|
|
26
26
|
show: boolean;
|
|
27
27
|
connector?: Connector;
|
|
@@ -56,16 +56,11 @@ export const SelectWalletPage = () => {
|
|
|
56
56
|
}}
|
|
57
57
|
>
|
|
58
58
|
{wallets?.map((connector) =>
|
|
59
|
-
(connector as Connector).
|
|
60
|
-
<UTXOListItemButton
|
|
61
|
-
key={(connector as Connector).id}
|
|
62
|
-
connector={connector as Connector}
|
|
63
|
-
onNotInstalled={handleNotInstalled}
|
|
64
|
-
/>
|
|
65
|
-
) : (connector as Connector).id ? (
|
|
59
|
+
(connector as Connector).id ? (
|
|
66
60
|
<EVMListItemButton
|
|
67
61
|
key={(connector as Connector).id}
|
|
68
62
|
connector={connector as Connector}
|
|
63
|
+
connectedConnector={account.connector}
|
|
69
64
|
onNotInstalled={handleNotInstalled}
|
|
70
65
|
/>
|
|
71
66
|
) : (
|
|
@@ -25,7 +25,7 @@ export const TransferIdCard = ({ transferId }: TransferIdCardProps) => {
|
|
|
25
25
|
|
|
26
26
|
const openTransferIdInExplorer = () => {
|
|
27
27
|
const txHash = getTxHash(transferId);
|
|
28
|
-
window.open(getTransactionLink(txHash), '_blank');
|
|
28
|
+
window.open(getTransactionLink({ txHash }), '_blank');
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
return (
|
|
@@ -85,6 +85,7 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
85
85
|
subvariantOptions,
|
|
86
86
|
contractSecondaryComponent,
|
|
87
87
|
contractCompactComponent,
|
|
88
|
+
feeConfig,
|
|
88
89
|
} = useWidgetConfig();
|
|
89
90
|
const { getChainById } = useAvailableChains();
|
|
90
91
|
|
|
@@ -251,6 +252,9 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
251
252
|
hasEnumFlag(status, RouteExecutionStatus.Done) &&
|
|
252
253
|
(contractCompactComponent || contractSecondaryComponent);
|
|
253
254
|
|
|
255
|
+
const VcComponent =
|
|
256
|
+
status === RouteExecutionStatus.Done ? feeConfig?._vcComponent : undefined;
|
|
257
|
+
|
|
254
258
|
return (
|
|
255
259
|
<Box p={3} ref={ref}>
|
|
256
260
|
{!showContractComponent ? (
|
|
@@ -296,6 +300,7 @@ export const StatusBottomSheetContent: React.FC<
|
|
|
296
300
|
{secondaryMessage ? (
|
|
297
301
|
<Typography py={1}>{secondaryMessage}</Typography>
|
|
298
302
|
) : null}
|
|
303
|
+
{VcComponent ? <VcComponent route={route} /> : null}
|
|
299
304
|
<Box mt={2}>
|
|
300
305
|
<Button variant="contained" fullWidth onClick={handlePrimaryButton}>
|
|
301
306
|
{status === RouteExecutionStatus.Idle ? t('button.ok') : null}
|
|
@@ -12,14 +12,14 @@ export type LanguageResource = typeof languages.en;
|
|
|
12
12
|
|
|
13
13
|
export type LanguageResources =
|
|
14
14
|
| {
|
|
15
|
-
[
|
|
15
|
+
[language 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
|
+
[namespace in 'translation']: PartialResource<LanguageResource>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type LanguageTranslationResources = {
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import type { SDKProvider } from '@lifi/sdk';
|
|
2
|
-
import { ChainType, EVM, Solana,
|
|
3
|
-
import {
|
|
4
|
-
getConnectorClient as getBigmiConnectorClient,
|
|
5
|
-
useConfig as useBigmiConfig,
|
|
6
|
-
} from '@lifi/wallet-management';
|
|
2
|
+
import { ChainType, EVM, Solana, config } from '@lifi/sdk';
|
|
7
3
|
import type { SignerWalletAdapter } from '@solana/wallet-adapter-base';
|
|
8
4
|
import { useWallet } from '@solana/wallet-adapter-react';
|
|
9
|
-
import {
|
|
10
|
-
getConnectorClient as getWagmiConnectorClient,
|
|
11
|
-
switchChain,
|
|
12
|
-
} from '@wagmi/core';
|
|
5
|
+
import { getWalletClient, switchChain } from '@wagmi/core';
|
|
13
6
|
import { useEffect } from 'react';
|
|
14
|
-
import { useConfig
|
|
7
|
+
import { useConfig } from 'wagmi';
|
|
15
8
|
import { useWidgetConfig } from '../WidgetProvider/WidgetProvider.js';
|
|
16
9
|
|
|
17
10
|
export const SDKProviders = () => {
|
|
18
11
|
const { sdkConfig } = useWidgetConfig();
|
|
19
12
|
const { wallet } = useWallet();
|
|
20
|
-
const wagmiConfig =
|
|
21
|
-
const bigmiConfig = useBigmiConfig();
|
|
13
|
+
const wagmiConfig = useConfig();
|
|
22
14
|
|
|
23
15
|
useEffect(() => {
|
|
24
16
|
// Configure SDK Providers
|
|
@@ -29,16 +21,13 @@ export const SDKProviders = () => {
|
|
|
29
21
|
const hasConfiguredSVMProvider = sdkConfig?.providers?.some(
|
|
30
22
|
(provider) => provider.type === ChainType.SVM,
|
|
31
23
|
);
|
|
32
|
-
const hasConfiguredUTXOProvider = sdkConfig?.providers?.some(
|
|
33
|
-
(provider) => provider.type === ChainType.UTXO,
|
|
34
|
-
);
|
|
35
24
|
if (!hasConfiguredEVMProvider) {
|
|
36
25
|
providers.push(
|
|
37
26
|
EVM({
|
|
38
|
-
getWalletClient: () =>
|
|
27
|
+
getWalletClient: () => getWalletClient(wagmiConfig),
|
|
39
28
|
switchChain: async (chainId: number) => {
|
|
40
29
|
const chain = await switchChain(wagmiConfig, { chainId });
|
|
41
|
-
return
|
|
30
|
+
return getWalletClient(wagmiConfig, { chainId: chain.id });
|
|
42
31
|
},
|
|
43
32
|
}),
|
|
44
33
|
);
|
|
@@ -52,18 +41,11 @@ export const SDKProviders = () => {
|
|
|
52
41
|
}),
|
|
53
42
|
);
|
|
54
43
|
}
|
|
55
|
-
if (!hasConfiguredUTXOProvider) {
|
|
56
|
-
providers.push(
|
|
57
|
-
UTXO({
|
|
58
|
-
getWalletClient: () => getBigmiConnectorClient(bigmiConfig),
|
|
59
|
-
}),
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
44
|
if (sdkConfig?.providers?.length) {
|
|
63
45
|
providers.push(...sdkConfig?.providers);
|
|
64
46
|
}
|
|
65
47
|
config.setProviders(providers);
|
|
66
|
-
}, [
|
|
48
|
+
}, [sdkConfig?.providers, wagmiConfig, wallet?.adapter]);
|
|
67
49
|
|
|
68
50
|
return null;
|
|
69
51
|
};
|
|
@@ -2,16 +2,13 @@ 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';
|
|
6
5
|
|
|
7
6
|
export const WalletProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
8
7
|
return (
|
|
9
8
|
<EVMProvider>
|
|
10
9
|
<SVMProvider>
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
{children}
|
|
14
|
-
</UTXOProvider>
|
|
10
|
+
<SDKProviders />
|
|
11
|
+
{children}
|
|
15
12
|
</SVMProvider>
|
|
16
13
|
</EVMProvider>
|
|
17
14
|
);
|
|
@@ -2,35 +2,29 @@ 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';
|
|
6
5
|
|
|
7
6
|
interface ExternalWalletProvider {
|
|
8
7
|
hasExternalProvider: boolean;
|
|
9
|
-
|
|
8
|
+
providers: ChainType[];
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export function useHasExternalWalletProvider(): ExternalWalletProvider {
|
|
13
12
|
const hasExternalEVMContext = useContext(EVMExternalContext);
|
|
14
13
|
const hasExternalSVMContext = useContext(SVMExternalContext);
|
|
15
|
-
const hasExternalUTXOContext = useContext(UTXOExternalContext);
|
|
16
14
|
|
|
17
15
|
const providers = useMemo(() => {
|
|
18
|
-
const providers
|
|
16
|
+
const providers = [];
|
|
19
17
|
if (hasExternalEVMContext) {
|
|
20
18
|
providers.push(ChainType.EVM);
|
|
21
19
|
}
|
|
22
20
|
if (hasExternalSVMContext) {
|
|
23
21
|
providers.push(ChainType.SVM);
|
|
24
22
|
}
|
|
25
|
-
if (hasExternalUTXOContext) {
|
|
26
|
-
providers.push(ChainType.UTXO);
|
|
27
|
-
}
|
|
28
23
|
return providers;
|
|
29
|
-
}, [hasExternalEVMContext, hasExternalSVMContext
|
|
24
|
+
}, [hasExternalEVMContext, hasExternalSVMContext]);
|
|
30
25
|
|
|
31
26
|
return {
|
|
32
|
-
hasExternalProvider:
|
|
33
|
-
|
|
34
|
-
availableChainTypes: providers,
|
|
27
|
+
hasExternalProvider: hasExternalEVMContext || hasExternalSVMContext,
|
|
28
|
+
providers,
|
|
35
29
|
};
|
|
36
30
|
}
|
|
@@ -2,9 +2,7 @@ import { config, createConfig, type SDKConfig } from '@lifi/sdk';
|
|
|
2
2
|
import { createContext, useContext, useId, useMemo } from 'react';
|
|
3
3
|
import { version } from '../../config/version.js';
|
|
4
4
|
import { setDefaultSettings } from '../../stores/settings/useSettingsStore.js';
|
|
5
|
-
import { formatInputAmount } from '../../utils/format.js';
|
|
6
5
|
import type { WidgetContextProps, WidgetProviderProps } from './types.js';
|
|
7
|
-
import { attemptToFindMatchingToAddressInConfig } from './utils.js';
|
|
8
6
|
|
|
9
7
|
const initialContext: WidgetContextProps = {
|
|
10
8
|
elementId: '',
|
|
@@ -29,45 +27,9 @@ export const WidgetProvider: React.FC<
|
|
|
29
27
|
|
|
30
28
|
const value = useMemo((): WidgetContextProps => {
|
|
31
29
|
try {
|
|
32
|
-
// Get search params from URL
|
|
33
|
-
const searchParams = Object.fromEntries(
|
|
34
|
-
new URLSearchParams(window?.location.search),
|
|
35
|
-
);
|
|
36
|
-
// Prevent using fromToken/toToken params if chain is not selected
|
|
37
|
-
['from', 'to'].forEach((key) => {
|
|
38
|
-
if (searchParams[`${key}Token`] && !searchParams[`${key}Chain`]) {
|
|
39
|
-
delete searchParams[`${key}Token`];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
30
|
// Create widget configuration object
|
|
43
31
|
const value = {
|
|
44
32
|
...widgetConfig,
|
|
45
|
-
fromChain:
|
|
46
|
-
(searchParams.fromChain &&
|
|
47
|
-
!isNaN(parseInt(searchParams.fromChain, 10))) ||
|
|
48
|
-
typeof widgetConfig.fromChain === 'number'
|
|
49
|
-
? parseInt(searchParams.fromChain, 10) || widgetConfig.fromChain
|
|
50
|
-
: undefined,
|
|
51
|
-
toChain:
|
|
52
|
-
(searchParams.toChain &&
|
|
53
|
-
!isNaN(parseInt(searchParams.toChain, 10))) ||
|
|
54
|
-
typeof widgetConfig.toChain === 'number'
|
|
55
|
-
? parseInt(searchParams.toChain, 10) || widgetConfig.toChain
|
|
56
|
-
: undefined,
|
|
57
|
-
fromToken: searchParams.fromToken || widgetConfig.fromToken,
|
|
58
|
-
toToken: searchParams.toToken || widgetConfig.toToken,
|
|
59
|
-
fromAmount:
|
|
60
|
-
typeof searchParams.fromAmount === 'string' &&
|
|
61
|
-
!isNaN(parseFloat(searchParams.fromAmount))
|
|
62
|
-
? formatInputAmount(searchParams.fromAmount)
|
|
63
|
-
: widgetConfig.fromAmount,
|
|
64
|
-
toAddress: searchParams.toAddress
|
|
65
|
-
? attemptToFindMatchingToAddressInConfig(
|
|
66
|
-
searchParams.toAddress,
|
|
67
|
-
widgetConfig,
|
|
68
|
-
)
|
|
69
|
-
: widgetConfig.toAddress,
|
|
70
|
-
integrator: widgetConfig.integrator,
|
|
71
33
|
elementId,
|
|
72
34
|
} as WidgetContextProps;
|
|
73
35
|
|
|
@@ -88,7 +50,7 @@ export const WidgetProvider: React.FC<
|
|
|
88
50
|
},
|
|
89
51
|
disableVersionCheck: true,
|
|
90
52
|
widgetVersion: version,
|
|
91
|
-
|
|
53
|
+
preloadChains: false,
|
|
92
54
|
};
|
|
93
55
|
if (!sdkInitialized) {
|
|
94
56
|
createConfig(_config);
|
package/stores/StoreProvider.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { SplitSubvariantStoreProvider } from './settings/useSplitSubvariantStore
|
|
|
10
10
|
export const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>> = ({
|
|
11
11
|
children,
|
|
12
12
|
config,
|
|
13
|
+
formRef,
|
|
13
14
|
}) => {
|
|
14
15
|
return (
|
|
15
16
|
<SplitSubvariantStoreProvider
|
|
@@ -20,15 +21,15 @@ export const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>> = ({
|
|
|
20
21
|
}
|
|
21
22
|
>
|
|
22
23
|
<HeaderStoreProvider namePrefix={config?.keyPrefix}>
|
|
23
|
-
<
|
|
24
|
-
<
|
|
24
|
+
<BookmarkStoreProvider namePrefix={config?.keyPrefix}>
|
|
25
|
+
<FormStoreProvider formRef={formRef}>
|
|
25
26
|
<ChainOrderStoreProvider namePrefix={config?.keyPrefix}>
|
|
26
27
|
<RouteExecutionStoreProvider namePrefix={config?.keyPrefix}>
|
|
27
28
|
{children}
|
|
28
29
|
</RouteExecutionStoreProvider>
|
|
29
30
|
</ChainOrderStoreProvider>
|
|
30
|
-
</
|
|
31
|
-
</
|
|
31
|
+
</FormStoreProvider>
|
|
32
|
+
</BookmarkStoreProvider>
|
|
32
33
|
</HeaderStoreProvider>
|
|
33
34
|
</SplitSubvariantStoreProvider>
|
|
34
35
|
);
|
|
@@ -1,63 +1,143 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
2
|
import { useMemo, useRef } from 'react';
|
|
3
3
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
4
|
+
import type { FormRef, ToAddress } from '../../types/widget.js';
|
|
4
5
|
import { HiddenUI } from '../../types/widget.js';
|
|
5
6
|
import { FormStoreContext } from './FormStoreContext.js';
|
|
6
7
|
import { FormUpdater } from './FormUpdater.js';
|
|
7
8
|
import { createFormStore, formDefaultValues } from './createFormStore.js';
|
|
8
|
-
import type { FormStoreStore } from './types.js';
|
|
9
|
+
import type { DefaultValues, FormStoreStore } from './types.js';
|
|
10
|
+
import { useFormRef } from './useFormRef.js';
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
// decorates and initialise the form date for use in the form store
|
|
13
|
+
const initialiseDefaultValues = (
|
|
14
|
+
defaultValues: Partial<DefaultValues>,
|
|
15
|
+
fromAmount?: number | string,
|
|
16
|
+
toAmount?: number | string,
|
|
17
|
+
toAddress?: ToAddress,
|
|
18
|
+
hiddenToAddress?: boolean,
|
|
19
|
+
) => ({
|
|
20
|
+
...formDefaultValues,
|
|
21
|
+
...defaultValues,
|
|
22
|
+
fromAmount:
|
|
23
|
+
(typeof fromAmount === 'number' ? fromAmount?.toPrecision() : fromAmount) ||
|
|
24
|
+
formDefaultValues.fromAmount,
|
|
25
|
+
toAmount:
|
|
26
|
+
(typeof toAmount === 'number' ? toAmount?.toPrecision() : toAmount) ||
|
|
27
|
+
formDefaultValues.toAmount,
|
|
28
|
+
// Prevent setting address when the field is hidden
|
|
29
|
+
toAddress: hiddenToAddress
|
|
30
|
+
? formDefaultValues.toAddress
|
|
31
|
+
: toAddress?.address || formDefaultValues.toAddress,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
interface FormStoreProviderProps extends PropsWithChildren {
|
|
35
|
+
formRef?: FormRef;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const FormStoreProvider: React.FC<FormStoreProviderProps> = ({
|
|
11
39
|
children,
|
|
40
|
+
formRef,
|
|
12
41
|
}) => {
|
|
42
|
+
const widgetConfig = useWidgetConfig();
|
|
43
|
+
|
|
13
44
|
const {
|
|
14
45
|
fromChain,
|
|
15
46
|
fromToken,
|
|
16
|
-
fromAmount,
|
|
17
47
|
toChain,
|
|
18
48
|
toToken,
|
|
49
|
+
fromAmount,
|
|
50
|
+
toAmount,
|
|
19
51
|
toAddress,
|
|
20
52
|
hiddenUI,
|
|
21
|
-
|
|
53
|
+
formUpdateKey,
|
|
54
|
+
} = widgetConfig;
|
|
55
|
+
|
|
22
56
|
const storeRef = useRef<FormStoreStore>();
|
|
23
57
|
|
|
24
58
|
const hiddenToAddress = hiddenUI?.includes(HiddenUI.ToAddress);
|
|
25
59
|
|
|
26
|
-
const
|
|
60
|
+
const configHasFromChain = widgetConfig.hasOwnProperty('fromChain');
|
|
61
|
+
const configHasFromToken = widgetConfig.hasOwnProperty('fromToken');
|
|
62
|
+
const configHasFromAmount = widgetConfig.hasOwnProperty('fromAmount');
|
|
63
|
+
const configHasToAmount = widgetConfig.hasOwnProperty('toAmount');
|
|
64
|
+
const configHasToAddress = widgetConfig.hasOwnProperty('toAddress');
|
|
65
|
+
const configHasToChain = widgetConfig.hasOwnProperty('toChain');
|
|
66
|
+
const configHasToToken = widgetConfig.hasOwnProperty('toToken');
|
|
67
|
+
|
|
68
|
+
// We use the presence/absence of a property to decide if the form values in state need to be updated
|
|
69
|
+
// We only build and set a property on the memoized form values here if they are included in the
|
|
70
|
+
// config - undefined is considered a valid value that will reset that form field
|
|
71
|
+
const reactiveFormValues = useMemo(
|
|
27
72
|
() => ({
|
|
28
|
-
...
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
?
|
|
40
|
-
|
|
73
|
+
...(configHasFromChain ? { fromChain } : undefined),
|
|
74
|
+
...(configHasFromToken ? { fromToken } : undefined),
|
|
75
|
+
...(configHasFromAmount
|
|
76
|
+
? {
|
|
77
|
+
fromAmount:
|
|
78
|
+
(typeof fromAmount === 'number'
|
|
79
|
+
? fromAmount?.toPrecision()
|
|
80
|
+
: fromAmount) || formDefaultValues.fromAmount,
|
|
81
|
+
}
|
|
82
|
+
: undefined),
|
|
83
|
+
...(configHasFromAmount
|
|
84
|
+
? {
|
|
85
|
+
toAmount:
|
|
86
|
+
(typeof toAmount === 'number'
|
|
87
|
+
? toAmount?.toPrecision()
|
|
88
|
+
: toAmount) || formDefaultValues.toAmount,
|
|
89
|
+
}
|
|
90
|
+
: undefined),
|
|
91
|
+
...(configHasToChain ? { toChain } : undefined),
|
|
92
|
+
...(configHasToToken ? { toToken } : undefined),
|
|
93
|
+
...(configHasToAddress
|
|
94
|
+
? {
|
|
95
|
+
toAddress: hiddenToAddress
|
|
96
|
+
? formDefaultValues.toAddress
|
|
97
|
+
: toAddress?.address || formDefaultValues.toAddress,
|
|
98
|
+
}
|
|
99
|
+
: undefined),
|
|
41
100
|
}),
|
|
101
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
102
|
[
|
|
43
103
|
fromAmount,
|
|
104
|
+
toAmount,
|
|
44
105
|
fromChain,
|
|
45
106
|
fromToken,
|
|
46
107
|
hiddenToAddress,
|
|
47
108
|
toAddress,
|
|
48
109
|
toChain,
|
|
49
110
|
toToken,
|
|
111
|
+
// formUpdateKey should be a randomly assigned unique key. It can be used to force updates for the form field values
|
|
112
|
+
formUpdateKey,
|
|
113
|
+
configHasFromChain,
|
|
114
|
+
configHasFromToken,
|
|
115
|
+
configHasFromAmount,
|
|
116
|
+
configHasToAmount,
|
|
117
|
+
configHasToAddress,
|
|
118
|
+
configHasToChain,
|
|
119
|
+
configHasToToken,
|
|
50
120
|
],
|
|
51
121
|
);
|
|
52
122
|
|
|
53
123
|
if (!storeRef.current) {
|
|
54
|
-
storeRef.current = createFormStore(
|
|
124
|
+
storeRef.current = createFormStore(
|
|
125
|
+
initialiseDefaultValues(
|
|
126
|
+
reactiveFormValues,
|
|
127
|
+
fromAmount,
|
|
128
|
+
toAmount,
|
|
129
|
+
toAddress,
|
|
130
|
+
hiddenToAddress,
|
|
131
|
+
),
|
|
132
|
+
);
|
|
55
133
|
}
|
|
56
134
|
|
|
135
|
+
useFormRef(storeRef.current, formRef);
|
|
136
|
+
|
|
57
137
|
return (
|
|
58
138
|
<FormStoreContext.Provider value={storeRef.current}>
|
|
59
139
|
{children}
|
|
60
|
-
<FormUpdater
|
|
140
|
+
<FormUpdater reactiveFormValues={reactiveFormValues} />
|
|
61
141
|
</FormStoreContext.Provider>
|
|
62
142
|
);
|
|
63
143
|
};
|