@openocean.finance/wallet 1.10.1 → 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
@@ -69,10 +69,11 @@ var appkit_1 = require("@reown/appkit");
69
69
  var appkit_adapter_wagmi_1 = require("@reown/appkit-adapter-wagmi");
70
70
  var helper_1 = require("../helper");
71
71
  var chains_1 = require("viem/chains");
72
+ var helper_2 = require("../helper");
72
73
  var WalletConnect = /** @class */ (function (_super) {
73
74
  __extends(WalletConnect, _super);
74
75
  function WalletConnect() {
75
- var _this = _super.call(this) || this;
76
+ var _this = _super !== null && _super.apply(this, arguments) || this;
76
77
  _this.name = types_1.EnumWalletName.WalletConnect;
77
78
  _this.icon = walletconnect_svg_1.default;
78
79
  _this.supportChains = [
@@ -120,6 +121,7 @@ var WalletConnect = /** @class */ (function (_super) {
120
121
  return _this;
121
122
  }
122
123
  WalletConnect.prototype.init = function (chainId, config) {
124
+ var _this = this;
123
125
  if (chainId === void 0) { chainId = 1; }
124
126
  var projectId = config && config.projectId ? config.projectId : 'c1ca7adc83e89c7e7848440702f28f38'; // '90304d7fbed3543fd7cac4b24f800264'
125
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];
@@ -135,6 +137,7 @@ var WalletConnect = /** @class */ (function (_super) {
135
137
  };
136
138
  var defaultNetwork = networks.find(function (item) { return item.id == chainId; });
137
139
  this.modal = (0, appkit_1.createAppKit)({
140
+ showWallets: true,
138
141
  adapters: [wagmiAdapter],
139
142
  defaultNetwork: defaultNetwork,
140
143
  networks: networks,
@@ -142,7 +145,8 @@ var WalletConnect = /** @class */ (function (_super) {
142
145
  projectId: projectId,
143
146
  features: {
144
147
  swaps: false,
145
- analytics: true // Optional - defaults to your Cloud configuration
148
+ socials: false,
149
+ email: false,
146
150
  },
147
151
  enableWalletConnect: true,
148
152
  debug: false,
@@ -151,16 +155,35 @@ var WalletConnect = /** @class */ (function (_super) {
151
155
  },
152
156
  excludeWalletIds: [
153
157
  'a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393'
154
- ]
155
- // allWallets: 'SHOW',
158
+ ],
159
+ allWallets: 'HIDE',
156
160
  });
157
161
  this.modal.subscribeEvents(function (event) {
162
+ console.log('_____________________event_________________');
158
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
+ }
159
177
  });
160
178
  this.modal.subscribeWalletInfo(function (data) {
161
- var sdf = data;
179
+ console.log('_____________________subscribeWalletInfo_________________');
180
+ console.log(data);
162
181
  });
163
182
  };
183
+ WalletConnect.prototype.getModalClose = function () {
184
+ var open = this.modal.getState().open;
185
+ return this.modalIsClose || !open;
186
+ };
164
187
  /**
165
188
  * connect metamask and get wallet address
166
189
  * @param chainId specific chainId,throw error when not match
@@ -174,54 +197,73 @@ var WalletConnect = /** @class */ (function (_super) {
174
197
  return __generator(this, function (_a) {
175
198
  switch (_a.label) {
176
199
  case 0:
177
- if (!this.modal) {
178
- this.init(chainId, config);
179
- }
180
- if (!this.modal) return [3 /*break*/, 4];
200
+ this.modalIsClose = false;
201
+ console.log('requestConnect1111-----------------');
202
+ if (!!this.modal) return [3 /*break*/, 2];
203
+ this.init(chainId, config);
204
+ return [4 /*yield*/, (0, helper_2.sleep)(5000)];
205
+ case 1:
206
+ _a.sent();
207
+ _a.label = 2;
208
+ case 2:
209
+ if (!this.modal) return [3 /*break*/, 6];
210
+ console.log('requestConnect222-----------------');
181
211
  provider_1 = this.modal.getWalletProvider();
182
212
  isConnected = this.modal.getIsConnectedState();
183
- if (!(provider_1 && isConnected)) return [3 /*break*/, 4];
213
+ console.log('requestConnect333-----------------');
214
+ if (!(provider_1 && isConnected)) return [3 /*break*/, 6];
215
+ console.log('requestConnect333322222-----------------');
184
216
  this.sdk = new web3_1.default(provider_1);
185
217
  return [4 /*yield*/, this.sdk.eth.getChainId()];
186
- case 1:
218
+ case 3:
187
219
  currentChainId_1 = _a.sent();
188
- if (!(chainId && currentChainId_1 != chainId)) return [3 /*break*/, 2];
220
+ console.log('requestConnect444-----------------');
221
+ if (!(chainId && currentChainId_1 != chainId)) return [3 /*break*/, 4];
222
+ console.log('requestConnect555-----------------');
189
223
  throw new Error(types_1.EnumErrors.ChainIdNotMath);
190
- case 2: return [4 /*yield*/, this.sdk.eth.getAccounts()];
191
- case 3:
224
+ case 4:
225
+ console.log('requestConnect666-----------------');
226
+ return [4 /*yield*/, this.sdk.eth.getAccounts()];
227
+ case 5:
192
228
  address_1 = (_a.sent())[0];
193
229
  this.address = address_1;
194
230
  this.chainId = currentChainId_1;
195
231
  return [2 /*return*/, address_1];
196
- case 4: return [4 /*yield*/, this.modal.open({
197
- view: 'Connect' //'Account' | 'Connect' | 'Networks' | 'ApproveTransaction' | 'OnRampProviders';
198
- })];
199
- case 5:
232
+ case 6:
233
+ console.log('requestConnect777-----------------');
234
+ return [4 /*yield*/, this.modal.open({
235
+ view: 'Connect' //'Account' | 'Connect' | 'Networks' | 'ApproveTransaction' | 'OnRampProviders';
236
+ })];
237
+ case 7:
200
238
  _a.sent();
201
239
  return [4 /*yield*/, (0, helper_1.autoWalletCheck)(function () {
202
- // const { name, icon } = this.modal.getWalletInfo()
203
- var _a = _this.modal.getState(), open = _a.open, selectedNetworkId = _a.selectedNetworkId;
204
- return !open;
240
+ return _this.getModalClose();
205
241
  }, 1000 * 60 * 6, 60 * 3)];
206
- case 6:
242
+ case 8:
207
243
  _a.sent();
244
+ console.log('autoWalletCheck-----------------');
208
245
  provider = this.modal.getWalletProvider();
209
246
  if (!provider) {
210
247
  this.modal.close();
211
- throw new Error('Cancel connect');
248
+ throw new Error('User rejected the request.');
212
249
  }
250
+ console.log('autoWalletCheck22-----------------');
213
251
  this.sdk = new web3_1.default(provider);
214
252
  return [4 /*yield*/, this.sdk.eth.getChainId()];
215
- case 7:
253
+ case 9:
216
254
  currentChainId = _a.sent();
255
+ console.log('autoWalletCheck333-----------------');
217
256
  if (chainId && currentChainId != chainId) {
218
257
  throw new Error(types_1.EnumErrors.ChainIdNotMath);
219
258
  }
259
+ console.log('autoWalletCheck4444-----------------');
220
260
  return [4 /*yield*/, this.sdk.eth.getAccounts()];
221
- case 8:
261
+ case 10:
222
262
  address = (_a.sent())[0];
223
263
  this.address = address;
224
264
  this.chainId = currentChainId;
265
+ console.log('address,currentChainId-----------------');
266
+ console.log(address, currentChainId);
225
267
  return [2 /*return*/, address];
226
268
  }
227
269
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "1.10.1",
3
+ "version": "1.10.3",
4
4
  "description": "A multi-chain wallets manager",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -60,7 +60,7 @@
60
60
  "@reown/appkit-adapter-wagmi": "^1.3.0",
61
61
  "@siddomains/sidjs": "^0.1.22",
62
62
  "@solana/web3.js": "^1.91.0",
63
- "@terra-money/terra.js": "3.0.8",
63
+ "@terra-money/terra.js": "3.1.10",
64
64
  "@uauth/js": "^2.4.0",
65
65
  "@walletconnect/ethereum-provider": "^2.17.1",
66
66
  "@walletconnect/modal": "^2.6.2",