@subwallet/extension-base 1.3.52-0 → 1.3.53-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.
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.3.52-0'
16
+ version: '1.3.53-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -162,7 +162,17 @@ class AccountJsonHandler extends _Base.AccountBaseHandler {
162
162
  accountProxies,
163
163
  modifyPairs
164
164
  } = json;
165
- const pairs = jsons.map(pair => _uiKeyring.keyring.createFromJson(pair));
165
+ const pairs = jsons.reduce((rs, pair) => {
166
+ try {
167
+ rs.push(_uiKeyring.keyring.createFromJson(pair));
168
+ } catch (e) {
169
+ console.error(e);
170
+ }
171
+ return rs;
172
+ }, []);
173
+ if (!(pairs !== null && pairs !== void 0 && pairs.length)) {
174
+ throw new Error((0, _i18next.t)('No valid accounts found to import'));
175
+ }
166
176
  const accountProxyMap = (0, _utils.combineAccountsWithKeyPair)(pairs, modifyPairs, accountProxies);
167
177
  const result = Object.values(accountProxyMap).map(proxy => {
168
178
  const rs = {
@@ -205,9 +215,24 @@ class AccountJsonHandler extends _Base.AccountBaseHandler {
205
215
  try {
206
216
  const {
207
217
  accountProxies,
208
- modifyPairs
218
+ modifyPairs: modifyPairsRestored
209
219
  } = file;
210
- const pairs = jsons.map(pair => _uiKeyring.keyring.createFromJson(pair));
220
+ const modifyPairs = {};
221
+ const pairs = jsons.reduce((rs, pairJson) => {
222
+ try {
223
+ const pair = _uiKeyring.keyring.createFromJson(pairJson);
224
+ if (modifyPairsRestored !== null && modifyPairsRestored !== void 0 && modifyPairsRestored[pair.address]) {
225
+ modifyPairs[pair.address] = modifyPairsRestored[pair.address];
226
+ }
227
+ rs.push(pair);
228
+ } catch (e) {
229
+ console.error(e);
230
+ }
231
+ return rs;
232
+ }, []);
233
+ if (!(pairs !== null && pairs !== void 0 && pairs.length)) {
234
+ throw new Error((0, _i18next.t)('No valid accounts found to import'));
235
+ }
211
236
  const accountProxyMap = (0, _utils.combineAccountsWithKeyPair)(pairs, modifyPairs, accountProxies);
212
237
  const rawProxyIds = _proxyIds && _proxyIds.length ? _proxyIds : Object.keys(accountProxyMap);
213
238
  let _exists;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WALLET_CONNECT_SUPPORT_NAMESPACES = exports.WALLET_CONNECT_SUPPORTED_METHODS = exports.WALLET_CONNECT_REQUEST_KEY = exports.WALLET_CONNECT_POLKADOT_NAMESPACE = exports.WALLET_CONNECT_EIP155_NAMESPACE = exports.RELAY_URL = exports.PROJECT_ID_MOBILE = exports.PROJECT_ID_EXTENSION = exports.DEFAULT_WALLET_CONNECT_OPTIONS = exports.ALL_WALLET_CONNECT_EVENT = void 0;
6
+ exports.WALLET_CONNECT_SUPPORT_NAMESPACES = exports.WALLET_CONNECT_SUPPORTED_METHODS = exports.WALLET_CONNECT_SESSION_TIMEOUT = exports.WALLET_CONNECT_REQUEST_KEY = exports.WALLET_CONNECT_POLKADOT_NAMESPACE = exports.WALLET_CONNECT_EIP155_NAMESPACE = exports.RELAY_URL = exports.RELAY_FALLBACK_URL = exports.PROJECT_ID_MOBILE = exports.PROJECT_ID_EXTENSION = exports.DEFAULT_WALLET_CONNECT_OPTIONS = exports.ALL_WALLET_CONNECT_EVENT = void 0;
7
7
  var _types = require("@subwallet/extension-base/services/wallet-connect-service/types");
8
8
  var _utils = require("@subwallet/extension-base/utils");
9
9
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
@@ -15,6 +15,8 @@ const PROJECT_ID_MOBILE = '6da34c0b48164d27681924dd9a46d6be';
15
15
  exports.PROJECT_ID_MOBILE = PROJECT_ID_MOBILE;
16
16
  const RELAY_URL = 'wss://relay.walletconnect.com';
17
17
  exports.RELAY_URL = RELAY_URL;
18
+ const RELAY_FALLBACK_URL = 'wss://relay.walletconnect.org';
19
+ exports.RELAY_FALLBACK_URL = RELAY_FALLBACK_URL;
18
20
  const DEFAULT_WALLET_CONNECT_OPTIONS = {
19
21
  logger: 'error',
20
22
  projectId: _utils.targetIsMobile ? PROJECT_ID_MOBILE : PROJECT_ID_EXTENSION,
@@ -38,4 +40,6 @@ exports.WALLET_CONNECT_EIP155_NAMESPACE = WALLET_CONNECT_EIP155_NAMESPACE;
38
40
  const WALLET_CONNECT_POLKADOT_NAMESPACE = 'polkadot';
39
41
  exports.WALLET_CONNECT_POLKADOT_NAMESPACE = WALLET_CONNECT_POLKADOT_NAMESPACE;
40
42
  const WALLET_CONNECT_SUPPORT_NAMESPACES = [WALLET_CONNECT_EIP155_NAMESPACE, WALLET_CONNECT_POLKADOT_NAMESPACE];
41
- exports.WALLET_CONNECT_SUPPORT_NAMESPACES = WALLET_CONNECT_SUPPORT_NAMESPACES;
43
+ exports.WALLET_CONNECT_SUPPORT_NAMESPACES = WALLET_CONNECT_SUPPORT_NAMESPACES;
44
+ const WALLET_CONNECT_SESSION_TIMEOUT = 20000; // 20 seconds
45
+ exports.WALLET_CONNECT_SESSION_TIMEOUT = WALLET_CONNECT_SESSION_TIMEOUT;
@@ -10,8 +10,9 @@ var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime
10
10
  var _utils = require("@json-rpc-tools/utils");
11
11
  var _Eip155RequestHandler = _interopRequireDefault(require("@subwallet/extension-base/services/wallet-connect-service/handler/Eip155RequestHandler"));
12
12
  var _storage = require("@subwallet/extension-base/storage");
13
+ var _utils2 = require("@subwallet/extension-base/utils");
13
14
  var _signClient = _interopRequireDefault(require("@walletconnect/sign-client"));
14
- var _utils2 = require("@walletconnect/utils");
15
+ var _utils3 = require("@walletconnect/utils");
15
16
  var _rxjs = require("rxjs");
16
17
  var _PolkadotRequestHandler = _interopRequireDefault(require("./handler/PolkadotRequestHandler"));
17
18
  var _constants = require("./constants");
@@ -130,7 +131,19 @@ class WalletConnectService {
130
131
  async initClient(force) {
131
132
  (0, _classPrivateFieldLooseBase2.default)(this, _removeListener)[_removeListener]();
132
133
  if (force || (await this.haveData())) {
133
- (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client] = await _signClient.default.init((0, _classPrivateFieldLooseBase2.default)(this, _option)[_option]);
134
+ try {
135
+ (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client] = await _signClient.default.init((0, _classPrivateFieldLooseBase2.default)(this, _option)[_option]);
136
+ } catch (e) {
137
+ if ((0, _classPrivateFieldLooseBase2.default)(this, _option)[_option].relayUrl === _constants.RELAY_URL) {
138
+ (0, _classPrivateFieldLooseBase2.default)(this, _option)[_option] = {
139
+ ...(0, _classPrivateFieldLooseBase2.default)(this, _option)[_option],
140
+ relayUrl: _constants.RELAY_FALLBACK_URL
141
+ };
142
+ (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client] = await _signClient.default.init((0, _classPrivateFieldLooseBase2.default)(this, _option)[_option]);
143
+ } else {
144
+ throw e;
145
+ }
146
+ }
134
147
  }
135
148
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
136
149
  (0, _classPrivateFieldLooseBase2.default)(this, _createListener)[_createListener]();
@@ -143,7 +156,7 @@ class WalletConnectService {
143
156
  var _classPrivateFieldLoo2;
144
157
  const session = (_classPrivateFieldLoo2 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo2 === void 0 ? void 0 : _classPrivateFieldLoo2.session.get(topic);
145
158
  if (!session) {
146
- throw new Error((0, _utils2.getInternalError)('MISMATCHED_TOPIC').message);
159
+ throw new Error((0, _utils3.getInternalError)('MISMATCHED_TOPIC').message);
147
160
  } else {
148
161
  return session;
149
162
  }
@@ -153,17 +166,21 @@ class WalletConnectService {
153
166
  await this.initClient();
154
167
  }
155
168
  async connect(uri) {
156
- var _classPrivateFieldLoo3;
157
- if (!(await this.haveData())) {
169
+ var _classPrivateFieldLoo3, _classPrivateFieldLoo4;
170
+ if (!(await this.haveData()) || !((_classPrivateFieldLoo3 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) !== null && _classPrivateFieldLoo3 !== void 0 && _classPrivateFieldLoo3.core.relayer.connected)) {
158
171
  await this.initClient(true);
159
172
  }
160
173
  (0, _classPrivateFieldLooseBase2.default)(this, _checkClient)[_checkClient]();
161
- await ((_classPrivateFieldLoo3 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo3 === void 0 ? void 0 : _classPrivateFieldLoo3.pair({
174
+
175
+ // The purpose of designing a timeout for pairing is to prevent the promise from not being resolved if there are issues during the pairing process.
176
+ await Promise.race([(_classPrivateFieldLoo4 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo4 === void 0 ? void 0 : _classPrivateFieldLoo4.pair({
162
177
  uri
163
- }));
178
+ }), (0, _utils2.wait)(_constants.WALLET_CONNECT_SESSION_TIMEOUT).then(() => {
179
+ throw new Error((0, _utils3.getInternalError)('EXPIRED').message);
180
+ })]);
164
181
  }
165
182
  async approveSession(result) {
166
- var _classPrivateFieldLoo4;
183
+ var _classPrivateFieldLoo5;
167
184
  (0, _classPrivateFieldLooseBase2.default)(this, _checkClient)[_checkClient]();
168
185
  Object.entries(result.namespaces).forEach(_ref3 => {
169
186
  let [namespace, {
@@ -172,34 +189,34 @@ class WalletConnectService {
172
189
  methods = [...methods, ...this.findMethodsMissing(_constants.WALLET_CONNECT_EIP155_NAMESPACE === namespace ? methodEVMRequire : methodDOTRequire, methods)];
173
190
  result.namespaces[namespace].methods = methods;
174
191
  });
175
- await ((_classPrivateFieldLoo4 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo4 === void 0 ? void 0 : _classPrivateFieldLoo4.approve(result));
192
+ await ((_classPrivateFieldLoo5 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo5 === void 0 ? void 0 : _classPrivateFieldLoo5.approve(result));
176
193
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
177
194
  }
178
195
  async rejectSession(id) {
179
- var _classPrivateFieldLoo5;
196
+ var _classPrivateFieldLoo6;
180
197
  (0, _classPrivateFieldLooseBase2.default)(this, _checkClient)[_checkClient]();
181
- await ((_classPrivateFieldLoo5 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo5 === void 0 ? void 0 : _classPrivateFieldLoo5.reject({
198
+ await ((_classPrivateFieldLoo6 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo6 === void 0 ? void 0 : _classPrivateFieldLoo6.reject({
182
199
  id: id,
183
- reason: (0, _utils2.getSdkError)('USER_REJECTED')
200
+ reason: (0, _utils3.getSdkError)('USER_REJECTED')
184
201
  }));
185
202
  }
186
203
  async responseRequest(response) {
187
- var _classPrivateFieldLoo6;
204
+ var _classPrivateFieldLoo7;
188
205
  (0, _classPrivateFieldLooseBase2.default)(this, _checkClient)[_checkClient]();
189
- await ((_classPrivateFieldLoo6 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo6 === void 0 ? void 0 : _classPrivateFieldLoo6.respond(response));
206
+ await ((_classPrivateFieldLoo7 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo7 === void 0 ? void 0 : _classPrivateFieldLoo7.respond(response));
190
207
  }
191
208
  async resetWallet(resetAll) {
192
- var _classPrivateFieldLoo7, _classPrivateFieldLoo9, _classPrivateFieldLoo11;
209
+ var _classPrivateFieldLoo8, _classPrivateFieldLoo10, _classPrivateFieldLoo12;
193
210
  (0, _classPrivateFieldLooseBase2.default)(this, _removeListener)[_removeListener]();
194
211
 
195
212
  // Disconnect session
196
- const sessions = ((_classPrivateFieldLoo7 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo7 === void 0 ? void 0 : _classPrivateFieldLoo7.session.values) || [];
213
+ const sessions = ((_classPrivateFieldLoo8 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo8 === void 0 ? void 0 : _classPrivateFieldLoo8.session.values) || [];
197
214
  for (const session of sessions) {
198
215
  try {
199
- var _classPrivateFieldLoo8;
200
- await ((_classPrivateFieldLoo8 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo8 === void 0 ? void 0 : _classPrivateFieldLoo8.disconnect({
216
+ var _classPrivateFieldLoo9;
217
+ await ((_classPrivateFieldLoo9 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo9 === void 0 ? void 0 : _classPrivateFieldLoo9.disconnect({
201
218
  topic: session.topic,
202
- reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
219
+ reason: (0, _utils3.getSdkError)('USER_DISCONNECTED')
203
220
  }));
204
221
  } catch (e) {
205
222
  console.error(e);
@@ -207,24 +224,24 @@ class WalletConnectService {
207
224
  }
208
225
 
209
226
  // Disconnect pair
210
- const pairs = ((_classPrivateFieldLoo9 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo9 === void 0 ? void 0 : _classPrivateFieldLoo9.pairing.values) || [];
227
+ const pairs = ((_classPrivateFieldLoo10 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo10 === void 0 ? void 0 : _classPrivateFieldLoo10.pairing.values) || [];
211
228
  for (const pair of pairs) {
212
229
  try {
213
- var _classPrivateFieldLoo10;
214
- await ((_classPrivateFieldLoo10 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo10 === void 0 ? void 0 : _classPrivateFieldLoo10.disconnect({
230
+ var _classPrivateFieldLoo11;
231
+ await ((_classPrivateFieldLoo11 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo11 === void 0 ? void 0 : _classPrivateFieldLoo11.disconnect({
215
232
  topic: pair.topic,
216
- reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
233
+ reason: (0, _utils3.getSdkError)('USER_DISCONNECTED')
217
234
  }));
218
235
  } catch (e) {
219
236
  console.error(e);
220
237
  }
221
238
  }
222
- const keys = (await ((_classPrivateFieldLoo11 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo11 === void 0 ? void 0 : _classPrivateFieldLoo11.core.storage.getKeys())) || [];
239
+ const keys = (await ((_classPrivateFieldLoo12 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo12 === void 0 ? void 0 : _classPrivateFieldLoo12.core.storage.getKeys())) || [];
223
240
  const deleteKeys = resetAll ? keys : keys.filter(key => key.startsWith('wc@'));
224
241
  for (const key of deleteKeys) {
225
242
  try {
226
- var _classPrivateFieldLoo12;
227
- await ((_classPrivateFieldLoo12 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo12 === void 0 ? void 0 : _classPrivateFieldLoo12.core.storage.removeItem(key));
243
+ var _classPrivateFieldLoo13;
244
+ await ((_classPrivateFieldLoo13 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo13 === void 0 ? void 0 : _classPrivateFieldLoo13.core.storage.removeItem(key));
228
245
  } catch (e) {
229
246
  console.error(e);
230
247
  }
@@ -233,10 +250,10 @@ class WalletConnectService {
233
250
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
234
251
  }
235
252
  async disconnect(topic) {
236
- var _classPrivateFieldLoo13;
237
- await ((_classPrivateFieldLoo13 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo13 === void 0 ? void 0 : _classPrivateFieldLoo13.disconnect({
253
+ var _classPrivateFieldLoo14;
254
+ await ((_classPrivateFieldLoo14 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo14 === void 0 ? void 0 : _classPrivateFieldLoo14.disconnect({
238
255
  topic: topic,
239
- reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
256
+ reason: (0, _utils3.getSdkError)('USER_DISCONNECTED')
240
257
  }));
241
258
  (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions]();
242
259
  }
@@ -279,19 +296,19 @@ function _onSessionRequest2(requestEvent) {
279
296
  const chainInfoMap = (0, _classPrivateFieldLooseBase2.default)(this, _koniState)[_koniState].getChainInfoMap();
280
297
  const [requestNamespace] = chainId.split(':');
281
298
  if (!namespaces.includes(requestNamespace)) {
282
- throw Error((0, _utils2.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message);
299
+ throw Error((0, _utils3.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message);
283
300
  }
284
301
  if (!chains.includes(chainId)) {
285
- throw Error((0, _utils2.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + chainId);
302
+ throw Error((0, _utils3.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + chainId);
286
303
  }
287
304
  if (!(0, _helpers.isSupportWalletConnectChain)(chainId, chainInfoMap)) {
288
- throw Error((0, _utils2.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + chainId);
305
+ throw Error((0, _utils3.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + chainId);
289
306
  }
290
307
  if (!methods.includes(method)) {
291
- throw Error((0, _utils2.getSdkError)('UNAUTHORIZED_METHOD').message + ' ' + method);
308
+ throw Error((0, _utils3.getSdkError)('UNAUTHORIZED_METHOD').message + ' ' + method);
292
309
  }
293
310
  if (!_constants.WALLET_CONNECT_SUPPORTED_METHODS.includes(method)) {
294
- throw Error((0, _utils2.getSdkError)('UNSUPPORTED_METHODS').message + ' ' + method);
311
+ throw Error((0, _utils3.getSdkError)('UNSUPPORTED_METHODS').message + ' ' + method);
295
312
  }
296
313
  switch (method) {
297
314
  case _types.POLKADOT_SIGNING_METHODS.POLKADOT_SIGN_MESSAGE:
@@ -307,7 +324,7 @@ function _onSessionRequest2(requestEvent) {
307
324
  (0, _classPrivateFieldLooseBase2.default)(this, _eip155RequestHandler)[_eip155RequestHandler].handleRequest(requestEvent);
308
325
  break;
309
326
  default:
310
- throw Error((0, _utils2.getSdkError)('INVALID_METHOD').message + ' ' + method);
327
+ throw Error((0, _utils3.getSdkError)('INVALID_METHOD').message + ' ' + method);
311
328
  }
312
329
  } catch (e) {
313
330
  console.log(e);
@@ -343,22 +360,22 @@ async function _onPingReply2(_ref4) {
343
360
  }
344
361
  }
345
362
  function _createListener2() {
346
- var _classPrivateFieldLoo14, _classPrivateFieldLoo15, _classPrivateFieldLoo16, _classPrivateFieldLoo17, _classPrivateFieldLoo18, _classPrivateFieldLoo19;
347
- (_classPrivateFieldLoo14 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo14 === void 0 ? void 0 : _classPrivateFieldLoo14.on('session_proposal', (0, _classPrivateFieldLooseBase2.default)(this, _onSessionProposal)[_onSessionProposal].bind(this));
348
- (_classPrivateFieldLoo15 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo15 === void 0 ? void 0 : _classPrivateFieldLoo15.on('session_request', (0, _classPrivateFieldLooseBase2.default)(this, _onSessionRequest)[_onSessionRequest].bind(this));
349
- (_classPrivateFieldLoo16 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo16 === void 0 ? void 0 : _classPrivateFieldLoo16.on('session_ping', (0, _classPrivateFieldLooseBase2.default)(this, _onPingReply)[_onPingReply].bind(this));
350
- (_classPrivateFieldLoo17 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo17 === void 0 ? void 0 : _classPrivateFieldLoo17.on('session_event', data => console.log('event', data));
351
- (_classPrivateFieldLoo18 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo18 === void 0 ? void 0 : _classPrivateFieldLoo18.on('session_update', data => console.log('update', data));
352
- (_classPrivateFieldLoo19 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo19 === void 0 ? void 0 : _classPrivateFieldLoo19.on('session_delete', (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions].bind(this));
363
+ var _classPrivateFieldLoo15, _classPrivateFieldLoo16, _classPrivateFieldLoo17, _classPrivateFieldLoo18, _classPrivateFieldLoo19, _classPrivateFieldLoo20;
364
+ (_classPrivateFieldLoo15 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo15 === void 0 ? void 0 : _classPrivateFieldLoo15.on('session_proposal', (0, _classPrivateFieldLooseBase2.default)(this, _onSessionProposal)[_onSessionProposal].bind(this));
365
+ (_classPrivateFieldLoo16 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo16 === void 0 ? void 0 : _classPrivateFieldLoo16.on('session_request', (0, _classPrivateFieldLooseBase2.default)(this, _onSessionRequest)[_onSessionRequest].bind(this));
366
+ (_classPrivateFieldLoo17 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo17 === void 0 ? void 0 : _classPrivateFieldLoo17.on('session_ping', (0, _classPrivateFieldLooseBase2.default)(this, _onPingReply)[_onPingReply].bind(this));
367
+ (_classPrivateFieldLoo18 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo18 === void 0 ? void 0 : _classPrivateFieldLoo18.on('session_event', data => console.log('event', data));
368
+ (_classPrivateFieldLoo19 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo19 === void 0 ? void 0 : _classPrivateFieldLoo19.on('session_update', data => console.log('update', data));
369
+ (_classPrivateFieldLoo20 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo20 === void 0 ? void 0 : _classPrivateFieldLoo20.on('session_delete', (0, _classPrivateFieldLooseBase2.default)(this, _updateSessions)[_updateSessions].bind(this));
353
370
  }
354
371
  function _removeListener2() {
355
372
  _constants.ALL_WALLET_CONNECT_EVENT.forEach(event => {
356
- var _classPrivateFieldLoo20;
357
- (_classPrivateFieldLoo20 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo20 === void 0 ? void 0 : _classPrivateFieldLoo20.removeAllListeners(event);
373
+ var _classPrivateFieldLoo21;
374
+ (_classPrivateFieldLoo21 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo21 === void 0 ? void 0 : _classPrivateFieldLoo21.removeAllListeners(event);
358
375
  });
359
376
  }
360
377
  function _checkClient2() {
361
378
  if (!(0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) {
362
- throw new Error((0, _utils2.getInternalError)('NOT_INITIALIZED').message);
379
+ throw new Error((0, _utils3.getInternalError)('NOT_INITIALIZED').message);
363
380
  }
364
381
  }
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.3.52-0",
20
+ "version": "1.3.53-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -2838,7 +2838,7 @@
2838
2838
  "dependencies": {
2839
2839
  "@acala-network/api": "^5.0.2",
2840
2840
  "@apollo/client": "^3.7.14",
2841
- "@azns/resolver-core": "^1.4.0",
2841
+ "@azns/resolver-core": "2.1.0",
2842
2842
  "@emurgo/cardano-serialization-lib-nodejs": "^13.2.0",
2843
2843
  "@equilab/api": "~1.14.25",
2844
2844
  "@ethereumjs/common": "^4.1.0",
@@ -2851,41 +2851,40 @@
2851
2851
  "@metaverse-network-sdk/type-definitions": "^0.0.1-13",
2852
2852
  "@oak-foundation/types": "^0.0.23",
2853
2853
  "@polkadot-api/merkleize-metadata": "^1.1.0",
2854
- "@polkadot/api": "^15.7.2",
2855
- "@polkadot/api-base": "^15.7.2",
2856
- "@polkadot/api-contract": "^15.7.2",
2857
- "@polkadot/api-derive": "^15.7.2",
2858
- "@polkadot/apps-config": "^0.150.2",
2859
- "@polkadot/hw-ledger": "^13.4.3",
2860
- "@polkadot/networks": "^13.4.3",
2861
- "@polkadot/phishing": "^0.25.4",
2862
- "@polkadot/rpc-provider": "^15.7.2",
2863
- "@polkadot/types": "^15.7.2",
2864
- "@polkadot/types-augment": "^15.7.2",
2865
- "@polkadot/types-known": "^15.7.2",
2866
- "@polkadot/ui-settings": "^3.12.2",
2867
- "@polkadot/util": "^13.4.3",
2868
- "@polkadot/util-crypto": "^13.4.3",
2869
- "@polkadot/x-global": "^13.4.3",
2854
+ "@polkadot/api": "^16.4.2",
2855
+ "@polkadot/api-base": "^16.4.2",
2856
+ "@polkadot/api-contract": "^16.4.2",
2857
+ "@polkadot/api-derive": "^16.4.2",
2858
+ "@polkadot/apps-config": "^0.161.1",
2859
+ "@polkadot/hw-ledger": "^13.5.3",
2860
+ "@polkadot/networks": "^13.5.3",
2861
+ "@polkadot/phishing": "^0.25.15",
2862
+ "@polkadot/rpc-provider": "^16.4.2",
2863
+ "@polkadot/types": "^16.4.2",
2864
+ "@polkadot/types-augment": "^16.4.2",
2865
+ "@polkadot/types-known": "^16.4.2",
2866
+ "@polkadot/ui-settings": "^3.15.2",
2867
+ "@polkadot/util": "^13.5.3",
2868
+ "@polkadot/util-crypto": "^13.5.3",
2869
+ "@polkadot/x-global": "^13.5.3",
2870
2870
  "@reduxjs/toolkit": "^1.9.1",
2871
2871
  "@sora-substrate/type-definitions": "^1.17.7",
2872
2872
  "@substrate/connect": "^0.8.9",
2873
2873
  "@subwallet-monorepos/subwallet-services-sdk": "^0.1.8",
2874
2874
  "@subwallet/chain-list": "0.2.111",
2875
- "@subwallet/extension-base": "^1.3.52-0",
2876
- "@subwallet/extension-chains": "^1.3.52-0",
2877
- "@subwallet/extension-dapp": "^1.3.52-0",
2878
- "@subwallet/extension-inject": "^1.3.52-0",
2879
- "@subwallet/keyring": "^0.1.12",
2880
- "@subwallet/subwallet-api-sdk": "^1.3.51-0",
2881
- "@subwallet/ui-keyring": "^0.1.12",
2875
+ "@subwallet/extension-base": "^1.3.53-0",
2876
+ "@subwallet/extension-chains": "^1.3.53-0",
2877
+ "@subwallet/extension-dapp": "^1.3.53-0",
2878
+ "@subwallet/extension-inject": "^1.3.53-0",
2879
+ "@subwallet/keyring": "^0.1.13",
2880
+ "@subwallet/ui-keyring": "^0.1.13",
2882
2881
  "@ton/core": "^0.56.3",
2883
2882
  "@ton/crypto": "^3.2.0",
2884
2883
  "@ton/ton": "^15.0.0",
2885
2884
  "@walletconnect/keyvaluestorage": "^1.1.1",
2886
- "@walletconnect/sign-client": "^2.20.2",
2887
- "@walletconnect/types": "^2.20.2",
2888
- "@walletconnect/utils": "^2.20.2",
2885
+ "@walletconnect/sign-client": "2.21.5",
2886
+ "@walletconnect/types": "2.21.5",
2887
+ "@walletconnect/utils": "2.21.5",
2889
2888
  "avail-js-sdk": "^0.2.12",
2890
2889
  "axios": "^1.6.2",
2891
2890
  "bignumber.js": "^9.1.1",
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@subwallet/extension-base',
8
8
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
9
  type: 'esm',
10
- version: '1.3.52-0'
10
+ version: '1.3.53-0'
11
11
  };
@@ -154,7 +154,17 @@ export class AccountJsonHandler extends AccountBaseHandler {
154
154
  accountProxies,
155
155
  modifyPairs
156
156
  } = json;
157
- const pairs = jsons.map(pair => keyring.createFromJson(pair));
157
+ const pairs = jsons.reduce((rs, pair) => {
158
+ try {
159
+ rs.push(keyring.createFromJson(pair));
160
+ } catch (e) {
161
+ console.error(e);
162
+ }
163
+ return rs;
164
+ }, []);
165
+ if (!(pairs !== null && pairs !== void 0 && pairs.length)) {
166
+ throw new Error(t('No valid accounts found to import'));
167
+ }
158
168
  const accountProxyMap = combineAccountsWithKeyPair(pairs, modifyPairs, accountProxies);
159
169
  const result = Object.values(accountProxyMap).map(proxy => {
160
170
  const rs = {
@@ -196,9 +206,24 @@ export class AccountJsonHandler extends AccountBaseHandler {
196
206
  try {
197
207
  const {
198
208
  accountProxies,
199
- modifyPairs
209
+ modifyPairs: modifyPairsRestored
200
210
  } = file;
201
- const pairs = jsons.map(pair => keyring.createFromJson(pair));
211
+ const modifyPairs = {};
212
+ const pairs = jsons.reduce((rs, pairJson) => {
213
+ try {
214
+ const pair = keyring.createFromJson(pairJson);
215
+ if (modifyPairsRestored !== null && modifyPairsRestored !== void 0 && modifyPairsRestored[pair.address]) {
216
+ modifyPairs[pair.address] = modifyPairsRestored[pair.address];
217
+ }
218
+ rs.push(pair);
219
+ } catch (e) {
220
+ console.error(e);
221
+ }
222
+ return rs;
223
+ }, []);
224
+ if (!(pairs !== null && pairs !== void 0 && pairs.length)) {
225
+ throw new Error(t('No valid accounts found to import'));
226
+ }
202
227
  const accountProxyMap = combineAccountsWithKeyPair(pairs, modifyPairs, accountProxies);
203
228
  const rawProxyIds = _proxyIds && _proxyIds.length ? _proxyIds : Object.keys(accountProxyMap);
204
229
  let _exists;
@@ -3,6 +3,7 @@ import { SignClientTypes } from '@walletconnect/types';
3
3
  export declare const PROJECT_ID_EXTENSION = "6da34c0b48164d27681924dd9a46d6be";
4
4
  export declare const PROJECT_ID_MOBILE = "6da34c0b48164d27681924dd9a46d6be";
5
5
  export declare const RELAY_URL = "wss://relay.walletconnect.com";
6
+ export declare const RELAY_FALLBACK_URL = "wss://relay.walletconnect.org";
6
7
  export declare const DEFAULT_WALLET_CONNECT_OPTIONS: SignClientTypes.Options;
7
8
  export declare const ALL_WALLET_CONNECT_EVENT: SignClientTypes.Event[];
8
9
  export declare const WALLET_CONNECT_SUPPORTED_METHODS: WalletConnectSigningMethod[];
@@ -10,3 +11,4 @@ export declare const WALLET_CONNECT_REQUEST_KEY = "wallet-connect";
10
11
  export declare const WALLET_CONNECT_EIP155_NAMESPACE = "eip155";
11
12
  export declare const WALLET_CONNECT_POLKADOT_NAMESPACE = "polkadot";
12
13
  export declare const WALLET_CONNECT_SUPPORT_NAMESPACES: string[];
14
+ export declare const WALLET_CONNECT_SESSION_TIMEOUT = 20000;
@@ -6,6 +6,7 @@ import { targetIsMobile } from '@subwallet/extension-base/utils';
6
6
  export const PROJECT_ID_EXTENSION = '6da34c0b48164d27681924dd9a46d6be';
7
7
  export const PROJECT_ID_MOBILE = '6da34c0b48164d27681924dd9a46d6be';
8
8
  export const RELAY_URL = 'wss://relay.walletconnect.com';
9
+ export const RELAY_FALLBACK_URL = 'wss://relay.walletconnect.org';
9
10
  export const DEFAULT_WALLET_CONNECT_OPTIONS = {
10
11
  logger: 'error',
11
12
  projectId: targetIsMobile ? PROJECT_ID_MOBILE : PROJECT_ID_EXTENSION,
@@ -22,4 +23,5 @@ export const WALLET_CONNECT_SUPPORTED_METHODS = [POLKADOT_SIGNING_METHODS.POLKAD
22
23
  export const WALLET_CONNECT_REQUEST_KEY = 'wallet-connect';
23
24
  export const WALLET_CONNECT_EIP155_NAMESPACE = 'eip155';
24
25
  export const WALLET_CONNECT_POLKADOT_NAMESPACE = 'polkadot';
25
- export const WALLET_CONNECT_SUPPORT_NAMESPACES = [WALLET_CONNECT_EIP155_NAMESPACE, WALLET_CONNECT_POLKADOT_NAMESPACE];
26
+ export const WALLET_CONNECT_SUPPORT_NAMESPACES = [WALLET_CONNECT_EIP155_NAMESPACE, WALLET_CONNECT_POLKADOT_NAMESPACE];
27
+ export const WALLET_CONNECT_SESSION_TIMEOUT = 20000; // 20 seconds
@@ -6,11 +6,12 @@ import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateF
6
6
  import { formatJsonRpcError } from '@json-rpc-tools/utils';
7
7
  import Eip155RequestHandler from '@subwallet/extension-base/services/wallet-connect-service/handler/Eip155RequestHandler';
8
8
  import { SWStorage } from '@subwallet/extension-base/storage';
9
+ import { wait } from '@subwallet/extension-base/utils';
9
10
  import SignClient from '@walletconnect/sign-client';
10
11
  import { getInternalError, getSdkError } from '@walletconnect/utils';
11
12
  import { BehaviorSubject } from 'rxjs';
12
13
  import PolkadotRequestHandler from "./handler/PolkadotRequestHandler.js";
13
- import { ALL_WALLET_CONNECT_EVENT, DEFAULT_WALLET_CONNECT_OPTIONS, WALLET_CONNECT_EIP155_NAMESPACE, WALLET_CONNECT_SUPPORTED_METHODS } from "./constants.js";
14
+ import { ALL_WALLET_CONNECT_EVENT, DEFAULT_WALLET_CONNECT_OPTIONS, RELAY_FALLBACK_URL, RELAY_URL, WALLET_CONNECT_EIP155_NAMESPACE, WALLET_CONNECT_SESSION_TIMEOUT, WALLET_CONNECT_SUPPORTED_METHODS } from "./constants.js";
14
15
  import { convertConnectRequest, convertNotSupportRequest, isSupportWalletConnectChain } from "./helpers.js";
15
16
  import { EIP155_SIGNING_METHODS, POLKADOT_SIGNING_METHODS } from "./types.js";
16
17
  const storage = SWStorage.instance;
@@ -116,7 +117,19 @@ export default class WalletConnectService {
116
117
  async initClient(force) {
117
118
  _classPrivateFieldLooseBase(this, _removeListener)[_removeListener]();
118
119
  if (force || (await this.haveData())) {
119
- _classPrivateFieldLooseBase(this, _client)[_client] = await SignClient.init(_classPrivateFieldLooseBase(this, _option)[_option]);
120
+ try {
121
+ _classPrivateFieldLooseBase(this, _client)[_client] = await SignClient.init(_classPrivateFieldLooseBase(this, _option)[_option]);
122
+ } catch (e) {
123
+ if (_classPrivateFieldLooseBase(this, _option)[_option].relayUrl === RELAY_URL) {
124
+ _classPrivateFieldLooseBase(this, _option)[_option] = {
125
+ ..._classPrivateFieldLooseBase(this, _option)[_option],
126
+ relayUrl: RELAY_FALLBACK_URL
127
+ };
128
+ _classPrivateFieldLooseBase(this, _client)[_client] = await SignClient.init(_classPrivateFieldLooseBase(this, _option)[_option]);
129
+ } else {
130
+ throw e;
131
+ }
132
+ }
120
133
  }
121
134
  _classPrivateFieldLooseBase(this, _updateSessions)[_updateSessions]();
122
135
  _classPrivateFieldLooseBase(this, _createListener)[_createListener]();
@@ -139,17 +152,21 @@ export default class WalletConnectService {
139
152
  await this.initClient();
140
153
  }
141
154
  async connect(uri) {
142
- var _classPrivateFieldLoo3;
143
- if (!(await this.haveData())) {
155
+ var _classPrivateFieldLoo3, _classPrivateFieldLoo4;
156
+ if (!(await this.haveData()) || !((_classPrivateFieldLoo3 = _classPrivateFieldLooseBase(this, _client)[_client]) !== null && _classPrivateFieldLoo3 !== void 0 && _classPrivateFieldLoo3.core.relayer.connected)) {
144
157
  await this.initClient(true);
145
158
  }
146
159
  _classPrivateFieldLooseBase(this, _checkClient)[_checkClient]();
147
- await ((_classPrivateFieldLoo3 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo3 === void 0 ? void 0 : _classPrivateFieldLoo3.pair({
160
+
161
+ // The purpose of designing a timeout for pairing is to prevent the promise from not being resolved if there are issues during the pairing process.
162
+ await Promise.race([(_classPrivateFieldLoo4 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo4 === void 0 ? void 0 : _classPrivateFieldLoo4.pair({
148
163
  uri
149
- }));
164
+ }), wait(WALLET_CONNECT_SESSION_TIMEOUT).then(() => {
165
+ throw new Error(getInternalError('EXPIRED').message);
166
+ })]);
150
167
  }
151
168
  async approveSession(result) {
152
- var _classPrivateFieldLoo4;
169
+ var _classPrivateFieldLoo5;
153
170
  _classPrivateFieldLooseBase(this, _checkClient)[_checkClient]();
154
171
  Object.entries(result.namespaces).forEach(([namespace, {
155
172
  methods
@@ -157,32 +174,32 @@ export default class WalletConnectService {
157
174
  methods = [...methods, ...this.findMethodsMissing(WALLET_CONNECT_EIP155_NAMESPACE === namespace ? methodEVMRequire : methodDOTRequire, methods)];
158
175
  result.namespaces[namespace].methods = methods;
159
176
  });
160
- await ((_classPrivateFieldLoo4 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo4 === void 0 ? void 0 : _classPrivateFieldLoo4.approve(result));
177
+ await ((_classPrivateFieldLoo5 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo5 === void 0 ? void 0 : _classPrivateFieldLoo5.approve(result));
161
178
  _classPrivateFieldLooseBase(this, _updateSessions)[_updateSessions]();
162
179
  }
163
180
  async rejectSession(id) {
164
- var _classPrivateFieldLoo5;
181
+ var _classPrivateFieldLoo6;
165
182
  _classPrivateFieldLooseBase(this, _checkClient)[_checkClient]();
166
- await ((_classPrivateFieldLoo5 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo5 === void 0 ? void 0 : _classPrivateFieldLoo5.reject({
183
+ await ((_classPrivateFieldLoo6 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo6 === void 0 ? void 0 : _classPrivateFieldLoo6.reject({
167
184
  id: id,
168
185
  reason: getSdkError('USER_REJECTED')
169
186
  }));
170
187
  }
171
188
  async responseRequest(response) {
172
- var _classPrivateFieldLoo6;
189
+ var _classPrivateFieldLoo7;
173
190
  _classPrivateFieldLooseBase(this, _checkClient)[_checkClient]();
174
- await ((_classPrivateFieldLoo6 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo6 === void 0 ? void 0 : _classPrivateFieldLoo6.respond(response));
191
+ await ((_classPrivateFieldLoo7 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo7 === void 0 ? void 0 : _classPrivateFieldLoo7.respond(response));
175
192
  }
176
193
  async resetWallet(resetAll) {
177
- var _classPrivateFieldLoo7, _classPrivateFieldLoo9, _classPrivateFieldLoo11;
194
+ var _classPrivateFieldLoo8, _classPrivateFieldLoo10, _classPrivateFieldLoo12;
178
195
  _classPrivateFieldLooseBase(this, _removeListener)[_removeListener]();
179
196
 
180
197
  // Disconnect session
181
- const sessions = ((_classPrivateFieldLoo7 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo7 === void 0 ? void 0 : _classPrivateFieldLoo7.session.values) || [];
198
+ const sessions = ((_classPrivateFieldLoo8 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo8 === void 0 ? void 0 : _classPrivateFieldLoo8.session.values) || [];
182
199
  for (const session of sessions) {
183
200
  try {
184
- var _classPrivateFieldLoo8;
185
- await ((_classPrivateFieldLoo8 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo8 === void 0 ? void 0 : _classPrivateFieldLoo8.disconnect({
201
+ var _classPrivateFieldLoo9;
202
+ await ((_classPrivateFieldLoo9 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo9 === void 0 ? void 0 : _classPrivateFieldLoo9.disconnect({
186
203
  topic: session.topic,
187
204
  reason: getSdkError('USER_DISCONNECTED')
188
205
  }));
@@ -192,11 +209,11 @@ export default class WalletConnectService {
192
209
  }
193
210
 
194
211
  // Disconnect pair
195
- const pairs = ((_classPrivateFieldLoo9 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo9 === void 0 ? void 0 : _classPrivateFieldLoo9.pairing.values) || [];
212
+ const pairs = ((_classPrivateFieldLoo10 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo10 === void 0 ? void 0 : _classPrivateFieldLoo10.pairing.values) || [];
196
213
  for (const pair of pairs) {
197
214
  try {
198
- var _classPrivateFieldLoo10;
199
- await ((_classPrivateFieldLoo10 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo10 === void 0 ? void 0 : _classPrivateFieldLoo10.disconnect({
215
+ var _classPrivateFieldLoo11;
216
+ await ((_classPrivateFieldLoo11 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo11 === void 0 ? void 0 : _classPrivateFieldLoo11.disconnect({
200
217
  topic: pair.topic,
201
218
  reason: getSdkError('USER_DISCONNECTED')
202
219
  }));
@@ -204,12 +221,12 @@ export default class WalletConnectService {
204
221
  console.error(e);
205
222
  }
206
223
  }
207
- const keys = (await ((_classPrivateFieldLoo11 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo11 === void 0 ? void 0 : _classPrivateFieldLoo11.core.storage.getKeys())) || [];
224
+ const keys = (await ((_classPrivateFieldLoo12 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo12 === void 0 ? void 0 : _classPrivateFieldLoo12.core.storage.getKeys())) || [];
208
225
  const deleteKeys = resetAll ? keys : keys.filter(key => key.startsWith('wc@'));
209
226
  for (const key of deleteKeys) {
210
227
  try {
211
- var _classPrivateFieldLoo12;
212
- await ((_classPrivateFieldLoo12 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo12 === void 0 ? void 0 : _classPrivateFieldLoo12.core.storage.removeItem(key));
228
+ var _classPrivateFieldLoo13;
229
+ await ((_classPrivateFieldLoo13 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo13 === void 0 ? void 0 : _classPrivateFieldLoo13.core.storage.removeItem(key));
213
230
  } catch (e) {
214
231
  console.error(e);
215
232
  }
@@ -218,8 +235,8 @@ export default class WalletConnectService {
218
235
  _classPrivateFieldLooseBase(this, _updateSessions)[_updateSessions]();
219
236
  }
220
237
  async disconnect(topic) {
221
- var _classPrivateFieldLoo13;
222
- await ((_classPrivateFieldLoo13 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo13 === void 0 ? void 0 : _classPrivateFieldLoo13.disconnect({
238
+ var _classPrivateFieldLoo14;
239
+ await ((_classPrivateFieldLoo14 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo14 === void 0 ? void 0 : _classPrivateFieldLoo14.disconnect({
223
240
  topic: topic,
224
241
  reason: getSdkError('USER_DISCONNECTED')
225
242
  }));
@@ -326,18 +343,18 @@ async function _onPingReply2({
326
343
  }
327
344
  }
328
345
  function _createListener2() {
329
- var _classPrivateFieldLoo14, _classPrivateFieldLoo15, _classPrivateFieldLoo16, _classPrivateFieldLoo17, _classPrivateFieldLoo18, _classPrivateFieldLoo19;
330
- (_classPrivateFieldLoo14 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo14 === void 0 ? void 0 : _classPrivateFieldLoo14.on('session_proposal', _classPrivateFieldLooseBase(this, _onSessionProposal)[_onSessionProposal].bind(this));
331
- (_classPrivateFieldLoo15 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo15 === void 0 ? void 0 : _classPrivateFieldLoo15.on('session_request', _classPrivateFieldLooseBase(this, _onSessionRequest)[_onSessionRequest].bind(this));
332
- (_classPrivateFieldLoo16 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo16 === void 0 ? void 0 : _classPrivateFieldLoo16.on('session_ping', _classPrivateFieldLooseBase(this, _onPingReply)[_onPingReply].bind(this));
333
- (_classPrivateFieldLoo17 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo17 === void 0 ? void 0 : _classPrivateFieldLoo17.on('session_event', data => console.log('event', data));
334
- (_classPrivateFieldLoo18 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo18 === void 0 ? void 0 : _classPrivateFieldLoo18.on('session_update', data => console.log('update', data));
335
- (_classPrivateFieldLoo19 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo19 === void 0 ? void 0 : _classPrivateFieldLoo19.on('session_delete', _classPrivateFieldLooseBase(this, _updateSessions)[_updateSessions].bind(this));
346
+ var _classPrivateFieldLoo15, _classPrivateFieldLoo16, _classPrivateFieldLoo17, _classPrivateFieldLoo18, _classPrivateFieldLoo19, _classPrivateFieldLoo20;
347
+ (_classPrivateFieldLoo15 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo15 === void 0 ? void 0 : _classPrivateFieldLoo15.on('session_proposal', _classPrivateFieldLooseBase(this, _onSessionProposal)[_onSessionProposal].bind(this));
348
+ (_classPrivateFieldLoo16 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo16 === void 0 ? void 0 : _classPrivateFieldLoo16.on('session_request', _classPrivateFieldLooseBase(this, _onSessionRequest)[_onSessionRequest].bind(this));
349
+ (_classPrivateFieldLoo17 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo17 === void 0 ? void 0 : _classPrivateFieldLoo17.on('session_ping', _classPrivateFieldLooseBase(this, _onPingReply)[_onPingReply].bind(this));
350
+ (_classPrivateFieldLoo18 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo18 === void 0 ? void 0 : _classPrivateFieldLoo18.on('session_event', data => console.log('event', data));
351
+ (_classPrivateFieldLoo19 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo19 === void 0 ? void 0 : _classPrivateFieldLoo19.on('session_update', data => console.log('update', data));
352
+ (_classPrivateFieldLoo20 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo20 === void 0 ? void 0 : _classPrivateFieldLoo20.on('session_delete', _classPrivateFieldLooseBase(this, _updateSessions)[_updateSessions].bind(this));
336
353
  }
337
354
  function _removeListener2() {
338
355
  ALL_WALLET_CONNECT_EVENT.forEach(event => {
339
- var _classPrivateFieldLoo20;
340
- (_classPrivateFieldLoo20 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo20 === void 0 ? void 0 : _classPrivateFieldLoo20.removeAllListeners(event);
356
+ var _classPrivateFieldLoo21;
357
+ (_classPrivateFieldLoo21 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo21 === void 0 ? void 0 : _classPrivateFieldLoo21.removeAllListeners(event);
341
358
  });
342
359
  }
343
360
  function _checkClient2() {