Skip to content

Commit

Permalink
feat: move to input file as source of truth (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
mds1 authored Jun 1, 2024
1 parent 52f1893 commit 44f9365
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
11 changes: 11 additions & 0 deletions script/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{ "chainId": 1 },
{ "chainId": 10 },
{ "chainId": 137 },
{ "chainId": 8453 },
{ "chainId": 34443 },
{ "chainId": 42161 },
{ "chainId": 43114 },
{ "chainId": 59144 },
{ "chainId": 534352 }
]
20 changes: 9 additions & 11 deletions script/main.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -euo pipefail

# Function to handle final preparation steps
# Function to handle final preparation steps.
final_preparation() {
local exitStatus=$?

Expand All @@ -16,27 +16,25 @@ final_preparation() {
fi
}

# Set up a trap to run final preparation steps on script exit
# Set up a trap to run final preparation steps on script exit.
trap final_preparation EXIT


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

index=1
for file in "${chainFiles[@]}"; do
input="${file%.json}" # Extract the file name without the extension
input="${input##*/}" # Extract the file name without the path
for chainId in $chainIds; do
echo ""
echo "Running for chain ID $input (chain $index of $numChains)"
bun script/index.ts "$input"
echo "Running for chain ID $chainId (chain $index of $numChains)"
bun script/index.ts "$chainId"
index=$((index + 1))
done
else
# Input provided, run the script with the provided input
# Input provided, run the script with the provided input.
echo "Running for chain ID $1"
bun script/index.ts "$1"
fi

0 comments on commit 44f9365

Please sign in to comment.