@openocean.finance/wallet 1.10.2 → 1.10.3

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.
@@ -9,8 +9,9 @@ declare class WalletConnect extends BaseWallet {
9
9
  sdk: any;
10
10
  infuraId?: string;
11
11
  modal: AppKit;
12
- constructor();
12
+ modalIsClose: Boolean;
13
13
  init(chainId?: number, config?: any): void;
14
+ getModalClose(): Boolean;
14
15
  /**
15
16
  * connect metamask and get wallet address
16
17
  * @param chainId specific chainId,throw error when not match
@@ -73,7 +73,7 @@ var helper_2 = require("../helper");
73
73
  var WalletConnect = /** @class */ (function (_super) {
74
74
  __extends(WalletConnect, _super);
75
75
  function WalletConnect() {
76
- var _this = _super.call(this) || this;
76
+ var _this = _super !== null && _super.apply(this, arguments) || this;
77
77
  _this.name = types_1.EnumWalletName.WalletConnect;
78
78
  _this.icon = walletconnect_svg_1.default;
79
79
  _this.supportChains = [
@@ -121,6 +121,7 @@ var WalletConnect = /** @class */ (function (_super) {
121
121
  return _this;
122
122
  }
123
123
  WalletConnect.prototype.init = function (chainId, config) {
124
+ var _this = this;
124
125
  if (chainId === void 0) { chainId = 1; }
125
126
  var projectId = config && config.projectId ? config.projectId : 'c1ca7adc83e89c7e7848440702f28f38'; // '90304d7fbed3543fd7cac4b24f800264'
126
127
  var networks = [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, 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, 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];
@@ -158,12 +159,31 @@ var WalletConnect = /** @class */ (function (_super) {
158
159
  allWallets: 'HIDE',
159
160
  });
160
161
  this.modal.subscribeEvents(function (event) {
162
+ console.log('_____________________event_________________');
161
163
  console.log(event.data);
164
+ console.log(event.data.event);
165
+ if (event.data.event == 'MODAL_OPEN') {
166
+ _this.modalIsClose = false;
167
+ }
168
+ if (event.data.event == "MODAL_CLOSE") {
169
+ _this.modalIsClose = true;
170
+ }
171
+ if (event.data.event == "CONNECT_ERROR") {
172
+ if (event.data.properties.message.indexOf('User rejected the request') != -1) {
173
+ _this.modal.close();
174
+ // this.modalIsClose = true
175
+ }
176
+ }
162
177
  });
163
178
  this.modal.subscribeWalletInfo(function (data) {
164
- var sdf = data;
179
+ console.log('_____________________subscribeWalletInfo_________________');
180
+ console.log(data);
165
181
  });
166
182
  };
183
+ WalletConnect.prototype.getModalClose = function () {
184
+ var open = this.modal.getState().open;
185
+ return this.modalIsClose || !open;
186
+ };
167
187
  /**
168
188
  * connect metamask and get wallet address
169
189
  * @param chainId specific chainId,throw error when not match
@@ -177,6 +197,8 @@ var WalletConnect = /** @class */ (function (_super) {
177
197
  return __generator(this, function (_a) {
178
198
  switch (_a.label) {
179
199
  case 0:
200
+ this.modalIsClose = false;
201
+ console.log('requestConnect1111-----------------');
180
202
  if (!!this.modal) return [3 /*break*/, 2];
181
203
  this.init(chainId, config);
182
204
  return [4 /*yield*/, (0, helper_2.sleep)(5000)];
@@ -185,54 +207,62 @@ var WalletConnect = /** @class */ (function (_super) {
185
207
  _a.label = 2;
186
208
  case 2:
187
209
  if (!this.modal) return [3 /*break*/, 6];
210
+ console.log('requestConnect222-----------------');
188
211
  provider_1 = this.modal.getWalletProvider();
189
212
  isConnected = this.modal.getIsConnectedState();
213
+ console.log('requestConnect333-----------------');
190
214
  if (!(provider_1 && isConnected)) return [3 /*break*/, 6];
215
+ console.log('requestConnect333322222-----------------');
191
216
  this.sdk = new web3_1.default(provider_1);
192
217
  return [4 /*yield*/, this.sdk.eth.getChainId()];
193
218
  case 3:
194
219
  currentChainId_1 = _a.sent();
220
+ console.log('requestConnect444-----------------');
195
221
  if (!(chainId && currentChainId_1 != chainId)) return [3 /*break*/, 4];
222
+ console.log('requestConnect555-----------------');
196
223
  throw new Error(types_1.EnumErrors.ChainIdNotMath);
197
- case 4: return [4 /*yield*/, this.sdk.eth.getAccounts()];
224
+ case 4:
225
+ console.log('requestConnect666-----------------');
226
+ return [4 /*yield*/, this.sdk.eth.getAccounts()];
198
227
  case 5:
199
228
  address_1 = (_a.sent())[0];
200
229
  this.address = address_1;
201
230
  this.chainId = currentChainId_1;
202
231
  return [2 /*return*/, address_1];
203
- case 6: return [4 /*yield*/, this.modal.open({
204
- view: 'Connect' //'Account' | 'Connect' | 'Networks' | 'ApproveTransaction' | 'OnRampProviders';
205
- })];
232
+ case 6:
233
+ console.log('requestConnect777-----------------');
234
+ return [4 /*yield*/, this.modal.open({
235
+ view: 'Connect' //'Account' | 'Connect' | 'Networks' | 'ApproveTransaction' | 'OnRampProviders';
236
+ })];
206
237
  case 7:
207
238
  _a.sent();
208
239
  return [4 /*yield*/, (0, helper_1.autoWalletCheck)(function () {
209
- // const { name, icon } = this.modal.getWalletInfo()
210
- var _a = _this.modal.getState(), open = _a.open, selectedNetworkId = _a.selectedNetworkId;
211
- return !open;
240
+ return _this.getModalClose();
212
241
  }, 1000 * 60 * 6, 60 * 3)];
213
242
  case 8:
214
243
  _a.sent();
244
+ console.log('autoWalletCheck-----------------');
215
245
  provider = this.modal.getWalletProvider();
216
246
  if (!provider) {
217
247
  this.modal.close();
218
- throw new Error('Cancel connect');
248
+ throw new Error('User rejected the request.');
219
249
  }
220
- console.log('fk01');
250
+ console.log('autoWalletCheck22-----------------');
221
251
  this.sdk = new web3_1.default(provider);
222
252
  return [4 /*yield*/, this.sdk.eth.getChainId()];
223
253
  case 9:
224
254
  currentChainId = _a.sent();
225
- console.log('fk02');
255
+ console.log('autoWalletCheck333-----------------');
226
256
  if (chainId && currentChainId != chainId) {
227
257
  throw new Error(types_1.EnumErrors.ChainIdNotMath);
228
258
  }
229
- console.log('fk03');
259
+ console.log('autoWalletCheck4444-----------------');
230
260
  return [4 /*yield*/, this.sdk.eth.getAccounts()];
231
261
  case 10:
232
262
  address = (_a.sent())[0];
233
263
  this.address = address;
234
264
  this.chainId = currentChainId;
235
- console.log('fk04');
265
+ console.log('address,currentChainId-----------------');
236
266
  console.log(address, currentChainId);
237
267
  return [2 /*return*/, address];
238
268
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {