Skip to content

Commit 44f9365

Browse files
authored
feat: move to input file as source of truth (#75)
1 parent 52f1893 commit 44f9365

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

script/input.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{ "chainId": 1 },
3+
{ "chainId": 10 },
4+
{ "chainId": 137 },
5+
{ "chainId": 8453 },
6+
{ "chainId": 34443 },
7+
{ "chainId": 42161 },
8+
{ "chainId": 43114 },
9+
{ "chainId": 59144 },
10+
{ "chainId": 534352 }
11+
]

script/main.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
# Function to handle final preparation steps
4+
# Function to handle final preparation steps.
55
final_preparation() {
66
local exitStatus=$?
77

@@ -16,27 +16,25 @@ final_preparation() {
1616
fi
1717
}
1818

19-
# Set up a trap to run final preparation steps on script exit
19+
# Set up a trap to run final preparation steps on script exit.
2020
trap final_preparation EXIT
2121

2222

2323
if [ $# -eq 0 ]; then
24-
# No input provided, find all *.json files in the data/chain folder
25-
chainFiles=(script/data/chain/*.json)
26-
numChains=${#chainFiles[@]}
24+
# No input provided, read from `input.json`.
25+
chainIds=$(jq -r '.[].chainId' script/input.json)
26+
numChains=$(echo "$chainIds" | wc -l | xargs)
2727
echo "Found $numChains chains"
2828

2929
index=1
30-
for file in "${chainFiles[@]}"; do
31-
input="${file%.json}" # Extract the file name without the extension
32-
input="${input##*/}" # Extract the file name without the path
30+
for chainId in $chainIds; do
3331
echo ""
34-
echo "Running for chain ID $input (chain $index of $numChains)"
35-
bun script/index.ts "$input"
32+
echo "Running for chain ID $chainId (chain $index of $numChains)"
33+
bun script/index.ts "$chainId"
3634
index=$((index + 1))
3735
done
3836
else
39-
# Input provided, run the script with the provided input
37+
# Input provided, run the script with the provided input.
4038
echo "Running for chain ID $1"
4139
bun script/index.ts "$1"
4240
fi

0 commit comments

Comments
 (0)