Skip to content

Conversation

julienrbrt
Copy link
Contributor

@julienrbrt julienrbrt commented Apr 2, 2025

Description

Cherry-picks #21853

Steps to reproduce: simd tx protocolpool create-continuous-fund alice 0.1


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, you can find examples of the prefixes below:
  • confirmed ! in 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
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • 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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Bug Fixes
    • Resolved an issue with processing large numeric values in transactions.
  • New Features
    • Enhanced error messages to display valid option choices for invalid inputs.
    • Added support for precise decimal inputs in command-line flags, improving both validation and handling.

@github-actions github-actions bot added the C:CLI label Apr 2, 2025
@julienrbrt julienrbrt marked this pull request as ready for review April 3, 2025 10:26
@julienrbrt julienrbrt requested a review from a team April 3, 2025 10:26
Copy link
Contributor

coderabbitai bot commented Apr 3, 2025

📝 Walkthrough

Walkthrough

The changes update the changelog by adding a new bug fix entry for unmarshalling *big.Int in transactions and reorganizing improvement entries. Additionally, new functionality is introduced to support a decimal scalar type ("cosmos.Dec") in the CLI flag builder. This includes adding a constant and mapping entry in the builder file as well as a new file that defines types and methods for handling decimal values with proper parsing and error handling.

Changes

File(s) Change Summary
client/v2/CHANGELOG.md Updated changelog entries: added a bug fix for *big.Int unmarshalling (PR #21853), moved improvement entry (#21936) to version v2.0.0-beta.6, and reassigned improvement entry (#21712) from v2.0.0-beta.5 to v2.0.0-beta.4.
client/v2/autocli/flag/builder.go
client/v2/autocli/flag/legacy_dec.go
Added new scalar type support for decimals: introduced constant DecScalarType with value "cosmos.Dec" and mapped it to a new decType in the builder; added a new file implementing decType and a corresponding decValue type with methods for creation, value retrieval, parsing via math.LegacyNewDecFromStr, and string conversion.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Builder
    participant DecimalHandler as decType/decValue
    participant Math

    User ->> Builder: Provide input for cosmos.Dec flag
    Builder ->> Builder: Lookup "cosmos.Dec" in scalarFlagTypes
    Builder ->> DecimalHandler: Call NewValue()
    DecimalHandler -->> Builder: Return new decValue (default "0")
    User ->> Builder: Set flag value (string input)
    Builder ->> DecimalHandler: Invoke Set(input)
    DecimalHandler ->> Math: Parse input using LegacyNewDecFromStr
    Math -->> DecimalHandler: Return parsed decimal or error
    DecimalHandler -->> Builder: Provide processed value or error
    Builder -->> User: Return final flag value or error
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 167f3f1 and 30c8596.

⛔ Files ignored due to path filters (3)
  • simapp/go.mod is excluded by !**/*.mod
  • simapp/go.sum is excluded by !**/*.sum, !**/*.sum
  • tests/go.mod is excluded by !**/*.mod
📒 Files selected for processing (3)
  • client/v2/CHANGELOG.md (2 hunks)
  • client/v2/autocli/flag/builder.go (2 hunks)
  • client/v2/autocli/flag/legacy_dec.go (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
client/v2/autocli/flag/legacy_dec.go (1)
client/v2/autocli/flag/builder.go (1)
  • Builder (35-57)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: test-system
  • GitHub Check: test-system-legacy
  • GitHub Check: tests (03)
  • GitHub Check: tests (02)
  • GitHub Check: tests (01)
  • GitHub Check: tests (00)
  • GitHub Check: test-sim-nondeterminism
  • GitHub Check: test-integration
  • GitHub Check: test-e2e
  • GitHub Check: Analyze
  • GitHub Check: build (amd64)
  • GitHub Check: Gosec
  • GitHub Check: Summary
🔇 Additional comments (9)
client/v2/autocli/flag/builder.go (2)

31-31: Added support for cosmos.Dec scalar type.

Good addition of the DecScalarType constant to support decimal values in the flag builder. This matches the Type string used in the new decType implementation.


74-74: Integration of decimal type with flag builder.

The addition of decType{} to the scalar flag types map correctly integrates the new decimal type handler with the existing flag building system.

client/v2/CHANGELOG.md (3)

42-42: Added bug fix entry for big.Int unmarshalling.

This changelog entry correctly documents the fix for *big.Int unmarshalling in transactions, which aligns with the PR's purpose of addressing issues with big.Int types.


58-59: Moved enum values error message improvement to correct version.

The entry about printing possible enum values in error messages has been correctly moved to the v2.0.0-beta.6 section, which helps maintain proper versioning.


74-76: Reorganized improvements section.

Good restructuring of the changelog by adding an "Improvements" section in v2.0.0-beta.4 and moving the appropriate entry there. This maintains chronological order and proper categorization.

client/v2/autocli/flag/legacy_dec.go (4)

11-19: Implementation of decimal type handler is appropriate.

The decType implementation follows the correct pattern for flag types in the Builder system. It provides methods to create new values and specify default values. The default value of "0" is sensible for a decimal type.


21-31: Decimal value struct implementation is correct.

The decValue struct and its methods for getting and displaying the value follow the appropriate pattern. The struct stores the decimal as a string, which is a suitable representation.


33-44: Good handling of decimal parsing and conversion.

The Set method appropriately uses math.LegacyNewDecFromStr to parse decimal values and convert them to a non-float representation. The error handling for invalid decimal values is correct.

The comment explaining the conversion from float to non-float representation is helpful. This approach maintains precision by storing the value as a BigInt string.


46-48: Type implementation matches the declared scalar type.

The Type method correctly returns "cosmos.Dec", which matches the DecScalarType constant defined in the builder file. This consistency is important for proper type identification.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

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.

sigs.k8s.io/yaml v1.4.0 // indirect
)

replace cosmossdk.io/client/v2 => ../client/v2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in a follow-up this should be removed and a pseudo version of client/v2 should be used.

@aljo242 aljo242 merged commit df07789 into main Apr 3, 2025
47 of 48 checks passed
@aljo242 aljo242 deleted the julien/clientv2-bigint branch April 3, 2025 14:02
mergify bot pushed a commit that referenced this pull request Apr 3, 2025
(cherry picked from commit df07789)

# Conflicts:
#	client/v2/CHANGELOG.md
#	simapp/go.sum
github-merge-queue bot pushed a commit that referenced this pull request Apr 3, 2025
) (#24365)

Co-authored-by: julienrbrt <julien@rbrt.fr>
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants