@web3auth/modal 5.0.0-alpha.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@web3auth/modal",
3
- "version": "5.0.0-alpha.0",
3
+ "version": "5.0.0",
4
4
  "homepage": "https://github.com/Web3Auth/Web3Auth#readme",
5
5
  "license": "ISC",
6
6
  "main": "dist/modal.cjs.js",
@@ -19,23 +19,23 @@
19
19
  "pre-commit": "lint-staged --cwd ."
20
20
  },
21
21
  "dependencies": {
22
- "@web3auth/base": "^5.0.0-alpha.0",
23
- "@web3auth/metamask-adapter": "^5.0.0-alpha.0",
24
- "@web3auth/no-modal": "^5.0.0-alpha.0",
25
- "@web3auth/openlogin-adapter": "^5.0.0-alpha.0",
26
- "@web3auth/phantom-adapter": "^5.0.0-alpha.0",
27
- "@web3auth/torus-evm-adapter": "^5.0.0-alpha.0",
28
- "@web3auth/torus-solana-adapter": "^5.0.0-alpha.0",
29
- "@web3auth/ui": "^5.0.0-alpha.0",
30
- "@web3auth/wallet-connect-v1-adapter": "^5.0.0-alpha.0"
22
+ "@web3auth/base": "^5.0.0",
23
+ "@web3auth/metamask-adapter": "^5.0.0",
24
+ "@web3auth/no-modal": "^5.0.0",
25
+ "@web3auth/openlogin-adapter": "^5.0.0",
26
+ "@web3auth/phantom-adapter": "^5.0.0",
27
+ "@web3auth/torus-evm-adapter": "^5.0.0",
28
+ "@web3auth/torus-solana-adapter": "^5.0.0",
29
+ "@web3auth/ui": "^5.0.0",
30
+ "@web3auth/wallet-connect-v1-adapter": "^5.0.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@svgr/webpack": "^6.5.1",
34
34
  "@toruslabs/isomorphic-style-loader": "^5.3.3",
35
- "@toruslabs/openlogin": "^3.1.0",
35
+ "@toruslabs/openlogin": "^3.2.1",
36
36
  "css-loader": "^6.7.3",
37
37
  "postcss-prefix-selector": "^1.16.0",
38
- "style-loader": "^3.3.1",
38
+ "style-loader": "^3.3.2",
39
39
  "tailwindcss": "^3.2.7",
40
40
  "url-loader": "^4.1.1"
41
41
  },
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "f8efd80b6c25a5c9af2057ed723ca9fb7f3f8e40"
67
+ "gitHead": "8702657a42f44ff5ebc0a4be796e68a10f506dde"
68
68
  }
@@ -133,7 +133,6 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
133
133
  });
134
134
 
135
135
  this.walletAdapters[adapterName] = ad;
136
-
137
136
  return adapterName;
138
137
  } else if (adapter?.type === ADAPTER_CATEGORY.IN_APP || adapter?.type === ADAPTER_CATEGORY.EXTERNAL || adapterName === this.cachedAdapter) {
139
138
  if (!this.modalConfig.adapters?.[adapterName].showOnModal) return;
@@ -159,7 +158,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
159
158
  }
160
159
  });
161
160
 
162
- const adapterNames = await Promise.all(adapterConfigurationPromises);
161
+ let adapterNames = await Promise.all(adapterConfigurationPromises);
163
162
  const hasInAppWallets = Object.values(this.walletAdapters).some((adapter) => {
164
163
  if (adapter.type !== ADAPTER_CATEGORY.IN_APP) return false;
165
164
  if (this.modalConfig.adapters?.[adapter.name]?.showOnModal !== true) return false;
@@ -172,7 +171,13 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
172
171
  if (Object.values(mergedLoginMethods).some((method: LoginMethodConfig[keyof LoginMethodConfig]) => method.showOnModal)) return true;
173
172
  return false;
174
173
  });
175
- log.debug(hasInAppWallets, this.walletAdapters, "hasInAppWallets");
174
+ log.debug(hasInAppWallets, this.walletAdapters, adapterNames, "hasInAppWallets");
175
+
176
+ // if both wc1 and wc2 are configured, give precedence to wc2.
177
+ if (this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1] && this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V2]) {
178
+ delete this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1];
179
+ adapterNames = adapterNames.filter((ad) => ad !== WALLET_ADAPTERS.WALLET_CONNECT_V1);
180
+ }
176
181
  // Now, initialize the adapters.
177
182
  const initPromises = adapterNames.map(async (adapterName) => {
178
183
  if (!adapterName) return;
@@ -297,13 +302,19 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
297
302
  this.loginModal.on(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, async (visibility: boolean) => {
298
303
  log.debug("is login modal visible", visibility);
299
304
  this.emit(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility);
300
- const walletConnectStatus = this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1]?.status;
301
- if (visibility && walletConnectStatus === ADAPTER_STATUS.READY) {
302
- // refreshing session for wallet connect whenever modal is opened.
303
- try {
304
- this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1].connect();
305
- } catch (error) {
306
- log.error(`Error while disconnecting to wallet connect in core`, error);
305
+ const adapter = this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V2] || this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1];
306
+ if (adapter) {
307
+ const walletConnectStatus = adapter?.status;
308
+ log.debug("trying refreshing wc session", visibility, walletConnectStatus);
309
+ if (visibility && (walletConnectStatus === ADAPTER_STATUS.READY || walletConnectStatus === ADAPTER_STATUS.CONNECTING)) {
310
+ log.debug("refreshing wc session");
311
+
312
+ // refreshing session for wallet connect whenever modal is opened.
313
+ try {
314
+ adapter.connect();
315
+ } catch (error) {
316
+ log.error(`Error while disconnecting to wallet connect in core`, error);
317
+ }
307
318
  }
308
319
  }
309
320
  });