From ad7371b6eb68d14591c48fd8de81d366027faf55 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Tue, 12 Nov 2024 11:34:06 -0500 Subject: [PATCH] fix: handle API key max_budget_usd --- src/client_query.rs | 13 ++----------- src/client_query/query_settings.rs | 7 ------- 2 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 src/client_query/query_settings.rs diff --git a/src/client_query.rs b/src/client_query.rs index 5ae9d3d4..608c29ca 100644 --- a/src/client_query.rs +++ b/src/client_query.rs @@ -26,10 +26,7 @@ use tokio::sync::mpsc; use tracing::{info_span, Instrument as _}; use url::Url; -use self::{ - attestation_header::GraphAttestation, context::Context, query_selector::QuerySelector, - query_settings::QuerySettings, -}; +use self::{attestation_header::GraphAttestation, context::Context, query_selector::QuerySelector}; use crate::{ auth::AuthSettings, block_constraints::{resolve_block_requirements, rewrite_query, BlockRequirements}, @@ -49,7 +46,6 @@ use crate::{ mod attestation_header; pub mod context; mod query_selector; -mod query_settings; const SELECTION_LIMIT: usize = 3; @@ -63,7 +59,6 @@ pub async fn handle_query( State(ctx): State, Extension(auth): Extension, Extension(RequestId(request_id)): Extension, - query_settings: Option>, selector: QuerySelector, payload: Bytes, ) -> Result, Error> { @@ -81,10 +76,7 @@ pub async fn handle_query( let one_grt = NotNan::new(1e18).unwrap(); let budget = { let mut budget = *(ctx.budgeter.query_fees_target.0 * grt_per_usd * one_grt) as u128; - if let Some(Extension(QuerySettings { - budget_usd: Some(user_budget_usd), - })) = query_settings - { + if let Some(user_budget_usd) = auth.budget_usd { // Security: Consumers can and will set their budget to unreasonably high values. // This `.min` prevents the budget from being set far beyond what it would be // automatically. The reason this is important is that sometimes queries are @@ -735,7 +727,6 @@ pub async fn handle_indexer_query( State(ctx): State, Extension(auth): Extension, Extension(RequestId(request_id)): Extension, - _query_settings: Option>, Path((deployment, indexer)): Path<(DeploymentId, IndexerId)>, payload: String, ) -> Result, Error> { diff --git a/src/client_query/query_settings.rs b/src/client_query/query_settings.rs deleted file mode 100644 index ef51e2c2..00000000 --- a/src/client_query/query_settings.rs +++ /dev/null @@ -1,7 +0,0 @@ -use ordered_float::NotNan; - -/// User query settings typically associated with an auth token. -#[derive(Clone, Debug, Default)] -pub struct QuerySettings { - pub budget_usd: Option>, -}