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: benfen return address #390

Merged
merged 2 commits into from
Dec 4, 2024
Merged

fix: benfen return address #390

merged 2 commits into from
Dec 4, 2024

Conversation

wabicai
Copy link
Contributor

@wabicai wabicai commented Dec 3, 2024

Summary by CodeRabbit

  • 新功能
    • 所有相关包的版本已更新至 1.0.16-alpha.0,标志着预发布状态。
  • 依赖更新
    • 更新了多个依赖包的版本,以确保兼容性和最新功能,包括 @onekeyfe/hd-core@onekeyfe/hd-shared 等。
  • 文档
    • 更新了各个包的 package.json 文件,确保信息准确。
  • 测试
    • 新增了针对 Benfen API 地址规范化功能的测试文件。
    • 更新了测试配置,以启用代码覆盖率收集。

Copy link

coderabbitai bot commented Dec 3, 2024

Walkthrough

本次更改涉及多个 package.json 文件的版本更新,所有相关项目的版本均从 1.0.15 升级至 1.0.16-alpha.0,标志着软件进入预发布状态。此外,多个项目的依赖项版本也进行了相应更新,确保与新版本兼容。具体更改包括对依赖项版本的统一提升,且未对文件结构或其他字段进行修改。

Changes

文件路径 更改摘要
packages/connect-examples/electron-example/package.json 版本更新至 1.0.16-alpha.0
packages/connect-examples/expo-example/package.json 版本更新至 1.0.16-alpha.0;依赖项更新至 ^1.0.16-alpha.0@onekeyfe/hd-ble-sdk@onekeyfe/hd-common-connect-sdk@onekeyfe/hd-core@onekeyfe/hd-web-sdk
packages/core/package.json 版本更新至 1.0.16-alpha.0;依赖项更新至 ^1.0.16-alpha.0@onekeyfe/hd-shared@onekeyfe/hd-transport
packages/hd-ble-sdk/package.json 版本更新至 1.0.16-alpha.0;依赖项更新至 ^1.0.16-alpha.0@onekeyfe/hd-core@onekeyfe/hd-shared@onekeyfe/hd-transport-react-native
packages/hd-common-connect-sdk/package.json 版本更新至 1.0.16-alpha.0;依赖项更新至 ^1.0.16-alpha.0@onekeyfe/hd-core@onekeyfe/hd-shared@onekeyfe/hd-transport-http@onekeyfe/hd-transport-lowlevel@onekeyfe/hd-transport-webusb
packages/hd-transport-http/package.json 版本更新至 1.0.16-alpha.0;依赖项更新至 ^1.0.16-alpha.0@onekeyfe/hd-shared@onekeyfe/hd-transport
packages/hd-transport-lowlevel/package.json 版本更新至 1.0.16-alpha.0;依赖项更新至 ^1.0.16-alpha.0@onekeyfe/hd-shared@onekeyfe/hd-transport
packages/hd-transport-react-native/package.json 版本更新至 1.0.16-alpha.0;依赖项更新至 ^1.0.16-alpha.0@onekeyfe/hd-shared@onekeyfe/hd-transport
packages/hd-transport-webusb/package.json 版本更新至 1.0.16-alpha.0;依赖项更新至 ^1.0.16-alpha.0@onekeyfe/hd-shared@onekeyfe/hd-transport
packages/hd-transport/package.json 版本更新至 1.0.16-alpha.0
packages/hd-web-sdk/package.json 版本更新至 1.0.16-alpha.0;依赖项更新至 ^1.0.16-alpha.0@onekeyfe/hd-core@onekeyfe/hd-shared@onekeyfe/hd-transport-http@onekeyfe/hd-transport-webusb
packages/shared/package.json 版本更新至 1.0.16-alpha.0

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PackageManager
    participant Package

    User->>PackageManager: Request update for packages
    PackageManager->>Package: Update version to 1.0.16-alpha.0
    Package->>PackageManager: Version updated
    PackageManager->>User: Notify update complete
Loading

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

Copy link

socket-security bot commented Dec 3, 2024

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 06f40a9 and fa0daaa.

📒 Files selected for processing (13)
  • packages/connect-examples/electron-example/package.json (1 hunks)
  • packages/connect-examples/expo-example/package.json (2 hunks)
  • packages/core/package.json (2 hunks)
  • packages/core/src/api/benfen/normalize.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)
🔇 Additional comments (13)
packages/hd-transport-lowlevel/package.json (1)

3-3: 版本更新检查通过!

版本号和依赖项更新保持一致性:

  • 包版本:1.0.16-alpha.0
  • @onekeyfe/hd-shared: ^1.0.16-alpha.0
  • @onekeyfe/hd-transport: ^1.0.16-alpha.0

Also applies to: 22-23

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

3-3: 验证所有包版本一致性

让我们确保所有相关包都已更新到相同版本。

Also applies to: 3-3, 3-3

✅ Verification successful

所有包版本已同步更新至 1.0.16-alpha.0

经过验证,所有相关的业务包都已正确更新到相同版本 1.0.16-alpha.0,包括:

  • core
  • hd-ble-sdk
  • hd-common-connect-sdk
  • hd-transport-http
  • hd-transport-lowlevel
  • hd-transport-react-native
  • hd-transport-webusb
  • hd-transport
  • hd-web-sdk
  • shared
  • connect-examples
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查所有 package.json 文件中的版本号是否一致

echo "检查版本一致性..."
find . -name "package.json" -exec grep -H "\"version\":" {} \;

Length of output: 53800

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

3-3: 版本更新提醒

从稳定版本 1.0.15 升级到预发布版本 1.0.16-alpha.0 需要注意以下几点:

  • 预发布版本可能包含不稳定特性
  • 确保所有依赖包版本同步更新
  • 建议在测试环境充分验证

Also applies to: 23-25

✅ Verification successful

版本一致性验证通过

所有 @onekeyfe 相关包已同步更新至 1.0.16-alpha.0 版本,包括:

  • 核心包版本统一
  • 依赖引用版本正确使用 ^1.0.16-alpha.0
  • 仅有两个特例包(cross-inpage-provider-core 和 react-native-ble-plx)使用独立版本号,这是预期行为
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查所有相关包的版本一致性
fd -e json -x jq -r '. | select(.name | startswith("@onekeyfe")) | .version' {} \;

Length of output: 2913


Script:

#!/bin/bash
# 使用更精确的命令查找包版本
echo "检查 package.json 文件中的版本信息:"
fd "package.json" packages/ -x jq -r 'select(.name != null and (.name | startswith("@onekeyfe"))) | "\(.name): \(.version)"' {} \;

echo -e "\n检查依赖项版本:"
fd "package.json" packages/ -x jq -r 'select(.dependencies != null) | .dependencies | to_entries[] | select(.key | startswith("@onekeyfe")) | "\(.key): \(.value)"' {} \;

Length of output: 1990

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

3-3: 依赖管理建议

依赖更新看起来很完整,建议:

  • 在升级后运行完整的测试套件
  • 记录任何破坏性改动
  • 更新相关文档

Also applies to: 23-24

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

3-3: React Native 环境测试提醒

版本升级涉及 React Native 环境,建议:

  • 在 iOS 和 Android 平台分别测试
  • 验证与现有 React Native 版本的兼容性
  • 关注性能变化

Also applies to: 22-23

✅ Verification successful

React Native 包版本更新验证完成

代码检查显示:

  • 所有内部依赖(@onekeyfe/*)已统一更新至 1.0.16-alpha.0
  • React Native 相关的外部依赖保持稳定版本
    • react-native-ble-plx: 3.0.1
    • react-native-ble-manager: 8.1.0

无需额外测试要求,版本更新符合预期。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否有未更新的依赖
rg '"@onekeyfe/[^"]+": "\^1\.0\.15"' 

Length of output: 38


Script:

#!/bin/bash
# Check package.json for dependencies and version
cat packages/hd-transport-react-native/package.json

# Find all package.json files to check for potential dependencies
fd package.json

# Check React Native related files
fd -e js -e jsx -e ts -e tsx | rg -i "react.?native"

Length of output: 1862

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

3-3: 版本更新提醒

包版本已更新至 alpha 预发布状态,请注意:

  • 版本从 1.0.15 升级到 1.0.16-alpha.0
  • 相关依赖已同步更新

Also applies to: 27-28

✅ Verification successful

版本更新已验证通过

所有相关包均已同步更新至 1.0.16-alpha.0 版本,包括:

  • 核心包:core, shared, hd-transport
  • SDK 包:hd-web-sdk, hd-ble-sdk
  • 传输层包:hd-transport-http, hd-transport-webusb, hd-transport-lowlevel
  • 示例项目:electron-example, expo-example
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 验证所有相关包版本一致性
rg -g "package.json" '"version": "1.0.16-alpha.0"' 

Length of output: 905

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

3-3: 依赖版本同步更新已确认

所有依赖包已统一更新至 1.0.16-alpha.0:

  • @onekeyfe/hd-core
  • @onekeyfe/hd-shared
  • @onekeyfe/hd-transport-http
  • @onekeyfe/hd-transport-lowlevel
  • @onekeyfe/hd-transport-webusb

Also applies to: 23-27

packages/core/package.json (1)

3-3: 核心包版本更新确认

核心包版本更新已完成:

  • 主版本升级至 1.0.16-alpha.0
  • 相关依赖同步更新完成

Also applies to: 28-29

✅ Verification successful

版本更新已完成确认

所有相关包已同步更新至 1.0.16-alpha.0 版本,包括:

  • @onekeyfe/hd-core
  • @onekeyfe/hd-shared
  • @onekeyfe/hd-transport
  • @onekeyfe/hd-transport-http
  • @onekeyfe/hd-transport-webusb
    以及其他依赖包
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否有遗漏的依赖版本更新
rg -g "package.json" '"@onekeyfe/hd-(shared|transport)": "\^1\.0\.15"'

Length of output: 70


Script:

#!/bin/bash
# 检查所有 package.json 中的依赖版本
rg -g "package.json" "@onekeyfe/hd-" -A 1 -B 1

Length of output: 5638


Script:

#!/bin/bash
# 查找所有 package.json 文件
fd "package.json" --type f --exec cat {}

Length of output: 17579


Script:

#!/bin/bash
# 检查当前版本号
rg -g "package.json" '"version":'

Length of output: 922

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

5-5: 版本更新已确认

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

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

3-3: 依赖版本更新已确认

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

Also applies to: 24-27

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

22-25: 依赖版本更新合理

OneKey SDK 相关依赖包版本更新保持一致:

  • 所有包都更新到了 ^1.0.16-alpha.0
  • 版本号对齐有助于避免兼容性问题

3-3: 请确认版本升级的必要性

将版本从稳定版 1.0.15 升级到预发布版本 1.0.16-alpha.0 是一个重要变更。这个改动:

  • 表明项目进入不稳定状态
  • 可能影响生产环境的稳定性
✅ Verification successful

版本更新符合项目规范

检查结果显示所有相关包都同步更新到了 1.0.16-alpha.0 版本,这是一个统一的版本升级。这种同步更新反映了良好的版本管理实践。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查其他包是否都同步更新到了相同版本
fd -e json -x jq -r '. | select(.version != null) | .version' {} \; | sort | uniq -c

Length of output: 829


Script:

#!/bin/bash
# 检查所有package.json文件中的版本信息
fd package.json -x echo "=== {} ===" \; -x cat {} \; | grep -A 1 '"version":'

# 检查是否有其他alpha版本的历史记录
git log -p --all | grep -B 2 "alpha.0"

Length of output: 954


Line range hint 1-99: 核实PR目标与代码变更的一致性

PR 标题提到 "fix: benfen return address",但当前变更仅包含版本升级。建议:

  • 确认是否遗漏了与 return address 相关的代码改动
  • 验证版本升级是否与修复目标相关
✅ Verification successful

代码变更与PR目标一致性已确认

PR确实包含了与Benfen地址相关的实质性改动。在packages/core/src/api/benfen/normalize.ts文件中,修改了地址校验和的计算方法,从直接处理十六进制字节改为使用TextEncoder处理。这个改动与修复Benfen返回地址的目标相符。其他的变更是相关依赖包的版本更新。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 搜索与 benfen return address 相关的改动
rg -i "benfen.*address|return.*address" 

Length of output: 7314


Script:

#!/bin/bash
# 检查PR中与benfen相关的具体改动
git diff HEAD^1 -- packages/core/src/api/benfen/

Length of output: 624


Script:

#!/bin/bash
# 检查PR中所有改动的文件
git diff --name-only HEAD^1

Length of output: 556


Script:

#!/bin/bash
# 检查PR的commit信息
git log -1 --pretty=format:"%B"

Length of output: 0

packages/shared/package.json Show resolved Hide resolved
packages/hd-transport/package.json Show resolved Hide resolved
packages/core/package.json Show resolved Hide resolved
packages/core/src/api/benfen/normalize.ts Show resolved Hide resolved
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

📥 Commits

Reviewing files that changed from the base of the PR and between fa0daaa and 00cde6f.

📒 Files selected for processing (3)
  • packages/core/__tests__/benfen.test.ts (1 hunks)
  • packages/core/__tests__/checkBootloaderReleast.test.js (1 hunks)
  • packages/core/jest.config.js (1 hunks)
🔇 Additional comments (1)
packages/core/jest.config.js (1)

5-5: 代码覆盖率收集配置已添加!

启用代码覆盖率收集是一个很好的改进,这有助于跟踪测试覆盖情况。

@wabicai wabicai merged commit 233ae26 into onekey Dec 4, 2024
7 checks passed
@wabicai wabicai deleted the fix/benfen branch December 4, 2024 03:02
Comment on lines +5 to +14
// Test case with a known public key and its expected address
const publicKey = '6e9c9ef745cc3a250168db15526d18075dc52849d49f8a6ea5477c1c264b4848';
const expectedHexAddress = '0xb4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa';
const expectedAddress =
'BFCb4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa2e35';

const hexAddress = publicKeyToAddress(publicKey);
const bfcAddress = hex2BfcAddress(hexAddress);
expect(hexAddress).toBe(expectedHexAddress);
expect(bfcAddress).toBe(expectedAddress);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

数据集太少,不要用常用钱包地址去做

准备一个 fixtures 数据集

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 本来是想管理一个通用的数据集,将助记词也记在里面,后续维护同一个数据集。但是有两个问题

    • 安全性。虽然可以使用空的,全新的钱包。
    • 一个一个导入钱包去生成地址/用例, 没有直接创建一个效率高。(因为导入需要输入助记词)
  • 目前维护 12 / 18 / 24 位助记词,每种类型 3 个数据。共 3 *3 = 9 个数据。这样应该是可以的?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 个数据为 "m/44'/728'/0'/0'","m/44'/728'/0'/0'/0'", "m/44'/728'/0'/0'/1'"

(另,第一次种情况,不传递最后一位address_index。在实际中应该不会出现,需要这样测试么?)

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