@openocean.finance/wallet 1.10.71 → 1.10.73

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.
@@ -74,19 +74,47 @@ var RabbyWallet = /** @class */ (function (_super) {
74
74
  _this.icon = rabby_svg_1.default;
75
75
  _this.supportChains = [
76
76
  types_1.EnumChains.ETH,
77
+ types_1.EnumChains.ROPSTEN,
78
+ types_1.EnumChains.RINKEBY,
77
79
  types_1.EnumChains.BSC,
78
- types_1.EnumChains.Base,
80
+ types_1.EnumChains.BSCTEST,
79
81
  types_1.EnumChains.Polygon,
82
+ types_1.EnumChains.OKEX,
83
+ types_1.EnumChains.XDai,
84
+ types_1.EnumChains.HECO,
80
85
  types_1.EnumChains.Fantom,
81
86
  types_1.EnumChains.Sonic,
82
87
  types_1.EnumChains.Avalanche,
83
88
  types_1.EnumChains.Arbitrum,
84
89
  types_1.EnumChains.Optimism,
90
+ types_1.EnumChains.Boba,
91
+ types_1.EnumChains.Moonriver,
92
+ types_1.EnumChains.Aurora,
93
+ types_1.EnumChains.Cronos,
94
+ types_1.EnumChains.Harmony,
95
+ types_1.EnumChains.ONTEVM,
96
+ types_1.EnumChains.Metis,
97
+ types_1.EnumChains.Kava,
85
98
  types_1.EnumChains.Celo,
99
+ types_1.EnumChains.Klaytn,
86
100
  types_1.EnumChains.ZKSYNC,
101
+ types_1.EnumChains.Linea,
102
+ types_1.EnumChains.LineaTest,
87
103
  types_1.EnumChains.PolygonzkEVM,
104
+ types_1.EnumChains.Telos,
105
+ types_1.EnumChains.Scroll,
106
+ types_1.EnumChains.Base,
107
+ types_1.EnumChains.OpBNB,
108
+ types_1.EnumChains.Mantle,
109
+ types_1.EnumChains.Manta,
110
+ types_1.EnumChains.X1,
111
+ types_1.EnumChains.Blast,
88
112
  types_1.EnumChains.Mode,
113
+ types_1.EnumChains.PulseChain,
114
+ types_1.EnumChains.MerlinChain,
89
115
  types_1.EnumChains.Rootstock,
116
+ types_1.EnumChains.Sei,
117
+ types_1.EnumChains.ArbitrumSepolia,
90
118
  types_1.EnumChains.Gravity,
91
119
  types_1.EnumChains.ApeChain,
92
120
  types_1.EnumChains.Bera,
@@ -1,26 +1,64 @@
1
1
  import { EnumChains, EnumWalletName, EnumWalletType } from "../types";
2
2
  import BaseWallet from "./BaseWallet";
3
+ import Web3 from "web3";
3
4
  import { AppKit } from '@reown/appkit';
5
+ declare const DEFAULT_METADATA: {
6
+ name: string;
7
+ description: string;
8
+ url: string;
9
+ icons: string[];
10
+ };
11
+ interface WalletConnectConfig {
12
+ projectId?: string;
13
+ metadata?: typeof DEFAULT_METADATA;
14
+ }
4
15
  declare class WalletConnect extends BaseWallet {
5
16
  name: EnumWalletName;
6
17
  icon: any;
7
18
  supportChains: EnumChains[];
8
19
  type: EnumWalletType;
9
- sdk: any;
20
+ sdk: Web3 | null;
10
21
  infuraId?: string;
11
- modal: AppKit;
12
- modalIsClose: Boolean;
13
- disconnected: Boolean;
14
- networks: any;
15
- init(chainId?: number, config?: any): void;
16
- getModalClose(): boolean | Boolean;
17
- /**
18
- * connect metamask and get wallet address
19
- * @param chainId specific chainId,throw error when not match
20
- * @param config
21
- */
22
- requestConnect(chainId?: number, config?: any): Promise<any>;
23
- switchNetwork(chainId: number): Promise<void>;
22
+ modal: AppKit | null;
23
+ modalIsClosed: boolean;
24
+ disconnected: boolean;
25
+ wcProvider: any;
26
+ modalIsClose: boolean;
27
+ networks: any[];
28
+ /**
29
+ * Check if running in a wallet WebView (iOS wallet apps)
30
+ */
31
+ private isInWalletWebView;
32
+ /**
33
+ * Connect via WalletConnect v2 (used in wallet WebViews like Zerion/OKX/Trust iOS)
34
+ */
35
+ private connectViaWalletConnectV2;
36
+ /**
37
+ * Switch network using WalletConnect provider
38
+ */
39
+ private switchNetworkViaWC;
40
+ /**
41
+ * Add network using WalletConnect provider
42
+ */
43
+ private addNetworkViaWC;
44
+ initModal(chainId: number, config?: WalletConnectConfig): void;
45
+ /**
46
+ * Connect via AppKit (used in browser environments)
47
+ */
48
+ connectViaAppKit(chainId: number, config?: WalletConnectConfig): Promise<string>;
49
+ getModalClose(): boolean;
50
+ /**
51
+ * Connect wallet - automatically chooses WalletConnect v2 for wallet WebViews or AppKit for browsers
52
+ */
53
+ requestConnect(chainId?: number, config?: WalletConnectConfig): Promise<string>;
54
+ /**
55
+ * Switch to a different network
56
+ * Supports both AppKit modal and WalletConnect v2 provider
57
+ */
58
+ switchNetworkModal(chainId: number): Promise<void>;
59
+ /**
60
+ * Disconnect wallet
61
+ */
24
62
  disconnect(): Promise<void>;
25
63
  }
26
64
  export default WalletConnect;
@@ -69,7 +69,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
69
69
  * @name WalletConnect
70
70
  * @author openocean
71
71
  * @date 2021/4/21
72
- * @desc
72
+ * @desc WalletConnect wallet integration using AppKit and WalletConnect v2
73
73
  */
74
74
  // @ts-ignore
75
75
  var walletconnect_svg_1 = __importDefault(require("../assets/walletconnect.svg"));
@@ -81,6 +81,16 @@ var appkit_adapter_wagmi_1 = require("@reown/appkit-adapter-wagmi");
81
81
  var helper_1 = require("../helper");
82
82
  var chains_1 = require("viem/chains");
83
83
  var helper_2 = require("../helper");
84
+ var ethereum_provider_1 = __importDefault(require("@walletconnect/ethereum-provider"));
85
+ // Constants
86
+ var DEFAULT_PROJECT_ID = 'c1ca7adc83e89c7e7848440702f28f38';
87
+ var DEFAULT_METADATA = {
88
+ name: 'OpenOcean',
89
+ description: 'OpenOcean dex',
90
+ url: 'https://app.openocean.finance',
91
+ icons: ['https://s3.openocean.finance/token_logos/logos/1666922406718_40623932820124664.png'],
92
+ };
93
+ var NETWORK_SWITCH_DELAY = 1000;
84
94
  var WalletConnect = /** @class */ (function (_super) {
85
95
  __extends(WalletConnect, _super);
86
96
  function WalletConnect() {
@@ -140,18 +150,211 @@ var WalletConnect = /** @class */ (function (_super) {
140
150
  ];
141
151
  _this.type = types_1.EnumWalletType.WalletConnect;
142
152
  _this.sdk = null;
143
- return _this;
144
- }
145
- WalletConnect.prototype.init = function (chainId, config) {
146
- var _this = this;
147
- if (chainId === void 0) { chainId = 1; }
148
- var projectId = config && config.projectId ? config.projectId : 'c1ca7adc83e89c7e7848440702f28f38'; // '90304d7fbed3543fd7cac4b24f800264'
149
- var networks = this.networks = [
153
+ _this.modal = null;
154
+ _this.modalIsClosed = true;
155
+ _this.disconnected = false;
156
+ _this.wcProvider = null;
157
+ _this.modalIsClose = true;
158
+ _this.networks = [
150
159
  chains_1.mainnet, chains_1.telos, chains_1.opBNB, chains_1.mantle, chains_1.manta, chains_1.blast, chains_1.mode, chains_1.pulsechain, chains_1.merlin, chains_1.rootstock, chains_1.sei, chains_1.arbitrumSepolia,
151
160
  chains_1.gravity, chains_1.apeChain, chains_1.harmonyOne, chains_1.metis, chains_1.kava, chains_1.celo, chains_1.klaytn, chains_1.zksync, chains_1.linea, chains_1.lineaTestnet, chains_1.polygonZkEvm,
152
161
  chains_1.arbitrum, chains_1.bsc, chains_1.polygon, chains_1.okc, chains_1.xdc, chains_1.fantom, chains_1.avalanche, chains_1.optimism, chains_1.bob, chains_1.moonriver, chains_1.aurora, chains_1.cronos, chains_1.base,
153
162
  chains_1.flare, chains_1.unichain, chains_1.monadTestnet, chains_1.swellchain, chains_1.plume, chains_1.berachain, chains_1.sonic, chains_1.gnosis, chains_1.plumeMainnet, chains_1.monad, chains_1.injective, chains_1.tac,
154
163
  ];
164
+ return _this;
165
+ }
166
+ /**
167
+ * Check if running in a wallet WebView (iOS wallet apps)
168
+ */
169
+ WalletConnect.prototype.isInWalletWebView = function () {
170
+ var ua = navigator.userAgent || '';
171
+ var isIOS = /iPhone|iPad|iPod/i.test(ua);
172
+ if (!isIOS)
173
+ return false;
174
+ var isSafari = /Safari/i.test(ua) && !/CriOS|FxiOS|EdgiOS/i.test(ua);
175
+ var isChrome = /CriOS/i.test(ua);
176
+ var isFirefox = /FxiOS/i.test(ua);
177
+ var isEdge = /EdgiOS/i.test(ua);
178
+ // If not Safari, Chrome, Firefox, or Edge, assume it's a Wallet WebView
179
+ return !(isSafari || isChrome || isFirefox || isEdge);
180
+ };
181
+ /**
182
+ * Connect via WalletConnect v2 (used in wallet WebViews like Zerion/OKX/Trust iOS)
183
+ */
184
+ WalletConnect.prototype.connectViaWalletConnectV2 = function (chainId, config) {
185
+ return __awaiter(this, void 0, void 0, function () {
186
+ var projectId, metadata, _a, address, currentChainId;
187
+ return __generator(this, function (_b) {
188
+ switch (_b.label) {
189
+ case 0:
190
+ projectId = (config === null || config === void 0 ? void 0 : config.projectId) || DEFAULT_PROJECT_ID;
191
+ metadata = (config === null || config === void 0 ? void 0 : config.metadata) || DEFAULT_METADATA;
192
+ _a = this;
193
+ return [4 /*yield*/, ethereum_provider_1.default.init({
194
+ projectId: projectId,
195
+ chains: [chainId],
196
+ optionalChains: this.networks.map(function (n) { return n.id; }),
197
+ showQrModal: true,
198
+ metadata: metadata,
199
+ })];
200
+ case 1:
201
+ _a.wcProvider = _b.sent();
202
+ return [4 /*yield*/, this.wcProvider.connect()];
203
+ case 2:
204
+ _b.sent();
205
+ this.sdk = new web3_1.default(this.wcProvider);
206
+ return [4 /*yield*/, this.sdk.eth.getAccounts()];
207
+ case 3:
208
+ address = (_b.sent())[0];
209
+ this.address = address;
210
+ return [4 /*yield*/, this.sdk.eth.getChainId()];
211
+ case 4:
212
+ currentChainId = _b.sent();
213
+ if (!(chainId && currentChainId !== chainId)) return [3 /*break*/, 8];
214
+ return [4 /*yield*/, this.switchNetworkViaWC(chainId)];
215
+ case 5:
216
+ _b.sent();
217
+ return [4 /*yield*/, (0, helper_2.sleep)(NETWORK_SWITCH_DELAY)];
218
+ case 6:
219
+ _b.sent();
220
+ return [4 /*yield*/, this.sdk.eth.getChainId()];
221
+ case 7:
222
+ // Verify chain switch
223
+ currentChainId = _b.sent();
224
+ if (currentChainId !== chainId) {
225
+ throw new Error(types_1.EnumErrors.ChainIdNotMath);
226
+ }
227
+ _b.label = 8;
228
+ case 8:
229
+ this.chainId = currentChainId;
230
+ this.disconnected = false;
231
+ return [2 /*return*/, address];
232
+ }
233
+ });
234
+ });
235
+ };
236
+ /**
237
+ * Switch network using WalletConnect provider
238
+ */
239
+ WalletConnect.prototype.switchNetworkViaWC = function (chainId) {
240
+ var _a, _b;
241
+ return __awaiter(this, void 0, void 0, function () {
242
+ var chainIdHex, switchError_1;
243
+ return __generator(this, function (_c) {
244
+ switch (_c.label) {
245
+ case 0:
246
+ if (!this.wcProvider) {
247
+ throw new Error('WalletConnect provider not initialized');
248
+ }
249
+ _c.label = 1;
250
+ case 1:
251
+ _c.trys.push([1, 3, , 7]);
252
+ chainIdHex = "0x".concat(chainId.toString(16));
253
+ return [4 /*yield*/, this.wcProvider.request({
254
+ method: 'wallet_switchEthereumChain',
255
+ params: [{ chainId: chainIdHex }],
256
+ })];
257
+ case 2:
258
+ _c.sent();
259
+ return [3 /*break*/, 7];
260
+ case 3:
261
+ switchError_1 = _c.sent();
262
+ if (!(switchError_1.code === 4902 ||
263
+ (((_b = (_a = switchError_1.data) === null || _a === void 0 ? void 0 : _a.originalError) === null || _b === void 0 ? void 0 : _b.code) === 4902))) return [3 /*break*/, 5];
264
+ // Try to add the chain
265
+ return [4 /*yield*/, this.addNetworkViaWC(chainId)];
266
+ case 4:
267
+ // Try to add the chain
268
+ _c.sent();
269
+ return [3 /*break*/, 6];
270
+ case 5: throw switchError_1;
271
+ case 6: return [3 /*break*/, 7];
272
+ case 7: return [2 /*return*/];
273
+ }
274
+ });
275
+ });
276
+ };
277
+ /**
278
+ * Add network using WalletConnect provider
279
+ */
280
+ WalletConnect.prototype.addNetworkViaWC = function (chainId) {
281
+ var _a, _b, _c, _d;
282
+ return __awaiter(this, void 0, void 0, function () {
283
+ var chain, chainIdHex, rpcUrls, blockExplorerUrls, explorer, nativeCurrency, error_1;
284
+ return __generator(this, function (_e) {
285
+ switch (_e.label) {
286
+ case 0:
287
+ if (!this.wcProvider) {
288
+ throw new Error('WalletConnect provider not initialized');
289
+ }
290
+ chain = this.networks.find(function (item) { return item.id === chainId; });
291
+ if (!chain) {
292
+ throw new Error("Chain with id ".concat(chainId, " is not supported"));
293
+ }
294
+ chainIdHex = "0x".concat(chainId.toString(16));
295
+ rpcUrls = [];
296
+ if (chain.rpcUrls) {
297
+ if (Array.isArray(chain.rpcUrls)) {
298
+ rpcUrls = chain.rpcUrls;
299
+ }
300
+ else if ((_a = chain.rpcUrls.default) === null || _a === void 0 ? void 0 : _a.http) {
301
+ rpcUrls = Array.isArray(chain.rpcUrls.default.http)
302
+ ? chain.rpcUrls.default.http
303
+ : [chain.rpcUrls.default.http];
304
+ }
305
+ else if ((_b = chain.rpcUrls.public) === null || _b === void 0 ? void 0 : _b.http) {
306
+ rpcUrls = Array.isArray(chain.rpcUrls.public.http)
307
+ ? chain.rpcUrls.public.http
308
+ : [chain.rpcUrls.public.http];
309
+ }
310
+ }
311
+ blockExplorerUrls = [];
312
+ if ((_d = (_c = chain.blockExplorers) === null || _c === void 0 ? void 0 : _c.default) === null || _d === void 0 ? void 0 : _d.url) {
313
+ blockExplorerUrls = [chain.blockExplorers.default.url];
314
+ }
315
+ else if (chain.blockExplorers && typeof chain.blockExplorers === 'object') {
316
+ explorer = Object.values(chain.blockExplorers)[0];
317
+ if (explorer === null || explorer === void 0 ? void 0 : explorer.url) {
318
+ blockExplorerUrls = [explorer.url];
319
+ }
320
+ }
321
+ nativeCurrency = chain.nativeCurrency || {
322
+ name: 'ETH',
323
+ symbol: 'ETH',
324
+ decimals: 18,
325
+ };
326
+ _e.label = 1;
327
+ case 1:
328
+ _e.trys.push([1, 3, , 4]);
329
+ return [4 /*yield*/, this.wcProvider.request({
330
+ method: 'wallet_addEthereumChain',
331
+ params: [{
332
+ chainId: chainIdHex,
333
+ chainName: chain.name,
334
+ nativeCurrency: nativeCurrency,
335
+ rpcUrls: rpcUrls.length > 0 ? rpcUrls : undefined,
336
+ blockExplorerUrls: blockExplorerUrls.length > 0 ? blockExplorerUrls : undefined,
337
+ }],
338
+ })];
339
+ case 2:
340
+ _e.sent();
341
+ return [3 /*break*/, 4];
342
+ case 3:
343
+ error_1 = _e.sent();
344
+ throw new Error("Failed to add network: ".concat((error_1 === null || error_1 === void 0 ? void 0 : error_1.message) || error_1));
345
+ case 4: return [2 /*return*/];
346
+ }
347
+ });
348
+ });
349
+ };
350
+ WalletConnect.prototype.initModal = function (chainId, config) {
351
+ var _this = this;
352
+ // Prevent duplicate initialization
353
+ if (this.modal) {
354
+ return;
355
+ }
356
+ var projectId = config && config.projectId ? config.projectId : 'c1ca7adc83e89c7e7848440702f28f38'; // '90304d7fbed3543fd7cac4b24f800264'
357
+ var networks = this.networks;
155
358
  var wagmiAdapter = new appkit_adapter_wagmi_1.WagmiAdapter({
156
359
  projectId: projectId,
157
360
  networks: networks
@@ -196,17 +399,10 @@ var WalletConnect = /** @class */ (function (_super) {
196
399
  console.log(data);
197
400
  });
198
401
  };
199
- WalletConnect.prototype.getModalClose = function () {
200
- var open = this.modal.getState().open;
201
- return this.modalIsClose || !open;
202
- };
203
402
  /**
204
- * connect metamask and get wallet address
205
- * @param chainId specific chainId,throw error when not match
206
- * @param config
403
+ * Connect via AppKit (used in browser environments)
207
404
  */
208
- WalletConnect.prototype.requestConnect = function (chainId, config) {
209
- if (chainId === void 0) { chainId = 1; }
405
+ WalletConnect.prototype.connectViaAppKit = function (chainId, config) {
210
406
  return __awaiter(this, void 0, void 0, function () {
211
407
  var provider1_1, providerType, isConnected, currentChainId_1, modalChainId, currentChainId_2, modalChainId_1, address_1, address1, _a, provider1, currentChainId, currentChainId_3, modalChainId, address, _b;
212
408
  var _this = this;
@@ -216,7 +412,7 @@ var WalletConnect = /** @class */ (function (_super) {
216
412
  this.modalIsClose = false;
217
413
  console.log('requestConnect1111-----------------');
218
414
  if (!!this.modal) return [3 /*break*/, 2];
219
- this.init(chainId, config);
415
+ this.initModal(chainId, config);
220
416
  return [4 /*yield*/, (0, helper_2.sleep)(5000)];
221
417
  case 1:
222
418
  _c.sent();
@@ -225,7 +421,6 @@ var WalletConnect = /** @class */ (function (_super) {
225
421
  if (!this.modal) return [3 /*break*/, 10];
226
422
  console.log('requestConnect222-----------------');
227
423
  provider1_1 = this.modal.getWalletProvider();
228
- console.log(provider1_1);
229
424
  providerType = this.modal.getWalletProviderType();
230
425
  console.log('providerType', providerType);
231
426
  isConnected = this.modal.getIsConnectedState();
@@ -244,7 +439,7 @@ var WalletConnect = /** @class */ (function (_super) {
244
439
  console.log(modalChainId, currentChainId_1, chainId);
245
440
  if (!(chainId && currentChainId_1 != chainId)) return [3 /*break*/, 7];
246
441
  console.log('requestConnect-----*********');
247
- return [4 /*yield*/, this.switchNetwork(+chainId)];
442
+ return [4 /*yield*/, this.switchNetworkModal(+chainId)];
248
443
  case 4:
249
444
  _c.sent();
250
445
  return [4 /*yield*/, (0, helper_2.sleep)(1000)];
@@ -302,7 +497,7 @@ var WalletConnect = /** @class */ (function (_super) {
302
497
  console.log('autoWalletCheck333-----------------');
303
498
  this.disconnected = false;
304
499
  if (!(chainId && currentChainId != chainId)) return [3 /*break*/, 17];
305
- return [4 /*yield*/, this.switchNetwork(chainId)];
500
+ return [4 /*yield*/, this.switchNetworkModal(chainId)];
306
501
  case 14:
307
502
  _c.sent();
308
503
  return [4 /*yield*/, (0, helper_2.sleep)(1000)];
@@ -333,33 +528,100 @@ var WalletConnect = /** @class */ (function (_super) {
333
528
  });
334
529
  });
335
530
  };
336
- WalletConnect.prototype.switchNetwork = function (chainId) {
531
+ WalletConnect.prototype.getModalClose = function () {
532
+ var open = this.modal.getState().open;
533
+ return this.modalIsClose || !open;
534
+ };
535
+ /**
536
+ * Connect wallet - automatically chooses WalletConnect v2 for wallet WebViews or AppKit for browsers
537
+ */
538
+ WalletConnect.prototype.requestConnect = function (chainId, config) {
539
+ if (chainId === void 0) { chainId = 1; }
540
+ return __awaiter(this, void 0, void 0, function () {
541
+ var inWallet;
542
+ return __generator(this, function (_a) {
543
+ switch (_a.label) {
544
+ case 0:
545
+ inWallet = this.isInWalletWebView();
546
+ if (!inWallet) return [3 /*break*/, 2];
547
+ return [4 /*yield*/, this.connectViaWalletConnectV2(chainId, config)];
548
+ case 1: return [2 /*return*/, _a.sent()];
549
+ case 2: return [4 /*yield*/, this.connectViaAppKit(chainId, config)];
550
+ case 3:
551
+ // Use AppKit for browser environments
552
+ return [2 /*return*/, _a.sent()];
553
+ }
554
+ });
555
+ });
556
+ };
557
+ /**
558
+ * Switch to a different network
559
+ * Supports both AppKit modal and WalletConnect v2 provider
560
+ */
561
+ WalletConnect.prototype.switchNetworkModal = function (chainId) {
337
562
  return __awaiter(this, void 0, void 0, function () {
338
- var chain;
563
+ var chain, currentChainId;
339
564
  return __generator(this, function (_a) {
340
565
  switch (_a.label) {
341
566
  case 0:
342
- chain = this.networks.find(function (item) { return item.id == chainId; });
567
+ if (!this.sdk) {
568
+ throw new Error('Wallet not connected. Please connect first.');
569
+ }
570
+ chain = this.networks.find(function (item) { return item.id === chainId; });
343
571
  if (!chain) {
344
572
  throw new Error("Chain with id ".concat(chainId, " is not supported"));
345
573
  }
574
+ if (!this.modal) return [3 /*break*/, 2];
575
+ // AppKit modal (browser environment)
346
576
  return [4 /*yield*/, this.modal.switchNetwork(chain)];
347
577
  case 1:
578
+ // AppKit modal (browser environment)
579
+ _a.sent();
580
+ return [3 /*break*/, 3];
581
+ case 2: throw new Error('Unable to determine connection type. Please reconnect.');
582
+ case 3:
583
+ // Wait for network switch to complete
584
+ return [4 /*yield*/, (0, helper_2.sleep)(NETWORK_SWITCH_DELAY)];
585
+ case 4:
586
+ // Wait for network switch to complete
348
587
  _a.sent();
588
+ return [4 /*yield*/, this.sdk.eth.getChainId()];
589
+ case 5:
590
+ currentChainId = _a.sent();
591
+ if (currentChainId !== chainId) {
592
+ throw new Error(types_1.EnumErrors.ChainIdNotMath);
593
+ }
594
+ this.chainId = currentChainId;
349
595
  return [2 /*return*/];
350
596
  }
351
597
  });
352
598
  });
353
599
  };
600
+ /**
601
+ * Disconnect wallet
602
+ */
354
603
  WalletConnect.prototype.disconnect = function () {
355
604
  return __awaiter(this, void 0, void 0, function () {
356
605
  return __generator(this, function (_a) {
357
606
  switch (_a.label) {
358
607
  case 0:
359
608
  this.disconnected = true;
360
- return [4 /*yield*/, this.modal.disconnect()];
609
+ if (!this.wcProvider) return [3 /*break*/, 2];
610
+ return [4 /*yield*/, this.wcProvider.disconnect()];
361
611
  case 1:
362
612
  _a.sent();
613
+ this.wcProvider = null;
614
+ _a.label = 2;
615
+ case 2:
616
+ if (!this.modal) return [3 /*break*/, 4];
617
+ return [4 /*yield*/, this.modal.disconnect()];
618
+ case 3:
619
+ _a.sent();
620
+ _a.label = 4;
621
+ case 4:
622
+ this.sdk = null;
623
+ this.address = undefined;
624
+ this.chainId = undefined;
363
625
  return [2 /*return*/];
364
626
  }
365
627
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "1.10.71",
3
+ "version": "1.10.73",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {