-
Notifications
You must be signed in to change notification settings - Fork 610
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
Use reflection + Generics to delete most CLI boilerplate for queries #3611
Conversation
Limitation for certain classes of further tx deletion:
|
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 great to me! Amazing work.
General suggestions/questions:
- Although most CLI functions are self-explanatory, godocs would still be helpful in many cases. E.g:
ParseField
. Also, for consistency with the repo. - What is the testing strategy for this?
fVal := v.Field(fieldIndex) | ||
fType := t.Field(fieldIndex) | ||
|
||
// fmt.Printf("Field %d: %s %s %s\n", fieldIndex, fType.Name, fType.Type, fType.Type.Kind()) |
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.
Since this is turning into a discussion, I would like to chime in with some thoughts as well.
I agree that these are valuable for debugging purposes. However, I don't think that leaving commented-out prints should be the direction.
I agree with @nicolaslara that we should be using a toggle. I would even go beyond that to suggest using various log levels - debug, info etc. Each log should be analyzed in the review whether it adds value, including its log level. Otherwise, we will eventually have a system full of misc logs at the info level.
In my opinion, raw commented-out prints only add additional complexity to a system. So we should be using a logger with a configured tracing level.
If we don't take proper care to analyze the value of each in the review, the system will eventually become polluted with comments.
|
||
// TODO: Make this able to read from some local alias file for denoms. | ||
func ParseCoins(arg string, fieldName string) (sdk.Coins, error) { | ||
coins, err := sdk.ParseCoinsNormalized(arg) |
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.
There are some cases where sdk.ParseCoinsNormalized
doesn't work. For example, here:
osmosis/x/gamm/client/cli/tx.go
Line 487 in da6b7d1
deposit, err := ParseCoinsNoSort(flags.InitialDeposit) |
Is that case handled in this PR?
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.
Took a quick peek. Looks like ParseCoinsNoSort
is still used in the right place
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.
yeah, explicitly didn't replace those for now. Need to add a way to set a custom per-field parser to get those replaced
Testing strategy:
|
Thanks for the reviews! Will get godocs added onto those primary parse methods |
@@ -84,7 +84,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r | |||
|
|||
// GetTxCmd returns the capability module's root tx command. | |||
func (a AppModuleBasic) GetTxCmd() *cobra.Command { | |||
return cli.GetTxCmd() | |||
return nil |
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 long term plan for this?
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.
wdym, it has no TX command?
Long term plan is that you don't have to implement this function for interface compat, if you don't use a tx cli
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.
Ah, was trying to figure out why we were returning GetTxCmd before, makes sense
return cmd | ||
} | ||
|
||
// TODO: Change these flags to args. Required flags don't make that much sense. |
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 lol
…(backport #3611) (#3633) Makes new, far more succinct methods, to build tx and query CLI's Co-authored-by: Dev Ojha <[email protected]> Co-authored-by: Dev Ojha <[email protected]>
What is the purpose of the change
Cleans up some CLI boilerplate. Mostly was using it as an exercise to play around with ChatGPT
Brief Changelog
Before:
After:
Testing and Verifying
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)