fix(cli): support shared foundry artifact deployments - #5132
Conversation
|
@samsamtrum is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
|
promiseeuler
left a comment
There was a problem hiding this comment.
While testing the new shared-artifact path locally on commit 86c111e, I found that watch mode only updates the original artifact contract, not the deployment aliases.
The initial contracts() call correctly returns ERC20, DAI, and WETH. After rewriting ERC20.json, however, plugin.watch.onChange(artifactPath) returns only:
{
name: 'ERC20',
abi: [{ name: 'after', /* ... */ }],
}This comes from both callbacks selecting (await getContract(path))[0]. In generate --watch, that updates only the ERC20 entry in contractMap; the generated DAI and WETH configs keep the previous ABI until the process is restarted.
Could the watch contract support returning all resolved aliases (and remove all of them on unlink), with a regression test that changes the shared artifact after initial resolution? The current focused test passes, as does @wagmi/cli check:types; the additional watch regression fails because it receives the single ERC20 object instead of the three expected updates.
Summary
Adds support for multiple named deployments sharing one Foundry ABI artifact in the CLI Foundry plugin.
Problem
When several deployed contracts share the same ABI artifact (for example
DAIandWETHboth usingERC20.json), the Foundry plugin can currently only emit the artifact contract name. That means only one generated config/address pair is available for the shared ABI use case.Changes
deploymentArtifactsmapping from deployment name to Foundry artifact name.deploymentsaddress mapping behavior intact.ERC20ABI artifact.Example:
This allows generated exports such as both
daiConfigandwethConfigwhile reusingerc20Abi.Verification
corepack pnpm install --ignore-scripts --frozen-lockfile --filter @wagmi/cli...corepack pnpm exec biome check --write packages/cli/src/plugins/foundry.ts packages/cli/src/plugins/foundry.test.tscorepack pnpm exec vitest run packages/cli/src/plugins/foundry.test.ts -t 'contracts supports multiple deployment names sharing one ABI artifact'corepack pnpm --filter @wagmi/cli run check:typesCloses #4396