Skip to content

Commit acd2ccb

Browse files
authored
Merge branch 'naga' into feat/naga-prod
2 parents 762a5f3 + 614001f commit acd2ccb

File tree

24 files changed

+1564
-679
lines changed

24 files changed

+1564
-679
lines changed

.changeset/gold-ducks-repeat.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@lit-protocol/networks': patch
3+
'@lit-protocol/e2e': patch
4+
---
5+
6+
PKP signing now auto-hashes Cosmos payloads, exposes a documented bypassAutoHashing option, and ships with a new e2e suite plus docs so builders can rely on every listed curve working out of the box.

.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.

docs/sdk/auth-context-consumption/pkp-sign.mdx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ const signatures = await litClient.chain.raw.pkpSign({
3131
});
3232
```
3333

34+
### Hashing defaults and bypass
35+
36+
By default the SDK hashes ECDSA payloads for you using the canonical function for each chain (Ethereum → keccak256, Bitcoin/Cosmos → SHA-256/SHA-384) before sending to the nodes for signing. Schnorr/EdDSA schemes receive the raw bytes exactly as you provided them. If you already computed a digest (for example when signing EIP-712 typed data) you can pass it directly and opt out of the SDK hashing step by setting `bypassAutoHashing: true`:
37+
38+
```ts
39+
const digestBytes = hexToBytes(hashTypedData(typedData));
40+
41+
const signature = await litClient.chain.raw.pkpSign({
42+
chain: 'ethereum',
43+
signingScheme: 'EcdsaK256Sha256',
44+
pubKey: pkpInfo.pubkey,
45+
authContext,
46+
toSign: digestBytes,
47+
bypassAutoHashing: true,
48+
});
49+
```
50+
3451
---
3552

3653
# Available signing schemes
@@ -66,4 +83,4 @@ const signatures = await litClient.chain.raw.pkpSign({
6683
| `SchnorrRistretto25519Sha512` | Ristretto25519 |
6784
| `SchnorrRedJubjubBlake2b512` | Jubjub |
6885
| `SchnorrRedDecaf377Blake2b512` | Decaf377 |
69-
| `SchnorrkelSubstrate` | sr25519 |
86+
| `SchnorrkelSubstrate` | sr25519 |
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)