feat: Add tron getBlock and getblockInfo for alpaca api#15050
Draft
estrauser-ledger wants to merge 2 commits intodevelopfrom
Draft
feat: Add tron getBlock and getblockInfo for alpaca api#15050estrauser-ledger wants to merge 2 commits intodevelopfrom
estrauser-ledger wants to merge 2 commits intodevelopfrom
Conversation
Contributor
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Tron block retrieval support to the Alpaca API by implementing getBlockInfo and getBlock (with transaction/operation mapping) and wiring them into the Tron createApi.
Changes:
- Add Tron network typing for blocks-with-transactions and a new network call to fetch them.
- Implement
getBlockInfo/getBlockincoin-tronlogic, including mapping TRX/TRC10/TRC20-like transfers intoBlockOperations. - Expose these methods through the Tron Alpaca API and add unit tests + a changeset.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| libs/coin-modules/coin-tron/src/network/types.ts | Adds API types for block headers and blocks with embedded transactions. |
| libs/coin-modules/coin-tron/src/network/index.ts | Adds getBlockWithTransactions() calling /wallet/getblock with detail: true. |
| libs/coin-modules/coin-tron/src/logic/index.ts | Re-exports the new block logic entrypoints. |
| libs/coin-modules/coin-tron/src/logic/getBlock.ts | Implements getBlockInfo/getBlock and transaction→operation mapping. |
| libs/coin-modules/coin-tron/src/logic/getBlock.test.ts | Adds unit tests for the new block logic (partial coverage). |
| libs/coin-modules/coin-tron/src/api/index.ts | Wires getBlock/getBlockInfo into createApi() instead of throwing. |
| .changeset/green-years-sin.md | Declares a minor bump for @ledgerhq/coin-tron. |
Comments suppressed due to low confidence (2)
libs/coin-modules/coin-tron/src/logic/getBlock.ts:70
BlockTransactionAPI.retis optional, butisSuccesscurrently treats a missingretas failure (undefined === "SUCCESS"), which will mark transactions as failed and drop their operations. This is inconsistent with existing Tron parsing innetwork/format.ts(it defaults missingret[0].contractRetto "SUCCESS"). Consider computingfailedonly whencontractRetis present and not "SUCCESS" (and still mapping operations whenretis absent).
libs/coin-modules/coin-tron/src/logic/getBlock.ts:164mapTriggerSmartContractintroduces TRC20 transfer decoding (methodId parsing, address extraction, BigInt amount parsing), but the new test suite doesn’t cover the successful TRC20 transfer case (and ideally a non-a9059cbb/short-data case). Add unit tests to ensure TRC20 transfers are mapped into twotransferoperations with the expected assetReference and amounts.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



✅ Checklist
npx changesetwas attached.📝 Description
Replace this text by a clear and concise description of what this pull request is about and why it is needed. Be sure to explain the problem you're addressing and the solution you're proposing.
For libraries, you can add a code sample of how to use it.
For bug fixes, you can explain the previous behaviour and how it was fixed.
In case of visual features, please attach screenshots or video recordings to demonstrate the changes.
❓ Context
🧐 Checklist for the PR Reviewers