Skip to content

feat: add Tron support to hdwallet-ledger#754

Merged
NeOMakinG merged 11 commits intomasterfrom
feat_tron_ledger
Dec 1, 2025
Merged

feat: add Tron support to hdwallet-ledger#754
NeOMakinG merged 11 commits intomasterfrom
feat_tron_ledger

Conversation

@gomesalexandre
Copy link
Contributor

@gomesalexandre gomesalexandre commented Dec 1, 2025

Description

Does what it says on the box - test with web fren.

NOTE: You may run into out of energy issues, unrelated to this PR, pls focus on signing bits.

Issue

Screenshots

E2E: https://jam.dev/c/6dc34b03-2180-4639-802f-da50850f9c18

  • Ledger Live addy
Screenshot 2025-12-01 at 13 36 53
  • Web addy
Screenshot 2025-12-01 at 14 02 17

Summary by CodeRabbit

  • New Features

    • Ledger integration: full Tron support — derive addresses, manage account paths, and sign Tron transactions via Ledger devices (WebUSB & WebHID).
    • WebHID transport: added mapping for Cosmos, Solana and Thorchain apps for improved Ledger compatibility.
  • Chores

    • Package version bumps and dependency range updates across the workspace.

✏️ Tip: You can customize this high-level summary in your review settings.

gomesalexandre and others added 5 commits December 1, 2025 13:28
Implements Tron support for Ledger hardware wallets following the established
pattern for chain integrations.

Changes:
- Add @ledgerhq/hw-app-trx dependency (v6.31.9)
- Create packages/hdwallet-ledger/src/tron.ts with:
  - tronGetAddress() - Derives Tron address from BIP44 path
  - tronSignTx() - Signs transactions using rawDataHex
  - tronGetAccountPaths() - Returns standard Tron BIP44 paths
  - tronNextAccountPath() - Account path iteration
- Update LedgerHDWalletInfo to implement TronWalletInfo interface
- Update LedgerHDWallet to implement TronWallet interface
- Add Tron app name mapping (SLIP44: 195 -> "Tron")
- Add "Tron" to LedgerTransportCoinType and type mappings
- Add Tron case to describePath()

Technical Details:
- BIP44 Path: m/44'/195'/0'/0/0 (SLIP44 code 195)
- Uses hw-app-trx library for Ledger device communication
- Signature format: rawDataHex + signature (65 bytes)
- Address format: Base58-encoded, starts with 'T'

This enables users to manage Tron assets with Ledger hardware wallets,
including native TRX and TRC20 token transactions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Auto-fix import order and array formatting to match project style.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add Tron coin case to translateCoinAndMethod in both WebUSB and WebHID
transport implementations. This allows the Ledger device to properly route
Tron method calls to the hw-app-trx library.

Also added missing Cosmos, Solana, and Thorchain support to WebHID transport
for feature parity with WebUSB.

Changes:
- Import Trx from @ledgerhq/hw-app-trx
- Add "Tron" case to translateCoinAndMethod switch statements
- WebHID: Add Cosmos, Solana, Thorchain cases for completeness

This fixes the "TypeError: coin" error when trying to connect Tron accounts
via Ledger hardware wallets.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@gomesalexandre gomesalexandre changed the title feat: add Tron support to Ledger feat: add Tron support to hdwallet-ledger Dec 1, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 1, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds Tron support to the Ledger HDWallet integration and expands Ledger webhid transport cases to include Cosmos, Solana, and Thorchain; updates transport types, introduces a new tron module with address/sign and account-path helpers, and bumps package versions and dependencies to 1.62.19 across many packages.

Changes

Cohort / File(s) Summary
Ledger transport (webhid/webusb)
packages/hdwallet-ledger-webhid/src/transport.ts, packages/hdwallet-ledger-webusb/src/transport.ts
Added translateCoinAndMethod cases for new coins (Tron in both; plus Cosmos, Solana, Thorchain in webhid) by importing Ledger app wrappers and binding methods to the transport.
Ledger core transport types
packages/hdwallet-ledger/src/transport.ts
Added type import for Trx; extended LedgerTransportCoinType to include "Tron" and mapped "Tron" to MethodsOnly<Trx> in LedgerTransportMethodMap.
Ledger HDWallet implementation
packages/hdwallet-ledger/src/ledger.ts
Implemented Tron interfaces: LedgerHDWalletInfo/LedgerHDWallet now implement TronWalletInfo/TronWallet; added _supportsTronInfo/_supportsTron flags; added tronGetAccountPaths, tronNextAccountPath, tronGetAddress, tronSignTx; extended describePath for Tron.
Tron module
packages/hdwallet-ledger/src/tron.ts
New module implementing tronGetAddress, tronSignTx, tronGetAccountPaths, tronNextAccountPath with BIP32 path derivation, transport calls, and error handling.
Utility mapping
packages/hdwallet-ledger/src/utils.ts
Added slip44 195 -> "Tron" mapping in appNameBySlip44.
Ledger package deps & version
packages/hdwallet-ledger/package.json
Bumped package version to 1.62.19; added dependency @ledgerhq/hw-app-trx: ^6.31.9; updated @shapeshiftoss/hdwallet-core constraint.
Monorepo / examples / integrations version bumps
lerna.json, integration/package.json, examples/sandbox/package.json, and many packages/*/package.json files (e.g., packages/hdwallet-*.package.json)
Bumped versions from 1.62.181.62.19 and updated many internal hdwallet dependency constraints from exact pins to caret ^1.62.19.

Sequence Diagram

sequenceDiagram
    participant User
    participant LedgerHDWallet
    participant TronModule
    participant Transport
    participant LedgerDevice

    User->>LedgerHDWallet: tronGetAddress(msg)
    LedgerHDWallet->>TronModule: tronGetAddress(transport, msg)
    TronModule->>TronModule: derive BIP32 path
    TronModule->>Transport: Trx.getAddress(path)
    Transport->>LedgerDevice: send APDU (path)
    LedgerDevice-->>Transport: address response
    Transport-->>TronModule: address
    TronModule-->>LedgerHDWallet: return address
    LedgerHDWallet-->>User: Promise<string>

    User->>LedgerHDWallet: tronSignTx(msg)
    LedgerHDWallet->>TronModule: tronSignTx(transport, msg)
    TronModule->>TronModule: derive BIP32 path & prepare tx
    TronModule->>Transport: Trx.signTransaction(path, tx)
    Transport->>LedgerDevice: send APDU (path + tx)
    LedgerDevice-->>Transport: signature
    Transport-->>TronModule: signature
    TronModule->>TronModule: format signed tx
    TronModule-->>LedgerHDWallet: return TronSignedTx
    LedgerHDWallet-->>User: Promise<TronSignedTx>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

  • Pay attention to:
    • packages/hdwallet-ledger/src/ledger.ts — interface implementations, capability flags, and describePath branching.
    • packages/hdwallet-ledger/src/tron.ts — BIP32 path derivation, transport calls, signing formatting, and error handling.
    • Transport files (webhid, webusb, src/transport.ts) — correct Trx instantiation and method bindings.
    • packages/hdwallet-ledger/package.json — new dependency and version bump consistency.

Suggested reviewers

  • gomesalexandre

Poem

🐰 I hopped in code at break of dawn,
Found Tron tucked in slip44's lawn,
Paths derived and signatures sing,
A tiny hop for a Ledger ring,
Thump — new coin sprouted on my lawn 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and accurately summarizes the main change: adding Tron support to the hdwallet-ledger package, which aligns with all file modifications across the codebase.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between de9f747 and ea0a1e2.

📒 Files selected for processing (27)
  • examples/sandbox/package.json (2 hunks)
  • integration/package.json (2 hunks)
  • lerna.json (1 hunks)
  • packages/hdwallet-coinbase/package.json (2 hunks)
  • packages/hdwallet-core/package.json (1 hunks)
  • packages/hdwallet-gridplus/package.json (2 hunks)
  • packages/hdwallet-keepkey-chromeusb/package.json (2 hunks)
  • packages/hdwallet-keepkey-electron/package.json (2 hunks)
  • packages/hdwallet-keepkey-nodehid/package.json (2 hunks)
  • packages/hdwallet-keepkey-nodewebusb/package.json (2 hunks)
  • packages/hdwallet-keepkey-tcp/package.json (2 hunks)
  • packages/hdwallet-keepkey-webusb/package.json (2 hunks)
  • packages/hdwallet-keepkey/package.json (2 hunks)
  • packages/hdwallet-keplr/package.json (2 hunks)
  • packages/hdwallet-ledger-webhid/package.json (2 hunks)
  • packages/hdwallet-ledger-webusb/package.json (2 hunks)
  • packages/hdwallet-ledger/package.json (2 hunks)
  • packages/hdwallet-metamask-multichain/package.json (2 hunks)
  • packages/hdwallet-native-vault/package.json (2 hunks)
  • packages/hdwallet-native/package.json (2 hunks)
  • packages/hdwallet-phantom/package.json (2 hunks)
  • packages/hdwallet-portis/package.json (2 hunks)
  • packages/hdwallet-trezor-connect/package.json (2 hunks)
  • packages/hdwallet-trezor/package.json (2 hunks)
  • packages/hdwallet-vultisig/package.json (2 hunks)
  • packages/hdwallet-walletconnect/package.json (2 hunks)
  • packages/hdwallet-walletconnectV2/package.json (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

gomesalexandre and others added 3 commits December 1, 2025 14:38
Remove ^ prefix from all 1.62.17 version references to use exact versions
instead of ranges. This ensures consistent dependency resolution.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@gomesalexandre gomesalexandre marked this pull request as ready for review December 1, 2025 14:39
@gomesalexandre gomesalexandre requested a review from a team as a code owner December 1, 2025 14:39
gomesalexandre added a commit that referenced this pull request Dec 1, 2025
Implements Ledger hardware wallet integration for Sui blockchain:
- Add @mysten/ledgerjs-hw-app-sui dependency
- Create sui.ts module for Ledger-specific Sui operations
- Implement suiGetAddress() and suiSignTx() for Ledger transport
- Add Sui support to LedgerHDWallet and LedgerHDWalletInfo classes
- Update transport type system and implementations (WebUSB, WebHID)
- Add Sui (784) to appNameBySlip44 mapping

Follows same pattern as Tron Ledger implementation (PR #754).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
NeOMakinG
NeOMakinG previously approved these changes Dec 1, 2025
Copy link
Contributor

@NeOMakinG NeOMakinG left a comment

Choose a reason for hiding this comment

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

image image image

Swapping is happy, account derivation is happy

@NeOMakinG NeOMakinG merged commit 0f3179d into master Dec 1, 2025
1 of 3 checks passed
@NeOMakinG NeOMakinG deleted the feat_tron_ledger branch December 1, 2025 23:07
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