From 1b1636ab0e9e1431854630f3b075613d9522c2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Mon, 18 Dec 2023 14:28:33 +0100 Subject: [PATCH] Fix parsing of negative bigint --- crates/uplc/src/parser.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/uplc/src/parser.rs b/crates/uplc/src/parser.rs index a2def058..23a564b6 100644 --- a/crates/uplc/src/parser.rs +++ b/crates/uplc/src/parser.rs @@ -256,7 +256,10 @@ peg::parser! { / _* "I" _+ n:big_number() { match n.to_i64() { Some(n) => PlutusData::BigInt(pallas_primitives::alonzo::BigInt::Int(n.into())), None => match n.sign() { - Sign::Minus => PlutusData::BigInt(pallas_primitives::babbage::BigInt::BigNInt(n.to_bytes_be().1.into())), + Sign::Minus => { + let m: BigInt = n+1; + PlutusData::BigInt(pallas_primitives::babbage::BigInt::BigNInt(m.to_bytes_be().1.into())) + }, _ => PlutusData::BigInt(pallas_primitives::babbage::BigInt::BigUInt(n.to_bytes_be().1.into())) } } }