diff --git a/src/error.rs b/src/error.rs index b2090fd..bf1db3c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -3,7 +3,7 @@ use axum::response::{IntoResponse, Response}; use axum::Json; use serde_json::json; use std::error::Error as StdError; -use std::num::ParseIntError; +use std::num::{ParseFloatError, ParseIntError}; use thiserror::Error as ThisError; use tokio::task::JoinError; @@ -57,6 +57,8 @@ pub enum Error { Generic(Box), #[error("ParseInt error")] ParseIntError(#[from] ParseIntError), + #[error("ParseFloat error")] + ParseFloatError(#[from] ParseFloatError), } impl From> for Error { diff --git a/src/server/shielded.rs b/src/server/shielded.rs index d6ce587..f1241fb 100644 --- a/src/server/shielded.rs +++ b/src/server/shielded.rs @@ -20,7 +20,7 @@ impl TryFrom<&Vec> for ShieldedAssetsResponse { let token: String = row.try_get("token")?; let amount_str: &str = row.try_get("amount")?; - let amount: u64 = amount_str.parse::()?; + let amount: f64 = amount_str.parse::()?; let target: String = row.try_get("target")?; let source: String = row.try_get("source")?; @@ -32,7 +32,7 @@ impl TryFrom<&Vec> for ShieldedAssetsResponse { let mut total = match shielded_assets.get(&token) { Some(v) => *v, - None => 0, + None => 0.0, }; if target == MASP_ADDR { @@ -49,4 +49,4 @@ impl TryFrom<&Vec> for ShieldedAssetsResponse { } } -pub type ShieldedAssets = HashMap; +pub type ShieldedAssets = HashMap;