@web3auth/modal 10.0.0-beta.7 → 10.0.0-beta.9

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  var noModal = require('@web3auth/no-modal');
4
4
 
5
- const version = "10.0.0-beta.7";
5
+ const version = "10.0.0-beta.9";
6
6
  const defaultConnectorsModalConfig = {
7
7
  hideWalletDiscovery: false,
8
8
  connectors: {
@@ -251,7 +251,9 @@ class Web3Auth extends noModal.Web3AuthNoModal {
251
251
  this.options.uiConfig = deepmerge(noModal.cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
252
252
  if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = utils.getUserLanguage(this.options.uiConfig.defaultLanguage);
253
253
  if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
254
- this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig);
254
+ this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig, {
255
+ arrayMerge: (_, sourceArray) => sourceArray
256
+ });
255
257
  // merge login methods order from project config and user config, with user config taking precedence
256
258
  const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter(x => x.isDefault).map(x => x.authConnection);
257
259
  const mergedAuthConnections = [...(this.options.uiConfig.loginMethodsOrder || []), ...defaultAuthConnections];
@@ -21,6 +21,10 @@ const useSolanaWallet = () => {
21
21
  }, [web3Auth, provider]);
22
22
  react.useEffect(() => {
23
23
  const init = async () => {
24
+ var _web3Auth$currentChai;
25
+ if (!(web3Auth !== null && web3Auth !== void 0 && (_web3Auth$currentChai = web3Auth.currentChain) !== null && _web3Auth$currentChai !== void 0 && _web3Auth$currentChai.chainNamespace) || web3Auth.currentChain.chainNamespace !== noModal.CHAIN_NAMESPACES.SOLANA) {
26
+ return;
27
+ }
24
28
  if (!solanaWallet) return;
25
29
  const accounts = await solanaWallet.requestAccounts();
26
30
  if ((accounts === null || accounts === void 0 ? void 0 : accounts.length) > 0) {
@@ -170,7 +170,7 @@ function WagmiProvider(_ref) {
170
170
  } else {
171
171
  wagmiChains.push(wagmiChain);
172
172
  }
173
- finalConfig.transports[wagmiChain.id] = viem.http(chain.rpcTarget);
173
+ finalConfig.transports[wagmiChain.id] = chain.wsTarget ? viem.webSocket(chain.wsTarget) : viem.http(chain.rpcTarget);
174
174
  });
175
175
  finalConfig.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
176
176
  }
@@ -183,9 +183,8 @@ function WagmiProvider(_ref) {
183
183
  return /*#__PURE__*/react.createElement(wagmi.WagmiProvider, // typecast to WagmiProviderPropsBase to avoid type error
184
184
  // as we are omitting the config prop from WagmiProviderProps
185
185
  // and creating a new config object with the finalConfig
186
- _objectSpread(_objectSpread({
187
- config: finalConfig
188
- }, props), {}, {
186
+ _objectSpread(_objectSpread({}, props), {}, {
187
+ config: finalConfig,
189
188
  reconnectOnMount: false
190
189
  }), /*#__PURE__*/react.createElement(Web3AuthWagmiProvider, null, children));
191
190
  }
@@ -28,6 +28,7 @@ function ConnectWalletQrCode(props) {
28
28
  primaryColor
29
29
  } = props;
30
30
  const isDesktop = react.useMemo(() => {
31
+ if (typeof window === "undefined") return false;
31
32
  const browser = Bowser.getParser(window.navigator.userAgent);
32
33
  return browser.getPlatformType() === "desktop";
33
34
  }, []);
@@ -94,6 +94,11 @@ function Root(props) {
94
94
  };
95
95
  // Wallet Details
96
96
  const deviceDetails = react.useMemo(() => {
97
+ if (typeof window === "undefined") return {
98
+ platform: "mobile",
99
+ browser: "chrome",
100
+ os: "ios"
101
+ };
97
102
  const browserData = Bowser.getParser(window.navigator.userAgent);
98
103
  return {
99
104
  platform: browserData.getPlatformType(),
@@ -15,7 +15,10 @@ const useSolanaWallet = () => {
15
15
  const solanaWallet = vue.shallowRef(null);
16
16
  const connection = vue.shallowRef(null);
17
17
  vue.watch(provider, async newVal => {
18
- var _accounts$value;
18
+ var _web3Auth$value, _accounts$value;
19
+ if (!((_web3Auth$value = web3Auth.value) !== null && _web3Auth$value !== void 0 && (_web3Auth$value = _web3Auth$value.currentChain) !== null && _web3Auth$value !== void 0 && _web3Auth$value.chainNamespace) || web3Auth.value.currentChain.chainNamespace !== noModal.CHAIN_NAMESPACES.SOLANA) {
20
+ return;
21
+ }
19
22
  if (!newVal && solanaWallet.value) {
20
23
  solanaWallet.value = null;
21
24
  accounts.value = null;
@@ -32,8 +35,8 @@ const useSolanaWallet = () => {
32
35
  }
33
36
  }
34
37
  if (solanaWallet.value && !connection.value) {
35
- var _web3Auth$value;
36
- connection.value = new web3_js.Connection((_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 || (_web3Auth$value = _web3Auth$value.currentChain) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.rpcTarget);
38
+ var _web3Auth$value2;
39
+ connection.value = new web3_js.Connection((_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 || (_web3Auth$value2 = _web3Auth$value2.currentChain) === null || _web3Auth$value2 === void 0 ? void 0 : _web3Auth$value2.rpcTarget);
37
40
  }
38
41
  });
39
42
  return {
@@ -179,7 +179,7 @@ const WagmiProvider = vue.defineComponent({
179
179
  } else {
180
180
  wagmiChains.push(wagmiChain);
181
181
  }
182
- configParams.transports[wagmiChain.id] = viem.http(chain.rpcTarget);
182
+ configParams.transports[wagmiChain.id] = chain.wsTarget ? viem.webSocket(chain.wsTarget) : viem.http(chain.rpcTarget);
183
183
  });
184
184
  configParams.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
185
185
  }
@@ -1,4 +1,3 @@
1
1
  import { PropsWithChildren } from "react";
2
- import { WagmiProviderProps as WagmiProviderPropsBase } from "wagmi";
3
2
  import { WagmiProviderProps } from "./interface";
4
- export declare function WagmiProvider({ children, ...props }: PropsWithChildren<WagmiProviderProps>): import("react").FunctionComponentElement<PropsWithChildren<WagmiProviderPropsBase>>;
3
+ export declare function WagmiProvider({ children, ...props }: PropsWithChildren<WagmiProviderProps>): import("react").FunctionComponentElement<PropsWithChildren<import("wagmi").WagmiProviderProps>>;
@@ -1,6 +1,6 @@
1
1
  import { EVM_CONNECTORS } from '@web3auth/no-modal';
2
2
 
3
- const version = "10.0.0-beta.7";
3
+ const version = "10.0.0-beta.9";
4
4
  const defaultConnectorsModalConfig = {
5
5
  hideWalletDiscovery: false,
6
6
  connectors: {
@@ -262,7 +262,9 @@ class Web3Auth extends Web3AuthNoModal {
262
262
  this.options.uiConfig = deepmerge(cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
263
263
  if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
264
264
  if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
265
- this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig);
265
+ this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig, {
266
+ arrayMerge: (_, sourceArray) => sourceArray
267
+ });
266
268
 
267
269
  // merge login methods order from project config and user config, with user config taking precedence
268
270
  const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter(x => x.isDefault).map(x => x.authConnection);
@@ -1,5 +1,5 @@
1
1
  import { Connection } from '@solana/web3.js';
2
- import { SolanaWallet } from '@web3auth/no-modal';
2
+ import { SolanaWallet, CHAIN_NAMESPACES } from '@web3auth/no-modal';
3
3
  import { useState, useMemo, useEffect } from 'react';
4
4
  import { useWeb3Auth } from '../../hooks/useWeb3Auth.js';
5
5
 
@@ -19,6 +19,10 @@ const useSolanaWallet = () => {
19
19
  }, [web3Auth, provider]);
20
20
  useEffect(() => {
21
21
  const init = async () => {
22
+ var _web3Auth$currentChai;
23
+ if (!(web3Auth !== null && web3Auth !== void 0 && (_web3Auth$currentChai = web3Auth.currentChain) !== null && _web3Auth$currentChai !== void 0 && _web3Auth$currentChai.chainNamespace) || web3Auth.currentChain.chainNamespace !== CHAIN_NAMESPACES.SOLANA) {
24
+ return;
25
+ }
22
26
  if (!solanaWallet) return;
23
27
  const accounts = await solanaWallet.requestAccounts();
24
28
  if ((accounts === null || accounts === void 0 ? void 0 : accounts.length) > 0) {
@@ -2,7 +2,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
2
2
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
3
  import { log } from '@web3auth/no-modal';
4
4
  import { useMemo, createElement, useEffect, Fragment } from 'react';
5
- import { defineChain, http } from 'viem';
5
+ import { defineChain, webSocket, 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';
@@ -169,7 +169,7 @@ function WagmiProvider(_ref) {
169
169
  } else {
170
170
  wagmiChains.push(wagmiChain);
171
171
  }
172
- finalConfig.transports[wagmiChain.id] = http(chain.rpcTarget);
172
+ finalConfig.transports[wagmiChain.id] = chain.wsTarget ? webSocket(chain.wsTarget) : http(chain.rpcTarget);
173
173
  });
174
174
  finalConfig.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
175
175
  }
@@ -183,9 +183,8 @@ function WagmiProvider(_ref) {
183
183
  return /*#__PURE__*/createElement(WagmiProvider$1, // typecast to WagmiProviderPropsBase to avoid type error
184
184
  // as we are omitting the config prop from WagmiProviderProps
185
185
  // and creating a new config object with the finalConfig
186
- _objectSpread(_objectSpread({
187
- config: finalConfig
188
- }, props), {}, {
186
+ _objectSpread(_objectSpread({}, props), {}, {
187
+ config: finalConfig,
189
188
  reconnectOnMount: false
190
189
  }), /*#__PURE__*/createElement(Web3AuthWagmiProvider, null, children));
191
190
  }
@@ -26,6 +26,7 @@ function ConnectWalletQrCode(props) {
26
26
  primaryColor
27
27
  } = props;
28
28
  const isDesktop = useMemo(() => {
29
+ if (typeof window === "undefined") return false;
29
30
  const browser = Bowser.getParser(window.navigator.userAgent);
30
31
  return browser.getPlatformType() === "desktop";
31
32
  }, []);
@@ -93,6 +93,11 @@ function Root(props) {
93
93
 
94
94
  // Wallet Details
95
95
  const deviceDetails = useMemo(() => {
96
+ if (typeof window === "undefined") return {
97
+ platform: "mobile",
98
+ browser: "chrome",
99
+ os: "ios"
100
+ };
96
101
  const browserData = Bowser.getParser(window.navigator.userAgent);
97
102
  return {
98
103
  platform: browserData.getPlatformType(),
@@ -1,5 +1,5 @@
1
1
  import { Connection } from '@solana/web3.js';
2
- import { SolanaWallet } from '@web3auth/no-modal';
2
+ import { CHAIN_NAMESPACES, SolanaWallet } from '@web3auth/no-modal';
3
3
  import { ref, shallowRef, watch } from 'vue';
4
4
  import '@web3auth/no-modal/vue';
5
5
  import { useWeb3Auth } from '../../composables/useWeb3Auth.js';
@@ -13,7 +13,10 @@ const useSolanaWallet = () => {
13
13
  const solanaWallet = shallowRef(null);
14
14
  const connection = shallowRef(null);
15
15
  watch(provider, async newVal => {
16
- var _accounts$value;
16
+ var _web3Auth$value, _accounts$value;
17
+ if (!((_web3Auth$value = web3Auth.value) !== null && _web3Auth$value !== void 0 && (_web3Auth$value = _web3Auth$value.currentChain) !== null && _web3Auth$value !== void 0 && _web3Auth$value.chainNamespace) || web3Auth.value.currentChain.chainNamespace !== CHAIN_NAMESPACES.SOLANA) {
18
+ return;
19
+ }
17
20
  if (!newVal && solanaWallet.value) {
18
21
  solanaWallet.value = null;
19
22
  accounts.value = null;
@@ -30,8 +33,8 @@ const useSolanaWallet = () => {
30
33
  }
31
34
  }
32
35
  if (solanaWallet.value && !connection.value) {
33
- var _web3Auth$value;
34
- connection.value = new Connection((_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 || (_web3Auth$value = _web3Auth$value.currentChain) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.rpcTarget);
36
+ var _web3Auth$value2;
37
+ connection.value = new Connection((_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 || (_web3Auth$value2 = _web3Auth$value2.currentChain) === null || _web3Auth$value2 === void 0 ? void 0 : _web3Auth$value2.rpcTarget);
35
38
  }
36
39
  });
37
40
  return {
@@ -3,7 +3,7 @@ import { hydrate } from '@wagmi/core';
3
3
  import { useConfig, useAccountEffect, configKey, createConfig } from '@wagmi/vue';
4
4
  import { injected } from '@wagmi/vue/connectors';
5
5
  import { log } from '@web3auth/no-modal';
6
- import { defineChain, http } from 'viem';
6
+ import { defineChain, webSocket, http } from 'viem';
7
7
  import { defineComponent, h, watch, provide, shallowRef } from 'vue';
8
8
  import '@web3auth/no-modal/vue';
9
9
  import { useWeb3Auth } from '../composables/useWeb3Auth.js';
@@ -180,7 +180,7 @@ const WagmiProvider = defineComponent({
180
180
  } else {
181
181
  wagmiChains.push(wagmiChain);
182
182
  }
183
- configParams.transports[wagmiChain.id] = http(chain.rpcTarget);
183
+ configParams.transports[wagmiChain.id] = chain.wsTarget ? webSocket(chain.wsTarget) : http(chain.rpcTarget);
184
184
  });
185
185
  configParams.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
186
186
  }