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

Add a verified icon next to the denomination name for MFX #242

Merged
merged 8 commits into from
Feb 6, 2025

Conversation

hansl
Copy link
Contributor

@hansl hansl commented Feb 5, 2025

There is a refactor to be done here which I'll file an issue for: moving all the logic of having the <DenomImage /> and <VerifiedIcon /> inside a new component DenomName or similar. I think this should be done as a follow up.

Right now I found 3 places where this token shows up as is. You can see all 3 in the screenshot:

CleanShot 2025-02-05 at 09 18 07@2x

Let me know if that's sufficient to consider the issue fixed.

Fixes #218
Fixes #243

Summary by CodeRabbit

  • New Features

    • Introduced a DenomDisplay component for improved token information presentation, consolidating the display of token images and names.
    • Added a verified status icon that appears next to qualifying tokens, enhancing clarity in token displays and selection menus.
  • Bug Fixes

    • Updated token rendering logic to ensure consistent display across various components.
  • Style

    • Applied updated styling to ensure the verified icon integrates smoothly with the overall design.

@hansl hansl requested a review from fmorency February 5, 2025 17:18
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

This pull request introduces the DenomDisplay component, which consolidates the rendering of token images and names into a single component. The VerifiedIcon component is also introduced to indicate verified tokens. Several components, including TokenList, SendForm, and IbcSendForm, have been updated to utilize DenomDisplay instead of DenomImage, enhancing the display of token information. The changes do not alter the existing functionality or logic of these components.

Changes

File(s) Change Summary
components/bank/components/tokenList.tsx
components/bank/forms/sendForm.tsx
components/bank/forms/ibcSendForm.tsx
Replaced DenomImage with DenomDisplay for rendering token information, and added import of VerifiedIcon from @/components/icons.
components/icons/VerifiedIcon.tsx New reusable React functional component that renders an SVG icon representing a verified token.
components/icons/index.ts Added export statement for the VerifiedIcon component for use throughout the application.
components/factory/components/DenomDisplay.tsx New component that displays token information, including image and name, and conditionally renders the VerifiedIcon based on token metadata.
components/factory/components/DenomList.tsx Updated to use DenomDisplay for rendering token information instead of DenomImage.
components/factory/components/index.ts Added export statement for the DenomDisplay component for broader accessibility.

Assessment against linked issues

Objective Addressed Explanation
Verified token badge (#218)
Refactor denomination display in its own component (#243)

Possibly related PRs

  • feat: bank page rework #117: The changes in the main PR are related to the modifications in the DenomDisplay component, which is utilized in both the SendForm and IbcSendForm components in the retrieved PR, indicating a direct connection at the code level.
  • fix: send form icons #177: The changes in the main PR are related to the modifications of the DenomDisplay component, which is also referenced in the retrieved PR where DenomImage is updated to include a withBackground prop, indicating a direct connection in how token information is rendered.
  • Add denom prefix #182: The changes in the main PR, which involve replacing DenomImage with DenomDisplay in multiple components, are related to the retrieved PR as both involve modifications to how token information is displayed, specifically through the use of the DenomDisplay component.

Suggested labels

UX, enhancement

Suggested reviewers

  • fmorency

Poem

I'm a rabbit, hopping in code delight,
With DenomDisplay, everything feels right.
A badge for tokens, shiny and true,
Verified with care, just for you!
In the meadow of code, we frolic and play,
Making sure our tokens are here to stay!
🥕🐇


📜 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 d7cb26b and 9fddada.

📒 Files selected for processing (1)
  • components/factory/components/DenomDisplay.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/factory/components/DenomDisplay.tsx

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.

@hansl
Copy link
Contributor Author

hansl commented Feb 5, 2025

Created #243

Copy link

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 63.15789% with 28 lines in your changes missing coverage. Please review.

Project coverage is 54.97%. Comparing base (8af1d4e) to head (9fddada).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
components/icons/VerifiedIcon.tsx 3.44% 28 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #242      +/-   ##
==========================================
- Coverage   55.08%   54.97%   -0.12%     
==========================================
  Files         200      203       +3     
  Lines       16873    16916      +43     
==========================================
+ Hits         9294     9299       +5     
- Misses       7579     7617      +38     

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

@hansl
Copy link
Contributor Author

hansl commented Feb 5, 2025

I could fix #243 as part of this PR as well if you're okay with delaying it.

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

🧹 Nitpick comments (2)
components/icons/VerifiedIcon.tsx (1)

4-32: Add accessibility attributes to the SVG icon.

The SVG icon should include accessibility attributes to improve screen reader support.

Apply this diff:

 export const VerifiedIcon: React.FC<SVGProps<SVGSVGElement>> = props => (
   <svg
     width="1em"
     height="1em"
     viewBox="0 0 24 24"
     fill="none"
     xmlns="http://www.w3.org/2000/svg"
     data-reactroot=""
+    role="img"
+    aria-label="Verified"
     {...props}
   >
components/bank/components/tokenList.tsx (1)

110-118: Consider extracting token display logic.

Since there's a planned refactor to create a DenomName component, consider extracting this token display logic into a separate component now to make the future refactor easier.

Example implementation:

interface TokenDisplayProps {
  metadata: any;
  truncateLength?: number;
}

const TokenDisplay: React.FC<TokenDisplayProps> = ({ metadata, truncateLength = 12 }) => (
  <>
    {truncateString(metadata?.display ?? '', truncateLength).toUpperCase()}
    {metadata?.base?.includes('umfx') && (
      <VerifiedIcon
        style={{ margin: '0 4px' }}
        className="inline-block text-primary"
      />
    )}
  </>
);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8af1d4e and c965eca.

📒 Files selected for processing (4)
  • components/bank/components/tokenList.tsx (2 hunks)
  • components/bank/forms/sendForm.tsx (3 hunks)
  • components/icons/VerifiedIcon.tsx (1 hunks)
  • components/icons/index.ts (1 hunks)
🧰 Additional context used
📓 Learnings (1)
components/bank/components/tokenList.tsx (1)
Learnt from: chalabi2
PR: liftedinit/manifest-app#161
File: components/factory/components/DenomList.tsx:408-417
Timestamp: 2025-01-07T01:23:26.489Z
Learning: In the manifest-app project, MintModal and BurnModal are intentionally kept separate with their own forms, transactions, and queries, prioritizing code clarity and maintainability over abstraction.
🔇 Additional comments (2)
components/icons/index.ts (1)

28-28: LGTM!

The export statement follows the established pattern in the file.

components/bank/components/tokenList.tsx (1)

112-117: LGTM!

The implementation correctly adds the verified icon for MFX tokens with appropriate styling.

components/bank/forms/sendForm.tsx Outdated Show resolved Hide resolved
@fmorency
Copy link
Contributor

fmorency commented Feb 5, 2025

I could fix #243 as part of this PR as well if you're okay with delaying it.

Yes, please include #243 as part of this PR.

@hansl
Copy link
Contributor Author

hansl commented Feb 5, 2025

Here's the latest screenshot:

CleanShot 2025-02-05 at 12 44 07@2x

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

🔭 Outside diff range comments (1)
components/factory/components/DenomList.tsx (1)

511-511:

🧩 Analysis chain

Verify the MFX token identification logic.

The code uses denom.base.includes('umfx') to identify MFX tokens. This string matching approach might be fragile if there are other tokens with similar names.

Consider using one of these alternatives:

  1. Use an exact match:
-disabled={denom.base.includes('umfx')}
+disabled={denom.base === 'umfx'}
  1. Use a constant:
const MFX_DENOM = 'umfx';
// Then use:
disabled={denom.base === MFX_DENOM}

Let's verify the current usage:

Also applies to: 519-519, 527-527


🏁 Script executed:

#!/bin/bash
# Search for other instances of 'umfx' string matching
rg -i "umfx" --type ts --type tsx

Length of output: 61


I'll re-run the search with an updated command that explicitly looks for *.ts and *.tsx files.


🏁 Script executed:

#!/bin/bash
# Re-run search for 'umfx' in both .ts and .tsx files using glob patterns
rg -i "umfx" -g "*.ts" -g "*.tsx"

Length of output: 3115

Action: Update the MFX token matching logic for consistency and precision

The search results reveal that while some parts of the code use strict equality (e.g., in DenomDisplay.tsx and send forms), others (such as DenomList.tsx and DenomImage.tsx) use the substring check with .includes('umfx'). This discrepancy can lead to potential false positives if a denom contains extra characters. It is advisable to refactor the code to use a constant and a strict equality check instead.

  • Update DenomList.tsx (lines 511, 519, and 527) to use an equality check.
  • Consider defining a constant (e.g. const MFX_DENOM = 'umfx') in a shared utility or config file to ensure consistency.

[iam_verified_issues_found]

🧹 Nitpick comments (1)
components/factory/components/DenomDisplay.tsx (1)

16-16: Consider making the verified token check configurable.

The hard-coded check for 'umfx' reduces reusability. Consider making this configurable through props or environment variables.

-  const verified = metadata?.base === 'umfx';
+  const verifiedTokens = ['umfx']; // Could be moved to config/env
+  const verified = metadata?.base && verifiedTokens.includes(metadata.base);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c965eca and c216b83.

📒 Files selected for processing (7)
  • components/bank/components/tokenList.tsx (2 hunks)
  • components/bank/forms/ibcSendForm.tsx (3 hunks)
  • components/bank/forms/sendForm.tsx (3 hunks)
  • components/factory/components/DenomDisplay.tsx (1 hunks)
  • components/factory/components/DenomList.tsx (2 hunks)
  • components/factory/components/index.ts (1 hunks)
  • components/icons/VerifiedIcon.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/bank/components/tokenList.tsx
  • components/bank/forms/sendForm.tsx
🧰 Additional context used
🪛 GitHub Check: codecov/patch
components/icons/VerifiedIcon.tsx

[warning] 4-31: components/icons/VerifiedIcon.tsx#L4-L31
Added lines #L4 - L31 were not covered by tests

🔇 Additional comments (6)
components/factory/components/index.ts (1)

3-3: LGTM!

The export statement for the new DenomDisplay component follows the established pattern.

components/factory/components/DenomDisplay.tsx (1)

18-29: LGTM on the component structure!

The component effectively combines the token image and name display with conditional verified icon rendering.

components/icons/VerifiedIcon.tsx (1)

4-33: Add test coverage for the VerifiedIcon component.

Static analysis indicates missing test coverage for this component.

Would you like me to generate test cases for the VerifiedIcon component? The tests should verify:

  1. Component renders without crashing
  2. Props are correctly passed to the SVG element
  3. Accessibility attributes are present
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 4-31: components/icons/VerifiedIcon.tsx#L4-L31
Added lines #L4 - L31 were not covered by tests

components/bank/forms/ibcSendForm.tsx (1)

287-294: LGTM on DenomDisplay integration!

The new DenomDisplay component is correctly integrated in both the token selector and dropdown list, with appropriate props passed for denomination and metadata.

Also applies to: 330-334

components/factory/components/DenomList.tsx (2)

3-4: LGTM! Import changes align with the PR objectives.

The addition of DenomDisplay import while retaining DenomImage suggests a gradual transition, which is consistent with the planned refactoring mentioned in the PR description.


486-486: LGTM! DenomDisplay integration looks good.

The replacement of the token display logic with the new DenomDisplay component aligns with the PR objective of adding verified icons next to denomination names.

components/factory/components/DenomDisplay.tsx Outdated Show resolved Hide resolved
components/icons/VerifiedIcon.tsx Outdated Show resolved Hide resolved
components/icons/VerifiedIcon.tsx Outdated Show resolved Hide resolved
@hansl
Copy link
Contributor Author

hansl commented Feb 5, 2025

@fmorency This is ready to review. We can move the list of verified token somewhere else when we have more than 1 :)

Copy link
Contributor

@fmorency fmorency left a comment

Choose a reason for hiding this comment

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

Thanks! It looks great!

bun run build fails with some error. Can you fix those?

(CI doesn't run that command; it probably should)

@hansl hansl requested a review from fmorency February 6, 2025 16:20
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.

Refactor denomination display in its own component Verified token badge
2 participants