Skip to content

Support nested Tron transactions from WalletConnect#958

Open
0xh3rman wants to merge 4 commits intomainfrom
tron-wc-fix
Open

Support nested Tron transactions from WalletConnect#958
0xh3rman wants to merge 4 commits intomainfrom
tron-wc-fix

Conversation

@0xh3rman
Copy link
Collaborator

  • Parse and handle nested Tron transaction payloads and refactor the Tron chain signer.
  • TriggerSmartContract parsing now looks for raw_data either at payload.transaction.raw_data or payload.transaction.transaction.raw_data.
  • The signer was reworked: introduce a TronPayload type with format detection (V1 vs Legacy), helpers to access transaction/raw_data_hex, and into_signed to attach signatures; ChainSigner::sign_data now uses this flow.
  • Tests updated/added: new nested transaction fixture and a test to sign nested transactions, plus updated expected response JSON structure.

Parse and handle nested Tron transaction payloads and refactor the Tron chain signer. TriggerSmartContract parsing now looks for raw_data either at payload.transaction.raw_data or payload.transaction.transaction.raw_data. The signer was reworked: introduce a TronPayload type with format detection (V1 vs Legacy), helpers to access transaction/raw_data_hex, and into_signed to attach signatures; ChainSigner::sign_data now uses this flow. Tests updated/added: new nested transaction fixture and a test to sign nested transactions, plus updated expected response JSON structure.
@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 19, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  gemstone/src/wallet_connect/test/tron_sign_transaction_response.json  91% smaller
  crates/gem_tron/src/models/contract.rs  27% smaller
  crates/gem_tron/src/signer/chain_signer.rs  22% smaller
  gemstone/justfile Unsupported file format
  gemstone/src/wallet_connect/mod.rs  0% smaller
  gemstone/src/wallet_connect/test/tron_sign_transaction_nested.json  0% smaller

@0xh3rman 0xh3rman changed the title Support nested Tron transactions and signer Support nested Tron transactions from WalletConnect Feb 19, 2026
@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 enhances the Tron integration by enabling the system to correctly parse and sign nested Tron transaction payloads. It introduces a more robust and modular TronPayload structure within the ChainSigner, which intelligently detects transaction formats and streamlines the signing process. This ensures compatibility with various Tron transaction types and improves the overall reliability of Tron transaction handling.

Highlights

  • Nested Tron Transaction Support: Implemented parsing and handling for nested Tron transaction payloads.
  • Tron Chain Signer Refactor: Refactored the Tron chain signer for improved structure and maintainability.
  • Enhanced TriggerSmartContract Parsing: Updated TriggerSmartContract parsing to support raw_data at both top-level and nested transaction paths.
  • New TronPayload Type: Introduced a new TronPayload type to encapsulate Tron transaction data, including format detection (V1 vs. Legacy).
  • Streamlined Signing Logic: Enhanced TronPayload with utility methods for accessing transaction details and attaching signatures, and integrated this new flow into ChainSigner::sign_data.
  • New Test Cases: Added a new test fixture and a dedicated test case for signing nested Tron transactions.
  • Updated Test Response Structure: Adjusted the expected JSON response structure in tests for signed transactions.

🧠 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
  • crates/gem_tron/src/models/contract.rs
    • Modified TriggerSmartContractData's from_data method to check for raw_data in both the primary payload.transaction.other and a nested payload.transaction.other.transaction path.
  • crates/gem_tron/src/signer/chain_signer.rs
    • Removed TronTransaction and PayloadMetadata structs.
    • Introduced PayloadFormat enum (V1, Legacy) to distinguish transaction structures.
    • Created a new TronPayload struct with methods parse, transaction, raw_data_hex, and into_signed to encapsulate transaction parsing, format detection, data access, and signature application.
    • Rewrote TronChainSigner::sign_data to utilize the new TronPayload structure, simplifying the signing logic.
    • Removed standalone sign_data, get_transaction, and apply_signature functions.
  • gemstone/src/wallet_connect/mod.rs
    • Updated the parse_tron_sign_transaction test to assert directly on the value["signature"][0] and added assertions for txID, raw_data_hex, and visible.
    • Added a new test parse_tron_sign_transaction_nested_and_sign to verify the signing of nested Tron transactions.
  • gemstone/src/wallet_connect/test/tron_sign_transaction_nested.json
    • Added a new JSON fixture representing a nested Tron transaction payload for testing.
  • gemstone/src/wallet_connect/test/tron_sign_transaction_response.json
    • Modified the expected JSON structure for a signed Tron transaction response, removing the top-level address and signature fields and adjusting the transaction field to be the root.
Activity
  • No human activity (comments, reviews, etc.) has been recorded for this pull request yet.
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 refactors the Tron signer to support nested transaction payloads from WalletConnect, which is a great improvement for compatibility. The changes are well-structured, introducing a TronPayload struct to handle different payload formats and centralize signing logic. I've identified a potential high-severity issue in the new signer logic that could lead to silent failures and incorrect signatures, and a medium-severity issue in the new test where an assertion is missing. My comments provide specific suggestions to address these points.

DEVICE_ID=$(xcrun simctl list devices available | grep iPhone | head -1 | sed 's/.*(\([A-F0-9-]*\)).*/\1/')
echo "Using Simulator: $DEVICE_ID"
xcodebuild -project tests/ios/GemTest/GemTest.xcodeproj \
NSUnbufferedIO=YES xcodebuild -project tests/ios/GemTest/GemTest.xcodeproj \
Copy link
Contributor

Choose a reason for hiding this comment

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

NSUnbufferedIO=YES what do we need this for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Trying to debug why the log wasn't lively updated, I will remove it

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

Comments