Skip to content

Commit

Permalink
fix: shielded assets parse int error (Zondax#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
rllola authored Feb 11, 2024
1 parent 47cad0f commit 1870cf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -57,6 +57,8 @@ pub enum Error {
Generic(Box<dyn StdError + Send>),
#[error("ParseInt error")]
ParseIntError(#[from] ParseIntError),
#[error("ParseFloat error")]
ParseFloatError(#[from] ParseFloatError),
}

impl From<SendError<(tendermint::Block, block_results::Response)>> for Error {
Expand Down
6 changes: 3 additions & 3 deletions src/server/shielded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl TryFrom<&Vec<Row>> for ShieldedAssetsResponse {
let token: String = row.try_get("token")?;

let amount_str: &str = row.try_get("amount")?;
let amount: u64 = amount_str.parse::<u64>()?;
let amount: f64 = amount_str.parse::<f64>()?;

let target: String = row.try_get("target")?;
let source: String = row.try_get("source")?;
Expand All @@ -32,7 +32,7 @@ impl TryFrom<&Vec<Row>> for ShieldedAssetsResponse {

let mut total = match shielded_assets.get(&token) {
Some(v) => *v,
None => 0,
None => 0.0,
};

if target == MASP_ADDR {
Expand All @@ -49,4 +49,4 @@ impl TryFrom<&Vec<Row>> for ShieldedAssetsResponse {
}
}

pub type ShieldedAssets = HashMap<String, u64>;
pub type ShieldedAssets = HashMap<String, f64>;

0 comments on commit 1870cf8

Please sign in to comment.