Skip to content

Commit

Permalink
fix(subgraph): update-script-to-handle-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Harman-singh-waraich committed Jun 4, 2024
1 parent f191704 commit e4986f9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions subgraph/scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ function update() #hardhatNetwork #graphNetwork #dataSourceIndex #contract
done
}

function updateTemplates() #hardhatNetwork #templateIndex #contract
{
local hardhatNetwork="$1"
local templateIndex="$2"
local contract="$3"
local artifact="$SCRIPT_DIR/../../contracts/deployments/$hardhatNetwork/$contract.json"

# Set the ABIs path for this Hardhat network
abiIndex=0
for f in $(yq e .templates[$templateIndex].mapping.abis[].file subgraph.yaml -o json -I 0 | jq -sr '.[]')
do
f2=$(echo $f | sed "s|\(.*\/deployments\/\).*\/|\1$hardhatNetwork\/|")
echo "$f2"
yq -i ".templates[$templateIndex].mapping.abis[$abiIndex].file=\"$f2\"" "$SCRIPT_DIR"/../subgraph.yaml
(( ++abiIndex ))
done
}

# as per ../contracts/hardhat.config.js
hardhatNetwork=${1:-arbitrumSepolia}

Expand All @@ -43,6 +61,14 @@ cp "$SCRIPT_DIR"/../subgraph.yaml "$SCRIPT_DIR"/../subgraph.yaml.bak.$(date +%s)

for contract in $(yq .dataSources[].name "$SCRIPT_DIR"/../subgraph.yaml)
do
echo "$i"
update $hardhatNetwork $graphNetwork $i $contract
(( ++i ))
done

j=0
for contract in $(yq .templates[].name "$SCRIPT_DIR"/../subgraph.yaml)
do
updateTemplates $hardhatNetwork $j $contract
(( ++j ))
done

0 comments on commit e4986f9

Please sign in to comment.