From 7793a32a0dbfae6d3b67ea252564147b07baf92f Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:00:16 +0100 Subject: [PATCH] even better --- latest.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 latest.sh diff --git a/latest.sh b/latest.sh new file mode 100755 index 00000000..a45ece22 --- /dev/null +++ b/latest.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +#!/bin/bash + +BASEPATH="$(dirname "$0")" +source $BASEPATH/.env + +blacklist=() +while IFS= read -r line; do + # Add each line to the array + blacklist+=("$line") +done < "$BASEPATH/path-blacklist.txt" + +pathlist=$(cat $BASEPATH/$1.yml | grep -oP "(?<=stripprefix\.prefixes).*\"" | cut -d'=' -f2- | sed 's/.$//') + +for path in $pathlist; do + include=true + for word in "${blacklist[@]}"; do + if echo "$path" | grep -qE "$word"; then + include=false + fi + done + + if $include; then + RPC_URL="https://$DOMAIN$path" + + curl -s -X POST $RPC_URL -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false],"id":1}' | jq -r '.result.number, .result.hash' | awk '{if (NR==1) print "Block Number:", strtonum($0); else print "Block Hash:", $0}' + fi +done