Skip to content

fix(tron): use fullnode for testnet balances - #5703

Open
royalpinto007 wants to merge 1 commit into
reown-com:mainfrom
royalpinto007:fix/tron-testnet-balance-fullnode
Open

fix(tron): use fullnode for testnet balances#5703
royalpinto007 wants to merge 1 commit into
reown-com:mainfrom
royalpinto007:fix/tron-testnet-balance-fullnode

Conversation

@royalpinto007

Copy link
Copy Markdown

Description

Fixes TRON testnet balance fetching for the TRON adapter.

TronAdapter.getBalance() previously routed all TRON balance reads through BlockchainApiController.getAddressBalance(). For Shasta/Nile, that goes through the WalletConnect RPC proxy, which currently returns 503 for TRON testnet balance requests. This made AppKit show 0 TRX and log repeated balance errors on Shasta.

This PR keeps the existing Blockchain API path for TRON mainnet, but uses the configured TRON fullnode chainDefault endpoint for testnet balances via /wallet/getaccount.

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

closes #5699

Showcase (Optional)

No UI change. The behavior is covered by unit tests:

  • Shasta/testnet balances call https://api.shasta.trongrid.io/wallet/getaccount
  • Mainnet balances continue using BlockchainApiController.getAddressBalance()

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Preview link is not applicable because this change is in adapter balance-fetching logic, not a UI surface.

Testing

  • pnpm --filter @reown/appkit-adapter-tron... build
  • pnpm --filter @reown/appkit-adapter-tron test
  • pnpm --filter @reown/appkit-adapter-tron lint

Note: lint exits successfully. It still reports the existing warning in TronWalletConnectConnector.ts for usesV1Format, which this PR does not touch.

Copilot AI review requested due to automatic review settings July 6, 2026 14:00
@cursor

cursor Bot commented Jul 6, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 94df5be

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@reown/appkit-utils Patch
@reown/appkit Patch
@reown/appkit-cdn Patch
@reown/appkit-cli Patch
@reown/appkit-codemod Patch
@reown/appkit-common Patch
@reown/appkit-core Patch
@reown/appkit-experimental Patch
@reown/appkit-pay Patch
@reown/appkit-polyfills Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-testing Patch
@reown/appkit-ui Patch
@reown/appkit-universal-connector Patch
@reown/appkit-wallet-button Patch
@reown/appkit-wallet Patch
@reown/appkit-controllers Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-ton Patch
@reown/appkit-adapter-tron Patch
@reown/appkit-adapter-wagmi Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

@royalpinto007 is attempting to deploy a commit to the Reown Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CTA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@royalpinto007

Copy link
Copy Markdown
Author

I have read the CTA Document and I hereby sign the CTA

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes TRON testnet (Shasta/Nile) balance fetching in the TRON adapter by bypassing the WalletConnect RPC proxy (which returns 503 for TRON testnet balance reads) and querying the configured TRON fullnode REST endpoint instead.

Changes:

  • Updated TronAdapter.getBalance() to use /wallet/getaccount on the configured rpcUrls.chainDefault fullnode for testnet networks, while keeping the Blockchain API path for mainnet.
  • Extracted TRX balance formatting into a helper method for reuse across both paths.
  • Added unit tests covering testnet vs mainnet routing behavior and included a changeset.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/adapters/tron/src/adapter.ts Route testnet balances through TRON fullnode /wallet/getaccount; keep mainnet via BlockchainApiController; refactor formatting.
packages/adapters/tron/src/tests/client.test.ts Adds unit coverage ensuring testnet uses fullnode and mainnet uses Blockchain API.
.changeset/tron-testnet-fullnode-balance.md Publishes a patch release note for the TRON testnet balance fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +350 to +358
if (!rpcUrl) {
return 0
}

const response = await fetch(`${rpcUrl}/wallet/getaccount`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ address, visible: true })
})
Comment on lines +42 to +45
beforeEach(() => {
vi.clearAllMocks()
adapter = new TronAdapter()
})
@royalpinto007
royalpinto007 force-pushed the fix/tron-testnet-balance-fullnode branch from 530f660 to 94df5be Compare July 6, 2026 14:07
@cursor

cursor Bot commented Jul 6, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@royalpinto007

royalpinto007 commented Jul 6, 2026

Copy link
Copy Markdown
Author

Addressed the Copilot review suggestions:

  • getFullNodeBalance() now fails fast when the configured TRON fullnode RPC URL is missing, so the outer getBalance() catch logs the issue instead of silently masking config problems.
  • Normalized the fullnode URL before appending /wallet/getaccount, so trailing slashes do not produce double-slash request URLs.
  • Added mock restoration in the new TRON adapter test file to avoid leaking spies across tests.

Re-ran:

  • pnpm --filter @reown/appkit-adapter-tron... build
  • pnpm --filter @reown/appkit-adapter-tron test
  • pnpm --filter @reown/appkit-adapter-tron lint

Note: lint exits successfully. It still reports the existing warning in TronWalletConnectConnector.ts for usesV1Format, which this PR does not touch.

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.

bug: TronAdapter.getBalance returns 503 on TRON Shasta — rpc.walletconnect.org doesn't support TRON testnets

2 participants