Skip to content
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

fix(autocli): fix simapp enhancing #15906

Merged
merged 6 commits into from
Apr 25, 2023
Merged

fix(autocli): fix simapp enhancing #15906

merged 6 commits into from
Apr 25, 2023

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Apr 21, 2023

Description

Discovered a bug in AutoCLI that it does not enrich the command when the CLI isn't defined, this PR will fix this as well.

I've tested the changes with simapp and hubl and it works.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@github-actions github-actions bot added C:CLI C:x/nft C:Confix Issues and PR related to Confix C:Cosmovisor Issues and PR related to Cosmovisor C:Hubl Tool: Hubl C:Rosetta Issues and PR related to Rosetta C:x/circuit labels Apr 21, 2023
@@ -245,8 +245,6 @@ func queryCommand() *cobra.Command {
authcmd.QueryTxCmd(),
)

simapp.ModuleBasics.AddQueryCommands(cmd)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary as autocli will enrich the commands that are not present

// if we have an existing command skip adding one here
if cmd.HasSubCommands() {
if _, _, err := cmd.Find([]string{moduleName}); err == nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was always returning true for simapp. We already had a helper that was working.

if msgCmd := findSubCommand(rootCmd, "tx"); msgCmd != nil {
if err := builder.enhanceCommandCommon(msgCmd, moduleOptions, customQueryCmds, enhanceMsg); err != nil {
Copy link
Member Author

@julienrbrt julienrbrt Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here it was passing the custom query commands, which is incorrect.

@julienrbrt julienrbrt changed the title feat(nft)!: migrate command queries to autocli feat(nft)!: migrate command queries to autocli and fix autocli enriching Apr 21, 2023
Copy link
Member Author

@julienrbrt julienrbrt Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this file, the command is not generated.
Still getting failure when running app err="client context not set" for all generated autocli apps.
Investigating the issue first. If this file is always needed then we need to update the docs as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done here: 1f01c04
I still have to dig the reason it was returning an error before, as the behavior of the commit above makes sense to me.

msgCmd := topLevelCmd("tx", "Transaction subcommands")
enhanceMsg := func(cmd *cobra.Command, modOpts *autocliv1.ModuleOptions, moduleName string) error {
txCmdDesc := modOpts.Tx
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was duplicated.

queryCmd := topLevelCmd("query", "Querying subcommands")
queryCmd.Aliases = []string{"q"}

enhanceMsg := func(cmd *cobra.Command, modOpts *autocliv1.ModuleOptions, moduleName string) error {
txQueryDesc := modOpts.Query
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was duplicated.

@julienrbrt julienrbrt changed the title feat(nft)!: migrate command queries to autocli and fix autocli enriching fix(autocli): fix simapp enriching Apr 21, 2023
@julienrbrt julienrbrt marked this pull request as ready for review April 21, 2023 21:57
@julienrbrt julienrbrt requested a review from a team as a code owner April 21, 2023 21:57
@julienrbrt julienrbrt requested review from aaronc and JeancarloBarrios and removed request for mark-rushakoff and atheeshp April 21, 2023 22:08
@github-actions

This comment has been minimized.

@julienrbrt julienrbrt changed the base branch from main to julien/codec-add-get-prefix April 23, 2023 15:19
@julienrbrt julienrbrt changed the base branch from julien/codec-add-get-prefix to main April 24, 2023 14:05
@julienrbrt julienrbrt changed the title fix(autocli): fix simapp enriching fix(autocli): fix simapp enhancing Apr 24, 2023
@@ -24,18 +27,20 @@ func (a addressStringType) NewValue(ctx context.Context, b *Builder) Value {
if resp == nil || resp.Config == nil {
panic("bech32 account address prefix is not set")
}
b.AddressPrefix = resp.Config.Bech32AccountAddressPrefix

b.AddressCodec = addresscodec.NewBech32Codec(resp.Config.Bech32AccountAddressPrefix)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't call grpc every time to get the bech32 prefix. This should be done by hubl during unit and update and then cached

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, do you want me to do that here or in a follow-up? This PR does not touch hubl's code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a follow up

@julienrbrt julienrbrt added this pull request to the merge queue Apr 25, 2023
Merged via the queue into main with commit ebcad58 Apr 25, 2023
@julienrbrt julienrbrt deleted the julien/nft-autocli branch April 25, 2023 14:10
bizk added a commit to Zondax/cosmos-sdk that referenced this pull request Apr 25, 2023
* solved lint issues

* feat(x/tx): API improvements (cosmos#15871)

* refactor(baseapp): set vote info to latest votes (cosmos#15930)

* refactor(staking, slashing, signing, misc): remove aliases from types/math.go (cosmos#15902)

* fix(autocli): fix simapp enhancing (cosmos#15906)

* fix lint on armor.go

* ran make lint-fix

---------

Co-authored-by: Matt Kocubinski <[email protected]>
Co-authored-by: Marko <[email protected]>
Co-authored-by: samricotta <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
@julienrbrt julienrbrt mentioned this pull request Apr 26, 2023
19 tasks
@tac0turtle tac0turtle mentioned this pull request May 3, 2023
4 tasks
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:CLI C:Confix Issues and PR related to Confix C:Cosmovisor Issues and PR related to Cosmovisor C:Hubl Tool: Hubl C:Rosetta Issues and PR related to Rosetta C:x/auth C:x/circuit C:x/nft
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants