11#! /bin/bash
22set -euo pipefail
33
4- # Function to handle final preparation steps
4+ # Function to handle final preparation steps.
55final_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.
2020trap final_preparation EXIT
2121
2222
2323if [ $# -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
3836else
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 "
4240fi
0 commit comments