-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add certificates to CLI interface in compatible transaction-sign
#972
base: master
Are you sure you want to change the base?
Add certificates to CLI interface in compatible transaction-sign
#972
Conversation
bd0fc1e
to
26a1017
Compare
26a1017
to
dbc9255
Compare
6473d28
to
ac19e61
Compare
(protocolUpdates, votes) :: (AnyProtocolUpdate era, AnyVote era) <- | ||
caseShelleyToBabbageOrConwayEraOnwards | ||
( const $ do | ||
prop <- maybe (pure $ NoPParamsUpdate sbe) readUpdateProposalFile mUpdateProposal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's not possible to move this one out of the case, to share the code between the two branches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really, those are two different files with different purposes
Code LGTM ✔️ cc @Jimbo4350 for approval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Two minor comments.
|
||
instance Error CompatibleTransactionError where | ||
prettyError = \case | ||
CompatibleTxOutError e -> renderTxCmdError e | ||
CompatibleTxCmdError e -> renderTxCmdError e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the name change? This error is TxOut
related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, TxCmdError
is much broader than just transaction outputs. I'm also reusing it in line 296.
|
||
runCompatibleTransactionCmd | ||
:: CompatibleTransactionCmds era -> ExceptT CompatibleTransactionError IO () | ||
:: forall era |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary forall era
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using scopedtypevariables to have the same era
in functions in where
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using it for readability purposes? If not you can remove all mentions of era
in the function body of runCompatibleTransactionCmd
. It still builds:
diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs b/cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs
index 25468707e..606a0945d 100644
--- a/cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs
+++ b/cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs
@@ -2,7 +2,6 @@
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
-{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
module Cardano.CLI.Compatible.Transaction
@@ -218,8 +217,7 @@ instance Error CompatibleTransactionError where
CompatibleScriptWitnessError e -> renderScriptWitnessError e
runCompatibleTransactionCmd
- :: forall era
- . CompatibleTransactionCmds era
+ :: CompatibleTransactionCmds era
-> ExceptT CompatibleTransactionError IO ()
runCompatibleTransactionCmd
( CreateCompatibleSignedTransaction
@@ -243,7 +241,7 @@ runCompatibleTransactionCmd
firstExceptT CompatibleScriptWitnessError $
readScriptWitnessFiles sbe certificates
- certsAndMaybeScriptWits :: [(Certificate era, Maybe (ScriptWitness WitCtxStake era))] <-
+ certsAndMaybeScriptWits <-
shelleyBasedEraConstraints sbe $
sequence
[ fmap
@@ -254,7 +252,7 @@ runCompatibleTransactionCmd
| (CertificateFile certFile, mSwit) <- certFilesAndMaybeScriptWits
]
- (protocolUpdates, votes) :: (AnyProtocolUpdate era, AnyVote era) <-
+ (protocolUpdates, votes) <-
caseShelleyToBabbageOrConwayEraOnwards
( const $ do
prop <- maybe (pure $ NoPParamsUpdate sbe) readUpdateProposalFile mUpdateProposal
@@ -326,26 +324,17 @@ runCompatibleTransactionCmd
newExceptT $
writeTxFileTextEnvelopeCddl sbe outputFp signedTx
where
- convertCertificates
- :: [(Certificate era, Maybe (ScriptWitness WitCtxStake era))]
- -> TxCertificates BuildTx era
convertCertificates certsAndScriptWitnesses =
TxCertificates sbe certs $ BuildTxWith reqWits
where
certs = map fst certsAndScriptWitnesses
reqWits = fromList $ mapMaybe convert' certsAndScriptWitnesses
- convert'
- :: (Certificate era, Maybe (ScriptWitness WitCtxStake era))
- -> Maybe (StakeCredential, Witness WitCtxStake era)
convert' (cert, mScriptWitnessFiles) = do
sCred <- selectStakeCredentialWitness cert
Just . (sCred,) $ case mScriptWitnessFiles of
Just sWit -> ScriptWitness ScriptWitnessForStakeAddr sWit
Nothing -> KeyWitness KeyWitnessForStakeAddr
- validateTxInsReference
- :: [TxIn]
- -> Either TxCmdError (TxInsReference era)
validateTxInsReference [] = return TxInsReferenceNone
validateTxInsReference allRefIns = do
let era = toCardanoEra era
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's mostly for readability. If you prefer to not have type signatures, I can remove them.
I've cherry-picked the non-SRP commit to #986 where it's needed for the version of api that's about to be released. However, I see now that there are a few minor comments still needing to be addressed. Could you please resolve those and then I can re-pick the commit. |
@neilmayhew thanks for letting me know. I'll merge this PR separately - I've disabled the feature for now in the integration branch. |
e3c153b
to
d554312
Compare
d554312
to
3b889d3
Compare
3b889d3
to
f7346ef
Compare
* Added reference test for `compatible conway transaction singed-transaction`
f7346ef
to
0521006
Compare
Changelog
Context
Requires:
createCompatibleSignedTx
. cardano-api#691Checklist