@lifi/widget 3.6.0-alpha.5 → 3.6.1
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 +23 -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/format.js +1 -1
- package/_esm/utils/format.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/format.ts +1 -1
- 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/hooks/useWallets.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
createWalletConnectConnector,
|
|
7
7
|
getWalletPriority,
|
|
8
8
|
isWalletInstalled,
|
|
9
|
-
useConfig as useBigmiConfig,
|
|
10
9
|
} from '@lifi/wallet-management';
|
|
11
10
|
import type { Theme } from '@mui/material';
|
|
12
11
|
import { useMediaQuery } from '@mui/material';
|
|
@@ -15,7 +14,7 @@ import type { Wallet } from '@solana/wallet-adapter-react';
|
|
|
15
14
|
import { useWallet } from '@solana/wallet-adapter-react';
|
|
16
15
|
import { useMemo } from 'react';
|
|
17
16
|
import type { Connector } from 'wagmi';
|
|
18
|
-
import {
|
|
17
|
+
import { useConnect, useAccount as useWagmiAccount } from 'wagmi';
|
|
19
18
|
import { defaultCoinbaseConfig } from '../config/coinbase.js';
|
|
20
19
|
import { defaultMetaMaskConfig } from '../config/metaMask.js';
|
|
21
20
|
import { defaultWalletConnectConfig } from '../config/walletConnect.js';
|
|
@@ -26,11 +25,8 @@ export const useWallets = (
|
|
|
26
25
|
walletConfig?: WidgetWalletConfig,
|
|
27
26
|
chains?: WidgetChains,
|
|
28
27
|
) => {
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const bigmiAccount = useAccount({ config: bigmiConfig });
|
|
32
|
-
const { connectors: wagmiConnectors } = useConnect();
|
|
33
|
-
const { connectors: bigmiConnectors } = useConnect({ config: bigmiConfig });
|
|
28
|
+
const account = useWagmiAccount();
|
|
29
|
+
const { connectors } = useConnect();
|
|
34
30
|
const { wallets: solanaWallets } = useWallet();
|
|
35
31
|
|
|
36
32
|
const isDesktopView = useMediaQuery((theme: Theme) =>
|
|
@@ -39,9 +35,9 @@ export const useWallets = (
|
|
|
39
35
|
|
|
40
36
|
const wallets = useMemo(() => {
|
|
41
37
|
const evmConnectors: (CreateConnectorFnExtended | Connector)[] =
|
|
42
|
-
Array.from(
|
|
38
|
+
Array.from(connectors);
|
|
43
39
|
if (
|
|
44
|
-
!
|
|
40
|
+
!connectors.some((connector) =>
|
|
45
41
|
connector.id.toLowerCase().includes('walletconnect'),
|
|
46
42
|
)
|
|
47
43
|
) {
|
|
@@ -52,7 +48,7 @@ export const useWallets = (
|
|
|
52
48
|
);
|
|
53
49
|
}
|
|
54
50
|
if (
|
|
55
|
-
!
|
|
51
|
+
!connectors.some((connector) =>
|
|
56
52
|
connector.id.toLowerCase().includes('coinbase'),
|
|
57
53
|
) &&
|
|
58
54
|
!isWalletInstalled('coinbase')
|
|
@@ -64,7 +60,7 @@ export const useWallets = (
|
|
|
64
60
|
);
|
|
65
61
|
}
|
|
66
62
|
if (
|
|
67
|
-
!
|
|
63
|
+
!connectors.some((connector) =>
|
|
68
64
|
connector.id.toLowerCase().includes('metamask'),
|
|
69
65
|
) &&
|
|
70
66
|
!isWalletInstalled('metaMask')
|
|
@@ -78,24 +74,13 @@ export const useWallets = (
|
|
|
78
74
|
const evmInstalled = isItemAllowed(ChainType.EVM, chains?.types)
|
|
79
75
|
? evmConnectors.filter(
|
|
80
76
|
(connector) =>
|
|
81
|
-
isWalletInstalled(connector.id) &&
|
|
77
|
+
isWalletInstalled(connector.id!) &&
|
|
82
78
|
// We should not show already connected connectors
|
|
83
|
-
|
|
79
|
+
account.connector?.id !== connector.id,
|
|
84
80
|
)
|
|
85
81
|
: [];
|
|
86
82
|
const evmNotDetected = isItemAllowed(ChainType.EVM, chains?.types)
|
|
87
|
-
? evmConnectors.filter((connector) => !isWalletInstalled(connector.id))
|
|
88
|
-
: [];
|
|
89
|
-
const utxoInstalled = isItemAllowed(ChainType.UTXO, chains?.types)
|
|
90
|
-
? bigmiConnectors.filter(
|
|
91
|
-
(connector) =>
|
|
92
|
-
isWalletInstalled(connector.id) &&
|
|
93
|
-
// We should not show already connected connectors
|
|
94
|
-
bigmiAccount.connector?.id !== connector.id,
|
|
95
|
-
)
|
|
96
|
-
: [];
|
|
97
|
-
const utxoNotDetected = isItemAllowed(ChainType.UTXO, chains?.types)
|
|
98
|
-
? bigmiConnectors.filter((connector) => !isWalletInstalled(connector.id!))
|
|
83
|
+
? evmConnectors.filter((connector) => !isWalletInstalled(connector.id!))
|
|
99
84
|
: [];
|
|
100
85
|
const svmInstalled = isItemAllowed(ChainType.SVM, chains?.types)
|
|
101
86
|
? solanaWallets?.filter(
|
|
@@ -112,33 +97,27 @@ export const useWallets = (
|
|
|
112
97
|
)
|
|
113
98
|
: [];
|
|
114
99
|
|
|
115
|
-
const installedWallets = [
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
...utxoInstalled,
|
|
119
|
-
].sort(walletComparator);
|
|
100
|
+
const installedWallets = [...evmInstalled, ...svmInstalled].sort(
|
|
101
|
+
walletComparator,
|
|
102
|
+
);
|
|
120
103
|
|
|
121
104
|
if (isDesktopView) {
|
|
122
|
-
const notDetectedWallets = [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
...utxoNotDetected,
|
|
126
|
-
].sort(walletComparator);
|
|
105
|
+
const notDetectedWallets = [...evmNotDetected, ...svmNotDetected].sort(
|
|
106
|
+
walletComparator,
|
|
107
|
+
);
|
|
127
108
|
installedWallets.push(...notDetectedWallets);
|
|
128
109
|
}
|
|
129
110
|
|
|
130
111
|
return installedWallets;
|
|
131
112
|
}, [
|
|
132
|
-
|
|
113
|
+
account.connector?.id,
|
|
133
114
|
chains?.types,
|
|
134
|
-
|
|
135
|
-
solanaWallets,
|
|
115
|
+
connectors,
|
|
136
116
|
isDesktopView,
|
|
137
|
-
|
|
117
|
+
solanaWallets,
|
|
138
118
|
walletConfig?.coinbase,
|
|
139
119
|
walletConfig?.metaMask,
|
|
140
|
-
|
|
141
|
-
wagmiAccount.connector?.id,
|
|
120
|
+
walletConfig?.walletConnect,
|
|
142
121
|
]);
|
|
143
122
|
|
|
144
123
|
return wallets;
|
package/i18n/en.json
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"bridgeReview": "Review bridge",
|
|
17
17
|
"buy": "Buy",
|
|
18
18
|
"cancel": "Cancel",
|
|
19
|
+
"changeWallet": "Change wallet",
|
|
19
20
|
"checkoutReview": "Review purchase",
|
|
20
21
|
"close": "Close",
|
|
21
22
|
"confirm": "Confirm",
|
|
22
|
-
"connectAnotherWallet": "Connect another wallet",
|
|
23
23
|
"connectWallet": "Connect wallet",
|
|
24
24
|
"contactSupport": "Contact support",
|
|
25
25
|
"continue": "Continue",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.1",
|
|
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
|
);
|