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

feat: improve token logos, fallbacks, improve code #59

Merged
merged 7 commits into from
Jun 7, 2024

Conversation

kemuru
Copy link
Contributor

@kemuru kemuru commented Jun 6, 2024

PR-Codex overview

This PR removes the dependency on EthTokenIcon in various components, updates token icons, and refactors token logo rendering.

Detailed summary

  • Removed EthTokenIcon dependency from multiple files
  • Updated token icons in eth.svg, usdt.svg, pnk.svg, and dai.svg
  • Refactored token logo rendering in TokenItem/index.tsx and DropdownButton.tsx

The following files were skipped due to too many changes: web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/DropdownButton.tsx, web/src/assets/svgs/icons/tokens/unknown.svg, web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/TokenItem/TokenIcon.tsx, web/src/assets/svgs/icons/tokens/matic.svg, web/src/assets/svgs/icons/tokens/gno.svg, web/src/assets/svgs/icons/tokens/op.svg, web/src/assets/svgs/icons/tokens/usdc.svg, web/src/assets/svgs/icons/tokens/arb.svg, web/src/assets/svgs/icons/tokens/weth.svg

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Introduced a TokenIcon component for dynamic token icon rendering based on the token symbol.
  • Refactor

    • Updated various components to use the new TokenIcon component, replacing the old TokenLogo styled image.
    • Refactored the logic for determining and displaying assetSymbol in transaction-related components for better clarity and consistency.
  • Chores

    • Removed unused imports and redundant code related to token icons across multiple files.

Copy link
Contributor

coderabbitai bot commented Jun 6, 2024

Walkthrough

The recent changes across various files focus on enhancing token icon handling and improving the rendering of transaction details. The updates include removing redundant imports, introducing a new TokenIcon component for dynamic icon rendering, and refactoring how token symbols and logos are managed and displayed. Additionally, error handling and local storage interactions have been refined to streamline the user experience.

Changes

Files Change Summary
web/src/hooks/useFilteredTokens.ts Removed EthTokenIcon import, updated logo assignment to use tokenMetadata.logo directly.
web/src/pages/NewTransaction/.../TokenSelector/DropdownButton.tsx Replaced TokenLogo styled image with TokenIcon component for better token icon rendering.
web/src/pages/NewTransaction/.../TokenSelector/TokenItem/TokenIcon.tsx Introduced TokenIcon component for dynamic token icon rendering based on token symbol.
web/src/pages/NewTransaction/.../TokenSelector/TokenItem/index.tsx Replaced TokenLogo styled component with TokenIcon component in TokenItem.
web/src/pages/NewTransaction/.../TokenSelector/index.tsx Removed localStorage item before initializing tokens.
web/src/utils/fetchNativeToken.ts Removed EthTokenIcon import and logo property assignment using EthTokenIcon.
web/src/utils/fetchTokenInfo.ts Removed default values for symbol and logo properties, updated error handling.
web/src/components/TransactionCard/index.tsx Refactored assetSymbol calculation to use token presence for rendering transaction details.
web/src/pages/MyTransactions/Modal/PaymentReleased/Header.tsx Replaced token usage with assetSymbol from useTransactionDetailsContext, removed useNativeTokenSymbol import.
web/src/pages/MyTransactions/TransactionDetails/index.tsx Updated assetSymbol usage and passed it as a prop to a child component.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant TokenSelector
    participant TokenIcon
    participant TransactionCard
    participant Header

    User->>TokenSelector: Select Token
    TokenSelector->>TokenIcon: Fetch Token Icon
    TokenIcon-->>TokenSelector: Return Token Icon
    TokenSelector-->>User: Display Token Icon
    
    User->>TransactionCard: View Transaction Details
    TransactionCard->>TokenSelector: Get Token Info
    TokenSelector-->>TransactionCard: Return Token Info
    TransactionCard->>Header: Display Transaction with Token Symbol
    Header-->>User: Show Transaction Details
Loading

Poem

In the land of code, where tokens gleam,
A new icon shines, like a dream.
No more static, icons flow,
Dynamic symbols, in the glow.
Transactions clear, details bright,
Coding magic, in the night.
🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Copy link

netlify bot commented Jun 6, 2024

Deploy Preview for kleros-escrow-v2 ready!

Name Link
🔨 Latest commit c35f31a
🔍 Latest deploy log https://app.netlify.com/sites/kleros-escrow-v2/deploys/6661a1509112450008205794
😎 Deploy Preview https://deploy-preview-59--kleros-escrow-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jun 6, 2024

Deploy Preview for kleros-escrow-v2 ready!

Name Link
🔨 Latest commit c2eb22b
🔍 Latest deploy log https://app.netlify.com/sites/kleros-escrow-v2/deploys/6661db4fcca16400086532de
😎 Deploy Preview https://deploy-preview-59--kleros-escrow-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6cae895 and 1486d17.

Files ignored due to path filters (12)
  • web/src/assets/svgs/icons/eth-token-icon.png is excluded by !**/*.png
  • web/src/assets/svgs/icons/tokens/arb.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/dai.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/eth.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/gno.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/matic.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/op.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/pnk.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/unknown.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/usdc.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/usdt.svg is excluded by !**/*.svg
  • web/src/assets/svgs/icons/tokens/weth.svg is excluded by !**/*.svg
Files selected for processing (7)
  • web/src/hooks/useFilteredTokens.ts (2 hunks)
  • web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/DropdownButton.tsx (3 hunks)
  • web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/TokenItem/TokenIcon.tsx (1 hunks)
  • web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/TokenItem/index.tsx (3 hunks)
  • web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/index.tsx (1 hunks)
  • web/src/utils/fetchNativeToken.ts (1 hunks)
  • web/src/utils/fetchTokenInfo.ts (1 hunks)
Files skipped from review due to trivial changes (3)
  • web/src/hooks/useFilteredTokens.ts
  • web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/TokenItem/index.tsx
  • web/src/utils/fetchNativeToken.ts
Additional context used
Biome
web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/index.tsx

[error] 31-31: This hook does not specify all of its dependencies: alchemyInstance (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.


[error] 31-31: This hook does not specify all of its dependencies: setTokens (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.

Additional comments not posted (5)
web/src/utils/fetchTokenInfo.ts (2)

8-9: LGTM! Using token metadata directly for symbol and logo properties enhances data consistency.


13-13: Excellent change to log errors instead of returning default values. This improves error transparency and debugging.

web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/DropdownButton.tsx (1)

4-4: The integration of the TokenIcon component enhances the UI by dynamically displaying token icons. Good job on this refactor!

Also applies to: 48-58

web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/TokenItem/TokenIcon.tsx (1)

1-57: The new TokenIcon component is well-implemented with a clear structure for handling various token icons dynamically. This should greatly improve the flexibility and maintainability of the token display logic.

web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/index.tsx (1)

33-33: Proactive removal of tokens from local storage ensures clean state management. Good practice!

kemuru and others added 3 commits June 6, 2024 14:15
update dependencies of useeffect hook

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@kemuru kemuru linked an issue Jun 6, 2024 that may be closed by this pull request
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1486d17 and f997082.

Files selected for processing (4)
  • web/src/components/TransactionCard/index.tsx (3 hunks)
  • web/src/pages/MyTransactions/Modal/PaymentReleased/Header.tsx (2 hunks)
  • web/src/pages/MyTransactions/TransactionDetails/index.tsx (3 hunks)
  • web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/index.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/index.tsx
Additional context used
Biome
web/src/pages/MyTransactions/TransactionDetails/index.tsx

[error] 59-59: This hook does not specify all of its dependencies: assetSymbol (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.


[error] 59-59: This hook specifies more dependencies than necessary: erc20TokenSymbol, nativeTokenSymbol, token (lint/correctness/useExhaustiveDependencies)

This dependency can be removed from the list.

This dependency can be removed from the list.

This dependency can be removed from the list.

Additional comments not posted (2)
web/src/pages/MyTransactions/Modal/PaymentReleased/Header.tsx (1)

13-17: LGTM! The usage of assetSymbol from the context is a good practice for dynamic content rendering.

web/src/components/TransactionCard/index.tsx (1)

75-75: LGTM! The dynamic handling of assetSymbol is implemented consistently across the component.

Also applies to: 94-94, 115-115

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 6, 2024
@kemuru kemuru marked this pull request as ready for review June 7, 2024 03:04
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f997082 and c2eb22b.

Files selected for processing (2)
  • web/src/pages/MyTransactions/TransactionDetails/index.tsx (3 hunks)
  • web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/index.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/src/pages/MyTransactions/TransactionDetails/index.tsx
Additional context used
Biome
web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/index.tsx

[error] 33-33: This hook does not specify all of its dependencies: setTokens (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.

Additional comments not posted (2)
web/src/pages/NewTransaction/Terms/Payment/GeneralTransaction/TokenAndAmount/TokenSelector/index.tsx (2)

38-38: The dependencies for this useEffect are correctly specified.


35-35: Ensure removal of "tokens" from localStorage is intentional and secure.

@kemuru kemuru merged commit 81af42e into master Jun 7, 2024
6 checks passed
@kemuru kemuru deleted the feat/token-icon-impros branch June 7, 2024 10:00
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.

Token icons fallbacks
1 participant