From 4aa34740a860eeb19772895eefe861a9936cc86b Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 26 May 2023 16:54:52 -0700 Subject: [PATCH] default balance to 0 --- web3_proxy/src/frontend/authorization.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web3_proxy/src/frontend/authorization.rs b/web3_proxy/src/frontend/authorization.rs index dcc3b614..29d2779b 100644 --- a/web3_proxy/src/frontend/authorization.rs +++ b/web3_proxy/src/frontend/authorization.rs @@ -1112,20 +1112,20 @@ impl Web3ProxyApp { let user_model = user::Entity::find_by_id(rpc_key_model.user_id) .one(db_replica.conn()) .await? - .expect("related user"); + .context("no related user")?; let balance = balance::Entity::find() .filter(balance::Column::UserId.eq(user_model.id)) .one(db_replica.conn()) .await? - .expect("related balance") - .available_balance; + .map(|x| x.available_balance) + .unwrap_or_default(); let user_tier_model = user_tier::Entity::find_by_id(user_model.user_tier_id) .one(db_replica.conn()) .await? - .expect("related user tier"); + .context("no related user tier")?; let allowed_ips: Option> = if let Some(allowed_ips) = rpc_key_model.allowed_ips {