Skip to content

Comments

feat: show destination network in swap activity description when source and destination symbols are the same#568

Merged
kvhnuke merged 1 commit intoprep/releasefrom
feat/activity-swap-description-dest-network
Dec 4, 2024
Merged

feat: show destination network in swap activity description when source and destination symbols are the same#568
kvhnuke merged 1 commit intoprep/releasefrom
feat/activity-swap-description-dest-network

Conversation

@NickKelly1
Copy link
Contributor

@NickKelly1 NickKelly1 commented Nov 22, 2024

Previously when swapping WETH on Polygon to WETH on Arbitrum, the activity description was Swap from WETH to WETH. This changes the activity description to Swap from WETH to WETH (Arbitrum).

Summary by CodeRabbit

  • New Features

    • Introduced dynamic messages for swap transactions, enhancing user experience with real-time updates.
    • Added functions to generate swap activity descriptions, providing detailed context based on network and token information.
  • Bug Fixes

    • Improved consistency in displaying status and date values related to swap activities.

@coderabbitai
Copy link

coderabbitai bot commented Nov 22, 2024

Walkthrough

The changes in this pull request focus on enhancing the network-activity-transaction.vue component by introducing a dynamic system for displaying swap transaction messages. A new reactive variable, swapMessage, is implemented to hold the message generated by two newly added functions: one synchronous and one asynchronous. These functions construct messages based on the activity's details, ensuring that the UI reflects the current state of swap activities. Additionally, minor adjustments were made to computed properties related to status and date handling.

Changes

File Path Change Summary
packages/extension/src/ui/action/views/network-activity/components/network-activity-transaction.vue - Introduced swapMessage reactive reference for dynamic message display.
- Added getSwapActivityDescriptionSync and getSwapActivityDescriptionAsync functions for message generation.
- Implemented watch function to update swapMessage based on activity prop changes.
- Minor adjustments to computed properties for status and date.

Possibly related PRs

  • Fix: Rango supported network check #549: The changes in the getRangoSwap method relate to swap functionality, which is directly connected to the new swap message handling introduced in the main PR.

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

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.

@github-actions
Copy link

github-actions bot commented Nov 22, 2024

💼 Build Files
chrome: enkrypt-chrome-3e027535.zip
firefox: enkrypt-firefox-3e027535.zip

💉 Virus total analysis
chrome: 3e027535
firefox: 3e027535

Copy link

@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

🧹 Outside diff range and nitpick comments (1)
packages/extension/src/ui/action/views/network-activity/components/network-activity-transaction.vue (1)

169-184: Enhance message construction and maintainability

While the logic is correct, the message construction could be improved:

  1. String concatenation could be replaced with template literals
  2. Common strings could be extracted as constants

Consider this refactoring:

+const MESSAGE_TEMPLATES = {
+  BASE: 'Swap from %from% to %to%',
+  WITH_NETWORK: 'Swap from %from% to %to% (%network%)',
+  LOADING: 'Swap from %from% to %to% (Loading...)',
+  UNKNOWN: 'Swap from %from% to %to% (Unknown)',
+} as const;

 const getSwapActivityDescriptionSync = (
   data: SwapActivityDescriptionData,
 ): string => {
   const { fromNetworkName, toNetworkName, fromTokenSymbol, toTokenSymbol } = data;
   if (fromNetworkName === toNetworkName || fromTokenSymbol !== toTokenSymbol) {
-    return `Swap from` + ` ${fromTokenSymbol}` + ` to ${toTokenSymbol}`;
+    return MESSAGE_TEMPLATES.BASE
+      .replace('%from%', fromTokenSymbol)
+      .replace('%to%', toTokenSymbol);
   }

-  return (
-    `Swap from` +
-    ` ${fromTokenSymbol}` +
-    ` to ${toTokenSymbol}` +
-    ` (Loading...)`
-  );
+  return MESSAGE_TEMPLATES.LOADING
+    .replace('%from%', fromTokenSymbol)
+    .replace('%to%', toTokenSymbol);
 };

Similar changes can be applied to getSwapActivityDescriptionAsync.

Also applies to: 186-211

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between abf56be and 3e02753.

📒 Files selected for processing (1)
  • packages/extension/src/ui/action/views/network-activity/components/network-activity-transaction.vue (4 hunks)
🔇 Additional comments (3)
packages/extension/src/ui/action/views/network-activity/components/network-activity-transaction.vue (3)

84-84: LGTM: Template binding looks good

The replacement of static text with the dynamic swapMessage binding is implemented correctly.


213-238: LGTM: Watch implementation is robust

The watch implementation is well-designed with:

  • Proper type casting
  • Caching to prevent unnecessary updates
  • Clean handling of async state updates

186-211: Verify network name display format

The implementation correctly shows the destination network using name_long from the network object. Let's verify the network name format across the codebase.

✅ Verification successful

Network name format is consistent across the codebase

The implementation correctly uses name_long property from the network object, which is consistent with the codebase usage. The search results show:

  • Network objects consistently use name_long for displaying full network names (e.g., in UI components, headers, and transaction views)
  • The implementation aligns with this pattern by using toNetwork.name_long in the swap activity description
  • No inconsistencies found in network name display format across the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check network name usage consistency

# Check for network name property usage
rg "name_long|name_short" --type ts --type vue

# Check for other network name formats in swap-related code
rg "networkInfo.*name" --type ts --type vue

Length of output: 150


Script:

#!/bin/bash
# Description: Check network name usage consistency with correct file types

# Check for network name property usage
rg "name_long|name_short" -t typescript -t vue-template -t vue

# Check for other network name formats in swap-related code
rg "networkInfo.*name" -t typescript -t vue-template -t vue

# Check network object structure
fd -e ts -e vue | xargs rg "network.*name"

Length of output: 37975

@kvhnuke kvhnuke changed the base branch from develop to prep/release December 4, 2024 18:52
@kvhnuke kvhnuke merged commit 741f728 into prep/release Dec 4, 2024
@kvhnuke kvhnuke deleted the feat/activity-swap-description-dest-network branch December 4, 2024 18:54
@coderabbitai coderabbitai bot mentioned this pull request Dec 6, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 20, 2024
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