@verified-network/verified-sdk 2.2.5 → 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 {
@@ -465,14 +465,74 @@ class VerifiedContract {
465
465
  }
466
466
  }
467
467
  catch (err) {
468
- console.error("MEE client transaction failed with error: ", (err === null || err === void 0 ? void 0 : err.message) || err);
469
- res.status = STATUS.ERROR;
470
- res.response = {
471
- hash: txHash,
472
- result: {},
473
- }; //TODO: update result on response
474
- res.message = "";
475
- 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
+ }
476
536
  }
477
537
  }
478
538
  async callContract(functionName, ...args) {
@@ -605,6 +665,7 @@ class VerifiedContract {
605
665
  instructions: [transactionInstruction],
606
666
  feeToken: { address: tkAddress, chainId },
607
667
  });
668
+ // console.log("cont quote: ", quote);
608
669
  return {
609
670
  tokenAddress: paymentTokenAddress,
610
671
  amount: quote === null || quote === void 0 ? void 0 : quote.paymentInfo.tokenAmount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verified-network/verified-sdk",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "description": "An SDK to develop applications on the Verified Network",
5
5
  "repository": {
6
6
  "type": "git",