Skip to content

Commit 0ce1972

Browse files
committed
docs(flashtestations-sdk): prepare SDK for initial public release with comprehensive documentation
This commit prepares the flashtestations-sdk for its initial public release by: 1. Overhauling documentation and cleaning up the public API surface. 2. Transforming the README from a generic TSDX template into comprehensive SDK documentation including installation instructions, API reference, error handling guide, advanced usage patterns, and practical examples. 3. Unused example files (getBlock.ts and getTransactionReceipt.ts) have been removed In a future commit we will update the version number to 1.0.0 and publish the SDK to npm improving VerificationResult handling
1 parent cc21e5a commit 0ce1972

File tree

11 files changed

+518
-283
lines changed

11 files changed

+518
-283
lines changed

sdks/flashtestations-sdk/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.DS_Store
33
node_modules
44
dist
5+
6+
.claude-output/

sdks/flashtestations-sdk/README.md

Lines changed: 290 additions & 56 deletions
Large diffs are not rendered by default.

sdks/flashtestations-sdk/examples/getBlock.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

sdks/flashtestations-sdk/examples/getFlashtestationTx.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
import { createRpcClient } from '../src/rpc/client';
1+
import { getFlashtestationTx } from '../src/index';
22

33
/**
4-
* Example: Check if a transaction is a flashtestation transaction
4+
* Example: Check if a block contains a flashtestation transaction
55
*
66
* This example demonstrates how to:
7-
* 1. Create an RPC client for Unichain Sepolia (chain ID 1301)
8-
* 2. Check if a transaction emitted the BlockBuilderProofVerified event
9-
* 3. Retrieve the full transaction data if it's a flashtestation transaction
10-
* 4. Handle the case where the transaction is not a flashtestation
7+
* 1. Use the getFlashtestationTx function to fetch flashtestation data from a block
8+
* 2. Retrieve the full flashtestation event data if present
9+
* 3. Handle the case where the block does not contain a flashtestation transaction
1110
*/
1211
async function main() {
1312
try {
14-
// Create RPC client for Unichain Sepolia (chain ID 1301)
15-
const client = createRpcClient({
13+
// Fetch flashtestation transaction from the latest block on Unichain Sepolia
14+
const tx = await getFlashtestationTx('latest', {
1615
chainId: 1301, // Unichain Sepolia testnet
1716
// Optional: provide custom RPC URL
1817
// rpcUrl: 'https://sepolia.unichain.org',
19-
// Optional: configure retry behavior
20-
// maxRetries: 3,
21-
// initialRetryDelay: 1000,
2218
});
2319

24-
// Check if this transaction is a flashtestation
25-
const tx = await client.getFlashtestationTx('latest');
26-
2720
if (tx) {
2821
// This is a flashtestation transaction
2922
console.log('\n✓ This is a flashtestation transaction!\n');
@@ -37,10 +30,8 @@ async function main() {
3730
console.log(`Source Locators: ${tx.sourceLocators.length > 0 ? tx.sourceLocators.join(', ') : 'None'}`);
3831
} else {
3932
// This is not a flashtestation transaction
40-
console.log('\n✗ This is not a flashtestation transaction.');
41-
console.log('\nThe transaction either:');
42-
console.log(' 1. Does not exist');
43-
console.log(' 2. Did not emit the BlockBuilderProofVerified event');
33+
console.log('\n✗ This is not a flashtestation transaction');
34+
console.log('\nThe transaction did not emit the BlockBuilderProofVerified event');
4435
}
4536

4637
} catch (error) {

sdks/flashtestations-sdk/examples/getTransactionReceipt.ts

Lines changed: 0 additions & 66 deletions
This file was deleted.

sdks/flashtestations-sdk/examples/verifyBlock.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { verifyFlashtestationInBlock } from '../src/verification/service';
1+
import { verifyFlashtestationInBlock } from '../src/index';
22

33
/**
44
* Example: Verify if a block was built by a specific TEE workload
@@ -43,19 +43,27 @@ async function main() {
4343

4444
if (result.isBuiltByExpectedTee) {
4545
console.log('\n✓ Block was built by the specified TEE workload!\n');
46-
console.log(`Workload ID: ${result.workloadId}`);
47-
console.log(`Commit Hash: ${result.commitHash}`);
48-
console.log(`Builder Address: ${result.builderAddress}`);
49-
console.log(`Version: ${result.version}`);
50-
console.log(`Source Locators: ${result.sourceLocators && result.sourceLocators.length > 0 ? result.sourceLocators.join(', ') : 'None'}`)
46+
console.log(`Workload ID: ${result.workloadMetadata.workloadId}`);
47+
console.log(`Commit Hash: ${result.workloadMetadata.commitHash}`);
48+
console.log(`Builder Address: ${result.workloadMetadata.builderAddress}`);
49+
console.log(`Version: ${result.workloadMetadata.version}`);
50+
console.log(`Source Locators: ${result.workloadMetadata.sourceLocators && result.workloadMetadata.sourceLocators.length > 0 ? result.workloadMetadata.sourceLocators.join(', ') : 'None'}`)
5151
if (result.blockExplorerLink) {
5252
console.log(`Block Explorer: ${result.blockExplorerLink}`);
5353
}
5454
} else {
55-
console.log('\n✗ Block was NOT built by the specified TEE workload.\n');
56-
console.log('The block either:');
57-
console.log(' 1. Does not contain a flashtestation transaction');
58-
console.log(' 2. Contains a flashtestation from a different workload');
55+
console.log('\n✗ Block was NOT built by the specified TEE workload\n');
56+
57+
if (result.workloadMetadata) {
58+
console.log('Block was built by a different TEE workload:');
59+
console.log(`Workload ID: ${result.workloadMetadata.workloadId}`);
60+
console.log(`Commit Hash: ${result.workloadMetadata.commitHash}`);
61+
console.log(`Builder Address: ${result.workloadMetadata.builderAddress}`);
62+
console.log(`Version: ${result.workloadMetadata.version}`);
63+
console.log(`Source Locators: ${result.workloadMetadata.sourceLocators.length > 0 ? result.workloadMetadata.sourceLocators.join(', ') : 'None'}`)
64+
} else {
65+
console.log('The block does not contain a flashtestation transaction')
66+
}
5967
}
6068

6169
// You can also verify specific blocks:

sdks/flashtestations-sdk/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"keywords": [
77
"flashteststations",
88
"ethereum",
9-
"flashbots"
9+
"flashbots",
10+
"unichain"
1011
],
1112
"version": "0.1.0",
1213
"license": "MIT",
Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
1-
// TODO: Remove this
2-
export const sum = (a: number, b: number) => {
3-
if ('development' === process.env.NODE_ENV) {
4-
console.log('boop');
5-
}
6-
return a + b;
7-
};
1+
/**
2+
* Flashtestations SDK - Verify TEE-built blocks on Unichain
3+
*
4+
* This SDK provides tools to verify whether blockchain blocks were built by
5+
* Trusted Execution Environments (TEEs) running specific workload software.
6+
*/
7+
8+
// Main verification function
9+
export { verifyFlashtestationInBlock, getFlashtestationTx } from './verification/service';
10+
11+
12+
// Core types
13+
export type {
14+
VerificationResult,
15+
WorkloadMeasureRegisters,
16+
BlockParameter,
17+
FlashtestationEvent,
18+
ChainConfig,
19+
ClientConfig,
20+
} from './types';
21+
22+
// Error classes for programmatic error handling
23+
export {
24+
NetworkError,
25+
BlockNotFoundError,
26+
ValidationError,
27+
ChainNotSupportedError,
28+
} from './types';
29+
30+
// Chain configuration utilities
31+
export {
32+
getSupportedChains,
33+
isChainSupported,
34+
getChainConfig,
35+
} from './config/chains';
36+
37+
// Workload ID computation utility
38+
export { computeWorkloadId } from './crypto/workload';

sdks/flashtestations-sdk/src/types/index.ts

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
1-
/**
2-
* Result of flashtestation verification
3-
*/
4-
export interface VerificationResult {
5-
/** Whether the block was built by a TEE running the specified workload */
6-
isBuiltByExpectedTee: boolean;
7-
/** workload ID of the TEE workload, null if not TEE-built */
8-
workloadId: string | null;
9-
/** Commit hash of the TEE workload source code, null if not TEE-built */
10-
commitHash: string | null;
11-
/** Block explorer link for the block, null if not TEE-built */
12-
blockExplorerLink: string | null;
1+
export type WorkloadMetadata = {
2+
/** workload ID of the TEE workload*/
3+
workloadId: string;
4+
/** Commit hash of the TEE workload source code */
5+
commitHash: string;
136
/** Address of the block builder, optional */
14-
builderAddress?: string;
7+
builderAddress: string;
158
/** Version of the flashtestation protocol, optional */
169
version: number;
1710
/** Source locators (e.g., GitHub URLs) for the workload source code, optional for backwards compatibility */
18-
sourceLocators?: string[];
11+
sourceLocators: string[];
1912
}
2013

14+
/**
15+
* Result of flashtestation verification
16+
*/
17+
export type VerificationResult = | {
18+
/** Block was built by the expected TEE workload */
19+
isBuiltByExpectedTee: true;
20+
blockExplorerLink: string | null;
21+
workloadMetadata: WorkloadMetadata;
22+
}
23+
| {
24+
/** Block was NOT built by the expected TEE workload */
25+
isBuiltByExpectedTee: false;
26+
blockExplorerLink: string | null;
27+
workloadMetadata: WorkloadMetadata | null;
28+
};
29+
2130
/**
2231
* TEE workload measurement registers used for workload ID computation
2332
*/
@@ -74,6 +83,16 @@ export interface ChainConfig {
7483
blockExplorerUrl: string;
7584
}
7685

86+
/**
87+
* Minimal configuration options for the JSON-RPC client to interact with the blockchain
88+
*/
89+
export interface ClientConfig {
90+
/** Chain ID to network */
91+
chainId: number;
92+
/** Optional custom RPC URL (overrides default) */
93+
rpcUrl?: string;
94+
}
95+
7796
/**
7897
* Block parameter for identifying blocks
7998
*/

0 commit comments

Comments
 (0)