@verified-network/verified-sdk 2.2.6 → 2.2.7

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.
@@ -405,7 +405,7 @@ class VerifiedContract {
405
405
  }
406
406
  /** Constructs and call function using MEE client that allows gas payment in ERC20 tokens */
407
407
  async callFunctionWithMEEClient(nexusAccount, chainId, tx, paymentToken, _apiKey) {
408
- var _a, _b, _c;
408
+ var _a, _b, _c, _d, _e, _f, _g, _h;
409
409
  let res = {};
410
410
  let txHash = "";
411
411
  try {
@@ -427,7 +427,6 @@ class VerifiedContract {
427
427
  address: paymentToken,
428
428
  },
429
429
  instructions: [transactionInstruction],
430
- upperBoundTimestamp: Date.now() + 3600, //1hour ???
431
430
  });
432
431
  txHash = hash;
433
432
  console.log(`MEE transaction hash: ${hash}`);
@@ -466,14 +465,74 @@ class VerifiedContract {
466
465
  }
467
466
  }
468
467
  catch (err) {
469
- console.error("MEE client transaction failed with error: ", (err === null || err === void 0 ? void 0 : err.message) || err);
470
- res.status = STATUS.ERROR;
471
- res.response = {
472
- hash: txHash,
473
- result: {},
474
- }; //TODO: update result on response
475
- res.message = "";
476
- return res;
468
+ if ((txHash === null || txHash === void 0 ? void 0 : txHash.length) > 0 &&
469
+ ((_d = err === null || err === void 0 ? void 0 : err.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes("execution deadline limit exceeded"))) {
470
+ console.warn("MEE client transaction deadline exceeded, will fetch receipt manually...");
471
+ const meeClient = await (0, abstractjs_1.createMeeClient)({
472
+ account: nexusAccount,
473
+ apiKey: _apiKey || constants_1.PaymasterConstants.MEE_API_KEY,
474
+ });
475
+ for (let i = 0; i < Number(constants_1.PaymasterConstants.MAX_WAITING_ROUND); i++) {
476
+ try {
477
+ await new Promise((resolve) => setTimeout(resolve, 6000)); // 6 second delay
478
+ console.log("MEE deadline exceeded, fetching receipt for round:", i + 1, "out of", Number(constants_1.PaymasterConstants.MAX_WAITING_ROUND));
479
+ const receipt = await meeClient.waitForSupertransactionReceipt({
480
+ hash: txHash,
481
+ });
482
+ if (((_e = receipt === null || receipt === void 0 ? void 0 : receipt.receipts) === null || _e === void 0 ? void 0 : _e.length) > 1) {
483
+ //at least 2 receipts
484
+ const txReceipt = receipt === null || receipt === void 0 ? void 0 : receipt.receipts[((_f = receipt === null || receipt === void 0 ? void 0 : receipt.receipts) === null || _f === void 0 ? void 0 : _f.length) - 1];
485
+ if ((txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.status) === "success") {
486
+ res.status = STATUS.SUCCESS;
487
+ res.response = {
488
+ hash: txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.transactionHash,
489
+ result: txReceipt,
490
+ }; //TODO: update result on response
491
+ res.message = "";
492
+ break; // Exit the loop
493
+ }
494
+ else {
495
+ res.status = STATUS.ERROR;
496
+ res.response = {
497
+ hash: txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.transactionHash,
498
+ result: txReceipt,
499
+ }; //TODO: update result on response
500
+ res.message = "";
501
+ break; // Exit the loop
502
+ }
503
+ }
504
+ else {
505
+ console.error("MEE client transaction failed with error: ", "Receipts lesser than one.");
506
+ res.status = STATUS.ERROR;
507
+ res.response = {
508
+ hash: (_g = receipt === null || receipt === void 0 ? void 0 : receipt.receipts[0]) === null || _g === void 0 ? void 0 : _g.transactionHash,
509
+ result: receipt === null || receipt === void 0 ? void 0 : receipt.receipts[0],
510
+ }; //TODO: update result on response
511
+ res.message = "";
512
+ return res;
513
+ }
514
+ }
515
+ catch (_err) {
516
+ if ((_h = _err === null || _err === void 0 ? void 0 : _err.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes("execution deadline limit exceeded")) {
517
+ continue;
518
+ }
519
+ else {
520
+ break;
521
+ }
522
+ }
523
+ }
524
+ return res;
525
+ }
526
+ else {
527
+ console.error("MEE client transaction failed with error: ", err);
528
+ res.status = STATUS.ERROR;
529
+ res.response = {
530
+ hash: txHash,
531
+ result: {},
532
+ }; //TODO: update result on response
533
+ res.message = "";
534
+ return res;
535
+ }
477
536
  }
478
537
  }
479
538
  async callContract(functionName, ...args) {
@@ -560,7 +619,6 @@ class VerifiedContract {
560
619
  }
561
620
  async getQuote(paymentTokenAddress, functionName, args, rpc, _apiKey) {
562
621
  var _a, _b, _c, _d;
563
- console.log(paymentTokenAddress, functionName, args, rpc, _apiKey);
564
622
  const chainId = await this.signer.getChainId();
565
623
  if (this.supportsGasless(chainId)) {
566
624
  const _signer = this.signer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verified-network/verified-sdk",
3
- "version": "2.2.6",
3
+ "version": "2.2.7",
4
4
  "description": "An SDK to develop applications on the Verified Network",
5
5
  "repository": {
6
6
  "type": "git",