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

Release: v2.0.2 #591

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Release: v2.0.2 #591

wants to merge 5 commits into from

Conversation

kvhnuke
Copy link
Contributor

@kvhnuke kvhnuke commented Jan 3, 2025

Summary by CodeRabbit

  • Version Update

    • Bumped extension package version from 2.0.1 to 2.0.2
  • Bug Fixes

    • Updated error messages across multiple blockchain providers to consistently display "Not enough balance" when transaction amount exceeds available funds
    • Enhanced token information retrieval for Ethereum and Solana tokens
  • Improvements

    • Added support for optional token icon in Ethereum token interfaces
    • Refined balance validation logic in send transaction components

Copy link

coderabbitai bot commented Jan 3, 2025

Walkthrough

This pull request introduces several minor updates across different blockchain provider components in the Enkrypt extension. The changes primarily focus on improving error messaging, adding support for token icons, and refining input validation logic. Key modifications include updating version numbers, introducing an optional icon property for token interfaces, and standardizing error messages across Bitcoin, Ethereum, Solana, and Kadena transaction components to use "Not enough balance" when appropriate.

Changes

File Change Summary
packages/extension/package.json Version bumped from 2.0.1 to 2.0.2
packages/extension/src/providers/bitcoin/ui/send-transaction/components/send-alert.vue Added isBalanceZero prop to handle zero balance scenarios
packages/extension/src/providers/bitcoin/ui/send-transaction/index.vue Added :is-balance-zero prop to <send-alert> component
packages/extension/src/providers/ethereum/libs/api.ts Added optional icon property to getTokenInfo method return type
packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts Enhanced icon handling for unknown tokens
packages/extension/src/providers/ethereum/types/index.ts Added optional icon property to ERC20TokenInfo interface
packages/extension/src/providers/ethereum/ui/send-transaction/index.vue Updated error message from "Amount exceeds maximum value" to "Not enough balance"
packages/extension/src/providers/kadena/ui/send-transaction/index.vue Changed error message from "Insufficient funds" to "Not enough balance"
packages/extension/src/providers/solana/libs/api.ts Refactored getTokenInfo method with new token information retrieval logic
packages/extension/src/providers/solana/types/sol-token.ts Removed icon property and made cgId optional in SPLTokenInfo interface
packages/extension/src/providers/solana/ui/send-transaction/index.vue Updated error message to "Not enough balance"

Possibly related PRs

Suggested reviewers

  • NickKelly1
  • gamalielhere

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

github-actions bot commented Jan 3, 2025

💼 Build Files
chrome: enkrypt-chrome-02338bc5.zip
firefox: enkrypt-firefox-02338bc5.zip

💉 Virus total analysis
chrome: 02338bc5
firefox: 02338bc5

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

🧹 Nitpick comments (4)
packages/extension/src/providers/ethereum/libs/api.ts (1)

79-79: Clarify placeholder icon usage
In the catch block, icon is always set to undefined. Confirm there is no fallback icon scenario.

packages/extension/src/providers/solana/libs/api.ts (2)

26-26: Confirm necessity of empty init()
This init() method is empty. If unused, consider removing it or using it for any async setup logic (e.g., pre-fetching data).


100-109: Conditional icon injection
Reading the first file URI for the icon is intuitive. Consider additional checks if multiple files are available.

packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts (1)

338-341: Consider extracting the fallback icon logic into a helper function for maintainability.

The fallback logic is correct. However, centralizing it in a helper function or utility could improve consistency across the codebase, especially if this pattern for handling icons is replicated in multiple places.

Below is an example of how you might define and reuse a helper function. Note that this new function would need to reside outside the selected line range, so no diff is provided to encapsulate the entire change, but you can still see how to reference it in the changed lines:

// Move this function to a suitable location in your codebase.
function getFallbackIcon(
  tokenInfo: Record<string, CGToken>,
  tInfo: { icon?: string },
  network: BaseNetwork,
  tokenAddress: string
): string {
  return (
    tokenInfo[tokenAddress]?.logoURI ||
    tInfo.icon ||
    network.icon
  );
}

Then change lines 338-341 accordingly:

-            icon:
-              tokenInfo[unknownTokens[idx]]?.logoURI ||
-              tInfo.icon ||
-              network.icon,
+            icon: getFallbackIcon(tokenInfo, tInfo, network, unknownTokens[idx]),
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc02c5c and 02338bc.

📒 Files selected for processing (11)
  • packages/extension/package.json (1 hunks)
  • packages/extension/src/providers/bitcoin/ui/send-transaction/components/send-alert.vue (2 hunks)
  • packages/extension/src/providers/bitcoin/ui/send-transaction/index.vue (2 hunks)
  • packages/extension/src/providers/ethereum/libs/api.ts (1 hunks)
  • packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts (1 hunks)
  • packages/extension/src/providers/ethereum/types/index.ts (1 hunks)
  • packages/extension/src/providers/ethereum/ui/send-transaction/index.vue (2 hunks)
  • packages/extension/src/providers/kadena/ui/send-transaction/index.vue (1 hunks)
  • packages/extension/src/providers/solana/libs/api.ts (3 hunks)
  • packages/extension/src/providers/solana/types/sol-token.ts (1 hunks)
  • packages/extension/src/providers/solana/ui/send-transaction/index.vue (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/extension/package.json
🔇 Additional comments (12)
packages/extension/src/providers/kadena/ui/send-transaction/index.vue (1)

325-325: Consistent Error Messaging

Changing the error message to "Not enough balance." helps maintain consistency across different transaction flows. This unified phrasing is clearer to the user and aligns with the convention used in other providers.

packages/extension/src/providers/bitcoin/ui/send-transaction/index.vue (1)

99-99: Expose zero balance as a reusable prop

The newly introduced :is-balance-zero="UTXOBalance.isZero()" prop helps the component correctly handle scenarios where the detected UTXO balance is zero. This is a good approach to ensure your UI can differentiate zero balances and provide a more tailored user message or experience.

packages/extension/src/providers/ethereum/ui/send-transaction/index.vue (2)

454-454: Improved user feedback for insufficient funds

Replacing "Amount exceeds maximum value." with "Not enough balance." is more direct, aligning with usage across other providers. This phrasing better communicates the underlying cause of the error from the user's perspective.


565-566: Validate numerical input before heavy processing

The introduction of:

const sendAmountBigNumber = new BigNumber(sendAmount.value);
if (sendAmountBigNumber.isNaN()) return false;

ensures that non-numeric inputs are caught early, preventing potential downstream errors in calculations. This is a good validation checkpoint that avoids unpredictable behavior.

packages/extension/src/providers/solana/ui/send-transaction/index.vue (1)

400-400: Unify insufficient balance message

Changing the error message to "Not enough balance." maintains consistency with other providers. It clearly communicates the issue to end users and aligns with the project-wide error messaging guidelines.

packages/extension/src/providers/bitcoin/ui/send-transaction/components/send-alert.vue (2)

4-5: Well-structured error message hierarchy!

The new condition for zero balance takes precedence over other error states, and the message "Not enough balance" aligns well with the standardization effort across blockchain providers. The logical progression from zero balance → below dust → not enough funds is clear and maintainable.


28-28: LGTM: Clean props interface addition

The new isBalanceZero prop is well-typed and follows the codebase's naming conventions.

packages/extension/src/providers/solana/types/sol-token.ts (1)

6-6: Check usage for undefined cgId
Making cgId optional is fine. Please verify that all references to cgId in the code handle the case where it is undefined.

packages/extension/src/providers/ethereum/types/index.ts (1)

63-63: Optional icon property
Adding icon?: string helps provide a token icon when available with minimal disruption. Ensure any consumer of this interface checks for undefined before using the icon.

packages/extension/src/providers/solana/libs/api.ts (3)

36-36: Good addition of 'confirmed' commitment
Providing a commitment level here helps ensure consistent transaction status. Nice improvement.


69-92: Verify JSON-RPC approach
Fetching token info via a JSON-RPC call is a robust solution. Make sure the node supports getAsset consistently in all environments.


98-98: Graceful fallback on missing token info
Switching to direct getParsedAccountInfo is a solid fallback for decoding basic token metadata.

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