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(evm-cli): Add the account query to the EVM command. Cover the CLI with tests. #2002

Merged
merged 8 commits into from
Aug 27, 2024

Conversation

Unique-Divine
Copy link
Member

@Unique-Divine Unique-Divine commented Aug 14, 2024

Purpose / Abstract

For easier account lookup

The --offline flag

It helps with this issue the gRPC query can fail and you want to use the command for the address conversion anyway.

image

Summary by CodeRabbit

  • New Features

    • Added the ability to query account information through the EVM command interface.
    • Introduced a new command for querying FunTokens, enhancing user interaction with fungible tokens.
    • Consolidated commands for creating fungible tokens into a single, more user-friendly command.
  • Bug Fixes

    • Improved error handling for command arguments, ensuring better user feedback and command execution.
  • Tests

    • Implemented a comprehensive test suite for the EVM CLI commands, enhancing reliability and robustness in functionality.

Copy link
Contributor

coderabbitai bot commented Aug 14, 2024

Walkthrough

The changes enhance the Ethereum Virtual Machine (EVM) module by introducing new command functionalities, improving test coverage, and refining code documentation. Key modifications include the addition of account query capabilities, restructuring the handling of fungible tokens, and implementing a comprehensive testing framework for command-line interactions. Updates also involve comment organization and field ordering in response structures across various components.

Changes

File Path Change Summary
CHANGELOG.md Added an entry for new account query functionality in the EVM command set, noting code quality maintained through tests.
app/evmante/evmante_sigverify.go Reformatted comments in NewEthSigVerificationDecorator and AnteHandle for improved readability without altering functionality.
x/evm/cli/cli_setup_test.go, x/evm/cli/cli_test.go Introduced a test suite for EVM CLI commands, covering setup methods, test cases for coin conversion, fungible token creation, and account queries with error handling.
x/evm/cli/query.go Replaced GetCmdFunToken with CmdQueryFunToken, added CmdQueryAccount for account queries, and improved command validation.
x/evm/cli/tx.go Consolidated fungible token creation commands into CmdCreateFunToken, modified argument handling for better usability, and renamed command for coin conversion.
x/evm/evmtest/eth.go Added NewEthPrivAccs function to generate multiple EthPrivKeyAcc instances efficiently.
x/evm/keeper/grpc_query.go Modified field order in QueryEthAccountResponse without changing underlying functionality.
x/evm/keeper/grpc_query_test.go Updated test case names for clarity and added a new test case for querying nonexistent accounts with Bech32 address inputs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant EVM Module
    participant Keeper

    User->>CLI: Execute account query command
    CLI->>EVM Module: Process query command
    EVM Module->>Keeper: Retrieve account information
    Keeper-->>EVM Module: Return account details
    EVM Module-->>CLI: Send account details response
    CLI-->>User: Display account information
Loading

🐇 "In the meadow, the code hops high,
New commands bloom, like clouds in the sky.
With tests galore and queries so bright,
EVM shines, a marvelous sight!
In every byte, a tale unfolds,
Of bunnies coding, and adventures bold!" 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 81.92771% with 15 lines in your changes missing coverage. Please review.

Project coverage is 65.90%. Comparing base (924f9c4) to head (34bd1bb).
Report is 1 commits behind head on main.

Files Patch % Lines
x/evm/cli/query.go 85.71% 3 Missing and 3 partials ⚠️
x/evm/evmtest/eth.go 0.00% 5 Missing ⚠️
x/evm/cli/tx.go 88.23% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2002      +/-   ##
==========================================
+ Coverage   65.73%   65.90%   +0.17%     
==========================================
  Files         261      263       +2     
  Lines       16405    16562     +157     
==========================================
+ Hits        10784    10916     +132     
- Misses       4809     4824      +15     
- Partials      812      822      +10     
Files Coverage Δ
app/evmante/evmante_sigverify.go 100.00% <ø> (ø)
x/evm/keeper/grpc_query.go 83.71% <100.00%> (ø)
x/evm/cli/tx.go 85.91% <88.23%> (ø)
x/evm/evmtest/eth.go 89.13% <0.00%> (-10.87%) ⬇️
x/evm/cli/query.go 87.65% <85.71%> (ø)

@Unique-Divine Unique-Divine changed the title feat(evm-cli): expose account query feat(evm-cli): Add the account query to the EVM command. Cover the CLI with tests. Aug 22, 2024
@@ -36,87 +36,72 @@ func GetTxCmd() *cobra.Command {
return txCmd
}

// CmdCreateFunTokenFromBankCoin broadcast MsgCreateFunToken
func CmdCreateFunTokenFromBankCoin() *cobra.Command {
// CmdCreateFunToken broadcast MsgCreateFunToken
Copy link
Member Author

@Unique-Divine Unique-Divine Aug 22, 2024

Choose a reason for hiding this comment

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

Now mirroring the behavior of the gRPC tx message

@Unique-Divine Unique-Divine marked this pull request as ready for review August 22, 2024 06:48
@Unique-Divine Unique-Divine requested a review from a team as a code owner August 22, 2024 06:48
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.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0a68933 and d20f66c.

Files selected for processing (9)
  • CHANGELOG.md (1 hunks)
  • app/evmante/evmante_sigverify.go (1 hunks)
  • x/evm/cli/cli_setup_test.go (1 hunks)
  • x/evm/cli/cli_test.go (1 hunks)
  • x/evm/cli/query.go (3 hunks)
  • x/evm/cli/tx.go (4 hunks)
  • x/evm/evmtest/eth.go (1 hunks)
  • x/evm/keeper/grpc_query.go (1 hunks)
  • x/evm/keeper/grpc_query_test.go (2 hunks)
Files skipped from review due to trivial changes (2)
  • app/evmante/evmante_sigverify.go
  • x/evm/keeper/grpc_query.go
Additional comments not posted (14)
x/evm/evmtest/eth.go (1)

39-46: New function NewEthPrivAccs is well-implemented.

The function efficiently creates a slice of EthPrivKeyAcc instances by calling NewEthPrivAcc multiple times. This addition enhances functionality by allowing batch creation of accounts.

x/evm/cli/cli_setup_test.go (2)

1-54: Test suite setup is well-structured.

The test suite uses the testify package effectively to set up and run tests. The SetupSuite method initializes the keyring and client context correctly, and the TestSuite function runs the suite as expected.


56-115: Test case structure is clear and comprehensive.

The TestCase struct and its methods RunTxCmd and RunQueryCmd provide a clear framework for executing transaction and query commands. The use of context and error handling is appropriate.

x/evm/cli/tx.go (3)

29-30: Command consolidation improves usability.

The consolidation of commands into CmdCreateFunToken simplifies the CLI by reducing the number of commands and using flags to specify the source. This change enhances user experience.


39-90: Flag-based argument handling is a good practice.

The use of flags --bank-denom and --erc20 in CmdCreateFunToken improves flexibility and clarity. The error handling for flag requirements is well-implemented.


Line range hint 94-120: Command renaming aligns with best practices.

Renaming ConvertCoinToEvm to CmdConvertCoinToEvm aligns with naming conventions and improves consistency. The command logic remains clear and functional.

x/evm/cli/query.go (1)

Line range hint 41-76: LGTM!

The CmdQueryFunToken function is well-implemented with appropriate error handling and command structure.

x/evm/cli/cli_test.go (4)

23-50: LGTM!

The TestCmdConvertCoinToEvm function is well-structured and covers both success and error scenarios effectively.


52-87: LGTM!

The TestCmdCreateFunToken function is comprehensive and effectively covers various scenarios, including errors.


89-139: LGTM!

The TestCmdQueryAccount function is well-designed, covering different address formats and offline mode effectively.


141-173: LGTM!

The TestCmdQueryFunToken function is thorough and effectively addresses both success and error scenarios.

x/evm/keeper/grpc_query_test.go (2)

Line range hint 141-158: LGTM!

The test case for a nonexistent account with a hex address input is well-structured and correctly verifies the expected response.


159-177: LGTM!

The test case for a nonexistent account with a Bech32 address input is well-structured and correctly verifies the expected response.

CHANGELOG.md (1)

111-111: Changelog entry is well-formed.

The new entry for the account query feature in the EVM command is correctly added under the "Unreleased" section. It adheres to the specified format and guidelines.

Comment on lines +95 to +97
isBech32, err := req.Validate()
fmt.Printf("TODO: UD-DEBUG: req.String(): %v\n", req.String())
fmt.Printf("TODO: UD-DEBUG: err: %v\n", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove debug print statements.

The debug print statements should be removed to clean up the code for production.

Apply this diff to remove the debug statements:

-	fmt.Printf("TODO: UD-DEBUG: req.String(): %v\n", req.String())
-	fmt.Printf("TODO: UD-DEBUG: err: %v\n", err)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
isBech32, err := req.Validate()
fmt.Printf("TODO: UD-DEBUG: req.String(): %v\n", req.String())
fmt.Printf("TODO: UD-DEBUG: err: %v\n", err)
isBech32, err := req.Validate()

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d20f66c and 1d54f44.

Files selected for processing (1)
  • x/evm/cli/cli_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/evm/cli/cli_test.go

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1d54f44 and 34bd1bb.

Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

@Unique-Divine Unique-Divine merged commit 95ba4af into main Aug 27, 2024
16 checks passed
@Unique-Divine Unique-Divine deleted the ud/cli-account branch August 27, 2024 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant