From ac27c5a064fdb8c401bad9342518beec275c8c1f Mon Sep 17 00:00:00 2001 From: aglkm <39521015+aglkm@users.noreply.github.com> Date: Sat, 22 Jun 2024 22:16:09 +0300 Subject: [PATCH] remove unwrap() calls --- src/requests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/requests.rs b/src/requests.rs index 9681f5a..8ef7761 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -91,7 +91,7 @@ pub async fn call(method: &str, params: &str, id: &str, rpc_type: &str) -> Resul Err(err) => { error!("rpc failed, status code: {:?}", err.status().unwrap()); }, } - let val: Value = serde_json::from_str(&result.text().await.unwrap())?; + let val: Value = serde_json::from_str(&result.text().await?)?; Ok(val) } @@ -158,7 +158,7 @@ pub async fn get_connected_peers(dashboard: Arc>) // Collecting: supply, inflation, price_usd, price_btc, volume_usd, volume_btc, cap_usd, cap_btc. -pub async fn get_market(dashboard: Arc>) -> Result<(), Error> { +pub async fn get_market(dashboard: Arc>) -> Result<(), anyhow::Error> { let client; let result; let mut val = Value::Null; @@ -166,7 +166,7 @@ pub async fn get_market(dashboard: Arc>) -> Result<(), Error> { if CONFIG.coingecko_api == "enabled" { client = reqwest::Client::new(); result = client.get("https://api.coingecko.com/api/v3/simple/price?ids=grin&vs_currencies=usd%2Cbtc&include_24hr_vol=true").send().await?; - val = serde_json::from_str(&result.text().await.unwrap()).unwrap(); + val = serde_json::from_str(&result.text().await?)?; } let mut data = dashboard.lock().unwrap();