diff --git a/entities/src/sea_orm_active_enums.rs b/entities/src/sea_orm_active_enums.rs index 8bb3f269..8af4137b 100644 --- a/entities/src/sea_orm_active_enums.rs +++ b/entities/src/sea_orm_active_enums.rs @@ -3,7 +3,7 @@ use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "role")] pub enum Role { #[sea_orm(string_value = "owner")] diff --git a/entities/src/secondary_user.rs b/entities/src/secondary_user.rs index 3c989edb..abbbb0f1 100644 --- a/entities/src/secondary_user.rs +++ b/entities/src/secondary_user.rs @@ -4,7 +4,7 @@ use super::sea_orm_active_enums::Role; use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] #[sea_orm(table_name = "secondary_user")] pub struct Model { #[sea_orm(primary_key)] diff --git a/entities/src/user.rs b/entities/src/user.rs index 6506455c..506696cb 100644 --- a/entities/src/user.rs +++ b/entities/src/user.rs @@ -3,7 +3,7 @@ use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)] #[sea_orm(table_name = "user")] pub struct Model { #[sea_orm(primary_key)] diff --git a/entities/src/user_keys.rs b/entities/src/user_keys.rs index 7456a3da..98126743 100644 --- a/entities/src/user_keys.rs +++ b/entities/src/user_keys.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use sea_orm::prelude::Uuid; use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)] #[sea_orm(table_name = "user_keys")] pub struct Model { #[sea_orm(primary_key)] diff --git a/web3_proxy/src/bin/web3_proxy_cli/check_config.rs b/web3_proxy/src/bin/web3_proxy_cli/check_config.rs index c41581df..da6e74c6 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/check_config.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/check_config.rs @@ -1,6 +1,6 @@ use argh::FromArgs; -#[derive(FromArgs, PartialEq, Debug)] +#[derive(FromArgs, PartialEq, Eq, Debug)] /// Second subcommand. #[argh(subcommand, name = "check_config")] pub struct CheckConfigSubCommand { diff --git a/web3_proxy/src/bin/web3_proxy_cli/create_user.rs b/web3_proxy/src/bin/web3_proxy_cli/create_user.rs index 0c707e1c..09e90132 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/create_user.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/create_user.rs @@ -1,12 +1,13 @@ use anyhow::Context; use argh::FromArgs; use entities::{user, user_keys}; -use ethers::types::Address; +use ethers::prelude::Address; use sea_orm::ActiveModelTrait; use tracing::info; +use uuid::Uuid; use web3_proxy::users::new_api_key; -#[derive(FromArgs, PartialEq, Debug)] +#[derive(FromArgs, PartialEq, Debug, Eq)] /// Create a new user and api key #[argh(subcommand, name = "create_user")] pub struct CreateUserSubCommand { @@ -17,6 +18,11 @@ pub struct CreateUserSubCommand { #[argh(option)] /// the user's optional email email: Option, + + #[argh(option)] + /// the user's first api key. + /// If none given, one will be generated randomly + api_key: Option, } impl CreateUserSubCommand { @@ -39,10 +45,12 @@ impl CreateUserSubCommand { info!("user #{}: {:?}", u.id, Address::from_slice(&u.address)); + let api_key = self.api_key.unwrap_or_else(new_api_key); + // create a key for the new user let uk = user_keys::ActiveModel { user_id: sea_orm::Set(u.id), - api_key: sea_orm::Set(new_api_key()), + api_key: sea_orm::Set(api_key), requests_per_minute: sea_orm::Set(6_000_000), ..Default::default() }; diff --git a/web3_proxy/src/bin/web3_proxy_cli/main.rs b/web3_proxy/src/bin/web3_proxy_cli/main.rs index 293a8f52..bf32bafd 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/main.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/main.rs @@ -54,6 +54,6 @@ async fn main() -> anyhow::Result<()> { x.main(&db).await } - SubCommand::Two(x) => x.main().await, + SubCommand::CheckConfig(x) => x.main().await, } }