-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit -o pipefail -o nounset | ||
|
||
repo_root_dir="$(git rev-parse --show-toplevel)" | ||
|
||
for deployment in "$repo_root_dir/broadcast/"*"/"*"/"*".json"; do | ||
# The subfolder name is the chain id | ||
chain_id=${deployment%/*} | ||
chain_id=${chain_id##*/} | ||
|
||
# First, every single deployment is formatted as if it had its own networks.json | ||
jq --arg chainId "$chain_id" ' | ||
.transactions[] | ||
| select(.transactionType == "CREATE") | ||
| select(.hash != null) | ||
| {(.contractName): {($chainId): {address: .contractAddress, transactionHash: .hash }}} | ||
' <"$deployment" | ||
done \ | ||
| # Then, all these single-contract single-chain-id networks.jsons are merged. Note: in case the same contract is | ||
# deployed twice in the same script run, the last deployed contract takes priority. | ||
jq --sort-keys --null-input 'reduce inputs as $item ({}; . *= $item)' | ||
|
||
# Todo: handle case where the same contract is deployed on multiple chains. |