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

fix pending validator icon #236

Merged
merged 1 commit into from
Feb 5, 2025
Merged

fix pending validator icon #236

merged 1 commit into from
Feb 5, 2025

Conversation

chalabi2
Copy link
Collaborator

@chalabi2 chalabi2 commented Feb 5, 2025

This PR fixes an issue where pending validators who do not have a logo_uri do not properly display the stock generated avatar. #223

If you'd like to test this pr locally without submitting a validator creation request add

const pendingValsMock = [
    {
      operator_address: 'manifest1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsfmy9qj',
      consensus_pubkey: undefined,
      jailed: false,
      status: BondStatus.BOND_STATUS_BONDED,

      tokens: '1000000',
      delegator_shares: '1000000',
      description: {
        moniker: 'Test Validator',
        identity: 'test123',
        website: 'https://test.com',
        details: 'test details',
        security_contact: '[email protected]',
      },
      unbonding_height: BigInt(0),
      unbonding_time: new Date(),
      commission: {
        rate: '0.1',
        max_rate: '0.2',
        update_time: new Date(),
        max_change_rate: '0.01',
        commission_rates: {
          rate: '0.1',
          max_rate: '0.2',
          max_change_rate: '0.01',
        },
      },
      min_self_delegation: '1000000',
      unbonding_on_hold_ref_count: BigInt(0),
      unbonding_ids: [],
    },
  ];

In the pending data for the ValidatorList

Summary by CodeRabbit

  • Bug Fixes
    • Improved logo display by automatically showing a fallback avatar when no custom image is available.
    • Ensured that the current input value is properly used during updates.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

This change refactors the conditional rendering logic in the ValidatorDetailsModal component. It updates the logic for displaying the validator's logo by checking for the existence of validator?.logo_url instead of verifying that it is not an empty string. A fallback using the ProfileAvatar component is now rendered when the logo URL is absent. Additionally, the handleUpdate function is modified to pass the current power state directly via the update button's onClick handler.

Changes

File(s) Change Summary
components/admins/modals/validatorModal.tsx Updated conditional rendering for logo: now checks for existence of validator?.logo_url; added fallback ProfileAvatar rendering; updated handleUpdate call to pass current power state directly.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant M as ValidatorDetailsModal
    participant F as ProfileAvatar (Fallback)
    
    U->>M: Open modal
    alt Validator has logo_url
        M->>M: Render validator logo
    else
        M->>F: Render ProfileAvatar
    end
    U->>M: Click update button
    M->>M: Execute handleUpdate(current power)
    M-->>U: Process update
Loading

Possibly related PRs

  • fix: pending validator power #228: Modifies the handleUpdate function in the ValidatorDetailsModal component, specifically how the power value is processed and submitted.

Suggested reviewers

  • jgryffindor

Poem

I’m just a rabbit with hops so light,
In code fields where changes take flight.
Logo checks now gleam with grace,
Fallback smiles in every place,
Hopping through updates, day and night! 🐰

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 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 d08d3d1 and df697f3.

📒 Files selected for processing (1)
  • components/admins/modals/validatorModal.tsx (1 hunks)
🔇 Additional comments (1)
components/admins/modals/validatorModal.tsx (1)

168-174: LGTM! The logo rendering logic now handles missing logos correctly.

The simplified condition and consistent fallback to ProfileAvatar properly address the issue with pending validators' icon display.


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>, 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.

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.

@chalabi2 chalabi2 requested review from hansl and fmorency February 5, 2025 06:12
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.07%. Comparing base (d08d3d1) to head (df697f3).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #236   +/-   ##
=======================================
  Coverage   55.06%   55.07%           
=======================================
  Files         199      199           
  Lines       16761    16762    +1     
=======================================
+ Hits         9230     9231    +1     
  Misses       7531     7531           

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

@fmorency
Copy link
Contributor

fmorency commented Feb 5, 2025

utACK

@fmorency fmorency merged commit 25265b2 into main Feb 5, 2025
8 checks passed
@fmorency fmorency deleted the chalabi/fix-pendingVal-icon branch February 5, 2025 14:33
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