made paymentrequired error code instead of introducing a new one

This commit is contained in:
yenicelik 2023-06-25 15:05:27 -04:00
parent 935681fde7
commit 4c157cfcf7
2 changed files with 5 additions and 17 deletions

@ -44,7 +44,6 @@ impl From<Web3ProxyError> for Web3ProxyResult<()> {
pub enum Web3ProxyError {
Abi(ethers::abi::Error),
AccessDenied,
AccessDeniedLowBalance,
AccessDeniedNoSubuser,
#[error(ignore)]
Anyhow(anyhow::Error),
@ -190,17 +189,6 @@ impl Web3ProxyError {
},
)
}
Self::AccessDeniedLowBalance => {
trace!("access denied due to low balance");
(
StatusCode::FORBIDDEN,
JsonRpcErrorData {
message: "FORBIDDEN: LOW BALANCE".into(),
code: StatusCode::FORBIDDEN.as_u16().into(),
data: None,
},
)
}
Self::AccessDeniedNoSubuser => {
trace!("access denied not a subuser");
(

@ -67,14 +67,14 @@ pub async fn query_user_stats<'a>(
if user_balance.total_spent_outside_free_tier - user_balance.total_deposits
< Decimal::from(0)
{
debug!("User has 0 balance");
return Err(Web3ProxyError::AccessDeniedLowBalance);
trace!("User has 0 balance");
return Err(Web3ProxyError::PaymentRequired);
}
// Otherwise make the user pass
}
None => {
debug!("User does not have a balance record, implying that he has no balance. Users must have a balance to access their stats dashboards");
return Err(Web3ProxyError::AccessDeniedLowBalance);
trace!("User does not have a balance record, implying that he has no balance. Users must have a balance to access their stats dashboards");
return Err(Web3ProxyError::PaymentRequired);
}
}
@ -99,7 +99,7 @@ pub async fn query_user_stats<'a>(
{
Some(secondary_user_record) => {
if secondary_user_record.role == Role::Collaborator {
debug!("Subuser is only a collaborator, collaborators cannot see stats");
trace!("Subuser is only a collaborator, collaborators cannot see stats");
return Err(Web3ProxyError::AccessDenied);
}
}