From 6edbb1c8745593e41dd24585c9f8d399a96fff51 Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Wed, 8 Mar 2023 12:10:10 +0400 Subject: [PATCH] fix: fix compile error using decimal-rs 0.1.42 (#5228) Description --- Fixes compile error caused by breaking change for decimal-rs >=0.1.42 Motivation and Context --- decimal-rs removed the Error impl for their error type in 0.1.42 but released this breaking change as a patch. The thiserror from impl requires that the Error trait be implemented so this PR manually implements From ~~Causing compile error in https://github.com/tari-project/tari-dan/pull/421~~ worked around this and other issues by not updating all dependencies and locking to 0.47.0-pre.0 tag. How Has This Been Tested? --- Code compiles --- Cargo.lock | 12 ++---------- base_layer/core/Cargo.toml | 2 +- base_layer/core/src/transactions/tari_amount.rs | 9 ++++++++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8dc24c07b..75e30eb5e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1626,14 +1626,12 @@ checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" [[package]] name = "decimal-rs" -version = "0.1.41" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b90a2f41762c36b9a3a4ce1e1ee404201d779fd7d9280117acc1a43105bdfc1d" +checksum = "af600a28ba8f319291ba644d5a6de01970230716284c25245118a05357019e00" dependencies = [ - "ethnum", "fast-float", "stack-buf", - "thiserror", ] [[package]] @@ -1960,12 +1958,6 @@ dependencies = [ "str-buf", ] -[[package]] -name = "ethnum" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0198b9d0078e0f30dedc7acbb21c974e838fc8fae3ee170128658a98cb2c1c04" - [[package]] name = "fancy-regex" version = "0.8.0" diff --git a/base_layer/core/Cargo.toml b/base_layer/core/Cargo.toml index 63bc979d68..432ab3bb54 100644 --- a/base_layer/core/Cargo.toml +++ b/base_layer/core/Cargo.toml @@ -44,7 +44,7 @@ chacha20poly1305 = "0.10.1" chrono = { version = "0.4.19", default-features = false, features = ["serde"] } criterion = { version = "0.4.0", optional = true } croaring = { version = "0.5.2", optional = true } -decimal-rs = "0.1.20" +decimal-rs = "0.1.42" derivative = "2.2.0" digest = "0.9.0" fs2 = "0.4.0" diff --git a/base_layer/core/src/transactions/tari_amount.rs b/base_layer/core/src/transactions/tari_amount.rs index affb87baf3..f6fb0f7133 100644 --- a/base_layer/core/src/transactions/tari_amount.rs +++ b/base_layer/core/src/transactions/tari_amount.rs @@ -69,7 +69,14 @@ pub enum MicroTariError { #[error("Failed to parse value: {0}")] ParseError(String), #[error("Failed to convert value: {0}")] - ConversionError(#[from] DecimalConvertError), + ConversionError(DecimalConvertError), +} + +// DecimalConvertError does not implement Error +impl From for MicroTariError { + fn from(err: DecimalConvertError) -> Self { + MicroTariError::ConversionError(err) + } } /// A convenience constant that makes it easier to define Tari amounts. /// ```edition2018