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(synapse-interface): portfolio gas tokens #2401

Merged
merged 53 commits into from
Apr 17, 2024

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Mar 29, 2024

  • Adding Gas Token Assets held by a Wallet to the Portfolio
  • Add Tooltip for gas icon
  • Update fetchPortfolioBalances function to catch errors thrown by a single network fetch, so we still return remainder of successfully fetched data

Summary by CodeRabbit

  • New Features
    • Introduced a GasTokenAsset component to display gas token information in the portfolio.
    • Added a new GasIcon component for rendering gas icons.
    • Updated the portfolio to show more detailed token information on hover using the new HoverTooltip component.
    • Added constants for various gas tokens across different chains.
  • Enhancements
    • Improved the display and formatting of token balances in the portfolio.

d39739942477b4e553402f39435532ad12b04d1f: synapse-interface preview link
638ea1d2e84dda34dc5e14bcbc27aa6aa0cedcde: synapse-interface preview link
ab473258d43e90cbe02b9e302926a12124a52ac0: synapse-interface preview link
aa037d6e680787740b03e6d320c8a85366b5ba81: synapse-interface preview link
ad76b84ba2ec701bc9e4f7aead0f2a7b05fd0c91: synapse-interface preview link
f48865de5a13b54020abbc0759ff3c1066bfaa78: synapse-interface preview link
3bb843aed6438f0e5d6121604b7b45b712a5e967: synapse-interface preview link
860abc9072722dd6c9d9ef21d752603e6000d9db: synapse-interface preview link
6e96a040a397f73b5c7ef66ae3962b902f67290b: synapse-interface preview link
783b5d8a932cf8336a0eedceca28d7408e20d9d5: synapse-interface preview link
2844125253cfba3ecf17faf97035800b1507876d: synapse-interface preview link
34fec38bf3bdd373c91922324c620a6af44b89bc: synapse-interface preview link
0682fd8a388f3113668bb1612e876deff7438f49: synapse-interface preview link
f73d5faf30ea5e8128c275710c0f19cf6236f312: synapse-interface preview link
ec260dd3b76775a437b25041224b00b2ac093290: synapse-interface preview link
2ac9c55f86117091ac3a879c982b38c4e13ccc10: synapse-interface preview link
9a9c1c3e2f65df28cbed3ca3c4c2888d1e1453e0: synapse-interface preview link
0e2bca1a8edce2646ba8a52e474610187e228ff9: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Mar 29, 2024

Walkthrough

The recent update focuses on enhancing the portfolio interface with a special emphasis on gas tokens. It introduces a new GasTokenAsset component, refines token display using HoverTooltip, adds a visual representation through GasIcon, and improves the logic for fetching balances. These changes are aimed at improving the handling of gas tokens and enhancing the overall user experience within the portfolio.

Changes

Files Change Summary
.../PortfolioTokenAsset.tsx, .../GasTokenAsset.tsx Added GasTokenAsset component for gas token information.
.../PortfolioTokenVisualizer.tsx Updated to use HoverTooltip for token details on hover; refactored display logic.
.../icons/GasIcon.tsx Introduced GasIcon component for gas token icons.
.../fetchPortfolioBalances.tsx, .../constants/tokens/gasTokens.ts Adjusted balance fetching for gas tokens; added gas token constants.
.../constants/chains/master.tsx Updated the symbol of the native currency for the CANTO chain to 'NOTE'.
.../utils/actions/fetchPortfolioBalances.tsx, .../constants/tokens/index.ts Refactored token fetching logic to handle gas tokens separately; improved error handling for balance fetching.

A Whimsical Poem by CodeRabbit

In the realm of code, where tokens dance,
A new asset comes, not by chance.
🚀 Gas flows free, in portfolios it gleams,
Guided by icons, and the coder's dreams.
Hover and find, what secrets it holds,
In tales of balances, bravely told.
🐰 With every click, a journey anew,
Our digital warren, forever true.


Recent Review Details

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between b3a272c and cbfcb6c.
Files selected for processing (1)
  • packages/synapse-interface/constants/tokens/index.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/constants/tokens/index.ts

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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

cloudflare-workers-and-pages bot commented Mar 29, 2024

Deploying sanguine with  Cloudflare Pages  Cloudflare Pages

Latest commit: cbfcb6c
Status: ✅  Deploy successful!
Preview URL: https://078328ef.sanguine.pages.dev
Branch Preview URL: https://fe-portfolio-gas-tokens.sanguine.pages.dev

View logs

Copy link

cloudflare-workers-and-pages bot commented Mar 29, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: cbfcb6c
Status: ✅  Deploy successful!
Preview URL: https://b014f3d2.sanguine-fe.pages.dev
Branch Preview URL: https://fe-portfolio-gas-tokens.sanguine-fe.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: 0

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between ae858ad and e06fe7e.
Files selected for processing (5)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx (2 hunks)
  • packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (4 hunks)
  • packages/synapse-interface/constants/tokens/gasTokens.ts (1 hunks)
  • packages/synapse-interface/constants/tokens/index.ts (4 hunks)
  • packages/synapse-interface/utils/actions/fetchPortfolioBalances.tsx (2 hunks)
Additional Context Used
Additional comments not posted (22)
packages/synapse-interface/constants/tokens/gasTokens.ts (8)

11-18: The GasToken type definition is clear and aligns with the intended use of gas tokens within the application. It includes all necessary fields for representing a gas token.


17-17: The icon field in the GasToken type is typed as any. For better type safety and to leverage TypeScript's capabilities, consider specifying a more precise type for icons, such as string if icons are represented by URLs or paths, or a specific type if icons are React components.


33-42: The definition of BNB_Gas as a GasToken is correctly structured and includes all necessary details. The use of zeroAddress for the token address and the inclusion of an icon are appropriate.


44-53: The METIS gas token is correctly defined. It follows the structure established by the GasToken type and includes relevant details such as the chain ID, symbol, name, decimals, and icon.


55-64: The NOTE gas token, representing the Canto network's native token, is correctly defined. The naming, structure, and included details are consistent with the other gas token definitions.


66-75: The MOVR gas token for the Moonriver network is correctly defined. The structure and details provided are consistent with the expectations for a GasToken.


77-86: The GLMR gas token for the Moonbeam network is correctly defined. The structure and details provided are consistent with the expectations for a GasToken.


88-97: The ONE gas token for the Harmony network is correctly defined. The structure and details provided are consistent with the expectations for a GasToken.

packages/synapse-interface/utils/actions/fetchPortfolioBalances.tsx (3)

3-6: The addition of GAS_TOKENS to the imports is appropriate for the purpose of integrating gas tokens into the portfolio balances fetching logic. This change enables the function to consider gas tokens alongside bridgeable tokens.


58-70: The logic for handling currentChainTokens has been updated to include gas tokens by concatenating them with bridgeable tokens and pool tokens (if available). This approach ensures that gas tokens are considered when fetching portfolio balances. The use of .concat for merging arrays is appropriate and maintains readability.


58-70: Consider adding error handling for the case where getTokenBalances fails for a specific chain. Currently, if getTokenBalances throws an error, it could cause the entire fetchPortfolioBalances function to fail. Implementing a try-catch block around the getTokenBalances call and handling errors gracefully can improve the robustness of the function.

packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx (3)

17-17: The import of the GasToken type is correctly added to support the typing of gas tokens within the GasTokenAsset component. This ensures type safety and clarity in the component's props.


30-59: The GasTokenAsset component is well-implemented, providing a clear and concise way to display gas token information. The use of destructuring for props, the rendering of the token's icon, and the display of the formatted balance and symbol are all appropriate. The component enhances the portfolio section by allowing for the distinct visualization of gas tokens.


30-59: Consider adding a tooltip or some form of description to the GasTokenAsset component to provide users with more context about gas tokens, especially for users who might not be familiar with the concept. This can improve the user experience by making the portfolio section more informative.

packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (4)

22-24: The addition of imports for GAS_TOKENS, GasTokenAsset, and GasToken is appropriate for the purpose of integrating gas token information into the SingleNetworkPortfolio component. These imports enable the component to handle gas tokens distinctly from bridgeable tokens.


36-61: The filterOutGasTokens function is correctly implemented to separate gas tokens from the list of all tokens based on the chain ID. This function enhances the portfolio section by allowing for distinct handling and display of gas tokens alongside bridgeable tokens. The use of array methods such as .flatMap and .forEach for processing tokens is appropriate and maintains code readability.


149-159: The rendering logic for gas tokens using the GasTokenAsset component is correctly implemented. It ensures that gas tokens, if present, are displayed distinctly from bridgeable tokens. This approach enhances the user experience by providing a more comprehensive view of the user's assets.


149-159: Consider adding a section header or some form of visual distinction between gas tokens and bridgeable tokens when rendering them in the portfolio. This can improve the clarity and usability of the portfolio section by making it easier for users to differentiate between the two types of tokens.

packages/synapse-interface/constants/tokens/index.ts (4)

4-4: The import of gas tokens from @constants/tokens/gasTokens is correctly added to support the integration of gas tokens into the token constants module. This change enables the application to handle gas tokens alongside bridgeable tokens.


9-9: The import of the GasToken interface from @constants/tokens/gasTokens is appropriate for ensuring type safety and clarity when working with gas tokens within this module.


78-95: The getGasTokens function is correctly implemented to retrieve gas tokens by chain. This function enhances the application's ability to process gas tokens alongside bridgeable tokens, facilitating their integration into the portfolio. The use of Object.entries and array methods for processing tokens is appropriate and maintains code readability.


121-121: The assignment of GAS_TOKENS using the getGasTokens function is correctly implemented. This ensures that gas tokens are available for use throughout the application, allowing for a more comprehensive representation of a user's assets.

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

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between e06fe7e and c9cf3e8.
Files selected for processing (2)
  • packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (4 hunks)
  • packages/synapse-interface/constants/tokens/gasTokens.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx
  • packages/synapse-interface/constants/tokens/gasTokens.ts
Additional Context Used

Copy link

codecov bot commented Mar 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.92864%. Comparing base (f5a7f22) to head (cbfcb6c).

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2401         +/-   ##
===================================================
- Coverage   47.05001%   46.92864%   -0.12137%     
===================================================
  Files            384         383          -1     
  Lines          29373       29189        -184     
  Branches          83          83                 
===================================================
- Hits           13820       13698        -122     
+ Misses         14102       14036         -66     
- Partials        1451        1455          +4     
Flag Coverage Δ
packages 90.62500% <ø> (+0.09766%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

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 Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between c9cf3e8 and d6554ed.
Files selected for processing (4)
  • packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx (1 hunks)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx (5 hunks)
  • packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (5 hunks)
  • packages/synapse-interface/constants/tokens/gasTokens.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx
  • packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx
  • packages/synapse-interface/constants/tokens/gasTokens.ts
Additional Context Used
Additional comments not posted (1)
packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx (1)

13-13: Ensure the Token type consistently defines decimals as a number to avoid unnecessary type assertions.

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

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between d6554ed and 66e9130.
Files selected for processing (2)
  • packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx (1 hunks)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx
Additional Context Used

@abtestingalpha abtestingalpha changed the title Fe/portfolio gas tokens feat(synapse-interface): portfolio gas tokens Apr 3, 2024
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: 0

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 6a31c29 and 601ea4d.
Files selected for processing (1)
  • packages/synapse-interface/components/Portfolio/components/HoverTooltip.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/components/Portfolio/components/HoverTooltip.tsx

@bigboydiamonds bigboydiamonds merged commit d43f3ee into master Apr 17, 2024
42 checks passed
@bigboydiamonds bigboydiamonds deleted the fe/portfolio-gas-tokens branch April 17, 2024 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants