I have this function that is expecting type TxOutTx
, but it receives ChainIndexTxOut
. I'm trying to convert to the type required but encountering issues
getTradeDatum o = case txOutDatum (txOutTxOut o) of
Just h -> do
let [(_,datum)] = P.filter (\(h',_) -> h == h') (Map.toList (txData (txOutTxTx o)))
let parsedDatum = PlutusTx.fromBuiltinData (getDatum datum) :: Maybe TradeDatum
case parsedDatum of
Just b -> b
_ -> traceError "expected datum"
_ -> traceError "expected datum"
I get the error:
* Couldn't match expected type `TxOutTx'
with actual type `ChainIndexTxOut'
* In the first argument of `txOutTxOut', namely `o'
In the first argument of `txOutDatum', namely `(txOutTxOut o)'
In the expression: txOutDatum (txOutTxOut o)
|
586 | getTradeDatum o = case txOutDatum (txOutTxOut o) of
|
I've tried the following solution, changing the single line below, because _ciTxOutValue
has worked for me before:
getTradeDatum o = case _ciTxOutDatum o of
But then I get this error:
error:
* Couldn't match expected type `Either DatumHash Datum'
with actual type `Maybe DatumHash'
* In the pattern: Just h