Skip to content

fix(cli): support named Foundry deployments sharing one artifact ABI - #5231

Open
TLSRUF wants to merge 1 commit into
wevm:mainfrom
TLSRUF:fix/foundry-alias-deployments
Open

fix(cli): support named Foundry deployments sharing one artifact ABI#5231
TLSRUF wants to merge 1 commit into
wevm:mainfrom
TLSRUF:fix/foundry-alias-deployments

Conversation

@TLSRUF

@TLSRUF TLSRUF commented Aug 27, 2026

Copy link
Copy Markdown

Closes #4396

The foundry plugin's deployments map is keyed by artifact name, so it can't express two named contracts (e.g. DAI and WETH) that share one artifact's ABI with different addresses — one entry silently overwrites the other, and only one of the two ends up generated.

What changed

Added a second deployments value shape, { artifact, address }, that generates an additional named contract reusing another artifact's ABI:

foundry({
  deployments: {
    DAI: { artifact: 'ERC20', address: { 1: '0x...' } },
    WETH: { artifact: 'ERC20', address: { 1: '0x...' } },
  },
})

The existing plain-address shape (deployments: { ERC20: { 1: '0x...' } }) is unchanged and fully backward compatible — covered by a new regression test.

Scope / limitation

Alias contracts are resolved by contracts() (i.e. a full wagmi generate run). watch.onAdd/watch.onChange can only return a single ContractConfig per changed file (per the existing Watch type), so during wagmi generate --watch a changed artifact only re-emits its own artifact-named contract — picking up alias contracts needs a rerun of wagmi generate. This is called out in the docs. Happy to extend onAdd/onChange to return multiple contracts in a follow-up if that's preferred, but wanted to keep this PR's surface area (and the shared Watch type used by every plugin) small.

Prior attempt

#5011 attempted this earlier but grew into a larger watch-mode rework across several follow-up commits and was closed without a merge or review comment. This PR re-approaches the same issue with a smaller, additive change to keep it easy to review.

Testing

  • Added deployments support multiple named contracts sharing one artifact ABI and deployments still support a plain address for the artifact itself to foundry.test.ts
  • pnpm --filter @wagmi/cli check:types passes
  • biome check passes on changed files
  • Verified the new logic against real out/ artifacts locally with forge: { build: false } (this dev environment doesn't have Foundry installed, so I couldn't exercise the existing forge build-dependent tests locally, only my scoped verification — CI has Foundry installed and should run the full suite)

🤖 Generated with Claude Code

Fixes wevm#4396. The foundry plugin's `deployments` map is keyed by artifact
name, so it can't express two named contracts (e.g. DAI and WETH) that
share one artifact's ABI with different addresses — one entry silently
overwrites the other.

Add a second deployment shape, `{ artifact, address }`, that generates
an additional named contract reusing another artifact's ABI:

  deployments: {
    DAI: { artifact: 'ERC20', address: { 1: '0x...' } },
    WETH: { artifact: 'ERC20', address: { 1: '0x...' } },
  }

The existing plain-address shape is unchanged and still works. Alias
contracts are resolved by contracts() (a full `wagmi generate` run);
onAdd/onChange in --watch mode can only return one ContractConfig per
changed file, so alias contracts need a rerun to pick up, which is now
documented.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc23b29

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

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

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