Skip to content

Comments

feat/PRO-3335/token-audit#312

Merged
RanaBug merged 3 commits intostagingfrom
feat/PRO-3335/token-audit
May 22, 2025
Merged

feat/PRO-3335/token-audit#312
RanaBug merged 3 commits intostagingfrom
feat/PRO-3335/token-audit

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented May 21, 2025

Description

  • FE implementation of Token Audit on Token Atlas

How Has This Been Tested?

  • Existing Unit Tests and Manual testing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • New Features

    • Introduced a new section displaying external audit service links for tokens, including Token Sniffer, Go Plus, and Honeypot.is (where supported).
    • Added a new blockchain cards component to visually represent blockchains associated with token contracts.
  • Refactor

    • Replaced the previous blockchain card display in the token info column with the new token audit links section for a streamlined user experience.
  • Tests

    • Updated tests to reflect the new audit links section and removed tests related to the old blockchain card display. Improved assertions for loading and fallback states.

@RanaBug RanaBug requested a review from IAmKio May 21, 2025 15:45
@RanaBug RanaBug self-assigned this May 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 21, 2025

Walkthrough

Two new React components, BlockchainCards and TokenAudit, are introduced to handle blockchain card display and token audit links, respectively. The TokenInfoColumn component is refactored to remove its internal blockchain card logic, instead embedding the new TokenAudit component. Corresponding tests are updated to reflect these UI and logic changes.

Changes

File(s) Change Summary
src/apps/token-atlas/components/BlockchainCards/BlockchainCards.tsx New React component BlockchainCards created to display blockchain cards with show more/less functionality.
src/apps/token-atlas/components/TokenAudit/TokenAudit.tsx New React component TokenAudit created to display audit service links for a selected token.
src/apps/token-atlas/components/TokenInfoColumn/TokenInfoColumn.tsx Removed blockchain cards logic and UI; replaced with the new TokenAudit component.
src/apps/token-atlas/components/TokenInfoColumn/test/TokenInfoColumn.test.tsx Updated tests: removed blockchain cards assertions, refined loading state check, and improved fallback stats test.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TokenInfoColumn
    participant TokenAudit
    participant ReduxStore

    User->>TokenInfoColumn: Render component
    TokenInfoColumn->>TokenAudit: Render TokenAudit
    TokenAudit->>ReduxStore: Get selected token
    TokenAudit->>TokenAudit: Map chain ID to audit URLs
    TokenAudit-->>User: Display audit service links
Loading

Suggested reviewers

  • IAmKio

Poem

In the garden of code, two sprouts appear—
BlockchainCards and TokenAudit, both crystal clear.
Old chains step aside, audits now in view,
With links and stats, all shiny and new.
Tests hop along, keeping things right,
As rabbits rejoice in the soft morning light.
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn config production Use --omit=dev instead.
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-05-22T15_25_40_972Z-debug-0.log

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 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 5d36587 and b7870fc.

⛔ Files ignored due to path filters (4)
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokenMarketDataRow/tests/__snapshots__/LeftColumnTokenMarketDataRow.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokensWithMarketDataTile/test/__snapshots__/TokensWithMarketDataTile.test.tsx.snap is excluded by !**/*.snap
  • src/apps/token-atlas/components/TokenInfoColumn/test/__snapshots__/TokenInfoColumn.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • src/apps/token-atlas/components/TokenAudit/TokenAudit.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/apps/token-atlas/components/TokenAudit/TokenAudit.tsx
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: lint
  • GitHub Check: unit-tests
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages
✨ 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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented May 21, 2025

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: b7870fc
Status: ✅  Deploy successful!
Preview URL: https://83b3cae9.x-e62.pages.dev
Branch Preview URL: https://feat-pro-3335-token-audit.x-e62.pages.dev

View logs

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

🧹 Nitpick comments (1)
src/apps/token-atlas/components/BlockchainCards/BlockchainCards.tsx (1)

48-54: Consider adding fallback UI for empty blockchain list

The component doesn't handle the case when tokenBlockchainsList is empty but not loading.

  {isLoadingTokenDataInfo && (
    <CircularProgress
      size={32}
      sx={{ color: '#979797' }}
      data-testid="circular-loading"
    />
  )}
+  {!isLoadingTokenDataInfo && tokenBlockchainsList.length === 0 && (
+    <Body className="text-white/[.5]">No blockchain information available</Body>
+  )}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 55abe3d and 5d36587.

⛔ Files ignored due to path filters (9)
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokenMarketDataRow/tests/__snapshots__/LeftColumnTokenMarketDataRow.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokensWithMarketDataTile/test/__snapshots__/TokensWithMarketDataTile.test.tsx.snap is excluded by !**/*.snap
  • src/apps/token-atlas/components/TokenInfoColumn/test/__snapshots__/TokenInfoColumn.test.tsx.snap is excluded by !**/*.snap
  • src/apps/token-atlas/images/external-link-audit.svg is excluded by !**/*.svg
  • src/apps/token-atlas/images/go-plus-logo.png is excluded by !**/*.png
  • src/apps/token-atlas/images/honeypot-logo.png is excluded by !**/*.png
  • src/apps/token-atlas/images/token-audit-icon.png is excluded by !**/*.png
  • src/apps/token-atlas/images/token-sniffer-logo.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • src/apps/token-atlas/components/BlockchainCards/BlockchainCards.tsx (1 hunks)
  • src/apps/token-atlas/components/TokenAudit/TokenAudit.tsx (1 hunks)
  • src/apps/token-atlas/components/TokenInfoColumn/TokenInfoColumn.tsx (3 hunks)
  • src/apps/token-atlas/components/TokenInfoColumn/test/TokenInfoColumn.test.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/apps/token-atlas/components/TokenInfoColumn/test/TokenInfoColumn.test.tsx (1)
src/apps/token-atlas/reducer/tokenAtlasSlice.ts (1)
  • setTokenDataInfo (83-88)
src/apps/token-atlas/components/TokenAudit/TokenAudit.tsx (2)
src/apps/token-atlas/types/types.tsx (1)
  • SelectedTokenType (14-23)
src/services/tokensData.ts (1)
  • chainIdToChainNameTokensData (213-234)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Cloudflare Pages
  • GitHub Check: build
🔇 Additional comments (4)
src/apps/token-atlas/components/TokenInfoColumn/TokenInfoColumn.tsx (1)

45-45: LGTM - Clean replacement of blockchain cards with TokenAudit component

The implementation correctly replaces the previous blockchain cards section with the new TokenAudit component, improving component separation and responsibility.

src/apps/token-atlas/components/TokenInfoColumn/test/TokenInfoColumn.test.tsx (2)

70-78: LGTM - Test updated to match component changes

The test has been correctly updated to check for only one loading indicator after the component changes.


113-124: LGTM - Improved test for undefined token data

This test more explicitly verifies the component's behavior when token data is missing, using the actual Redux action to set undefined data.

src/apps/token-atlas/components/BlockchainCards/BlockchainCards.tsx (1)

32-35: LGTM - Handles edge cases for hidden cards calculation

The code correctly handles the case when there are fewer cards than can fit in the visible area.

// This is to make sure that if the chains do not all fit in one line, we add the number of hidden chains
const tokenBlockchainsList =
tokenDataInfo?.contracts.map((contract) => contract.blockchain) || [];
const numberVisibleCards = Math.floor((dimensions.width - 50) / 158);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Extract magic numbers into named constants

The calculation for visible cards uses hard-coded magic numbers (158 and 50) without explanation.

+  // Constants for card width calculation
+  const CHAIN_CARD_WIDTH = 158; // Width of a single chain card in pixels
+  const CONTAINER_PADDING = 50; // Extra padding or gap space to account for

-  const numberVisibleCards = Math.floor((dimensions.width - 50) / 158);
+  const numberVisibleCards = Math.floor((dimensions.width - CONTAINER_PADDING) / CHAIN_CARD_WIDTH);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const numberVisibleCards = Math.floor((dimensions.width - 50) / 158);
// Constants for card width calculation
const CHAIN_CARD_WIDTH = 158; // Width of a single chain card in pixels
const CONTAINER_PADDING = 50; // Extra padding or gap space to account for
const numberVisibleCards = Math.floor(
(dimensions.width - CONTAINER_PADDING) / CHAIN_CARD_WIDTH
);
🤖 Prompt for AI Agents
In src/apps/token-atlas/components/BlockchainCards/BlockchainCards.tsx at line
30, the calculation for numberVisibleCards uses hard-coded magic numbers 158 and
50. Extract these numbers into clearly named constants defined at the top of the
file or near the calculation to improve readability and maintainability. Replace
the literals with the constants in the calculation.

Copy link
Collaborator

@IAmKio IAmKio left a comment

Choose a reason for hiding this comment

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

LGTM

@RanaBug RanaBug merged commit f0af85d into staging May 22, 2025
7 of 8 checks passed
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