Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/warm-lizards-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@lit-protocol/lit-client': patch
'@lit-protocol/networks': patch
'@lit-protocol/e2e': patch
---

SDK exposes typed Shiva env helpers (`createShivaEnvVars`, `waitForTestnetInfo`, `SUPPORTED_NETWORKS`) so QA suites can spin up testnets without bespoke env plumbing, and the new `executeWithHandshake` runner automatically retry failures for more stable Lit action execution.
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
import { EthBlockhashInfo } from '@lit-protocol/types';

const RETRY_ATTEMPTS = 2; // total attempts = RETRY_ATTEMPTS + 1
const RETRY_DELAY_MS = 250;

const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

export const fetchBlockchainData = async () => {
try {
const resp = await fetch(
'https://block-indexer.litgateway.com/get_most_recent_valid_block'
);
if (!resp.ok) {
throw new Error(`Primary fetch failed with status: ${resp.status}`); // Or a custom error
}
let lastError: Error | undefined;

const blockHashBody: EthBlockhashInfo = await resp.json();
const { blockhash, timestamp } = blockHashBody;
for (let attempt = 0; attempt <= RETRY_ATTEMPTS; attempt++) {
try {
const resp = await fetch(
'https://block-indexer.litgateway.com/get_most_recent_valid_block'
);
if (!resp.ok) {
throw new Error(`Primary fetch failed with status: ${resp.status}`);
}

if (!blockhash || !timestamp) {
throw new Error('Invalid data from primary blockhash source');
}
const blockHashBody: EthBlockhashInfo = await resp.json();
const { blockhash, timestamp } = blockHashBody;

return blockhash;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
if (!blockhash || !timestamp) {
throw new Error('Invalid data from primary blockhash source');
}

return blockhash;
} catch (error) {
lastError = error instanceof Error ? error : new Error(String(error));
if (attempt === RETRY_ATTEMPTS) {
throw new Error(lastError.message);
}

await delay(RETRY_DELAY_MS * (attempt + 1));
}
throw new Error(String(error));
}

throw new Error(lastError?.message ?? 'Unknown fetchBlockchainData error');
};
2 changes: 1 addition & 1 deletion packages/e2e/src/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
createViewPKPsByAddressTest,
createViewPKPsByAuthDataTest,
init,
registerPaymentDelegationTicketSuite,
} from '@lit-protocol/e2e';
import type { AuthContext } from '@lit-protocol/e2e';
import { registerPaymentDelegationTicketSuite } from './tickets/delegation.suite';

const SELECTED_NETWORK = process.env['NETWORK'];
const RPC_OVERRIDE_ENV_VAR =
Expand Down
Loading
Loading