Skip to content

Commit

Permalink
Replace use of readScriptWitnessFiles with readCertificateScriptWitne…
Browse files Browse the repository at this point in the history
…sses
  • Loading branch information
Jimbo4350 committed Jan 22, 2025
1 parent b33ae93 commit c0c1f37
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import Cardano.CLI.EraBased.Commands.Transaction
import qualified Cardano.CLI.EraBased.Commands.Transaction as Cmd
import Cardano.CLI.EraBased.Run.Genesis.Common (readProtocolParameters)
import Cardano.CLI.EraBased.Run.Query
import Cardano.CLI.EraBased.Script.Certificate.Read
import Cardano.CLI.EraBased.Script.Certificate.Types (CertificateScriptWitness (..))
import Cardano.CLI.EraBased.Script.Mint.Read
import Cardano.CLI.EraBased.Script.Mint.Types
import Cardano.CLI.EraBased.Script.Spend.Read
Expand Down Expand Up @@ -161,14 +163,15 @@ runTransactionBuildCmd
readSpendScriptWitnesses eon txins

let spendingScriptWitnesses = mapMaybe (fmap sswScriptWitness . snd) txinsAndMaybeScriptWits

certFilesAndMaybeScriptWits <-
firstExceptT TxCmdScriptWitnessError $ readScriptWitnessFiles eon certificates
firstExceptT TxCmdCliScriptWitnessError $ readCertificateScriptWitnesses eon certificates

-- TODO: Conway Era - How can we make this more composable?
certsAndMaybeScriptWits <-
sequence
[ fmap
(,mSwit)
(,cswScriptWitness <$> mSwit)
( firstExceptT TxCmdReadTextViewFileError . newExceptT $
shelleyBasedEraConstraints eon $
readFileTextEnvelope AsCertificate (File certFile)
Expand Down Expand Up @@ -265,7 +268,7 @@ runTransactionBuildCmd
getAllReferenceInputs
spendingScriptWitnesses
(map mswScriptWitness $ snd usedToGetReferenceInputs)
certsAndMaybeScriptWits
(mapMaybe snd certsAndMaybeScriptWits)
withdrawalsAndMaybeScriptWits
votingProceduresAndMaybeScriptWits
proposals
Expand Down Expand Up @@ -413,8 +416,8 @@ runTransactionBuildEstimateCmd -- TODO change type
readSpendScriptWitnesses sbe txins

certFilesAndMaybeScriptWits <-
firstExceptT TxCmdScriptWitnessError $
readScriptWitnessFiles sbe certificates
firstExceptT TxCmdCliScriptWitnessError $
readCertificateScriptWitnesses sbe certificates

withdrawalsAndMaybeScriptWits <-
firstExceptT TxCmdScriptWitnessError $
Expand Down Expand Up @@ -468,7 +471,7 @@ runTransactionBuildEstimateCmd -- TODO change type
shelleyBasedEraConstraints sbe $
sequence
[ fmap
(,mSwit)
(,cswScriptWitness <$> mSwit)
( firstExceptT TxCmdReadTextViewFileError . newExceptT $
readFileTextEnvelope AsCertificate (File certFile)
)
Expand Down Expand Up @@ -655,8 +658,8 @@ runTransactionBuildRawCmd
readSpendScriptWitnesses eon txIns

certFilesAndMaybeScriptWits <-
firstExceptT TxCmdScriptWitnessError $
readScriptWitnessFiles eon certificates
firstExceptT TxCmdCliScriptWitnessError $
readCertificateScriptWitnesses eon certificates

withdrawalsAndMaybeScriptWits <-
firstExceptT TxCmdScriptWitnessError $
Expand Down Expand Up @@ -715,7 +718,7 @@ runTransactionBuildRawCmd
shelleyBasedEraConstraints eon $
sequence
[ fmap
(,mSwit)
(,cswScriptWitness <$> mSwit)
( firstExceptT TxCmdReadTextViewFileError . newExceptT $
readFileTextEnvelope AsCertificate (File certFile)
)
Expand Down Expand Up @@ -907,7 +910,7 @@ constructTxBodyContent
getAllReferenceInputs
(map sswScriptWitness $ mapMaybe snd inputsAndMaybeScriptWits)
(map mswScriptWitness $ snd valuesWithScriptWits)
certsAndMaybeScriptWits
(mapMaybe snd certsAndMaybeScriptWits)
withdrawals
votingProcedures
proposals
Expand Down Expand Up @@ -1054,7 +1057,7 @@ runTxBuild
getAllReferenceInputs
(map sswScriptWitness $ mapMaybe snd inputsAndMaybeScriptWits)
(map mswScriptWitness $ snd valuesWithScriptWits)
certsAndMaybeScriptWits
(mapMaybe snd certsAndMaybeScriptWits)
withdrawals
votingProcedures
proposals
Expand Down Expand Up @@ -1221,7 +1224,7 @@ validateTxInsReference sbe allRefIns = do
getAllReferenceInputs
:: [ScriptWitness WitCtxTxIn era]
-> [ScriptWitness WitCtxMint era]
-> [(Certificate era, Maybe (ScriptWitness WitCtxStake era))]
-> [ScriptWitness WitCtxStake era]
-> [(StakeAddress, Lovelace, Maybe (ScriptWitness WitCtxStake era))]
-> [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
-> [(Proposal era, Maybe (ScriptWitness WitCtxStake era))]
Expand All @@ -1231,14 +1234,14 @@ getAllReferenceInputs
getAllReferenceInputs
spendingWitnesses
mintWitnesses
certFiles
certScriptWitnesses
withdrawals
votingProceduresAndMaybeScriptWits
propProceduresAnMaybeScriptWits
readOnlyRefIns = do
let txinsWitByRefInputs = map getScriptWitnessReferenceInput spendingWitnesses
mintingRefInputs = map getScriptWitnessReferenceInput mintWitnesses
certsWitByRefInputs = [getScriptWitnessReferenceInput sWit | (_, Just sWit) <- certFiles]
certsWitByRefInputs = map getScriptWitnessReferenceInput certScriptWitnesses
withdrawalsWitByRefInputs = [getScriptWitnessReferenceInput sWit | (_, _, Just sWit) <- withdrawals]
votesWitByRefInputs = [getScriptWitnessReferenceInput sWit | (_, Just sWit) <- votingProceduresAndMaybeScriptWits]
propsWitByRefInputs = [getScriptWitnessReferenceInput sWit | (_, Just sWit) <- propProceduresAnMaybeScriptWits]
Expand Down

0 comments on commit c0c1f37

Please sign in to comment.