Feat: Add Foundry broadcasts to deployments mapping
#4908
+205
−5
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.
Problem
The deployments mapping in
FoundryConfigis useful for attaching contracts to addresses. But often when developing locally in a monorepo I run anvil (or a local fork) and deploy my contracts there. The addresses might change as the contracts change, and keeping the deployments mapping updated is awkward, it seems like a small addition towagmi/clicould make this a lot easier.wagmi/site/cli/api/plugins/foundry.md
Lines 52 to 57 in 29f95df
Update
This PR adds a flag
includeBroadcastswhich automatically populates the deployments mapping with any contracts deployed in arun-latest.jsonfile in the/broadcasts/folder.wagmi/packages/cli/src/plugins/foundry.ts
Lines 55 to 62 in 80c777f
With that flag set, running
wagmi generatein a local development script after deploying any test contracts locally will take the latest deployment addresses and generate files that can be read by the frontend.Further Work
I think more info from these broadcast files could be useful to extract too. Things like
blockNumberor deployment arguments might be useful for linking to indexers etc.