Skip to content

Commit 4e44f9a

Browse files
committed
Fixing hash_script_data
1 parent 1f48b12 commit 4e44f9a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

rust/src/plutus.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,13 @@ impl PlutusList {
475475
}
476476
}
477477

478+
pub(crate) fn clone_definite(&self) -> Self {
479+
Self {
480+
elems: self.elems.clone(),
481+
definite_encoding: Some(true),
482+
}
483+
}
484+
478485
pub fn len(&self) -> usize {
479486
self.elems.len()
480487
}

rust/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ pub fn hash_script_data(redeemers: &Redeemers, cost_models: &Costmdls, datums: O
921921
*/
922922
buf.extend(redeemers.to_bytes());
923923
if let Some(d) = &datums {
924-
buf.extend(d.to_bytes());
924+
buf.extend(d.clone_definite().to_bytes());
925925
}
926926
buf.extend(cost_models.language_views_encoding());
927927
}
@@ -2173,7 +2173,7 @@ mod tests {
21732173

21742174
assert_eq!(
21752175
hex::encode(script_data_hash.to_bytes()),
2176-
"4415e6667e6d6bbd992af5092d48e3c2ba9825200d0234d2470068f7f0f178b3"
2176+
"57240d358f8ab6128c4a66340271e4fec39b4971232add308f01a5809313adcf"
21772177
);
21782178
}
21792179

0 commit comments

Comments
 (0)