update
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"base": {
|
"base": {
|
||||||
"id": 8453,
|
"id": 8453,
|
||||||
"urls": ["https://base.drpc.org"]}
|
"urls": ["https://base.drpc.org"]},
|
||||||
"eth": {
|
"eth": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"urls": ["https://eth.drpc.org"]}
|
"urls": ["https://eth.drpc.org"]}
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Check if the script is provided with the correct number of arguments
|
# Check if the script is provided with the correct number of arguments
|
||||||
if [ $# -ne 2 ]; then
|
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
|
||||||
echo "Usage: $0 <id> <index>"
|
echo "Usage: $0 <id> [<index>]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ID and index provided as arguments
|
# ID and index provided as arguments
|
||||||
id="$1"
|
id="$1"
|
||||||
index="$2"
|
|
||||||
|
# Set index to 0 if not provided as the second argument
|
||||||
|
index="${2:-0}"
|
||||||
|
|
||||||
# Check if the JSON file exists
|
# Check if the JSON file exists
|
||||||
json_file="reference-rpc-endpoint.json"
|
json_file="reference-rpc-endpoint.json"
|
||||||
if [ ! -f "$json_file" ]; then
|
if [ ! -f "$json_file" ]; then
|
||||||
echo "Error: JSON file '$json_file' not found."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -22,7 +23,6 @@ object=$(jq --arg id "$id" '.[] | select(.id == ($id | tonumber))' "$json_file")
|
|||||||
|
|
||||||
# Check if the object exists
|
# Check if the object exists
|
||||||
if [ -z "$object" ]; then
|
if [ -z "$object" ]; then
|
||||||
echo "Error: Object with ID '$id' not found."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ urls=$(echo "$object" | jq -r '.urls')
|
|||||||
# Check if the index is out of range
|
# Check if the index is out of range
|
||||||
num_urls=$(echo "$urls" | jq -r 'length')
|
num_urls=$(echo "$urls" | jq -r 'length')
|
||||||
if [ "$index" -ge "$num_urls" ]; then
|
if [ "$index" -ge "$num_urls" ]; then
|
||||||
echo "Error: Index '$index' is out of range for ID '$id'."
|
#echo "Error: Index '$index' is out of range for ID '$id'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -40,4 +40,4 @@ fi
|
|||||||
url=$(echo "$urls" | jq -r ".[$index]")
|
url=$(echo "$urls" | jq -r ".[$index]")
|
||||||
|
|
||||||
# Print the URL
|
# Print the URL
|
||||||
echo "URL at index '$index' for ID '$id': $url"
|
echo "$url"
|
||||||
|
|||||||
Reference in New Issue
Block a user