[BCN] Handle missing Solana token ATA in txhistory#4173
Open
msalcala11 wants to merge 1 commit into
Open
Conversation
80ab6fd to
03b5dc1
Compare
7d469b0 to
18e0943
Compare
18e0943 to
d634fea
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Solana SPL token txhistory streaming when the associated token account (ATA) is currently missing/uninitialized (e.g., closed after balance returned to zero), by falling back to the deterministically derived ATA so prior token-account activity can still be discovered.
Changes:
- Add missing-ATA detection and fallback from
getConfirmedAtatoderiveAtawhen streaming address/wallet transactions for SPL tokens. - Introduce a helper for identifying “missing ATA” errors.
- Add an integration regression test covering the missing-current-ATA streaming path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/bitcore-node/src/providers/chain-state/svm/api/csp.ts | Adds missing-ATA error detection and falls back to derived ATA for token txhistory streaming. |
| packages/bitcore-node/test/integration/solana/csp.test.ts | Adds a regression test for token txhistory streaming when the current ATA is not initialized. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+39
to
+42
| function isMissingAtaError(err: any): boolean { | ||
| const message = err?.message || ''; | ||
| return message === 'Missing ATA' || message.includes('ATA not initialized'); | ||
| } |
Comment on lines
+225
to
+226
| const tokenAddress = '11111111111111111111111111111112'; | ||
| const derivedAtaAddress = 'derivedTokenAccountAddress'; |
Comment on lines
+224
to
+230
| it('should stream empty SPL token history from derived ATA when current ATA is not initialized', async () => { | ||
| const tokenAddress = '11111111111111111111111111111112'; | ||
| const derivedAtaAddress = 'derivedTokenAccountAddress'; | ||
| const chunks: string[] = []; | ||
| const connection = { | ||
| getSignaturesForAddress: sandbox.stub().returns({ send: sandbox.stub().resolves([]) }) | ||
| }; |
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.
Description
Fixes a BitPay app txhistory failure observed with zero-balance Solana token wallets.
Zero-balance Solana token wallets can still have transaction history. A user may have received or sent a token before, then sent the balance back to zero or closed the associated token account. In that state, the wallet should still be able to show historical activity.
Observed failure mode: When the app fetched txhistory for one of these token wallets, BWS returned a plain-text
Error getting ATA addressresponse instead of an empty or historical transaction list.Root cause: BWS forwards
/v1/txhistory/requests withtokenAddressto bitcore-node wallet transaction streaming. In the Solana token path, bitcore-node resolves the wallet address's associated token account before listing signatures. If there is no currently initialized ATA,getConfirmedAtathrows and the stream fails.The fix: This change keeps
getConfirmedAtaas the first lookup, so invalid mints and other non-missing-ATA failures keep their existing behavior. For the missing or uninitialized ATA case, it derives the deterministic ATA address and uses it to find any prior token-account activity. If prior activity exists, txhistory returns the corresponding transaction history even if the ATA was later closed.Changelog
SOL + tokenAddress + missing current ATA.Testing Notes
From
packages/bitcore-node, run: