Skip to content

Commit

Permalink
feat: change user identifier type to a string from address (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
sahra-karakoc authored Oct 23, 2024
1 parent 24f1ac2 commit 8f018e3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SubgraphId>,
pub budget_usd: Option<NotNan<f64>>,
}
Expand All @@ -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_with::TryFromInto<f64>>")]
#[serde(rename = "max_budget")]
Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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,
})
Expand Down
2 changes: 1 addition & 1 deletion src/reports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<f64>,
pub indexer_requests: Vec<IndexerRequest>,
pub request_bytes: u32,
Expand Down
3 changes: 1 addition & 2 deletions src/subgraph_studio.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::HashMap;

use serde::Deserialize;
use thegraph_core::Address;
use tokio::{
sync::watch,
time::{interval, Duration, MissedTickBehavior},
Expand Down Expand Up @@ -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<f64>,
#[serde(default)]
Expand Down

0 comments on commit 8f018e3

Please sign in to comment.