@layr-labs/ecloud-sdk 0.4.0-dev.3 → 0.4.0-dev.4

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.
package/dist/billing.js CHANGED
@@ -1811,6 +1811,28 @@ async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
1811
1811
  const expectedCode = `0xef0100${delegatorAddress.slice(2)}`;
1812
1812
  return code.toLowerCase() === expectedCode.toLowerCase();
1813
1813
  }
1814
+ var TRANSIENT_PATTERNS = [
1815
+ "indexing is in progress",
1816
+ "is not in the chain"
1817
+ ];
1818
+ function isTransientReceiptError(error) {
1819
+ const msg = error instanceof Error ? error.message : String(error);
1820
+ return TRANSIENT_PATTERNS.some((p) => msg.includes(p));
1821
+ }
1822
+ async function waitForReceipt(publicClient, hash, logger, { maxRetries = 5, baseDelayMs = 2e3 } = {}) {
1823
+ for (let attempt = 0; ; attempt++) {
1824
+ try {
1825
+ return await publicClient.waitForTransactionReceipt({ hash });
1826
+ } catch (error) {
1827
+ if (!isTransientReceiptError(error) || attempt >= maxRetries) throw error;
1828
+ const delay = baseDelayMs * 2 ** attempt;
1829
+ logger.debug(
1830
+ `Receipt not available yet (attempt ${attempt + 1}/${maxRetries}), retrying in ${delay}ms...`
1831
+ );
1832
+ await new Promise((r) => setTimeout(r, delay));
1833
+ }
1834
+ }
1835
+ }
1814
1836
  async function executeBatch(options, logger = noopLogger) {
1815
1837
  const {
1816
1838
  walletClient,
@@ -1878,7 +1900,7 @@ async function executeBatch(options, logger = noopLogger) {
1878
1900
  }
1879
1901
  const hash = await walletClient.sendTransaction(txRequest);
1880
1902
  logger.info(`Transaction sent: ${hash}`);
1881
- const receipt = await publicClient.waitForTransactionReceipt({ hash });
1903
+ const receipt = await waitForReceipt(publicClient, hash, logger);
1882
1904
  if (receipt.status === "reverted") {
1883
1905
  let revertReason = "Unknown reason";
1884
1906
  try {