Skip to main content
added 689 characters in body
Source Link

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 txOutValueI 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

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 is expecting type TxOutTx where o is of type ChainIndexTxOut. How can I convert ChainIndexTxOut to type TxOutTx?

Here is the actual error:

    * Couldn't match expected type `TxOutTx'
                  with actual type `ChainIndexTxOut'
    * In the first argument of `txOutTxOut', namely `o'
      In the second argument of `($)', namely `txOutTxOut o'
      In the expression: txOutValue $ txOutTxOut o

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
Source Link

Convert ChainIndexTxOut to TxOutTx

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 is expecting type TxOutTx where o is of type ChainIndexTxOut. How can I convert ChainIndexTxOut to type TxOutTx?

Here is the actual error:

    * Couldn't match expected type `TxOutTx'
                  with actual type `ChainIndexTxOut'
    * In the first argument of `txOutTxOut', namely `o'
      In the second argument of `($)', namely `txOutTxOut o'
      In the expression: txOutValue $ txOutTxOut o