@web3auth/modal 10.13.1 → 10.14.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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  var noModal = require('@web3auth/no-modal');
4
4
 
5
- const version = "10.13.1";
5
+ const version = "10.14.0";
6
6
  const defaultConnectorsModalConfig = {
7
7
  hideWalletDiscovery: false,
8
8
  connectors: {
@@ -321,11 +321,11 @@ function Root(props) {
321
321
  }
322
322
  // Wallet Details Screen
323
323
  if (isWalletDetailsExpanded) {
324
- return isPrivacyPolicyOrTncLink ? "640px" : "588px";
324
+ return isPrivacyPolicyOrTncLink ? "680px" : "628px";
325
325
  }
326
326
  // MetaMask QR Code Screen
327
327
  if ((_bodyState$metamaskQr = bodyState.metamaskQrCode) !== null && _bodyState$metamaskQr !== void 0 && _bodyState$metamaskQr.show) {
328
- return isPrivacyPolicyOrTncLink ? "640px" : "588px";
328
+ return isPrivacyPolicyOrTncLink ? "680px" : "628px";
329
329
  }
330
330
  // Connect Wallet Screen
331
331
  if (modalState.currentPage === constants.PAGES.CONNECT_WALLET) {
@@ -19,6 +19,8 @@ const Web3AuthProvider = vue.defineComponent({
19
19
  const isMFAEnabled = vue.ref(false);
20
20
  const status = vue.ref(null);
21
21
  const isAuthorized = vue.ref(false);
22
+ const chainId = vue.ref(null);
23
+ const chainNamespace = vue.ref(null);
22
24
  const isInitializing = vue.ref(false);
23
25
  const initError = vue.ref(null);
24
26
  const isInitialized = vue.ref(false);
@@ -37,6 +39,8 @@ const Web3AuthProvider = vue.defineComponent({
37
39
  isConnected.value = false;
38
40
  isAuthorized.value = false;
39
41
  status.value = null;
42
+ chainId.value = null;
43
+ chainNamespace.value = null;
40
44
  };
41
45
  onInvalidate(() => {
42
46
  if (web3Auth.value) {
@@ -90,9 +94,12 @@ const Web3AuthProvider = vue.defineComponent({
90
94
  status.value = web3Auth.value.status;
91
95
  // we do this because of rehydration issues. status connected is fired first but web3auth sdk is not ready yet.
92
96
  if (web3Auth.value.status === noModal.CONNECTOR_STATUS.CONNECTED) {
97
+ var _web3Auth$value$curre, _web3Auth$value$curre2;
93
98
  if (!isInitialized.value) isInitialized.value = true;
94
99
  isConnected.value = true;
95
100
  provider.value = newWeb3Auth.provider;
101
+ chainId.value = web3Auth.value.currentChainId;
102
+ chainNamespace.value = (_web3Auth$value$curre = (_web3Auth$value$curre2 = web3Auth.value.currentChain) === null || _web3Auth$value$curre2 === void 0 ? void 0 : _web3Auth$value$curre2.chainNamespace) !== null && _web3Auth$value$curre !== void 0 ? _web3Auth$value$curre : null;
96
103
  }
97
104
  };
98
105
  const disconnectedListener = () => {
@@ -146,6 +153,23 @@ const Web3AuthProvider = vue.defineComponent({
146
153
  }, {
147
154
  immediate: true
148
155
  });
156
+ // Listen for chain changes on the provider
157
+ vue.watch(provider, (newProvider, prevProvider) => {
158
+ const handleChainChange = newChainId => {
159
+ var _web3Auth$value$curre3, _web3Auth$value;
160
+ chainId.value = newChainId;
161
+ chainNamespace.value = (_web3Auth$value$curre3 = (_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 || (_web3Auth$value = _web3Auth$value.currentChain) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.chainNamespace) !== null && _web3Auth$value$curre3 !== void 0 ? _web3Auth$value$curre3 : null;
162
+ };
163
+ // unregister previous listener
164
+ if (prevProvider && newProvider !== prevProvider) {
165
+ prevProvider.removeListener("chainChanged", handleChainChange);
166
+ }
167
+ if (newProvider && newProvider !== prevProvider) {
168
+ newProvider.on("chainChanged", handleChainChange);
169
+ }
170
+ }, {
171
+ immediate: true
172
+ });
149
173
  vue.provide(noModal.Web3AuthContextKey, {
150
174
  web3Auth,
151
175
  isConnected,
@@ -156,6 +180,8 @@ const Web3AuthProvider = vue.defineComponent({
156
180
  isInitializing,
157
181
  initError,
158
182
  isMFAEnabled,
183
+ chainId,
184
+ chainNamespace,
159
185
  getPlugin,
160
186
  setIsMFAEnabled
161
187
  });
@@ -1,23 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var vue = require('vue');
4
3
  var useWeb3AuthInner = require('./useWeb3AuthInner.js');
5
4
 
6
5
  const useChain = () => {
7
6
  const context = useWeb3AuthInner.useWeb3AuthInner();
8
- const chainId = vue.computed(() => {
9
- var _context$web3Auth$val;
10
- if (!((_context$web3Auth$val = context.web3Auth.value) !== null && _context$web3Auth$val !== void 0 && _context$web3Auth$val.currentChain)) return null;
11
- return context.web3Auth.value.currentChain.chainId;
12
- });
13
- const chainNamespace = vue.computed(() => {
14
- var _context$web3Auth$val2;
15
- if (!((_context$web3Auth$val2 = context.web3Auth.value) !== null && _context$web3Auth$val2 !== void 0 && _context$web3Auth$val2.currentChain)) return null;
16
- return context.web3Auth.value.currentChain.chainNamespace;
17
- });
18
7
  return {
19
- chainId,
20
- chainNamespace
8
+ chainId: context.chainId,
9
+ chainNamespace: context.chainNamespace
21
10
  };
22
11
  };
23
12
 
@@ -1,7 +1,7 @@
1
1
  import { ChainNamespaceType } from "@web3auth/no-modal";
2
- import { ComputedRef } from "vue";
2
+ import { Ref } from "vue";
3
3
  export type IUseChain = {
4
- chainId: ComputedRef<string | null>;
5
- chainNamespace: ComputedRef<ChainNamespaceType | null>;
4
+ chainId: Ref<string | null>;
5
+ chainNamespace: Ref<ChainNamespaceType | null>;
6
6
  };
7
7
  export declare const useChain: () => IUseChain;
@@ -1,4 +1,4 @@
1
- import type { CONNECTOR_STATUS_TYPE, IPlugin, IProvider, WalletServicesPluginType } from "@web3auth/no-modal";
1
+ import type { ChainNamespaceType, CONNECTOR_STATUS_TYPE, IPlugin, IProvider, WalletServicesPluginType } from "@web3auth/no-modal";
2
2
  import { Ref, ShallowRef } from "vue";
3
3
  import type { Web3Auth, Web3AuthOptions } from "../modalManager";
4
4
  export type Web3AuthContextConfig = {
@@ -16,6 +16,8 @@ interface IBaseWeb3AuthComposableContext {
16
16
  isInitialized: Ref<boolean>;
17
17
  status: Ref<CONNECTOR_STATUS_TYPE | null>;
18
18
  isMFAEnabled: Ref<boolean>;
19
+ chainId: Ref<string | null>;
20
+ chainNamespace: Ref<ChainNamespaceType | null>;
19
21
  getPlugin: (pluginName: string) => IPlugin | null;
20
22
  setIsMFAEnabled: (isMfaEnabled: boolean) => void;
21
23
  }
@@ -1,6 +1,6 @@
1
1
  import { EVM_CONNECTORS } from '@web3auth/no-modal';
2
2
 
3
- const version = "10.13.1";
3
+ const version = "10.14.0";
4
4
  const defaultConnectorsModalConfig = {
5
5
  hideWalletDiscovery: false,
6
6
  connectors: {
@@ -327,12 +327,12 @@ function Root(props) {
327
327
 
328
328
  // Wallet Details Screen
329
329
  if (isWalletDetailsExpanded) {
330
- return isPrivacyPolicyOrTncLink ? "640px" : "588px";
330
+ return isPrivacyPolicyOrTncLink ? "680px" : "628px";
331
331
  }
332
332
 
333
333
  // MetaMask QR Code Screen
334
334
  if ((_bodyState$metamaskQr = bodyState.metamaskQrCode) !== null && _bodyState$metamaskQr !== void 0 && _bodyState$metamaskQr.show) {
335
- return isPrivacyPolicyOrTncLink ? "640px" : "588px";
335
+ return isPrivacyPolicyOrTncLink ? "680px" : "628px";
336
336
  }
337
337
 
338
338
  // Connect Wallet Screen
@@ -17,6 +17,8 @@ const Web3AuthProvider = defineComponent({
17
17
  const isMFAEnabled = ref(false);
18
18
  const status = ref(null);
19
19
  const isAuthorized = ref(false);
20
+ const chainId = ref(null);
21
+ const chainNamespace = ref(null);
20
22
  const isInitializing = ref(false);
21
23
  const initError = ref(null);
22
24
  const isInitialized = ref(false);
@@ -35,6 +37,8 @@ const Web3AuthProvider = defineComponent({
35
37
  isConnected.value = false;
36
38
  isAuthorized.value = false;
37
39
  status.value = null;
40
+ chainId.value = null;
41
+ chainNamespace.value = null;
38
42
  };
39
43
  onInvalidate(() => {
40
44
  if (web3Auth.value) {
@@ -89,9 +93,12 @@ const Web3AuthProvider = defineComponent({
89
93
  status.value = web3Auth.value.status;
90
94
  // we do this because of rehydration issues. status connected is fired first but web3auth sdk is not ready yet.
91
95
  if (web3Auth.value.status === CONNECTOR_STATUS.CONNECTED) {
96
+ var _currentChain$chainNa, _currentChain;
92
97
  if (!isInitialized.value) isInitialized.value = true;
93
98
  isConnected.value = true;
94
99
  provider.value = newWeb3Auth.provider;
100
+ chainId.value = web3Auth.value.currentChainId;
101
+ chainNamespace.value = (_currentChain$chainNa = (_currentChain = web3Auth.value.currentChain) === null || _currentChain === void 0 ? void 0 : _currentChain.chainNamespace) !== null && _currentChain$chainNa !== void 0 ? _currentChain$chainNa : null;
95
102
  }
96
103
  };
97
104
  const disconnectedListener = () => {
@@ -146,6 +153,25 @@ const Web3AuthProvider = defineComponent({
146
153
  }, {
147
154
  immediate: true
148
155
  });
156
+
157
+ // Listen for chain changes on the provider
158
+ watch(provider, (newProvider, prevProvider) => {
159
+ const handleChainChange = newChainId => {
160
+ var _web3Auth$value$curre, _web3Auth$value;
161
+ chainId.value = newChainId;
162
+ chainNamespace.value = (_web3Auth$value$curre = (_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 || (_web3Auth$value = _web3Auth$value.currentChain) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.chainNamespace) !== null && _web3Auth$value$curre !== void 0 ? _web3Auth$value$curre : null;
163
+ };
164
+
165
+ // unregister previous listener
166
+ if (prevProvider && newProvider !== prevProvider) {
167
+ prevProvider.removeListener("chainChanged", handleChainChange);
168
+ }
169
+ if (newProvider && newProvider !== prevProvider) {
170
+ newProvider.on("chainChanged", handleChainChange);
171
+ }
172
+ }, {
173
+ immediate: true
174
+ });
149
175
  provide(Web3AuthContextKey, {
150
176
  web3Auth,
151
177
  isConnected,
@@ -156,6 +182,8 @@ const Web3AuthProvider = defineComponent({
156
182
  isInitializing,
157
183
  initError,
158
184
  isMFAEnabled,
185
+ chainId,
186
+ chainNamespace,
159
187
  getPlugin,
160
188
  setIsMFAEnabled
161
189
  });
@@ -1,21 +1,10 @@
1
- import { computed } from 'vue';
2
1
  import { useWeb3AuthInner } from './useWeb3AuthInner.js';
3
2
 
4
3
  const useChain = () => {
5
4
  const context = useWeb3AuthInner();
6
- const chainId = computed(() => {
7
- var _context$web3Auth$val;
8
- if (!((_context$web3Auth$val = context.web3Auth.value) !== null && _context$web3Auth$val !== void 0 && _context$web3Auth$val.currentChain)) return null;
9
- return context.web3Auth.value.currentChain.chainId;
10
- });
11
- const chainNamespace = computed(() => {
12
- var _context$web3Auth$val2;
13
- if (!((_context$web3Auth$val2 = context.web3Auth.value) !== null && _context$web3Auth$val2 !== void 0 && _context$web3Auth$val2.currentChain)) return null;
14
- return context.web3Auth.value.currentChain.chainNamespace;
15
- });
16
5
  return {
17
- chainId,
18
- chainNamespace
6
+ chainId: context.chainId,
7
+ chainNamespace: context.chainNamespace
19
8
  };
20
9
  };
21
10