chore: change how we depend on pallas
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use pallas_primitives::babbage::Language;
|
||||
use pallas::ledger::primitives::babbage::Language;
|
||||
|
||||
use crate::builtins::DefaultFunction;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{mem::size_of, ops::Deref, rc::Rc};
|
||||
use num_bigint::BigInt;
|
||||
use num_integer::Integer;
|
||||
use once_cell::sync::Lazy;
|
||||
use pallas_primitives::babbage::{Language, PlutusData};
|
||||
use pallas::ledger::primitives::babbage::{Language, PlutusData};
|
||||
|
||||
use crate::{
|
||||
ast::{Constant, Data, Type},
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::{collections::VecDeque, mem::size_of, ops::Deref, rc::Rc};
|
||||
|
||||
use num_bigint::BigInt;
|
||||
use num_traits::{Signed, ToPrimitive};
|
||||
use pallas_primitives::babbage::{self as pallas, PlutusData};
|
||||
use pallas::ledger::primitives::babbage::{self, PlutusData};
|
||||
|
||||
use crate::{
|
||||
ast::{Constant, NamedDeBruijn, Term, Type},
|
||||
@@ -394,27 +394,29 @@ fn integer_log2(i: BigInt) -> i64 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_pallas_bigint(n: &pallas::BigInt) -> BigInt {
|
||||
pub fn from_pallas_bigint(n: &babbage::BigInt) -> BigInt {
|
||||
match n {
|
||||
pallas::BigInt::Int(i) => i128::from(*i).into(),
|
||||
pallas::BigInt::BigUInt(bytes) => BigInt::from_bytes_be(num_bigint::Sign::Plus, bytes),
|
||||
pallas::BigInt::BigNInt(bytes) => BigInt::from_bytes_be(num_bigint::Sign::Minus, bytes) - 1,
|
||||
babbage::BigInt::Int(i) => i128::from(*i).into(),
|
||||
babbage::BigInt::BigUInt(bytes) => BigInt::from_bytes_be(num_bigint::Sign::Plus, bytes),
|
||||
babbage::BigInt::BigNInt(bytes) => {
|
||||
BigInt::from_bytes_be(num_bigint::Sign::Minus, bytes) - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_pallas_bigint(n: &BigInt) -> pallas::BigInt {
|
||||
pub fn to_pallas_bigint(n: &BigInt) -> babbage::BigInt {
|
||||
if let Some(i) = n.to_i64() {
|
||||
let pallas_int: pallas_codec::utils::Int = i.into();
|
||||
pallas::BigInt::Int(pallas_int)
|
||||
let pallas_int: pallas::codec::utils::Int = i.into();
|
||||
babbage::BigInt::Int(pallas_int)
|
||||
} else if n.is_positive() {
|
||||
let (_, bytes) = n.to_bytes_be();
|
||||
pallas::BigInt::BigUInt(bytes.into())
|
||||
babbage::BigInt::BigUInt(bytes.into())
|
||||
} else {
|
||||
// Note that this would break if n == 0
|
||||
// BUT n == 0 always fits into 64bits and hence would end up in the first branch.
|
||||
let n: BigInt = n + 1;
|
||||
let (_, bytes) = n.to_bytes_be();
|
||||
pallas::BigInt::BigNInt(bytes.into())
|
||||
babbage::BigInt::BigNInt(bytes.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user