@web3auth/modal 10.0.0-beta.5 → 10.0.0-beta.7
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/dist/lib.cjs/packages/modal/src/config.js +1 -1
- package/dist/lib.cjs/packages/modal/src/modalManager.js +30 -4
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWalletServicesPlugin.js +2 -1
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthConnect.js +5 -1
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignAndSendTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignMessage.js +37 -0
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSolanaWallet.js +39 -0
- package/dist/lib.cjs/packages/modal/src/react/solana/index.js +13 -0
- package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +2 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +21 -15
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +12 -7
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +21 -6
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +12 -9
- package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +151 -81
- package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +11 -1
- package/dist/lib.cjs/packages/modal/src/ui/constants.js +26 -0
- package/dist/lib.cjs/packages/modal/src/ui/context/RootContext.js +12 -3
- package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +24 -15
- package/dist/lib.cjs/packages/modal/src/ui/utils.js +16 -4
- package/dist/lib.cjs/packages/modal/src/vue/WalletServicesInnerProvider.js +70 -0
- package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +16 -74
- package/dist/lib.cjs/packages/modal/src/vue/composables/useCheckout.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useEnableMFA.js +32 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useIdentityToken.js +44 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useManageMFA.js +32 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useSwap.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useSwitchChain.js +32 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletConnectScanner.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletServicesPlugin.js +13 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletUI.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3Auth.js +2 -4
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthConnect.js +50 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthDisconnect.js +32 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthInner.js +12 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthUser.js +53 -0
- package/dist/lib.cjs/packages/modal/src/vue/index.js +24 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignMessage.js +38 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSolanaWallet.js +46 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/index.js +13 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/index.js +7 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/provider.js +218 -0
- package/dist/lib.cjs/types/interface.d.ts +1 -1
- package/dist/lib.cjs/types/react/solana/hooks/index.d.ts +4 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignAndSendTransaction.d.ts +8 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignMessage.d.ts +8 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignTransaction.d.ts +13 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSolanaWallet.d.ts +8 -0
- package/dist/lib.cjs/types/react/solana/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/wagmi/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/wagmi/interface.d.ts +1 -1
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.type.d.ts +1 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.type.d.ts +3 -4
- package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.type.d.ts +3 -2
- package/dist/lib.cjs/types/ui/constants.d.ts +2 -0
- package/dist/lib.cjs/types/ui/context/RootContext.d.ts +12 -3
- package/dist/lib.cjs/types/ui/interfaces.d.ts +6 -0
- package/dist/lib.cjs/types/ui/loginModal.d.ts +1 -1
- package/dist/lib.cjs/types/ui/utils.d.ts +2 -2
- package/dist/lib.cjs/types/vue/WalletServicesInnerProvider.d.ts +1 -0
- package/dist/lib.cjs/types/vue/composables/index.d.ts +12 -0
- package/dist/lib.cjs/types/vue/composables/useCheckout.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useEnableMFA.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/useIdentityToken.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useManageMFA.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/useSwap.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useSwitchChain.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWalletConnectScanner.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useWalletServicesPlugin.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useWalletUI.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3Auth.d.ts +3 -2
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthConnect.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthDisconnect.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthInner.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthUser.d.ts +10 -0
- package/dist/lib.cjs/types/vue/interfaces.d.ts +10 -18
- package/dist/lib.cjs/types/vue/solana/composables/index.d.ts +4 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignAndSendTransaction.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignMessage.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignTransaction.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSolanaWallet.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/wagmi/index.d.ts +2 -0
- package/dist/lib.cjs/types/vue/wagmi/interface.d.ts +4 -0
- package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +16 -0
- package/dist/lib.esm/packages/modal/src/config.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +33 -4
- package/dist/lib.esm/packages/modal/src/react/hooks/useWalletServicesPlugin.js +2 -1
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthConnect.js +5 -1
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignAndSendTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignMessage.js +35 -0
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSolanaWallet.js +37 -0
- package/dist/lib.esm/packages/modal/src/react/solana/index.js +4 -0
- package/dist/lib.esm/packages/modal/src/react/wagmi/provider.js +2 -1
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +21 -15
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +13 -8
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +22 -6
- package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +12 -9
- package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +154 -82
- package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +12 -1
- package/dist/lib.esm/packages/modal/src/ui/constants.js +26 -1
- package/dist/lib.esm/packages/modal/src/ui/context/RootContext.js +12 -3
- package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +24 -15
- package/dist/lib.esm/packages/modal/src/ui/utils.js +16 -4
- package/dist/lib.esm/packages/modal/src/vue/WalletServicesInnerProvider.js +69 -0
- package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +17 -75
- package/dist/lib.esm/packages/modal/src/vue/composables/useCheckout.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useEnableMFA.js +30 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useIdentityToken.js +42 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useManageMFA.js +30 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useSwap.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useSwitchChain.js +30 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWalletConnectScanner.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWalletServicesPlugin.js +11 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWalletUI.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3Auth.js +2 -4
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthConnect.js +48 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthDisconnect.js +30 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthInner.js +10 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthUser.js +51 -0
- package/dist/lib.esm/packages/modal/src/vue/index.js +12 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignMessage.js +36 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSolanaWallet.js +44 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/index.js +4 -0
- package/dist/lib.esm/packages/modal/src/vue/wagmi/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/vue/wagmi/provider.js +219 -0
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +3 -23
- package/package.json +42 -6
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import { SolanaWallet } from '@web3auth/no-modal';
|
|
3
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
4
|
+
import { useWeb3Auth } from '../../hooks/useWeb3Auth.js';
|
|
5
|
+
|
|
6
|
+
const useSolanaWallet = () => {
|
|
7
|
+
const {
|
|
8
|
+
provider,
|
|
9
|
+
web3Auth
|
|
10
|
+
} = useWeb3Auth();
|
|
11
|
+
const [accounts, setAccounts] = useState(null);
|
|
12
|
+
const solanaWallet = useMemo(() => {
|
|
13
|
+
if (!provider) return null;
|
|
14
|
+
return new SolanaWallet(provider);
|
|
15
|
+
}, [provider]);
|
|
16
|
+
const connection = useMemo(() => {
|
|
17
|
+
if (!web3Auth || !provider) return null;
|
|
18
|
+
return new Connection(web3Auth.currentChain.rpcTarget);
|
|
19
|
+
}, [web3Auth, provider]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const init = async () => {
|
|
22
|
+
if (!solanaWallet) return;
|
|
23
|
+
const accounts = await solanaWallet.requestAccounts();
|
|
24
|
+
if ((accounts === null || accounts === void 0 ? void 0 : accounts.length) > 0) {
|
|
25
|
+
setAccounts(accounts);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
if (solanaWallet) init();
|
|
29
|
+
}, [solanaWallet, web3Auth]);
|
|
30
|
+
return {
|
|
31
|
+
solanaWallet,
|
|
32
|
+
accounts,
|
|
33
|
+
connection
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { useSolanaWallet };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useSignAndSendTransaction } from './hooks/useSignAndSendTransaction.js';
|
|
2
|
+
export { useSignMessage } from './hooks/useSignMessage.js';
|
|
3
|
+
export { useSignTransaction } from './hooks/useSignTransaction.js';
|
|
4
|
+
export { useSolanaWallet } from './hooks/useSolanaWallet.js';
|
|
@@ -6,11 +6,11 @@ import { defineChain, http } from 'viem';
|
|
|
6
6
|
import { createConfig, WagmiProvider as WagmiProvider$1, useConfig, useAccountEffect } from 'wagmi';
|
|
7
7
|
import { injected } from 'wagmi/connectors';
|
|
8
8
|
import '@babel/runtime/helpers/defineProperty';
|
|
9
|
+
import '@web3auth/auth';
|
|
9
10
|
import 'deepmerge';
|
|
10
11
|
import '../../config.js';
|
|
11
12
|
import '../../ui/config.js';
|
|
12
13
|
import '../../ui/css/index.css.js';
|
|
13
|
-
import '@web3auth/auth';
|
|
14
14
|
import 'react-dom/client';
|
|
15
15
|
import '@toruslabs/http-helpers';
|
|
16
16
|
import 'clsx';
|
|
@@ -99,6 +99,7 @@ function Web3AuthWagmiProvider({
|
|
|
99
99
|
if (isConnected && provider) {
|
|
100
100
|
const connector = await setupConnector(provider, wagmiConfig);
|
|
101
101
|
if (!connector) {
|
|
102
|
+
log.error("Failed to setup react wagmi connector");
|
|
102
103
|
throw new Error("Failed to setup connector");
|
|
103
104
|
}
|
|
104
105
|
await connectWeb3AuthWithWagmi(connector, wagmiConfig);
|
|
@@ -16,6 +16,7 @@ function ConnectWallet(props) {
|
|
|
16
16
|
isDark,
|
|
17
17
|
config,
|
|
18
18
|
walletConnectUri,
|
|
19
|
+
metamaskConnectUri,
|
|
19
20
|
walletRegistry,
|
|
20
21
|
allExternalButtons,
|
|
21
22
|
customConnectorButtons,
|
|
@@ -29,9 +30,7 @@ function ConnectWallet(props) {
|
|
|
29
30
|
} = props;
|
|
30
31
|
const {
|
|
31
32
|
bodyState,
|
|
32
|
-
setBodyState
|
|
33
|
-
toast,
|
|
34
|
-
setToast
|
|
33
|
+
setBodyState
|
|
35
34
|
} = useContext(RootContext);
|
|
36
35
|
const [currentPage, setCurrentPage] = useState(CONNECT_WALLET_PAGES.CONNECT_WALLET);
|
|
37
36
|
const [selectedWallet, setSelectedWallet] = useState(false);
|
|
@@ -66,7 +65,7 @@ function ConnectWallet(props) {
|
|
|
66
65
|
const defaultButtonKeys = useMemo(() => new Set(Object.keys(walletRegistry.default)), [walletRegistry]);
|
|
67
66
|
const defaultButtons = useMemo(() => {
|
|
68
67
|
// display order: default injected buttons > custom adapter buttons > default non-injected buttons
|
|
69
|
-
const buttons = [...allExternalButtons.filter(button => button.hasInjectedWallet && defaultButtonKeys.has(button.name)), ...customConnectorButtons, ...allExternalButtons.filter(button => !button.hasInjectedWallet && defaultButtonKeys.has(button.name))];
|
|
68
|
+
const buttons = [...allExternalButtons.filter(button => button.hasInjectedWallet && defaultButtonKeys.has(button.name)), ...customConnectorButtons, ...allExternalButtons.filter(button => !button.hasInjectedWallet && defaultButtonKeys.has(button.name))].sort((a, _) => a.name === WALLET_CONNECTORS.METAMASK ? -1 : 1);
|
|
70
69
|
const buttonSet = new Set();
|
|
71
70
|
return buttons.filter(button => {
|
|
72
71
|
if (buttonSet.has(button.name)) return false;
|
|
@@ -102,7 +101,7 @@ function ConnectWallet(props) {
|
|
|
102
101
|
};
|
|
103
102
|
const filteredButtons = useMemo(() => {
|
|
104
103
|
if (walletDiscoverySupported) {
|
|
105
|
-
return [...allUniqueButtons.filter(button => button.hasInjectedWallet), ...allUniqueButtons.filter(button => !button.hasInjectedWallet)].filter(button => selectedChain === "all" || button.chainNamespaces.includes(selectedChain)).filter(button => button.name.toLowerCase().includes(walletSearch.toLowerCase()));
|
|
104
|
+
return [...allUniqueButtons.filter(button => button.hasInjectedWallet), ...allUniqueButtons.filter(button => !button.hasInjectedWallet)].sort((a, _) => a.name === WALLET_CONNECTORS.METAMASK ? -1 : 1).filter(button => selectedChain === "all" || button.chainNamespaces.includes(selectedChain)).filter(button => button.name.toLowerCase().includes(walletSearch.toLowerCase()));
|
|
106
105
|
}
|
|
107
106
|
return installedWalletButtons;
|
|
108
107
|
}, [walletDiscoverySupported, installedWalletButtons, walletSearch, allUniqueButtons, selectedChain]);
|
|
@@ -123,8 +122,10 @@ function ConnectWallet(props) {
|
|
|
123
122
|
const isChainNamespaceSelectorRequired = button.hasInjectedWallet && ((_button$chainNamespac2 = button.chainNamespaces) === null || _button$chainNamespac2 === void 0 ? void 0 : _button$chainNamespac2.length) > 1;
|
|
124
123
|
if (isChainNamespaceSelectorRequired) {
|
|
125
124
|
setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
multiChainSelector: {
|
|
126
|
+
show: true,
|
|
127
|
+
wallet: button
|
|
128
|
+
}
|
|
128
129
|
}));
|
|
129
130
|
return;
|
|
130
131
|
}
|
|
@@ -143,14 +144,23 @@ function ConnectWallet(props) {
|
|
|
143
144
|
handleWalletDetailsHeight();
|
|
144
145
|
} else {
|
|
145
146
|
setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
installLinks: {
|
|
148
|
+
show: true,
|
|
149
|
+
wallet: button
|
|
150
|
+
}
|
|
148
151
|
}));
|
|
149
152
|
}
|
|
150
153
|
};
|
|
151
154
|
const handleMoreWallets = () => {
|
|
152
155
|
setIsShowAllWallets(true);
|
|
153
156
|
};
|
|
157
|
+
const qrCodeValue = useMemo(() => {
|
|
158
|
+
if (!selectedWallet) return null;
|
|
159
|
+
if (selectedButton.name === WALLET_CONNECTORS.METAMASK && !selectedButton.hasInjectedWallet) {
|
|
160
|
+
return metamaskConnectUri;
|
|
161
|
+
}
|
|
162
|
+
return walletConnectUri;
|
|
163
|
+
}, [metamaskConnectUri, selectedButton, selectedWallet, walletConnectUri]);
|
|
154
164
|
return /*#__PURE__*/jsxs("div", {
|
|
155
165
|
className: "w3a--relative w3a--flex w3a--flex-1 w3a--flex-col w3a--gap-y-4",
|
|
156
166
|
children: [/*#__PURE__*/jsx(ConnectWalletHeader, {
|
|
@@ -158,15 +168,11 @@ function ConnectWallet(props) {
|
|
|
158
168
|
currentPage: currentPage,
|
|
159
169
|
selectedButton: selectedButton
|
|
160
170
|
}), selectedWallet ? /*#__PURE__*/jsx(ConnectWalletQrCode, {
|
|
161
|
-
|
|
162
|
-
setToast: setToast,
|
|
163
|
-
walletConnectUri: walletConnectUri,
|
|
171
|
+
qrCodeValue: qrCodeValue,
|
|
164
172
|
isDark: isDark,
|
|
165
173
|
selectedButton: selectedButton,
|
|
166
|
-
bodyState: bodyState,
|
|
167
174
|
primaryColor: (_selectedButton$walle = selectedButton.walletRegistryItem) === null || _selectedButton$walle === void 0 ? void 0 : _selectedButton$walle.primaryColor,
|
|
168
|
-
logoImage: `https://images.web3auth.io/login-${selectedButton.name}.${selectedButton.imgExtension}
|
|
169
|
-
setBodyState: setBodyState
|
|
175
|
+
logoImage: `https://images.web3auth.io/login-${selectedButton.name}.${selectedButton.imgExtension}`
|
|
170
176
|
}) : /*#__PURE__*/jsxs("div", {
|
|
171
177
|
className: "w3a--flex w3a--flex-col w3a--gap-y-2",
|
|
172
178
|
children: [/*#__PURE__*/jsx(ConnectWalletChainFilter, {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import Bowser from 'bowser';
|
|
3
|
-
import { useMemo } from 'react';
|
|
3
|
+
import { useContext, useMemo } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { QRCode } from 'react-qrcode-logo';
|
|
6
6
|
import { WALLET_CONNECT_LOGO } from '../../../constants.js';
|
|
7
|
+
import { RootContext } from '../../../context/RootContext.js';
|
|
7
8
|
import i18nInstance from '../../../localeImport.js';
|
|
8
9
|
import Image from '../../Image/Image.js';
|
|
9
10
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -14,11 +15,13 @@ function ConnectWalletQrCode(props) {
|
|
|
14
15
|
i18n: i18nInstance
|
|
15
16
|
});
|
|
16
17
|
const {
|
|
17
|
-
|
|
18
|
+
bodyState,
|
|
19
|
+
setBodyState
|
|
20
|
+
} = useContext(RootContext);
|
|
21
|
+
const {
|
|
22
|
+
qrCodeValue,
|
|
18
23
|
isDark,
|
|
19
24
|
selectedButton,
|
|
20
|
-
setBodyState,
|
|
21
|
-
bodyState,
|
|
22
25
|
logoImage,
|
|
23
26
|
primaryColor
|
|
24
27
|
} = props;
|
|
@@ -33,7 +36,7 @@ function ConnectWalletQrCode(props) {
|
|
|
33
36
|
const qrColor = primaryColor && primaryColor.toLowerCase() === "#ffffff" ? "#000000" : primaryColor;
|
|
34
37
|
return /*#__PURE__*/jsxs("div", {
|
|
35
38
|
className: "w3a--contents",
|
|
36
|
-
children: [
|
|
39
|
+
children: [qrCodeValue ? /*#__PURE__*/jsxs("div", {
|
|
37
40
|
className: "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4 w3a--rounded-2xl w3a--border w3a--border-app-gray-200 w3a--p-4 dark:w3a--border-app-gray-700",
|
|
38
41
|
children: [/*#__PURE__*/jsx("div", {
|
|
39
42
|
className: "w3a--relative w3a--flex w3a--size-[300px] w3a--items-center w3a--justify-center w3a--rounded-2xl",
|
|
@@ -43,7 +46,7 @@ function ConnectWalletQrCode(props) {
|
|
|
43
46
|
qrStyle: "dots",
|
|
44
47
|
removeQrCodeBehindLogo: true,
|
|
45
48
|
logoImage: logoImage || WALLET_CONNECT_LOGO,
|
|
46
|
-
value:
|
|
49
|
+
value: qrCodeValue,
|
|
47
50
|
logoHeight: 32,
|
|
48
51
|
logoWidth: 32,
|
|
49
52
|
logoPadding: 10,
|
|
@@ -78,8 +81,10 @@ function ConnectWalletQrCode(props) {
|
|
|
78
81
|
className: "w3a--appearance-none w3a--rounded-full w3a--border w3a--border-app-gray-200 w3a--bg-transparent w3a--px-5 w3a--py-2 w3a--text-base w3a--font-normal w3a--text-app-gray-700 w3a--transition-all w3a--duration-150 hover:w3a--border-transparent hover:w3a--shadow-light active:w3a--scale-95 dark:w3a--border-app-gray-700 dark:w3a--text-app-gray-300 dark:hover:w3a--border-transparent dark:hover:w3a--shadow-dark",
|
|
79
82
|
onClick: () => {
|
|
80
83
|
setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
installLinks: {
|
|
85
|
+
show: true,
|
|
86
|
+
wallet: selectedButton
|
|
87
|
+
}
|
|
83
88
|
}));
|
|
84
89
|
},
|
|
85
90
|
children: t("modal.external.get-wallet")
|
|
@@ -51,6 +51,7 @@ function Login(props) {
|
|
|
51
51
|
setBodyState
|
|
52
52
|
} = useContext(RootContext);
|
|
53
53
|
const [countryCode, setCountryCode] = useState("");
|
|
54
|
+
const [countryFlag, setCountryFlag] = useState("");
|
|
54
55
|
const [passwordlessErrorMessage, setPasswordlessErrorMessage] = useState("");
|
|
55
56
|
const [otpErrorMessage, setOtpErrorMessage] = useState("");
|
|
56
57
|
const [expand, setExpand] = useState(false);
|
|
@@ -215,8 +216,8 @@ function Login(props) {
|
|
|
215
216
|
if (isSmsPasswordLessLoginVisible) {
|
|
216
217
|
const number = loginHint.startsWith("+") ? loginHint : `${countryCode}${loginHint}`;
|
|
217
218
|
const result = await validatePhoneNumber(number);
|
|
218
|
-
if (result) {
|
|
219
|
-
const finalLoginHint = typeof result === "string" ? result : number;
|
|
219
|
+
if (result.success) {
|
|
220
|
+
const finalLoginHint = typeof result.parsed_number === "string" ? result.parsed_number : number;
|
|
220
221
|
const connectorConfig = socialLoginsConfig.loginMethods[AUTH_CONNECTION.SMS_PASSWORDLESS];
|
|
221
222
|
if (connectorConfig.isDefault) {
|
|
222
223
|
return handleSocialLoginClick({
|
|
@@ -231,6 +232,7 @@ function Login(props) {
|
|
|
231
232
|
}
|
|
232
233
|
});
|
|
233
234
|
} else {
|
|
235
|
+
setCountryFlag(result.country_flag);
|
|
234
236
|
return handleCustomLogin(AUTH_CONNECTION.SMS_PASSWORDLESS, finalLoginHint);
|
|
235
237
|
}
|
|
236
238
|
}
|
|
@@ -303,11 +305,24 @@ function Login(props) {
|
|
|
303
305
|
};
|
|
304
306
|
const handleInstalledWalletClick = wallet => {
|
|
305
307
|
var _wallet$chainNamespac;
|
|
308
|
+
// for non-injected Metamask, show QR code to connect
|
|
309
|
+
if (wallet.name === WALLET_CONNECTORS.METAMASK && !wallet.hasInjectedWallet) {
|
|
310
|
+
setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
|
|
311
|
+
metamaskQrCode: {
|
|
312
|
+
show: true,
|
|
313
|
+
wallet: wallet
|
|
314
|
+
}
|
|
315
|
+
}));
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
306
319
|
// when having multiple namespaces, ask user to select one
|
|
307
320
|
if (((_wallet$chainNamespac = wallet.chainNamespaces) === null || _wallet$chainNamespac === void 0 ? void 0 : _wallet$chainNamespac.length) > 1) {
|
|
308
321
|
setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
|
|
309
|
-
|
|
310
|
-
|
|
322
|
+
multiChainSelector: {
|
|
323
|
+
show: true,
|
|
324
|
+
wallet: wallet
|
|
325
|
+
}
|
|
311
326
|
}));
|
|
312
327
|
} else {
|
|
313
328
|
handleExternalWalletClick({
|
|
@@ -327,7 +342,8 @@ function Login(props) {
|
|
|
327
342
|
setShowOtpFlow: setShowOtpFlow,
|
|
328
343
|
authConnection: authConnection,
|
|
329
344
|
handleOtpComplete: handleOtpComplete,
|
|
330
|
-
errorMessage: otpErrorMessage
|
|
345
|
+
errorMessage: otpErrorMessage,
|
|
346
|
+
countryFlag: countryFlag
|
|
331
347
|
});
|
|
332
348
|
}
|
|
333
349
|
const socialLoginSection = (otherRow = []) => {
|
|
@@ -482,7 +498,7 @@ function Login(props) {
|
|
|
482
498
|
children: [/*#__PURE__*/jsxs("div", {
|
|
483
499
|
className: cn("w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2 w3a--pt-6", logoAlignment === "center" ? "" : "w3a--w-full"),
|
|
484
500
|
children: [/*#__PURE__*/jsx("figure", {
|
|
485
|
-
className: cn("w3a--mx-auto w3a--h-12 w3a--w-[200px]", logoAlignment === "center" ? "w3a--flex w3a--justify-center w3a--items-center" : "w3a--ml-0"),
|
|
501
|
+
className: cn("w3a--mx-auto w3a--h-12 w3a--w-[200px]", logoAlignment === "center" ? "w3a--flex w3a--justify-center w3a--items-center" : "w3a--ml-0 w3a--w-auto"),
|
|
486
502
|
children: /*#__PURE__*/jsx("img", {
|
|
487
503
|
src: headerLogo || getIcons(isDark ? "logo-dark" : "logo-light"),
|
|
488
504
|
alt: "Logo",
|
|
@@ -18,7 +18,8 @@ function OtpInput(props) {
|
|
|
18
18
|
authConnection,
|
|
19
19
|
loginHint = "",
|
|
20
20
|
errorMessage,
|
|
21
|
-
otpLoading
|
|
21
|
+
otpLoading,
|
|
22
|
+
countryFlag
|
|
22
23
|
} = props;
|
|
23
24
|
const isMobileOtp = useMemo(() => authConnection === AUTH_CONNECTION.SMS_PASSWORDLESS, [authConnection]);
|
|
24
25
|
const [t] = useTranslation(undefined, {
|
|
@@ -28,8 +29,8 @@ function OtpInput(props) {
|
|
|
28
29
|
if (authConnection === AUTH_CONNECTION.EMAIL_PASSWORDLESS) return loginHint;
|
|
29
30
|
const [countryCode, number] = loginHint.includes("-") ? loginHint.split("-") : ["", loginHint];
|
|
30
31
|
const masked = `${number}`.slice(-Math.floor(number.length / 2)).padStart(`${number}`.length, "*");
|
|
31
|
-
return `${countryCode} ${masked}`;
|
|
32
|
-
}, [loginHint, authConnection]);
|
|
32
|
+
return `${countryFlag} ${countryCode} ${masked}`;
|
|
33
|
+
}, [loginHint, authConnection, countryFlag]);
|
|
33
34
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
34
35
|
children: [/*#__PURE__*/jsx("div", {
|
|
35
36
|
className: "w3a--mr-auto w3a--flex w3a--w-full w3a--items-start w3a--justify-start",
|
|
@@ -57,17 +58,17 @@ function OtpInput(props) {
|
|
|
57
58
|
alt: "otp",
|
|
58
59
|
className: "w3a--size-auto"
|
|
59
60
|
}), /*#__PURE__*/jsxs("div", {
|
|
60
|
-
className: "-w3a--mt-6 w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2",
|
|
61
|
+
className: "w3a--mx-auto -w3a--mt-6 w3a--flex w3a--w-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2",
|
|
61
62
|
children: [/*#__PURE__*/jsx("p", {
|
|
62
63
|
className: "w3a--text-lg w3a--font-bold w3a--text-app-gray-900 dark:w3a--text-app-white",
|
|
63
64
|
children: isMobileOtp ? t("modal.otp.mobile-title") : t("modal.otp.email-title")
|
|
64
65
|
}), /*#__PURE__*/jsxs("div", {
|
|
65
|
-
className: "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-1",
|
|
66
|
+
className: "w3a--mx-auto w3a--flex w3a--w-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-1",
|
|
66
67
|
children: [/*#__PURE__*/jsx("p", {
|
|
67
|
-
className: "w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
|
|
68
|
+
className: "w3a--text-center w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
|
|
68
69
|
children: isMobileOtp ? t("modal.otp.mobile-subtext") : t("modal.otp.email-subtext")
|
|
69
70
|
}), /*#__PURE__*/jsx("p", {
|
|
70
|
-
className: "w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
|
|
71
|
+
className: "w3a--text-center w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
|
|
71
72
|
children: isMobileOtp ? parsedLoginHint : t("modal.otp.email-subtext-example", {
|
|
72
73
|
email: parsedLoginHint
|
|
73
74
|
})
|
|
@@ -97,7 +98,8 @@ function LoginOtp(props) {
|
|
|
97
98
|
handleOtpComplete,
|
|
98
99
|
authConnection,
|
|
99
100
|
loginHint,
|
|
100
|
-
errorMessage
|
|
101
|
+
errorMessage,
|
|
102
|
+
countryFlag
|
|
101
103
|
} = props;
|
|
102
104
|
return /*#__PURE__*/jsx("div", {
|
|
103
105
|
className: "w3a--flex w3a--size-full w3a--flex-1 w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4",
|
|
@@ -107,7 +109,8 @@ function LoginOtp(props) {
|
|
|
107
109
|
handleOtpComplete: handleOtpComplete,
|
|
108
110
|
authConnection: authConnection,
|
|
109
111
|
loginHint: loginHint,
|
|
110
|
-
otpLoading: otpLoading
|
|
112
|
+
otpLoading: otpLoading,
|
|
113
|
+
countryFlag: countryFlag
|
|
111
114
|
})
|
|
112
115
|
});
|
|
113
116
|
}
|