-
Notifications
You must be signed in to change notification settings - Fork 7
Chore/arb to gnosis subgraphs and veascan config #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d740474
chore(veascan-subgraph): add support for arbToGnosis
739d18a
chore: update script for chain based config
e66d90b
chore(veascan-subgraph): add outbox support for arbToGnosis
c3029fa
chore(veascan): add arbToGnosis config
3a2202b
fix: script os dependency
053bee4
Merge branch 'dev' into chore/arbToGnosis-subgraphs
mani99brar ed423a3
Merge branch 'dev' into chore/arbToGnosis-subgraphs
mani99brar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,90 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # | ||
| # scripts/update.sh | ||
| # | ||
| # Usage: | ||
| # ./scripts/update.sh <hardhatNetwork> <graphNetwork> [contractFileSuffix] | ||
| # | ||
| # hardhatNetwork: either "sepolia" or "chiado" | ||
| # graphNetwork: the same string to write into subgraph.yaml → .network (e.g. "sepolia" or "chiado") | ||
| # | ||
|
|
||
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
| SUBGRAPH_YAML="$SCRIPT_DIR/../subgraph.yaml" | ||
| VEAOUTBOX_TS="$SCRIPT_DIR/../src/VeaOutbox.ts" | ||
|
|
||
| hardhatNetwork="${1:?"Usage: $0 <hardhatNetwork> <graphNetwork> [contractFileSuffix]"}" | ||
| graphNetwork="${2:?"Usage: $0 <hardhatNetwork> <graphNetwork> [contractFileSuffix]"}" | ||
| contractFileSuffix="${3:-}" | ||
|
|
||
| # Back up the original subgraph.yaml | ||
| cp "$SUBGRAPH_YAML" "$SUBGRAPH_YAML".bak."$(date +%s)" | ||
|
|
||
| count=$(yq '.dataSources | length' "$SUBGRAPH_YAML") | ||
|
|
||
| for i in $(seq 0 $((count - 1))); do | ||
| origName="$(yq -r ".dataSources[$i].name" "$SUBGRAPH_YAML")" | ||
| newName="$origName" | ||
|
|
||
| if [[ "$hardhatNetwork" == "sepolia" ]]; then | ||
| if [[ "$origName" == *"ArbToGnosisDevnet"* ]]; then | ||
| newName="${origName/ArbToGnosisDevnet/ArbToEthDevnet}" | ||
| elif [[ "$origName" == *"ArbToGnosisTestnet"* ]]; then | ||
| newName="${origName/ArbToGnosisTestnet/ArbToEthTestnet}" | ||
| fi | ||
|
|
||
| # Patch VeaOutbox.ts: swap Gnosis imports to Eth imports when targeting sepolia | ||
| sed -i "" \ | ||
| -e 's|from "../generated/VeaOutboxArbToGnosisDevnet/VeaOutboxArbToGnosisDevnet";|from "../generated/VeaOutboxArbToEthDevnet/VeaOutboxArbToEthDevnet";|' \ | ||
| -e 's|from "../generated/VeaOutboxArbToGnosisTestnet/VeaOutboxArbToGnosisTestnet";|from "../generated/VeaOutboxArbToEthTestnet/VeaOutboxArbToEthTestnet";|' \ | ||
| "$VEAOUTBOX_TS" | ||
|
|
||
|
|
||
| elif [[ "$hardhatNetwork" == "chiado" ]]; then | ||
| if [[ "$origName" == *"ArbToEthDevnet"* ]]; then | ||
| newName="${origName/ArbToEthDevnet/ArbToGnosisDevnet}" | ||
| elif [[ "$origName" == *"ArbToEthTestnet"* ]]; then | ||
| newName="${origName/ArbToEthTestnet/ArbToGnosisTestnet}" | ||
| fi | ||
|
|
||
|
|
||
| # Patch VeaOutbox.ts: swap Eth imports to Gnosis imports when targeting chiado | ||
| sed -i "" \ | ||
| -e 's|from "../generated/VeaOutboxArbToEthDevnet/VeaOutboxArbToEthDevnet";|from "../generated/VeaOutboxArbToGnosisDevnet/VeaOutboxArbToGnosisDevnet";|' \ | ||
| -e 's|from "../generated/VeaOutboxArbToEthTestnet/VeaOutboxArbToEthTestnet";|from "../generated/VeaOutboxArbToGnosisTestnet/VeaOutboxArbToGnosisTestnet";|' \ | ||
| "$VEAOUTBOX_TS" | ||
| fi | ||
| artifact="$SCRIPT_DIR/../../contracts/deployments/$hardhatNetwork/${newName}${contractFileSuffix}.json" | ||
|
|
||
| if [[ ! -f "$artifact" ]]; then | ||
| echo "Artifact not found for dataSource[$i]:" | ||
| exit 1 | ||
| fi | ||
|
|
||
| yq -i ".dataSources[$i].name = \"$newName\"" "$SUBGRAPH_YAML" | ||
|
|
||
| yq -i ".dataSources[$i].mapping.abis[0].name = \"$newName\"" "$SUBGRAPH_YAML" | ||
|
|
||
| relative_abi_file="../contracts/deployments/$hardhatNetwork/${newName}${contractFileSuffix}.json" | ||
| yq -i ".dataSources[$i].mapping.abis[0].file = \"$relative_abi_file\"" "$SUBGRAPH_YAML" | ||
|
|
||
| yq -i ".dataSources[$i].source.abi = \"$newName\"" "$SUBGRAPH_YAML" | ||
|
|
||
| if [[ "$graphNetwork" == "chiado" ]]; then | ||
| yq -i ".dataSources[$i].network = \"gnosis-chiado\"" "$SUBGRAPH_YAML" | ||
| else | ||
| yq -i ".dataSources[$i].network = \"$graphNetwork\"" "$SUBGRAPH_YAML" | ||
| fi | ||
|
|
||
| address="$(jq -r '.address' "$artifact")" | ||
| yq -i ".dataSources[$i].source.address = \"$address\"" "$SUBGRAPH_YAML" | ||
|
|
||
|
|
||
| blockNumber="$(jq '.receipt.blockNumber' "$artifact")" | ||
| yq -i ".dataSources[$i].source.startBlock = $blockNumber" "$SUBGRAPH_YAML" | ||
|
|
||
| function update() { # Parameters: file, dataSourceIndex, graphNetwork | ||
| local f="$1" | ||
| local dataSourceIndex="$2" | ||
| local graphNetwork="$3" | ||
|
|
||
| # Compute the contract file path relative to the subgraph.yaml file. | ||
| local contractFile="${f#$SCRIPT_DIR/../}" | ||
|
|
||
| # Update the ABI file path in subgraph.yaml using an inline environment variable. | ||
| contractFile="$contractFile" yq -i ".dataSources[$dataSourceIndex].mapping.abis[0].file = env(contractFile)" "$SCRIPT_DIR/../subgraph.yaml" | ||
|
|
||
| # Update the network field using the provided graphNetwork value. | ||
| graphNetwork="$graphNetwork" yq -i ".dataSources[$dataSourceIndex].network = env(graphNetwork)" "$SCRIPT_DIR/../subgraph.yaml" | ||
|
|
||
| # Extract the address and start block from the artifact using jq. | ||
| local address | ||
| address=$(jq '.address' "$f") | ||
| yq -i ".dataSources[$dataSourceIndex].source.address = $address" "$SCRIPT_DIR/../subgraph.yaml" | ||
|
|
||
| local blockNumber | ||
| blockNumber=$(jq '.receipt.blockNumber' "$f") | ||
| yq -i ".dataSources[$dataSourceIndex].source.startBlock = $blockNumber" "$SCRIPT_DIR/../subgraph.yaml" | ||
| } | ||
|
|
||
| # Parameters: | ||
| # $1: hardhatNetwork (default: sepolia) | ||
| # $2: graphNetwork (default: sepolia) | ||
| # $3: contractFileSuffix (optional; default: empty string) | ||
| hardhatNetwork="${1:-sepolia}" | ||
| graphNetwork="${2:-sepolia}" | ||
| contractFileSuffix="${3:-}" # default is now an empty string | ||
| i=0 | ||
|
|
||
| # Backup the current subgraph.yaml file. | ||
| cp "$SCRIPT_DIR/../subgraph.yaml" "$SCRIPT_DIR/../subgraph.yaml.bak.$(date +%s)" | ||
|
|
||
| # Iterate over each data source defined in subgraph.yaml. | ||
| for contract in $(yq .dataSources[].name "$SCRIPT_DIR/../subgraph.yaml"); do | ||
| update "$SCRIPT_DIR/../../contracts/deployments/$hardhatNetwork/${contract}${contractFileSuffix}.json" "$i" "$graphNetwork" | ||
| (( i++ )) | ||
| done | ||
|
|
||
| echo "Done! subgraph.yaml is now pointing at $hardhatNetwork artifacts. Backup saved as subgraph.yaml.bak.<timestamp>." | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| # Subgraph endpoints for veascan, Example: "85918/vea-inbox-arb-sepolia-devnet/version/latest" | ||
| export VEASCAN_INBOX_SUBGRAPH=61738/veascan-inbox-arb-sepolia/version/latest | ||
| export VEASCAN_OUTBOX_SUBGRAPH=61738/veascan-outbox-sepolia/version/latest | ||
| export VEASCAN_INBOX_SUBGRAPH_ARBSEPOLIA=61738/veascan-inbox-arb-sepolia/version/latest | ||
| export VEASCAN_OUTBOX_SUBGRAPH_CHIADO=61738/veascan-outbox-chiado/version/latest | ||
| export VEASCAN_OUTBOX_SUBGRAPH_SEPOLIA=61738/veascan-outbox-sepolia/version/latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.