OneKeyHQ / firmware

Other
60 stars 46 forks source link

feat: support ton #583

Open Lu1zz opened 2 days ago

Lu1zz commented 2 days ago

Summary by CodeRabbit

版本更新说明

coderabbitai[bot] commented 2 days ago

Walkthrough

本次更改主要涉及对TON(The Open Network)区块链的支持。更新包括添加新的protobuf消息类型、功能和常量,以便于地址获取、消息签名和证明签名。此外,CLI工具也进行了扩展,以支持TON相关的命令和操作。这些更改增强了现有的Trezor硬件钱包功能,允许用户与TON区块链进行交互。

Changes

文件路径 更改摘要
common/protob/check.py 更新protobuf前缀检查逻辑,新增"Ton"前缀。
common/protob/messages-ton.proto 新增TON相关的protobuf定义,包括多个枚举和消息类型。
common/protob/messages.proto 添加Nexa和Ton协议的新消息类型。
core/SConscript.firmware 增加TON应用的源文件路径配置。
core/embed/firmware/memory_H.ld 在.linker脚本中添加新对象文件的引用。
core/embed/firmware/mpconfigport.h 启用特殊数学函数支持的宏定义更新。
core/embed/unix/mpconfigport.h 启用特殊数学函数支持的宏定义更新。
core/src/all_modules.py 添加TON模块及其子模块的导入。
core/src/apps/ton/init.py 新增TON应用的常量定义。
core/src/apps/ton/get_address.py 新增异步函数get_address,用于获取TON地址。
core/src/apps/ton/layout.py 新增多个与交易确认和费用管理相关的函数。
core/src/apps/ton/sign_message.py 新增异步函数sign_message,用于签名TON消息。
core/src/apps/ton/sign_proof.py 新增异步函数sign_proof,用于签名TON证明。
core/src/apps/ton/tokens.py 新增TokenInfo类及相关函数。
core/src/apps/ton/tonsdk/boc/init.py 更新模块导入和公共接口定义。
core/src/apps/ton/tonsdk/boc/_bit_string.py 新增BitString类,用于管理位序列。
core/src/apps/ton/tonsdk/boc/_builder.py 新增Builder类,用于构建位数据结构。
core/src/apps/ton/tonsdk/boc/_cell.py 新增Cell类,表示BOC格式的单元。
core/src/apps/ton/tonsdk/boc/_dict_builder.py 新增DictBuilder类,用于构建字典结构。
core/src/apps/ton/tonsdk/boc/dict/init.py 更新模块导入,定义公共接口。
core/src/apps/ton/tonsdk/boc/dict/find_common_prefix.py 新增find_common_prefix函数,查找字符串的最长公共前缀。
core/src/apps/ton/tonsdk/boc/dict/serialize_dict.py 新增一系列函数,用于字典序列化。
core/src/apps/ton/tonsdk/contract/init.py 新增Contract类,用于管理智能合约。
core/src/apps/ton/tonsdk/contract/token/ft/init.py 导入JettonWallet类,更新公共接口。
core/src/apps/ton/tonsdk/contract/token/ft/jetton_minter.py 新增JettonMinter类,管理代币铸造。
core/src/apps/ton/tonsdk/contract/token/ft/jetton_wallet.py 新增JettonWallet类,管理代币钱包操作。
core/src/apps/ton/tonsdk/contract/token/nft/init.py 导入NFT相关类,更新公共接口。
core/src/apps/ton/tonsdk/contract/token/nft/nft_collection.py 新增NFTCollection类,管理NFT集合。
core/src/apps/ton/tonsdk/contract/token/nft/nft_item.py 新增NFTItem类,管理NFT项。
core/src/apps/ton/tonsdk/contract/token/nft/nft_sale.py 新增NFTSale类,管理NFT销售。
core/src/apps/ton/tonsdk/contract/token/nft/nft_utils.py 新增与NFT相关的实用函数。
core/src/apps/ton/tonsdk/contract/wallet/init.py 新增钱包版本枚举和钱包类。
core/src/apps/ton/tonsdk/contract/wallet/_wallet_contract.py 新增WalletContract类,管理钱包操作。
core/src/apps/ton/tonsdk/contract/wallet/_wallet_contract_v3.py 新增V3钱包合约实现。
core/src/apps/ton/tonsdk/contract/wallet/_wallet_contract_v4.py 新增V4钱包合约实现。
core/src/apps/ton/tonsdk/utils/init.py 更新模块导入,定义公共接口。
core/src/apps/ton/tonsdk/utils/_address.py 新增地址解析和处理功能。
core/src/apps/ton/tonsdk/utils/_utils.py 新增字节数组和CRC计算的实用函数。
core/src/apps/workflow_handlers.py 为TON协议添加新的消息处理功能。
core/src/trezor/enums/MessageType.py 新增TON区块链相关的消息类型。
core/src/trezor/enums/TonWalletVersion.py 新增V4R2常量。
core/src/trezor/enums/TonWorkChain.py 新增BASECHAINMASTERCHAIN常量。
core/src/trezor/enums/init.py 新增TON钱包版本和工作链的枚举类。
core/src/trezor/lvglui/scrs/template.py 新增TonMessageTonTransfer类,处理TON交易显示。
core/src/trezor/messages.py 新增TON相关的消息类。
core/src/trezor/strings.py 新增format_customer_data函数,处理客户数据格式。
core/src/trezor/ui/layouts/lvgl/init.py 新增TON相关的确认函数。
core/src/trezor/ui/layouts/lvgl/altcoin.py 新增confirm_total_ton函数,处理TON交易确认。
python/src/trezorlib/cli/ton.py 新增与TON区块链交互的CLI命令。
python/src/trezorlib/cli/trezorctl.py 为TON命令添加命令别名。
python/src/trezorlib/messages.py 新增TON相关的消息类。
python/src/trezorlib/ton.py 新增与TON交互的函数。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TrezorClient
    participant TON

    User->>TrezorClient: get_address()
    TrezorClient->>TON: TonGetAddress
    TON-->>TrezorClient: Address
    TrezorClient-->>User: Address

    User->>TrezorClient: sign_message()
    TrezorClient->>TON: TonSignMessage
    TON-->>TrezorClient: SignedMessage
    TrezorClient-->>User: Signature

    User->>TrezorClient: sign_proof()
    TrezorClient->>TON: TonSignProof
    TON-->>TrezorClient: SignedProof
    TrezorClient-->>User: Signature

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.