Skip to content

Commit

Permalink
Actually decode redeemer data in observeAbortTx
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Oct 28, 2021
1 parent bcc4361 commit 8687121
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions hydra-node/src/Hydra/Chain/Direct/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,14 @@ observeAbortTx ::
observeAbortTx utxo ValidatedTx{wits, body} = do
-- XXX(SN): not hard-code policyId
headInput <- fmap fst . findScriptOutput utxo . plutusScript $ Head.validatorScript policyId
case decodeHeadRedeemer headInput of
Just Head.Abort -> Just (OnAbortTx, Final)
decodeHeadRedeemer headInput >>= \case
Head.Abort -> pure (OnAbortTx, Final)
_ -> Nothing
where
decodeHeadRedeemer txIn =
Set.lookupIndex txIn (inputs body) >>= \idx -> Map.lookup (RdmrPtr Spend (fromIntegral idx)) (unRedeemers (txrdmrs wits))

decodeData d s = s <|> fromData (getPlutusData d)

redeemerData = fmap fst . Map.elems . unRedeemers $ txrdmrs wits
decodeHeadRedeemer txIn = do
idx <- Set.lookupIndex txIn (inputs body)
(d, _exUnits) <- Map.lookup (RdmrPtr Spend (fromIntegral idx)) (unRedeemers (txrdmrs wits))
fromData (getPlutusData d)

findScriptOutput ::
Map (TxIn StandardCrypto) (TxOut Era) ->
Expand Down

0 comments on commit 8687121

Please sign in to comment.