-
Notifications
You must be signed in to change notification settings - Fork 721
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
cardano-cli: simplifiy the consumption of 'InputTxBodyOrTxFile` #4647
Conversation
a1bb2ad
to
767379a
Compare
e2ed0a4
to
6b62c80
Compare
Also: * extend transaction view command with new options * extend transcation assemble command to allow adding extra witnesses.
6b62c80
to
d9ae0c7
Compare
IncompleteCddlFormattedTx anyTx -> do | ||
InAnyShelleyBasedEra _era unwitTx <- | ||
anyTx <- readFileTxBody txbodyFile `rescue` ShelleyTxCmdCddlError | ||
--TODO: in principle we should be able to support Byron era txs too |
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.
Can you say what currently happens with Byron era transactions?
TextFormat -> writeFileTextEnvelope oFp Nothing tx `rescue` ShelleyTxCmdWriteFileError | ||
|
||
rescue :: Functor m => m (Either x a) -> (x -> y) -> ExceptT y m a | ||
rescue action except = firstExceptT except $ newExceptT action |
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.
We should probably move this to a re-usable location, but not right now.
firstExceptT ShelleyTxCmdWriteFileError . newExceptT $ | ||
writeTxFileTextEnvelopeCddl oFp tx | ||
runTxSignWitness inputTx witnessFiles (OutputFile oFp) = do | ||
(InAnyCardanoEra era input) <- readInputTxBodyOrTxFile inputTx `rescue` ShelleyTxCmdCddlError |
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 in favour of dropping the redundant parens in this bind.
CompleteTx tx -> friendlyTxBS era tx | ||
IncompleteTx (UnwitnessedCliFormattedTxBody txBody) -> friendlyTxBodyBS era txBody | ||
-- In the IncompleteCddlFormattedTx case, the legacy format | ||
-- takes the body of the tx and converts the tx to a tx-body |
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.
Remove double space after tx
.
-- and prints that using `friendlyTxBodyBS era body`. | ||
-- Any preexisting witnesses (that may be there ?!? ) are discarded !! | ||
-- Would make more sense: | ||
-- IncompleteTx (IncompleteCddlFormattedTx tx) -> friendlyTxBS era tx |
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.
This is an interesting point. @Jimbo4350 @LudvikGalois
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.
Left some review comments
case eTxBody of | ||
Left e -> fmap (IncompleteCddlFormattedTx . unCddlTx) <$> acceptTxCDDLSerialisation e | ||
Right txBody -> return $ Right $ UnwitnessedCliFormattedTxBody txBody | ||
data IncompleteTx 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.
What is the benefit of adding the era
parameter? This has further complicated the code without any obvious benefit.
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 am highly skeptical of the changes to data IncompleteTx
. I don't see any obvious benefit for the increase in code complexity.
The old definition was the root-cause for the code-duplication in |
Lets hold off on the refactor for now as:
Will be eliminated when we remove the cli format, which I will like to do in the next cli release. Once we do that we can revisit the refactor. |
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.
This PR makes is easier to use CLI arguments of type
InputTxBodyOrTxFile
IncompleteTx
TxOrTxBody
readInputTxBodyOrTxFile :: InputTxBodyOrTxFile -> IO (Either CddlError (InAnyCardanoEra CompleteOrIncompleteTx)