Skip to content

Commit

Permalink
Update renew-config.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyfilyanin authored Jul 19, 2024
1 parent be72ce6 commit adba1fc
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions scripts/renew-config.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

TESTNET_CONFIG_PATH="./config/rosetta/vara-testnet.json"
MAINNET_CONFIG_PATH="./config/rosetta/vara-mainnet.json"

Expand All @@ -10,17 +12,52 @@ production_meta_url="https://github.com/gear-tech/gear/releases/download/v"$tag"
echo "Downloading testnet metadata from $testnet_meta_url"
testnet_metadata=$(curl -L $testnet_meta_url)

if [ $? -ne 0 ]; then
echo "Failed to download testnet metadata"
exit 1
fi

echo "Downloading production metadata from $production_meta_url"
production_metadata=$(curl -L $production_meta_url)

if [ $? -ne 0 ]; then
echo "Failed to download production metadata"
exit 1
fi

# Convert metadata to JSON format if needed
testnet_metadata_json=$(echo "$testnet_metadata" | jq .)
if [ $? -ne 0 ]; then
echo "Failed to parse testnet metadata as JSON"
exit 1
fi

production_metadata_json=$(echo "$production_metadata" | jq .)
if [ $? -ne 0 ]; then
echo "Failed to parse production metadata as JSON"
exit 1
fi

echo "Updating testnet config"
echo "$testnet_metadata" | jq --argjson version "$version" \
'.metadataRpc = input | .specVersion = $version' \
jq --argjson version "$version" --argjson metadata "$testnet_metadata_json" \
'.metadataRpc = $metadata | .specVersion = $version' \
"$TESTNET_CONFIG_PATH" > tmp.$$.json \
&& mv tmp.$$.json "$TESTNET_CONFIG_PATH"

if [ $? -ne 0 ]; then
echo "Failed to update testnet config"
exit 1
fi

echo "Updating mainnet config"
echo "$production_metadata" | jq --argjson version "$version" \
'.metadataRpc = input | .specVersion = $version' \
jq --argjson version "$version" --argjson metadata "$production_metadata_json" \
'.metadataRpc = $metadata | .specVersion = $version' \
"$MAINNET_CONFIG_PATH" > tmp.$$.json \
&& mv tmp.$$.json "$MAINNET_CONFIG_PATH"

if [ $? -ne 0 ]; then
echo "Failed to update mainnet config"
exit 1
fi

echo "Configuration update completed successfully"

0 comments on commit adba1fc

Please sign in to comment.