Skip to content

Commit 1646650

Browse files
committed
Merge branch 'master' of github.com:mlabs-haskell/plutus-ledger-api-rust into tmp
2 parents c4bcdf2 + fb93fa5 commit 1646650

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
proptest = "1.3.1"
10-
lbr-prelude = { git = "https://github.com/mlabs-haskell/lambda-buffers.git", rev = "fc9ce0635e3a0adc4ecc35e371c7034167b19f7a", optional = true }
10+
lbr-prelude = { git = "https://github.com/mlabs-haskell/lambda-buffers.git", rev = "59d3fb6422fef707c66fb83c2bd29327371d9bd3", optional = true }
1111
serde_json = { version = "1.0.107", features = [
1212
"arbitrary_precision",
1313
], optional = true }

src/plutus_data.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,28 @@ pub enum PlutusData {
2424
Bytes(Vec<u8>),
2525
}
2626

27+
impl PlutusData {
28+
pub fn constr(tag: u32, fields: Vec<PlutusData>) -> Self {
29+
PlutusData::Constr(BigInt::from(tag), fields)
30+
}
31+
32+
pub fn map(fields: Vec<(PlutusData, PlutusData)>) -> Self {
33+
PlutusData::Map(fields)
34+
}
35+
36+
pub fn list(fields: Vec<PlutusData>) -> Self {
37+
PlutusData::List(fields)
38+
}
39+
40+
pub fn integer(value: u32) -> Self {
41+
PlutusData::Integer(BigInt::from(value))
42+
}
43+
44+
pub fn bytes(value: Vec<u8>) -> Self {
45+
PlutusData::Bytes(value)
46+
}
47+
}
48+
2749
#[cfg(feature = "lbf")]
2850
impl Json for PlutusData {
2951
fn to_json(&self) -> serde_json::Value {
@@ -140,28 +162,6 @@ impl Json for PlutusData {
140162
}
141163
}
142164

143-
impl PlutusData {
144-
pub fn constr(tag: u32, fields: Vec<PlutusData>) -> Self {
145-
PlutusData::Constr(BigInt::from(tag), fields)
146-
}
147-
148-
pub fn map(fields: Vec<(PlutusData, PlutusData)>) -> Self {
149-
PlutusData::Map(fields)
150-
}
151-
152-
pub fn list(fields: Vec<PlutusData>) -> Self {
153-
PlutusData::List(fields)
154-
}
155-
156-
pub fn integer(value: u32) -> Self {
157-
PlutusData::Integer(BigInt::from(value))
158-
}
159-
160-
pub fn bytes(value: Vec<u8>) -> Self {
161-
PlutusData::Bytes(value)
162-
}
163-
}
164-
165165
/// Deserialise a Plutus data using parsers for each variant
166166
pub fn case_plutus_data<'a, T>(
167167
ctor_case: impl FnOnce(&'a BigInt) -> Box<dyn 'a + FnOnce(&'a Vec<PlutusData>) -> T>,

0 commit comments

Comments
 (0)