Skip to content

refactor: rename choice to vote#7

Merged
linguists merged 1 commit intomainfrom
refactor/rename-to-vote
Jun 24, 2025
Merged

refactor: rename choice to vote#7
linguists merged 1 commit intomainfrom
refactor/rename-to-vote

Conversation

@linguists
Copy link
Copy Markdown
Contributor

@linguists linguists commented Jun 24, 2025

Summary by CodeRabbit

  • Refactor
    • Renamed the "Choice" enum to "Vote" and updated all related method names, parameters, and documentation for consistency.
    • Changed field names in event data and JSON arguments from "choice" to "vote" across the app and tests.
  • Tests
    • Updated test cases to use the new "vote" naming in all relevant scenarios.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 24, 2025

Walkthrough

This change renames the Choice enum to Vote throughout the codebase, updates all related method and variable names, and modifies the Event::Voted variant to use a vote field referencing Vote instead of choice. Associated documentation and test code were updated to reflect these naming changes.

Changes

File(s) Change Summary
src/lib.rs Renamed Choice enum to Vote; updated all related type signatures, parameters, and docs.
src/events.rs Changed Event::Voted variant: field choice: &'a Choicevote: &'a Vote.
tests/test_vote.rs Updated JSON argument key "choice" to "vote" in all relevant test cases.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Contract
    participant Events

    User->>Contract: vote(vote, staking_pool_id)
    Contract->>Contract: internal_vote(vote, account_id)
    Contract->>Events: emit Event::Voted { vote }
Loading

Possibly related PRs

Suggested reviewers

  • arkff202310
  • dongcool

Poem

A rabbit hopped into the code one night,
Swapping "Choice" for "Vote" to make it right.
Events and tests now clearly state,
What each voter does decide or relate.
With tidy names, the contract’s neat—
A voting update, crisp and sweet!
🐇✨


📜 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 f706fe7 and b958fa2.

📒 Files selected for processing (3)
  • src/events.rs (1 hunks)
  • src/lib.rs (17 hunks)
  • tests/test_vote.rs (13 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Build
  • GitHub Check: Code Linter
  • GitHub Check: Tests
🔇 Additional comments (7)
src/events.rs (1)

21-21: LGTM! Field renamed consistently with enum refactoring.

The field name and type reference have been properly updated from choice: &'a Choice to vote: &'a Vote, maintaining consistency with the enum renaming throughout the codebase.

tests/test_vote.rs (1)

25-25: LGTM! Test arguments updated consistently.

All JSON argument keys have been systematically updated from "choice" to "vote" across all test functions, maintaining consistency with the contract API changes.

Also applies to: 37-37, 69-69, 80-80, 120-120, 191-191, 253-253, 302-302, 321-321, 373-373, 392-392, 444-444, 481-481

src/lib.rs (5)

20-23: LGTM! Enum renamed consistently.

The enum has been properly renamed from Choice to Vote while maintaining the same variants and functionality.


89-100: LGTM! Public method signature updated consistently.

The method signature, parameter names, and documentation have been updated to use the new Vote enum. The functionality remains unchanged.

Note that this is a breaking API change. Ensure that any external callers of this contract are updated to use the new parameter names and enum variants.


104-120: LGTM! Callback method updated consistently.

The callback method parameters and internal calls have been properly updated to use the renamed enum and parameter names.


123-153: LGTM! Internal voting logic updated consistently.

All internal references have been properly updated:

  • Method parameter renamed
  • Variable names updated
  • Pattern matching uses new enum variants
  • Event emission uses new field name

The voting logic remains functionally identical.


305-319: LGTM! Test code updated comprehensively.

All test functions have been updated to use the new Vote enum variants (Vote::Yes and Vote::No). The test coverage and functionality remain intact.

Also applies to: 331-331, 344-344, 359-359, 362-362, 378-378, 390-390, 423-423, 446-446, 456-476, 490-490, 537-537, 548-548

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

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

@linguists linguists merged commit a42e490 into main Jun 24, 2025
7 checks passed
@linguists linguists deleted the refactor/rename-to-vote branch June 24, 2025 01: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.

3 participants