Skip to content

Commit

Permalink
Simplify by using head
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Feb 6, 2023
1 parent 23a326b commit c1fa047
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions hydra-plutus/src/Hydra/Contract/Commit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ validator (_party, _headScriptHash, _commit, headId) r ctx =
traceIfFalse "ST is missing in the output" (hasST headId headOutputValue)
where
headOutputValue =
case txInfoOutputs (scriptContextTxInfo ctx) of
[] -> mempty
(headOutput : _otherOutputs) -> txOutValue headOutput
txOutValue . head $ txInfoOutputs (scriptContextTxInfo ctx)

compiledValidator :: CompiledCode ValidatorType
compiledValidator =
Expand Down
5 changes: 3 additions & 2 deletions hydra-plutus/src/Hydra/Contract/Head.hs
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,9 @@ findParticipationTokens headCurrency (Value val) =

headOutputDatum :: ScriptContext -> Datum
headOutputDatum ScriptContext{scriptContextTxInfo} =
let headOutput = head (txInfoOutputs scriptContextTxInfo)
in findTxOutDatum scriptContextTxInfo headOutput
findTxOutDatum scriptContextTxInfo (head $ txInfoOutputs txInfo)
where
ScriptContext{scriptContextTxInfo = txInfo} = ctx
{-# INLINEABLE headOutputDatum #-}

findTxOutDatum :: TxInfo -> TxOut -> Datum
Expand Down

0 comments on commit c1fa047

Please sign in to comment.