fix(interop): map missing u5c redeemers (#490)
This commit is contained in:
parent
a85619623d
commit
4fbca7b8ce
6 changed files with 95 additions and 14 deletions
|
|
@ -18,6 +18,7 @@ pallas-codec = { version = "=0.28.0", path = "../pallas-codec" }
|
|||
hex = "0.4.3"
|
||||
thiserror = "1.0.31"
|
||||
paste = "1.0.14"
|
||||
itertools = "0.13.0"
|
||||
|
||||
# TODO: remove once GenesisValue moves into new genesis crate
|
||||
serde = "1.0.155"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use std::{borrow::Cow, collections::HashSet, ops::Deref};
|
||||
|
||||
use itertools::Itertools;
|
||||
use pallas_codec::{minicbor, utils::KeepRaw};
|
||||
use pallas_crypto::hash::Hash;
|
||||
use pallas_primitives::{
|
||||
|
|
@ -209,6 +210,27 @@ impl<'b> MultiEraTx<'b> {
|
|||
raw
|
||||
}
|
||||
|
||||
pub fn mints_sorted_set(&self) -> Vec<MultiEraPolicyAssets> {
|
||||
let mut raw = self.mints();
|
||||
|
||||
raw.sort_by_key(|m| *m.policy());
|
||||
|
||||
raw
|
||||
}
|
||||
|
||||
pub fn withdrawals_sorted_set(&self) -> Vec<(&[u8], u64)> {
|
||||
match self.withdrawals() {
|
||||
MultiEraWithdrawals::NotApplicable | MultiEraWithdrawals::Empty => {
|
||||
std::iter::empty().collect()
|
||||
}
|
||||
MultiEraWithdrawals::AlonzoCompatible(x) => x
|
||||
.iter()
|
||||
.map(|(k, v)| (k.as_slice(), *v))
|
||||
.sorted_by_key(|(k, _)| *k)
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the transaction reference inputs
|
||||
///
|
||||
/// NOTE: It is possible for this to return duplicates. See
|
||||
|
|
|
|||
|
|
@ -161,6 +161,26 @@ impl<'b> MultiEraTx<'b> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn find_mint_redeemer(&self, mint_order: u32) -> Option<MultiEraRedeemer> {
|
||||
self.redeemers().into_iter().find(|r| {
|
||||
r.tag() == pallas_primitives::conway::RedeemerTag::Mint && r.index() == mint_order
|
||||
})
|
||||
}
|
||||
|
||||
pub fn find_withdrawal_redeemer(&self, withdrawal_order: u32) -> Option<MultiEraRedeemer> {
|
||||
self.redeemers().into_iter().find(|r| {
|
||||
r.tag() == pallas_primitives::conway::RedeemerTag::Reward
|
||||
&& r.index() == withdrawal_order
|
||||
})
|
||||
}
|
||||
|
||||
pub fn find_certificate_redeemer(&self, certificate_order: u32) -> Option<MultiEraRedeemer> {
|
||||
self.redeemers().into_iter().find(|r| {
|
||||
r.tag() == pallas_primitives::conway::RedeemerTag::Cert
|
||||
&& r.index() == certificate_order
|
||||
})
|
||||
}
|
||||
|
||||
pub fn plutus_v2_scripts(&self) -> &[PlutusV2Script] {
|
||||
match self {
|
||||
Self::Byron(_) => &[],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue