Fix parsing of negative bigint

This commit is contained in:
Niels Mündler 2023-12-18 14:28:33 +01:00 committed by Lucas
parent 0cfcd78039
commit 1b1636ab0e
1 changed files with 4 additions and 1 deletions

View File

@ -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()))
}
} }