|
42 | 42 |
|
43 | 43 | # Get contract addresses - Updated paths to local-network directory |
44 | 44 | GRAPH_TOKEN=$(get_contract_address "../contrib/local-network/horizon.json" "L2GraphToken") |
45 | | -TAP_ESCROW_V1=$(get_contract_address "../contrib/local-network/tap-contracts.json" "TAPEscrow") |
| 45 | +TAP_ESCROW_V1=$(get_contract_address "../contrib/local-network/tap-contracts.json" "Escrow") |
46 | 46 | PAYMENTS_ESCROW_V2=$(get_contract_address "../contrib/local-network/horizon.json" "PaymentsEscrow") |
47 | 47 | GRAPH_TALLY_COLLECTOR_V2=$(get_contract_address "../contrib/local-network/horizon.json" "GraphTallyCollector") |
48 | 48 |
|
@@ -138,100 +138,99 @@ ALLOCATION_QUERY_RESULT=$(curl -s -X POST http://localhost:8000/subgraphs/name/g |
138 | 138 | -H "Content-Type: application/json" \ |
139 | 139 | -d '{"query": "{ allocations(where: { status: Active }) { id indexer { id } subgraphDeployment { id } } }"}') |
140 | 140 |
|
141 | | -# Extract allocation ID from the JSON response |
142 | | -CURRENT_ALLOCATION_ID=$(echo "$ALLOCATION_QUERY_RESULT" | jq -r '.data.allocations[0].id') |
143 | | - |
144 | | -if [ "$CURRENT_ALLOCATION_ID" == "null" ] || [ -z "$CURRENT_ALLOCATION_ID" ]; then |
145 | | - echo "❌ Failed to find current allocation ID from network subgraph" |
146 | | - echo "Response: $ALLOCATION_QUERY_RESULT" |
147 | | - exit 1 |
148 | | -fi |
149 | | - |
150 | | -echo "✅ Found current allocation ID: $CURRENT_ALLOCATION_ID" |
151 | | - |
152 | | -# For V2, we need to specify payer, collector, and receiver |
153 | | -# Payer is the test account, collector is the allocation ID, receiver is the indexer |
154 | | -PAYER=$SENDER_ADDRESS |
155 | | -COLLECTOR=$CURRENT_ALLOCATION_ID |
156 | | -RECEIVER="0xf4EF6650E48d099a4972ea5B414daB86e1998Bd3" # This must be the indexer address |
157 | | - |
158 | | -# Check current V2 escrow balance before funding |
159 | | -echo "Checking current V2 escrow balance..." |
160 | | -echo " Payer: $PAYER" |
161 | | -echo " Collector: $COLLECTOR" |
162 | | -echo " Receiver: $RECEIVER" |
163 | | - |
164 | | -# Try to get balance - V2 might use a different function name |
165 | | -CURRENT_BALANCE_V2="0" |
166 | | -echo "Current V2 escrow balance: $CURRENT_BALANCE_V2 (assuming 0 for new escrow)" |
167 | | - |
168 | | -# Approve GRT for V2 escrow |
169 | | -echo "Approving GRT for V2 escrow..." |
170 | | -docker exec chain cast send \ |
171 | | - --rpc-url http://localhost:8545 \ |
172 | | - --private-key $SENDER_KEY \ |
173 | | - --confirmations 1 \ |
174 | | - $GRAPH_TOKEN "approve(address,uint256)" $PAYMENTS_ESCROW_V2 $AMOUNT |
175 | | - |
176 | | -# For V2, we also need to authorize the signer |
177 | | -echo "Authorizing signer for V2..." |
178 | | -# Create authorization proof: payer authorizes signer (same address in test) |
179 | | -PROOF_DEADLINE=$(($(date +%s) + 3600)) # 1 hour from now |
180 | | -echo "Creating authorization proof with deadline: $PROOF_DEADLINE" |
181 | | - |
182 | | -# Create the message to sign according to _verifyAuthorizationProof |
183 | | -# abi.encodePacked(chainId, contractAddress, "authorizeSignerProof", deadline, authorizer) |
184 | | -CHAIN_ID_HEX=$(printf "%064x" 1337) # uint256: 32 bytes |
185 | | -CONTRACT_HEX=${GRAPH_TALLY_COLLECTOR_V2:2} # address: 20 bytes (remove 0x) |
186 | | -DOMAIN_HEX=$(echo -n "authorizeSignerProof" | xxd -p) # string: no length prefix |
187 | | -DEADLINE_HEX=$(printf "%064x" $PROOF_DEADLINE) # uint256: 32 bytes |
188 | | -AUTHORIZER_HEX=${SENDER_ADDRESS:2} # address: 20 bytes (remove 0x) |
189 | | - |
190 | | -MESSAGE_DATA="${CHAIN_ID_HEX}${CONTRACT_HEX}${DOMAIN_HEX}${DEADLINE_HEX}${AUTHORIZER_HEX}" |
191 | | -MESSAGE_HASH=$(docker exec chain cast keccak "0x$MESSAGE_DATA") |
192 | | - |
193 | | -# Sign the message with the signer's private key |
194 | | -PROOF=$(docker exec chain cast wallet sign --private-key $SENDER_KEY "$MESSAGE_HASH") |
195 | | - |
196 | | -echo "Calling authorizeSigner with proof..." |
197 | | -docker exec chain cast send \ |
198 | | - --rpc-url http://localhost:8545 \ |
199 | | - --private-key $SENDER_KEY \ |
200 | | - --confirmations 1 \ |
201 | | - $GRAPH_TALLY_COLLECTOR_V2 "authorizeSigner(address,uint256,bytes)" $SENDER_ADDRESS $PROOF_DEADLINE $PROOF 2>/dev/null || { |
202 | | - echo "⚠️ Signer authorization failed (likely already authorized)" |
203 | | - echo "Checking if signer is already authorized..." |
204 | | - IS_AUTHORIZED=$(docker exec chain cast call \ |
| 141 | +# Extract all allocation IDs |
| 142 | +ALL_ALLOCATION_IDS=$(echo "$ALLOCATION_QUERY_RESULT" | jq -r '.data.allocations[].id') |
| 143 | + |
| 144 | +# Loop through each allocation and fund it |
| 145 | +for ALLOCATION_ID in $ALL_ALLOCATION_IDS; do |
| 146 | + # echo "Funding allocation: $ALLOCATION_ID" |
| 147 | + echo "✅ Funding allocation ID: $ALLOCATION_ID" |
| 148 | + # For V2, we need to specify payer, collector, and receiver |
| 149 | + # Payer is the test account, collector is the allocation ID, receiver is the indexer |
| 150 | + PAYER=$SENDER_ADDRESS |
| 151 | + COLLECTOR=$ALLOCATION_ID |
| 152 | + RECEIVER="0xf4EF6650E48d099a4972ea5B414daB86e1998Bd3" # This must be the indexer address |
| 153 | + |
| 154 | + # Check current V2 escrow balance before funding |
| 155 | + echo "Checking current V2 escrow balance..." |
| 156 | + echo " Payer: $PAYER" |
| 157 | + echo " Collector: $COLLECTOR" |
| 158 | + echo " Receiver: $RECEIVER" |
| 159 | + |
| 160 | + # Try to get balance - V2 might use a different function name |
| 161 | + CURRENT_BALANCE_V2="0" |
| 162 | + echo "Current V2 escrow balance: $CURRENT_BALANCE_V2 (assuming 0 for new escrow)" |
| 163 | + |
| 164 | + # Approve GRT for V2 escrow |
| 165 | + echo "Approving GRT for V2 escrow..." |
| 166 | + docker exec chain cast send \ |
205 | 167 | --rpc-url http://localhost:8545 \ |
206 | | - $GRAPH_TALLY_COLLECTOR_V2 "isAuthorized(address,address)(bool)" $SENDER_ADDRESS $SENDER_ADDRESS) |
207 | | - if [ "$IS_AUTHORIZED" = "true" ]; then |
208 | | - echo "✅ Signer is already authorized" |
209 | | - else |
210 | | - echo "❌ Signer authorization failed for unknown reason" |
211 | | - exit 1 |
212 | | - fi |
213 | | -} |
214 | | - |
215 | | -# Deposit to V2 escrow with payer, collector, receiver |
216 | | -echo "Depositing to V2 escrow..." |
217 | | -docker exec chain cast send \ |
218 | | - --rpc-url http://localhost:8545 \ |
219 | | - --private-key $SENDER_KEY \ |
220 | | - --confirmations 1 \ |
221 | | - $PAYMENTS_ESCROW_V2 "deposit(address,address,uint256)" $COLLECTOR $RECEIVER $AMOUNT |
222 | | - |
223 | | -# Note: We'll check via the subgraph instead of direct contract call |
224 | | -echo "Deposit transaction completed." |
225 | | -ESCROW_BALANCE_V2="(check via subgraph)" |
226 | | - |
227 | | -# Since we can't easily check balance via contract call, we'll verify via transaction success |
228 | | -echo "✅ V2 escrow deposit transaction completed!" |
229 | | -echo " Payer: $PAYER" |
230 | | -echo " Collector: $COLLECTOR" |
231 | | -echo " Receiver: $RECEIVER" |
232 | | -echo " Amount: $AMOUNT" |
233 | | -echo "" |
234 | | -echo "Note: V2 escrow balance can be verified via the TAP V2 subgraph" |
235 | | - |
236 | | -echo "" |
237 | | -echo "✅ Successfully funded both V1 and V2 escrows!" |
| 168 | + --private-key $SENDER_KEY \ |
| 169 | + --confirmations 1 \ |
| 170 | + $GRAPH_TOKEN "approve(address,uint256)" $PAYMENTS_ESCROW_V2 $AMOUNT |
| 171 | + |
| 172 | + # For V2, we also need to authorize the signer |
| 173 | + 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" |
| 177 | + |
| 178 | + # Create the message to sign according to _verifyAuthorizationProof |
| 179 | + # abi.encodePacked(chainId, contractAddress, "authorizeSignerProof", deadline, authorizer) |
| 180 | + CHAIN_ID_HEX=$(printf "%064x" 1337) # uint256: 32 bytes |
| 181 | + CONTRACT_HEX=${GRAPH_TALLY_COLLECTOR_V2:2} # address: 20 bytes (remove 0x) |
| 182 | + DOMAIN_HEX=$(echo -n "authorizeSignerProof" | xxd -p) # string: no length prefix |
| 183 | + DEADLINE_HEX=$(printf "%064x" $PROOF_DEADLINE) # uint256: 32 bytes |
| 184 | + AUTHORIZER_HEX=${SENDER_ADDRESS:2} # address: 20 bytes (remove 0x) |
| 185 | + |
| 186 | + MESSAGE_DATA="${CHAIN_ID_HEX}${CONTRACT_HEX}${DOMAIN_HEX}${DEADLINE_HEX}${AUTHORIZER_HEX}" |
| 187 | + MESSAGE_HASH=$(docker exec chain cast keccak "0x$MESSAGE_DATA") |
| 188 | + |
| 189 | + # Sign the message with the signer's private key |
| 190 | + PROOF=$(docker exec chain cast wallet sign --private-key $SENDER_KEY "$MESSAGE_HASH") |
| 191 | + |
| 192 | + echo "Calling authorizeSigner with proof..." |
| 193 | + docker exec chain cast send \ |
| 194 | + --rpc-url http://localhost:8545 \ |
| 195 | + --private-key $SENDER_KEY \ |
| 196 | + --confirmations 1 \ |
| 197 | + $GRAPH_TALLY_COLLECTOR_V2 "authorizeSigner(address,uint256,bytes)" $SENDER_ADDRESS $PROOF_DEADLINE $PROOF 2>/dev/null || { |
| 198 | + echo "⚠️ Signer authorization failed (likely already authorized)" |
| 199 | + echo "Checking if signer is already authorized..." |
| 200 | + IS_AUTHORIZED=$(docker exec chain cast call \ |
| 201 | + --rpc-url http://localhost:8545 \ |
| 202 | + $GRAPH_TALLY_COLLECTOR_V2 "isAuthorized(address,address)(bool)" $SENDER_ADDRESS $SENDER_ADDRESS) |
| 203 | + if [ "$IS_AUTHORIZED" = "true" ]; then |
| 204 | + echo "✅ Signer is already authorized" |
| 205 | + else |
| 206 | + echo "❌ Signer authorization failed for unknown reason" |
| 207 | + exit 1 |
| 208 | + fi |
| 209 | + } |
| 210 | + |
| 211 | + # Deposit to V2 escrow with payer, collector, receiver |
| 212 | + echo "Depositing to V2 escrow..." |
| 213 | + docker exec chain cast send \ |
| 214 | + --rpc-url http://localhost:8545 \ |
| 215 | + --private-key $SENDER_KEY \ |
| 216 | + --confirmations 1 \ |
| 217 | + $PAYMENTS_ESCROW_V2 "deposit(address,address,uint256)" $COLLECTOR $RECEIVER $AMOUNT |
| 218 | + |
| 219 | + # Note: We'll check via the subgraph instead of direct contract call |
| 220 | + echo "Deposit transaction completed." |
| 221 | + ESCROW_BALANCE_V2="(check via subgraph)" |
| 222 | + |
| 223 | + # Since we can't easily check balance via contract call, we'll verify via transaction success |
| 224 | + echo "✅ V2 escrow deposit transaction completed!" |
| 225 | + echo " Payer: $PAYER" |
| 226 | + echo " Collector: $COLLECTOR" |
| 227 | + echo " Receiver: $RECEIVER" |
| 228 | + echo " Amount: $AMOUNT" |
| 229 | + echo "" |
| 230 | + echo "Note: V2 escrow balance can be verified via the TAP V2 subgraph" |
| 231 | + |
| 232 | + echo "" |
| 233 | + echo "✅ Successfully funded both V1 and V2 escrows!" |
| 234 | +done |
| 235 | + |
| 236 | +echo "✅ Done funding escrows." |
0 commit comments