Skip to content

fix(cli): support named Foundry deployments sharing one ABI#5011

Open
theamodhshetty wants to merge 5 commits intowevm:mainfrom
theamodhshetty:codex/foundry-multi-address-alias
Open

fix(cli): support named Foundry deployments sharing one ABI#5011
theamodhshetty wants to merge 5 commits intowevm:mainfrom
theamodhshetty:codex/foundry-multi-address-alias

Conversation

@theamodhshetty
Copy link
Copy Markdown
Contributor

Summary

This fixes foundry plugin deployments so multiple generated contracts can share a single artifact ABI.

Issue: when one ABI is reused for multiple deployments on the same chain (e.g. DAI + WETH both using ERC20), users currently can't express this in deployments without overwriting values.

What changed

  • Added named deployment support to Foundry plugin config:
    • existing (unchanged):
      • Counter: { 1: '0x...' }
    • new:
      • DAI: { artifact: 'ERC20', address: { 1: '0x...' } }
      • WETH: { artifact: 'ERC20', address: { 1: '0x...' } }
  • Foundry plugin now generates extra contract entries for named deployments using the referenced artifact ABI.
  • Added docs for the new deployment shape in site/cli/api/plugins/foundry.md.
  • Added regression test: named deployments can share one artifact ABI.
  • Added changeset for @wagmi/cli patch bump.

Validation

  • pnpm --filter @wagmi/cli check:types
  • pnpm exec vitest run --project cli packages/cli/src/plugins/foundry.test.ts -t "named deployments can share one artifact ABI"

Note: running the full foundry.test.ts suite locally requires forge to be installed; this environment does not have forge available.

Closes #4396

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 28, 2026

@theamodhshetty is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 28, 2026

🦋 Changeset detected

Latest commit: d7ca8c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@wagmi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@theamodhshetty
Copy link
Copy Markdown
Contributor Author

Small correction on my previous comment (formatting got mangled while posting from terminal).

I added a follow-up fix on this branch to keep named Foundry deployments in sync during --watch mode.

What changed:

  • watch callbacks can now return multiple contracts/names
  • Foundry now emits all contracts tied to an artifact (base + named aliases) on add/change
  • remove events now clear aliases too
  • added regression coverage for watch add/change/remove with shared ABI deployments

Validation run:

  • pnpm --filter @wagmi/cli check:types
  • pnpm exec vitest run --project cli packages/cli/src/plugins/foundry.test.ts -t "watch callbacks include named deployments for one artifact|named deployments can share one artifact ABI"

forge isn’t installed in this environment, so full Foundry fixture tests were not runnable locally.

@theamodhshetty
Copy link
Copy Markdown
Contributor Author

Pushed another follow-up on this branch:

  • fix(cli): fall back to onChange for watch add events (f836f1e5)
  • plus formatter follow-up (d7ca8c2f)

This covers plugins that implement onChange but omit optional onAdd, and adds watch-mode regression tests for:

  • add -> onChange fallback
  • unlink returning multiple contract names

Validation run:

  • pnpm --filter @wagmi/cli check:types
  • pnpm exec vitest run --project cli packages/cli/src/commands/generate.watch.test.ts

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.

bug: foundry plugin multiple addresses referencing the same ABI

1 participant