@@ -10,14 +10,10 @@ use thegraph_core::alloy::{primitives::Address, signers::local::PrivateKeySigner
10
10
11
11
use crate :: {
12
12
constants:: {
13
- ACCOUNT0_SECRET , CHAIN_ID , GATEWAY_API_KEY , GATEWAY_URL , GRAPH_TALLY_COLLECTOR_CONTRACT ,
14
- GRAPH_URL , INDEXER_URL , MAX_RECEIPT_VALUE , SUBGRAPH_ID , TAP_AGENT_METRICS_URL ,
15
- TAP_VERIFIER_CONTRACT ,
16
- } ,
17
- utils:: {
18
- create_request, create_tap_receipt, create_tap_receipt_v2, encode_v2_receipt,
19
- find_allocation,
13
+ ACCOUNT0_SECRET , CHAIN_ID , GATEWAY_API_KEY , GATEWAY_URL , GRAPH_URL , MAX_RECEIPT_VALUE ,
14
+ SUBGRAPH_ID , TAP_AGENT_METRICS_URL , TAP_VERIFIER_CONTRACT ,
20
15
} ,
16
+ utils:: { create_request_with_api_key, create_tap_receipt, find_allocation} ,
21
17
MetricsChecker ,
22
18
} ;
23
19
@@ -68,7 +64,7 @@ pub async fn test_tap_rav_v1() -> Result<()> {
68
64
69
65
for i in 0 ..NUM_RECEIPTS {
70
66
let response = http_client
71
- . post ( format ! ( "{GATEWAY_URL}/api/subgraphs /id/{SUBGRAPH_ID}" ) )
67
+ . post ( format ! ( "{GATEWAY_URL}/api/deployments /id/{SUBGRAPH_ID}" ) )
72
68
. header ( "Content-Type" , "application/json" )
73
69
. header ( "Authorization" , format ! ( "Bearer {GATEWAY_API_KEY}" ) )
74
70
. json ( & json ! ( {
@@ -115,7 +111,7 @@ pub async fn test_tap_rav_v1() -> Result<()> {
115
111
println ! ( "Sending trigger query {}/{}..." , i + 1 , MAX_TRIGGERS ) ;
116
112
117
113
let response = http_client
118
- . post ( format ! ( "{GATEWAY_URL}/api/subgraphs /id/{SUBGRAPH_ID}" ) )
114
+ . post ( format ! ( "{GATEWAY_URL}/api/deployments /id/{SUBGRAPH_ID}" ) )
119
115
. header ( "Content-Type" , "application/json" )
120
116
. header ( "Authorization" , format ! ( "Bearer {GATEWAY_API_KEY}" ) )
121
117
. json ( & json ! ( {
@@ -194,13 +190,14 @@ pub async fn test_invalid_chain_id() -> Result<()> {
194
190
) ?;
195
191
196
192
let receipt_json = serde_json:: to_string ( & receipt) . unwrap ( ) ;
197
- let response = create_request (
193
+ let response = create_request_with_api_key (
198
194
& http_client,
199
- format ! ( "{INDEXER_URL}/subgraphs /id/{SUBGRAPH_ID}" ) . as_str ( ) ,
195
+ format ! ( "{GATEWAY_URL}/api/deployments /id/{SUBGRAPH_ID}" ) . as_str ( ) ,
200
196
& receipt_json,
201
197
& json ! ( {
202
198
"query" : "{ _meta { block { number } } }"
203
199
} ) ,
200
+ GATEWAY_API_KEY ,
204
201
)
205
202
. send ( )
206
203
. await ?;
@@ -217,16 +214,11 @@ pub async fn test_invalid_chain_id() -> Result<()> {
217
214
pub async fn test_tap_rav_v2 ( ) -> Result < ( ) > {
218
215
// Setup HTTP client
219
216
let http_client = Arc :: new ( Client :: new ( ) ) ;
220
- let wallet: PrivateKeySigner = ACCOUNT0_SECRET . parse ( ) . unwrap ( ) ;
221
217
222
218
// Query the network subgraph to find active allocations
223
219
let allocation_id = find_allocation ( http_client. clone ( ) , GRAPH_URL ) . await ?;
224
220
let allocation_id = Address :: from_str ( & allocation_id) ?;
225
221
226
- // For V2, we need payer and service provider addresses
227
- let payer = wallet. address ( ) ;
228
- let service_provider = allocation_id; // Using allocation_id as service provider for simplicity
229
-
230
222
// Create a metrics checker
231
223
let metrics_checker =
232
224
MetricsChecker :: new ( http_client. clone ( ) , TAP_AGENT_METRICS_URL . to_string ( ) ) ;
@@ -261,24 +253,11 @@ pub async fn test_tap_rav_v2() -> Result<()> {
261
253
println ! ( "Sending V2 batch {batch} of {BATCHES} with {NUM_RECEIPTS} receipts each..." , ) ;
262
254
263
255
for i in 0 ..NUM_RECEIPTS {
264
- // Create V2 receipt
265
- let receipt = create_tap_receipt_v2 (
266
- MAX_RECEIPT_VALUE ,
267
- & allocation_id,
268
- GRAPH_TALLY_COLLECTOR_CONTRACT ,
269
- CHAIN_ID ,
270
- & wallet,
271
- & payer,
272
- & service_provider,
273
- ) ?;
274
-
275
- let receipt_encoded = encode_v2_receipt ( & receipt) ?;
276
-
256
+ // Send plain GraphQL query to gateway - let gateway generate V2 receipt
277
257
let response = http_client
278
- . post ( format ! ( "{GATEWAY_URL}/api/subgraphs /id/{SUBGRAPH_ID}" ) )
258
+ . post ( format ! ( "{GATEWAY_URL}/api/deployments /id/{SUBGRAPH_ID}" ) )
279
259
. header ( "Content-Type" , "application/json" )
280
260
. header ( "Authorization" , format ! ( "Bearer {GATEWAY_API_KEY}" ) )
281
- . header ( "Tap-Receipt" , receipt_encoded)
282
261
. json ( & json ! ( {
283
262
"query" : "{ _meta { block { number } } }"
284
263
} ) )
@@ -333,24 +312,11 @@ pub async fn test_tap_rav_v2() -> Result<()> {
333
312
for i in 0 ..MAX_TRIGGERS {
334
313
println ! ( "Sending V2 trigger query {}/{}..." , i + 1 , MAX_TRIGGERS ) ;
335
314
336
- // Create V2 receipt
337
- let receipt = create_tap_receipt_v2 (
338
- MAX_RECEIPT_VALUE / 10 , // Smaller value for trigger receipts
339
- & allocation_id,
340
- GRAPH_TALLY_COLLECTOR_CONTRACT ,
341
- CHAIN_ID ,
342
- & wallet,
343
- & payer,
344
- & service_provider,
345
- ) ?;
346
-
347
- let receipt_encoded = encode_v2_receipt ( & receipt) ?;
348
-
315
+ // Send plain GraphQL query to gateway - let gateway generate V2 receipt
349
316
let response = http_client
350
- . post ( format ! ( "{GATEWAY_URL}/api/subgraphs /id/{SUBGRAPH_ID}" ) )
317
+ . post ( format ! ( "{GATEWAY_URL}/api/deployments /id/{SUBGRAPH_ID}" ) )
351
318
. header ( "Content-Type" , "application/json" )
352
319
. header ( "Authorization" , format ! ( "Bearer {GATEWAY_API_KEY}" ) )
353
- . header ( "Tap-Receipt" , receipt_encoded)
354
320
. json ( & json ! ( {
355
321
"query" : "{ _meta { block { number } } }"
356
322
} ) )
0 commit comments