1
1
use alloy_primitives:: Address ;
2
2
use anyhow:: { anyhow, Context } ;
3
3
use gateway_common:: utils:: timestamp:: unix_timestamp;
4
- use gateway_framework:: errors:: { self , IndexerError } ;
4
+ use gateway_framework:: {
5
+ errors:: { self , IndexerError } ,
6
+ scalar:: ScalarReceipt ,
7
+ } ;
5
8
use ordered_float:: NotNan ;
6
9
use prost:: Message ;
7
10
use serde_json:: json;
@@ -25,14 +28,12 @@ pub struct IndexerRequest {
25
28
pub indexer : Address ,
26
29
pub url : String ,
27
30
pub deployment : DeploymentId ,
28
- pub allocation : Address ,
31
+ pub receipt : ScalarReceipt ,
29
32
pub subgraph_chain : String ,
30
33
pub result : Result < IndexerResponse , errors:: IndexerError > ,
31
34
pub response_time_ms : u16 ,
32
35
pub seconds_behind : u32 ,
33
36
pub blocks_behind : u64 , // TODO: rm
34
- pub legacy_scalar : bool ,
35
- pub fee : u128 ,
36
37
pub request : String ,
37
38
}
38
39
@@ -87,7 +88,7 @@ impl Reporter {
87
88
let total_fees_grt: f64 = client_request
88
89
. indexer_requests
89
90
. iter ( )
90
- . map ( |i| i. fee as f64 * 1e-18 )
91
+ . map ( |i| i. receipt . grt_value ( ) as f64 * 1e-18 )
91
92
. sum ( ) ;
92
93
let total_fees_usd: f64 = total_fees_grt / * client_request. grt_per_usd ;
93
94
@@ -198,7 +199,7 @@ impl Reporter {
198
199
"api_key" : & client_request. api_key,
199
200
"fee" : total_fees_grt as f32 ,
200
201
"response_time_ms" : indexer_request. response_time_ms,
201
- "allocation" : & indexer_request. allocation,
202
+ "allocation" : & indexer_request. receipt . allocation( ) ,
202
203
"indexer_errors" : indexer_errors,
203
204
"status" : indexer_request. result. as_ref( ) . map( |_| "200 OK" . into( ) ) . unwrap_or_else( |err| err. to_string( ) ) ,
204
205
"status_code" : legacy_status_code,
@@ -218,12 +219,12 @@ impl Reporter {
218
219
"network" : & indexer_request. subgraph_chain,
219
220
"indexer" : & indexer_request. indexer,
220
221
"url" : & indexer_request. url,
221
- "fee" : ( indexer_request. fee as f64 * 1e-18 ) as f32 ,
222
- "legacy_scalar" : indexer_request. legacy_scalar ,
222
+ "fee" : ( indexer_request. receipt . grt_value ( ) as f64 * 1e-18 ) as f32 ,
223
+ "legacy_scalar" : matches! ( & indexer_request. receipt , ScalarReceipt :: Legacy ( _ , _ ) ) ,
223
224
"utility" : 1.0 ,
224
225
"blocks_behind" : indexer_request. blocks_behind,
225
226
"response_time_ms" : indexer_request. response_time_ms,
226
- "allocation" : & indexer_request. allocation,
227
+ "allocation" : & indexer_request. receipt . allocation( ) ,
227
228
"indexer_errors" : indexer_errors,
228
229
"status" : indexer_request. result. as_ref( ) . map( |_| "200 OK" . into( ) ) . unwrap_or_else( |err| err. to_string( ) ) ,
229
230
"status_code" : legacy_status_code,
@@ -250,7 +251,7 @@ impl Reporter {
250
251
AttestationProtobuf {
251
252
request : Some ( indexer_request. request ) . filter ( |r| r. len ( ) <= MAX_PAYLOAD_BYTES ) ,
252
253
response : Some ( original_response) . filter ( |r| r. len ( ) <= MAX_PAYLOAD_BYTES ) ,
253
- allocation : indexer_request. allocation . 0 . 0 . into ( ) ,
254
+ allocation : indexer_request. receipt . allocation ( ) . 0 . 0 . into ( ) ,
254
255
subgraph_deployment : attestation. deployment . 0 . into ( ) ,
255
256
request_cid : attestation. request_cid . 0 . into ( ) ,
256
257
response_cid : attestation. response_cid . 0 . into ( ) ,
0 commit comments