From f42f6dde1fa2402aee5e3584ab5d3d8da1194e41 Mon Sep 17 00:00:00 2001 From: Tiago Carvalho Date: Fri, 1 Sep 2023 10:08:45 +0100 Subject: [PATCH] Convert Uint to Amount with 0 denom --- core/src/types/token.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/types/token.rs b/core/src/types/token.rs index 3201684e0f..0ee60b4326 100644 --- a/core/src/types/token.rs +++ b/core/src/types/token.rs @@ -190,9 +190,13 @@ impl Amount { denom: impl Into, ) -> Result { let denom = denom.into(); + let uint = uint.into(); + if denom == 0 { + return Ok(Self { raw: uint }); + } match Uint::from(10) .checked_pow(Uint::from(denom)) - .and_then(|scaling| scaling.checked_mul(uint.into())) + .and_then(|scaling| scaling.checked_mul(uint)) { Some(amount) => Ok(Self { raw: amount }), None => Err(AmountParseError::ConvertToDecimal),