22set -e
33
44# ==============================================================================
5- # SETUP LOCAL GRAPH NETWORK FOR TESTING
5+ # SETUP LOCAL GRAPH NETWORK FOR TESTING (HORIZON VERSION)
66# ==============================================================================
7- # This script sets up a local Graph network for testing.
7+ # This script sets up a local Graph network for testing with horizon upgrade .
88#
99# NOTES:
1010# - If you encounter container conflicts, run: docker compose down
@@ -34,13 +34,8 @@ container_running() {
3434 return $?
3535}
3636
37- # Function to fund the escrow smart contract
38- # 1. first read .env variables from local-network/.env
39- # 2. then read contract addresses from local-network/contracts.json
40- # 3. finally, use the cast command to approve and deposit GRT to the escrow
41- # this should be done just after deploying the gateway
42- # otherwise it does not move forward in its setup process
43- # causing false error during deployment of our local testnet
37+ # Function to fund the escrow smart contract for horizon
38+ # Uses L2GraphToken and TAPEscrow from the horizon structure
4439fund_escrow () {
4540 echo " Funding escrow for sender..."
4641
@@ -51,11 +46,14 @@ fund_escrow() {
5146 return 1
5247 fi
5348
54- GRAPH_TOKEN=$( jq -r ' ."1337".GraphToken.address' local-network/contracts.json)
55- TAP_ESCROW=$( jq -r ' ."1337".TAPEscrow.address' local-network/contracts.json)
49+ # Use L2GraphToken from horizon.json for horizon upgrade
50+ GRAPH_TOKEN=$( jq -r ' ."1337".L2GraphToken.address' local-network/horizon.json)
51+ TAP_ESCROW=$( jq -r ' ."1337".TAPEscrow.address' local-network/tap-contracts.json)
5652
57- if [ -z " $GRAPH_TOKEN " ] || [ -z " $TAP_ESCROW " ]; then
58- echo " Error: Could not read contract addresses from contracts.json"
53+ if [ -z " $GRAPH_TOKEN " ] || [ -z " $TAP_ESCROW " ] || [ " $GRAPH_TOKEN " == " null" ] || [ " $TAP_ESCROW " == " null" ]; then
54+ echo " Error: Could not read contract addresses from horizon.json or tap-contracts.json"
55+ echo " GRAPH_TOKEN: $GRAPH_TOKEN "
56+ echo " TAP_ESCROW: $TAP_ESCROW "
5957 return 1
6058 fi
6159
@@ -64,7 +62,7 @@ fund_escrow() {
6462 SENDER_KEY=" $ACCOUNT0_SECRET "
6563 AMOUNT=" 10000000000000000000"
6664
67- echo " Using GraphToken at: $GRAPH_TOKEN "
65+ echo " Using L2GraphToken at: $GRAPH_TOKEN "
6866 echo " Using TapEscrow at: $TAP_ESCROW "
6967 echo " Using sender address: $SENDER_ADDRESS "
7068
116114if [ ! -d " local-network" ]; then
117115 git clone https://github.com/semiotic-ai/local-network.git
118116 cd local-network
119- # Checkout to a branch with no dipper
117+ # Checkout to the horizon branch
120118 git checkout suchapalaver/test/horizon
121119 cd ..
122120fi
@@ -135,17 +133,17 @@ docker compose up -d graph-contracts
135133# Wait for contracts to be deployed
136134timeout 300 bash -c ' until docker ps -a | grep graph-contracts | grep -q "Exited (0)"; do sleep 5; done'
137135
138- # Verify the contracts have code
139- graph_token_address =$( jq -r ' ."1337".GraphToken .address' contracts .json)
140- controller_address=$( jq -r ' ."1337".Controller.address' contracts .json)
136+ # Verify the contracts have code using horizon structure
137+ l2_graph_token_address =$( jq -r ' ."1337".L2GraphToken .address' horizon .json)
138+ controller_address=$( jq -r ' ."1337".Controller.address' horizon .json)
141139
142- echo " Checking GraphToken contract at $graph_token_address "
143- code=$( docker exec chain cast code $graph_token_address --rpc-url http://localhost:8545)
140+ echo " Checking L2GraphToken contract at $l2_graph_token_address "
141+ code=$( docker exec chain cast code $l2_graph_token_address --rpc-url http://localhost:8545)
144142if [ -z " $code " ] || [ " $code " == " 0x" ]; then
145- echo " ERROR: GraphToken contract has no code!"
143+ echo " ERROR: L2GraphToken contract has no code!"
146144 exit 1
147145fi
148- echo " GraphToken contract verified."
146+ echo " L2GraphToken contract verified."
149147
150148echo " Checking Controller contract at $controller_address "
151149code=$( docker exec chain cast code $controller_address --rpc-url http://localhost:8545)
@@ -237,10 +235,12 @@ source local-network/.env
237235docker build -t local-gateway:latest ./local-network/gateway
238236
239237echo " Running gateway container..."
238+ # Updated to use the horizon file structure
240239docker run -d --name gateway \
241240 --network local-network_default \
242241 -p 7700:7700 \
243- -v " $( pwd) /local-network/contracts.json" :/opt/contracts.json:ro \
242+ -v " $( pwd) /local-network/tap-contracts.json" :/opt/tap-contracts.json:ro \
243+ -v " $( pwd) /local-network/subgraph-service.json" :/opt/subgraph-service.json:ro \
244244 -e RUST_LOG=info,graph_gateway=trace \
245245 -e ACCOUNT0_SECRET=" $ACCOUNT0_SECRET " \
246246 -e ACCOUNT0_ADDRESS=" $ACCOUNT0_ADDRESS " \
@@ -275,7 +275,7 @@ END_CONTAINERS_SIZE=$(docker system df --format '{{.ContainersSize}}' 2>/dev/nul
275275END_VOLUMES_SIZE=$( docker system df --format ' {{.VolumesSize}}' 2> /dev/null || echo " N/A" )
276276
277277echo " All services are now running!"
278- echo " You can enjoy your new local network setup for testing."
278+ echo " You can enjoy your new local network setup for testing with horizon upgrade ."
279279
280280echo " ============ FINAL DISK USAGE ============"
281281echo " Docker directory usage: $END_SPACE "
0 commit comments