@openocean.finance/wallet 1.10.10 → 1.10.11
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.
|
@@ -242,7 +242,7 @@ function linkAddOrSwitch(wallet, chain) {
|
|
|
242
242
|
_b.label = 1;
|
|
243
243
|
case 1:
|
|
244
244
|
_b.trys.push([1, 9, , 22]);
|
|
245
|
-
console.log('wallet_switchEthereumChain____start');
|
|
245
|
+
console.log('wallet_switchEthereumChain____start----');
|
|
246
246
|
return [4 /*yield*/, currentProvider.request({
|
|
247
247
|
method: 'wallet_switchEthereumChain',
|
|
248
248
|
params: [{ chainId: params.chainId }],
|
|
@@ -263,13 +263,18 @@ function linkAddOrSwitch(wallet, chain) {
|
|
|
263
263
|
address = (_b.sent())[0];
|
|
264
264
|
wallet.address = address;
|
|
265
265
|
_b.label = 7;
|
|
266
|
-
case 7:
|
|
266
|
+
case 7:
|
|
267
|
+
console.log('wallet_switchEthereumChain____end---');
|
|
268
|
+
return [2 /*return*/, wallet];
|
|
267
269
|
case 8: return [3 /*break*/, 22];
|
|
268
270
|
case 9:
|
|
269
271
|
switchError_1 = _b.sent();
|
|
270
272
|
console.log('wallet_switchEthereumChain errer');
|
|
271
|
-
console.log(
|
|
273
|
+
console.log(switchError_1);
|
|
272
274
|
console.log(params);
|
|
275
|
+
if (switchError_1.code === 5000 && switchError_1.message && switchError_1.message.indexOf('4902')) {
|
|
276
|
+
switchError_1.code = 4902;
|
|
277
|
+
}
|
|
273
278
|
if (!(switchError_1.code === 4902 || (switchError_1.data && switchError_1.data.originalError && switchError_1.data.originalError.code == 4902))) return [3 /*break*/, 20];
|
|
274
279
|
_b.label = 10;
|
|
275
280
|
case 10:
|
|
@@ -20,7 +20,7 @@ declare class WalletConnect extends BaseWallet {
|
|
|
20
20
|
* @param config
|
|
21
21
|
*/
|
|
22
22
|
requestConnect(chainId?: number, config?: any): Promise<any>;
|
|
23
|
-
switchNetwork(chainId: number): void
|
|
23
|
+
switchNetwork(chainId: number): Promise<void>;
|
|
24
24
|
disconnect(): Promise<void>;
|
|
25
25
|
}
|
|
26
26
|
export default WalletConnect;
|
|
@@ -191,11 +191,11 @@ var WalletConnect = /** @class */ (function (_super) {
|
|
|
191
191
|
*/
|
|
192
192
|
WalletConnect.prototype.requestConnect = function () {
|
|
193
193
|
return __awaiter(this, arguments, void 0, function (chainId, config) {
|
|
194
|
-
var provider1_1, providerType, isConnected, currentChainId_1, modalChainId, currentChainId_2, modalChainId_1, address_1, address1, provider1, currentChainId, address;
|
|
194
|
+
var provider1_1, providerType, isConnected, currentChainId_1, modalChainId, currentChainId_2, modalChainId_1, address_1, address1, _a, provider1, currentChainId, currentChainId_3, modalChainId, address, _b;
|
|
195
195
|
var _this = this;
|
|
196
196
|
if (chainId === void 0) { chainId = 1; }
|
|
197
|
-
return __generator(this, function (
|
|
198
|
-
switch (
|
|
197
|
+
return __generator(this, function (_c) {
|
|
198
|
+
switch (_c.label) {
|
|
199
199
|
case 0:
|
|
200
200
|
this.modalIsClose = false;
|
|
201
201
|
console.log('requestConnect1111-----------------');
|
|
@@ -203,10 +203,10 @@ var WalletConnect = /** @class */ (function (_super) {
|
|
|
203
203
|
this.init(chainId, config);
|
|
204
204
|
return [4 /*yield*/, (0, helper_2.sleep)(5000)];
|
|
205
205
|
case 1:
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
_c.sent();
|
|
207
|
+
_c.label = 2;
|
|
208
208
|
case 2:
|
|
209
|
-
if (!this.modal) return [3 /*break*/,
|
|
209
|
+
if (!this.modal) return [3 /*break*/, 10];
|
|
210
210
|
console.log('requestConnect222-----------------');
|
|
211
211
|
provider1_1 = this.modal.getWalletProvider();
|
|
212
212
|
console.log(provider1_1);
|
|
@@ -214,7 +214,7 @@ var WalletConnect = /** @class */ (function (_super) {
|
|
|
214
214
|
console.log('providerType', providerType);
|
|
215
215
|
isConnected = this.modal.getIsConnectedState();
|
|
216
216
|
console.log('requestConnect333-----------------');
|
|
217
|
-
if (!(provider1_1 && isConnected && !this.disconnected)) return [3 /*break*/,
|
|
217
|
+
if (!(provider1_1 && isConnected && !this.disconnected)) return [3 /*break*/, 10];
|
|
218
218
|
// let provider =await provider1.getProvider()
|
|
219
219
|
// console.log(provider)
|
|
220
220
|
console.log('requestConnect333322222-----------------');
|
|
@@ -222,43 +222,54 @@ var WalletConnect = /** @class */ (function (_super) {
|
|
|
222
222
|
this.sdk = new web3_1.default(provider1_1);
|
|
223
223
|
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
224
224
|
case 3:
|
|
225
|
-
currentChainId_1 =
|
|
225
|
+
currentChainId_1 = _c.sent();
|
|
226
226
|
modalChainId = this.modal.getChainId();
|
|
227
227
|
console.log('requestConnect444-------chainId----------');
|
|
228
228
|
console.log(modalChainId, currentChainId_1, chainId);
|
|
229
|
-
if (!(chainId && currentChainId_1 != chainId)) return [3 /*break*/,
|
|
230
|
-
console.log('
|
|
231
|
-
this.switchNetwork(+chainId);
|
|
232
|
-
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
229
|
+
if (!(chainId && currentChainId_1 != chainId)) return [3 /*break*/, 7];
|
|
230
|
+
console.log('requestConnect-----*********');
|
|
231
|
+
return [4 /*yield*/, this.switchNetwork(+chainId)];
|
|
233
232
|
case 4:
|
|
234
|
-
|
|
233
|
+
_c.sent();
|
|
234
|
+
return [4 /*yield*/, (0, helper_2.sleep)(1000)];
|
|
235
|
+
case 5:
|
|
236
|
+
_c.sent();
|
|
237
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
238
|
+
case 6:
|
|
239
|
+
currentChainId_2 = _c.sent();
|
|
235
240
|
modalChainId_1 = this.modal.getChainId();
|
|
236
241
|
console.log('requestConnect-------chainId----------');
|
|
237
242
|
console.log(modalChainId_1, currentChainId_2, chainId);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
243
|
+
if (currentChainId_2 != modalChainId_1 || currentChainId_2 != chainId) {
|
|
244
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
245
|
+
}
|
|
246
|
+
_c.label = 7;
|
|
247
|
+
case 7:
|
|
248
|
+
console.log('requestConnect--------666666666666');
|
|
241
249
|
return [4 /*yield*/, this.sdk.eth.getAccounts()];
|
|
242
|
-
case
|
|
243
|
-
address_1 = (
|
|
250
|
+
case 8:
|
|
251
|
+
address_1 = (_c.sent())[0];
|
|
244
252
|
address1 = this.modal.getAddress();
|
|
245
253
|
console.log(address_1, address1);
|
|
246
254
|
this.address = address_1 || address1;
|
|
247
|
-
|
|
255
|
+
_a = this;
|
|
256
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
257
|
+
case 9:
|
|
258
|
+
_a.chainId = _c.sent();
|
|
248
259
|
this.disconnected = false;
|
|
249
260
|
return [2 /*return*/, address_1];
|
|
250
|
-
case
|
|
261
|
+
case 10:
|
|
251
262
|
console.log('requestConnect777-----------------');
|
|
252
263
|
return [4 /*yield*/, this.modal.open({
|
|
253
264
|
view: 'Connect' //'Account' | 'Connect' | 'Networks' | 'ApproveTransaction' | 'OnRampProviders';
|
|
254
265
|
})];
|
|
255
|
-
case
|
|
256
|
-
|
|
266
|
+
case 11:
|
|
267
|
+
_c.sent();
|
|
257
268
|
return [4 /*yield*/, (0, helper_1.autoWalletCheck)(function () {
|
|
258
269
|
return _this.getModalClose();
|
|
259
270
|
}, 1000 * 60 * 6, 60 * 3)];
|
|
260
|
-
case
|
|
261
|
-
|
|
271
|
+
case 12:
|
|
272
|
+
_c.sent();
|
|
262
273
|
console.log('autoWalletCheck-----------------');
|
|
263
274
|
provider1 = this.modal.getWalletProvider();
|
|
264
275
|
console.log(provider1);
|
|
@@ -271,20 +282,37 @@ var WalletConnect = /** @class */ (function (_super) {
|
|
|
271
282
|
// console.log(provider)
|
|
272
283
|
this.sdk = new web3_1.default(provider1);
|
|
273
284
|
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
274
|
-
case
|
|
275
|
-
currentChainId =
|
|
285
|
+
case 13:
|
|
286
|
+
currentChainId = _c.sent();
|
|
276
287
|
console.log('autoWalletCheck333-----------------');
|
|
277
288
|
this.disconnected = false;
|
|
278
|
-
if (chainId && currentChainId != chainId)
|
|
279
|
-
|
|
280
|
-
|
|
289
|
+
if (!(chainId && currentChainId != chainId)) return [3 /*break*/, 17];
|
|
290
|
+
return [4 /*yield*/, this.switchNetwork(chainId)];
|
|
291
|
+
case 14:
|
|
292
|
+
_c.sent();
|
|
293
|
+
return [4 /*yield*/, (0, helper_2.sleep)(1000)];
|
|
294
|
+
case 15:
|
|
295
|
+
_c.sent();
|
|
296
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
297
|
+
case 16:
|
|
298
|
+
currentChainId_3 = _c.sent();
|
|
299
|
+
modalChainId = this.modal.getChainId();
|
|
300
|
+
console.log('requestConnect999999-------chainId----------');
|
|
301
|
+
console.log(modalChainId, currentChainId_3, chainId);
|
|
302
|
+
if (currentChainId_3 != modalChainId || currentChainId_3 != chainId) {
|
|
303
|
+
throw new Error(types_1.EnumErrors.ChainIdNotMath);
|
|
281
304
|
}
|
|
282
|
-
|
|
305
|
+
_c.label = 17;
|
|
306
|
+
case 17:
|
|
307
|
+
console.log('autoWalletCheck------------666666666666');
|
|
283
308
|
return [4 /*yield*/, this.sdk.eth.getAccounts()];
|
|
284
|
-
case
|
|
285
|
-
address = (
|
|
309
|
+
case 18:
|
|
310
|
+
address = (_c.sent())[0];
|
|
286
311
|
this.address = address;
|
|
287
|
-
|
|
312
|
+
_b = this;
|
|
313
|
+
return [4 /*yield*/, this.sdk.eth.getChainId()];
|
|
314
|
+
case 19:
|
|
315
|
+
_b.chainId = _c.sent();
|
|
288
316
|
console.log('address,currentChainId-----------------');
|
|
289
317
|
console.log(address, currentChainId);
|
|
290
318
|
return [2 /*return*/, address];
|
|
@@ -293,10 +321,21 @@ var WalletConnect = /** @class */ (function (_super) {
|
|
|
293
321
|
});
|
|
294
322
|
};
|
|
295
323
|
WalletConnect.prototype.switchNetwork = function (chainId) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
this
|
|
299
|
-
|
|
324
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
325
|
+
var chain;
|
|
326
|
+
return __generator(this, function (_a) {
|
|
327
|
+
switch (_a.label) {
|
|
328
|
+
case 0:
|
|
329
|
+
chain = this.networks.find(function (item) { return item.id == chainId; });
|
|
330
|
+
if (!chain) return [3 /*break*/, 2];
|
|
331
|
+
return [4 /*yield*/, this.modal.switchNetwork(chain)];
|
|
332
|
+
case 1:
|
|
333
|
+
_a.sent();
|
|
334
|
+
_a.label = 2;
|
|
335
|
+
case 2: return [2 /*return*/];
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
});
|
|
300
339
|
};
|
|
301
340
|
WalletConnect.prototype.disconnect = function () {
|
|
302
341
|
return __awaiter(this, void 0, void 0, function () {
|