From 3dee116b8cd7f27b1f5875be77e9021aa28e11c0 Mon Sep 17 00:00:00 2001 From: Xykota Date: Thu, 26 Oct 2023 11:09:10 +0700 Subject: [PATCH] minor(frontend): add tool to generate subgraph.json --- packages/frontend/bin/import-subgraph.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 packages/frontend/bin/import-subgraph.sh diff --git a/packages/frontend/bin/import-subgraph.sh b/packages/frontend/bin/import-subgraph.sh new file mode 100755 index 00000000..5ee0168d --- /dev/null +++ b/packages/frontend/bin/import-subgraph.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -eu -o pipefail; cd "$(dirname "$0")/.." + +networks=$(jq -r 'keys|.[]' ../subgraph/deployments.json) + +# Output as: { "chainId1": "url1", "chainId2": "url2" } +output="{}" + +for network in $networks; do + # Get url from deployments.json value of the network key + url=$(jq -r ".\"$network\"" ../subgraph/deployments.json) + + # Get chain id from networks-more.json with key $network field chainId + chain_id=$(jq -r ".\"$network\".chainId" ../subgraph/networks-more.json) + + # Add to output + output=$(jq -n --argjson output "$output" --arg chain_id "$chain_id" --arg url "$url" '$output + { ($chain_id): $url }') +done + +echo "$output" > src/subgraph.json