Skip to content

Commit

Permalink
Delete AlonzEraOnly and the ability to use datum-hash in the Alonzo era
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 19, 2023
1 parent 942eaf0 commit f17129d
Showing 1 changed file with 13 additions and 45 deletions.
58 changes: 13 additions & 45 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f17129d

Please sign in to comment.