3737GRAPH_TOKEN=$( get_contract_address " horizon.json" " L2GraphToken" )
3838TAP_ESCROW_V1=$( get_contract_address " tap-contracts.json" " TAPEscrow" )
3939PAYMENTS_ESCROW_V2=$( get_contract_address " horizon.json" " PaymentsEscrow" )
40+ GRAPH_TALLY_COLLECTOR_V2=$( get_contract_address " horizon.json" " GraphTallyCollector" )
4041
4142# Use environment variables from .env
4243SENDER_ADDRESS=" $ACCOUNT0_ADDRESS "
@@ -47,6 +48,7 @@ echo "============ FUNDING BOTH V1 AND V2 ESCROWS ============"
4748echo " L2GraphToken address: $GRAPH_TOKEN "
4849echo " TAPEscrow (v1) address: $TAP_ESCROW_V1 "
4950echo " PaymentsEscrow (v2) address: $PAYMENTS_ESCROW_V2 "
51+ echo " GraphTallyCollector (v2) address: $GRAPH_TALLY_COLLECTOR_V2 "
5052echo " Sender address: $SENDER_ADDRESS "
5153echo " Amount per escrow: $AMOUNT (10 GRT)"
5254echo " ======================================================"
@@ -149,12 +151,42 @@ docker exec chain cast send \
149151
150152# For V2, we also need to authorize the signer
151153echo " Authorizing signer for V2..."
152- # Try PaymentsEscrow for signer authorization
154+ # Create authorization proof: payer authorizes signer (same address in test)
155+ PROOF_DEADLINE=$(( $(date +% s) + 3600 )) # 1 hour from now
156+ echo " Creating authorization proof with deadline: $PROOF_DEADLINE "
157+
158+ # Create the message to sign according to _verifyAuthorizationProof
159+ # abi.encodePacked(chainId, contractAddress, "authorizeSignerProof", deadline, authorizer)
160+ CHAIN_ID_HEX=$( printf " %064x" 1337) # uint256: 32 bytes
161+ CONTRACT_HEX=${GRAPH_TALLY_COLLECTOR_V2: 2} # address: 20 bytes (remove 0x)
162+ DOMAIN_HEX=$( echo -n " authorizeSignerProof" | xxd -p) # string: no length prefix
163+ DEADLINE_HEX=$( printf " %064x" $PROOF_DEADLINE ) # uint256: 32 bytes
164+ AUTHORIZER_HEX=${SENDER_ADDRESS: 2} # address: 20 bytes (remove 0x)
165+
166+ MESSAGE_DATA=" ${CHAIN_ID_HEX}${CONTRACT_HEX}${DOMAIN_HEX}${DEADLINE_HEX}${AUTHORIZER_HEX} "
167+ MESSAGE_HASH=$( docker exec chain cast keccak " 0x$MESSAGE_DATA " )
168+
169+ # Sign the message with the signer's private key
170+ PROOF=$( docker exec chain cast wallet sign --private-key $SENDER_KEY " $MESSAGE_HASH " )
171+
172+ echo " Calling authorizeSigner with proof..."
153173docker exec chain cast send \
154174 --rpc-url http://localhost:8545 \
155175 --private-key $SENDER_KEY \
156176 --confirmations 1 \
157- $PAYMENTS_ESCROW_V2 " authorizeSigner(address)" $SENDER_ADDRESS || echo " Note: Signer authorization might use different method"
177+ $GRAPH_TALLY_COLLECTOR_V2 " authorizeSigner(address,uint256,bytes)" $SENDER_ADDRESS $PROOF_DEADLINE $PROOF 2> /dev/null || {
178+ echo " ⚠️ Signer authorization failed (likely already authorized)"
179+ echo " Checking if signer is already authorized..."
180+ IS_AUTHORIZED=$( docker exec chain cast call \
181+ --rpc-url http://localhost:8545 \
182+ $GRAPH_TALLY_COLLECTOR_V2 " isAuthorized(address,address)(bool)" $SENDER_ADDRESS $SENDER_ADDRESS )
183+ if [ " $IS_AUTHORIZED " = " true" ]; then
184+ echo " ✅ Signer is already authorized"
185+ else
186+ echo " ❌ Signer authorization failed for unknown reason"
187+ exit 1
188+ fi
189+ }
158190
159191# Deposit to V2 escrow with payer, collector, receiver
160192echo " Depositing to V2 escrow..."
0 commit comments