-
Notifications
You must be signed in to change notification settings - Fork 199
feat: wire-up hdwallet-ledger with tron support bits #11245
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cf3461f
docs: add Tron Ledger support implementation documentation
gomesalexandre d7825c7
feat: bump locally
gomesalexandre 7a9ae3a
feat: add Tron to Ledger available chains
gomesalexandre 4cfb8b1
chore: merge develop into feat_tron_ledger
gomesalexandre bec62af
fix: trc10 support
NeOMakinG 30d5f3c
fix: reverts
NeOMakinG 23772af
fix: oupsy
NeOMakinG 12a93cc
Merge branch 'develop' into feat_tron_ledger
NeOMakinG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
NeOMakinG marked this conversation as resolved.
Outdated
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # Tron Ledger Support Integration | ||
|
|
||
| ## Overview | ||
| This document tracks the integration of Ledger hardware wallet support for Tron (TRX) in shapeshiftWeb. | ||
|
|
||
| ## Expected Changes | ||
|
|
||
| ### 1. hdwallet Dependency Update | ||
| - Update `@shapeshiftoss/hdwallet-ledger` to version with Tron support | ||
| - No code changes required in shapeshiftWeb | ||
|
|
||
| ## How It Works | ||
|
|
||
| ### Automatic Detection | ||
| The existing infrastructure in shapeshiftWeb automatically detects Ledger Tron support: | ||
|
|
||
| 1. **Wallet Support Detection** (`src/hooks/useWalletSupportsChain/useWalletSupportsChain.ts`) | ||
| - Uses `supportsTron(wallet)` type guard from hdwallet-core | ||
| - Returns true if wallet implements TronWallet interface | ||
|
|
||
| 2. **Account Discovery** (`src/lib/account/tron.ts`) | ||
| - Calls `wallet.tronGetAddress()` for Ledger wallets | ||
| - Uses standard BIP44 path: `m/44'/195'/0'/0/0` | ||
|
|
||
| 3. **Transaction Signing** (`src/components/Modals/Send/utils.ts`) | ||
| - Tron chain adapter calls `wallet.tronSignTx()` | ||
| - Ledger signs with rawDataHex from unsigned transaction | ||
|
|
||
| ### Wallet Flow | ||
| ``` | ||
| User connects Ledger | ||
| ↓ | ||
| useWalletSupportsChain checks supportsTron(wallet) → true | ||
| ↓ | ||
| Tron appears as supported chain | ||
| ↓ | ||
| deriveTronAccountIdsAndMetadata calls wallet.tronGetAddress() | ||
| ↓ | ||
| User can send TRX/TRC20 tokens | ||
| ↓ | ||
| Chain adapter calls wallet.tronSignTx() | ||
| ↓ | ||
| Transaction broadcasted | ||
| ``` | ||
|
|
||
| ## Testing Checklist | ||
|
|
||
| ### Prerequisites | ||
| - [ ] Ledger device with Tron app installed | ||
| - [ ] hdwallet updated to version with Tron support | ||
| - [ ] Tron feature flag enabled (`VITE_FEATURE_TRON=true`) | ||
|
|
||
| ### Test Cases | ||
| - [ ] Ledger appears as option when connecting wallet | ||
| - [ ] Tron chain shows as supported for Ledger | ||
| - [ ] Can derive Tron address from Ledger | ||
| - [ ] Address matches expected format (base58, starts with 'T') | ||
| - [ ] Can view Tron balance | ||
| - [ ] Can send native TRX from Ledger | ||
| - [ ] Can send TRC20 tokens from Ledger | ||
| - [ ] Ledger displays correct transaction details | ||
| - [ ] User can approve/reject on device | ||
| - [ ] Signed transaction broadcasts successfully | ||
| - [ ] Transaction appears in portfolio after confirmation | ||
|
|
||
| ## Verification Steps | ||
|
|
||
| ### 1. Check Wallet Detection | ||
| ```javascript | ||
| // In browser console after connecting Ledger | ||
| import { supportsTron } from '@shapeshiftoss/hdwallet-core'; | ||
| console.log('Ledger supports Tron:', supportsTron(wallet)); | ||
| ``` | ||
|
|
||
| ### 2. Check Account Discovery | ||
| ```javascript | ||
| // Look for Tron accounts in Redux state | ||
| window.store.getState().portfolio.accountIds | ||
| // Should include tron:T... account IDs for Ledger | ||
| ``` | ||
|
|
||
| ### 3. Check Transaction Building | ||
| - Navigate to Send modal | ||
| - Select Tron or TRC20 token | ||
| - Enter amount and recipient | ||
| - Click Review | ||
| - Verify Ledger prompts for approval | ||
| - Approve on device | ||
| - Verify transaction broadcasts | ||
|
|
||
| ## Known Limitations | ||
| - Requires Ledger Tron app to be installed and open | ||
| - User must approve address display on device for first use | ||
| - Transaction signing requires device confirmation | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### "Wrong App" Error | ||
| - Ensure Tron app is open on Ledger device | ||
| - Check SLIP44 mapping includes 195: "Tron" | ||
|
|
||
| ### Address Derivation Fails | ||
| - Verify BIP44 path: `m/44'/195'/0'/0/0` | ||
| - Check hw-app-trx is properly installed | ||
| - Confirm Ledger transport is connected | ||
|
|
||
| ### Signature Invalid | ||
| - Ensure rawDataHex format is correct | ||
| - Verify signature format matches expected (65 bytes) | ||
| - Check serialization: rawDataHex + signature | ||
|
|
||
| ## References | ||
| - [Tron Chain Adapter](/packages/chain-adapters/src/tron/TronChainAdapter.ts) | ||
| - [Tron Account Discovery](/src/lib/account/tron.ts) | ||
| - [Wallet Support Hook](/src/hooks/useWalletSupportsChain/useWalletSupportsChain.ts) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
NeOMakinG marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.