Skip to content

Commit

Permalink
chore: add networks.json and build script
Browse files Browse the repository at this point in the history
  • Loading branch information
mfw78 committed Sep 10, 2024
1 parent a2c2a26 commit d97276e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
24 changes: 24 additions & 0 deletions dev/generate-networks-file.sh
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 == "CREATE2")
| 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.
38 changes: 38 additions & 0 deletions networks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"COWShed": {
"1": {
"address": "0x2cffa8cf11b90c9f437567b86352169df4009f73",
"transactionHash": "0x79847c8b2973ba9e7d428ad9b72f66000d90dda925ac7063bf9ad2ab40391e39"
},
"100": {
"address": "0x2cffa8cf11b90c9f437567b86352169df4009f73",
"transactionHash": "0x4b35fead93074842acf02c9578aee86d51f3b1f28b086878157d09e82d3410c6"
},
"11155111": {
"address": "0x2cffa8cf11b90c9f437567b86352169df4009f73",
"transactionHash": "0x35a6cdadd6bae4f7eb4ac916ea56b7e353030c9492817ef6e58fa8c2bc3521fc"
},
"42161": {
"address": "0x2cffa8cf11b90c9f437567b86352169df4009f73",
"transactionHash": "0x85b22963aac6eac5a365c50f768bf9b27bb316cbcf5eb49dc67af9ad40f7a7b1"
}
},
"COWShedFactory": {
"1": {
"address": "0x00e989b87700514118fa55326cd1cce82faebef6",
"transactionHash": "0x524688ba4b3f8bdcf142ae94cf69411613f94f3884cba6bec9a964399c73fb49"
},
"100": {
"address": "0x00e989b87700514118fa55326cd1cce82faebef6",
"transactionHash": "0x188c0a2b080e3684c56aa32ae61a697b1b34860a4acb9d4a94bda2c57c548041"
},
"11155111": {
"address": "0x00e989b87700514118fa55326cd1cce82faebef6",
"transactionHash": "0x90a44e07189e6ccec31cfa8de58ec1a5afbb4b4ae9bb1238fdd0b4ba8b98f2a5"
},
"42161": {
"address": "0x00e989b87700514118fa55326cd1cce82faebef6",
"transactionHash": "0x31a9f03c26a60231acd382468e3a2b2c6d3870cbdba4e5c0cc1ab9cf35210bf2"
}
}
}

0 comments on commit d97276e

Please sign in to comment.