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

OK-34450: Prevent zero amount transfer on SUI #6375

Merged
merged 5 commits into from
Dec 19, 2024
Merged

Conversation

originalix
Copy link
Contributor

@originalix originalix commented Dec 19, 2024

Summary by CodeRabbit

  • 新特性

    • 增强了代币交易中的错误处理,增加了对余额为零和无可用币的检查。
    • 引入了更具体的错误信息以替代之前的通用错误提示。
  • 修复

    • 改进了余额检查逻辑,确保在余额不足时能够正确抛出错误。

Copy link

codesandbox bot commented Dec 19, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

coderabbitai bot commented Dec 19, 2024

概述

步骤说明

此次变更主要针对 Sui SDK 实现中的 transactions.ts 文件,重点是优化余额不足的错误处理机制。新增了两个来自 OneKey 共享库的导入:OneKeyInternalErrorETranslations。在 createTokenTransaction 函数中,错误检查逻辑得到了增强,现在能更精确地处理余额为零且无可用代币的情况。

变更详情

文件路径 变更摘要
packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts 新增 OneKeyInternalErrorETranslations 导入;优化余额检查逻辑
packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts 新增 OneKeyInternalErrorETranslations 导入;优化余额检查逻辑

主要修改点

  1. 引入新的错误处理类 OneKeyInternalError
  2. 添加 ETranslations 用于国际化错误消息
  3. 增强余额不足的错误检测机制

这些变更旨在提供更精确和友好的错误处理,特别是在处理代币交易时的余额检查。


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

@originalix originalix marked this pull request as draft December 19, 2024 07:53
@originalix originalix marked this pull request as ready for review December 19, 2024 07:56
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 UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07d933f and 6547115.

📒 Files selected for processing (1)
  • packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts (2 hunks)
🧰 Additional context used
🪛 eslint
packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts

[error] 107-107: Delete ··

(prettier/prettier)

🔇 Additional comments (1)
packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts (1)

8-9: 导入错误处理模块,代码结构清晰!

新增的错误处理导入模块使代码更加规范,有利于统一的错误处理机制。

@originalix originalix enabled auto-merge (squash) December 19, 2024 11:03
@originalix originalix merged commit 80cc134 into x Dec 19, 2024
8 checks passed
@originalix originalix deleted the fix/sui-zero-amount branch December 19, 2024 11:09
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.

4 participants