Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move to input file as source of truth #75

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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