Skip to content

Commit

Permalink
fix: fix compile error using decimal-rs 0.1.42 (#5228)
Browse files Browse the repository at this point in the history
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 tari-project/tari-dan#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

<!-- Does this include a breaking change? If so, include this line as a footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain -->
  • Loading branch information
sdbondi authored Mar 8, 2023
1 parent 35fcd55 commit 6edbb1c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
12 changes: 2 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion base_layer/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion base_layer/core/src/transactions/tari_amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DecimalConvertError> for MicroTariError {
fn from(err: DecimalConvertError) -> Self {
MicroTariError::ConversionError(err)
}
}
/// A convenience constant that makes it easier to define Tari amounts.
/// ```edition2018
Expand Down

0 comments on commit 6edbb1c

Please sign in to comment.