diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index 6fdf8e7aee..fa57fbf028 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs @@ -729,18 +729,9 @@ toTxOutInAnyEra era (TxOutAnyEra addr' val' mDatumHash refScriptFp) = do addr <- hoistEither $ toAddressInAnyEra era addr' val <- hoistEither $ toTxOutValueInAnyEra era val' (datum, refScript) - <- caseByronToMaryOrAlonzoEraOnwards + <- caseByronToAlonzoOrBabbageEraOnwards (const $ pure (TxOutDatumNone, ReferenceScriptNone)) - (\w -> - caseAlonzoOnlyOrBabbageEraOnwards - (\wa -> - (,) - <$> toTxAlonzoDatum (alonzoEraOnlyToAlonzoEraOnwards wa) mDatumHash - <*> pure ReferenceScriptNone - ) - (\wbo -> toTxDatumReferenceScriptBabbage w wbo mDatumHash refScriptFp) - w - ) + (\w -> toTxDatumReferenceScriptBabbage w mDatumHash refScriptFp) era pure $ TxOut addr val datum refScript @@ -755,50 +746,27 @@ toTxOutInAnyEra era (TxOutAnyEra addr' val' mDatumHash refScriptFp) = do <$> firstExceptT TxCmdScriptFileError (readFileScriptInAnyLang fp) toTxDatumReferenceScriptBabbage :: () - => AlonzoEraOnwards era - -> BabbageEraOnwards era + => BabbageEraOnwards era -> TxOutDatumAnyEra -> ReferenceScriptAnyEra -> ExceptT TxCmdError IO (TxOutDatum CtxTx era, ReferenceScript era) - toTxDatumReferenceScriptBabbage sDataSupp inlineRefSupp cliDatum refScriptFp' = do - refScript <- getReferenceScript refScriptFp' inlineRefSupp + toTxDatumReferenceScriptBabbage bOn cliDatum refScriptFp' = do + let aOn = babbageEraOnwardsToAlonzoEraOnwards bOn + refScript <- getReferenceScript refScriptFp' bOn case cliDatum of TxOutDatumByNone -> do pure (TxOutDatumNone, refScript) TxOutDatumByHashOnly dh -> do - pure (TxOutDatumHash sDataSupp dh, refScript) + pure (TxOutDatumHash aOn dh, refScript) TxOutDatumByHashOf fileOrSdata -> do - sData <- firstExceptT TxCmdScriptDataError - $ readScriptDataOrFile fileOrSdata - pure (TxOutDatumHash sDataSupp $ hashScriptDataBytes sData, refScript) + sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile fileOrSdata + pure (TxOutDatumHash aOn $ hashScriptDataBytes sData, refScript) TxOutDatumByValue fileOrSdata -> do - sData <- firstExceptT TxCmdScriptDataError - $ readScriptDataOrFile fileOrSdata - pure (TxOutDatumInTx sDataSupp sData, refScript) + sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile fileOrSdata + pure (TxOutDatumInTx aOn sData, refScript) TxOutInlineDatumByValue fileOrSdata -> do - sData <- firstExceptT TxCmdScriptDataError - $ readScriptDataOrFile fileOrSdata - pure (TxOutDatumInline inlineRefSupp sData, refScript) - - toTxAlonzoDatum :: () - => AlonzoEraOnwards era - -> TxOutDatumAnyEra - -> ExceptT TxCmdError IO (TxOutDatum CtxTx era) - toTxAlonzoDatum supp cliDatum = - case cliDatum of - TxOutDatumByHashOnly h -> pure (TxOutDatumHash supp h) - TxOutDatumByHashOf sDataOrFile -> do - sData <- firstExceptT TxCmdScriptDataError - $ readScriptDataOrFile sDataOrFile - pure (TxOutDatumHash supp $ hashScriptDataBytes sData) - TxOutDatumByValue sDataOrFile -> do - sData <- firstExceptT TxCmdScriptDataError - $ readScriptDataOrFile sDataOrFile - pure (TxOutDatumInTx supp sData) - TxOutInlineDatumByValue _ -> - txFeatureMismatch era TxFeatureInlineDatums - TxOutDatumByNone -> pure TxOutDatumNone - + sData <- firstExceptT TxCmdScriptDataError $ readScriptDataOrFile fileOrSdata + pure (TxOutDatumInline bOn sData, refScript) -- TODO: Currently we specify the policyId with the '--mint' option on the cli -- and we added a separate '--policy-id' parser that parses the policy id for the