From 651f0fcad3a4ecd801351f816258eeddf555d0a0 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Tue, 23 May 2023 14:51:34 -0700 Subject: [PATCH] lint --- web3_proxy/src/frontend/admin.rs | 16 +++++----------- web3_proxy/src/rpcs/request.rs | 4 +++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/web3_proxy/src/frontend/admin.rs b/web3_proxy/src/frontend/admin.rs index e2527b93..ba4d4eaa 100644 --- a/web3_proxy/src/frontend/admin.rs +++ b/web3_proxy/src/frontend/admin.rs @@ -5,11 +5,9 @@ use super::errors::Web3ProxyResponse; use crate::admin_queries::query_admin_modify_usertier; use crate::app::Web3ProxyApp; use crate::frontend::errors::{Web3ProxyError, Web3ProxyErrorContext}; -use crate::http_params::get_user_id_from_params; use crate::user_token::UserBearerToken; use crate::PostLogin; use anyhow::Context; -use axum::body::HttpBody; use axum::{ extract::{Path, Query}, headers::{authorization::Bearer, Authorization}, @@ -29,10 +27,9 @@ use http::StatusCode; use log::{debug, info, warn}; use migration::sea_orm::prelude::{Decimal, Uuid}; use migration::sea_orm::{ - self, ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter, - TransactionTrait, Update, + self, ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter, }; -use migration::{ConnectionTrait, Expr, OnConflict}; +use migration::{Expr, OnConflict}; use serde_json::json; use siwe::{Message, VerificationOpts}; use std::ops::Add; @@ -76,7 +73,7 @@ pub async fn admin_increase_balance( .map_err(|_| { Web3ProxyError::BadRequest("Unable to parse user_address as an Address".to_string()) })?; - let user_address_bytes: Vec = user_address.clone().to_fixed_bytes().into(); + let user_address_bytes: Vec = user_address.to_fixed_bytes().into(); let note: String = params .get("note") .ok_or_else(|| { @@ -94,11 +91,8 @@ pub async fn admin_increase_balance( Web3ProxyError::BadRequest("Unable to get the amount key from the request".to_string()) }) .map(|x| Decimal::from_str(x))? - .or_else(|err| { - Err(Web3ProxyError::BadRequest(format!( - "Unable to parse amount from the request {:?}", - err - ))) + .map_err(|err| { + Web3ProxyError::BadRequest(format!("Unable to parse amount from the request {:?}", err)) })?; let user_entry: user::Model = user::Entity::find() diff --git a/web3_proxy/src/rpcs/request.rs b/web3_proxy/src/rpcs/request.rs index 9e91f75c..7a8a0003 100644 --- a/web3_proxy/src/rpcs/request.rs +++ b/web3_proxy/src/rpcs/request.rs @@ -184,7 +184,9 @@ impl OpenRequestHandle { } else if let Some(ref p) = self.rpc.ws_provider { p.request(method, params).await } else { - unimplemented!("no provider. cannot send request") + return Err(ProviderError::CustomError( + "no provider configured!".to_string(), + )); }; // we do NOT want to measure errors, so we intentionally do not record this latency now.