@web3auth/modal 3.0.1 → 3.0.2

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.
@@ -1,6 +1,6 @@
1
1
  import { SafeEventEmitterProvider, WALLET_ADAPTER_TYPE } from "@web3auth/base";
2
2
  import { Web3AuthCore, Web3AuthCoreOptions } from "@web3auth/core";
3
- import LoginModal from "@web3auth/ui";
3
+ import { LoginModal } from "@web3auth/ui";
4
4
  import { ModalConfig } from "./interface";
5
5
  export interface UIConfig {
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@web3auth/modal",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "homepage": "https://github.com/Web3Auth/Web3Auth#readme",
5
5
  "license": "ISC",
6
6
  "main": "dist/modal.cjs.js",
@@ -26,7 +26,7 @@
26
26
  "@web3auth/phantom-adapter": "^3.0.0",
27
27
  "@web3auth/torus-evm-adapter": "^3.0.0",
28
28
  "@web3auth/torus-solana-adapter": "^3.0.0",
29
- "@web3auth/ui": "^3.0.1",
29
+ "@web3auth/ui": "^3.0.2",
30
30
  "@web3auth/wallet-connect-v1-adapter": "^3.0.0"
31
31
  },
32
32
  "devDependencies": {
@@ -61,5 +61,5 @@
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "gitHead": "1b1cdb54ffe74f44402b381948502ec318212316"
64
+ "gitHead": "5f770a0ea28759581f32e6c85fe12c60cdae0677"
65
65
  }
@@ -12,7 +12,7 @@ import {
12
12
  WALLET_ADAPTERS,
13
13
  } from "@web3auth/base";
14
14
  import { Web3AuthCore, Web3AuthCoreOptions } from "@web3auth/core";
15
- import LoginModal, { getAdapterSocialLogins, LOGIN_MODAL_EVENTS, OPENLOGIN_PROVIDERS } from "@web3auth/ui";
15
+ import { getAdapterSocialLogins, LOGIN_MODAL_EVENTS, LoginModal, OPENLOGIN_PROVIDERS } from "@web3auth/ui";
16
16
 
17
17
  import {
18
18
  defaultEvmDappModalConfig,
@@ -261,44 +261,26 @@ export class Web3Auth extends Web3AuthCore {
261
261
  private async initExternalWalletAdapters(externalWalletsInitialized: boolean, options?: { showExternalWalletsOnly: boolean }): Promise<void> {
262
262
  if (externalWalletsInitialized) return;
263
263
  const adaptersConfig: Record<string, BaseAdapterConfig> = {};
264
- const adaptersData: Record<string, unknown> = {};
265
- const adapterPromises = Object.keys(this.walletAdapters).map(async (adapterName) => {
266
- try {
267
- const adapter = this.walletAdapters[adapterName];
268
- if (adapter?.type === ADAPTER_CATEGORY.EXTERNAL) {
269
- log.debug("init external wallet", this.cachedAdapter, adapterName);
270
- this.subscribeToAdapterEvents(adapter);
271
- // we are not initializing cached adapter here as it is already being initialized in initModal before.
272
- if (this.cachedAdapter === adapterName) {
273
- return;
274
- }
275
- if (adapter.status === ADAPTER_STATUS.NOT_READY)
276
- return await Promise.race([
277
- adapter.init({ autoConnect: this.cachedAdapter === adapterName }).then(() => {
278
- adaptersConfig[adapterName] = (this.modalConfig.adapters as Record<WALLET_ADAPTER_TYPE, ModalConfig>)[adapterName];
279
- adaptersData[adapterName] = adapter.adapterData || {};
280
- return adapterName;
281
- }),
282
- new Promise((resolve) => {
283
- setTimeout(() => {
284
- return resolve(null);
285
- }, 5000);
286
- }),
287
- ]);
264
+ Object.keys(this.walletAdapters).forEach(async (adapterName) => {
265
+ const adapter = this.walletAdapters[adapterName];
266
+ if (adapter?.type === ADAPTER_CATEGORY.EXTERNAL) {
267
+ log.debug("init external wallet", this.cachedAdapter, adapterName);
268
+ this.subscribeToAdapterEvents(adapter);
269
+ // we are not initializing cached adapter here as it is already being initialized in initModal before.
270
+ if (this.cachedAdapter === adapterName) {
271
+ return;
288
272
  }
289
- } catch (error) {
290
- log.error(error, "error while initializing adapter");
291
- }
292
- });
293
-
294
- const adapterInitResults = await Promise.all(adapterPromises);
295
- const finalAdaptersConfig: Record<WALLET_ADAPTER_TYPE, BaseAdapterConfig> = {};
296
- adapterInitResults.forEach((result: string | undefined) => {
297
- if (result) {
298
- finalAdaptersConfig[result] = adaptersConfig[result];
273
+ if (adapter.status === ADAPTER_STATUS.NOT_READY)
274
+ await adapter
275
+ .init({ autoConnect: this.cachedAdapter === adapterName })
276
+ .then(() => {
277
+ adaptersConfig[adapterName] = (this.modalConfig.adapters as Record<WALLET_ADAPTER_TYPE, ModalConfig>)[adapterName];
278
+ this.loginModal.addWalletLogins(adaptersConfig, { showExternalWalletsOnly: !!options?.showExternalWalletsOnly });
279
+ return undefined;
280
+ })
281
+ .catch((error) => log.error(error, "error while initializing adapter"));
299
282
  }
300
283
  });
301
- this.loginModal.addWalletLogins(finalAdaptersConfig, { showExternalWalletsOnly: !!options?.showExternalWalletsOnly });
302
284
  }
303
285
 
304
286
  private initializeInAppWallet(adapterName: string): void {