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

fix: swap estimate fee error on hw #6382

Merged
merged 3 commits into from
Dec 20, 2024
Merged

fix: swap estimate fee error on hw #6382

merged 3 commits into from
Dec 20, 2024

Conversation

weatherstar
Copy link
Contributor

@weatherstar weatherstar commented Dec 20, 2024

Summary by CodeRabbit

  • 新功能

    • 在交易创建中引入了新的可选参数 maxSendNativeToken,以增强代币交易逻辑。
    • 优化了交易费用估算逻辑,特别是在多交易场景下的处理。
  • 错误修复

    • 改进了交易费用估算过程中的错误处理,确保更准确的费用状态更新。
  • 样式

    • FloatingIconModal 组件的代码进行了格式化,以提高可读性。

Copy link

codesandbox bot commented Dec 20, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

概述

代码变更步骤

本次代码变更涉及三个不同的文件,主要包括事务处理、交易费用容器和浮动图标设置。这些变更旨在优化代码逻辑和用户交互体验。

变更

文件路径 变更摘要
packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts createTokenTransaction 函数中新增 maxSendNativeToken 可选参数,调整代币交易处理逻辑
packages/kit/src/views/Send/pages/SendConfirm/TxFeeContainer.tsx 优化交易费用估算逻辑,改进多交易场景下的费用计算和处理
packages/kit/src/views/Setting/pages/FloatingIcon/index.tsx onChange 处理程序进行轻微格式化,提高代码可读性

事务处理变更详细说明

代码变更

transactions.ts 文件中,createTokenTransaction 函数新增了 maxSendNativeToken 参数:

async function createTokenTransaction({
  ..., 
  maxSendNativeToken = false
}) {
  // 根据 maxSendNativeToken 调整交易逻辑
}

变更序列图

sequenceDiagram
    participant User
    participant Transaction
    participant Coins
    
    User->>Transaction: 创建代币交易
    Transaction->>Coins: 检查 maxSendNativeToken
    alt maxSendNativeToken 为 true
        Coins-->>Transaction: 使用过滤后的币种
        Transaction->>Transaction: 设置 Gas 支付
    else maxSendNativeToken 为 false
        Transaction->>Transaction: 使用默认交易逻辑
    end
Loading

交易费用容器变更

主要变更点

  1. 优化多交易场景下的费用估算
  2. 改进特殊交易类型(如交换和授权)的 Gas 限制处理
  3. 增强错误处理机制
  4. 扩展状态管理和性能优化

浮动图标设置

仅进行了代码格式化,未改变功能逻辑。

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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

@weatherstar weatherstar enabled auto-merge (squash) December 20, 2024 03:40
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0200c47 and c47809c.

📒 Files selected for processing (3)
  • packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts (1 hunks)
  • packages/kit/src/views/Send/pages/SendConfirm/TxFeeContainer.tsx (1 hunks)
  • packages/kit/src/views/Setting/pages/FloatingIcon/index.tsx (1 hunks)
🔇 Additional comments (2)
packages/kit/src/views/Setting/pages/FloatingIcon/index.tsx (1)

35-37: 仅是格式上的微调,逻辑并未改变,当前实现清晰可读。

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

107-107: 新增的“maxSendNativeToken”逻辑可读性不错,帮助区分最大原生币发送场景。整体实现看上去符合预期。

@weatherstar weatherstar merged commit fffbe10 into x Dec 20, 2024
8 checks passed
@weatherstar weatherstar deleted the fix/wallet-issues branch December 20, 2024 03:45
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.

3 participants