-
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 era-independent "debug transaction view" command #840
Conversation
c461329
to
414388c
Compare
] | ||
++ ( caseByronToBabbageOrConwaysEraOnwards era $ |
Check notice
Code scanning / HLint
Redundant $ Note
Found:
caseByronToBabbageOrConwaysEraOnwards era
$ (\ cOnwards
-> case txProposalProcedures of
Nothing -> []
Just (Featured _ TxProposalProceduresNone) -> []
Just (Featured _ (TxProposalProcedures lProposals _witnesses))
-> ["governance actions"
.= (friendlyLedgerProposals cOnwards $ toList lProposals)])
Perhaps:
caseByronToBabbageOrConwaysEraOnwards
era
(\ cOnwards
-> case txProposalProcedures of
Nothing -> []
Just (Featured _ TxProposalProceduresNone) -> []
Just (Featured _ (TxProposalProcedures lProposals _witnesses))
-> ["governance actions"
.= (friendlyLedgerProposals cOnwards $ toList lProposals)])
["governance actions" .= (friendlyLedgerProposals cOnwards $ toList lProposals)] | ||
) | ||
) | ||
++ ( caseByronToBabbageOrConwaysEraOnwards era $ |
Check notice
Code scanning / HLint
Redundant $ Note
Found:
caseByronToBabbageOrConwaysEraOnwards era
$ (\ cOnwards
-> case txVotingProcedures of
Nothing -> []
Just (Featured _ TxVotingProceduresNone) -> []
Just (Featured _ (TxVotingProcedures votes _witnesses))
-> ["voters" .= friendlyVotingProcedures cOnwards votes])
Perhaps:
caseByronToBabbageOrConwaysEraOnwards
era
(\ cOnwards
-> case txVotingProcedures of
Nothing -> []
Just (Featured _ TxVotingProceduresNone) -> []
Just (Featured _ (TxVotingProcedures votes _witnesses))
-> ["voters" .= friendlyVotingProcedures cOnwards votes])
) | ||
) | ||
++ ( caseByronToBabbageOrConwaysEraOnwards era $ | ||
const $ |
Check notice
Code scanning / HLint
Redundant $ Note
Found:
const
$ ["currentTreasuryValue"
.= toJSON (unFeatured <$> txCurrentTreasuryValue)]
Perhaps:
const
["currentTreasuryValue"
.= toJSON (unFeatured <$> txCurrentTreasuryValue)]
["currentTreasuryValue" .= toJSON (unFeatured <$> txCurrentTreasuryValue)] | ||
) | ||
++ ( caseByronToBabbageOrConwaysEraOnwards era $ | ||
const $ |
Check notice
Code scanning / HLint
Redundant $ Note
Found:
const
$ ["treasuryDonation"
.= toJSON (unFeatured <$> txTreasuryDonation)]
Perhaps:
const
["treasuryDonation" .= toJSON (unFeatured <$> txTreasuryDonation)]
( \sbe -> do | ||
caseShelleyToBabbageOrConwayEraOnwards | ||
(const []) | ||
(\cOnwards -> f cOnwards) |
Check warning
Code scanning / HLint
Avoid lambda Warning
Found:
(\ cOnwards -> f cOnwards)
Perhaps:
f
317ad96
to
1bdc3df
Compare
cc @mkoura |
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.
Looks good. Just a lint
++ ( caseByronToBabbageOrConwaysEraOnwards | ||
( \cOnwards -> | ||
case txProposalProcedures of | ||
Nothing -> [] | ||
Just (Featured _ TxProposalProceduresNone) -> [] | ||
Just (Featured _ (TxProposalProcedures lProposals _witnesses)) -> | ||
["governance actions" .= (friendlyLedgerProposals cOnwards $ toList lProposals)] | ||
) | ||
era | ||
) | ||
++ ( caseByronToBabbageOrConwaysEraOnwards | ||
( \cOnwards -> | ||
case txVotingProcedures of | ||
Nothing -> [] | ||
Just (Featured _ TxVotingProceduresNone) -> [] | ||
Just (Featured _ (TxVotingProcedures votes _witnesses)) -> | ||
["voters" .= friendlyVotingProcedures cOnwards votes] | ||
) | ||
era | ||
) | ||
++ ( caseByronToBabbageOrConwaysEraOnwards | ||
(const ["currentTreasuryValue" .= toJSON (unFeatured <$> txCurrentTreasuryValue)]) | ||
era | ||
) | ||
++ ( caseByronToBabbageOrConwaysEraOnwards | ||
(const ["treasuryDonation" .= toJSON (unFeatured <$> txTreasuryDonation)]) | ||
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.
++ ( caseByronToBabbageOrConwaysEraOnwards | |
( \cOnwards -> | |
case txProposalProcedures of | |
Nothing -> [] | |
Just (Featured _ TxProposalProceduresNone) -> [] | |
Just (Featured _ (TxProposalProcedures lProposals _witnesses)) -> | |
["governance actions" .= (friendlyLedgerProposals cOnwards $ toList lProposals)] | |
) | |
era | |
) | |
++ ( caseByronToBabbageOrConwaysEraOnwards | |
( \cOnwards -> | |
case txVotingProcedures of | |
Nothing -> [] | |
Just (Featured _ TxVotingProceduresNone) -> [] | |
Just (Featured _ (TxVotingProcedures votes _witnesses)) -> | |
["voters" .= friendlyVotingProcedures cOnwards votes] | |
) | |
era | |
) | |
++ ( caseByronToBabbageOrConwaysEraOnwards | |
(const ["currentTreasuryValue" .= toJSON (unFeatured <$> txCurrentTreasuryValue)]) | |
era | |
) | |
++ ( caseByronToBabbageOrConwaysEraOnwards | |
(const ["treasuryDonation" .= toJSON (unFeatured <$> txTreasuryDonation)]) | |
era | |
++ ( concat | |
( caseByronToBabbageOrConwaysEraOnwards | |
( \cOnwards -> | |
[ case txProposalProcedures of | |
Nothing -> [] | |
Just (Featured _ TxProposalProceduresNone) -> [] | |
Just (Featured _ (TxProposalProcedures lProposals _witnesses)) -> | |
["governance actions" .= (friendlyLedgerProposals cOnwards $ toList lProposals)] | |
, case txVotingProcedures of | |
Nothing -> [] | |
Just (Featured _ TxVotingProceduresNone) -> [] | |
Just (Featured _ (TxVotingProcedures votes _witnesses)) -> | |
["voters" .= friendlyVotingProcedures cOnwards votes] | |
, ["currentTreasuryValue" .= toJSON (unFeatured <$> txCurrentTreasuryValue)] | |
, ["treasuryDonation" .= toJSON (unFeatured <$> txTreasuryDonation)] | |
] | |
) | |
era | |
) |
We can factor caseByronToBabbageOrConwaysEraOnwards
out by using concat
. We could also use concatMap
but this way we don't even need the const
s. Or we could use catMaybes
, that would enforce that it is only one item, but probably much less readable
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 think the code is easier to understand by not using concat
, because it avoids nesting. And so it keeps the "one blob of code <==> one item in the list" structure that the items above have 👍
So I'll pass on this suggestion 👍
Maybe @Jimbo4350 you want to have a look before merging |
caseByronToBabbageOrConwaysEraOnwards :: (ConwayEraOnwards era -> [a]) -> CardanoEra era -> [a] | ||
caseByronToBabbageOrConwaysEraOnwards f = | ||
caseByronOrShelleyBasedEra | ||
[] | ||
(caseShelleyToBabbageOrConwayEraOnwards (const []) f) |
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.
That's doing the same same as
monoidForEraInEonA
:: ()
=> Eon eon
=> Applicative f
=> Monoid a
=> CardanoEra era
-> (eon era -> f a)
-> f a
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.
Nope, because Aeson.Value
is not a monoid 🙂 (besides, I'm not sure the added abstraction would be worth the harder-to-understand code).
renderDebugCmdError :: DebugCmdError -> Doc ann | ||
renderDebugCmdError DebugCmdFailed = "Debug command failed" | ||
renderDebugCmdError = \case | ||
DebugCmdFailed -> "Debug command failed" | ||
DebugTxCmdError err -> renderTxCmdError err |
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 should be an Error
instance in the DebugCmdError
type module.
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.
Good point, changed 👍
@@ -30,60 +19,6 @@ goldenDir, inputDir :: FilePath | |||
goldenDir = "test/cardano-cli-golden/files/golden" | |||
inputDir = "test/cardano-cli-golden/files/input" | |||
|
|||
-- TODO: Expose command to view byron tx files | |||
_hprop_golden_view_byron_yaml :: Property |
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 think this makes HLINT
pragma unneccessary. Can you remove it if it's possible?
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 indeed, changing 👍
…"[era] transaction view")
…eting corresponding unplugged tests
…(don't even show 'null')
1bdc3df
to
e80203b
Compare
InAnyShelleyBasedEra era txbody <- pure $ unIncompleteCddlTxBody unwitnessed | ||
-- Why are we differentiating between a transaction body and a transaction? | ||
-- In the case of a transaction body, we /could/ simply call @makeSignedTransaction []@ | ||
-- to get a transaction which would allow us to reuse friendlyTxBS. However, |
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 something the new api would fix because by default we would either produce an unsigned tx or a signed tx. No need to think about transaction bodies that are missing witnesses.
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!
connect to a local node and log the epoch state to a | ||
file. The log file format is line delimited JSON. The | ||
command will not terminate. | ||
transaction Transaction commands |
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.
Transaction debugging commands?
@@ -74,6 +76,11 @@ import GHC.Unicode (isAlphaNum) | |||
|
|||
data FriendlyFormat = FriendlyJson | FriendlyYaml | |||
|
|||
viewOutputFormatToFriendlyFormat :: ViewOutputFormat -> FriendlyFormat |
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 don't think FriendlyFormat
is necessary. Why not propagate ViewOutputFormat
to the friendly*
functions?
Changelog
Context
babbage transaction view
on Babbage-era transaction shows some Conway era fields #799[era] transaction view
command after the next release.null
for fields in irrelevant erasHow to trust this PR
transaction view
on this Conway transaction, which is visible here didn't change: the Conway fields stayed.transaction view
outputs have changed.Checklist