feat: remove flat-rs crate and use it through pallas_codec

This commit is contained in:
rvcas
2023-12-04 22:01:51 -05:00
parent b17b7f287c
commit 0a1e0d7bee
19 changed files with 17 additions and 1143 deletions

View File

@@ -33,7 +33,6 @@ serde_json = "1.0.94"
strum = "0.24.1"
strum_macros = "0.24.3"
thiserror = "1.0.39"
flat-rs = { path = "../flat-rs", version = "1.0.20-alpha" }
blst = "0.3.11"
once_cell = "1.18.0"

View File

@@ -1,9 +1,8 @@
use std::{fmt::Display, rc::Rc, str::FromStr};
use pallas_codec::flat::de;
use strum_macros::EnumIter;
use flat_rs::de;
use crate::ast::Term;
/// All the possible builtin functions in Untyped Plutus Core.

View File

@@ -1,3 +1,12 @@
use std::{collections::VecDeque, fmt::Debug, rc::Rc};
use pallas_codec::flat::{
de::{self, Decode, Decoder},
en::{self, Encode, Encoder},
Flat,
};
use pallas_primitives::{babbage::PlutusData, Fragment};
use crate::{
ast::{
Constant, DeBruijn, FakeNamedDeBruijn, Name, NamedDeBruijn, Program, Term, Type, Unique,
@@ -6,16 +15,6 @@ use crate::{
machine::runtime::Compressable,
};
use anyhow::anyhow;
use flat_rs::{
de::{self, Decode, Decoder},
en::{self, Encode, Encoder},
Flat,
};
use pallas_primitives::{babbage::PlutusData, Fragment};
use std::{collections::VecDeque, fmt::Debug, rc::Rc};
const BUILTIN_TAG_WIDTH: u32 = 7;
const CONST_TAG_WIDTH: u32 = 4;
const TERM_TAG_WIDTH: u32 = 4;
@@ -117,7 +116,10 @@ where
match term_option {
Ok(term) => Ok(Program { version, term }),
Err(error) => Err(de::Error::ParseError(state_log.join(""), anyhow!(error))),
Err(error) => Err(de::Error::Message(format!(
"{} {error}",
state_log.join("")
))),
}
}
}
@@ -948,8 +950,8 @@ mod tests {
ast::{DeBruijn, Name, Type},
parser,
};
use flat_rs::Flat;
use indoc::indoc;
use pallas_codec::flat::Flat;
#[test]
fn flat_encode_integer() {

View File

@@ -7,7 +7,7 @@ pub enum Error {
#[error("Only shelley reward addresses can be a part of withdrawals")]
BadWithdrawalAddress,
#[error("{0}")]
FlatDecode(#[from] flat_rs::de::Error),
FlatDecode(#[from] pallas_codec::flat::de::Error),
#[error("{0}")]
FragmentDecode(#[from] pallas_primitives::Error),
#[error("{}\n\n{:#?}\n\n{}", .0, .1, .2.join("\n"))]