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(client/v2): set context for queries #18323

Merged
merged 2 commits into from
Nov 1, 2023
Merged

fix(client/v2): set context for queries #18323

merged 2 commits into from
Nov 1, 2023

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Nov 1, 2023

Description

Fixes an issue where client.toml wouldn't be read for autocli queries.


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
  • run make lint and make test
  • 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)

Summary by CodeRabbit

New Features:

  • Enhanced the BuildQueryMethodCommand function in the autocli/query.go file. The function now sets the context of the command with the client context, allowing the command to access the client context when executing. This change improves the command's functionality and interaction with the client context.

Refactor:

  • Rearranged code in the autocli/query.go file to set the encoder options after setting the context, improving the overall code structure and execution flow.

@julienrbrt julienrbrt requested a review from a team as a code owner November 1, 2023 08:29
Copy link
Contributor

coderabbitai bot commented Nov 1, 2023

Walkthrough

The codebase has been updated to enhance the functionality of the BuildQueryMethodCommand function in the query.go file. The changes include the addition of new imports and the setting of the command context with the client context, enabling the command to access the client context during execution.

Changes

File Path Summary
client/v2/.../query.go New imports for the "context" and "github.com/cosmos/cosmos-sdk/client" packages have been added. The BuildQueryMethodCommand function has been modified to set the command context with the client context.

Poem

🍂 As November winds begin to blow,
In the code, new changes start to show.
With context set, the command takes flight,
In the realm of code, a shining light. 🌟

🐇 Hopping through the lines of code,
The rabbit finds a new abode.
Celebrate the change, let's cheer,
For the end of the year is near! 🎉

In the world of tech, we unite,
Making changes, day and night.
Inclusivity is our might,
Coding for all, is our right! 💻🌍🕊️


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.json

@julienrbrt julienrbrt added the backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release label Nov 1, 2023
Copy link
Contributor

github-actions bot commented Nov 1, 2023

@julienrbrt your pull request is missing a changelog!

@github-actions github-actions bot added the C:CLI label Nov 1, 2023
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 79246d2 and 983595f.
Files selected for processing (1)
  • client/v2/autocli/query.go (2 hunks)
Additional comments: 2
client/v2/autocli/query.go (2)
  • 1-15: The new imports for "context" and "github.com/cosmos/cosmos-sdk/client" are appropriate for the changes made in this hunk.

  • 116-121: The context of the command is now set with the client context. This allows the command to access the client context when executing. This is a good practice as it allows the command to have access to the necessary context when it is executed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 983595f and 406396f.
Files selected for processing (1)
  • client/v2/autocli/query.go (3 hunks)
Additional comments: 3
client/v2/autocli/query.go (3)
  • 1-15: The new imports for "context" and "github.com/cosmos/cosmos-sdk/client" are correctly placed and formatted.

  • 116-120: The context of the command is correctly set with the client context. This allows the command to access the client context when executing.

+ cmd.SetContext(context.WithValue(context.Background(), client.ClientContextKey, &b.ClientCtx))
  • 129-131: The encoder options are correctly set after the context has been set. This ensures that the encoder options are applied correctly when the command is executed.
+ if noIndent, _ := cmd.Flags().GetBool(flags.FlagNoIndent); noIndent {
+     encoderOptions.Indent = ""
+ }

@julienrbrt julienrbrt added this pull request to the merge queue Nov 1, 2023
Merged via the queue into main with commit 630836e Nov 1, 2023
63 of 64 checks passed
@julienrbrt julienrbrt deleted the julien/autocli-ctx branch November 1, 2023 10:19
mergify bot pushed a commit that referenced this pull request Nov 1, 2023
julienrbrt added a commit that referenced this pull request Nov 1, 2023
Co-authored-by: Julien Robert <julien@rbrt.fr>
@faddat faddat mentioned this pull request Nov 8, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release C:CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants