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/add hmstr #969

Merged
merged 7 commits into from
Sep 26, 2024
Merged

Feat/add hmstr #969

merged 7 commits into from
Sep 26, 2024

Conversation

haunv3
Copy link
Contributor

@haunv3 haunv3 commented Sep 26, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a carousel notice functionality in the Pool-V3 component, displaying multiple listings dynamically.
    • Added support for a new token icon, 'HmstrIcon', enhancing visual representation.
  • Improvements

    • Updated the @oraichain/oraiswap-v3 package to the latest version for enhanced performance.
    • Streamlined configuration by removing unused imports and legacy declarations, improving code clarity.
    • Enhanced token sorting logic in the SelectToken component to prioritize specific denominations.
  • Bug Fixes

    • Removed deprecated exports to ensure cleaner and more maintainable code structure.

Copy link

coderabbitai bot commented Sep 26, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces several updates across multiple files. Key changes include an update to the version of the @oraichain/oraiswap-v3 package in package.json, the removal of deprecated imports and exports in src/config/chainInfos.ts, the addition of a new token icon in src/config/iconInfos.ts, and the implementation of a carousel notice feature in the BannerNoticePool component within src/pages/Pool-V3/components. These modifications streamline the codebase and enhance functionality without altering existing core features.

Changes

File Path Change Summary
package.json Updated @oraichain/oraiswap-v3 version from 0.1.14 to 0.1.18; removed resolution for @oraichain/oraidex-common.
src/config/chainInfos.ts Removed commented-out imports and exports for various tokens; updated chainInfosWithSdk to include bitcoinMainnet.
src/config/iconInfos.ts Added new token icon HmstrIcon with associated coinGeckoId in tokensIconInfos.
src/pages/Pool-V3/components/BannerNoticePool/index.tsx Introduced a carousel for banner notices with dynamic display of listings for "HMSTR/USDC" and "PEPE/USDC".
src/pages/UniversalSwap/Swap/components/SelectToken/SelectToken.tsx Added constant HMSTR_ORAICHAIN_DENOM to prioritize token sorting based on this denomination.

Possibly related PRs

  • Feat/zapper v3 #965: The changes in package.json regarding the version update of the @oraichain/oraiswap-v3 package are directly related to the main PR, which also updates this package version.
  • feat: sort token list #966: The sorting logic introduced in SelectToken.tsx that prioritizes tokens based on their usd values and tokenRank may relate to the overall token handling and display improvements in the main PR, which involves updates to token configurations.

Suggested reviewers

  • vuonghuuhung
  • trungbach

Poem

🐇 In the code where bunnies play,
New icons hop and dance today!
A carousel spins with joy so bright,
Tokens gleam in the morning light.
With every change, our hearts take flight,
Together we code, making it right! 🌟


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.

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.

trungbach
trungbach previously approved these changes Sep 26, 2024
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: 1

🧹 Outside diff range and nitpick comments (2)
src/config/chainInfos.ts (1)

Address any Type Usage in bitcoinMainnet Configuration

The bitcoinMainnet configuration utilizes the any type in several places, which compromises type safety. Please address the following:

  • Avoid using any for chainId and chainName. Define specific types to enhance type safety.
  • Review other instances of any, such as in coinDecimals and networkType, and replace them with appropriate types.
🔗 Analysis chain

Line range hint 83-138: Review and validate the new bitcoinMainnet configuration

The addition of the bitcoinMainnet configuration is a significant feature. Please ensure the following:

  1. Verify that all the provided information (RPC endpoints, chain ID, bech32 config, etc.) is correct for the Bitcoin mainnet.
  2. The use of any type in chainId and chainName should be avoided if possible. Consider using more specific types for better type safety.
  3. Confirm that the features: ['isBtc'] is the correct way to identify Bitcoin functionality in your system.
  4. Validate the gas price steps (currently set to 0) to ensure this is intentional and correct for Bitcoin transactions.

To ensure the configuration is correct, you may want to cross-check with official Bitcoin documentation or other reliable sources. Here's a script to help verify some of the information:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify Bitcoin mainnet configuration
echo "Verifying Bitcoin mainnet configuration..."
curl -s https://blockstream.info/api/blocks/tip/height
echo "The above should match the latest Bitcoin block height"
curl -s https://blockstream.info/api/fee-estimates
echo "Compare the above fee estimates with the gas price steps in the configuration"

Length of output: 1251


Script:

#!/bin/bash
# Verify Bitcoin mainnet configuration

echo "Verifying Bitcoin mainnet block height..."
BLOCK_HEIGHT=$(curl -s https://blockstream.info/api/blocks/tip/height)
if [ -z "$BLOCK_HEIGHT" ]; then
  echo "Error: Failed to retrieve Bitcoin block height."
else
  echo "Latest Bitcoin block height: $BLOCK_HEIGHT"
fi

echo "Verifying Bitcoin mainnet fee estimates..."
FEE_ESTIMATES=$(curl -s https://blockstream.info/api/fee-estimates)
if [ -z "$FEE_ESTIMATES" ]; then
  echo "Error: Failed to retrieve Bitcoin fee estimates."
else
  echo "Bitcoin fee estimates:"
  echo "$FEE_ESTIMATES"
fi

Length of output: 1947


Script:

#!/bin/bash
# Check for use of 'any' types in bitcoinMainnet configuration
echo "Checking for 'any' type usage in bitcoinMainnet configuration..."
ast-grep --lang typescript --pattern '
export const bitcoinMainnet: CustomChainInfo = {
  $$$
  chainId: $_ as any,
  chainName: $_ as any,
  $$$
}' src/config/chainInfos.ts

# Verify the 'features' array contains 'isBtc'
echo "Verifying 'features' array in bitcoinMainnet configuration..."
ast-grep --lang typescript --pattern '
export const bitcoinMainnet: CustomChainInfo = {
  $$$
  features: [$$_],
  $$$
}' src/config/chainInfos.ts | grep 'isBtc'

# Check gas price steps are set to 0
echo "Checking gas price steps in bitcoinMainnet configuration..."
ast-grep --lang typescript --pattern '
export const bitcoinMainnet: CustomChainInfo = {
  $$$
  currencies: [
    {
      $$$
      gasPriceStep: {
        low: $_,
        average: $_,
        high: $_
      }
      $$$
    }
  ],
  $$$
}' src/config/chainInfos.ts | grep '"low": 0' && grep '"average": 0' && grep '"high": 0'

Length of output: 3686

src/pages/Pool-V3/components/BannerNoticePool/index.tsx (1)

42-42: Nitpick: Consistent naming for state setter function

The state setter function setBannersIdx should be renamed to setBannerIdx to match the state variable bannerIdx for consistency.

Suggested change:

- const [bannerIdx, setBannersIdx] = useState(0);
+ const [bannerIdx, setBannerIdx] = useState(0);

Also, update the usage in line 49:

- setBannersIdx((bannerIdx) => {
+ setBannerIdx((bannerIdx) => {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a8994bd and cae52d5.

⛔ Files ignored due to path filters (2)
  • src/assets/icons/hmstr.svg is excluded by !**/*.svg
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • package.json (2 hunks)
  • src/config/chainInfos.ts (5 hunks)
  • src/config/iconInfos.ts (2 hunks)
  • src/pages/Pool-V3/components/BannerNoticePool/index.tsx (2 hunks)
🔇 Additional comments (14)
package.json (2)

132-132: Verify the impact of removing @oraichain/oraidex-common resolution

The resolution for @oraichain/oraidex-common (version 1.1.18) has been removed from the resolutions section.

Please ensure that:

  1. This removal is intentional and doesn't introduce version conflicts with other dependencies.
  2. The project and its dependencies can work correctly without this specific version resolution.
  3. There are no other parts of the project that rely on version 1.1.18 of @oraichain/oraidex-common.

You can run the following script to check for any potential conflicts or usage of this package:

#!/bin/bash
# Description: Check for potential conflicts or usage of @oraichain/oraidex-common

echo "Checking for direct usage of @oraichain/oraidex-common in the project:"
rg --type js --type ts '@oraichain/oraidex-common'

echo "\nChecking for indirect dependencies on @oraichain/oraidex-common:"
npm ls @oraichain/oraidex-common

echo "\nChecking the installed version of @oraichain/oraidex-common:"
npm list @oraichain/oraidex-common

This script will help you identify any potential issues that might arise from removing this resolution.


73-73: Verify the implications of updating @oraichain/oraiswap-v3

The version of @oraichain/oraiswap-v3 has been updated from 0.1.14 to 0.1.18. This minor version update likely introduces new features or non-breaking changes.

Please ensure that:

  1. This update is intentional and aligns with the project's requirements.
  2. The changes in versions 0.1.15 through 0.1.18 are compatible with your project.
  3. Any new features or changes in this update are properly utilized or accounted for in your codebase.

You can run the following script to check the changelog or release notes for this package:

This script will help you review the changes introduced in the new version.

src/config/iconInfos.ts (3)

30-30: LGTM: New icon import follows existing conventions.

The import statement for the HmstrIcon is consistent with the existing import pattern and naming conventions used in this file.


30-30: Summary: New token icon added with minimal impact

The changes introduce support for a new "Hamster Kombat" token icon. This addition is straightforward and follows existing patterns in the codebase. The impact on existing functionality should be minimal as no existing code was altered.

However, to ensure full integration:

  1. Verify that the hmstr.svg file exists in the assets/icons/ directory.
  2. If this token will be used in other parts of the application, ensure that any necessary updates (e.g., to token lists or supported currencies) have been made in relevant files.

Let's verify the existence of the SVG file:

#!/bin/bash
# Description: Verify the existence of the hmstr.svg file

# Test: Check if the hmstr.svg file exists in the assets/icons directory
echo "Checking for hmstr.svg file:"
fd --type file --extension svg hmstr assets/icons

Also applies to: 164-167


164-167: New token entry structure looks good, but a few points to consider:

  1. The overall structure of the new entry is consistent with other entries in the tokensIconInfos array.

  2. The use of as any for the coinGeckoId suggests a potential type issue. Can you clarify why this type assertion is necessary? If it's a temporary workaround, consider adding a TODO comment explaining the reason and any plans to address it in the future.

  3. Most other entries in this array have separate Icon and IconLight components. Is there a reason why HmstrIcon is used for both? If a light version of the icon exists, consider adding it to maintain consistency with other entries.

To ensure the coinGeckoId is valid and consistent, let's check its usage:

src/config/chainInfos.ts (3)

Line range hint 1198-1207: Review the new chain filtering exports and commented-out configurations

The addition of evmChains and btcChains exports provides a way to filter chains based on specific criteria. However, there are some points to consider:

  1. The large commented-out section (lines 534-1197) contains detailed configurations for various chains. If these are no longer needed, consider removing them entirely or moving them to a separate file for future reference.

  2. The new evmChains export filters chains based on network type, BIP44 coin type, and excludes a specific chain ID. Ensure this filtering logic is correct and meets the requirements of your application.

  3. The btcChains export uses a type assertion ('bitcoin' as any). Consider defining a proper type for the Bitcoin network type to avoid using any.

To ensure the filtering is working as expected, run the following script:

#!/bin/bash
# Check the filtering of EVM and BTC chains
echo "Checking EVM and BTC chain filtering..."
grep -n "evmChains =" src/config/chainInfos.ts
grep -n "btcChains =" src/config/chainInfos.ts
echo "Verify that the filtering logic for evmChains and btcChains is correct."

Consider creating a separate file for deprecated or unused chain configurations to keep the main configuration file clean and manageable.


Line range hint 140-528: Verify the impact of commented-out chain and token configurations

A significant portion of chain and token configurations has been commented out. This could have a substantial impact on the application's functionality. Please address the following points:

  1. Ensure that commenting out these configurations is intentional and doesn't break any existing features.
  2. If these configurations are no longer needed, consider removing them entirely instead of leaving them commented out.
  3. For any configurations that might be needed in the future, add TODO comments explaining why they are kept and when they might be reintroduced.
  4. The addition of bitcoinMainnet to chainInfosWithSdk is consistent with the new Bitcoin support. Verify that all systems using this export are updated to handle the new Bitcoin configuration.

To ensure no critical configurations are accidentally removed, run the following script to check for any references to the commented-out chains or tokens:

✅ Verification successful

No External References to Commented-Out Configurations Found

The verification script confirmed that the commented-out chain and token configurations in src/config/chainInfos.ts are not referenced elsewhere in the codebase. This indicates that removing these configurations should not impact the application's functionality.

Recommendations:

  • Remove Unused Configurations: If these configurations are no longer needed, consider deleting them to maintain a clean codebase.
  • Document Future Intentions: If there's a possibility that these configurations might be needed in the future, add TODO comments explaining their purpose and potential reintroduction.
  • Verify Bitcoin Integration: Ensure that the addition of bitcoinMainnet to chainInfosWithSdk is fully integrated and that all dependent systems are updated to handle the new Bitcoin configuration appropriately.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for references to commented-out chains and tokens
echo "Checking for references to commented-out chains and tokens..."
grep -R "oraichainNetworkOld" .
grep -R "OraiBToken" .
grep -R "KawaiiToken" .
grep -R "OraiBTCToken" .
echo "If any results are shown above, those references may need to be updated."

Length of output: 1251


Script:

#!/bin/bash
# Check for references to commented-out chains and tokens
echo "Checking for references to commented-out chains and tokens..."
grep -R "oraichainNetworkOld" .
grep -R "OraiBToken" .
grep -R "KawaiiToken" .
grep -R "OraiBTCToken" .
echo "If any results are shown above, those references may need to be updated."

Length of output: 1157


528-529: Verify the updated chainInfosWithSdk and chainInfos exports

The changes to chainInfosWithSdk and chainInfos exports reflect the addition of Bitcoin support. Please ensure the following:

  1. Confirm that all systems relying on chainInfosWithSdk are prepared to handle the new Bitcoin and OraiBTC network configurations.
  2. Verify that the mapListWithIcon function correctly applies icons to all chain infos, including the newly added ones.
  3. Test the application thoroughly to ensure these changes don't introduce any unexpected behavior in chain selection or display.

Run the following script to check if all chains in chainInfosWithSdk have corresponding icons:

src/pages/Pool-V3/components/BannerNoticePool/index.tsx (6)

2-2: Import statement for 'HamsterIcon' is correct

The import of HamsterIcon from 'assets/icons/hmstr.svg' is correctly added and consistent with the existing imports.


16-18: Definition of 'urlHmstr' is correct

The urlHmstr variable is properly defined using HMSTR_ORAICHAIN_DENOM and USDC_CONTRACT, ensuring correct URL encoding.


22-37: NoticeList configuration supports carousel functionality

The NoticeList array is well-structured, allowing the carousel to display multiple notices with their respective icons, names, and URLs.


45-63: useEffect hook correctly manages carousel timing

The useEffect hook appropriately sets up the interval for changing the banner index and includes a cleanup function to clear the interval upon unmounting.


79-80: Dynamic rendering of icons

The XIcon and YIcon components are correctly rendered based on the current notice from NoticeList, ensuring the icons match the displayed notice.


83-87: Display of dynamic text content is correct

The text content accurately displays the new listing alert with the appropriate coin names and provides a link to add liquidity.

src/config/chainInfos.ts Show resolved Hide resolved
@trung2891 trung2891 self-requested a review September 26, 2024 11:01
@trung2891 trung2891 merged commit 9e8fb5f into main Sep 26, 2024
2 checks passed
Copy link

sonarcloud bot commented Sep 26, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

This was referenced Sep 30, 2024
This was referenced Oct 8, 2024
@trungbach trungbach deleted the feat/add-hmstr branch October 16, 2024 01:18
This was referenced Oct 17, 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.

5 participants