@web3auth/no-modal 10.8.0 → 10.8.1

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.8.0";
148
+ const sdkVersion = "10.8.1";
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;
@@ -147,12 +147,37 @@ class CoinbaseConnector extends baseEvmConnector.BaseEvmConnector {
147
147
  }
148
148
  async switchChain(params, init = false) {
149
149
  super.checkSwitchChainRequirements(params, init);
150
- await this.coinbaseProvider.request({
151
- method: "wallet_switchEthereumChain",
152
- params: [{
153
- chainId: params.chainId
154
- }]
155
- });
150
+ try {
151
+ await this.coinbaseProvider.request({
152
+ method: "wallet_switchEthereumChain",
153
+ params: [{
154
+ chainId: params.chainId
155
+ }]
156
+ });
157
+ } catch (switchError) {
158
+ // 4902 indicates that the client does not recognize the Harmony One network
159
+ if (switchError.code === 4902) {
160
+ const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId);
161
+ if (!chainConfig) throw index$1.WalletLoginError.connectionError("Chain config is not available");
162
+ await this.coinbaseProvider.request({
163
+ method: "wallet_addEthereumChain",
164
+ params: [{
165
+ chainId: chainConfig.chainId,
166
+ rpcUrls: [chainConfig.rpcTarget],
167
+ chainName: chainConfig.displayName,
168
+ nativeCurrency: {
169
+ name: chainConfig.tickerName,
170
+ symbol: chainConfig.ticker,
171
+ decimals: chainConfig.decimals || 18
172
+ },
173
+ blockExplorerUrls: [chainConfig.blockExplorerUrl],
174
+ iconUrls: [chainConfig.logo]
175
+ }]
176
+ });
177
+ return;
178
+ }
179
+ throw switchError;
180
+ }
156
181
  }
157
182
  async enableMFA() {
158
183
  throw new Error("Method Not implemented");
@@ -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.8.0";
148
+ const sdkVersion = "10.8.1";
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;
@@ -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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@web3auth/no-modal",
3
- "version": "10.8.0",
3
+ "version": "10.8.1",
4
4
  "description": "Multi chain wallet aggregator for web3Auth",
5
5
  "keywords": [
6
6
  "web3Auth/no-modal",
@@ -203,5 +203,5 @@
203
203
  "node": ">=20.x",
204
204
  "npm": ">=9.x"
205
205
  },
206
- "gitHead": "233481482c77b2bfa9b27f41589df45cf0978072"
206
+ "gitHead": "d93410531e87a465eba46ae0e9b645a6646ee0b4"
207
207
  }