Skip to content

Commit

Permalink
minor(frontend): add tool to generate subgraph.json
Browse files Browse the repository at this point in the history
  • Loading branch information
xykota committed Oct 26, 2023
1 parent bdd60a4 commit 3dee116
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/frontend/bin/import-subgraph.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3dee116

Please sign in to comment.