Skip to content

Commit

Permalink
Reverted the previous changes and updated the witness-set field-4 ser…
Browse files Browse the repository at this point in the history
…ialization
  • Loading branch information
vsubhuman committed Feb 15, 2022
1 parent 270a518 commit 5dfc32e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cardano-serialization-lib",
"version": "10.0.4-beta.3",
"version": "10.0.4-beta.4",
"description": "(De)serialization functions for the Cardano blockchain along with related utility functions",
"scripts": {
"rust:build-nodejs": "(rimraf ./rust/pkg && cd rust; wasm-pack build --target=nodejs; wasm-pack pack) && npm run js:flowgen",
Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cardano-serialization-lib"
version = "10.0.4-beta.3"
version = "10.0.4-beta.4"
edition = "2018"
authors = ["EMURGO"]
license = "MIT"
Expand Down
11 changes: 2 additions & 9 deletions rust/src/plutus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,6 @@ impl PlutusList {
}
}

pub(crate) fn clone_as_definite(&self) -> Self {
Self {
elems: self.elems.clone(),
definite_encoding: Some(true),
}
}

pub fn len(&self) -> usize {
self.elems.len()
}
Expand Down Expand Up @@ -1279,12 +1272,12 @@ mod tests {
// witness_set should have fixed length array
let mut witness_set = TransactionWitnessSet::new();
witness_set.set_plutus_data(&list);
assert_eq!("a1048101", hex::encode(witness_set.to_bytes()));
assert_eq!("a1049f01ff", hex::encode(witness_set.to_bytes()));

list = PlutusList::new();
list.add(&datum);
witness_set.set_plutus_data(&list);
assert_eq!(format!("a10481{}", datum_cli), hex::encode(witness_set.to_bytes()));
assert_eq!(format!("a1049f{}ff", datum_cli), hex::encode(witness_set.to_bytes()));
}

#[test]
Expand Down
5 changes: 1 addition & 4 deletions rust/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1806,10 +1806,7 @@ impl cbor_event::se::Serialize for TransactionWitnessSet {
}
if let Some(field) = &self.plutus_data {
serializer.write_unsigned_integer(4)?;
serializer.write_array(cbor_event::Len::Len(field.len() as u64))?;
for i in 0..field.len() {
field.get(i).serialize(serializer)?;
}
field.serialize(serializer)?;
}
if let Some(field) = &self.redeemers {
serializer.write_unsigned_integer(5)?;
Expand Down
6 changes: 3 additions & 3 deletions rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ pub fn hash_script_data(redeemers: &Redeemers, cost_models: &Costmdls, datums: O
*/
buf.push(0x80);
if let Some(d) = &datums {
buf.extend(d.clone_as_definite().to_bytes());
buf.extend(d.to_bytes());
}
buf.push(0xA0);
} else {
Expand All @@ -921,7 +921,7 @@ pub fn hash_script_data(redeemers: &Redeemers, cost_models: &Costmdls, datums: O
*/
buf.extend(redeemers.to_bytes());
if let Some(d) = &datums {
buf.extend(d.clone_as_definite().to_bytes());
buf.extend(d.to_bytes());
}
buf.extend(cost_models.language_views_encoding());
}
Expand Down Expand Up @@ -2173,7 +2173,7 @@ mod tests {

assert_eq!(
hex::encode(script_data_hash.to_bytes()),
"57240d358f8ab6128c4a66340271e4fec39b4971232add308f01a5809313adcf"
"4415e6667e6d6bbd992af5092d48e3c2ba9825200d0234d2470068f7f0f178b3"
);
}

Expand Down

0 comments on commit 5dfc32e

Please sign in to comment.