@glowlabs-org/utils 0.2.172 → 0.2.174

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var calculateFarmEfficiency = require('./calculate-farm-efficiency-CIHgzMwj.js');
3
+ var calculateFarmEfficiency = require('./calculate-farm-efficiency-CBI3L6Cz.js');
4
4
  require('decimal.js');
5
5
  var viem = require('viem');
6
6
  require('ethers');
@@ -443,12 +443,20 @@ async function waitForEthersTransactionWithRetry(signer, txHash, options = {}) {
443
443
  }
444
444
  catch (error) {
445
445
  const errorMessage = parseEthersError(error);
446
- consecutiveErrors++;
447
- if (consecutiveErrors >= maxRetries) {
448
- throw new Error(`Transaction failed after ${consecutiveErrors} attempts: ${errorMessage}`);
449
- }
450
- if (enableLogging) {
451
- console.warn(`Error fetching receipt (attempt ${consecutiveErrors}/${maxRetries}), retrying in ${pollIntervalMs}ms...`);
446
+ // Treat not found/receipt missing as retryable without counting towards errors
447
+ const isNotFound = errorMessage.toLowerCase().includes("not found") ||
448
+ errorMessage.toLowerCase().includes("could not be found") ||
449
+ errorMessage.toLowerCase().includes("receipt") ||
450
+ errorMessage.toLowerCase().includes("not confirmed") ||
451
+ errorMessage.toLowerCase().includes("transactionreceiptnotfound");
452
+ if (!isNotFound) {
453
+ consecutiveErrors++;
454
+ if (consecutiveErrors >= maxRetries) {
455
+ throw new Error(`Transaction failed after ${consecutiveErrors} attempts: ${errorMessage}`);
456
+ }
457
+ if (enableLogging) {
458
+ console.warn(`Error fetching receipt (attempt ${consecutiveErrors}/${maxRetries}), retrying in ${pollIntervalMs}ms...`);
459
+ }
452
460
  }
453
461
  }
454
462
  await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
@@ -534,7 +542,7 @@ function assertSigner(maybeSigner) {
534
542
  throw new Error(exports.ForwarderError.SIGNER_NOT_AVAILABLE);
535
543
  }
536
544
  }
537
- function useForwarder(signer, CHAIN_ID) {
545
+ function useForwarder(signer, CHAIN_ID, publicClient) {
538
546
  // Use dynamic addresses based on chain configuration
539
547
  const ADDRESSES = getAddresses(CHAIN_ID);
540
548
  // Framework-agnostic processing flag
@@ -673,10 +681,18 @@ function useForwarder(signer, CHAIN_ID) {
673
681
  setIsProcessing(true);
674
682
  // Approve only the specific amount needed
675
683
  const approveTx = await tokenContract.approve(ADDRESSES.FORWARDER, amount);
676
- await waitForEthersTransactionWithRetry(signer, approveTx.hash, {
677
- timeoutMs: 30000,
678
- pollIntervalMs: 2000,
679
- });
684
+ if (publicClient) {
685
+ await waitForViemTransactionWithRetry(publicClient, approveTx.hash, {
686
+ timeoutMs: 60000,
687
+ pollIntervalMs: 2000,
688
+ });
689
+ }
690
+ else {
691
+ await waitForEthersTransactionWithRetry(signer, approveTx.hash, {
692
+ timeoutMs: 60000,
693
+ pollIntervalMs: 2000,
694
+ });
695
+ }
680
696
  return true;
681
697
  }
682
698
  catch (error) {
@@ -736,10 +752,18 @@ function useForwarder(signer, CHAIN_ID) {
736
752
  if (allowance < amount) {
737
753
  try {
738
754
  const approveTx = await tokenContract.approve(ADDRESSES.FORWARDER, ethers.MaxUint256);
739
- await waitForEthersTransactionWithRetry(signer, approveTx.hash, {
740
- timeoutMs: 30000,
741
- pollIntervalMs: 2000,
742
- });
755
+ if (publicClient) {
756
+ await waitForViemTransactionWithRetry(publicClient, approveTx.hash, {
757
+ timeoutMs: 60000,
758
+ pollIntervalMs: 2000,
759
+ });
760
+ }
761
+ else {
762
+ await waitForEthersTransactionWithRetry(signer, approveTx.hash, {
763
+ timeoutMs: 60000,
764
+ pollIntervalMs: 2000,
765
+ });
766
+ }
743
767
  }
744
768
  catch (approveError) {
745
769
  sentryCaptureException(approveError, {
@@ -810,10 +834,18 @@ function useForwarder(signer, CHAIN_ID) {
810
834
  ? ADDRESSES.AUDIT_FEE_WALLET
811
835
  : ADDRESSES.FOUNDATION_WALLET, amount, sendToCounterfactualWallet, message);
812
836
  }
813
- await waitForEthersTransactionWithRetry(signer, tx.hash, {
814
- timeoutMs: 30000,
815
- pollIntervalMs: 2000,
816
- });
837
+ if (publicClient) {
838
+ await waitForViemTransactionWithRetry(publicClient, tx.hash, {
839
+ timeoutMs: 60000,
840
+ pollIntervalMs: 2000,
841
+ });
842
+ }
843
+ else {
844
+ await waitForEthersTransactionWithRetry(signer, tx.hash, {
845
+ timeoutMs: 60000,
846
+ pollIntervalMs: 2000,
847
+ });
848
+ }
817
849
  return tx.hash;
818
850
  }
819
851
  catch (txError) {
@@ -1048,10 +1080,18 @@ function useForwarder(signer, CHAIN_ID) {
1048
1080
  setIsProcessing(true);
1049
1081
  // Try to call mint function (common for test tokens)
1050
1082
  const tx = await usdcContract.mint(recipient, amount);
1051
- await waitForEthersTransactionWithRetry(signer, tx.hash, {
1052
- timeoutMs: 30000,
1053
- pollIntervalMs: 2000,
1054
- });
1083
+ if (publicClient) {
1084
+ await waitForViemTransactionWithRetry(publicClient, tx.hash, {
1085
+ timeoutMs: 60000,
1086
+ pollIntervalMs: 2000,
1087
+ });
1088
+ }
1089
+ else {
1090
+ await waitForEthersTransactionWithRetry(signer, tx.hash, {
1091
+ timeoutMs: 60000,
1092
+ pollIntervalMs: 2000,
1093
+ });
1094
+ }
1055
1095
  return tx.hash;
1056
1096
  }
1057
1097
  catch (error) {
@@ -5331,4 +5371,4 @@ exports.useOffchainFractions = useOffchainFractions;
5331
5371
  exports.useRewardsKernel = useRewardsKernel;
5332
5372
  exports.waitForEthersTransactionWithRetry = waitForEthersTransactionWithRetry;
5333
5373
  exports.waitForViemTransactionWithRetry = waitForViemTransactionWithRetry;
5334
- //# sourceMappingURL=calculate-farm-efficiency-CIHgzMwj.js.map
5374
+ //# sourceMappingURL=calculate-farm-efficiency-CBI3L6Cz.js.map