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

Chore: optimize request & ton version limit #394

Merged
merged 5 commits into from
Dec 13, 2024

Conversation

ByteZhang1024
Copy link
Contributor

@ByteZhang1024 ByteZhang1024 commented Dec 12, 2024

Summary by CodeRabbit

  • 新特性

    • PlaygroundExecutor 组件中添加了加载状态指示,按钮在执行方法时会显示加载状态。
    • 更新了 MenuListItem 组件以支持国际化,确保标题正确本地化。
    • 增加了 classic1s 版本范围,并更新了 pro 版本范围的处理逻辑。
    • 新增错误代码 BTCPsbtTooManyUtxos,用于处理特定的错误场景。
    • 引入了严格的设备支持检查机制,确保方法执行前验证设备兼容性。
  • 错误修复

    • TonSignMessage 中增强了错误处理机制,确保设备固件版本符合要求。
    • BTCSignPsbt 中改进了错误处理逻辑,提供更具体的错误反馈。
  • 文档

    • 更新了多个类的方法签名以反映版本范围和参数处理的变化。
    • 更新了 package.json 文件以反映版本号和依赖项的变化。

Copy link

coderabbitai bot commented Dec 12, 2024

Walkthrough

此次更改涉及多个组件的更新。PlaygroundExecutor 组件新增了一个 isLoading 状态变量,以指示方法执行的加载状态。MenuListItem 组件更新了标题的国际化处理。TonGetAddressTonSignMessage 类的 getVersionRange 方法进行了版本范围的修改,并增强了错误处理机制。TonSignProof 类的版本结构也进行了调整。整体上,这些更改提升了代码的结构性和可读性。

Changes

文件路径 更改摘要
packages/connect-examples/expo-example/src/components/PlaygroundExecutor.tsx 新增 isLoading 状态变量,更新 executeMethod 函数以管理加载状态,更新 Button 组件的 onPress 属性。
packages/connect-examples/expo-example/src/components/ui/MenuListItem.tsx 更新 title 属性的设置,使用 intl.formatMessage 进行国际化处理。
packages/core/src/api/ton/TonGetAddress.ts 更新 getVersionRange 方法以添加新版本范围,改进 init 方法中的 payload 处理。
packages/core/src/api/ton/TonSignMessage.ts 更新 getVersionRange 方法,增强 checkFixCommentError 方法的错误处理,改进 run 方法中的 jettonAmount 处理。
packages/core/src/api/ton/TonSignProof.ts 更新 getVersionRange 方法以调整返回结构,增加新版本范围 classic1s
packages/core/src/api/btc/BTCSignPsbt.ts 更新 getVersionRange 方法以添加新版本范围,修改 run 方法的错误处理逻辑。
packages/shared/src/HardwareError.ts 新增错误代码 BTCPsbtTooManyUtxos 和相应的错误消息。
packages/connect-examples/electron-example/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1
packages/connect-examples/expo-example/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1,更新多个依赖版本。
packages/core/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1,更新依赖版本。
packages/core/src/api/BaseMethod.ts 新增 strictCheckDeviceSupport 属性以加强设备支持检查。
packages/core/src/api/allnetwork/AllNetworkGetAddress.ts 新增 preCheckDeviceSupport 方法以验证设备兼容性,更新 callMethod 函数。
packages/core/src/api/benfen/BenfenGetAddress.ts 新增 strictCheckDeviceSupport 属性,更新 getVersionRange 方法以返回详细版本范围。
packages/core/src/api/benfen/BenfenGetPublicKey.ts 新增 strictCheckDeviceSupport 属性,更新 getVersionRange 方法以返回详细版本范围。
packages/core/src/api/benfen/BenfenSignMessage.ts 更新 getVersionRange 方法以返回多个版本范围。
packages/core/src/api/benfen/BenfenSignTransaction.ts 更新 getVersionRange 方法以返回多个版本范围。
packages/core/src/core/index.ts 更新 callAPIensureConnected 方法以增强错误处理机制。
packages/hd-ble-sdk/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1,更新依赖版本。
packages/hd-common-connect-sdk/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1,更新依赖版本。
packages/hd-transport-http/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1,更新依赖版本。
packages/hd-transport-lowlevel/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1,更新依赖版本。
packages/hd-transport-react-native/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1,更新依赖版本。
packages/hd-transport-webusb/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1,更新依赖版本。
packages/hd-transport/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1
packages/hd-web-sdk/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1,更新依赖版本。
packages/shared/package.json 更新版本号,从 1.0.16-alpha.0 增加到 1.0.16-alpha.1

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. (Experiment)
  • @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.

@ByteZhang1024 ByteZhang1024 enabled auto-merge (squash) December 12, 2024 01:59
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: 3

🧹 Outside diff range comments (3)
packages/connect-examples/expo-example/src/components/PlaygroundExecutor.tsx (1)

Line range hint 40-77: 优化加载状态管理和错误处理

几点建议:

  1. 建议将重试次数提取为常量
  2. 考虑添加错误边界处理
  3. 可以使用 React.Suspense 优化加载状态
+ const MAX_RETRY_COUNT = 1;

  const requestParams = {
    ...commonParams,
-   retryCount: 1,
+   retryCount: MAX_RETRY_COUNT,
    ...(await onAcquireParams()),
  };
packages/core/src/api/ton/TonSignMessage.ts (2)

Line range hint 92-94: 改进注释以提升可读性

注释“Equipment that does not need to be repaired”可能不够清晰。建议改为“无需修复的设备”,使含义更加明确。

应用以下修改更新注释:

-    // Equipment that does not need to be repaired
+    // 无需修复的设备

Also applies to: 121-123


Line range hint 138-140: 修复 jettonAmount 为零时的判断

run() 方法中,if (jettonAmount) 条件会在 jettonAmount0 时返回 false,可能导致零值被忽略。建议修改条件,确保零值被正确处理。

应用以下修改修正条件判断:

-    if (jettonAmount) {
+    if (jettonAmount !== null && jettonAmount !== undefined) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 300f8dc and 3727ac3.

📒 Files selected for processing (5)
  • packages/connect-examples/expo-example/src/components/PlaygroundExecutor.tsx (3 hunks)
  • packages/connect-examples/expo-example/src/components/ui/MenuListItem.tsx (0 hunks)
  • packages/core/src/api/ton/TonGetAddress.ts (1 hunks)
  • packages/core/src/api/ton/TonSignMessage.ts (1 hunks)
  • packages/core/src/api/ton/TonSignProof.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/connect-examples/expo-example/src/components/ui/MenuListItem.tsx
🔇 Additional comments (3)
packages/core/src/api/ton/TonSignProof.ts (1)

45-50: 版本范围定义清晰明确!

版本结构的重构很好地区分了不同设备类型的要求:

  • pro 设备要求 4.10.0 以上版本
  • classic1s 设备支持 3.10.0 以上版本

建议验证这些版本要求与实际设备兼容性是否匹配。

✅ Verification successful

版本要求设置正确且一致!

代码搜索结果显示:

  • TON 相关功能的版本要求与其他模块保持一致
  • pro 设备普遍要求 4.x 版本
  • classic1s 设备普遍支持 3.x 版本
  • 特别是在 TonGetAddress.tsTonSignMessage.ts 中使用了相同的版本要求

版本定义完全符合项目的整体规范。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查其他TON相关文件中的版本要求是否一致

# 搜索所有相关文件中的版本定义
rg -A 3 "getVersionRange|min.*[34]\." --type typescript

# 检查是否有相关的设备兼容性测试文件
fd -e test.ts -e spec.ts ton

Length of output: 123


Script:

#!/bin/bash
# Search for version requirements in TypeScript files
rg -t ts "getVersionRange|min.*[34]\." 

# Find test files related to TON functionality
find . -type f -name "*ton*.test.ts" -o -name "*ton*.spec.ts"

# Search for version-related constants or configurations
rg -t ts "version.*[34]\." 

# Look for device type definitions
ast-grep --pattern 'interface $_Device {
  $$$
}'

Length of output: 12338

packages/core/src/api/ton/TonGetAddress.ts (1)

59-64: 版本范围更新需要验证一致性

这些版本范围的更改看起来合理,但建议:

  1. 确保其他 TON 相关文件(如 TonSignMessage 和 TonSignProof)使用相同的版本命名和要求
  2. 在文档中说明这些版本要求的原因和影响
✅ Verification successful

版本范围更新已验证一致

搜索结果显示 TON 相关文件(TonSignMessage、TonSignProof)都使用了相同的版本要求:

  • pro: min '4.10.0'
  • classic1s: min '3.10.0'

这些更改保持了跨文件的一致性,不需要额外修改。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查其他 TON 相关文件中的版本范围定义
ast-grep --pattern 'getVersionRange() {
  return {
    $$$
    pro: {
      min: $$$
    },
    $$$
  };
}'

# 检查是否存在相关文档
fd -g "*ton*.md" -g "*TON*.md" -g "README.md"

Length of output: 307


Script:

#!/bin/bash
# 使用 ripgrep 搜索版本范围定义
rg -U "getVersionRange.*?\{.*?return.*?\{.*?\}" --type ts -A 10

# 搜索可能的文档文件
find . -type f -name "README.md" -o -name "*ton*.md" -o -name "*TON*.md"

# 搜索其他可能包含版本信息的文件
rg "pro.*?min.*?[0-9]+\.[0-9]+\.[0-9]+" --type ts
rg "classic1s.*?min.*?[0-9]+\.[0-9]+\.[0-9]+" --type ts

Length of output: 20254


Script:

#!/bin/bash
# 使用更简单的模式搜索版本定义
rg "getVersionRange.*?{" --type ts -A 15
rg "model_touch.*?min.*?[0-9]" --type ts

Length of output: 187


Script:

#!/bin/bash
# 使用固定字符串搜索版本定义
rg "getVersionRange" --type ts -A 15
rg "model_touch" --type ts
rg "classic1s" --type ts

Length of output: 68347

packages/core/src/api/ton/TonSignMessage.ts (1)

71-73: 确认设备型号的支持范围

getVersionRange() 方法中,定义了 proclassic1s 模型。但在 getSupportJettonAmountBytesVersionRange()getFixCommentErrorVersionRange() 方法中,仅包含了 pro。如果 classic1s 设备也应支持这些特性,建议添加其版本范围;否则,请确认这些特性仅适用于 pro 设备。

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: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3727ac3 and 91decc8.

📒 Files selected for processing (2)
  • packages/core/src/api/btc/BTCSignPsbt.ts (2 hunks)
  • packages/shared/src/HardwareError.ts (2 hunks)
🔇 Additional comments (4)
packages/core/src/api/btc/BTCSignPsbt.ts (3)

2-2: 引入必要的模块


8-8: 引入必要的模块


35-37: 请确认 classic1s 的最低版本号

请确保 classic1s 设备的最低版本号 '3.10.1' 是否正确。

packages/shared/src/HardwareError.ts (1)

366-370: 添加新的错误代码

packages/core/src/api/btc/BTCSignPsbt.ts Show resolved Hide resolved
packages/core/src/api/btc/BTCSignPsbt.ts Show resolved Hide resolved
packages/shared/src/HardwareError.ts Show resolved Hide resolved
Copy link

socket-security bot commented Dec 12, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Critical CVE npm/[email protected] ⚠︎

View full report↗︎

Next steps

What is a critical CVE?

Contains a Critical Common Vulnerability and Exposure (CVE).

Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

Copy link

Report too large to display inline

View full report↗︎

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: 5

🧹 Outside diff range comments (1)
packages/core/src/api/benfen/BenfenGetAddress.ts (1)

Line range hint 61-120: 建议优化 run 方法的结构

run 方法的实现较为复杂,建议进行以下优化:

  1. 将批处理逻辑抽取为独立方法
  2. 简化嵌套条件结构
  3. 添加更详细的错误处理

建议重构示例:

async run() {
+  const responses = await this.processAddressRequests();
+  this.validateResponses(responses);
+  return this.hasBundle ? responses : responses[0];
}

+ private async processAddressRequests(): Promise<BenfenAddress[]> {
+  return supportBatchPublicKey(this.device?.features)
+    ? await this.processBatchRequests()
+    : await this.processIndividualRequests();
}

+ private async processBatchRequests(): Promise<BenfenAddress[]> {
+  const publicKeyRes = await this.getBatchPublicKeys();
+  return await Promise.all(
+    this.params.map((param, i) => 
+      this.processPublicKey(param, publicKeyRes.message.public_keys[i])
+    )
+  );
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 91decc8 and 4037210.

📒 Files selected for processing (21)
  • packages/connect-examples/electron-example/package.json (1 hunks)
  • packages/connect-examples/expo-example/package.json (2 hunks)
  • packages/connect-examples/expo-example/src/views/ApiPayloadScreen.tsx (1 hunks)
  • packages/core/package.json (2 hunks)
  • packages/core/src/api/BaseMethod.ts (1 hunks)
  • packages/core/src/api/allnetwork/AllNetworkGetAddress.ts (4 hunks)
  • packages/core/src/api/benfen/BenfenGetAddress.ts (2 hunks)
  • packages/core/src/api/benfen/BenfenGetPublicKey.ts (2 hunks)
  • packages/core/src/api/benfen/BenfenSignMessage.ts (1 hunks)
  • packages/core/src/api/benfen/BenfenSignTransaction.ts (1 hunks)
  • packages/core/src/core/index.ts (1 hunks)
  • packages/hd-ble-sdk/package.json (2 hunks)
  • packages/hd-common-connect-sdk/package.json (2 hunks)
  • packages/hd-transport-http/package.json (2 hunks)
  • packages/hd-transport-lowlevel/package.json (2 hunks)
  • packages/hd-transport-react-native/package.json (2 hunks)
  • packages/hd-transport-webusb/package.json (2 hunks)
  • packages/hd-transport/package.json (1 hunks)
  • packages/hd-web-sdk/package.json (2 hunks)
  • packages/shared/package.json (1 hunks)
  • packages/shared/src/HardwareError.ts (4 hunks)
🔇 Additional comments (26)
packages/core/src/api/benfen/BenfenSignMessage.ts (1)

27-36: 版本范围实现清晰明确!

版本范围的实现结构清晰,支持了 pro 和 classic1s 两种设备型号。

让我们验证一下这些版本限制在其他相关文件中是否一致:

✅ Verification successful

版本范围设置完全一致,实现规范!

经验证,所有 benfen 相关文件(BenfenSignMessage、BenfenSignTransaction、BenfenGetPublicKey、BenfenGetAddress)的版本范围设置完全一致:

  • pro 设备最低版本:4.12.0
  • classic1s 设备最低版本:3.11.0
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:检查其他 benfen 相关文件中的版本限制是否一致

# 搜索所有 benfen 相关文件中的版本定义
rg -A 5 "getVersionRange|min.*4\.12\.0|min.*3\.11\.0" packages/core/src/api/benfen/

Length of output: 3186

packages/core/src/api/benfen/BenfenGetPublicKey.ts (2)

10-10: 新增设备支持严格检查

添加 strictCheckDeviceSupport 属性有助于确保设备兼容性检查更加严格,这是一个很好的安全性改进。


39-48: 版本范围更新合理

版本范围的更新支持了两种设备型号:

  • pro: 最低版本 4.12.0
  • classic1s: 最低版本 3.11.0

这种结构与其他文件保持一致,便于维护。

packages/core/src/api/benfen/BenfenSignTransaction.ts (1)

34-43: 版本范围定义统一

getVersionRange 方法的实现与其他 Benfen 相关类保持一致,这种统一性有助于维护和版本控制。

packages/core/src/api/benfen/BenfenGetAddress.ts (2)

16-16: 设备支持检查增强

添加 strictCheckDeviceSupport 属性,与其他 Benfen 相关类保持一致,提高了代码的安全性。


49-58: 版本范围更新统一

版本范围定义与其他 Benfen 相关类保持一致,这种统一性值得肯定。

packages/hd-transport-lowlevel/package.json (1)

3-3: 版本更新和依赖同步已完成

版本号和相关依赖已经同步更新到 1.0.16-alpha.1,保持了包之间的一致性。

Also applies to: 22-23

packages/shared/package.json (1)

3-3: 版本号更新已确认

版本号已更新至 1.0.16-alpha.1

packages/hd-ble-sdk/package.json (1)

3-3: 版本更新看起来没有问题!

版本号和依赖项的更新保持一致,从 1.0.16-alpha.0 升级到 1.0.16-alpha.1。

Also applies to: 23-25

✅ Verification successful

版本更新验证完成,所有相关包版本一致!

所有相关包都已成功更新到 1.0.16-alpha.1 版本,包括:

  • core
  • hd-ble-sdk
  • hd-common-connect-sdk
  • hd-transport 系列包
  • hd-web-sdk
  • shared
  • connect-examples
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 验证所有相关包的版本一致性
echo "检查相关包的版本..."
find . -name "package.json" -exec grep -l "1.0.16-alpha" {} \;

Length of output: 692


Script:

#!/bin/bash
# 检查每个包中的具体版本号,确保都是 1.0.16-alpha.1
for f in $(find . -name "package.json"); do
  echo "=== $f ==="
  grep '"version"' "$f" | grep "1.0.16-alpha"
done

Length of output: 101837

packages/hd-transport-webusb/package.json (1)

3-3: 版本更新符合预期!

版本号和依赖项更新保持同步,确保了包之间的兼容性。

Also applies to: 23-24

packages/hd-transport-react-native/package.json (1)

3-3: 版本更新完成!

版本号和内部依赖项更新已完成,外部依赖保持不变,符合预期。

Also applies to: 22-23

packages/hd-transport-http/package.json (1)

3-3: 版本更新已确认

版本号和依赖项的更新保持一致,符合预期。

Also applies to: 27-28

packages/hd-common-connect-sdk/package.json (1)

3-3: 依赖关系更新完整

版本号更新和相关依赖包的版本更新都已完成,保持了版本一致性。

Also applies to: 23-27

packages/core/package.json (1)

3-3: 版本更新已完成

核心包的版本号和依赖项更新均已完成,保持一致性。

Also applies to: 28-29

packages/connect-examples/electron-example/package.json (1)

5-5: 版本更新已确认

版本号从 1.0.16-alpha.0 更新到 1.0.16-alpha.1,与其他包保持一致。

packages/hd-web-sdk/package.json (1)

3-3: 依赖版本更新已完成

包版本和相关依赖都已更新到 1.0.16-alpha.1,保持了版本一致性。

Also applies to: 24-27

✅ Verification successful

版本更新已完全同步

所有 @onekeyfe 相关依赖已全部更新到 1.0.16-alpha.1 版本,没有遗漏任何旧版本依赖。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否有遗漏的 @onekeyfe 依赖版本更新
rg -l "@onekeyfe.*1\.0\.16-alpha\.0" "packages/**/package.json"

Length of output: 130


Script:

#!/bin/bash
# Check for any @onekeyfe dependencies with version 1.0.16-alpha.0
rg "@onekeyfe.*1\.0\.16-alpha\.0" .

# Also check for the new version to confirm the update
rg "@onekeyfe.*1\.0\.16-alpha\.1" .

# List all package.json files to verify the search path
fd "package.json$"

Length of output: 2981

packages/connect-examples/expo-example/package.json (1)

3-3: 版本同步更新完成

主版本和 @onekeyfe 相关依赖已统一更新到 1.0.16-alpha.1。

Also applies to: 22-25

packages/connect-examples/expo-example/src/views/ApiPayloadScreen.tsx (2)

52-55: 配置项移动位置符合预期!

'Benfen API' 配置项的新位置遵循了字母顺序排序规则,使得整个配置列表更加有序和易于维护。


52-55: 验证数据结构的完整性

让我们确保 benfen.default 导出的数据结构与其他 API 配置保持一致。

✅ Verification successful

数据结构验证完成,格式正确无误

benfen.ts 的数据结构完全符合要求:

  • 正确导出了 PlaygroundProps[] 类型的数组
  • 每个 API 方法都包含了必需的 method 和 description 字段
  • presupposes 字段的结构与其他 API 配置保持一致
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查 benfen.default 的数据结构

# 查找并比较数据结构
ast-grep --pattern 'export default [
  {
    method: $_,
    $$$
  }
]' src/data/benfen.ts

# 检查其他相关引用
rg "from ['|\"].*benfen" -t ts -t tsx

Length of output: 228


Script:

#!/bin/bash
# 首先查找 benfen 相关文件
fd benfen

# 查找所有数据文件的结构
fd -e ts -e tsx -e js -e jsx -d 2 "^.*data.*" packages/connect-examples/expo-example/src/

# 检查 ApiPayloadScreen 中的其他数据引用
cat packages/connect-examples/expo-example/src/views/ApiPayloadScreen.tsx

Length of output: 5509


Script:

#!/bin/bash
# 检查 benfen.ts 数据文件的内容
cat packages/connect-examples/expo-example/src/data/benfen.ts

# 对比其他 API 数据文件的结构
cat packages/connect-examples/expo-example/src/data/basic.ts

Length of output: 12159

packages/core/src/api/allnetwork/AllNetworkGetAddress.ts (2)

314-314: 正确调用 preCheckDeviceSupport 进行设备支持验证

在调用方法前添加了 preCheckDeviceSupport,确保设备与方法的兼容性。


439-440: 正确添加 DeviceNotSupportMethod 的错误处理

更新了错误处理逻辑,加入了对 HardwareErrorCode.DeviceNotSupportMethod 的检查。

packages/core/src/core/index.ts (1)

203-204: 正确处理设备不支持的方法

当设备固件版本范围不可用且方法要求严格检查设备支持时,抛出 DeviceNotSupportMethod 错误,合理地处理了设备兼容性问题。

packages/core/src/api/BaseMethod.ts (1)

84-90: 添加 strictCheckDeviceSupport 属性以支持严格的设备检查

BaseMethod 类中新增了 strictCheckDeviceSupport 属性,默认值为 false,用于在需要时启用严格的设备支持检查。

packages/shared/src/HardwareError.ts (3)

233-237: 添加 DeviceNotSupportMethod 错误代码以表示设备不支持的方法

新增了 DeviceNotSupportMethod: 415 错误代码,更明确地表示设备不支持特定方法的情况。


371-376: 添加 BTCPsbtTooManyUtxos 错误代码以处理 PSBT 包含过多 UTXO 的情况

新增了 BTCPsbtTooManyUtxos: 818 错误代码,准确地处理 PSBT 中包含过多 UTXO 的情形。


495-495: 改进错误消息的语法

错误消息应为完整的句子,建议修改为“PSBT 包含过多的 UTXO”。

- [HardwareErrorCode.BTCPsbtTooManyUtxos]: 'PSBT too many utxos',
+ [HardwareErrorCode.BTCPsbtTooManyUtxos]: 'PSBT 包含过多的 UTXO',

packages/hd-transport/package.json Show resolved Hide resolved
packages/hd-transport-http/package.json Show resolved Hide resolved
packages/core/package.json Show resolved Hide resolved
packages/shared/src/HardwareError.ts Show resolved Hide resolved
@wabicai wabicai self-requested a review December 13, 2024 07:52
@ByteZhang1024 ByteZhang1024 merged commit 418da0d into onekey Dec 13, 2024
7 checks passed
@ByteZhang1024 ByteZhang1024 deleted the chore/optimizeRequest branch December 13, 2024 08:46
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