Skip to content

Commit

Permalink
safe lovelace conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Jan 31, 2025
1 parent cb3435b commit 524f79e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Binary file modified src/core/libs/lucid_core/pkg/lucid_core_bg.wasm
Binary file not shown.
3 changes: 2 additions & 1 deletion src/core/libs/lucid_core/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ impl TryFrom<Assets> for Value {
type Error = CoreErr;
fn try_from(assets: Assets) -> Result<Self, Self::Error> {
let mut assets_inner = assets.0.clone();
let lovelace = assets_inner.remove("lovelace").unwrap_or(0) as u64;
let lovelace = u64::try_from(assets_inner.remove("lovelace").unwrap_or(0))
.map_err(|_| CoreError::msg("lovelace cannot be negative"))?;
if assets_inner.len() > 0 {
let mut value: BTreeMap<Vec<u8>, BTreeMap<Vec<u8>, i128>> = BTreeMap::new();
for (unit, quantity) in assets_inner.into_iter() {
Expand Down

0 comments on commit 524f79e

Please sign in to comment.