Skip to content

Commit e139644

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

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

common/src/indexer_service/http/request_handler.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use reqwest::StatusCode;
1414
use thegraph_core::DeploymentId;
1515
use tracing::trace;
1616

17-
use crate::indexer_service::http::IndexerServiceResponse;
17+
use serde_json::value::RawValue;
18+
19+
use crate::{indexer_service::http::IndexerServiceResponse, tap::AgoraQuery};
1820

1921
use super::{
2022
indexer_service::{AttestationOutput, IndexerServiceError, IndexerServiceState},
@@ -41,14 +43,38 @@ where
4143
.with_label_values(&[&manifest_id.to_string()])
4244
.inc();
4345

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

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

5077
// Verify the receipt and store it in the database
51-
// TODO update checks
5278
state
5379
.tap_manager
5480
.verify_and_store_receipt(receipt)

common/src/tap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mod checks;
2525
mod receipt_store;
2626

2727
pub use checks::value_check::{
28-
create_value_check, CostModelSource, ValueCheckReceiver, ValueCheckSender,
28+
create_value_check, AgoraQuery, CostModelSource, ValueCheckReceiver, ValueCheckSender,
2929
};
3030

3131
#[derive(Clone)]

common/src/tap/checks/value_check.rs

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

203203
pub struct AgoraQuery {
204-
signature: Signature,
205-
deployment_id: DeploymentId,
206-
query: String,
207-
variables: String,
204+
pub signature: Signature,
205+
pub deployment_id: DeploymentId,
206+
pub query: String,
207+
pub variables: String,
208208
}
209209

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

0 commit comments

Comments
 (0)