@web3auth/no-modal 10.5.3 → 10.5.5

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.
@@ -145,7 +145,7 @@ const getWalletServicesAnalyticsProperties = walletServicesConfig => {
145
145
  ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig1 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig1 === void 0 ? void 0 : _walletServicesConfig1.defaultPortfolio
146
146
  };
147
147
  };
148
- const sdkVersion = "10.5.3";
148
+ const sdkVersion = "10.5.5";
149
149
  const getErrorAnalyticsProperties = error => {
150
150
  try {
151
151
  const code = error instanceof index.Web3AuthError ? error.code : error === null || error === void 0 ? void 0 : error.code;
@@ -32,6 +32,7 @@ require('@toruslabs/bs58');
32
32
  var JrpcClient = require('../../providers/solana-provider/rpc/JrpcClient.js');
33
33
  var solanaRpcMiddlewares = require('../../providers/solana-provider/rpc/solanaRpcMiddlewares.js');
34
34
  require('@web3auth/ws-embed');
35
+ var utils$1 = require('./utils.js');
35
36
  var walletConnectV2Utils = require('./walletConnectV2Utils.js');
36
37
 
37
38
  var _WalletConnectV2Provider;
@@ -217,14 +218,14 @@ class WalletConnectV2Provider extends baseProvider.BaseProvider {
217
218
  if (event.name === "chainChanged") {
218
219
  if (!data) return;
219
220
  const connectedChainId = data;
220
- const connectedHexChainId = `0x${connectedChainId.toString(16)}`;
221
+ const formattedChainId = utils$1.formatChainId(connectedChainId);
221
222
  // Check if chainId changed and trigger event
222
223
  const {
223
224
  currentChain
224
225
  } = this;
225
- if (connectedHexChainId && currentChain.chainId !== connectedHexChainId) {
226
+ if (formattedChainId && currentChain.chainId !== formattedChainId) {
226
227
  // Handle rpcUrl update
227
- await this.setupEngine(connector, connectedHexChainId);
228
+ await this.setupEngine(connector, formattedChainId);
228
229
  }
229
230
  }
230
231
  });
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ require('@babel/runtime/helpers/objectSpread2');
4
+
5
+ const formatChainId = chainId => {
6
+ if (typeof chainId === "number") {
7
+ return `0x${chainId.toString(16)}`;
8
+ } else if (typeof chainId === "string") {
9
+ return chainId.startsWith("0x") ? chainId : `0x${parseInt(chainId, 10).toString(16)}`;
10
+ }
11
+ throw new Error(`Invalid chainId: ${chainId}`);
12
+ };
13
+
14
+ exports.formatChainId = formatChainId;
@@ -1,3 +1,4 @@
1
1
  import type { EngineTypes } from "@walletconnect/types";
2
2
  import type { ChainNamespaceType } from "../../base";
3
3
  export declare const isChainIdSupported: (chainNamespace: ChainNamespaceType, chainID: number, loginSettings: EngineTypes.ConnectParams | undefined) => boolean;
4
+ export declare const formatChainId: (chainId: number | string) => string;
@@ -145,7 +145,7 @@ const getWalletServicesAnalyticsProperties = walletServicesConfig => {
145
145
  ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig1 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig1 === void 0 ? void 0 : _walletServicesConfig1.defaultPortfolio
146
146
  };
147
147
  };
148
- const sdkVersion = "10.5.3";
148
+ const sdkVersion = "10.5.5";
149
149
  const getErrorAnalyticsProperties = error => {
150
150
  try {
151
151
  const code = error instanceof Web3AuthError ? error.code : error === null || error === void 0 ? void 0 : error.code;
@@ -2,6 +2,7 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
3
  import { getAccountsFromNamespaces, parseAccountId } from '@walletconnect/utils';
4
4
  import { providerErrors, JRPCEngine, providerFromEngine } from '@web3auth/auth';
5
+ import { formatChainId } from './utils.js';
5
6
  import { switchChain, getAccounts, getEthProviderHandlers, getSolProviderHandlers } from './walletConnectV2Utils.js';
6
7
  import { createEthMiddleware, createEthChainSwitchMiddleware } from '../../providers/ethereum-provider/rpc/ethRpcMiddlewares.js';
7
8
  import { createEthJsonRpcClient } from '../../providers/ethereum-provider/rpc/jrpcClient.js';
@@ -196,15 +197,14 @@ class WalletConnectV2Provider extends BaseProvider {
196
197
  if (event.name === "chainChanged") {
197
198
  if (!data) return;
198
199
  const connectedChainId = data;
199
- const connectedHexChainId = `0x${connectedChainId.toString(16)}`;
200
-
200
+ const formattedChainId = formatChainId(connectedChainId);
201
201
  // Check if chainId changed and trigger event
202
202
  const {
203
203
  currentChain
204
204
  } = this;
205
- if (connectedHexChainId && currentChain.chainId !== connectedHexChainId) {
205
+ if (formattedChainId && currentChain.chainId !== formattedChainId) {
206
206
  // Handle rpcUrl update
207
- await this.setupEngine(connector, connectedHexChainId);
207
+ await this.setupEngine(connector, formattedChainId);
208
208
  }
209
209
  }
210
210
  });
@@ -0,0 +1,12 @@
1
+ import '@babel/runtime/helpers/objectSpread2';
2
+
3
+ const formatChainId = chainId => {
4
+ if (typeof chainId === "number") {
5
+ return `0x${chainId.toString(16)}`;
6
+ } else if (typeof chainId === "string") {
7
+ return chainId.startsWith("0x") ? chainId : `0x${parseInt(chainId, 10).toString(16)}`;
8
+ }
9
+ throw new Error(`Invalid chainId: ${chainId}`);
10
+ };
11
+
12
+ export { formatChainId };