fix: tron trc20 balances for non-activated accounts + send warning#12191
fix: tron trc20 balances for non-activated accounts + send warning#12191gomesalexandre merged 5 commits intodevelopfrom
Conversation
- TronApi: fallback for non-activated accounts - uses hardcoded top tokens (USDT, USDC) + received TRC20 tx history discovery, then balanceOf() via triggerconstantcontract to fetch balances that TronGrid /v1/accounts skips - portfolioSlice utils: checkAccountHasActivity now checks token balances so non-activated accounts with TRC20 tokens aren't skipped - useIsTronAddressActivated: new hook to check if a Tron recipient address has been activated on-chain (checks for address property in response) - SendAmountDetails: warning shown when sending TRC20 to non-activated recipient (suppressed for native TRX sends which activate the account) Closes #12190 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds TRC20 discovery fallback for Tron, updates portfolio activity detection for Tron tokens, introduces a hook that queries Tron RPC to check address activation, surfaces a send-modal warning for non-activated Tron recipients, and adds an e2e fixture validating the warning for USDT/TRC20 recipients. Changes
Sequence DiagramsequenceDiagram
participant User
participant SendUI as SendAmountDetails
participant Hook as useIsTronAddressActivated
participant Query as ReactQuery
participant TronRPC as Tron RPC
User->>SendUI: open send modal, select USDT, enter recipient (T...)
SendUI->>Hook: call useIsTronAddressActivated(to, chainId)
Hook->>Query: register/query ['isTronAddressActivated', to, chainId]
Query->>TronRPC: POST /wallet/getaccount {address}
TronRPC-->>Query: return account data (address present or empty)
Query-->>Hook: activation status (true/false/undefined)
Hook-->>SendUI: isTronRecipientActivated = false
SendUI->>User: render yellow/orange warning "recipient hasn't activated Tron"
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@e2e/fixtures/tron-non-activated-balances.yaml`:
- Around line 31-39: The fixture "Verify non-activated recipient warning shows"
currently asserts that the Continue/Preview button is enabled without entering
an amount; update the instruction block for that test to include an explicit
amount-entry step (e.g., type a valid numeric value into the amount field on the
send amount screen) before the expected assertion so the Continue/Preview
enabled check is deterministic.
- Around line 9-11: The fixture's instruction incorrectly navigates to
"/assets/eip155:195/slip44:195" (which is TRX) instead of the Tron USDT asset;
update the instruction under "Navigate to Tron USDT asset page" to point to the
correct Tron USDT asset route (replace "/assets/eip155:195/slip44:195" with the
proper Tron USDT asset path) or explicitly instruct the test to search for "USDT
on Tron" in the asset list so the test lands on the USDT (Tron) page rather than
the native TRX page.
In `@packages/unchained-client/src/tron/api.ts`:
- Around line 112-119: The current fallback fans out unbounded RPC calls by
using Promise.all over discoveredContracts which can flood providers; change the
logic that builds balanceResults to throttle concurrent getTRC20Balance calls
(e.g., process discoveredContracts in small batches or use a concurrency
limiter) so only N calls run concurrently, retry transient failures if desired,
and collect { contractAddress, balance } results the same way; update the code
that references balanceResults and the Promise.all usage to use the new
batched/limited executor for getTRC20Balance.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7dec60bf-646e-4981-91d6-c9f87b880c89
📒 Files selected for processing (6)
e2e/fixtures/tron-non-activated-balances.yamlpackages/unchained-client/src/tron/api.tssrc/assets/translations/en/main.jsonsrc/components/Modals/Send/views/SendAmountDetails.tsxsrc/hooks/useIsTronAddressActivated/useIsTronAddressActivated.tssrc/state/slices/portfolioSlice/utils/index.ts
- throttle balanceOf calls sequentially instead of Promise.all fanout - fix fixture: use correct tron:0x2b6653dc/trc20:... USDT asset route - fix fixture: separate warning assertion from preview-enabled assertion Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
addressed @coderabbitai comments:
|
|
Tip For best results, initiate chat on the files or code changes.
🧠 Learnings used |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/unchained-client/src/tron/api.ts`:
- Around line 117-119: In getTRC20Balance's fallback catch block that currently
swallows _fallbackErr, record the failure before continuing: emit a breadcrumb
or log (e.g., Sentry.addBreadcrumb or processLogger.warn/processLogger.error)
including the error object and context (token address, wallet address, and that
the fallback path failed) so the partial token list return is discoverable;
update the catch surrounding _fallbackErr to call the project's telemetry/logger
with those details and then continue returning the partial results.
- Around line 97-115: getAccount() currently iterates up to 200 inbound TRC20
transfers and then serially runs this.throttle() + getTRC20Balance() for every
entry in discoveredContracts, which can stall the shared requestQueue; limit the
probe set by adding a hard cap (e.g. MAX_FALLBACK_CONTRACT_PROBES) and only
probe the most relevant contracts (most recent or highest-value) before calling
getTRC20Balance(), or alternatively make the probes fire off as non-blocking
background tasks rather than blocking getAccount() (reference
discoveredContracts, throttle(), getTRC20Balance(), tokens, and the shared
requestQueue/TronApi instance when implementing).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 71705778-7def-4cab-bb79-3a3cf1ba3072
📒 Files selected for processing (2)
e2e/fixtures/tron-non-activated-balances.yamlpackages/unchained-client/src/tron/api.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- e2e/fixtures/tron-non-activated-balances.yaml
- add MAX_FALLBACK_CONTRACTS = 20 ceiling to prevent stalling shared requestQueue - log fallback discovery errors instead of silently swallowing them Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 QA Test Report - PR #12191Status: ✅ PASSED Test SummaryTesting TRON TRC20 balance discovery for non-activated accounts and send warning UI. Test Results
Verified Features1. TRC20 Balance Discovery for Non-Activated Accounts ✅
2. Send Warning for Non-Activated Recipients ✅
Screenshots
Test Environment:
Automated QA by OpenClaw |
🤖 QA Test ReportTested by: OpenClaw QA Bot ✅ Test Results
📋 Findings1. TRX Balances Display Correctly
2. Code Changes Review
3. Warning Message
📝 Notes
🎯 RecommendationAPPROVE - Code changes are well-implemented and follow best practices. |
✅ QA Test PassedTest: Tron TRC20 Non-Activated Address Warning Test Steps:
Result:The warning message appears as expected:
QABot Report:https://qabot-kappa.vercel.app/runs/861a0ad0-e9fd-46b3-8d1e-b2067d777ba6 Automated QA by OpenClaw |
NeOMakinG
left a comment
There was a problem hiding this comment.
Tested the TRC20 non-activated address warning functionality. The warning displays correctly when attempting to send TRC20 tokens to an unactivated Tron address.
Description
Two fixes for Tron non-activated accounts:
TRC20 balance discovery for non-activated accounts - The TronGrid
/v1/accounts/{addr}API returns{"data":[]}for addresses that have never sent TRX (non-activated). Added a fallback inTronApi.getAccount()that checks hardcoded top tokens (USDT, USDC) + scans received TRC20 tx history to discover token contracts, then callsbalanceOf()viatriggerconstantcontract. Non-activated accounts with USDT/TRC20 balances now show up in the portfolio.Send flow warning for non-activated recipient - Added
useIsTronAddressActivatedhook that checks if a Tron recipient address is activated. On the send amount screen, if the recipient is non-activated and the asset is not native TRX, a yellow warning alert is shown: "This address hasn't been activated on Tron yet. Your tokens will arrive, but the recipient won't be able to move them until they also receive some TRX." Warn-and-allow - send is not blocked.Issue (if applicable)
closes #12190
Risk
Low - Tron-specific changes, under the TRON feature flag. The balance fallback only triggers for non-activated accounts (empty
data[]response from TronGrid). The send warning is informational only and doesn't block the flow.Tron TRC20 token sends only.
Testing
Engineering
qabot run (6/6 passed): http://localhost:8080/runs/99d0a229-c7e4-49b3-b7d5-a3b93922f5d5
Operations
Tron is behind the
VITE_FEATURE_TRONflag.Summary by CodeRabbit
Bug Fixes
New Features
Tests
Documentation