Skip to content

Commit

Permalink
chore: fix to_wei
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir committed Jan 5, 2024
1 parent bc4c1b3 commit cf39da9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/cast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,11 @@ impl SimpleCast {
/// # Ok::<_, eyre::Report>(())
/// ```
pub fn to_wei(value: &str, unit: &str) -> Result<String> {
Ok(ParseUnits::parse_units(value, unit.parse()?)?.to_string())
let wei = match unit {
"gwei" => ethers_core::utils::parse_units(value, 9),
_ => ethers_core::utils::parse_units(value, 18),
}?;
Ok(wei.to_string())
}

/// Decodes rlp encoded list with hex data
Expand Down

0 comments on commit cf39da9

Please sign in to comment.