fix(cli/foundry): support multiple addresses sharing same ABI via DisplayName:ArtifactName#5131
Open
0xAxiom wants to merge 2 commits into
Open
fix(cli/foundry): support multiple addresses sharing same ABI via DisplayName:ArtifactName#51310xAxiom wants to merge 2 commits into
0xAxiom wants to merge 2 commits into
Conversation
…playName:ArtifactName Closes wevm#4396. When multiple tokens share an ABI (e.g. DAI and WETH both use ERC20), the `deployments` map previously only accepted one entry per contract name, causing later entries to silently overwrite earlier ones. Add `'DisplayName:ArtifactName'` key syntax to the foundry plugin's `deployments` option. Any key ending in `:ArtifactName` is treated as an alias: the ABI is read from `ArtifactName.json` and the generated export uses `DisplayName` as its name. Multiple aliases for the same artifact each produce their own named contract config. ```ts // wagmi.config.ts deployments: { 'DAI:ERC20': { 1: '0x6B175...' }, 'WETH:ERC20': { 1: '0xC02aA...' }, } // generates: daiConfig + wethConfig, both with erc20Abi ``` Direct-key deployments (`{ ERC20: { ... } }`) continue to work unchanged. Tests added for multi-alias, single-alias, and direct-key cases.
|
@0xAxiom is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
|
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.
Closes #4396.
Problem
When multiple tokens share an ABI (e.g. DAI and WETH both use
ERC20.json), thedeploymentsmap previously only accepted one entry per contract name — later entries silently overwrote earlier ones, producing only one export instead of two.Solution
Add a
'DisplayName:ArtifactName'key syntax to the foundry plugin'sdeploymentsoption. Any key ending in:ArtifactNameis treated as an alias: the ABI is read fromArtifactName.jsonand the generated export usesDisplayNameas its name. Multiple aliases for the same artifact each produce their own named contract config.Generated output:
Behaviour
'ERC20'ERC20'DAI:ERC20'ERC20.json, name =DAI'DAI:ERC20'+'WETH:ERC20'DAI,WETH), both witherc20AbiChanges
packages/cli/src/plugins/foundry.ts—getDeploymentsForArtifacthelper + updatedcontracts()loop + JSDoc ondeploymentsoptionpackages/cli/src/plugins/foundry.test.ts— two new tests: multi-alias and single-alias cases