feat(reader): exportAddressBook — multi-network address-book / typed-client export (#152) - #162
Merged
Merged
Conversation
Aggregate one or more DeploymentSnapshots into a canonical downstream artifact: a deterministic JSON address book plus a typed TypeScript module (as const, so addresses[chainId].MyContract is type-safe), a matching .d.ts, and an optional publishable package scaffold. Optional per-contract ABIs are embedded verbatim (viem-ready) when supplied. Output is deterministic (chainId numeric asc, contractId sorted, fixed field order, trailing newline) so the artifact diffs cleanly in git. Null-address contracts are skipped with a warning; conflicting addresses for the same (chainId, contractId) are first-wins with a warning; empty input yields a valid empty artifact. Closes #152 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
robercano
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #152.
Adds
exportAddressBookto@redeploy/reader: aggregates one or moreDeploymentSnapshots into a canonical downstream artifact so reDeploy is the source of truth for "where is everything deployed".Output:
json— deterministic address book keyedchainId -> contractId -> { address, contractName, chainId, network?, deployedAt, abi? }.ts— a typed TypeScript module usingas const, soaddresses[chainId].MyContract.addressis a type-safe lookup (verified by a realtsc --noEmitcompile in the tests).dts— matching declaration mirror for consumers of compiled output.packageFiles(optional, whenpackageNameis set) — a publishable package scaffold (package.json+index.js+index.d.ts) for teams that version their address book on npm.warnings— surfaced for skipped/conflicting entries.Per-contract ABIs supplied via
abis(contractName -> ABI) are embedded verbatim (viem-ready); omitted entirely when not provided.Behavior
(chainId, contractId): first-wins with a warning; identical duplicates are silent.Scope is confined to
packages/reader/(module boundary respected). Pure/read-only — the caller persists the output.Gates
tsc --noEmittype-safety compiles)@redeploy/reader;address-book.ts97.51% stmts / 90.16% branch (threshold 80)Review
All four lenses (correctness, tests, security, performance) approved (consensus = all).
Known low-severity follow-up (non-blocking)
The security lens noted that an own-enumerable
__proto__key inside a caller-supplied ABI (only reachable if a caller passes an ABI built viaJSON.parse('{"__proto__":...}')— real viem ABIs never carry such keys) is emitted into the generated object literal and performs a prototype SET on that one nested object at module-eval time. It is confined to a single nested object in the generated artifact — no RCE, no consumer global prototype pollution. Note: simply quoting the key does NOT fix it (a quoted"__proto__"literal key still sets the prototype in JS; only a computed["__proto__"]key creates an own property), so a proper fix would change the generated output format and warrants its own review — deferred as a follow-up rather than bundled here.🤖 Generated with Claude Code