Skip to content

Commit bfedf61

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

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

common/src/indexer_service/http/request_handler.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ use reqwest::StatusCode;
1616
use thegraph_core::DeploymentId;
1717
use tracing::trace;
1818

19-
use crate::indexer_service::http::IndexerServiceResponse;
19+
use serde_json::value::RawValue;
20+
21+
use crate::{indexer_service::http::IndexerServiceResponse, tap::AgoraQuery};
2022

2123
use super::{
2224
indexer_service::{AttestationOutput, IndexerServiceError, IndexerServiceState},
@@ -109,6 +111,31 @@ where
109111
};
110112

111113
let allocation_id = receipt.message.allocation_id;
114+
let signature = receipt.signature;
115+
116+
#[derive(Debug, serde::Deserialize)]
117+
pub struct QueryBody {
118+
pub query: String,
119+
pub variables: Option<Box<RawValue>>,
120+
}
121+
122+
let query_body: QueryBody =
123+
serde_json::from_slice(&body).map_err(|e| IndexerServiceError::InvalidRequest(e.into()))?;
124+
let variables = query_body
125+
.variables
126+
.as_ref()
127+
.map(ToString::to_string)
128+
.unwrap_or_default();
129+
let _ = state
130+
.value_check_sender
131+
.tx_query
132+
.send(AgoraQuery {
133+
signature,
134+
deployment_id: manifest_id,
135+
query: query_body.query.clone(),
136+
variables,
137+
})
138+
.await;
112139

113140
// recover the signer address
114141
// get escrow accounts from eventual

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)