fix: return witness objects for conway era multieratx (#346)
This commit is contained in:
parent
35e0d5459c
commit
afa397f4ea
8 changed files with 174 additions and 106 deletions
|
|
@ -70,6 +70,12 @@ impl ComputeHash<28> for alonzo::NativeScript {
|
|||
}
|
||||
}
|
||||
|
||||
impl OriginalHash<28> for KeepRaw<'_, alonzo::NativeScript> {
|
||||
fn original_hash(&self) -> Hash<28> {
|
||||
Hasher::<224>::hash_tagged(self.raw_cbor(), 0)
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputeHash<28> for alonzo::PlutusScript {
|
||||
fn compute_hash(&self) -> Hash<28> {
|
||||
Hasher::<224>::hash_tagged(&self.0, 1)
|
||||
|
|
|
|||
|
|
@ -34,11 +34,13 @@ impl<'b> MultiEraOutput<'b> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn script_ref(&self) -> Option<&babbage::ScriptRef> {
|
||||
pub fn script_ref(&self) -> Option<babbage::MintedScriptRef> {
|
||||
match &self {
|
||||
MultiEraOutput::Babbage(x) => match x.deref().deref() {
|
||||
babbage::MintedTransactionOutput::Legacy(_) => None,
|
||||
babbage::MintedTransactionOutput::PostAlonzo(x) => x.script_ref.as_ref(),
|
||||
babbage::MintedTransactionOutput::PostAlonzo(x) => {
|
||||
x.script_ref.clone().map(|x| x.unwrap())
|
||||
}
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use pallas_codec::utils::KeepRaw;
|
||||
use pallas_primitives::{
|
||||
alonzo::{self, BootstrapWitness, NativeScript, PlutusData, Redeemer, VKeyWitness},
|
||||
babbage::PlutusV2Script,
|
||||
alonzo::{self, BootstrapWitness, NativeScript, PlutusData, VKeyWitness},
|
||||
babbage::{PlutusV2Script, Redeemer},
|
||||
conway::{self, PlutusV3Script},
|
||||
};
|
||||
|
||||
use crate::MultiEraTx;
|
||||
|
|
@ -9,6 +10,7 @@ use crate::MultiEraTx;
|
|||
impl<'b> MultiEraTx<'b> {
|
||||
pub fn vkey_witnesses(&self) -> &[VKeyWitness] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
Self::AlonzoCompatible(x, _) => x
|
||||
.transaction_witness_set
|
||||
.vkeywitness
|
||||
|
|
@ -21,12 +23,18 @@ impl<'b> MultiEraTx<'b> {
|
|||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
_ => &[],
|
||||
Self::Conway(x) => x
|
||||
.transaction_witness_set
|
||||
.vkeywitness
|
||||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn native_scripts(&self) -> &[NativeScript] {
|
||||
pub fn native_scripts(&self) -> &[KeepRaw<'b, NativeScript>] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
Self::AlonzoCompatible(x, _) => x
|
||||
.transaction_witness_set
|
||||
.native_script
|
||||
|
|
@ -39,12 +47,18 @@ impl<'b> MultiEraTx<'b> {
|
|||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
_ => &[],
|
||||
Self::Conway(x) => x
|
||||
.transaction_witness_set
|
||||
.native_script
|
||||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bootstrap_witnesses(&self) -> &[BootstrapWitness] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
Self::AlonzoCompatible(x, _) => x
|
||||
.transaction_witness_set
|
||||
.bootstrap_witness
|
||||
|
|
@ -57,12 +71,18 @@ impl<'b> MultiEraTx<'b> {
|
|||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
_ => &[],
|
||||
Self::Conway(x) => x
|
||||
.transaction_witness_set
|
||||
.bootstrap_witness
|
||||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plutus_v1_scripts(&self) -> &[alonzo::PlutusScript] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
Self::AlonzoCompatible(x, _) => x
|
||||
.transaction_witness_set
|
||||
.plutus_script
|
||||
|
|
@ -75,12 +95,18 @@ impl<'b> MultiEraTx<'b> {
|
|||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
_ => &[],
|
||||
Self::Conway(x) => x
|
||||
.transaction_witness_set
|
||||
.plutus_v1_script
|
||||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plutus_data(&self) -> &[KeepRaw<'b, PlutusData>] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
Self::AlonzoCompatible(x, _) => x
|
||||
.transaction_witness_set
|
||||
.plutus_data
|
||||
|
|
@ -93,12 +119,19 @@ impl<'b> MultiEraTx<'b> {
|
|||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
_ => &[],
|
||||
Self::Conway(x) => x
|
||||
.transaction_witness_set
|
||||
.plutus_data
|
||||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: MultiEraRedeemer?
|
||||
pub fn redeemers(&self) -> &[Redeemer] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
Self::AlonzoCompatible(x, _) => x
|
||||
.transaction_witness_set
|
||||
.redeemer
|
||||
|
|
@ -111,19 +144,54 @@ impl<'b> MultiEraTx<'b> {
|
|||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
_ => &[],
|
||||
Self::Conway(_) => &[],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn conway_redeemers(&self) -> &[conway::Redeemer] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
Self::AlonzoCompatible(_, _) => &[],
|
||||
Self::Babbage(_) => &[],
|
||||
Self::Conway(x) => x
|
||||
.transaction_witness_set
|
||||
.redeemer
|
||||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plutus_v2_scripts(&self) -> &[PlutusV2Script] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
Self::AlonzoCompatible(_, _) => &[],
|
||||
Self::Babbage(x) => x
|
||||
.transaction_witness_set
|
||||
.plutus_v2_script
|
||||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
_ => &[],
|
||||
Self::Conway(x) => x
|
||||
.transaction_witness_set
|
||||
.plutus_v2_script
|
||||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plutus_v3_scripts(&self) -> &[PlutusV3Script] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
Self::AlonzoCompatible(_, _) => &[],
|
||||
Self::Babbage(_) => &[],
|
||||
Self::Conway(x) => x
|
||||
.transaction_witness_set
|
||||
.plutus_v3_script
|
||||
.as_ref()
|
||||
.map(|x| x.as_ref())
|
||||
.unwrap_or(&[]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue