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

Adding ETH on BNB Chain [SLT-398] #3338

Merged
merged 10 commits into from
Oct 29, 2024
Merged

Adding ETH on BNB Chain [SLT-398] #3338

merged 10 commits into from
Oct 29, 2024

Conversation

Defi-Moses
Copy link
Collaborator

@Defi-Moses Defi-Moses commented Oct 27, 2024

This PR adds the BNB token to bridgeMap and bridgeable tokens lists. A relayer now supports BNB (on BNB chain) <> ETH (on any chain) routes.

Summary by CodeRabbit

  • New Features

    • Added support for the ETH token in the bridge functionality across multiple blockchain networks.
    • Enhanced token representation for ETH on the Binance Smart Chain with updated addresses and properties.
  • Bug Fixes

    • Improved swappable options and relationships for existing tokens in the bridge system.
  • Documentation

    • Updated token definitions and mappings to reflect new entries and modifications for ETH.
  • Refactor

    • Adjusted type assertions in various components to enhance type compatibility without altering functionality.

de6b5da: synapse-interface preview link
913d0c9: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Oct 27, 2024

Walkthrough

The changes in this pull request introduce new entries for the 'ETH' token across multiple files, enhancing the bridge functionality and token mappings. Specifically, the BRIDGE_MAP and bridgeable.ts files are updated to include properties for the 'ETH' token, such as its address, decimals, and origin. Additionally, several existing entries in the BRIDGE_MAP are modified to update swappable options and relationships among tokens. Type assertions for the Fragment component are also adjusted in various components, affecting type safety without altering overall functionality.

Changes

File Change Summary
packages/rest-api/src/constants/bridgeMap.ts Added new entry for 'ETH' under network '56' with properties: symbol, origin, destination, decimals, swappable.
packages/rest-api/src/constants/bridgeable.ts Updated addresses and decimals for CHAINS.BNBCHAIN.id to include 'ETH'.
packages/synapse-constants/src/constants/bridgeMap.ts Added new entry for 'ETH' under network '56' with properties: decimals, symbol, origin, destination, swappable.
packages/synapse-constants/src/constants/tokens/bridgeable.ts Introduced new constant ETH with properties including addresses, decimals, symbol, name, logo, isNative, swapableOn.
packages/synapse-interface/constants/bridgeMap.ts Added new entry for 'ETH' under network '56' with properties: symbol, origin, destination, decimals, swappable.
packages/synapse-interface/constants/tokens/bridgeable.ts Added new token declaration for ETH, updated addresses for BNB chain.
packages/widget/src/constants/bridgeMap.ts Added new entry for 'ETH' under network '56'; modified existing entries for 'nUSD' and 'USDC' under network '25'.
packages/synapse-interface/components/Activity/Transaction/TransactionOptions.tsx Updated type assertion for as prop in TransactionPopoverContainer from Fragment to Fragment as any.
packages/synapse-interface/components/Pools/PoolActionOptions.tsx Updated type assertion for as prop in TransactionPopoverContainer from Fragment to Fragment as any.
packages/synapse-interface/components/layouts/LandingPageWrapper/index.tsx Updated type assertions for LandingNav and PopoverPanelContainer functions from Fragment to Fragment as any.

Possibly related PRs

Suggested labels

size/m, M-deps

Suggested reviewers

  • aureliusbtc
  • trajan0x
  • bigboydiamonds

🐇 In the meadow, hopping so free,
New tokens added, oh what glee!
ETH now bridges, a path so bright,
With swappable options, a true delight.
Let's celebrate this change today,
Hooray for tokens, hip-hip-hooray! 🎉


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.

Copy link

cloudflare-workers-and-pages bot commented Oct 27, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7de1c18
Status: ✅  Deploy successful!
Preview URL: https://bf8298fd.sanguine-fe.pages.dev
Branch Preview URL: https://update-tokens-constants.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Oct 27, 2024

Bundle Report

Changes will increase total bundle size by 270.7kB (0.85%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
synapse-interface-client-array-push 7.47MB 88.18kB (1.19%) ⬆️
synapse-interface-server-cjs 1.65MB 175 bytes (0.01%) ⬆️
widget-cjs-esm 275.02kB 3.75kB (1.38%) ⬆️
@synapsecns/synapse-constants-esm-cjs 178.6kB 178.6kB (100%) ⬆️

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 42c0079 and 2ad4f4a.

📒 Files selected for processing (8)
  • packages/rest-api/src/constants/bridgeMap.ts (2 hunks)
  • packages/rest-api/src/constants/bridgeable.ts (1 hunks)
  • packages/synapse-constants/src/constants/bridgeMap.ts (2 hunks)
  • packages/synapse-constants/src/constants/tokens/bridgeable.ts (1 hunks)
  • packages/synapse-interface/constants/bridgeMap.ts (2 hunks)
  • packages/synapse-interface/constants/tokens/bridgeable.ts (2 hunks)
  • packages/widget/src/constants/bridgeMap.ts (2 hunks)
  • packages/widget/src/constants/bridgeable.ts (1 hunks)
🔇 Additional comments (9)
packages/synapse-interface/constants/tokens/bridgeable.ts (1)

46-46: LGTM: Import statement follows established pattern.

The BNB logo import follows the same consistent pattern as other token logo imports.

packages/rest-api/src/constants/bridgeable.ts (1)

1434-1450: LGTM! The BNB token definition follows the established patterns.

The implementation correctly defines BNB as a native token with appropriate properties matching other major tokens in the system.

packages/widget/src/constants/bridgeable.ts (1)

1454-1469: LGTM! The BNB token implementation looks correct and consistent.

The implementation follows the established pattern for native tokens, using the appropriate special address for native BNB and correct token properties (18 decimals, priority rank 300).

packages/rest-api/src/constants/bridgeMap.ts (1)

572-578: Verify the BNB token configuration.

The BNB token entry looks correct with:

  • Proper canonical zero address for native token
  • Correct decimals (18)
  • RFQ bridge support via origin

However, the empty destination array suggests one-way bridging only. Please verify if this is the intended behavior.

✅ Verification successful

BNB token configuration is consistent across the codebase

The empty destination and swappable arrays are consistent across all bridgeMap.ts files in different packages (rest-api, synapse-constants, synapse-interface, and widget). This confirms that the one-way bridging configuration via RFQ.BNB is intentional and properly synchronized across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if other files reference BNB bridging
# Test: Search for BNB bridging references. Expect: Consistent one-way configuration.
rg -l "RFQ.BNB"

Length of output: 207


Script:

#!/bin/bash
# Check the content of BNB configurations across different bridge map files
for file in $(rg -l "RFQ.BNB"); do
  echo "=== $file ==="
  rg -A5 -B1 "'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'.*{" "$file"
done

Length of output: 1732


Script:

#!/bin/bash
# Check the content of BNB configurations across different bridge map files
for file in $(rg -l "RFQ.BNB"); do
  echo "=== $file ==="
  rg -A5 "RFQ\.BNB" "$file"
done

Length of output: 2116

packages/synapse-constants/src/constants/bridgeMap.ts (2)

593-599: Verify the WBNB token configuration.

The WBNB token configuration looks correct with:

  • Proper contract address for WBNB on BNB Chain
  • Correct decimals (18)
  • Origin set to 'RFQ.BNB'

However, similar to native BNB, having an empty destination array might limit bridging capabilities. Consider if WBNB should be bridgeable to any destinations.

Let's verify if WBNB should be bridgeable to any destinations:

✅ Verification successful

WBNB configuration is correctly set with empty destinations

Based on the verification results, the current WBNB configuration is correct as is. The search results show that:

  • Both BNB and WBNB tokens are configured with origin: ['RFQ.BNB'] and empty destinations
  • This pattern is consistent across BNB-related tokens in the bridgeMap
  • No other tokens in the bridgeMap reference BNB or WBNB as destinations

The empty destination array is intentional for RFQ-based tokens and doesn't limit functionality, as these tokens are handled through the RFQ system rather than traditional bridging paths.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if WBNB token is referenced as a destination in other chains
# This helps verify if we need to add any destinations for WBNB

rg -l "destination.*WBNB" --type ts

Length of output: 37


Script:

#!/bin/bash
# Let's check for any references to WBNB in the bridgeMap file to understand the bridging patterns
rg -A 5 -B 5 "WBNB" packages/synapse-constants/src/constants/bridgeMap.ts

# Also check for any BNB-related bridging patterns to compare with WBNB
rg -A 5 -B 5 "BNB['\"].*destination" packages/synapse-constants/src/constants/bridgeMap.ts

Length of output: 448


Script:

#!/bin/bash
# Let's check for any BNB-related tokens and their bridging configurations
rg "symbol.*BNB.*origin.*destination" -A 5 -B 2 packages/synapse-constants/src/constants/bridgeMap.ts

# Also check for RFQ.BNB patterns to understand similar configurations
rg "RFQ\.BNB" -A 5 -B 2 packages/synapse-constants/src/constants/bridgeMap.ts

# Check for any bridge destinations that might be relevant for BNB/WBNB
rg "destination.*\[.*BNB" packages/synapse-constants/src/constants/bridgeMap.ts

Length of output: 651


572-578: Verify the BNB token configuration.

The BNB token configuration looks correct with:

  • Proper address for native BNB token
  • Correct decimals (18)
  • Origin set to 'RFQ.BNB'

However, having an empty destination array might limit bridging capabilities. Consider if BNB should be bridgeable to any destinations.

Let's verify if BNB should be bridgeable to any destinations:

✅ Verification successful

Empty destination array is correct for BNB token configuration

The empty destination array in the BNB token configuration is correct. From analyzing the codebase:

  1. Tokens with RFQ (Request for Quote) origins typically have empty destinations (e.g., WETH with 'RFQ.ETH' origin)
  2. BNB is configured with 'RFQ.BNB' origin, following the same pattern as other RFQ tokens
  3. This is consistent with other similar configurations in the bridgeMap, such as USDT and WETH with RFQ origins
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if BNB token is referenced as a destination in other chains
# This helps verify if we need to add any destinations for BNB

rg -l "destination.*BNB" --type ts

Length of output: 37


Script:

#!/bin/bash
# Let's try a broader search to understand BNB bridging patterns
rg "BNB.*destination|destination.*BNB" -A 2 -B 2 --type ts

# Also search for any BNB-related configurations
rg "symbol.*BNB" -A 5 -B 2 --type ts

Length of output: 9615


Script:

#!/bin/bash
# Let's check if other tokens in the bridgeMap have destinations set
# This will help us understand if empty destinations is the normal pattern
rg "destination: \[.*\]" -B 2 packages/synapse-constants/src/constants/bridgeMap.ts

Length of output: 19661

packages/synapse-interface/constants/bridgeMap.ts (1)

593-599: Verify WBNB configuration matches other wrapped native tokens.

The WBNB token entry uses:

  • Correct WBNB contract address on BNB Chain
  • Same configuration as BNB (RFQ.BNB origin, empty destination/swappable)

Consider if WBNB should have additional swappable tokens defined to improve liquidity options.

#!/bin/bash
# Description: Compare WBNB configuration with other wrapped native tokens
# This helps validate if the configuration follows the same pattern

echo "Searching for other wrapped native token configurations..."
rg -U "symbol: 'W[A-Z]+'.+?origin: \['RFQ\." -A 5
packages/widget/src/constants/bridgeMap.ts (2)

593-599: Verify the WBNB token configuration.

The WBNB token configuration looks correct with:

  • Standard WBNB contract address on BNB Chain (0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c)
  • Matching configuration with native BNB
#!/bin/bash
# Description: Verify WBNB token address and configuration in other bridge-related files
# Expect: Same configuration in other bridge map files and consistent with BNB

# Search for WBNB token configurations
rg --type ts "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c.*WBNB.*RFQ\.BNB"

572-578: Verify the BNB token configuration.

The native BNB token configuration looks correct with:

  • Standard address for native token (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
  • Correct decimals (18)
  • RFQ bridge support via RFQ.BNB
✅ Verification successful

BNB token configuration is correctly implemented across the codebase

The native BNB token configuration is consistent across multiple packages with:

  • Standard native token address (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
  • Correct symbol ("BNB") and decimals (18)
  • RFQ bridge support via RFQ.BNB protocol
  • Configuration is synchronized in bridgeMap files across packages (widget, synapse-interface, rest-api)
  • Proper integration with the BNB Chain configuration (chain ID 56)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify BNB token address and configuration in other bridge-related files
# Expect: Same configuration in other bridge map files

# Search for BNB token configurations
rg --type ts "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE.*BNB.*RFQ\.BNB"

Length of output: 75


Script:

#!/bin/bash
# Let's try a broader search for BNB token configurations
# Search for the native token address pattern
rg --type ts "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"

# Search for BNB symbol usage in bridge configurations
rg --type ts "symbol: ['\"](BNB)['\"]"

# Search for RFQ.BNB pattern
rg --type ts "RFQ\.BNB"

# Look for any bridge-related configuration files
fd "bridge.*\.(ts|js|json)$"

Length of output: 20459

Comment on lines 1274 to 1289
export const BNB = new Token({
priorityRank: 300,
visibilityRank: 300,
addresses: {
[CHAINS.BNB.id]: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
},
decimals: {
[CHAINS.BNB.id]: 18,
},
symbol: 'BNB',
name: 'BNB',
logo: bnbLogo,
swapableType: 'BNB',
color: 'yellow',
routeSymbol: 'BNB',
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing isNative flag and standardize native token address.

The BNB token declaration should follow the same pattern as other native tokens (ETH, AVAX, KLAY, etc.).

Apply these changes to align with other native token declarations:

 export const BNB = new Token({
   priorityRank: 300,
   visibilityRank: 300,
   addresses: {
-    [CHAINS.BNB.id]: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
+    [CHAINS.BNB.id]: zeroAddress,
   },
   decimals: {
     [CHAINS.BNB.id]: 18,
   },
   symbol: 'BNB',
   name: 'BNB',
   logo: bnbLogo,
+  isNative: true,
   swapableType: 'BNB',
   color: 'yellow',
   routeSymbol: 'BNB',
 })

Committable suggestion was skipped due to low confidence.

Comment on lines 1318 to 1332
export const BNB = new Token({
priorityRank: 300,
addresses: {
[CHAINS.BNB.id]: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
},
decimals: {
[CHAINS.BNB.id]: 18,
},
symbol: 'BNB',
name: 'BNB',
swapableType: 'BNB',
color: 'yellow',
routeSymbol: 'BNB',
logo: 'https://45a97b3d.sanguine-fe.pages.dev/_next/static/media/bnb.5948fe5e.svg',
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing properties to BNB token definition

The BNB token definition is missing several standard properties that are commonly used across other token definitions in this file:

  1. isNative flag should be set to true as BNB is the native token on BNB chain
  2. Missing standard properties that should be added:
    • coingeckoId
    • visibilityRank
    • swapableOn

Apply this diff to add the missing properties:

 export const BNB = new Token({
   priorityRank: 300,
   addresses: {
     [CHAINS.BNB.id]: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
   },
   decimals: {
     [CHAINS.BNB.id]: 18,
   },
   symbol: 'BNB',
   name: 'BNB',
   swapableType: 'BNB',
   color: 'yellow',
   routeSymbol: 'BNB',
   logo: 'https://45a97b3d.sanguine-fe.pages.dev/_next/static/media/bnb.5948fe5e.svg',
+  isNative: true,
+  coingeckoId: 'binancecoin',
+  visibilityRank: 90,
+  swapableOn: [CHAINS.BNB.id],
 })
📝 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
export const BNB = new Token({
priorityRank: 300,
addresses: {
[CHAINS.BNB.id]: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
},
decimals: {
[CHAINS.BNB.id]: 18,
},
symbol: 'BNB',
name: 'BNB',
swapableType: 'BNB',
color: 'yellow',
routeSymbol: 'BNB',
logo: 'https://45a97b3d.sanguine-fe.pages.dev/_next/static/media/bnb.5948fe5e.svg',
})
export const BNB = new Token({
priorityRank: 300,
addresses: {
[CHAINS.BNB.id]: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
},
decimals: {
[CHAINS.BNB.id]: 18,
},
symbol: 'BNB',
name: 'BNB',
swapableType: 'BNB',
color: 'yellow',
routeSymbol: 'BNB',
logo: 'https://45a97b3d.sanguine-fe.pages.dev/_next/static/media/bnb.5948fe5e.svg',
isNative: true,
coingeckoId: 'binancecoin',
visibilityRank: 90,
swapableOn: [CHAINS.BNB.id],
})

Comment on lines 593 to 599
'0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c': {
decimals: 18,
symbol: 'WBNB',
origin: ['RFQ.BNB'],
destination: [],
swappable: [],
},
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

Consider enhancing WBNB integration.

While the WBNB configuration mirrors BNB's settings, consider these potential improvements:

  1. Add swappable tokens to enable DEX integrations
  2. Consider adding destination chains if two-way bridging should be supported

Example enhancement:

 '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c': {
   decimals: 18,
   symbol: 'WBNB',
   origin: ['RFQ.BNB'],
   destination: [],
-  swappable: [],
+  swappable: [
+    '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'  // Native BNB
+  ],
 },

Committable suggestion was skipped due to low confidence.

Comment on lines 572 to 578
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE': {
decimals: 18,
symbol: 'BNB',
origin: ['RFQ.BNB'],
destination: [],
swappable: [],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Empty destination array for BNB is inconsistent with other RFQ tokens

Looking at other RFQ token configurations in the bridgeMap:

  • ETH has both origin and destination set to ['RFQ.ETH']
  • USDC has both origin and destination set to ['RFQ.USDC']
  • WLD has both origin and destination set to ['RFQ.WLD']

The BNB configuration should follow the same pattern and include 'RFQ.BNB' in both origin and destination arrays to enable bi-directional bridging.

  • packages/synapse-interface/constants/bridgeMap.ts: Update BNB and WBNB entries to include destination: ['RFQ.BNB']
🔗 Analysis chain

Verify the BNB bridging configuration.

The BNB token entry is added with:

  • Correct zero address for native token
  • Correct decimals (18)
  • RFQ.BNB as origin
  • Empty destination and swappable arrays

Consider if the empty destination array is intentional, as it means BNB cannot be the destination token in any bridge operation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if other RFQ tokens have similar empty destination arrays
# This helps validate if the configuration aligns with other RFQ implementations

echo "Searching for other RFQ token configurations..."
rg -U "origin: \['RFQ\.[^']+'\][^{]*destination: \[\]" 

Length of output: 281


Script:

#!/bin/bash
# Let's try a different approach to search for RFQ configurations
echo "Searching for RFQ token configurations..."
rg -U "origin: \[\s*'RFQ\." -A 3 -B 3 packages/synapse-interface/constants/bridgeMap.ts

echo -e "\nSearching for other native token configurations..."
rg -U "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" -A 5 -B 2 packages/synapse-interface/constants/bridgeMap.ts

Length of output: 12311

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

🧹 Outside diff range and nitpick comments (1)
packages/rest-api/src/tests/tokenListRoute.test.ts (1)

Line range hint 17-24: Add BNB token verification to the test case.

While the test verifies the total token count and existing tokens (ETH, SYN), it should also validate the newly added BNB token address to ensure correct mapping.

Add BNB verification like this:

    expect(keys.length).toBe(65)
    expect(response.body['ETH']['addresses']['1']).toBe(
      '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
    )
    expect(response.body['SYN']['addresses']['1']).toBe(
      '0x0f2d719407fdbeff09d87557abb7232601fd9f29'
    )
+   expect(response.body['BNB']['addresses']['56']).toBe(
+     '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
+   )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2ad4f4a and 6852b2b.

📒 Files selected for processing (3)
  • packages/rest-api/src/tests/indexRoute.test.ts (1 hunks)
  • packages/rest-api/src/tests/tokenListRoute.test.ts (1 hunks)
  • packages/synapse-interface/constants/tokens/bridgeable.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/constants/tokens/bridgeable.ts
🧰 Additional context used
📓 Learnings (1)
packages/rest-api/src/tests/indexRoute.test.ts (4)
Learnt from: abtestingalpha
PR: synapsecns/sanguine#3126
File: packages/rest-api/src/tests/indexRoute.test.ts:21-31
Timestamp: 2024-10-08T15:41:49.333Z
Learning: In this project, tests intentionally use hardcoded values for counts to capture changes in the number of available chains and tokens.
Learnt from: abtestingalpha
PR: synapsecns/sanguine#3126
File: packages/rest-api/src/tests/indexRoute.test.ts:21-31
Timestamp: 2024-09-16T17:19:34.740Z
Learning: In this project, tests intentionally use hardcoded values for counts to capture changes in the number of available chains and tokens.
Learnt from: abtestingalpha
PR: synapsecns/sanguine#3126
File: packages/rest-api/src/tests/indexRoute.test.ts:21-31
Timestamp: 2024-10-08T15:41:49.333Z
Learning: In this project, tests intentionally use hardcoded values for counts to capture changes in the number of available chains and tokens.
Learnt from: abtestingalpha
PR: synapsecns/sanguine#3126
File: packages/rest-api/src/tests/indexRoute.test.ts:21-31
Timestamp: 2024-10-08T15:41:48.274Z
Learning: In this project, tests intentionally use hardcoded values for counts to capture changes in the number of available chains and tokens.
🔇 Additional comments (2)
packages/rest-api/src/tests/tokenListRoute.test.ts (1)

17-17: LGTM! The token count update aligns with BNB addition.

The increment from 64 to 65 tokens correctly reflects the addition of the BNB token to the bridge map.

packages/rest-api/src/tests/indexRoute.test.ts (1)

30-30: LGTM! The updated token count correctly reflects the addition of BNB.

The increment from 64 to 65 tokens aligns with the PR's objective of adding BNB token support. Note: As per project convention, we intentionally use hardcoded values in these tests to catch unexpected changes in the number of available tokens.

Copy link

codecov bot commented Oct 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.44834%. Comparing base (42c0079) to head (7de1c18).
Report is 14 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                  @@
##              master       #3338          +/-   ##
====================================================
+ Coverage   33.25951%   90.44834%   +57.18883%     
====================================================
  Files            543          54         -489     
  Lines          34769        1026       -33743     
  Branches          82          82                  
====================================================
- Hits           11564         928       -10636     
+ Misses         22182          95       -22087     
+ Partials        1023           3        -1020     
Flag Coverage Δ
cctp-relayer ?
core ?
ethergo ?
git-changes-action ?
omnirpc ?
opbot ?
packages 90.44834% <ø> (ø)
promexporter ?
rfq ?
screener-api ?
scribe ?
tools ?

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.

@Defi-Moses Defi-Moses changed the title Adding BNB token Adding BNB token [SLT-398] Oct 28, 2024
@Defi-Moses
Copy link
Collaborator Author

Last item here is to get the svg static image for the token and include that in the rest API and constants package.

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

🧹 Outside diff range and nitpick comments (1)
packages/synapse-interface/components/Activity/Transaction/TransactionOptions.tsx (1)

Line range hint 142-146: Improve type safety of TransactionPopoverContainer props.

While the component architecture is well-structured, the children prop is typed as any, which reduces type safety. Consider using a more specific type definition.

export function TransactionPopoverContainer({
  children,
  className,
}: {
-  children: any
+  children: React.ReactNode
  className?: string
})
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 52902fd and 4c84de7.

⛔ Files ignored due to path filters (1)
  • packages/synapse-interface/assets/icons/bnb.svg is excluded by !**/*.svg
📒 Files selected for processing (3)
  • packages/synapse-interface/components/Activity/Transaction/TransactionOptions.tsx (1 hunks)
  • packages/synapse-interface/components/Pools/PoolActionOptions.tsx (1 hunks)
  • packages/synapse-interface/components/layouts/LandingPageWrapper/index.tsx (2 hunks)
🔇 Additional comments (1)
packages/synapse-interface/components/Pools/PoolActionOptions.tsx (1)

123-123: 🛠️ Refactor suggestion

Consider a more type-safe alternative to as any.

While this change resolves type compatibility issues with @headlessui/react, using as any bypasses TypeScript's type checking system, which could mask potential type-related bugs.

Consider these alternatives:

  1. Update @headlessui/react to the latest version which might have better TypeScript support
  2. Create a proper type definition:
import { TransitionRootProps } from '@headlessui/react'

type CustomTransitionProps = Omit<TransitionRootProps, 'as'> & {
  as: typeof Fragment
}

Let's verify if this is a broader pattern:

@@ -145,7 +145,7 @@ export function TransactionPopoverContainer({
}) {
return (
<Transition
as={Fragment}
as={Fragment as any}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid using as any type assertion.

The type assertion Fragment as any bypasses TypeScript's type checking system, which could mask potential type-related issues. This is generally considered an anti-pattern in TypeScript development.

Consider one of these type-safe alternatives:

- as={Fragment as any}
+ as={Fragment}

Or if you're facing type compatibility issues with @headlessui/react, properly type it using:

import { TransitionRootProps } from '@headlessui/react'

type AsProps = TransitionRootProps['as']
// Then use it as
as={Fragment as AsProps}

@@ -118,7 +118,7 @@ export function LandingNav() {
</div>

<Transition
as={Fragment}
as={Fragment as any}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid using as any type assertions with @headlessui/react components.

The type assertions Fragment as any in both Transition components bypass TypeScript's type checking, which could hide potential runtime errors. This is generally considered an anti-pattern.

Consider these alternatives:

  1. Use proper types from @headlessui/react:
import { Transition } from '@headlessui/react'
import type { Fragment } from 'react'

// Use proper type
as={Fragment as React.ComponentType}
  1. If the type issue persists, check for version mismatches:
npm info @headlessui/react version
npm info @types/react version
  1. Update dependencies if needed:
npm update @headlessui/react @types/react

Also applies to: 164-164

@Defi-Moses Defi-Moses changed the title Adding BNB token [SLT-398] Adding ETH on BNB Chain [SLT-398] Oct 28, 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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4c84de7 and d1a73c9.

📒 Files selected for processing (7)
  • packages/rest-api/src/constants/bridgeMap.ts (1 hunks)
  • packages/rest-api/src/constants/bridgeable.ts (2 hunks)
  • packages/synapse-constants/src/constants/bridgeMap.ts (1 hunks)
  • packages/synapse-constants/src/constants/tokens/bridgeable.ts (1 hunks)
  • packages/synapse-interface/constants/bridgeMap.ts (1 hunks)
  • packages/synapse-interface/constants/tokens/bridgeable.ts (1 hunks)
  • packages/widget/src/constants/bridgeMap.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/rest-api/src/constants/bridgeMap.ts
  • packages/synapse-interface/constants/bridgeMap.ts
  • packages/synapse-interface/constants/tokens/bridgeable.ts
🔇 Additional comments (2)
packages/rest-api/src/constants/bridgeable.ts (1)

811-811: Implementation looks good!

The addition of ETH token support for the BNB chain is properly implemented with:

  • Correct contract address for the ETH token on BNB chain
  • Standard decimals value (18) consistent with other chains

Let's verify the ETH token contract address on BNB chain:

Also applies to: 825-825

✅ Verification successful

ETH token address on BNB chain is correctly configured

The implementation is consistent across the codebase:

  • The ETH token contract address 0x2170Ed0880ac9A755fd29B2688956BD959F933F8 is properly referenced in all relevant configuration files
  • The token is consistently configured with 18 decimals
  • The symbol is correctly set as 'ETH' in bridge mappings
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the ETH token contract address on BNB chain
# Expected: Should find references to this contract address in bridge configuration

rg -l "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"

Length of output: 408


Script:

#!/bin/bash
# Let's verify the consistency of ETH token address across different files
rg "0x2170Ed0880ac9A755fd29B2688956BD959F933F8" -A 2 -B 2

Length of output: 2861

packages/widget/src/constants/bridgeMap.ts (1)

525-531: Verify the token configuration.

The ETH token configuration has the following potential issues:

  1. Empty destination array might prevent bridging to other chains
  2. No swappable tokens might limit functionality
  3. Only 'RFQ.ETH' in origin array might restrict bridging options

Please verify if these configurations are intentional.

Run the following script to check ETH token configurations across other chains:

✅ Verification successful

Based on the search results, I can now provide a final response since I have enough information about ETH token configurations across the codebase:

ETH token configuration is consistent with other implementations

The empty destination array and swappable array for this ETH token (0x2170Ed0880ac9A755fd29B2688956BD959F933F8) is intentional as it follows a pattern seen in other similar configurations where:

  • Tokens with only 'RFQ.ETH' in origin typically have either empty destination arrays or ['RFQ.ETH'] as destination
  • Not all ETH tokens require swappable configurations, as evidenced by multiple other ETH token entries with empty swappable arrays
  • The configuration aligns with other ETH tokens in the bridgeMap that have similar minimal configurations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check ETH token configurations across chains for consistency

# Test: Search for ETH token entries with RFQ.ETH origin
echo "ETH tokens with RFQ.ETH origin:"
rg -A 5 "'RFQ.ETH'"

# Test: Search for ETH symbol entries
echo "Tokens with ETH symbol:"
rg -A 5 "symbol: 'ETH'"

Length of output: 80400

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d1a73c9 and 7de1c18.

📒 Files selected for processing (1)
  • packages/synapse-constants/package.json (1 hunks)

Comment on lines +48 to +49
"viem": "^2.21.6",
"@codecov/rollup-plugin": "^1.2.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Move @codecov/rollup-plugin to devDependencies

The @codecov/rollup-plugin is a development tool for code coverage reporting and should be in devDependencies rather than dependencies. This change will prevent the package from being installed in production environments where it's not needed.

Apply this diff to fix the dependency location:

  "dependencies": {
    "viem": "^2.21.6",
-   "@codecov/rollup-plugin": "^1.2.0"
  },
  "devDependencies": {
+   "@codecov/rollup-plugin": "^1.2.0"
  }
📝 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
"viem": "^2.21.6",
"@codecov/rollup-plugin": "^1.2.0"
"viem": "^2.21.6"

💡 Codebase verification

Code coverage plugin addition appears unrelated to current changes

The addition of @codecov/rollup-plugin to synapse-constants package appears unnecessary as:

  • There are no test files in the synapse-constants package
  • No changes were detected in the rollup configuration to utilize this plugin
  • The package's purpose is to provide constants, which typically don't require code coverage

Consider:

  • Removing the @codecov/rollup-plugin dependency as it's not being used
  • If code coverage is needed, create a separate PR with proper test setup and configuration
🔗 Analysis chain

Verify the relevance of code coverage changes

The addition of the code coverage plugin appears unrelated to the PR's objective of adding ETH on BNB Chain. Could you clarify why these changes are included in this PR? Consider moving them to a separate PR focused on testing infrastructure improvements.


Let me gather more specific information about code coverage related changes.


Let me check the specific rollup configuration changes in the synapse-constants package.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any test-related changes in this PR that would justify adding code coverage
rg -l "test|spec|coverage" --type ts --type js

Length of output: 6964


Script:

#!/bin/bash
# Check for any changes to test configuration files or coverage settings
git diff HEAD~1 -G"coverage|jest|test" -- "*.json" "*.js" "*.ts"

# Check if codecov plugin is used in any rollup configs
rg -l "codecov|rollup" --type js --type ts

Length of output: 363


Script:

#!/bin/bash
# Check the rollup config changes in synapse-constants
git diff HEAD~1 packages/synapse-constants/rollup.config.js

# Also check if there are any test files in synapse-constants
fd -t f "test|spec" packages/synapse-constants/

Length of output: 111

@Defi-Moses Defi-Moses merged commit bae13aa into master Oct 29, 2024
39 checks passed
@Defi-Moses Defi-Moses deleted the update/tokens-constants branch October 29, 2024 16:32
This was referenced Oct 29, 2024
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