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
|
|
@ -1293,7 +1293,7 @@ pub struct MintedWitnessSet<'b> {
|
|||
pub vkeywitness: Option<Vec<VKeyWitness>>,
|
||||
|
||||
#[n(1)]
|
||||
pub native_script: Option<Vec<NativeScript>>,
|
||||
pub native_script: Option<Vec<KeepRaw<'b, NativeScript>>>,
|
||||
|
||||
#[n(2)]
|
||||
pub bootstrap_witness: Option<Vec<BootstrapWitness>>,
|
||||
|
|
@ -1312,7 +1312,9 @@ impl<'b> From<MintedWitnessSet<'b>> for WitnessSet {
|
|||
fn from(x: MintedWitnessSet<'b>) -> Self {
|
||||
WitnessSet {
|
||||
vkeywitness: x.vkeywitness,
|
||||
native_script: x.native_script,
|
||||
native_script: x
|
||||
.native_script
|
||||
.map(|x| x.into_iter().map(|x| x.unwrap()).collect()),
|
||||
bootstrap_witness: x.bootstrap_witness,
|
||||
plutus_script: x.plutus_script,
|
||||
plutus_data: x
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ impl<'b> From<MintedTransactionOutput<'b>> for TransactionOutput {
|
|||
|
||||
#[derive(Encode, Decode, Debug, PartialEq, Clone)]
|
||||
#[cbor(map)]
|
||||
pub struct PseudoPostAlonzoTransactionOutput<T1> {
|
||||
pub struct PseudoPostAlonzoTransactionOutput<T1, T2> {
|
||||
#[n(0)]
|
||||
pub address: Bytes,
|
||||
|
||||
|
|
@ -381,13 +381,13 @@ pub struct PseudoPostAlonzoTransactionOutput<T1> {
|
|||
pub datum_option: Option<T1>,
|
||||
|
||||
#[n(3)]
|
||||
pub script_ref: Option<ScriptRef>,
|
||||
pub script_ref: Option<CborWrap<T2>>,
|
||||
}
|
||||
|
||||
pub type PostAlonzoTransactionOutput = PseudoPostAlonzoTransactionOutput<DatumOption>;
|
||||
pub type PostAlonzoTransactionOutput = PseudoPostAlonzoTransactionOutput<DatumOption, ScriptRef>;
|
||||
|
||||
pub type MintedPostAlonzoTransactionOutput<'b> =
|
||||
PseudoPostAlonzoTransactionOutput<MintedDatumOption<'b>>;
|
||||
PseudoPostAlonzoTransactionOutput<MintedDatumOption<'b>, MintedScriptRef<'b>>;
|
||||
|
||||
impl<'b> From<MintedPostAlonzoTransactionOutput<'b>> for PostAlonzoTransactionOutput {
|
||||
fn from(value: MintedPostAlonzoTransactionOutput<'b>) -> Self {
|
||||
|
|
@ -395,7 +395,7 @@ impl<'b> From<MintedPostAlonzoTransactionOutput<'b>> for PostAlonzoTransactionOu
|
|||
address: value.address,
|
||||
value: value.value,
|
||||
datum_option: value.datum_option.map(|x| x.into()),
|
||||
script_ref: value.script_ref,
|
||||
script_ref: value.script_ref.map(|x| CborWrap(x.unwrap().into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -464,7 +464,7 @@ pub struct MintedWitnessSet<'b> {
|
|||
pub vkeywitness: Option<Vec<VKeyWitness>>,
|
||||
|
||||
#[n(1)]
|
||||
pub native_script: Option<Vec<NativeScript>>,
|
||||
pub native_script: Option<Vec<KeepRaw<'b, NativeScript>>>,
|
||||
|
||||
#[n(2)]
|
||||
pub bootstrap_witness: Option<Vec<BootstrapWitness>>,
|
||||
|
|
@ -486,7 +486,9 @@ impl<'b> From<MintedWitnessSet<'b>> for WitnessSet {
|
|||
fn from(x: MintedWitnessSet<'b>) -> Self {
|
||||
WitnessSet {
|
||||
vkeywitness: x.vkeywitness,
|
||||
native_script: x.native_script,
|
||||
native_script: x
|
||||
.native_script
|
||||
.map(|x| x.into_iter().map(|x| x.unwrap()).collect()),
|
||||
bootstrap_witness: x.bootstrap_witness,
|
||||
plutus_v1_script: x.plutus_v1_script,
|
||||
plutus_data: x
|
||||
|
|
@ -573,18 +575,33 @@ impl<'b> From<MintedDatumOption<'b>> for DatumOption {
|
|||
}
|
||||
}
|
||||
|
||||
// script_ref = #6.24(bytes .cbor script)
|
||||
pub type ScriptRef = CborWrap<Script>;
|
||||
|
||||
// script = [ 0, native_script // 1, plutus_v1_script // 2, plutus_v2_script ]
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
pub enum Script {
|
||||
NativeScript(NativeScript),
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum PseudoScript<T1> {
|
||||
NativeScript(T1),
|
||||
PlutusV1Script(PlutusV1Script),
|
||||
PlutusV2Script(PlutusV2Script),
|
||||
}
|
||||
|
||||
impl<'b, C> minicbor::Decode<'b, C> for Script {
|
||||
// script_ref = #6.24(bytes .cbor script)
|
||||
pub type ScriptRef = PseudoScript<NativeScript>;
|
||||
|
||||
pub type MintedScriptRef<'b> = PseudoScript<KeepRaw<'b, NativeScript>>;
|
||||
|
||||
impl<'b> From<MintedScriptRef<'b>> for ScriptRef {
|
||||
fn from(value: MintedScriptRef<'b>) -> Self {
|
||||
match value {
|
||||
PseudoScript::NativeScript(x) => Self::NativeScript(x.unwrap()),
|
||||
PseudoScript::PlutusV1Script(x) => Self::PlutusV1Script(x),
|
||||
PseudoScript::PlutusV2Script(x) => Self::PlutusV2Script(x),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b, C, T> minicbor::Decode<'b, C> for PseudoScript<T>
|
||||
where
|
||||
T: minicbor::Decode<'b, ()>,
|
||||
{
|
||||
fn decode(
|
||||
d: &mut minicbor::Decoder<'b>,
|
||||
_ctx: &mut C,
|
||||
|
|
@ -602,7 +619,10 @@ impl<'b, C> minicbor::Decode<'b, C> for Script {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C> minicbor::Encode<C> for Script {
|
||||
impl<C, T> minicbor::Encode<C> for PseudoScript<T>
|
||||
where
|
||||
T: minicbor::Encode<C>,
|
||||
{
|
||||
fn encode<W: minicbor::encode::Write>(
|
||||
&self,
|
||||
e: &mut minicbor::Encoder<W>,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
|||
use pallas_codec::minicbor::{Decode, Encode};
|
||||
use pallas_crypto::hash::Hash;
|
||||
|
||||
use pallas_codec::utils::{Bytes, CborWrap, KeepRaw, KeyValuePairs, MaybeIndefArray, Nullable};
|
||||
use pallas_codec::utils::{Bytes, KeepRaw, KeyValuePairs, MaybeIndefArray, Nullable};
|
||||
|
||||
// required for derive attrs to work
|
||||
use pallas_codec::minicbor;
|
||||
|
|
@ -1250,7 +1250,7 @@ pub struct WitnessSet {
|
|||
pub plutus_v2_script: Option<Vec<PlutusV2Script>>,
|
||||
|
||||
#[n(7)]
|
||||
pub plutus_v3_script: Option<Vec<PlutusV2Script>>,
|
||||
pub plutus_v3_script: Option<Vec<PlutusV3Script>>,
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug, PartialEq, Clone)]
|
||||
|
|
@ -1260,7 +1260,7 @@ pub struct MintedWitnessSet<'b> {
|
|||
pub vkeywitness: Option<Vec<VKeyWitness>>,
|
||||
|
||||
#[n(1)]
|
||||
pub native_script: Option<Vec<NativeScript>>,
|
||||
pub native_script: Option<Vec<KeepRaw<'b, NativeScript>>>,
|
||||
|
||||
#[n(2)]
|
||||
pub bootstrap_witness: Option<Vec<BootstrapWitness>>,
|
||||
|
|
@ -1278,14 +1278,16 @@ pub struct MintedWitnessSet<'b> {
|
|||
pub plutus_v2_script: Option<Vec<PlutusV2Script>>,
|
||||
|
||||
#[n(7)]
|
||||
pub plutus_v3_script: Option<Vec<PlutusV2Script>>,
|
||||
pub plutus_v3_script: Option<Vec<PlutusV3Script>>,
|
||||
}
|
||||
|
||||
impl<'b> From<MintedWitnessSet<'b>> for WitnessSet {
|
||||
fn from(x: MintedWitnessSet<'b>) -> Self {
|
||||
WitnessSet {
|
||||
vkeywitness: x.vkeywitness,
|
||||
native_script: x.native_script,
|
||||
native_script: x
|
||||
.native_script
|
||||
.map(|x| x.into_iter().map(|x| x.unwrap()).collect()),
|
||||
bootstrap_witness: x.bootstrap_witness,
|
||||
plutus_v1_script: x.plutus_v1_script,
|
||||
plutus_data: x
|
||||
|
|
@ -1317,78 +1319,43 @@ pub struct PostAlonzoAuxiliaryData {
|
|||
pub plutus_v3_scripts: Option<Vec<PlutusV3Script>>,
|
||||
}
|
||||
|
||||
pub type DatumHash = Hash<32>;
|
||||
pub use crate::babbage::DatumHash;
|
||||
|
||||
//pub type Data = CborWrap<PlutusData>;
|
||||
pub use crate::babbage::PseudoDatumOption;
|
||||
|
||||
// datum_option = [ 0, $hash32 // 1, data ]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum PseudoDatumOption<T1> {
|
||||
Hash(Hash<32>),
|
||||
Data(CborWrap<T1>),
|
||||
}
|
||||
pub use crate::babbage::DatumOption;
|
||||
|
||||
impl<'b, C, T> minicbor::Decode<'b, C> for PseudoDatumOption<T>
|
||||
where
|
||||
T: minicbor::Decode<'b, C>,
|
||||
{
|
||||
fn decode(d: &mut minicbor::Decoder<'b>, ctx: &mut C) -> Result<Self, minicbor::decode::Error> {
|
||||
d.array()?;
|
||||
|
||||
match d.u8()? {
|
||||
0 => Ok(Self::Hash(d.decode_with(ctx)?)),
|
||||
1 => Ok(Self::Data(d.decode_with(ctx)?)),
|
||||
_ => Err(minicbor::decode::Error::message(
|
||||
"invalid variant for datum option enum",
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, T> minicbor::Encode<C> for PseudoDatumOption<T>
|
||||
where
|
||||
T: minicbor::Encode<C>,
|
||||
{
|
||||
fn encode<W: minicbor::encode::Write>(
|
||||
&self,
|
||||
e: &mut minicbor::Encoder<W>,
|
||||
ctx: &mut C,
|
||||
) -> Result<(), minicbor::encode::Error<W::Error>> {
|
||||
match self {
|
||||
Self::Hash(x) => e.encode_with((0, x), ctx)?,
|
||||
Self::Data(x) => e.encode_with((1, x), ctx)?,
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub type DatumOption = PseudoDatumOption<PlutusData>;
|
||||
|
||||
pub type MintedDatumOption<'b> = PseudoDatumOption<KeepRaw<'b, PlutusData>>;
|
||||
|
||||
impl<'b> From<MintedDatumOption<'b>> for DatumOption {
|
||||
fn from(value: MintedDatumOption<'b>) -> Self {
|
||||
match value {
|
||||
PseudoDatumOption::Hash(x) => Self::Hash(x),
|
||||
PseudoDatumOption::Data(x) => Self::Data(CborWrap(x.unwrap().unwrap())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// script_ref = #6.24(bytes .cbor script)
|
||||
pub type ScriptRef = CborWrap<Script>;
|
||||
pub use crate::babbage::MintedDatumOption;
|
||||
|
||||
// script = [ 0, native_script // 1, plutus_v1_script // 2, plutus_v2_script ]
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
pub enum Script {
|
||||
NativeScript(NativeScript),
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum PseudoScript<T1> {
|
||||
NativeScript(T1),
|
||||
PlutusV1Script(PlutusV1Script),
|
||||
PlutusV2Script(PlutusV2Script),
|
||||
PlutusV3Script(PlutusV3Script),
|
||||
}
|
||||
|
||||
impl<'b, C> minicbor::Decode<'b, C> for Script {
|
||||
// script_ref = #6.24(bytes .cbor script)
|
||||
pub type ScriptRef = PseudoScript<NativeScript>;
|
||||
|
||||
pub type MintedScriptRef<'b> = PseudoScript<KeepRaw<'b, NativeScript>>;
|
||||
|
||||
impl<'b> From<MintedScriptRef<'b>> for ScriptRef {
|
||||
fn from(value: MintedScriptRef<'b>) -> Self {
|
||||
match value {
|
||||
PseudoScript::NativeScript(x) => Self::NativeScript(x.unwrap()),
|
||||
PseudoScript::PlutusV1Script(x) => Self::PlutusV1Script(x),
|
||||
PseudoScript::PlutusV2Script(x) => Self::PlutusV2Script(x),
|
||||
PseudoScript::PlutusV3Script(x) => Self::PlutusV3Script(x),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b, C, T> minicbor::Decode<'b, C> for PseudoScript<T>
|
||||
where
|
||||
T: minicbor::Decode<'b, ()>,
|
||||
{
|
||||
fn decode(
|
||||
d: &mut minicbor::Decoder<'b>,
|
||||
_ctx: &mut C,
|
||||
|
|
@ -1407,7 +1374,10 @@ impl<'b, C> minicbor::Decode<'b, C> for Script {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C> minicbor::Encode<C> for Script {
|
||||
impl<C, T> minicbor::Encode<C> for PseudoScript<T>
|
||||
where
|
||||
T: minicbor::Encode<C>,
|
||||
{
|
||||
fn encode<W: minicbor::encode::Write>(
|
||||
&self,
|
||||
e: &mut minicbor::Encoder<W>,
|
||||
|
|
|
|||
|
|
@ -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(&[]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ use pallas_crypto::hash::Hash;
|
|||
use pallas_primitives::{
|
||||
babbage::{
|
||||
DatumOption, ExUnits as PallasExUnits, NativeScript, NetworkId, PlutusData, PlutusV1Script,
|
||||
PlutusV2Script, PostAlonzoTransactionOutput, PseudoTransactionOutput, Redeemer,
|
||||
RedeemerTag, Script as PallasScript, TransactionBody, TransactionInput, Tx as BabbageTx,
|
||||
Value, WitnessSet,
|
||||
PlutusV2Script, PostAlonzoTransactionOutput, PseudoScript as PallasScript,
|
||||
PseudoTransactionOutput, Redeemer, RedeemerTag, TransactionBody, TransactionInput,
|
||||
Tx as BabbageTx, Value, WitnessSet,
|
||||
},
|
||||
Fragment,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,16 +56,16 @@ pub fn map_tx_output(x: &trv::MultiEraOutput) -> u5c::TxOutput {
|
|||
Some(babbage::PseudoDatumOption::Hash(x)) => x.to_vec().into(),
|
||||
_ => vec![].into(),
|
||||
},
|
||||
script: match x.script_ref().map(|x| x.deref()) {
|
||||
Some(babbage::Script::NativeScript(x)) => u5c::Script {
|
||||
script: u5c::script::Script::Native(map_native_script(x)).into(),
|
||||
script: match x.script_ref() {
|
||||
Some(babbage::PseudoScript::NativeScript(x)) => u5c::Script {
|
||||
script: u5c::script::Script::Native(map_native_script(&x)).into(),
|
||||
}
|
||||
.into(),
|
||||
Some(babbage::Script::PlutusV1Script(x)) => u5c::Script {
|
||||
Some(babbage::PseudoScript::PlutusV1Script(x)) => u5c::Script {
|
||||
script: u5c::script::Script::PlutusV1(x.0.to_vec().into()).into(),
|
||||
}
|
||||
.into(),
|
||||
Some(babbage::Script::PlutusV2Script(x)) => u5c::Script {
|
||||
Some(babbage::PseudoScript::PlutusV2Script(x)) => u5c::Script {
|
||||
script: u5c::script::Script::PlutusV2(x.0.to_vec().into()).into(),
|
||||
}
|
||||
.into(),
|
||||
|
|
@ -263,7 +263,7 @@ fn collect_all_scripts(tx: &trv::MultiEraTx) -> Vec<u5c::Script> {
|
|||
let ns = tx
|
||||
.native_scripts()
|
||||
.iter()
|
||||
.map(map_native_script)
|
||||
.map(|x| map_native_script(x.deref()))
|
||||
.map(|x| u5c::Script {
|
||||
script: u5c::script::Script::Native(x).into(),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue