Skip to content

feat(json-abi): support enum definitions - #1155

Merged
DaniPopes merged 3 commits into
alloy-rs:mainfrom
stevencartavia:support-enum-definitions
Jul 17, 2026
Merged

DaniPopes merged 3 commits into
alloy-rs:mainfrom
stevencartavia:support-enum-definitions

Conversation

@stevencartavia

Copy link
Copy Markdown
Collaborator

JSON ABIs preserve an enum’s name through internalType, but do not include its variants, so JsonAbi::to_sol currently represents enums as uint8 user-defined value types. This adds optional enum definitions to the JSON ABI rendering and SolInput normalization APIs, allowing callers with compiler metadata to generate real Solidity enum declarations.

Existing behavior remains unchanged when definitions are missing, invalid, or conflicting, falling back to the current uint8 representation. This enables consumers such as Foundry to restore enum variants from Solar without duplicating Alloy’s ABI traversal or rewriting the generated AST. This supports foundry-rs/foundry#10441.

Comment thread crates/json-abi/src/abi.rs Resolved
Comment thread crates/json-abi/src/to_sol.rs Resolved
Comment thread crates/json-abi/src/to_sol.rs Resolved
@github-project-automation github-project-automation Bot moved this to Reviewed in Alloy Jul 17, 2026
@DaniPopes
DaniPopes enabled auto-merge (squash) July 17, 2026 19:12
@DaniPopes
DaniPopes merged commit a0ee414 into alloy-rs:main Jul 17, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewed to Done in Alloy Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants