Skip to content

Commit

Permalink
Move function to somewhere which makes more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
KaffinPX committed Sep 28, 2024
1 parent 5b4e972 commit 964ab1f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions wallet/core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ pub fn sompi_to_kaspa(sompi: u64) -> f64 {
sompi as f64 / SOMPI_PER_KASPA as f64
}

#[inline]
pub fn sompi_to_unit(sompi: u64, decimals: u32) -> f64 {
let sompi_per_unit = 10u64.pow(decimals);

sompi as f64 / sompi_per_unit as f64
}

#[inline]
pub fn kaspa_to_sompi(kaspa: f64) -> u64 {
(kaspa * SOMPI_PER_KASPA as f64) as u64
Expand All @@ -62,6 +55,13 @@ pub fn sompi_to_kaspa_string(sompi: u64) -> String {
sompi_to_kaspa(sompi).separated_string()
}

#[inline]
pub fn sompi_to_unit(sompi: u64, decimals: u32) -> f64 {
let sompi_per_unit = 10u64.pow(decimals);

sompi as f64 / sompi_per_unit as f64
}

#[inline]
pub fn sompi_to_unit_string(sompi: u64, decimals: u32) -> String {
sompi_to_unit(sompi, decimals).separated_string()
Expand Down

0 comments on commit 964ab1f

Please sign in to comment.