@@ -47,16 +47,29 @@ PAYMENTS_ESCROW_V2=$(get_contract_address "../contrib/local-network/horizon.json
4747GRAPH_TALLY_COLLECTOR_V2=$( get_contract_address " ../contrib/local-network/horizon.json" " GraphTallyCollector" )
4848
4949# Use environment variables from .env
50+ # Payer is ACCOUNT0 (sender), signer is ACCOUNT1, receiver is the indexer
5051SENDER_ADDRESS=" $ACCOUNT0_ADDRESS "
5152SENDER_KEY=" $ACCOUNT0_SECRET "
52- AMOUNT=" 10000000000000000000" # 10 GRT per escrow
53+ RECEIVER_ADDRESS=" $RECEIVER_ADDRESS "
54+ AMOUNT=" 10000000000000000000" # 10 GRT per escrow
55+
56+ # Gateway signer info (for authorization)
57+ # V1: Use ACCOUNT1 (ACCOUNT0 already authorized for itself)
58+ # V2: Use ACCOUNT0 (as originally configured)
59+ V1_GATEWAY_SIGNER_ADDRESS=" $ACCOUNT1_ADDRESS "
60+ V1_GATEWAY_SIGNER_KEY=" $ACCOUNT1_SECRET "
61+ V2_GATEWAY_SIGNER_ADDRESS=" $ACCOUNT1_ADDRESS "
62+ V2_GATEWAY_SIGNER_KEY=" $ACCOUNT1_SECRET "
5363
5464echo " ============ FUNDING BOTH V1 AND V2 ESCROWS ============"
5565echo " L2GraphToken address: $GRAPH_TOKEN "
5666echo " TAPEscrow (v1) address: $TAP_ESCROW_V1 "
5767echo " PaymentsEscrow (v2) address: $PAYMENTS_ESCROW_V2 "
5868echo " GraphTallyCollector (v2) address: $GRAPH_TALLY_COLLECTOR_V2 "
5969echo " Sender address: $SENDER_ADDRESS "
70+ echo " Receiver address (indexer): $RECEIVER_ADDRESS "
71+ echo " V1 Signer address: $V1_GATEWAY_SIGNER_ADDRESS "
72+ echo " V2 Signer address: $V2_GATEWAY_SIGNER_ADDRESS "
6073echo " Amount per escrow: $AMOUNT (10 GRT)"
6174echo " ======================================================"
6275
8699echo " "
87100echo " ========== FUNDING V1 ESCROW =========="
88101
102+ # Transfer GRT from ACCOUNT0 to indexer for V1 escrow funding
103+ # # With payer set to ACCOUNT0, no transfer is needed here
104+
89105# Check current escrow balance before funding
106+ # Note: V1 TAP escrow 2-arg deposit creates sender->sender accounts
90107echo " Checking current V1 escrow balance..."
91108CURRENT_BALANCE_V1=$( docker exec chain cast call \
92109 --rpc-url http://localhost:8545 \
@@ -101,15 +118,72 @@ docker exec chain cast send \
101118 --confirmations 1 \
102119 $GRAPH_TOKEN " approve(address,uint256)" $TAP_ESCROW_V1 $AMOUNT
103120
104- # Deposit to V1 escrow
121+ # Deposit to V1 escrow - V1 uses 2-argument deposit (sender only)
105122echo " Depositing to V1 escrow..."
106123docker exec chain cast send \
107124 --rpc-url http://localhost:8545 \
108125 --private-key $SENDER_KEY \
109126 --confirmations 1 \
110127 $TAP_ESCROW_V1 " deposit(address,uint256)" $SENDER_ADDRESS $AMOUNT
111128
129+ # Authorize signer for V1 escrow
130+ echo " Authorizing signer for V1 escrow..."
131+ # V1 TAP Escrow uses: authorizeSigner(address signer, uint256 proofDeadline, bytes calldata proof)
132+ # The proof must be signed by the signer and contains (chainId, proofDeadline, sender)
133+ # Gateway uses ACCOUNT1 as V1 signer (ACCOUNT0 already authorized for its own escrow)
134+ V1_SIGNER_ADDRESS=" $V1_GATEWAY_SIGNER_ADDRESS "
135+ V1_SIGNER_KEY=" $V1_GATEWAY_SIGNER_KEY "
136+ echo " Authorizing V1 signer: $V1_SIGNER_ADDRESS to sign for payer: $SENDER_ADDRESS "
137+
138+ # Create proof deadline (1 hour from now)
139+ PROOF_DEADLINE=$(( $(date +% s) + 3600 ))
140+ echo " Creating V1 authorization proof with deadline: $PROOF_DEADLINE "
141+
142+ # Create the message to sign: keccak256(abi.encodePacked(chainId, proofDeadline, sender))
143+ CHAIN_ID_HEX=$( printf " %064x" 1337) # uint256: 32 bytes
144+ DEADLINE_HEX=$( printf " %064x" $PROOF_DEADLINE ) # uint256: 32 bytes
145+ SENDER_HEX=${SENDER_ADDRESS: 2} # address: 20 bytes (no padding in encodePacked)
146+
147+ MESSAGE_DATA=" ${CHAIN_ID_HEX}${DEADLINE_HEX}${SENDER_HEX} "
148+ MESSAGE_HASH=$( docker exec chain cast keccak " 0x$MESSAGE_DATA " )
149+
150+ # Sign the message with the signer key (ACCOUNT1)
151+ PROOF=$( docker exec chain cast wallet sign --private-key $V1_SIGNER_KEY " $MESSAGE_HASH " )
152+
153+ echo " Calling V1 authorizeSigner with proof..."
154+ docker exec chain cast send \
155+ --rpc-url http://localhost:8545 \
156+ --private-key $SENDER_KEY \
157+ --confirmations 1 \
158+ $TAP_ESCROW_V1 " authorizeSigner(address,uint256,bytes)" $V1_SIGNER_ADDRESS $PROOF_DEADLINE $PROOF 2> /dev/null || {
159+ echo " ⚠️ V1 signer authorization failed. Checking if already authorized..."
160+ # Check current authorization state
161+ V1_AUTH_STATE=$( docker exec chain cast call \
162+ --rpc-url http://localhost:8545 \
163+ $TAP_ESCROW_V1 " authorizedSigners(address)(address,uint256)" $V1_SIGNER_ADDRESS 2> /dev/null || echo " error" )
164+ echo " Current V1 authorization state for signer: $V1_AUTH_STATE "
165+ }
166+
167+ # Verify V1 signer authorization using the correct mapping
168+ echo " Verifying V1 signer authorization..."
169+ V1_SENDER_ADDRESS=$( docker exec chain cast call \
170+ --rpc-url http://localhost:8545 \
171+ $TAP_ESCROW_V1 " authorizedSigners(address)(address,uint256)" $V1_SIGNER_ADDRESS 2> /dev/null | head -n 1 | tr -d ' \n' || echo " error" )
172+
173+ if [ " $V1_SENDER_ADDRESS " = " $SENDER_ADDRESS " ]; then
174+ echo " ✅ V1 signer authorization successful!"
175+ echo " Payer: $SENDER_ADDRESS "
176+ echo " Signer: $V1_SIGNER_ADDRESS "
177+ echo " Authorization confirmed on-chain"
178+ else
179+ echo " ⚠️ V1 signer authorization verification failed"
180+ echo " Expected sender: $SENDER_ADDRESS "
181+ echo " Returned sender: $V1_SENDER_ADDRESS "
182+ echo " This may cause V1 receipt validation to fail with '402 No sender found for signer' errors."
183+ fi
184+
112185# Verify V1 deposit
186+ # Note: V1 TAP escrow 2-arg deposit creates sender->sender accounts
113187echo " Verifying V1 deposit..."
114188ESCROW_BALANCE_V1=$( docker exec chain cast call \
115189 --rpc-url http://localhost:8545 \
@@ -149,7 +223,7 @@ for ALLOCATION_ID in $ALL_ALLOCATION_IDS; do
149223 # Payer is the test account, collector is the allocation ID, receiver is the indexer
150224 PAYER=$SENDER_ADDRESS
151225 COLLECTOR=$ALLOCATION_ID
152- RECEIVER=" 0xf4EF6650E48d099a4972ea5B414daB86e1998Bd3 " # This must be the indexer address
226+ RECEIVER=" $RECEIVER_ADDRESS " # Indexer address from env
153227
154228 # Check current V2 escrow balance before funding
155229 echo " Checking current V2 escrow balance..."
@@ -161,6 +235,8 @@ for ALLOCATION_ID in $ALL_ALLOCATION_IDS; do
161235 CURRENT_BALANCE_V2=" 0"
162236 echo " Current V2 escrow balance: $CURRENT_BALANCE_V2 (assuming 0 for new escrow)"
163237
238+ # # With payer set to ACCOUNT0, no transfer is needed here
239+
164240 # Approve GRT for V2 escrow
165241 echo " Approving GRT for V2 escrow..."
166242 docker exec chain cast send \
@@ -171,35 +247,35 @@ for ALLOCATION_ID in $ALL_ALLOCATION_IDS; do
171247
172248 # For V2, we also need to authorize the signer
173249 echo " Authorizing signer for V2..."
174- # Create authorization proof: payer authorizes signer (same address in test )
175- PROOF_DEADLINE =$(( $(date +% s) + 3600 )) # 1 hour from now
176- echo " Creating authorization proof with deadline: $PROOF_DEADLINE "
250+ # Create authorization proof: payer authorizes signer (V2 uses ACCOUNT0 as originally configured )
251+ V2_PROOF_DEADLINE =$(( $(date +% s) + 3600 )) # 1 hour from now
252+ echo " Creating V2 authorization proof with deadline: $V2_PROOF_DEADLINE "
177253
178254 # Create the message to sign according to _verifyAuthorizationProof
179255 # abi.encodePacked(chainId, contractAddress, "authorizeSignerProof", deadline, authorizer)
180256 CHAIN_ID_HEX=$( printf " %064x" 1337) # uint256: 32 bytes
181257 CONTRACT_HEX=${GRAPH_TALLY_COLLECTOR_V2: 2} # address: 20 bytes (remove 0x)
182258 DOMAIN_HEX=$( echo -n " authorizeSignerProof" | xxd -p) # string: no length prefix
183- DEADLINE_HEX=$( printf " %064x" $PROOF_DEADLINE ) # uint256: 32 bytes
259+ DEADLINE_HEX=$( printf " %064x" $V2_PROOF_DEADLINE ) # uint256: 32 bytes
184260 AUTHORIZER_HEX=${SENDER_ADDRESS: 2} # address: 20 bytes (remove 0x)
185261
186262 MESSAGE_DATA=" ${CHAIN_ID_HEX}${CONTRACT_HEX}${DOMAIN_HEX}${DEADLINE_HEX}${AUTHORIZER_HEX} "
187263 MESSAGE_HASH=$( docker exec chain cast keccak " 0x$MESSAGE_DATA " )
188264
189- # Sign the message with the signer 's private key
265+ # Sign the message with the payer 's private key (ACCOUNT0)
190266 PROOF=$( docker exec chain cast wallet sign --private-key $SENDER_KEY " $MESSAGE_HASH " )
191267
192- echo " Calling authorizeSigner with proof..."
268+ echo " Calling V2 authorizeSigner with proof..."
193269 docker exec chain cast send \
194270 --rpc-url http://localhost:8545 \
195- --private-key $SENDER_KEY \
271+ --private-key $V2_GATEWAY_SIGNER_KEY \
196272 --confirmations 1 \
197- $GRAPH_TALLY_COLLECTOR_V2 " authorizeSigner(address,uint256,bytes)" $SENDER_ADDRESS $PROOF_DEADLINE $PROOF 2> /dev/null || {
273+ $GRAPH_TALLY_COLLECTOR_V2 " authorizeSigner(address,uint256,bytes)" $SENDER_ADDRESS $V2_PROOF_DEADLINE $PROOF 2> /dev/null || {
198274 echo " ⚠️ Signer authorization failed (likely already authorized)"
199275 echo " Checking if signer is already authorized..."
200276 IS_AUTHORIZED=$( docker exec chain cast call \
201277 --rpc-url http://localhost:8545 \
202- $GRAPH_TALLY_COLLECTOR_V2 " isAuthorized(address,address)(bool)" $SENDER_ADDRESS $SENDER_ADDRESS )
278+ $GRAPH_TALLY_COLLECTOR_V2 " isAuthorized(address,address)(bool)" $SENDER_ADDRESS $V2_GATEWAY_SIGNER_ADDRESS )
203279 if [ " $IS_AUTHORIZED " = " true" ]; then
204280 echo " ✅ Signer is already authorized"
205281 else
0 commit comments