From d366c5f3d6b040883d027f5380a865fdb4a02b90 Mon Sep 17 00:00:00 2001 From: Sahra Date: Thu, 12 Sep 2024 17:04:55 +0300 Subject: [PATCH] feat: change user identifier type to a string from address --- src/auth.rs | 10 +++++----- src/reports.rs | 4 ++-- src/subgraph_studio.rs | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index b8ce4bb9..1cbea27a 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -7,13 +7,13 @@ use anyhow::{anyhow, bail, ensure}; use ordered_float::NotNan; use serde::Deserialize; use serde_with::serde_as; -use thegraph_core::{Address, SubgraphId}; +use thegraph_core::SubgraphId; use tokio::sync::watch; #[derive(Clone, Debug, Default)] pub struct AuthSettings { pub key: String, - pub user: Address, + pub user: String, pub authorized_subgraphs: Vec, pub budget_usd: Option>, } @@ -36,7 +36,7 @@ impl AuthSettings { #[derive(Clone, Debug, Default, Deserialize)] pub struct APIKey { pub key: String, - pub user_address: Address, + pub user_address: String, pub query_status: QueryStatus, #[serde_as(as = "Option>")] #[serde(rename = "max_budget")] @@ -75,7 +75,7 @@ impl AuthContext { if self.special_api_keys.contains(token) { return Ok(AuthSettings { key: token.to_string(), - user: Address::default(), + user: String::new(), authorized_subgraphs: vec![], budget_usd: None, }); @@ -105,7 +105,7 @@ impl AuthContext { Ok(AuthSettings { key: api_key.key.clone(), - user: api_key.user_address, + user: api_key.user_address.clone(), authorized_subgraphs: api_key.subgraphs.clone(), budget_usd: api_key.max_budget_usd, }) diff --git a/src/reports.rs b/src/reports.rs index 0d20cb62..6ee22e4c 100644 --- a/src/reports.rs +++ b/src/reports.rs @@ -2,7 +2,7 @@ use anyhow::{anyhow, Context}; use ordered_float::NotNan; use prost::Message; use serde_json::json; -use thegraph_core::{Address, AllocationId, DeploymentId, IndexerId}; +use thegraph_core::{AllocationId, DeploymentId, IndexerId}; use tokio::sync::mpsc; use toolshed::concat_bytes; @@ -13,7 +13,7 @@ pub struct ClientRequest { pub response_time_ms: u16, pub result: Result<(), errors::Error>, pub api_key: String, - pub user_address: Address, + pub user_address: String, pub grt_per_usd: NotNan, pub indexer_requests: Vec, pub request_bytes: u32, diff --git a/src/subgraph_studio.rs b/src/subgraph_studio.rs index 2bb5c7ac..57278224 100644 --- a/src/subgraph_studio.rs +++ b/src/subgraph_studio.rs @@ -1,7 +1,6 @@ use std::collections::HashMap; use serde::Deserialize; -use thegraph_core::Address; use tokio::{ sync::watch, time::{interval, Duration, MissedTickBehavior}, @@ -53,7 +52,7 @@ impl Client { #[derive(Deserialize, Debug)] struct _ApiKey { key: String, - user_address: Address, + user_address: String, query_status: QueryStatus, max_budget: Option, #[serde(default)]