diff --git a/Cargo.lock b/Cargo.lock index e9d127ddc5..7dcb192b24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -646,19 +646,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "bigdecimal" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06619be423ea5bb86c95f087d5707942791a08a85530df0db2209a3ecfb8bc9" -dependencies = [ - "autocfg 1.1.0", - "libm", - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "binascii" version = "0.1.4" @@ -5114,7 +5101,6 @@ version = "1.0.0" dependencies = [ "anyhow", "base64 0.13.1", - "bigdecimal", "bip39", "bs58 0.5.0", "cfg-if", diff --git a/common/commands/Cargo.toml b/common/commands/Cargo.toml index 83c1d45fc4..b2ef8bc3ea 100644 --- a/common/commands/Cargo.toml +++ b/common/commands/Cargo.toml @@ -8,7 +8,6 @@ license.workspace = true [dependencies] anyhow = { workspace = true } base64 = "0.13.0" -bigdecimal = "0.4.2" bip39 = { workspace = true } bs58 = { workspace = true } comfy-table = "6.0.0" diff --git a/common/commands/src/validator/mixnet/delegators/delegate_to_multiple_mixnodes.rs b/common/commands/src/validator/mixnet/delegators/delegate_to_multiple_mixnodes.rs index 3488824052..068b24c5d2 100644 --- a/common/commands/src/validator/mixnet/delegators/delegate_to_multiple_mixnodes.rs +++ b/common/commands/src/validator/mixnet/delegators/delegate_to_multiple_mixnodes.rs @@ -1,7 +1,6 @@ // Copyright 2024 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive}; use std::cmp::Ordering; use std::collections::{HashMap, HashSet}; use std::fs; @@ -10,7 +9,7 @@ use std::fs::OpenOptions; use clap::Parser; use comfy_table::Table; use csv::WriterBuilder; -use log::{info, warn}; +use log::info; use nym_mixnet_contract_common::ExecuteMsg; use nym_mixnet_contract_common::ExecuteMsg::{DelegateToMixnode, UndelegateFromMixnode}; @@ -65,20 +64,12 @@ impl InputFileReader { anyhow::bail!("Incorrect format: {}", line); } let mix_id = tokens[0].trim().to_string(); - let input_amount = BigDecimal::parse_bytes(tokens[1].trim().as_bytes(), 10) - .ok_or_else(|| anyhow::anyhow!("Invalid number format"))?; - let scaled_amount = input_amount.with_scale(6); + let input_amount = tokens[1] + .trim() + .parse::() + .map_err(|_| anyhow::anyhow!("'{}' has an invalid amount", line))?; - if scaled_amount > BigDecimal::from(1_000_000) { - warn!("Delegation amount is high. Please make sure your input is in NYM and not unym denomination"); - } - - let smallest_unit_multiplier = BigDecimal::from_u64(1_000_000).unwrap(); // For 6 decimal places - let amount_in_smallest_unit = scaled_amount * smallest_unit_multiplier; - - let amount = amount_in_smallest_unit.to_u128().ok_or_else(|| { - anyhow::anyhow!("Amount after scaling cannot be represented in u128") - })?; + let micro_nym_amount = input_amount * 1_000_000; if !mix_id_set.insert(mix_id.clone()) { anyhow::bail!("Duplicate mix_id found: {}", mix_id); @@ -87,7 +78,7 @@ impl InputFileReader { rows.push(InputFileRow { mix_id, amount: Coin { - amount, + amount: micro_nym_amount, denom: "unym".to_string(), }, }); @@ -337,7 +328,7 @@ pub async fn delegate_to_multiple_mixnodes(args: Args, client: SigningClient) { delegation_msgs, None, format!( - "Delegatations to {} nodes via nym-cli", + "Delegatation to {} nodes via nym-cli", undelegation_msgs.len() ), )