Skip to content

Commit 02dc7f2

Browse files
committed
feat: send query request to value check
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent ee51bb6 commit 02dc7f2

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

common/src/indexer_service/http/request_handler.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ use axum::{
1111
};
1212
use axum_extra::TypedHeader;
1313
use reqwest::StatusCode;
14+
use serde_json::value::RawValue;
1415
use thegraph::types::DeploymentId;
1516
use tracing::trace;
1617

17-
use crate::{indexer_service::http::IndexerServiceResponse, prelude::AttestationSigner};
18+
use crate::{
19+
indexer_service::http::IndexerServiceResponse, prelude::AttestationSigner, tap::AgoraQuery,
20+
};
1821

1922
use super::{
2023
indexer_service::{IndexerServiceError, IndexerServiceState},
@@ -41,16 +44,40 @@ where
4144
.with_label_values(&[&manifest_id.to_string()])
4245
.inc();
4346

47+
#[derive(Debug, serde::Deserialize)]
48+
pub struct QueryBody {
49+
pub query: String,
50+
pub variables: Option<Box<RawValue>>,
51+
}
52+
4453
let request =
4554
serde_json::from_slice(&body).map_err(|e| IndexerServiceError::InvalidRequest(e.into()))?;
4655

4756
let mut attestation_signer: Option<AttestationSigner> = None;
4857

4958
if let Some(receipt) = receipt.into_signed_receipt() {
5059
let allocation_id = receipt.message.allocation_id;
60+
let signature = receipt.signature;
61+
62+
let request: QueryBody = serde_json::from_slice(&body)
63+
.map_err(|e| IndexerServiceError::InvalidRequest(e.into()))?;
64+
let variables = request
65+
.variables
66+
.as_ref()
67+
.map(ToString::to_string)
68+
.unwrap_or_default();
69+
let _ = state
70+
.value_check_sender
71+
.tx_query
72+
.send(AgoraQuery {
73+
signature,
74+
deployment_id: manifest_id,
75+
query: request.query.clone(),
76+
variables,
77+
})
78+
.await;
5179

5280
// Verify the receipt and store it in the database
53-
// TODO update checks
5481
state
5582
.tap_manager
5683
.verify_and_store_receipt(receipt)

common/src/tap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod checks;
1919
mod receipt_store;
2020

2121
pub use checks::value_check::{
22-
create_value_check, CostModelSource, ValueCheckReceiver, ValueCheckSender,
22+
create_value_check, AgoraQuery, CostModelSource, ValueCheckReceiver, ValueCheckSender,
2323
};
2424

2525
#[derive(Clone)]

common/src/tap/checks/value_check.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ fn compile_cost_model(src: CostModelSource) -> anyhow::Result<CostModel> {
198198
}
199199

200200
pub struct AgoraQuery {
201-
signature: Signature,
202-
deployment_id: DeploymentId,
203-
query: String,
204-
variables: String,
201+
pub signature: Signature,
202+
pub deployment_id: DeploymentId,
203+
pub query: String,
204+
pub variables: String,
205205
}
206206

207207
#[derive(Clone, Eq, Hash, PartialEq)]

0 commit comments

Comments
 (0)