feat(primitives): Add ToHash to DatumOption (#163)
This commit is contained in:
parent
abcde9d46b
commit
497a6ba51e
1 changed files with 10 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::ToHash;
|
use crate::ToHash;
|
||||||
|
|
||||||
use super::{Header, PlutusV2Script, TransactionBody};
|
use super::{Header, PlutusV2Script, TransactionBody, DatumOption};
|
||||||
use pallas_codec::utils::KeepRaw;
|
use pallas_codec::utils::KeepRaw;
|
||||||
use pallas_crypto::hash::{Hash, Hasher};
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use pallas_codec::minicbor;
|
use pallas_codec::minicbor;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue