Skip to content

Add tron sign message and txs support for WalletConnect#925

Open
0xh3rman wants to merge 9 commits intomainfrom
tron-wallet-connect
Open

Add tron sign message and txs support for WalletConnect#925
0xh3rman wants to merge 9 commits intomainfrom
tron-wallet-connect

Conversation

@0xh3rman
Copy link
Collaborator

@0xh3rman 0xh3rman commented Feb 5, 2026

  • Added WalletConnect Tron request parsing for tron_signMessage, tron_signTransaction, and tron_sendTransaction.
  • Implemented Tron signing flows (message hashing + transaction signing) and response shaping in core, with per‑chain response handler structure.
  • Added raw_data_hex to Tron transaction metadata and updated mappings/FFI models.
  • Added fixtures + tests for Tron WalletConnect signMessage/signTransaction/sendTransaction.

@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 5, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  gemstone/src/message/signer.rs  65% smaller
  crates/primitives/src/wallet_connect_namespace.rs  22% smaller
  crates/gem_tron/src/rpc/client.rs  14% smaller
  gemstone/src/wallet_connect/mod.rs  7% smaller
  gemstone/src/wallet_connect/response_handler/mod.rs  1% smaller
  crates/gem_tron/src/provider/preload.rs  1% smaller
  Cargo.lock Unsupported file format
  crates/gem_hash/Cargo.toml Unsupported file format
  crates/gem_hash/src/lib.rs  0% smaller
  crates/gem_hash/src/sha2.rs  0% smaller
  crates/gem_tron/Cargo.toml Unsupported file format
  crates/gem_tron/src/lib.rs  0% smaller
  crates/gem_tron/src/models/contract.rs  0% smaller
  crates/gem_tron/src/models/mod.rs  0% smaller
  crates/gem_tron/src/signer/chain_signer.rs  0% smaller
  crates/gem_tron/src/signer/message.rs  0% smaller
  crates/gem_tron/src/signer/mod.rs  0% smaller
  crates/gem_tron/src/signer/transaction.rs  0% smaller
  crates/primitives/src/chain_config.rs  0% smaller
  crates/primitives/src/wallet_connector.rs  0% smaller
  gemstone/src/config/wallet_connect.rs  0% smaller
  gemstone/src/message/sign_type.rs  0% smaller
  gemstone/src/signer/chain.rs  0% smaller
  gemstone/src/siwe.rs Unsupported file format
  gemstone/src/wallet_connect/actions.rs  0% smaller
  gemstone/src/wallet_connect/request_handler/mod.rs  0% smaller
  gemstone/src/wallet_connect/request_handler/tron.rs  0% smaller
  gemstone/src/wallet_connect/test/tron_send_transaction.json  0% smaller
  gemstone/src/wallet_connect/test/tron_sign_message.json  0% smaller
  gemstone/src/wallet_connect/test/tron_sign_message_response.json  0% smaller
  gemstone/src/wallet_connect/test/tron_sign_transaction.json  0% smaller
  gemstone/src/wallet_connect/test/tron_sign_transaction_response.json  0% smaller

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @0xh3rman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the platform's multi-chain capabilities by introducing comprehensive support for the Tron blockchain. It establishes a dedicated gem_tron crate for all Tron-related logic, including robust transaction and message signing. Furthermore, it seamlessly integrates Tron into the existing WalletConnect infrastructure, allowing users to securely sign and send Tron transactions and messages through WalletConnect-enabled applications. This enhancement ensures broader compatibility and functionality for Tron users within the ecosystem.

Highlights

  • New gem_tron Crate: A new crate, gem_tron, has been introduced to encapsulate all Tron-specific functionalities, including address handling, transaction signing, and message hashing.
  • Tron Chain Signer Implementation: The TronChainSigner has been implemented, providing the core logic for signing Tron transactions and messages using SHA256 hashing and Secp256k1 signatures, and handling transaction payload extraction and signature application.
  • WalletConnect Integration for Tron: Tron has been fully integrated into the WalletConnect system, enabling support for tron_signMessage, tron_signTransaction, and tron_sendTransaction methods. This includes new request and response handlers for Tron-specific WalletConnect actions.
  • Primitives and Configuration Updates: The primitives crate has been updated to include Tron in ChainConfig, TransactionLoadMetadata (adding raw_data_hex), and WalletConnectCAIP2 enum, ensuring proper chain identification and metadata handling.
  • Gemstone Module Enhancements: The gemstone crate now recognizes Tron as a supported chain for WalletConnect, incorporates TronPersonal as a SignDigestType, and updates various signing and transaction decoding/validation logic to accommodate Tron.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • Cargo.lock
    • Added gem_hash, sha2, and signer dependencies.
  • crates/gem_tron/Cargo.toml
    • Added sha2, signer, and gem_hash dependencies.
  • crates/gem_tron/src/lib.rs
    • Introduced signer module and re-exported TronChainSigner.
  • crates/gem_tron/src/provider/preload.rs
    • Added raw_data_hex: None to TronTransactionLoadInput for consistency.
  • crates/gem_tron/src/signer/chain_signer.rs
    • New file implementing TronChainSigner for signing Tron transactions.
    • Handles transaction parsing, SHA256 hashing of raw data, and Secp256k1 signing.
    • Supports returning raw signatures or encoded transactions with applied signatures.
  • crates/gem_tron/src/signer/message.rs
    • New file defining tron_hash_message for hashing Tron-specific messages using Keccak256 with a TRON prefix.
  • crates/gem_tron/src/signer/mod.rs
    • New module to organize Tron signer components, re-exporting TronChainSigner and tron_hash_message.
  • crates/primitives/src/chain_config.rs
    • Updated Tron's network_id from an empty string to '0x2b6653dc'.
  • crates/primitives/src/transaction_load_metadata.rs
    • Added raw_data_hex: Option<String> to Tron variant of TransactionLoadMetadata.
  • crates/primitives/src/wallet_connect_namespace.rs
    • Added Tron variant to WalletConnectCAIP2 enum.
    • Updated WalletConnectCAIP2 implementations to include Tron for chain type, chain, and network ID resolution.
  • crates/primitives/src/wallet_connector.rs
    • Added TronSignMessage, TronSignTransaction, and TronSendTransaction methods to WalletConnectionMethods enum.
  • gemstone/src/config/wallet_connect.rs
    • Included Chain::Tron in the list of chains for WalletConnect configuration.
  • gemstone/src/message/sign_type.rs
    • Added TronPersonal to SignDigestType enum.
  • gemstone/src/message/signer.rs
    • Imported tron_hash_message.
    • Modified preview, plain_preview, get_hash, get_result, and sign methods to support SignDigestType::TronPersonal.
  • gemstone/src/models/transaction.rs
    • Moved GemStakeData definition to resolve potential ordering issues.
    • Added raw_data_hex: Option<String> to GemTransactionLoadMetadata::Tron and updated From implementations.
  • gemstone/src/signer/chain.rs
    • Imported TronChainSigner.
    • Added Chain::Tron to the GemChainSigner implementation.
  • gemstone/src/siwe.rs
    • Imported GemstoneError and updated siwe_validate error mapping.
  • gemstone/src/wallet_connect/actions.rs
    • Added Tron variant to WalletConnectTransactionType and WalletConnectTransaction enums.
  • gemstone/src/wallet_connect/mod.rs
    • Imported GemstoneError.
    • Updated parse_request, validate_sign_message, validate_send_transaction, and decode_send_transaction to handle Tron-specific logic and error types.
  • gemstone/src/wallet_connect/request_handler/mod.rs
    • Added tron module and TronRequestHandler.
    • Integrated TronRequestHandler for parsing WalletConnect methods.
  • gemstone/src/wallet_connect/request_handler/tron.rs
    • New file implementing ChainRequestHandler for Tron.
    • Provides parse_sign_message, parse_sign_transaction, and parse_send_transaction methods for Tron WalletConnect requests.
  • gemstone/src/wallet_connect/response_handler.rs
    • Modified encode_sign_message to handle ChainType::Tron.
    • Modified encode_sign_transaction to handle ChainType::Tron by returning the raw JSON.
Activity
  • A new gem_tron crate was created to house Tron-specific logic.
  • Dependencies for gem_hash, sha2, and signer were added to Cargo.lock and crates/gem_tron/Cargo.toml.
  • New modules for Tron signing (chain_signer, message, mod.rs) were added within crates/gem_tron/src/signer.
  • The primitives crate was updated to correctly configure Tron's network ID and extend transaction metadata with raw_data_hex.
  • WalletConnect-related enums and methods in primitives and gemstone were expanded to include Tron support.
  • The gemstone crate's message signer and chain signer implementations were updated to recognize and process Tron-specific signing types.
  • New WalletConnect request and response handlers for Tron were added and integrated into the gemstone WalletConnect module.
  • Existing code in gemstone was refactored to use GemstoneError consistently.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for Tron wallet connect. The changes are comprehensive, touching multiple crates to add Tron to chain configurations, WalletConnect namespaces, and message/transaction signing logic. The core implementation for Tron signing is added in the gem_tron crate.

My main feedback is on a logical issue in the new chain_signer.rs file, where applying a signature to a transaction payload might fail for nested JSON structures. I've provided a detailed comment with a suggested fix for this.

Overall, the changes are well-structured and the addition of Tron support is a great enhancement.

@0xh3rman 0xh3rman changed the title Tron wallet connect Add tron sign message and txs support for WalletConnect Feb 5, 2026
@0xh3rman 0xh3rman marked this pull request as ready for review February 5, 2026 07:57
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