I'm getting utxos like so:
utxos <- utxosAt tradeAddress
And then getting the value o
(oref, o) <- Map.toList utxos, case getTradeDatum o of (Offer details) -> "0" .....
Then using o
in txOutValue
:
txOutValue $ txOutTxOut o
However txOutValue
I have this function that is expecting type TxOutTx where oTxOutTx
is of type ChainIndexTxOut, but it receives ChainIndexTxOut
. How can II'm trying to convert ChainIndexTxOut to the type TxOutTx?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"
Here isI get the actual error:
* Couldn't match expected type `TxOutTx'
with actual type `ChainIndexTxOut'
* In the first argument of `txOutTxOut', namely `o'
In the secondfirst argument of `($)'`txOutDatum', namely `txOutTxOut`(txOutTxOut o'o)'
In the expression: txOutValuetxOutDatum $(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