-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Require proto.Message in client.Context.PrintOutput #6999
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6999 +/- ##
==========================================
- Coverage 61.94% 59.39% -2.55%
==========================================
Files 519 368 -151
Lines 32088 21741 -10347
==========================================
- Hits 19877 12914 -6963
+ Misses 10597 7754 -2843
+ Partials 1614 1073 -541 |
…ronc/cli-print-output-proto
x/distribution/client/cli/tx.go
Outdated
@@ -287,7 +287,7 @@ Where proposal.json contains: | |||
return err | |||
} | |||
|
|||
proposal, err := ParseCommunityPoolSpendProposalJSON(clientCtx.JSONMarshaler, args[0]) | |||
proposal, err := ParseCommunityPoolSpendProposalJSON(clientCtx.Codec, args[0]) |
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.
To be migrated in #6987
@@ -19,7 +19,8 @@ type ( | |||
) | |||
|
|||
// ParseCommunityPoolSpendProposalJSON reads and parses a CommunityPoolSpendProposalJSON from a file. | |||
func ParseCommunityPoolSpendProposalJSON(cdc codec.JSONMarshaler, proposalFile string) (CommunityPoolSpendProposalJSON, error) { | |||
// TODO: migrate this to protobuf |
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.
To be migrated in #6987
} | ||
|
||
// PrintOutputLegacy is a variant of PrintOutput that doesn't require a proto type | ||
// and uses amino JSON encoding. It will be removed in the near future! |
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.
To be removed in #6987 when all the remaining pieces are migrated to proto
…ronc/cli-print-output-proto
…nto aaronc/cli-print-output-proto
@@ -84,7 +85,7 @@ func GetCmdQueryInflation() *cobra.Command { | |||
return err | |||
} | |||
|
|||
return clientCtx.PrintOutput(res.Inflation) | |||
return clientCtx.PrintString(fmt.Sprintf("%s\n", res.Inflation)) |
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 PrintString
?
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.
Inflation
is a Dec
and we can't print simply a Dec
with jsonpb, but a Dec
can just be printed as a string.
The previous output was something like "1234.00000"
in quotes. The new version just prints a number not in quotes 1234.00000
. If we actually want to print a JSON string we will need to print something like {"inflation":"1234.00000"}
wrapped in an object. Would that be preferable?
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, {"inflation":"1234.00000"}
would be better. May be return clientCtx.PrintOutput(res)
?
@@ -116,7 +117,7 @@ func GetCmdQueryAnnualProvisions() *cobra.Command { | |||
return err | |||
} | |||
|
|||
return clientCtx.PrintOutput(res.AnnualProvisions) | |||
return clientCtx.PrintString(fmt.Sprintf("%s\n", res.AnnualProvisions)) |
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.
ditto
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.
see comment above regarding Inflation
Dec
@@ -105,7 +105,7 @@ func GetAppliedPlanCmd() *cobra.Command { | |||
if err != nil { | |||
return err | |||
} | |||
return clientCtx.PrintOutput(string(bz)) | |||
return clientCtx.PrintString(fmt.Sprintf("%s\n", string(bz))) |
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.
ditto
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 was just printing a string using amino. It doesn't work in proto. So the easiest thing seems to be to just print a string. If a json string is really needed we could use encoding/json
Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
Was originally part of #6859 but split out into a smaller PR
This is a stepping stone to enabling protobuf JSON generally in #6859.
client.Context.PrintOutput
now requiresproto.Message
- proto JSON is more or less impossible to enforce without this. Queries that returned arrays from query responses, now return the full response. This probably the correct behavior because these queries should also eventually includepagination
data if they don't alreadyclient.Context.PrintOutputLegacy
was added to use amino JSON where we don't have proto types yet. Rather than dealing with all of the migrations in this already large PR, stuff that wasn't migrated usesPrintOutputLegacy
and the issues are tracked in Migrate remaining CLI cmd's to proto #6987Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes