Closed 0xd34df00d closed 1 year ago
For the record, the diff for (2) is fairly trivial:
diff --git a/cooked-validators/src/Cooked/MockChain/Monad/Direct.hs b/cooked-validators/src/Cooked/MockChain/Monad/Direct.hs
index 58fb322..ea34f3d 100644
--- a/cooked-validators/src/Cooked/MockChain/Monad/Direct.hs
+++ b/cooked-validators/src/Cooked/MockChain/Monad/Direct.hs
@@ -377,26 +377,27 @@ utxosSuchThisAndThat' addrPred datumPred = do
case cTxOutToCito out of
Nothing -> pure Nothing
Just cito -> do
- mDatum <- extractDatum oref cito $ Pl.fromCardanoTxOutDatumHash cDatum
+ mDatum <- extractDatum oref cito $ Pl.fromCardanoTxOutDatum cDatum
pure $
if datumPred mDatum (Pl._ciTxOutValue cito)
then Just (cito, mDatum)
else Nothing
- extractDatum :: Pl.TxOutRef -> Pl.ChainIndexTxOut -> Maybe Pl.DatumHash -> MockChainT m (Maybe a)
- extractDatum oref cito Nothing
+ extractDatum :: Pl.TxOutRef -> Pl.ChainIndexTxOut -> Pl.OutputDatum -> MockChainT m (Maybe a)
+ extractDatum oref cito Pl.NoOutputDatum
| isScriptCito cito = fail $ "ScriptCredential with no datum hash: " ++ show oref
| otherwise = pure Nothing
- extractDatum oref _ (Just dh) = do
+ extractDatum oref _ (Pl.OutputDatumHash dh) = do
managedDatums <- gets mcstDatums
Just <$> case dh `M.lookup` managedDatums of
-- TODO PORT previously this was an error only for script datums,
-- but I think it should be an error for any datum hash
-- that's mentioned but cannot be found in managedDatums.
Nothing -> fail $ "Unmanaged datum with hash: " ++ show dh ++ " at: " ++ show oref
- Just datum -> maybe failBadConvert pure (Pl.fromBuiltinData $ Pl.getDatum datum)
- where
- failBadConvert = fail $ "Can't convert from builtin data at: " ++ show oref ++ "; are you sure this is the right type?"
+ Just datum -> maybe (failBadConvert oref) pure (Pl.fromBuiltinData $ Pl.getDatum datum)
+ extractDatum oref _ (Pl.OutputDatum datum) = maybe (failBadConvert oref) pure (Pl.fromBuiltinData $ Pl.getDatum datum)
+
+ failBadConvert oref = fail $ "Can't convert from builtin data at: " ++ show oref ++ "; are you sure this is the right type?"
-- | Check 'utxosSuchThat' for details
utxosSuchThat' ::
Right now,
utxosSuchThisAndThat'
gets the datum hash viafromCardanoTxOutDatumHash
and uses that to look up the datum in the map of managed datums. Inline datums aren't managed, so we could either (1) make them managed, or (2) usefromCardanoTxOutDatum
and discriminate betweenOutputDatum
andOutputDatumHash
.I tried the second approach briefly, but it gives me
on some tests, the cause of which I don't understand.