feat: generate frontend ABI bindings from Hardhat artifacts (ticket 09)#63
Merged
Conversation
Stop hand-maintaining contract ABIs in the frontend. A small Node script reads the Hardhat artifacts and emits viem-typed `as const` modules; the frontend imports those, and CI fails if they drift from the compiled contracts. - contracts/evm/scripts/generate-abis.mjs: reads artifacts, writes web/src/generated/contracts/<name>.ts (+ index) with an "Auto-generated. Do not edit" header. Plain Node ESM (no ts-node/Hardhat runtime needed). - contracts/evm: `npm run generate:abis` = hardhat compile + the script. - Covered: ArtistDirectory, ArtistRuntimeFactory, and the Music Registry/Royalties/Access/NFT pallet facets (the contracts the app calls). SmartRuntime is a diamond, called through the facet ABIs, so it needs no separate binding; extend CONTRACTS in the script to add more. - web/src/shared/config/contracts.ts drops its six hand-maintained ABI blocks and re-exports the generated modules under the same names, so useCatalog / useArtistConsole are unchanged. Generated (full) ABIs are supersets of the old curated subsets. - Generated files are committed, excluded from ESLint/Prettier (machine output) but still typechecked, so an un-regenerated signature change fails the build. - ci-evm regenerates and runs `git diff --exit-code -- web/src/generated` to fail on drift; its path filter now also watches web/src/generated/**. - Docs: web/README workflow section + ticket 09 delivery notes; backlog status. Verified: generate:abis clean, then web tsc + lint (0 errors) + build + fmt:check + 72 unit tests + 10/10 Playwright e2e all green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Deploy Preview for muzinga ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Ticket 09: generate frontend ABI bindings from Hardhat artifacts
Stops the frontend hand-maintaining contract ABIs. A small Node script reads the
Hardhat artifacts and emits viem-typed
as constmodules; the frontend importsthose, and CI fails if they drift from the compiled contracts. Branches from
main.What this does
contracts/evm/scripts/generate-abis.mjs: reads the artifacts and writesweb/src/generated/contracts/<name>.ts(+ anindex.tsbarrel), each with an// Auto-generated. Do not edit manually.header. Plain Node ESM on purpose:it only reads artifact JSON, so no ts-node or Hardhat runtime is needed.
npm run generate:abis(incontracts/evm) =hardhat compile && node scripts/generate-abis.mjs.ArtistDirectory,ArtistRuntimeFactory, and theMusicRegistry/MusicRoyalties/MusicAccess/
MusicNFTpallet facets.SmartRuntimeis a diamond and is called throughthose facet ABIs at the runtime address, so it needs no separate binding;
extend
CONTRACTSin the script to add more.web/src/shared/config/contracts.tsdrops its six hand-maintained ABI blocksand re-exports the generated modules under the same names, so
useCataloganduseArtistConsoleare unchanged. The generated (full) ABIs are supersets of thepreviously curated subsets.
output) but still typechecked by
tsc, so an un-regenerated signature changefails the web build.
ci-evmregenerates and runsgit diff --exit-code -- web/src/generatedtofail on drift; its path filter now also watches
web/src/generated/**.web/READMEworkflow section, ticket 09 delivery notes, backlog + plan status.Acceptance criteria (ticket 09)
npm run generate:abis).committed modules + the
ci-evmdrift diff).Verification
generate:abisclean (byte-stable output), then inweb/: tsc + lint (0 errors)unchanged (the e2e specs drive the on-chain calls through the new ABIs).
🤖 Generated with Claude Code