@web3auth/no-modal 10.9.0-alpha.0 → 10.10.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.
Files changed (23) hide show
  1. package/dist/lib.cjs/base/utils.js +4 -3
  2. package/dist/lib.cjs/connectors/auth-connector/authConnector.js +1 -1
  3. package/dist/lib.cjs/connectors/coinbase-connector/coinbaseConnector.js +32 -7
  4. package/dist/lib.cjs/connectors/injected-evm-connector/injectedEvmConnector.js +1 -1
  5. package/dist/lib.cjs/connectors/injected-solana-connector/walletStandardConnector.js +1 -1
  6. package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +2 -2
  7. package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +2 -2
  8. package/dist/lib.cjs/noModal.js +8 -11
  9. package/dist/lib.cjs/types/base/connector/interfaces.d.ts +4 -0
  10. package/dist/lib.cjs/types/base/interfaces.d.ts +2 -1
  11. package/dist/lib.cjs/types/base/utils.d.ts +2 -1
  12. package/dist/lib.cjs/vue/WalletServicesInnerProvider.js +1 -1
  13. package/dist/lib.esm/base/utils.js +4 -3
  14. package/dist/lib.esm/connectors/auth-connector/authConnector.js +1 -1
  15. package/dist/lib.esm/connectors/coinbase-connector/coinbaseConnector.js +32 -7
  16. package/dist/lib.esm/connectors/injected-evm-connector/injectedEvmConnector.js +1 -1
  17. package/dist/lib.esm/connectors/injected-solana-connector/walletStandardConnector.js +1 -1
  18. package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +2 -2
  19. package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +2 -2
  20. package/dist/lib.esm/noModal.js +9 -13
  21. package/dist/lib.esm/vue/WalletServicesInnerProvider.js +1 -1
  22. package/dist/noModal.umd.min.js +1 -1
  23. package/package.json +9 -9
@@ -129,7 +129,7 @@ const getAaAnalyticsProperties = accountAbstractionConfig => {
129
129
  };
130
130
  };
131
131
  const getWalletServicesAnalyticsProperties = walletServicesConfig => {
132
- var _walletServicesConfig, _walletServicesConfig2, _walletServicesConfig3, _walletServicesConfig4, _walletServicesConfig5, _walletServicesConfig6, _walletServicesConfig7, _walletServicesConfig8, _walletServicesConfig9, _walletServicesConfig0, _walletServicesConfig1;
132
+ var _walletServicesConfig, _walletServicesConfig2, _walletServicesConfig3, _walletServicesConfig4, _walletServicesConfig5, _walletServicesConfig6, _walletServicesConfig7, _walletServicesConfig8, _walletServicesConfig9, _walletServicesConfig0, _walletServicesConfig1, _walletServicesConfig10;
133
133
  return {
134
134
  ws_confirmation_strategy: walletServicesConfig === null || walletServicesConfig === void 0 ? void 0 : walletServicesConfig.confirmationStrategy,
135
135
  ws_enable_key_export: walletServicesConfig === null || walletServicesConfig === void 0 ? void 0 : walletServicesConfig.enableKeyExport,
@@ -143,10 +143,11 @@ const getWalletServicesAnalyticsProperties = walletServicesConfig => {
143
143
  ws_hide_swap: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig8 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig8 === void 0 ? void 0 : _walletServicesConfig8.hideSwap,
144
144
  ws_hide_show_all_tokens: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig9 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig9 === void 0 ? void 0 : _walletServicesConfig9.hideShowAllTokens,
145
145
  ws_hide_wallet_connect: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig0 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig0 === void 0 ? void 0 : _walletServicesConfig0.hideWalletConnect,
146
- ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig1 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig1 === void 0 ? void 0 : _walletServicesConfig1.defaultPortfolio
146
+ ws_hide_defi_positions_display: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig1 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig1 === void 0 ? void 0 : _walletServicesConfig1.hideDefiPositionsDisplay,
147
+ ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig10 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig10 === void 0 ? void 0 : _walletServicesConfig10.defaultPortfolio
147
148
  };
148
149
  };
149
- const sdkVersion = "10.9.0-alpha.0";
150
+ const sdkVersion = "10.10.0";
150
151
  const getErrorAnalyticsProperties = error => {
151
152
  try {
152
153
  const code = error instanceof index.Web3AuthError ? error.code : error === null || error === void 0 ? void 0 : error.code;
@@ -147,7 +147,7 @@ class AuthConnector extends baseConnector.BaseConnector {
147
147
  this.rehydrated = true;
148
148
  await this.connect({
149
149
  chainId: options.chainId,
150
- getIdentityToken: false
150
+ getIdentityToken: options.getIdentityToken
151
151
  });
152
152
  } else if (!sessionId && options.autoConnect) {
153
153
  // if here, this means that the connector is cached but the sessionId is not available.
@@ -66,7 +66,7 @@ class CoinbaseConnector extends baseEvmConnector.BaseEvmConnector {
66
66
  this.rehydrated = true;
67
67
  const provider = await this.connect({
68
68
  chainId: options.chainId,
69
- getIdentityToken: false
69
+ getIdentityToken: options.getIdentityToken
70
70
  });
71
71
  // the connect function could fail silently as well.
72
72
  if (!provider) {
@@ -148,12 +148,37 @@ class CoinbaseConnector extends baseEvmConnector.BaseEvmConnector {
148
148
  }
149
149
  async switchChain(params, init = false) {
150
150
  super.checkSwitchChainRequirements(params, init);
151
- await this.coinbaseProvider.request({
152
- method: "wallet_switchEthereumChain",
153
- params: [{
154
- chainId: params.chainId
155
- }]
156
- });
151
+ try {
152
+ await this.coinbaseProvider.request({
153
+ method: "wallet_switchEthereumChain",
154
+ params: [{
155
+ chainId: params.chainId
156
+ }]
157
+ });
158
+ } catch (switchError) {
159
+ // 4902 indicates that the client does not recognize the Harmony One network
160
+ if (switchError.code === 4902) {
161
+ const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId);
162
+ if (!chainConfig) throw index$1.WalletLoginError.connectionError("Chain config is not available");
163
+ await this.coinbaseProvider.request({
164
+ method: "wallet_addEthereumChain",
165
+ params: [{
166
+ chainId: chainConfig.chainId,
167
+ rpcUrls: [chainConfig.rpcTarget],
168
+ chainName: chainConfig.displayName,
169
+ nativeCurrency: {
170
+ name: chainConfig.tickerName,
171
+ symbol: chainConfig.ticker,
172
+ decimals: chainConfig.decimals || 18
173
+ },
174
+ blockExplorerUrls: [chainConfig.blockExplorerUrl],
175
+ iconUrls: [chainConfig.logo]
176
+ }]
177
+ });
178
+ return;
179
+ }
180
+ throw switchError;
181
+ }
157
182
  }
158
183
  async enableMFA() {
159
184
  throw new Error("Method Not implemented");
@@ -54,7 +54,7 @@ class InjectedEvmConnector extends baseEvmConnector.BaseEvmConnector {
54
54
  this.rehydrated = true;
55
55
  const provider = await this.connect({
56
56
  chainId: options.chainId,
57
- getIdentityToken: false
57
+ getIdentityToken: options.getIdentityToken
58
58
  });
59
59
  if (!provider) {
60
60
  this.rehydrated = false;
@@ -70,7 +70,7 @@ class WalletStandardConnector extends baseSolanaConnector.BaseSolanaConnector {
70
70
  this.rehydrated = true;
71
71
  const provider = await this.connect({
72
72
  chainId: options.chainId,
73
- getIdentityToken: false
73
+ getIdentityToken: options.getIdentityToken
74
74
  });
75
75
  if (!provider) {
76
76
  this.rehydrated = false;
@@ -80,7 +80,7 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
80
80
  this.rehydrated = true;
81
81
  const provider = await this.connect({
82
82
  chainId: options.chainId,
83
- getIdentityToken: false
83
+ getIdentityToken: options.getIdentityToken
84
84
  });
85
85
  if (!provider) {
86
86
  this.rehydrated = false;
@@ -216,7 +216,7 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
216
216
  } catch (error) {
217
217
  // If the error code is 4902, the network needs to be added
218
218
  if ((error === null || error === void 0 ? void 0 : error.code) === 4902) {
219
- const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId && [baseControllers.CHAIN_NAMESPACES.EIP155, baseControllers.CHAIN_NAMESPACES.SOLANA].includes(x.chainNamespace));
219
+ const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId && [baseControllers.CHAIN_NAMESPACES.EIP155].includes(x.chainNamespace));
220
220
  await this.addChain(chainConfig);
221
221
  await requestSwitchChain();
222
222
  } else {
@@ -106,7 +106,7 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
106
106
  try {
107
107
  await this.onConnectHandler({
108
108
  chain: chainConfig,
109
- getIdentityToken: false
109
+ getIdentityToken: options.getIdentityToken
110
110
  });
111
111
  } catch (error) {
112
112
  loglevel.log.error("wallet auto connect", error);
@@ -171,7 +171,7 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
171
171
  if (this.connected) {
172
172
  await this.onConnectHandler({
173
173
  chain: chainConfig,
174
- getIdentityToken: false
174
+ getIdentityToken
175
175
  });
176
176
  return this.provider;
177
177
  }
@@ -348,6 +348,7 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
348
348
  cleanup: false
349
349
  }) {
350
350
  if (!connectorStatus.CONNECTED_STATUSES.includes(this.status) || !this.connectedConnector) throw index.WalletLoginError.notConnectedError(`No wallet is connected`);
351
+ if (this.connectedConnector.status === constants.CONNECTOR_STATUS.DISCONNECTING) return;
351
352
  await this.connectedConnector.disconnect(options);
352
353
  }
353
354
  async getUserInfo() {
@@ -544,6 +545,7 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
544
545
  enableReceiveButton = true,
545
546
  enableShowAllTokensButton = true,
546
547
  enableConfirmationModal = false,
548
+ enableDefiPositionsDisplay = true,
547
549
  portfolioWidgetPosition = baseControllers.BUTTON_POSITION.BOTTOM_LEFT,
548
550
  defaultPortfolio = "token"
549
551
  } = walletUi || {};
@@ -557,6 +559,7 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
557
559
  hideSwap: !enableSwapButton,
558
560
  hideShowAllTokens: !enableShowAllTokensButton,
559
561
  hideWalletConnect: !enableWalletConnect,
562
+ hideDefiPositionsDisplay: !enableDefiPositionsDisplay,
560
563
  buttonPosition: portfolioWidgetPosition,
561
564
  defaultPortfolio
562
565
  };
@@ -613,7 +616,8 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
613
616
  const autoConnect = this.checkIfAutoConnect(connector);
614
617
  await connector.init({
615
618
  autoConnect,
616
- chainId: initialChain.chainId
619
+ chainId: initialChain.chainId,
620
+ getIdentityToken: this.coreOptions.initialAuthenticationMode === constants.CONNECTOR_INITIAL_AUTHENTICATION_MODE.CONNECT_AND_SIGN
617
621
  });
618
622
  } catch (e) {
619
623
  loglevel.log.error(e, connector.name);
@@ -635,9 +639,9 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
635
639
  const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
636
640
  const isMipdEnabled = isExternalWalletEnabled && ((_this$coreOptions$mul = this.coreOptions.multiInjectedProviderDiscovery) !== null && _this$coreOptions$mul !== void 0 ? _this$coreOptions$mul : true);
637
641
  const chainNamespaces = new Set(this.coreOptions.chains.map(chain => chain.chainNamespace));
638
- // it's safe to add it here as if there is a MetaMask injected provider, this won't override it
639
- // only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
640
- if (utils.isBrowser() && chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.EIP155) && !chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.SOLANA)) {
642
+ // prioritize using MM connector over injected connector for EVM chains
643
+ if (utils.isBrowser() && chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.EIP155)) {
644
+ // only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
641
645
  connectorFns.push(metamaskConnector.metaMaskConnector(modalMode ? {
642
646
  headless: true
643
647
  } : undefined));
@@ -673,13 +677,6 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
673
677
  connectorFns.push(...evmMipd.getProviders().map(injectedEvmConnector));
674
678
  }
675
679
  }
676
- // it's safe to add it here as if there is a MetaMask injected provider, this won't override it
677
- // only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
678
- if (utils.isBrowser() && (chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.SOLANA) || chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.EIP155))) {
679
- connectorFns.push(metamaskConnector.metaMaskConnector(modalMode ? {
680
- headless: true
681
- } : undefined));
682
- }
683
680
  // add WalletConnectV2 connector if external wallets are enabled
684
681
  if (utils.isBrowser() && isExternalWalletEnabled && (chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.SOLANA) || chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.EIP155))) {
685
682
  const {
@@ -19,6 +19,10 @@ export interface ConnectorInitOptions {
19
19
  * The chainId to connect to
20
20
  */
21
21
  chainId: string;
22
+ /**
23
+ * Whether to get the identity token
24
+ */
25
+ getIdentityToken?: boolean;
22
26
  }
23
27
  export type CONNECTOR_STATUS_TYPE = (typeof CONNECTOR_STATUS)[keyof typeof CONNECTOR_STATUS];
24
28
  export type IdentityTokenInfo = {
@@ -45,8 +45,9 @@ export interface WalletUiConfig {
45
45
  enableSendButton?: boolean;
46
46
  enableSwapButton?: boolean;
47
47
  enableReceiveButton?: boolean;
48
+ enableDefiPositionsDisplay?: boolean;
48
49
  portfolioWidgetPosition?: BUTTON_POSITION_TYPE;
49
- defaultPortfolio?: "token" | "nft";
50
+ defaultPortfolio?: "token" | "nft" | "defi";
50
51
  }
51
52
  export type ModalSignInMethodType = (typeof MODAL_SIGN_IN_METHODS)[keyof typeof MODAL_SIGN_IN_METHODS];
52
53
  export type WidgetType = (typeof WIDGET_TYPE)[keyof typeof WIDGET_TYPE];
@@ -56,7 +56,8 @@ export declare const getWalletServicesAnalyticsProperties: (walletServicesConfig
56
56
  ws_hide_swap: boolean;
57
57
  ws_hide_show_all_tokens: boolean;
58
58
  ws_hide_wallet_connect: boolean;
59
- ws_default_portfolio: "token" | "nft";
59
+ ws_hide_defi_positions_display: boolean;
60
+ ws_default_portfolio: "token" | "nft" | "defi";
60
61
  };
61
62
  export declare const sdkVersion: string;
62
63
  export declare const getErrorAnalyticsProperties: (error: unknown) => {
@@ -42,7 +42,7 @@ const WalletServicesInnerProvider = vue.defineComponent({
42
42
  if (newIsConnected) {
43
43
  var _walletServicesPlugin;
44
44
  const plugin = getPlugin(IPlugin.EVM_PLUGINS.WALLET_SERVICES);
45
- if (!walletServicesPlugin.value) walletServicesPlugin.value = plugin;
45
+ walletServicesPlugin.value = plugin;
46
46
  // when rehydrating, the connectedListener may be registered after the connected event is emitted, we need to check the status here
47
47
  if (((_walletServicesPlugin = walletServicesPlugin.value) === null || _walletServicesPlugin === void 0 ? void 0 : _walletServicesPlugin.status) === constants.CONNECTOR_STATUS.CONNECTED) ready.value = true;
48
48
  }
@@ -128,7 +128,7 @@ const getAaAnalyticsProperties = accountAbstractionConfig => {
128
128
  };
129
129
  };
130
130
  const getWalletServicesAnalyticsProperties = walletServicesConfig => {
131
- var _walletServicesConfig, _walletServicesConfig2, _walletServicesConfig3, _walletServicesConfig4, _walletServicesConfig5, _walletServicesConfig6, _walletServicesConfig7, _walletServicesConfig8, _walletServicesConfig9, _walletServicesConfig0, _walletServicesConfig1;
131
+ var _walletServicesConfig, _walletServicesConfig2, _walletServicesConfig3, _walletServicesConfig4, _walletServicesConfig5, _walletServicesConfig6, _walletServicesConfig7, _walletServicesConfig8, _walletServicesConfig9, _walletServicesConfig0, _walletServicesConfig1, _walletServicesConfig10;
132
132
  return {
133
133
  ws_confirmation_strategy: walletServicesConfig === null || walletServicesConfig === void 0 ? void 0 : walletServicesConfig.confirmationStrategy,
134
134
  ws_enable_key_export: walletServicesConfig === null || walletServicesConfig === void 0 ? void 0 : walletServicesConfig.enableKeyExport,
@@ -142,10 +142,11 @@ const getWalletServicesAnalyticsProperties = walletServicesConfig => {
142
142
  ws_hide_swap: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig8 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig8 === void 0 ? void 0 : _walletServicesConfig8.hideSwap,
143
143
  ws_hide_show_all_tokens: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig9 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig9 === void 0 ? void 0 : _walletServicesConfig9.hideShowAllTokens,
144
144
  ws_hide_wallet_connect: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig0 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig0 === void 0 ? void 0 : _walletServicesConfig0.hideWalletConnect,
145
- ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig1 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig1 === void 0 ? void 0 : _walletServicesConfig1.defaultPortfolio
145
+ ws_hide_defi_positions_display: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig1 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig1 === void 0 ? void 0 : _walletServicesConfig1.hideDefiPositionsDisplay,
146
+ ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig10 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig10 === void 0 ? void 0 : _walletServicesConfig10.defaultPortfolio
146
147
  };
147
148
  };
148
- const sdkVersion = "10.9.0-alpha.0";
149
+ const sdkVersion = "10.10.0";
149
150
  const getErrorAnalyticsProperties = error => {
150
151
  try {
151
152
  const code = error instanceof Web3AuthError ? error.code : error === null || error === void 0 ? void 0 : error.code;
@@ -144,7 +144,7 @@ class AuthConnector extends BaseConnector {
144
144
  this.rehydrated = true;
145
145
  await this.connect({
146
146
  chainId: options.chainId,
147
- getIdentityToken: false
147
+ getIdentityToken: options.getIdentityToken
148
148
  });
149
149
  } else if (!sessionId && options.autoConnect) {
150
150
  // if here, this means that the connector is cached but the sessionId is not available.
@@ -55,7 +55,7 @@ class CoinbaseConnector extends BaseEvmConnector {
55
55
  this.rehydrated = true;
56
56
  const provider = await this.connect({
57
57
  chainId: options.chainId,
58
- getIdentityToken: false
58
+ getIdentityToken: options.getIdentityToken
59
59
  });
60
60
  // the connect function could fail silently as well.
61
61
  if (!provider) {
@@ -137,12 +137,37 @@ class CoinbaseConnector extends BaseEvmConnector {
137
137
  }
138
138
  async switchChain(params, init = false) {
139
139
  super.checkSwitchChainRequirements(params, init);
140
- await this.coinbaseProvider.request({
141
- method: "wallet_switchEthereumChain",
142
- params: [{
143
- chainId: params.chainId
144
- }]
145
- });
140
+ try {
141
+ await this.coinbaseProvider.request({
142
+ method: "wallet_switchEthereumChain",
143
+ params: [{
144
+ chainId: params.chainId
145
+ }]
146
+ });
147
+ } catch (switchError) {
148
+ // 4902 indicates that the client does not recognize the Harmony One network
149
+ if (switchError.code === 4902) {
150
+ const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId);
151
+ if (!chainConfig) throw WalletLoginError.connectionError("Chain config is not available");
152
+ await this.coinbaseProvider.request({
153
+ method: "wallet_addEthereumChain",
154
+ params: [{
155
+ chainId: chainConfig.chainId,
156
+ rpcUrls: [chainConfig.rpcTarget],
157
+ chainName: chainConfig.displayName,
158
+ nativeCurrency: {
159
+ name: chainConfig.tickerName,
160
+ symbol: chainConfig.ticker,
161
+ decimals: chainConfig.decimals || 18
162
+ },
163
+ blockExplorerUrls: [chainConfig.blockExplorerUrl],
164
+ iconUrls: [chainConfig.logo]
165
+ }]
166
+ });
167
+ return;
168
+ }
169
+ throw switchError;
170
+ }
146
171
  }
147
172
  async enableMFA() {
148
173
  throw new Error("Method Not implemented");
@@ -44,7 +44,7 @@ class InjectedEvmConnector extends BaseEvmConnector {
44
44
  this.rehydrated = true;
45
45
  const provider = await this.connect({
46
46
  chainId: options.chainId,
47
- getIdentityToken: false
47
+ getIdentityToken: options.getIdentityToken
48
48
  });
49
49
  if (!provider) {
50
50
  this.rehydrated = false;
@@ -58,7 +58,7 @@ class WalletStandardConnector extends BaseSolanaConnector {
58
58
  this.rehydrated = true;
59
59
  const provider = await this.connect({
60
60
  chainId: options.chainId,
61
- getIdentityToken: false
61
+ getIdentityToken: options.getIdentityToken
62
62
  });
63
63
  if (!provider) {
64
64
  this.rehydrated = false;
@@ -74,7 +74,7 @@ class MetaMaskConnector extends BaseEvmConnector {
74
74
  this.rehydrated = true;
75
75
  const provider = await this.connect({
76
76
  chainId: options.chainId,
77
- getIdentityToken: false
77
+ getIdentityToken: options.getIdentityToken
78
78
  });
79
79
  if (!provider) {
80
80
  this.rehydrated = false;
@@ -215,7 +215,7 @@ class MetaMaskConnector extends BaseEvmConnector {
215
215
  } catch (error) {
216
216
  // If the error code is 4902, the network needs to be added
217
217
  if ((error === null || error === void 0 ? void 0 : error.code) === 4902) {
218
- const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId && [CHAIN_NAMESPACES.EIP155, CHAIN_NAMESPACES.SOLANA].includes(x.chainNamespace));
218
+ const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId && [CHAIN_NAMESPACES.EIP155].includes(x.chainNamespace));
219
219
  await this.addChain(chainConfig);
220
220
  await requestSwitchChain();
221
221
  } else {
@@ -100,7 +100,7 @@ class WalletConnectV2Connector extends BaseConnector {
100
100
  try {
101
101
  await this.onConnectHandler({
102
102
  chain: chainConfig,
103
- getIdentityToken: false
103
+ getIdentityToken: options.getIdentityToken
104
104
  });
105
105
  } catch (error) {
106
106
  log.error("wallet auto connect", error);
@@ -167,7 +167,7 @@ class WalletConnectV2Connector extends BaseConnector {
167
167
  if (this.connected) {
168
168
  await this.onConnectHandler({
169
169
  chain: chainConfig,
170
- getIdentityToken: false
170
+ getIdentityToken
171
171
  });
172
172
  return this.provider;
173
173
  }
@@ -12,9 +12,9 @@ import { CONNECTOR_STATUS, CONNECTOR_INITIAL_AUTHENTICATION_MODE, CONNECTOR_EVEN
12
12
  import { sdkVersion, fetchProjectConfig, withAbort, getErrorAnalyticsProperties, getCaipChainId, isHexStrict, getHostname, getWhitelabelAnalyticsProperties, getAaAnalyticsProperties, getWalletServicesAnalyticsProperties, isBrowser } from './base/utils.js';
13
13
  import { CommonJRPCProvider } from './providers/base-provider/CommonJRPCProvider.js';
14
14
  import { authConnector } from './connectors/auth-connector/authConnector.js';
15
- import { metaMaskConnector } from './connectors/metamask-connector/metamaskConnector.js';
16
15
  import { walletServicesPlugin } from './plugins/wallet-services-plugin/plugin.js';
17
16
  import { storageAvailable } from './base/connector/utils.js';
17
+ import { metaMaskConnector } from './connectors/metamask-connector/metamaskConnector.js';
18
18
  import { WalletInitializationError, WalletLoginError } from './base/errors/index.js';
19
19
  import { log } from './base/loglevel.js';
20
20
  import { WALLET_CONNECTORS } from './base/wallet/index.js';
@@ -353,6 +353,7 @@ class Web3AuthNoModal extends SafeEventEmitter {
353
353
  cleanup: false
354
354
  }) {
355
355
  if (!CONNECTED_STATUSES.includes(this.status) || !this.connectedConnector) throw WalletLoginError.notConnectedError(`No wallet is connected`);
356
+ if (this.connectedConnector.status === CONNECTOR_STATUS.DISCONNECTING) return;
356
357
  await this.connectedConnector.disconnect(options);
357
358
  }
358
359
  async getUserInfo() {
@@ -553,6 +554,7 @@ class Web3AuthNoModal extends SafeEventEmitter {
553
554
  enableReceiveButton = true,
554
555
  enableShowAllTokensButton = true,
555
556
  enableConfirmationModal = false,
557
+ enableDefiPositionsDisplay = true,
556
558
  portfolioWidgetPosition = BUTTON_POSITION.BOTTOM_LEFT,
557
559
  defaultPortfolio = "token"
558
560
  } = walletUi || {};
@@ -566,6 +568,7 @@ class Web3AuthNoModal extends SafeEventEmitter {
566
568
  hideSwap: !enableSwapButton,
567
569
  hideShowAllTokens: !enableShowAllTokensButton,
568
570
  hideWalletConnect: !enableWalletConnect,
571
+ hideDefiPositionsDisplay: !enableDefiPositionsDisplay,
569
572
  buttonPosition: portfolioWidgetPosition,
570
573
  defaultPortfolio
571
574
  };
@@ -623,7 +626,8 @@ class Web3AuthNoModal extends SafeEventEmitter {
623
626
  const autoConnect = this.checkIfAutoConnect(connector);
624
627
  await connector.init({
625
628
  autoConnect,
626
- chainId: initialChain.chainId
629
+ chainId: initialChain.chainId,
630
+ getIdentityToken: this.coreOptions.initialAuthenticationMode === CONNECTOR_INITIAL_AUTHENTICATION_MODE.CONNECT_AND_SIGN
627
631
  });
628
632
  } catch (e) {
629
633
  log.error(e, connector.name);
@@ -647,9 +651,9 @@ class Web3AuthNoModal extends SafeEventEmitter {
647
651
  const isMipdEnabled = isExternalWalletEnabled && ((_this$coreOptions$mul = this.coreOptions.multiInjectedProviderDiscovery) !== null && _this$coreOptions$mul !== void 0 ? _this$coreOptions$mul : true);
648
652
  const chainNamespaces = new Set(this.coreOptions.chains.map(chain => chain.chainNamespace));
649
653
 
650
- // it's safe to add it here as if there is a MetaMask injected provider, this won't override it
651
- // only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
652
- if (isBrowser() && chainNamespaces.has(CHAIN_NAMESPACES.EIP155) && !chainNamespaces.has(CHAIN_NAMESPACES.SOLANA)) {
654
+ // prioritize using MM connector over injected connector for EVM chains
655
+ if (isBrowser() && chainNamespaces.has(CHAIN_NAMESPACES.EIP155)) {
656
+ // only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
653
657
  connectorFns.push(metaMaskConnector(modalMode ? {
654
658
  headless: true
655
659
  } : undefined));
@@ -686,14 +690,6 @@ class Web3AuthNoModal extends SafeEventEmitter {
686
690
  }
687
691
  }
688
692
 
689
- // it's safe to add it here as if there is a MetaMask injected provider, this won't override it
690
- // only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
691
- if (isBrowser() && (chainNamespaces.has(CHAIN_NAMESPACES.SOLANA) || chainNamespaces.has(CHAIN_NAMESPACES.EIP155))) {
692
- connectorFns.push(metaMaskConnector(modalMode ? {
693
- headless: true
694
- } : undefined));
695
- }
696
-
697
693
  // add WalletConnectV2 connector if external wallets are enabled
698
694
  if (isBrowser() && isExternalWalletEnabled && (chainNamespaces.has(CHAIN_NAMESPACES.SOLANA) || chainNamespaces.has(CHAIN_NAMESPACES.EIP155))) {
699
695
  const {
@@ -28,7 +28,7 @@ const WalletServicesInnerProvider = defineComponent({
28
28
  if (newIsConnected) {
29
29
  var _walletServicesPlugin;
30
30
  const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES);
31
- if (!walletServicesPlugin.value) walletServicesPlugin.value = plugin;
31
+ walletServicesPlugin.value = plugin;
32
32
  // when rehydrating, the connectedListener may be registered after the connected event is emitted, we need to check the status here
33
33
  if (((_walletServicesPlugin = walletServicesPlugin.value) === null || _walletServicesPlugin === void 0 ? void 0 : _walletServicesPlugin.status) === CONNECTOR_STATUS.CONNECTED) ready.value = true;
34
34
  }