Skip to content

Commit 614001f

Browse files
authored
Merge pull request #989 from LIT-Protocol/feat/naga-shiva
Feat/naga shiva
2 parents 02f7eb3 + fbec27e commit 614001f

File tree

18 files changed

+1428
-672
lines changed

18 files changed

+1428
-672
lines changed

.changeset/warm-lizards-fry.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@lit-protocol/lit-client': patch
3+
'@lit-protocol/networks': patch
4+
'@lit-protocol/e2e': patch
5+
---
6+
7+
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.
Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
import { EthBlockhashInfo } from '@lit-protocol/types';
22

3+
const RETRY_ATTEMPTS = 2; // total attempts = RETRY_ATTEMPTS + 1
4+
const RETRY_DELAY_MS = 250;
5+
6+
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
7+
38
export const fetchBlockchainData = async () => {
4-
try {
5-
const resp = await fetch(
6-
'https://block-indexer.litgateway.com/get_most_recent_valid_block'
7-
);
8-
if (!resp.ok) {
9-
throw new Error(`Primary fetch failed with status: ${resp.status}`); // Or a custom error
10-
}
9+
let lastError: Error | undefined;
1110

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

15-
if (!blockhash || !timestamp) {
16-
throw new Error('Invalid data from primary blockhash source');
17-
}
20+
const blockHashBody: EthBlockhashInfo = await resp.json();
21+
const { blockhash, timestamp } = blockHashBody;
1822

19-
return blockhash;
20-
} catch (error) {
21-
if (error instanceof Error) {
22-
throw new Error(error.message);
23+
if (!blockhash || !timestamp) {
24+
throw new Error('Invalid data from primary blockhash source');
25+
}
26+
27+
return blockhash;
28+
} catch (error) {
29+
lastError = error instanceof Error ? error : new Error(String(error));
30+
if (attempt === RETRY_ATTEMPTS) {
31+
throw new Error(lastError.message);
32+
}
33+
34+
await delay(RETRY_DELAY_MS * (attempt + 1));
2335
}
24-
throw new Error(String(error));
2536
}
37+
38+
throw new Error(lastError?.message ?? 'Unknown fetchBlockchainData error');
2639
};

packages/e2e/src/e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {
1414
createViewPKPsByAddressTest,
1515
createViewPKPsByAuthDataTest,
1616
init,
17+
registerPaymentDelegationTicketSuite,
1718
} from '@lit-protocol/e2e';
1819
import type { AuthContext } from '@lit-protocol/e2e';
19-
import { registerPaymentDelegationTicketSuite } from './tickets/delegation.suite';
2020

2121
const SELECTED_NETWORK = process.env['NETWORK'];
2222
const RPC_OVERRIDE_ENV_VAR =

0 commit comments

Comments
 (0)