fix: correct attestation example flow and documentation#139
Conversation
WalkthroughThis PR updates the attestation example to fix non-functional execution methods by adding a package manifest, refactoring the control flow with proper error handling and attestation retrieval, and updating documentation with clarified prerequisites, running instructions, and signature verification code. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Script as index.ts
participant SDK as Attestation SDK
participant Blockchain
User->>Script: Run with PRIVATE_KEY
rect rgb(200, 220, 240)
Note over Script: Setup Phase
Script->>Script: Initialize wallet from PRIVATE_KEY
Script->>Script: Display wallet address (if no key, use default)
end
rect rgb(240, 220, 200)
Note over Script: List Attestations Phase
Script->>SDK: List recent attestations (limit: 3)
SDK-->>Script: Return attestation list
Script->>Script: Display TX ID, blocks, hashes
end
rect rgb(220, 240, 200)
Note over Script: Retrieve Signed Attestation Phase
alt Attestations exist
Script->>SDK: Fetch signed attestation
SDK-->>Script: Return payload & signature
Script->>Script: Compute SHA256(canonical payload)
Script->>Script: Recover validator address via recoverAddress(hash, R, S, V)
Script->>Script: Display extraction guidance
else No attestations
Script->>Script: Skip retrieval phase
end
end
rect rgb(240, 200, 220)
Note over Script: Request New Attestation Phase
alt Key provided
Script->>SDK: Request new attestation with data provider, stream, args
SDK->>Blockchain: Submit attestation request
Script->>Script: Wait for TX confirmation
Script->>SDK: Poll for signed attestation (multiple attempts)
alt Success
SDK-->>Script: Return signed attestation
Script->>Script: Extract & verify validator address
Script->>Script: Display payload details
else Timeout
Script->>Script: Log timeout, continue
end
else Insufficient balance
Script->>Script: Log insufficient balance, continue
end
end
Script->>User: Summarize completed operations
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Areas requiring attention:
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Time Submission Status
|
Bug Report Checklist
|
|
@pr-time-tracker bug commit 93e7768 && bug author @MicBun |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
examples/attestation/README.md(6 hunks)examples/attestation/index.ts(5 hunks)examples/attestation/package.json(1 hunks)
🧰 Additional context used
🪛 Gitleaks (8.28.0)
examples/attestation/README.md
[high] 61-61: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
| "scripts": { | ||
| "start": "tsx index.ts" | ||
| }, |
There was a problem hiding this comment.
Ensure tsx is installed for this package’s start script
Following the new Quick Start (clean clone → npm install at repo root → cd examples/attestation → npm start) still fails with sh: tsx: command not found. Because this package doesn’t declare tsx, the local npm start has no binary unless someone happens to have it installed globally. Please declare tsx (and install it before running) so the example works out of the box.
Suggested fix:
"scripts": {
- "start": "tsx index.ts"
- },
+ "start": "tsx index.ts"
+ },
+ "devDependencies": {
+ "tsx": "^4.19.0"
+ }After adding the dependency, remember to document running npm install inside this directory (see README).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "scripts": { | |
| "start": "tsx index.ts" | |
| }, | |
| "scripts": { | |
| "start": "tsx index.ts" | |
| }, | |
| "devDependencies": { | |
| "tsx": "^4.19.0" | |
| } |
🤖 Prompt for AI Agents
In examples/attestation/package.json around lines 6 to 8, the "start" script
uses the tsx binary which is not declared in this package, causing "tsx: command
not found"; add "tsx" (preferably as a devDependency) to this package.json and
run npm install in the examples/attestation directory so the binary is available
locally, and update the example README to instruct users to run npm install
inside examples/attestation before npm start.
| # From the sdk-js root directory, navigate to the example | ||
| cd examples/attestation | ||
|
|
||
| Or directly: | ||
| ```bash | ||
| npx tsx examples/attestation/index.ts | ||
| # Run with default test key | ||
| npm start | ||
| ``` | ||
|
|
||
| ### With Your Own Wallet | ||
|
|
||
| If you want to use your own private key instead of the test key: | ||
|
|
||
| ```bash | ||
| # Set your private key | ||
| export PRIVATE_KEY="0x..." | ||
| # From the sdk-js root directory, navigate to the example | ||
| cd examples/attestation | ||
|
|
||
| # Set your private key (replace with your actual private key) | ||
| export PRIVATE_KEY="0x1234567890abcdef..." | ||
|
|
||
| # Run the example | ||
| npm run example:attestation | ||
| npm start | ||
| ``` |
There was a problem hiding this comment.
Document installing the example dependencies before npm start
Results from README’s Quick Start (root npm install, cd examples/attestation, npm start) still error out because this package needs its own npm install to fetch tsx. Please add that step—otherwise the new manifest doesn’t actually fix the reproduction path from issue #136.
For example:
# From the sdk-js root directory, navigate to the example
cd examples/attestation
# Install example dependencies
npm install
# Run with default test key
npm startThat keeps the instructions runnable for anyone starting from a clean clone.
🧰 Tools
🪛 Gitleaks (8.28.0)
[high] 61-61: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🤖 Prompt for AI Agents
examples/attestation/README.md around lines 45 to 65: the Quick Start omits
installing the example-specific dependencies so running npm start after
installing at the repo root fails (missing tsx); update the instructions to
include an npm install step inside examples/attestation before npm start (show
commands: cd examples/attestation, npm install, then npm start) so the example
dependencies are fetched and the example runs from a clean clone.
resolves: #136
Summary by CodeRabbit
Release Notes
Documentation
New Features
Chores