fix(sdk-coin-trx): guard against missing trc20 field in account response#9277
Draft
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
Draft
fix(sdk-coin-trx): guard against missing trc20 field in account response#9277bitgo-ai-agent-dev[bot] wants to merge 1 commit into
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
Conversation
The TRON node API omits the `trc20` field entirely from account info
responses for accounts that have never interacted with TRC20 tokens.
Three recovery paths iterated over `account.data[0].trc20` without
first checking whether the field exists, causing a TypeError crash
("Cannot read properties of undefined (reading Symbol.iterator)")
whenever consolidation or recovery was attempted and any scanned
receive address had TRX balance but no prior TRC20 history.
Fix: use the `?? []` nullish coalescing fallback when iterating in
`recover()`, `recoverTss()`, and `recoverConsolidations()`. Also
mark the `trc20` field optional in `AccountInfo` to reflect the real
API contract.
Add unit tests for all three code paths that confirm graceful handling
when the `trc20` field is absent (the base-address recovery and TSS
recovery throw a clear "token not found" error, and consolidation
skips the address instead of crashing).
Ticket: SPT-101
Session-Id: e2414be7-1b86-4412-b43c-7267b56dac1d
Task-Id: 1123cac4-3d06-4115-8039-d9aea9e761aa
Contributor
bitgo-ai-agent-dev
Bot
force-pushed
the
spt-101/fix-trx-token-consolidation-missing-trc20
branch
from
July 16, 2026 14:41
269a7b5 to
eb57a0f
Compare
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.
What
trc20as optional in theAccountInfointerface to reflect the real TRON node API contractrecover(),recoverTss(),recoverConsolidations()) against a missingtrc20field using?? []nullish coalescingtrc20is absent from the account responseWhy
trc20field entirely from account info responses for wallets that have never interacted with TRC20 tokens (e.g. pure TRX receive addresses used as intermediary accounts)Test plan
should throw if trc20 field absent and token recovery requested (base address)— confirms base-address recovery throws a clear "token not found" error rather than a TypeErrorshould skip token consolidation when trc20 field absent from account response— confirms consolidation silently skips addresses without TRC20 datashould throw if trc20 field absent for TSS wallet token recovery— confirms TSS wallet recovery throws a clear "token not found" errormaster)Ticket: SPT-101