diff --git a/subgraph/scripts/update.sh b/subgraph/scripts/update.sh index 2c867c7..857e147 100755 --- a/subgraph/scripts/update.sh +++ b/subgraph/scripts/update.sh @@ -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} @@ -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 \ No newline at end of file