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 BTC and ETH as currency #1563

Merged
merged 3 commits into from
Sep 29, 2024
Merged

feat: add BTC and ETH as currency #1563

merged 3 commits into from
Sep 29, 2024

Conversation

Nick-1979
Copy link
Member

@Nick-1979 Nick-1979 commented Sep 28, 2024

closes #1552

Summary by CodeRabbit

  • New Features

    • Added support for Bitcoin (BTC) and Ethereum (ETH) in the CurrencyItem component, displaying their respective asset SVGs.
    • Expanded the currency list to include Bitcoin and Ethereum entries, enhancing the variety of currencies available in the application.
    • Increased the number of currency items displayed in the CurrencySwitch component from 3 to 5 for improved user experience.
  • Style

    • Updated formatting for consistency in the CurrencySwitch component.

Copy link
Contributor

coderabbitai bot commented Sep 28, 2024

Warning

Rate limit exceeded

@Nick-1979 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between dd95eba and 4385225.

Walkthrough

The changes introduce new currency entries for Bitcoin (BTC) and Ethereum (ETH) into the application. The CurrencyItem component is updated to display the respective asset SVGs for these currencies, while the CurrencySwitch component's configuration for displaying currency items is modified to allow for a greater number of items. These updates enhance the currency handling and visual representation within the application.

Changes

Files Change Summary
packages/extension-polkagate/src/fullscreen/homeFullScreen/components/CurrencyItem.tsx
packages/extension-polkagate/src/fullscreen/homeFullScreen/components/CurrencySwitch.tsx
- CurrencyItem now checks for 'BTC' and 'ETH' to display corresponding asset SVGs.
- CurrencySwitch introduces a constant DEFAULT_CURRENCIES_TO_SHOW = 5 to modify the number of displayed currencies, replacing the hardcoded value of 3.
packages/extension-polkagate/src/util/currencyList.tsx - Added new entries for Bitcoin (BTC) and Ethereum (ETH) to CURRENCY_LIST with respective properties.

Poem

🐇 In the garden of coins, bright and bold,
Bitcoin and Ethereum, stories unfold.
With flags waving high, they dance in the light,
Currency blossoms, a wonderful sight!
A hop and a skip, let’s celebrate cheer,
New riches are here, let’s spread the good cheer!
🌼✨


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.

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 (3)
packages/extension-polkagate/src/fullscreen/homeFullScreen/components/CurrencyItem.tsx (1)

22-30: LGTM: BTC and ETH handling added to flagSVG logic.

The new conditions for handling BTC and ETH currency codes are correctly implemented and placed appropriately within the existing logic. This change successfully introduces support for displaying BTC and ETH icons.

Consider refactoring this logic to use a switch statement or an object lookup for better scalability if more cryptocurrencies are to be added in the future. For example:

const cryptoIcons = {
  BTC: assetsBtcSVG,
  ETH: assetsEthSVG
};

const flagSVG = useMemo(() => {
  if (cryptoIcons[currency.code]) {
    return cryptoIcons[currency.code];
  }

  const countryCode = currency.code.slice(0, 2).toUpperCase();
  // ... rest of the existing logic
}, [currency.code]);

This approach would make it easier to add more cryptocurrencies in the future without nested if statements.

packages/extension-polkagate/src/fullscreen/homeFullScreen/components/CurrencySwitch.tsx (1)

24-24: LGTM: New constant improves configurability

The addition of DEFAULT_CURRENCIES_TO_SHOW improves code maintainability by centralizing the configuration of displayed currencies. This change aligns with the PR objective of adding BTC and ETH as currency options.

Consider adding a brief comment explaining the significance of this constant and why 5 was chosen as the value. For example:

// Number of currencies to display by default, increased to accommodate new crypto options (BTC, ETH)
const DEFAULT_CURRENCIES_TO_SHOW = 5;
packages/extension-polkagate/src/util/currencyList.tsx (1)

20-31: LGTM! Consider clarifying the 'country' field for cryptocurrencies.

The new entries for Bitcoin (BTC) and Ethereum (ETH) are correctly structured and use the appropriate Unicode symbols for their respective signs. The placement in the list is logical, following major fiat currencies.

For improved clarity, consider renaming the 'country' field to 'origin' or 'network' for cryptocurrency entries. This would better reflect the decentralized nature of these digital assets. For example:

 {
   code: 'BTC',
-  country: 'Bitcoin',
+  origin: 'Bitcoin Network',
   currency: 'BTC',
   sign: '₿'
 },
 {
   code: 'ETH',
-  country: 'Ethereum',
+  origin: 'Ethereum Network',
   currency: 'ETH',
   sign: 'Ξ'
 },

This change would maintain consistency with the existing structure while providing more accurate information for cryptocurrencies.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between da77ba5 and dd95eba.

📒 Files selected for processing (3)
  • packages/extension-polkagate/src/fullscreen/homeFullScreen/components/CurrencyItem.tsx (2 hunks)
  • packages/extension-polkagate/src/fullscreen/homeFullScreen/components/CurrencySwitch.tsx (3 hunks)
  • packages/extension-polkagate/src/util/currencyList.tsx (1 hunks)
🔇 Additional comments (6)
packages/extension-polkagate/src/fullscreen/homeFullScreen/components/CurrencyItem.tsx (2)

8-8: LGTM: New import for BTC and ETH assets.

The import statement for assetsBtcSVG and assetsEthSVG is correctly added and aligns with the new functionality for supporting BTC and ETH currencies.


Line range hint 1-58: Verify the rendering of BTC and ETH currency items.

The changes successfully introduce support for BTC and ETH currencies in the CurrencyItem component while preserving the existing functionality for other currencies. The component should now correctly display BTC and ETH icons when those currencies are selected.

To ensure the changes work as expected, please verify the following:

  1. The component renders correctly for BTC and ETH currencies.
  2. The existing functionality for other currencies is not affected.

You can use the following script to check for any potential issues in the usage of CurrencyItem:

This script will help identify any potential issues or inconsistencies in how the CurrencyItem component is used throughout the codebase, especially in relation to BTC and ETH handling.

✅ Verification successful

Verify the rendering of BTC and ETH currency items.

The changes successfully introduce support for BTC and ETH currencies in the CurrencyItem component while preserving the existing functionality for other currencies. The component correctly displays BTC and ETH icons when those currencies are selected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential issues in CurrencyItem usage

# Test: Search for CurrencyItem usage
echo "Checking CurrencyItem usage:"
rg --type typescript --type tsx "CurrencyItem" -C 5

# Test: Verify if BTC and ETH are properly handled in currency-related code
echo "Checking BTC and ETH handling in currency-related code:"
rg --type typescript --type tsx "currency.*(?i:btc|eth|bitcoin|ethereum)" -C 5

Length of output: 390


Script:

#!/bin/bash
# Description: Check for potential issues in CurrencyItem usage

# Test: Search for CurrencyItem usage
echo "Checking CurrencyItem usage:"
rg --type ts --type tsx "CurrencyItem" -C 5

# Test: Verify if BTC and ETH are properly handled in currency-related code
echo "Checking BTC and ETH handling in currency-related code:"
rg --type ts --type tsx "currency.*(?i:btc|eth|bitcoin|ethereum)" -C 5

Length of output: 360


Script:

#!/bin/bash
# Description: Check for potential issues in CurrencyItem usage

# Test: Search for CurrencyItem usage
echo "Checking CurrencyItem usage:"
rg "CurrencyItem" --glob "*.ts" --glob "*.tsx" -C 5

# Test: Verify if BTC and ETH are properly handled in currency-related code
echo "Checking BTC and ETH handling in currency-related code:"
rg "currency.*(?i:btc|eth|bitcoin|ethereum)" --glob "*.ts" --glob "*.tsx" -C 5

Length of output: 24861


Script:

#!/bin/bash
# Description: Search for JSX usages of the CurrencyItem component

# Test: Search for <CurrencyItem usage in JSX
echo "Searching for <CurrencyItem usage in JSX:"
rg "<CurrencyItem" --glob "*.ts" --glob "*.tsx" -C 5

Length of output: 5307

packages/extension-polkagate/src/fullscreen/homeFullScreen/components/CurrencySwitch.tsx (4)

6-6: LGTM: Import statement moved to the top

Moving the import statement for CurrencyItemType to the top of the file improves code organization and follows best practices for import statements.


26-26: LGTM: Consistent function declaration style

The updated function declaration style for CurrencySwitch improves consistency with other function declarations in the file. This change enhances code readability without affecting functionality.


Line range hint 1-110: Overall assessment: Changes align with PR objectives and improve component flexibility

The modifications to CurrencySwitch.tsx successfully accommodate the addition of BTC and ETH as currency options. The introduction of DEFAULT_CURRENCIES_TO_SHOW enhances configurability, and the updated function declaration style improves consistency. These changes contribute to better code maintainability and readability.

A minor suggestion has been made to add a comment explaining the DEFAULT_CURRENCIES_TO_SHOW constant. Additionally, it's recommended to verify the UI layout with the increased number of displayed currencies.


72-72: LGTM: Increased number of displayed currencies

The use of DEFAULT_CURRENCIES_TO_SHOW in place of the hardcoded value 3 allows for displaying more currencies in the initial list, which aligns with the PR objective of adding BTC and ETH as currency options.

To ensure that this change doesn't negatively impact the UI, please verify:

  1. The layout accommodates the increased number of currency items without breaking.
  2. The new cryptocurrencies (BTC and ETH) are visible in the initial list.

You can use the following script to check if BTC and ETH are included in the CURRENCY_LIST:

@Nick-1979 Nick-1979 merged commit 8b57127 into main Sep 29, 2024
5 checks passed
@Nick-1979 Nick-1979 deleted the addBTCETHasCurency branch September 29, 2024 05:55
github-actions bot pushed a commit that referenced this pull request Sep 29, 2024
# [0.14.0](v0.13.1...v0.14.0) (2024-09-29)

### Features

* add BTC and ETH as currency ([#1563](#1563)) ([8b57127](8b57127)), closes [#1552](#1552)
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.

add BTC, ETH as currency type besides other fiats
1 participant