Skip to content

Commit

Permalink
Keep non spending redeemers
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Oct 7, 2024
1 parent 6513996 commit 88eae06
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion hydra-tx/src/Hydra/Tx/Commit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ commitTx networkId scriptRegistry headId party commitBlueprintTx (initialInput,
in tx
& bodyTxL . inputsTxBodyL .~ newInputs
& bodyTxL . referenceInputsTxBodyL <>~ Set.singleton (toLedgerTxIn initialScriptRef)
& witsTxL . rdmrsTxWitsL .~ mkRedeemers newRedeemers newInputs
& witsTxL . rdmrsTxWitsL <>~ Redeemers (toList resolveNonSpendingRedeemers)
& witsTxL . rdmrsTxWitsL <>~ mkRedeemers newRedeemers newInputs

-- Make redeemers (with zeroed units) from a TxIn -> Data map and a set of transaction inputs
mkRedeemers resolved inputs =
Expand All @@ -103,6 +104,19 @@ commitTx networkId scriptRegistry headId party commitBlueprintTx (initialInput,
)
(unRedeemers $ tx ^. witsTxL . rdmrsTxWitsL)

resolveNonSpendingRedeemers tx =
Map.foldMapWithKey
( \p (d, ex) ->
case redeemerPointerInverse (tx ^. bodyTxL) p of
SJust (ConwayMinting (AsIxItem i _)) -> [(ConwayMinting (AsIx i), (d, ex))]
SJust (ConwayRewarding (AsIxItem i _)) -> [(ConwayRewarding (AsIx i), (d, ex))]
SJust (ConwayCertifying (AsIxItem i _)) -> [(ConwayCertifying (AsIx i), (d, ex))]
SJust (ConwayProposing (AsIxItem i _)) -> [(ConwayProposing (AsIx i), (d, ex))]
SJust (ConwayVoting (AsIxItem i _)) -> [(ConwayVoting (AsIx i), (d, ex))]
SJust (ConwaySpending (AsIxItem _ _)) -> []
SNothing -> []
)
(unRedeemers $ tx ^. witsTxL . rdmrsTxWitsL)
initialScriptRef =
fst (initialReference scriptRegistry)

Expand Down

0 comments on commit 88eae06

Please sign in to comment.