Skip to content

Commit

Permalink
feat: start mapping mint redeemers
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Jul 15, 2024
1 parent a856196 commit 7536a3c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pallas-traverse/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ impl<'b> MultiEraTx<'b> {
raw
}

pub fn mints_sorted_set(&self) -> Vec<MultiEraPolicyAssets> {
todo!()
}

/// Return the transaction reference inputs
///
/// NOTE: It is possible for this to return duplicates. See
Expand Down
6 changes: 6 additions & 0 deletions pallas-traverse/src/witnesses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ 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 plutus_v2_scripts(&self) -> &[PlutusV2Script] {
match self {
Self::Byron(_) => &[],
Expand Down
15 changes: 12 additions & 3 deletions pallas-utxorpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl<C: LedgerContext> Mapper<C> {
u5c::Multiasset {
policy_id: x.policy().to_vec().into(),
assets: x.assets().iter().map(|x| self.map_asset(x)).collect(),
redeemer: None, // TODO
redeemer: None,
}
}

Expand Down Expand Up @@ -542,9 +542,18 @@ impl<C: LedgerContext> Mapper<C> {
.map(|x| self.map_withdrawals(x))
.collect(),
mint: tx
.mints()
.mints_sorted_set()
.iter()
.map(|x| self.map_policy_assets(x))
.enumerate()
.map(|(order, x)| {
let mut ma = self.map_policy_assets(x);

ma.redeemer = tx
.find_mint_redeemer(order as u32)
.map(|r| self.map_redeemer(&r));

ma
})
.collect(),
reference_inputs: tx
.reference_inputs()
Expand Down

0 comments on commit 7536a3c

Please sign in to comment.