@web3auth/modal 10.0.0-beta.6 → 10.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/lib.cjs/packages/modal/src/config.js +1 -1
  2. package/dist/lib.cjs/packages/modal/src/modalManager.js +33 -5
  3. package/dist/lib.cjs/packages/modal/src/react/hooks/useWalletServicesPlugin.js +2 -1
  4. package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthConnect.js +5 -1
  5. package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignAndSendTransaction.js +2 -1
  6. package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignMessage.js +2 -1
  7. package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignTransaction.js +2 -0
  8. package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSolanaWallet.js +12 -5
  9. package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +2 -1
  10. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +21 -15
  11. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +12 -7
  12. package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +20 -5
  13. package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +12 -9
  14. package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +151 -81
  15. package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +11 -1
  16. package/dist/lib.cjs/packages/modal/src/ui/constants.js +26 -0
  17. package/dist/lib.cjs/packages/modal/src/ui/context/RootContext.js +12 -3
  18. package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +1 -1
  19. package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +24 -15
  20. package/dist/lib.cjs/packages/modal/src/ui/utils.js +16 -4
  21. package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletServicesPlugin.js +2 -1
  22. package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthConnect.js +4 -0
  23. package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +36 -0
  24. package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignMessage.js +38 -0
  25. package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignTransaction.js +36 -0
  26. package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSolanaWallet.js +46 -0
  27. package/dist/lib.cjs/packages/modal/src/vue/solana/index.js +13 -0
  28. package/dist/lib.cjs/packages/modal/src/vue/wagmi/index.js +7 -0
  29. package/dist/lib.cjs/packages/modal/src/vue/wagmi/provider.js +218 -0
  30. package/dist/lib.cjs/types/interface.d.ts +1 -1
  31. package/dist/lib.cjs/types/react/solana/hooks/useSignTransaction.d.ts +1 -1
  32. package/dist/lib.cjs/types/react/solana/hooks/useSolanaWallet.d.ts +2 -0
  33. package/dist/lib.cjs/types/react/wagmi/index.d.ts +1 -0
  34. package/dist/lib.cjs/types/react/wagmi/interface.d.ts +1 -1
  35. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.type.d.ts +1 -0
  36. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.type.d.ts +3 -4
  37. package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.type.d.ts +3 -2
  38. package/dist/lib.cjs/types/ui/constants.d.ts +2 -0
  39. package/dist/lib.cjs/types/ui/context/RootContext.d.ts +12 -3
  40. package/dist/lib.cjs/types/ui/interfaces.d.ts +6 -0
  41. package/dist/lib.cjs/types/ui/loginModal.d.ts +1 -1
  42. package/dist/lib.cjs/types/ui/utils.d.ts +2 -2
  43. package/dist/lib.cjs/types/vue/solana/composables/index.d.ts +4 -0
  44. package/dist/lib.cjs/types/vue/solana/composables/useSignAndSendTransaction.d.ts +9 -0
  45. package/dist/lib.cjs/types/vue/solana/composables/useSignMessage.d.ts +9 -0
  46. package/dist/lib.cjs/types/vue/solana/composables/useSignTransaction.d.ts +9 -0
  47. package/dist/lib.cjs/types/vue/solana/composables/useSolanaWallet.d.ts +9 -0
  48. package/dist/lib.cjs/types/vue/solana/index.d.ts +1 -0
  49. package/dist/lib.cjs/types/vue/wagmi/index.d.ts +2 -0
  50. package/dist/lib.cjs/types/vue/wagmi/interface.d.ts +4 -0
  51. package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +16 -0
  52. package/dist/lib.esm/packages/modal/src/config.js +1 -1
  53. package/dist/lib.esm/packages/modal/src/modalManager.js +36 -5
  54. package/dist/lib.esm/packages/modal/src/react/hooks/useWalletServicesPlugin.js +2 -1
  55. package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthConnect.js +5 -1
  56. package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignAndSendTransaction.js +2 -1
  57. package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignMessage.js +2 -1
  58. package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignTransaction.js +2 -0
  59. package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSolanaWallet.js +12 -5
  60. package/dist/lib.esm/packages/modal/src/react/wagmi/provider.js +2 -1
  61. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +21 -15
  62. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +13 -8
  63. package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +21 -5
  64. package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +12 -9
  65. package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +154 -82
  66. package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +12 -1
  67. package/dist/lib.esm/packages/modal/src/ui/constants.js +26 -1
  68. package/dist/lib.esm/packages/modal/src/ui/context/RootContext.js +12 -3
  69. package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +1 -1
  70. package/dist/lib.esm/packages/modal/src/ui/loginModal.js +24 -15
  71. package/dist/lib.esm/packages/modal/src/ui/utils.js +16 -4
  72. package/dist/lib.esm/packages/modal/src/vue/composables/useWalletServicesPlugin.js +2 -1
  73. package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthConnect.js +4 -0
  74. package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +34 -0
  75. package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignMessage.js +36 -0
  76. package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignTransaction.js +34 -0
  77. package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSolanaWallet.js +44 -0
  78. package/dist/lib.esm/packages/modal/src/vue/solana/index.js +4 -0
  79. package/dist/lib.esm/packages/modal/src/vue/wagmi/index.js +1 -0
  80. package/dist/lib.esm/packages/modal/src/vue/wagmi/provider.js +219 -0
  81. package/dist/modal.umd.min.js +1 -1
  82. package/dist/modal.umd.min.js.LICENSE.txt +2 -26
  83. package/package.json +40 -15
@@ -2,7 +2,7 @@
2
2
 
3
3
  var noModal = require('@web3auth/no-modal');
4
4
 
5
- const version = "10.0.0-beta.6";
5
+ const version = "10.0.0-beta.8";
6
6
  const defaultConnectorsModalConfig = {
7
7
  hideWalletDiscovery: false,
8
8
  connectors: {
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
4
4
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
5
+ var auth = require('@web3auth/auth');
5
6
  var noModal = require('@web3auth/no-modal');
6
7
  var deepmerge = require('deepmerge');
7
8
  var config = require('./config.js');
@@ -41,6 +42,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
41
42
  _defineProperty(this, "onModalVisibility", async visibility => {
42
43
  noModal.log.debug("is login modal visible", visibility);
43
44
  this.emit(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility);
45
+ // handle WC session refresh
44
46
  const wcConnector = this.getConnector(noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2);
45
47
  if (wcConnector) {
46
48
  const walletConnectStatus = wcConnector === null || wcConnector === void 0 ? void 0 : wcConnector.status;
@@ -62,6 +64,28 @@ class Web3Auth extends noModal.Web3AuthNoModal {
62
64
  wcConnector.status = noModal.CONNECTOR_STATUS.READY;
63
65
  }
64
66
  }
67
+ // handle MM session refresh if MM is not injected
68
+ const metamaskConnector = this.getConnector(noModal.WALLET_CONNECTORS.METAMASK);
69
+ if (metamaskConnector && !metamaskConnector.isInjected) {
70
+ const status = metamaskConnector === null || metamaskConnector === void 0 ? void 0 : metamaskConnector.status;
71
+ noModal.log.debug("trying refreshing MM session", visibility, status);
72
+ if (visibility && (status === noModal.CONNECTOR_STATUS.READY || status === noModal.CONNECTOR_STATUS.CONNECTING)) {
73
+ noModal.log.debug("refreshing MM session");
74
+ // refreshing session for MM whenever modal is opened.
75
+ try {
76
+ const initialChain = this.getInitialChainIdForConnector(metamaskConnector);
77
+ metamaskConnector.connect({
78
+ chainId: initialChain.chainId
79
+ });
80
+ } catch (error) {
81
+ noModal.log.error(`Error while connecting to MM`, error);
82
+ }
83
+ }
84
+ if (!visibility && this.status === noModal.CONNECTOR_STATUS.CONNECTED && (status === noModal.CONNECTOR_STATUS.READY || status === noModal.CONNECTOR_STATUS.CONNECTING)) {
85
+ noModal.log.debug("this stops MM connector from trying to reconnect once proposal expires");
86
+ metamaskConnector.status = noModal.CONNECTOR_STATUS.READY;
87
+ }
88
+ }
65
89
  });
66
90
  _defineProperty(this, "getChainNamespaces", () => {
67
91
  var _this$coreOptions$cha;
@@ -126,7 +150,8 @@ class Web3Auth extends noModal.Web3AuthNoModal {
126
150
  }), signal, onAbortHandler);
127
151
  });
128
152
  await noModal.withAbort(() => super.loadConnectors({
129
- projectConfig
153
+ projectConfig,
154
+ modalMode: true
130
155
  }), signal);
131
156
  // initialize plugins
132
157
  await noModal.withAbort(() => super.initPlugins(), signal);
@@ -199,8 +224,9 @@ class Web3Auth extends noModal.Web3AuthNoModal {
199
224
  }), noModal.fetchWalletRegistry(config.walletRegistryUrl)]);
200
225
  // handle project config result
201
226
  if (projectConfigResult.status === "rejected") {
202
- noModal.log.error("Failed to fetch project configurations", projectConfigResult.reason);
203
- throw noModal.WalletInitializationError.notReady("failed to fetch project configurations", projectConfigResult.reason);
227
+ const error = await auth.serializeError(projectConfigResult.reason);
228
+ noModal.log.error("Failed to fetch project configurations", error);
229
+ throw noModal.WalletInitializationError.notReady("failed to fetch project configurations", error);
204
230
  }
205
231
  const projectConfig = projectConfigResult.value;
206
232
  // handle wallet registry result
@@ -225,7 +251,9 @@ class Web3Auth extends noModal.Web3AuthNoModal {
225
251
  this.options.uiConfig = deepmerge(noModal.cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
226
252
  if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = utils.getUserLanguage(this.options.uiConfig.defaultLanguage);
227
253
  if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
228
- this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig);
254
+ this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig, {
255
+ arrayMerge: (_, sourceArray) => sourceArray
256
+ });
229
257
  // merge login methods order from project config and user config, with user config taking precedence
230
258
  const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter(x => x.isDefault).map(x => x.authConnection);
231
259
  const mergedAuthConnections = [...(this.options.uiConfig.loginMethodsOrder || []), ...defaultAuthConnections];
@@ -413,7 +441,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
413
441
  // skip if connector is already initialized
414
442
  if (connector.status !== noModal.CONNECTOR_STATUS.NOT_READY) return;
415
443
  // only initialize a external connectors here if it is a cached connector.
416
- if (this.cachedConnector !== connectorName && connectorName !== noModal.WALLET_CONNECTORS.METAMASK && connector.type === noModal.CONNECTOR_CATEGORY.EXTERNAL) return;
444
+ if (this.cachedConnector !== connectorName && connector.type === noModal.CONNECTOR_CATEGORY.EXTERNAL) return;
417
445
  // in-app wallets or cached wallet (being connected or already connected) are initialized first.
418
446
  // if connector is configured then only initialize in app or cached connector.
419
447
  // external wallets are initialized on INIT_EXTERNAL_WALLET event.
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var noModal = require('@web3auth/no-modal');
3
4
  var react = require('react');
4
5
  var WalletServicesInnerContext = require('../context/WalletServicesInnerContext.js');
5
6
 
6
7
  const useWalletServicesPlugin = () => {
7
8
  const context = react.useContext(WalletServicesInnerContext.WalletServicesContext);
8
- if (!context) throw new Error("WalletServicesContext not found");
9
+ if (!context) throw noModal.WalletInitializationError.fromCode(1000, "usage of useWalletServicesPlugin not wrapped in `WalletServicesContextProvider`.");
9
10
  return context;
10
11
  };
11
12
 
@@ -12,10 +12,14 @@ const useWeb3AuthConnect = () => {
12
12
  const [error, setError] = react.useState(null);
13
13
  const [connectorName, setConnectorName] = react.useState(null);
14
14
  react.useEffect(() => {
15
+ if (!web3Auth) return;
15
16
  if (!isConnected && connectorName) {
16
17
  setConnectorName(null);
17
18
  }
18
- }, [isConnected, connectorName]);
19
+ if (isConnected && !connectorName) {
20
+ setConnectorName(web3Auth.connectedConnectorName);
21
+ }
22
+ }, [isConnected, connectorName, web3Auth]);
19
23
  const connect = react.useCallback(async () => {
20
24
  setLoading(true);
21
25
  setError(null);
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var noModal = require('@web3auth/no-modal');
3
4
  var react = require('react');
4
5
  var useSolanaWallet = require('./useSolanaWallet.js');
5
6
 
@@ -14,7 +15,7 @@ const useSignAndSendTransaction = () => {
14
15
  setLoading(true);
15
16
  setError(null);
16
17
  try {
17
- if (!solanaWallet) throw new Error("Solana wallet not found");
18
+ if (!solanaWallet) throw noModal.WalletInitializationError.notReady();
18
19
  const signature = await solanaWallet.signAndSendTransaction(transaction);
19
20
  setData(signature);
20
21
  return signature;
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var noModal = require('@web3auth/no-modal');
3
4
  var react = require('react');
4
5
  var useSolanaWallet = require('./useSolanaWallet.js');
5
6
 
@@ -15,7 +16,7 @@ const useSignMessage = () => {
15
16
  setLoading(true);
16
17
  setError(null);
17
18
  try {
18
- if (!solanaWallet) throw new Error("Solana wallet not found");
19
+ if (!solanaWallet) throw noModal.WalletInitializationError.notReady();
19
20
  const signature = await solanaWallet.signMessage(message, from !== null && from !== void 0 ? from : accounts === null || accounts === void 0 ? void 0 : accounts[0]);
20
21
  setData(signature);
21
22
  return signature;
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var noModal = require('@web3auth/no-modal');
3
4
  var react = require('react');
4
5
  var useSolanaWallet = require('./useSolanaWallet.js');
5
6
 
@@ -14,6 +15,7 @@ const useSignTransaction = () => {
14
15
  setLoading(true);
15
16
  setError(null);
16
17
  try {
18
+ if (!solanaWallet) throw noModal.WalletInitializationError.notReady();
17
19
  const signedTransaction = await solanaWallet.signTransaction(transaction);
18
20
  setData(signedTransaction);
19
21
  return signedTransaction;
@@ -1,31 +1,38 @@
1
1
  'use strict';
2
2
 
3
+ var web3_js = require('@solana/web3.js');
3
4
  var noModal = require('@web3auth/no-modal');
4
5
  var react = require('react');
5
6
  var useWeb3Auth = require('../../hooks/useWeb3Auth.js');
6
7
 
7
8
  const useSolanaWallet = () => {
8
9
  const {
9
- provider
10
+ provider,
11
+ web3Auth
10
12
  } = useWeb3Auth.useWeb3Auth();
11
13
  const [accounts, setAccounts] = react.useState(null);
12
14
  const solanaWallet = react.useMemo(() => {
13
15
  if (!provider) return null;
14
16
  return new noModal.SolanaWallet(provider);
15
17
  }, [provider]);
18
+ const connection = react.useMemo(() => {
19
+ if (!web3Auth || !provider) return null;
20
+ return new web3_js.Connection(web3Auth.currentChain.rpcTarget);
21
+ }, [web3Auth, provider]);
16
22
  react.useEffect(() => {
17
- const fetchAccounts = async () => {
23
+ const init = async () => {
18
24
  if (!solanaWallet) return;
19
25
  const accounts = await solanaWallet.requestAccounts();
20
26
  if ((accounts === null || accounts === void 0 ? void 0 : accounts.length) > 0) {
21
27
  setAccounts(accounts);
22
28
  }
23
29
  };
24
- if (solanaWallet) fetchAccounts();
25
- }, [solanaWallet]);
30
+ if (solanaWallet) init();
31
+ }, [solanaWallet, web3Auth]);
26
32
  return {
27
33
  solanaWallet,
28
- accounts
34
+ accounts,
35
+ connection
29
36
  };
30
37
  };
31
38
 
@@ -8,13 +8,13 @@ var viem = require('viem');
8
8
  var wagmi = require('wagmi');
9
9
  var connectors = require('wagmi/connectors');
10
10
  require('@babel/runtime/helpers/defineProperty');
11
+ require('@web3auth/auth');
11
12
  require('deepmerge');
12
13
  require('../../config.js');
13
14
  require('../../ui/config.js');
14
15
  require('../../ui/interfaces.js');
15
16
  require('react/jsx-runtime');
16
17
  require('../../ui/css/index.css.js');
17
- require('@web3auth/auth');
18
18
  require('react-dom/client');
19
19
  require('@toruslabs/http-helpers');
20
20
  require('clsx');
@@ -100,6 +100,7 @@ function Web3AuthWagmiProvider({
100
100
  if (isConnected && provider) {
101
101
  const connector = await setupConnector(provider, wagmiConfig);
102
102
  if (!connector) {
103
+ noModal.log.error("Failed to setup react wagmi connector");
103
104
  throw new Error("Failed to setup connector");
104
105
  }
105
106
  await connectWeb3AuthWithWagmi(connector, wagmiConfig);
@@ -18,6 +18,7 @@ function ConnectWallet(props) {
18
18
  isDark,
19
19
  config,
20
20
  walletConnectUri,
21
+ metamaskConnectUri,
21
22
  walletRegistry,
22
23
  allExternalButtons,
23
24
  customConnectorButtons,
@@ -31,9 +32,7 @@ function ConnectWallet(props) {
31
32
  } = props;
32
33
  const {
33
34
  bodyState,
34
- setBodyState,
35
- toast,
36
- setToast
35
+ setBodyState
37
36
  } = react.useContext(RootContext.RootContext);
38
37
  const [currentPage, setCurrentPage] = react.useState(constants.CONNECT_WALLET_PAGES.CONNECT_WALLET);
39
38
  const [selectedWallet, setSelectedWallet] = react.useState(false);
@@ -68,7 +67,7 @@ function ConnectWallet(props) {
68
67
  const defaultButtonKeys = react.useMemo(() => new Set(Object.keys(walletRegistry.default)), [walletRegistry]);
69
68
  const defaultButtons = react.useMemo(() => {
70
69
  // display order: default injected buttons > custom adapter buttons > default non-injected buttons
71
- const buttons = [...allExternalButtons.filter(button => button.hasInjectedWallet && defaultButtonKeys.has(button.name)), ...customConnectorButtons, ...allExternalButtons.filter(button => !button.hasInjectedWallet && defaultButtonKeys.has(button.name))];
70
+ 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 === noModal.WALLET_CONNECTORS.METAMASK ? -1 : 1);
72
71
  const buttonSet = new Set();
73
72
  return buttons.filter(button => {
74
73
  if (buttonSet.has(button.name)) return false;
@@ -104,7 +103,7 @@ function ConnectWallet(props) {
104
103
  };
105
104
  const filteredButtons = react.useMemo(() => {
106
105
  if (walletDiscoverySupported) {
107
- 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()));
106
+ return [...allUniqueButtons.filter(button => button.hasInjectedWallet), ...allUniqueButtons.filter(button => !button.hasInjectedWallet)].sort((a, _) => a.name === noModal.WALLET_CONNECTORS.METAMASK ? -1 : 1).filter(button => selectedChain === "all" || button.chainNamespaces.includes(selectedChain)).filter(button => button.name.toLowerCase().includes(walletSearch.toLowerCase()));
108
107
  }
109
108
  return installedWalletButtons;
110
109
  }, [walletDiscoverySupported, installedWalletButtons, walletSearch, allUniqueButtons, selectedChain]);
@@ -125,8 +124,10 @@ function ConnectWallet(props) {
125
124
  const isChainNamespaceSelectorRequired = button.hasInjectedWallet && ((_button$chainNamespac2 = button.chainNamespaces) === null || _button$chainNamespac2 === void 0 ? void 0 : _button$chainNamespac2.length) > 1;
126
125
  if (isChainNamespaceSelectorRequired) {
127
126
  setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
128
- showMultiChainSelector: true,
129
- walletDetails: button
127
+ multiChainSelector: {
128
+ show: true,
129
+ wallet: button
130
+ }
130
131
  }));
131
132
  return;
132
133
  }
@@ -145,14 +146,23 @@ function ConnectWallet(props) {
145
146
  handleWalletDetailsHeight();
146
147
  } else {
147
148
  setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
148
- showWalletDetails: true,
149
- walletDetails: button
149
+ installLinks: {
150
+ show: true,
151
+ wallet: button
152
+ }
150
153
  }));
151
154
  }
152
155
  };
153
156
  const handleMoreWallets = () => {
154
157
  setIsShowAllWallets(true);
155
158
  };
159
+ const qrCodeValue = react.useMemo(() => {
160
+ if (!selectedWallet) return null;
161
+ if (selectedButton.name === noModal.WALLET_CONNECTORS.METAMASK && !selectedButton.hasInjectedWallet) {
162
+ return metamaskConnectUri;
163
+ }
164
+ return walletConnectUri;
165
+ }, [metamaskConnectUri, selectedButton, selectedWallet, walletConnectUri]);
156
166
  return jsxRuntime.jsxs("div", {
157
167
  className: "w3a--relative w3a--flex w3a--flex-1 w3a--flex-col w3a--gap-y-4",
158
168
  children: [jsxRuntime.jsx(ConnectWalletHeader, {
@@ -160,15 +170,11 @@ function ConnectWallet(props) {
160
170
  currentPage: currentPage,
161
171
  selectedButton: selectedButton
162
172
  }), selectedWallet ? jsxRuntime.jsx(ConnectWalletQrCode, {
163
- toast: toast,
164
- setToast: setToast,
165
- walletConnectUri: walletConnectUri,
173
+ qrCodeValue: qrCodeValue,
166
174
  isDark: isDark,
167
175
  selectedButton: selectedButton,
168
- bodyState: bodyState,
169
176
  primaryColor: (_selectedButton$walle = selectedButton.walletRegistryItem) === null || _selectedButton$walle === void 0 ? void 0 : _selectedButton$walle.primaryColor,
170
- logoImage: `https://images.web3auth.io/login-${selectedButton.name}.${selectedButton.imgExtension}`,
171
- setBodyState: setBodyState
177
+ logoImage: `https://images.web3auth.io/login-${selectedButton.name}.${selectedButton.imgExtension}`
172
178
  }) : jsxRuntime.jsxs("div", {
173
179
  className: "w3a--flex w3a--flex-col w3a--gap-y-2",
174
180
  children: [jsxRuntime.jsx(ConnectWalletChainFilter, {
@@ -7,6 +7,7 @@ var react = require('react');
7
7
  var reactI18next = require('react-i18next');
8
8
  var reactQrcodeLogo = require('react-qrcode-logo');
9
9
  var constants = require('../../../constants.js');
10
+ var RootContext = require('../../../context/RootContext.js');
10
11
  var localeImport = require('../../../localeImport.js');
11
12
  var Image = require('../../Image/Image.js');
12
13
 
@@ -16,11 +17,13 @@ function ConnectWalletQrCode(props) {
16
17
  i18n: localeImport
17
18
  });
18
19
  const {
19
- walletConnectUri,
20
+ bodyState,
21
+ setBodyState
22
+ } = react.useContext(RootContext.RootContext);
23
+ const {
24
+ qrCodeValue,
20
25
  isDark,
21
26
  selectedButton,
22
- setBodyState,
23
- bodyState,
24
27
  logoImage,
25
28
  primaryColor
26
29
  } = props;
@@ -35,7 +38,7 @@ function ConnectWalletQrCode(props) {
35
38
  const qrColor = primaryColor && primaryColor.toLowerCase() === "#ffffff" ? "#000000" : primaryColor;
36
39
  return jsxRuntime.jsxs("div", {
37
40
  className: "w3a--contents",
38
- children: [walletConnectUri ? jsxRuntime.jsxs("div", {
41
+ children: [qrCodeValue ? jsxRuntime.jsxs("div", {
39
42
  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",
40
43
  children: [jsxRuntime.jsx("div", {
41
44
  className: "w3a--relative w3a--flex w3a--size-[300px] w3a--items-center w3a--justify-center w3a--rounded-2xl",
@@ -45,7 +48,7 @@ function ConnectWalletQrCode(props) {
45
48
  qrStyle: "dots",
46
49
  removeQrCodeBehindLogo: true,
47
50
  logoImage: logoImage || constants.WALLET_CONNECT_LOGO,
48
- value: walletConnectUri,
51
+ value: qrCodeValue,
49
52
  logoHeight: 32,
50
53
  logoWidth: 32,
51
54
  logoPadding: 10,
@@ -80,8 +83,10 @@ function ConnectWalletQrCode(props) {
80
83
  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",
81
84
  onClick: () => {
82
85
  setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
83
- showWalletDetails: true,
84
- walletDetails: selectedButton
86
+ installLinks: {
87
+ show: true,
88
+ wallet: selectedButton
89
+ }
85
90
  }));
86
91
  },
87
92
  children: t("modal.external.get-wallet")
@@ -53,6 +53,7 @@ function Login(props) {
53
53
  setBodyState
54
54
  } = react.useContext(RootContext.RootContext);
55
55
  const [countryCode, setCountryCode] = react.useState("");
56
+ const [countryFlag, setCountryFlag] = react.useState("");
56
57
  const [passwordlessErrorMessage, setPasswordlessErrorMessage] = react.useState("");
57
58
  const [otpErrorMessage, setOtpErrorMessage] = react.useState("");
58
59
  const [expand, setExpand] = react.useState(false);
@@ -214,8 +215,8 @@ function Login(props) {
214
215
  if (isSmsPasswordLessLoginVisible) {
215
216
  const number = loginHint.startsWith("+") ? loginHint : `${countryCode}${loginHint}`;
216
217
  const result = await utils.validatePhoneNumber(number);
217
- if (result) {
218
- const finalLoginHint = typeof result === "string" ? result : number;
218
+ if (result.success) {
219
+ const finalLoginHint = typeof result.parsed_number === "string" ? result.parsed_number : number;
219
220
  const connectorConfig = socialLoginsConfig.loginMethods[auth.AUTH_CONNECTION.SMS_PASSWORDLESS];
220
221
  if (connectorConfig.isDefault) {
221
222
  return handleSocialLoginClick({
@@ -230,6 +231,7 @@ function Login(props) {
230
231
  }
231
232
  });
232
233
  } else {
234
+ setCountryFlag(result.country_flag);
233
235
  return handleCustomLogin(auth.AUTH_CONNECTION.SMS_PASSWORDLESS, finalLoginHint);
234
236
  }
235
237
  }
@@ -302,11 +304,23 @@ function Login(props) {
302
304
  };
303
305
  const handleInstalledWalletClick = wallet => {
304
306
  var _wallet$chainNamespac;
307
+ // for non-injected Metamask, show QR code to connect
308
+ if (wallet.name === noModal.WALLET_CONNECTORS.METAMASK && !wallet.hasInjectedWallet) {
309
+ setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
310
+ metamaskQrCode: {
311
+ show: true,
312
+ wallet: wallet
313
+ }
314
+ }));
315
+ return;
316
+ }
305
317
  // when having multiple namespaces, ask user to select one
306
318
  if (((_wallet$chainNamespac = wallet.chainNamespaces) === null || _wallet$chainNamespac === void 0 ? void 0 : _wallet$chainNamespac.length) > 1) {
307
319
  setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
308
- showMultiChainSelector: true,
309
- walletDetails: wallet
320
+ multiChainSelector: {
321
+ show: true,
322
+ wallet: wallet
323
+ }
310
324
  }));
311
325
  } else {
312
326
  handleExternalWalletClick({
@@ -326,7 +340,8 @@ function Login(props) {
326
340
  setShowOtpFlow: setShowOtpFlow,
327
341
  authConnection: authConnection,
328
342
  handleOtpComplete: handleOtpComplete,
329
- errorMessage: otpErrorMessage
343
+ errorMessage: otpErrorMessage,
344
+ countryFlag: countryFlag
330
345
  });
331
346
  }
332
347
  const socialLoginSection = (otherRow = []) => {
@@ -20,7 +20,8 @@ function OtpInput(props) {
20
20
  authConnection,
21
21
  loginHint = "",
22
22
  errorMessage,
23
- otpLoading
23
+ otpLoading,
24
+ countryFlag
24
25
  } = props;
25
26
  const isMobileOtp = react.useMemo(() => authConnection === auth.AUTH_CONNECTION.SMS_PASSWORDLESS, [authConnection]);
26
27
  const [t] = reactI18next.useTranslation(undefined, {
@@ -30,8 +31,8 @@ function OtpInput(props) {
30
31
  if (authConnection === auth.AUTH_CONNECTION.EMAIL_PASSWORDLESS) return loginHint;
31
32
  const [countryCode, number] = loginHint.includes("-") ? loginHint.split("-") : ["", loginHint];
32
33
  const masked = `${number}`.slice(-Math.floor(number.length / 2)).padStart(`${number}`.length, "*");
33
- return `${countryCode} ${masked}`;
34
- }, [loginHint, authConnection]);
34
+ return `${countryFlag} ${countryCode} ${masked}`;
35
+ }, [loginHint, authConnection, countryFlag]);
35
36
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
36
37
  children: [jsxRuntime.jsx("div", {
37
38
  className: "w3a--mr-auto w3a--flex w3a--w-full w3a--items-start w3a--justify-start",
@@ -59,17 +60,17 @@ function OtpInput(props) {
59
60
  alt: "otp",
60
61
  className: "w3a--size-auto"
61
62
  }), jsxRuntime.jsxs("div", {
62
- className: "-w3a--mt-6 w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2",
63
+ 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",
63
64
  children: [jsxRuntime.jsx("p", {
64
65
  className: "w3a--text-lg w3a--font-bold w3a--text-app-gray-900 dark:w3a--text-app-white",
65
66
  children: isMobileOtp ? t("modal.otp.mobile-title") : t("modal.otp.email-title")
66
67
  }), jsxRuntime.jsxs("div", {
67
- className: "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-1",
68
+ className: "w3a--mx-auto w3a--flex w3a--w-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-1",
68
69
  children: [jsxRuntime.jsx("p", {
69
- className: "w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
70
+ className: "w3a--text-center w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
70
71
  children: isMobileOtp ? t("modal.otp.mobile-subtext") : t("modal.otp.email-subtext")
71
72
  }), jsxRuntime.jsx("p", {
72
- className: "w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
73
+ className: "w3a--text-center w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
73
74
  children: isMobileOtp ? parsedLoginHint : t("modal.otp.email-subtext-example", {
74
75
  email: parsedLoginHint
75
76
  })
@@ -98,7 +99,8 @@ function LoginOtp(props) {
98
99
  handleOtpComplete,
99
100
  authConnection,
100
101
  loginHint,
101
- errorMessage
102
+ errorMessage,
103
+ countryFlag
102
104
  } = props;
103
105
  return jsxRuntime.jsx("div", {
104
106
  className: "w3a--flex w3a--size-full w3a--flex-1 w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4",
@@ -108,7 +110,8 @@ function LoginOtp(props) {
108
110
  handleOtpComplete: handleOtpComplete,
109
111
  authConnection: authConnection,
110
112
  loginHint: loginHint,
111
- otpLoading: otpLoading
113
+ otpLoading: otpLoading,
114
+ countryFlag: countryFlag
112
115
  })
113
116
  });
114
117
  }