Skip to content

feat: generate frontend ABI bindings from Hardhat artifacts (ticket 09)#63

Merged
knzeng-e merged 1 commit into
mainfrom
feat/generated-abi-bindings
Jul 5, 2026
Merged

feat: generate frontend ABI bindings from Hardhat artifacts (ticket 09)#63
knzeng-e merged 1 commit into
mainfrom
feat/generated-abi-bindings

Conversation

@knzeng-e

@knzeng-e knzeng-e commented Jul 4, 2026

Copy link
Copy Markdown
Owner

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 const modules; the frontend imports
those, 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 writes
    web/src/generated/contracts/<name>.ts (+ an index.ts barrel), 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 (in contracts/evm) = hardhat compile && node scripts/generate-abis.mjs.
  • Covered contracts (the ones the app calls): ArtistDirectory,
    ArtistRuntimeFactory, and the MusicRegistry / MusicRoyalties / MusicAccess
    / MusicNFT pallet facets. SmartRuntime is a diamond and is called through
    those facet ABIs at the runtime address, 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 and
    useArtistConsole are unchanged. The generated (full) ABIs are supersets of the
    previously curated subsets.
  • Generated files are committed, excluded from ESLint/Prettier (machine
    output) but still typechecked by tsc, so an un-regenerated signature change
    fails the web 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 + plan status.

Acceptance criteria (ticket 09)

  • Fresh clone can compile contracts and generate bindings: yes (npm run generate:abis).
  • Frontend builds using generated bindings: yes.
  • Contract signature changes produce visible TS/CI failures: yes (tsc on the
    committed modules + the ci-evm drift diff).
  • Documentation explains the workflow: yes.

Verification

generate:abis clean (byte-stable output), then in web/: tsc + lint (0 errors)

  • build + fmt:check + 72 unit tests + 10/10 Playwright e2e, all green. Behavior
    unchanged (the e2e specs drive the on-chain calls through the new ABIs).

🤖 Generated with Claude Code

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>
@netlify

netlify Bot commented Jul 4, 2026

Copy link
Copy Markdown

Deploy Preview for muzinga ready!

Name Link
🔨 Latest commit a5afefc
🔍 Latest deploy log https://app.netlify.com/projects/muzinga/deploys/6a48efe36fb2be00088f5727
😎 Deploy Preview https://deploy-preview-63--muzinga.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@knzeng-e
knzeng-e merged commit 5efabab into main Jul 5, 2026
10 checks passed
@knzeng-e
knzeng-e deleted the feat/generated-abi-bindings branch July 5, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant