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(katana): allow specifying multiple values w/o wrapping in quotes #3018

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

kariy
Copy link
Member

@kariy kariy commented Feb 13, 2025

Accidentally remove the num_args after I wrote the test for it in #3017 . Now this should be possible:

--slot.paymasters 0x1,0x2 0x3,0x4

without quotes.

@glihm

Summary by CodeRabbit

  • Documentation
    • Updated instructions for specifying multiple paymaster accounts by removing the requirement for quotation marks, making it clearer to input multiple values separated by spaces.
  • Refactor
    • Improved the command-line argument behavior to naturally accept a variable number of paymaster accounts, streamlining the overall user experience.

Copy link

coderabbitai bot commented Feb 13, 2025

Walkthrough

Ohayo, sensei! This PR updates the CLI for specifying multiple paymaster accounts in the SlotArgs struct. The documentation now indicates that multiple accounts should be provided as space-separated values instead of requiring double quotes. The argument parsing has been modified—changing from a value_delimiter = ' ' configuration to num_args = 1..—to allow a flexible number of inputs.

Changes

File(s) Change Summary
bin/katana/src/cli/init/slot.rs Updated documentation for paymaster_accounts to allow space-separated entries and revised argument parsing by switching from value_delimiter = ' ' to num_args = 1...

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant SlotArgs
    User->>CLI: Run command with --slot.paymasters "account1 account2 ..."
    CLI->>SlotArgs: Parse paymaster accounts using num_args = 1..
    SlotArgs-->>CLI: Return list of parsed accounts
    CLI-->>User: Process command with provided paymaster accounts
Loading

Possibly related PRs

Suggested reviewers

  • glihm

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

@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

🧹 Nitpick comments (2)
bin/katana/src/cli/init/slot.rs (2)

23-34: Ohayo sensei! Consider enhancing the documentation with validation rules.

The documentation clearly explains the new format, but it would be helpful to include:

  • Valid format for public keys and salts (e.g., hex format, length)
  • Error handling behavior for invalid inputs

188-190: Ohayo sensei! Consider adding more test cases.

While the current test covers the happy path well, consider adding test cases for:

  • Edge cases (empty string, malformed input)
  • Maximum number of arguments (if any)
  • Invalid hex values

Example test case for invalid input:

#[test]
fn test_parse_invalid_paymaster_args() {
    #[derive(Parser)]
    struct Cli {
        #[arg(long)]
        id: bool,
        #[command(flatten)]
        slot: SlotArgs,
    }

    // Test malformed input
    let result = Cli::parse_from([
        "cli",
        "--id",
        "--slot",
        "--slot.paymasters",
        "invalid",
    ]);
    assert!(result.is_err());

    // Test invalid hex
    let result = Cli::parse_from([
        "cli",
        "--id",
        "--slot",
        "--slot.paymasters",
        "0xZ,0x1",
    ]);
    assert!(result.is_err());
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac52ea6 and ac0db6a.

📒 Files selected for processing (1)
  • bin/katana/src/cli/init/slot.rs (2 hunks)
🔇 Additional comments (1)
bin/katana/src/cli/init/slot.rs (1)

36-36: LGTM! The argument parsing change looks solid.

The switch to num_args = 1.. elegantly handles both single and multiple paymaster specifications without requiring quotes.

Copy link

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.23%. Comparing base (ac52ea6) to head (ac0db6a).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3018      +/-   ##
==========================================
- Coverage   56.24%   56.23%   -0.01%     
==========================================
  Files         436      436              
  Lines       58829    58830       +1     
==========================================
- Hits        33087    33084       -3     
- Misses      25742    25746       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

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

Sorry I've missed that also, better than the quotes. 👍

@glihm glihm merged commit c60392a into main Feb 13, 2025
15 checks passed
@glihm glihm deleted the katana/split-args branch February 13, 2025 12:36
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.

2 participants