-
Notifications
You must be signed in to change notification settings - Fork 201
fix: tron trc20 balances for non-activated accounts + send warning #12191
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
+152
−2
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f0c4085
fix: tron trc20 balances for non-activated accounts + send warning
gomesalexandre d849fc0
chore: add qabot fixture for tron non-activated balances
gomesalexandre e16846f
fix: address coderabbit review comments
gomesalexandre 7b97bf9
fix: cap fallback contract probes + log fallback errors
gomesalexandre e118aae
Merge branch 'develop' into fix/tron-non-activated-balances
gomesalexandre 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: Tron Non-Activated Account Balances | ||
| description: > | ||
| Verifies fix for #12190 - USDT/TRC20 tokens show in portfolio for non-activated Tron accounts, | ||
| and send flow shows a warning when sending TRC20 to a non-activated recipient address. | ||
| route: / | ||
| depends_on: | ||
| - wallet-health.yaml | ||
| steps: | ||
| - name: Navigate to Tron USDT asset page | ||
| instruction: Navigate to the Tron USDT asset page at /assets/tron:0x2b6653dc/trc20:TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t | ||
| expected: The USDT (Tron) asset page is visible | ||
| screenshot: true | ||
|
|
||
| - name: Verify USDT balance visible for Tron account | ||
| instruction: Check the account balances shown for USDT on Tron. Look for any TRX/Tron wallet accounts listed. | ||
| expected: At least one account shows a USDT balance (even if zero TRX balance) | ||
| screenshot: true | ||
|
|
||
| - name: Open send modal for Tron USDT | ||
| instruction: Click the Send button on the USDT Tron asset page to open the send flow | ||
| expected: The send modal opens showing the address input screen | ||
| screenshot: true | ||
|
|
||
| - name: Enter non-activated Tron recipient address | ||
| instruction: > | ||
| In the address input field, type the known non-activated Tron address: TNJ1pzzz8Tzip6Nid6DxMVso3zM4bLFDxu | ||
| Wait for address validation to complete. | ||
| expected: The address is accepted and validated (no red error), navigation to amount screen happens | ||
| screenshot: true | ||
|
|
||
| - name: Verify non-activated recipient warning shows | ||
| instruction: > | ||
| On the send amount screen, look for a yellow/orange warning alert about the recipient address | ||
| not being activated on Tron. The warning should mention that tokens will arrive but the | ||
| recipient needs TRX to move them. | ||
| expected: > | ||
| A warning alert is visible saying the recipient address hasn't been activated and they'll | ||
| need TRX to use the tokens. | ||
| screenshot: true | ||
|
|
||
| - name: Verify send is not blocked | ||
| instruction: Enter a valid non-zero USDT amount, for example 1. | ||
| expected: The Preview button is enabled - the warning is informational only and does not block the send flow. | ||
| screenshot: true | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide 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
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
44 changes: 44 additions & 0 deletions
44
src/hooks/useIsTronAddressActivated/useIsTronAddressActivated.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type { ChainId } from '@shapeshiftoss/caip' | ||
| import { tronChainId } from '@shapeshiftoss/caip' | ||
| import { useQuery } from '@tanstack/react-query' | ||
|
|
||
| import { assertGetTronChainAdapter } from '@/lib/utils/tron' | ||
|
|
||
| const checkTronAddressActivated = async ( | ||
| to: string | undefined, | ||
| chainId: ChainId | undefined, | ||
| ): Promise<boolean | undefined> => { | ||
| if (!to || !chainId || chainId !== tronChainId) return undefined | ||
| if (!to.startsWith('T')) return undefined | ||
|
|
||
| try { | ||
| const adapter = assertGetTronChainAdapter(chainId) | ||
| const rpcUrl = adapter.httpProvider.getRpcUrl() | ||
|
|
||
| const response = await fetch(`${rpcUrl}/wallet/getaccount`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify({ address: to, visible: true }), | ||
| }) | ||
|
|
||
| if (!response.ok) return undefined | ||
|
|
||
| const data = await response.json() | ||
|
|
||
| // Activated accounts have an 'address' field; non-activated accounts return {} | ||
| return !!data?.address | ||
| } catch (error) { | ||
| console.error('Failed to check Tron address activation status:', error) | ||
| return undefined | ||
| } | ||
| } | ||
|
|
||
| export const useIsTronAddressActivated = (to: string | undefined, chainId: ChainId | undefined) => { | ||
| return useQuery({ | ||
| queryKey: ['isTronAddressActivated', to, chainId], | ||
| queryFn: () => checkTronAddressActivated(to, chainId), | ||
| enabled: Boolean(to) && to?.startsWith('T') && chainId === tronChainId, | ||
| staleTime: 30_000, | ||
| refetchInterval: false, | ||
| }) | ||
| } |
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.