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

feat: add --qrcode flag to keys show command #18557

Merged
merged 11 commits into from
Nov 27, 2023
Merged

feat: add --qrcode flag to keys show command #18557

merged 11 commits into from
Nov 27, 2023

Conversation

levisyin
Copy link
Contributor

@levisyin levisyin commented Nov 26, 2023

Description

Closes: #18556

simd keys show account1 --address=true --qrcode=true

Screenshot from 2023-11-26 12-03-58


Author Checklist

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

    • Introduced a --qrcode flag for the keys show command to display keys as a payment QR code.
    • Added support for a default key name in client.toml, eliminating the need for the --from flag during transactions.
  • Enhancements

    • Implemented a new key_rotation_fee parameter in the x/staking module for fee calculation during key rotations.
    • Added a SubmitTestTx helper method in testutil for broadcasting test transactions in end-to-end tests.
  • Tests

    • Expanded test coverage for the keys show command with new test cases for QR code display and key management scenarios.
  • Documentation

    • Updated CHANGELOG.md with a summary of new features and enhancements.

@levisyin levisyin requested a review from a team as a code owner November 26, 2023 04:09
Copy link
Contributor

coderabbitai bot commented Nov 26, 2023

Walkthrough

The code changes introduce a new feature to display a payment QR code in the terminal for a given key name or address, enhancing the keys command in a client application. This allows users to conveniently make payments to an account by scanning the QR code with a wallet app. The changes include adding a new flag to trigger QR code display, updating tests to cover the new functionality, and documenting the feature in the changelog.

Changes

File(s) Change Summary
client/keys/show.go Added --qrcode flag to ShowKeysCmd and logic to generate QR code using qrterminal package.
client/keys/show_test.go Updated tests to include cases for the new --qrcode flag and other key management scenarios.
testutil/ioutil.go Commented out c.SetOut(io.Discard) affecting command output behavior.
CHANGELOG.md Documented new features and changes, including the --qrcode flag and other updates in the client and x/staking module.

Assessment against linked issues

Objective Addressed Explanation
Support displaying payment for QR code in terminal for a given key name or address (#18556) The --qrcode flag and QR code generation logic in show.go directly address this feature request.
Ensure the feature is tested (#18556) The updated tests in show_test.go cover the new functionality, ensuring the QR code display feature works as intended.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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.v2.json

@github-actions github-actions bot added C:CLI C:Keys Keybase, KMS and HSMs labels Nov 26, 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: 5

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 34b1634 and 942ed09.
Files ignored due to filter (2)
  • go.mod
  • go.sum
Files selected for processing (3)
  • client/keys/show.go (5 hunks)
  • client/keys/show_test.go (1 hunks)
  • testutil/ioutil.go (1 hunks)
Additional comments: 3
client/keys/show.go (2)
  • 4-9: The import of the qrterminal package is correctly placed in the import block, following the convention of grouping third-party imports together. However, ensure that the errors package is not being used anymore since it's replaced by errorsmod from cosmossdk.io/errors. If it's not used, it should be removed to avoid unnecessary imports.

  • 31-35: The addition of the flagQRCode constant is consistent with the implementation of the new feature. It follows the established naming conventions and is well-documented.

testutil/ioutil.go (1)
  • 44-50:

The change to comment out c.SetOut(io.Discard) will cause the command's standard output to no longer be discarded during tests. This could lead to unintended side effects if the output is not handled or asserted properly in tests. Verify that this change is intentional and that all tests still behave as expected without discarding the standard output.

client/keys/show_test.go Show resolved Hide resolved
client/keys/show_test.go Outdated Show resolved Hide resolved
client/keys/show.go Outdated Show resolved Hide resolved
client/keys/show.go Show resolved Hide resolved
client/keys/show.go Show resolved Hide resolved
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 942ed09 and 66e3407.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)

@julienrbrt
Copy link
Member

lgtm, thank you! But I wouldn't call that a "payment qrcode". Maybe just address qrcode or smth.

@levisyin
Copy link
Contributor Author

lgtm, thank you! But I wouldn't call that a "payment qrcode". Maybe just address qrcode or smth.

Okay, let's call it address qrcode😀

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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 66e3407 and ec27187.
Files ignored due to filter (2)
  • simapp/go.mod
  • simapp/go.sum
Files selected for processing (1)
  • client/keys/show_test.go (1 hunks)
Additional comments: 1
client/keys/show_test.go (1)
  • 174-176:

client/keys/show_test.go Show resolved Hide resolved
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: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ec27187 and a94ec2d.
Files selected for processing (1)
  • client/keys/show.go (5 hunks)
Additional comments: 3
client/keys/show.go (3)
  • 34-34:
    The introduction of the flagQRCode constant is consistent with the naming conventions and purpose of the pull request.

  • 51-54:
    The flag descriptions for FlagPublicKey, FlagDevice, flagMultiSigThreshold, and flagQRCode are clear and provide the necessary information to the user.

  • 99-105:
    The retrieval of flag values for isShowAddr, isShowPubKey, isShowDevice, and isShowQRCode is consistent with the existing pattern and correctly implemented.

client/keys/show.go Show resolved Hide resolved
client/keys/show.go Show resolved Hide resolved
@julienrbrt julienrbrt self-assigned this Nov 26, 2023
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm! 🚀

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Awesome, really cool. Thanks @levisyin

client/keys/show.go Outdated Show resolved Hide resolved
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a94ec2d and 79cff12.
Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • client/keys/show.go (5 hunks)
Additional comments: 1
CHANGELOG.md (1)
  • 43-43: The changelog entries are correctly formatted, include the necessary links to the pull requests, and accurately describe the new features and changes.

client/keys/show.go Show resolved Hide resolved
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

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

cool feature!
Lgtm!!

@julienrbrt julienrbrt added this pull request to the merge queue Nov 27, 2023
Merged via the queue into cosmos:main with commit 536bd3a Nov 27, 2023
54 of 56 checks passed
@levisyin levisyin deleted the feat/payment-qrcode branch November 27, 2023 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:CLI C:Keys Keybase, KMS and HSMs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: support displaying payment for QR code
4 participants