feat(primitives): Add ToHash to DatumOption (#163)
This commit is contained in:
parent
dde9f96595
commit
a4873c404e
1 changed files with 10 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::ToHash;
|
||||
|
||||
use super::{Header, PlutusV2Script, TransactionBody};
|
||||
use super::{Header, PlutusV2Script, TransactionBody, DatumOption};
|
||||
use pallas_codec::utils::KeepRaw;
|
||||
use pallas_crypto::hash::{Hash, Hasher};
|
||||
|
||||
|
|
@ -28,6 +28,15 @@ impl ToHash<32> for KeepRaw<'_, TransactionBody> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToHash<32> for DatumOption {
|
||||
fn to_hash(&self) -> Hash<32> {
|
||||
match self {
|
||||
DatumOption::Hash(hash) => *hash,
|
||||
DatumOption::Data(data) => data.to_hash()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pallas_codec::minicbor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue