solanaFetcher()
solanaFetcher(
params):Promise<void>
Defined in: trackers/solanaTracker.ts:164
A fetcher for initializePollingTracker from @tuwaio/pulsar-core that checks a Solana transaction once.
It sends getSignatureStatuses (with searchTransactionHistory on the first check of a run and past a blockhash’s lifetime, so
transactions older than the node’s recent status cache are found after a page reload) to tx.rpcUrl, or to the public endpoint of the cluster in tx.chainId,
through a client cached by createSolanaRPC from @tuwaio/orbit-solana. Until it has the fee, blockhash and
instructions (from tx, or fetched on an earlier tick of the same tracking run and cached in memory for the tx
object), it also sends getTransaction (commitment confirmed, maxSupportedTransactionVersion: 1, so legacy,
version 0 and version 1 transactions are read). A getTransaction error is not thrown: the check goes on with the
status alone and the details are asked again on the next tick.
- Signature not found, with
tx.lastValidBlockHeight(or the onesignAndSendSolanaTxrecorded for the signature in this page): sendsgetBlockHeight(commitmentconfirmed); once the height is more than 32 blocks above it, checks the signature once more and, still not found, callsonFailureand stops polling, withexpired: truewhen this run saw the blockhash still valid (it can never land),falsewhen it came back later and the node may just keep no old statuses. - Signature not found otherwise: keeps polling; one hour after
localTimestampcallsonFailure()and stops polling. - Found: calls
onIntervalTickwith the status (confirmationStatusprocessed,confirmedorfinalized, plus the details oncegetTransactionreturns them), then: an on-chain error pastprocessedcallsonFailurewith it right away;finalizedwith the details callsonSuccess.finalizedwithout the details keeps polling for them and, on the 10th such check of thetxobject (counted in memory), logs a warning and callsonSuccesswithout them. A transaction not finalized one hour afterlocalTimestampcallsonFailurewith its status; a finalized one never does.
Every terminal outcome stops polling with withoutRemoving: true, so the transaction is never removed.
- Errors of
getSignatureStatusesandgetBlockHeightare thrown, so the polling tracker retries and gives up aftermaxRetriesconsecutive errors.
Parameters
params
PollingFetcherParams<SolanaSignatureStatusResponse, SolanaFetcherTx>
The fetcher parameters provided by initializePollingTracker.
Returns
Promise<void>
A promise that resolves when the check is done.
Throws
Error when tx.adapter is not OrbitAdapter.SOLANA, and any error of getSignatureStatuses or
getBlockHeight.
Example
import { OrbitAdapter, SOLANA_CHAIN_IDS } from '@tuwaio/orbit-core';
import { initializePollingTracker } from '@tuwaio/pulsar-core';
import { solanaFetcher } from '@tuwaio/pulsar-solana';
initializePollingTracker({
tx: { adapter: OrbitAdapter.SOLANA, txKey: signature, chainId: SOLANA_CHAIN_IDS.devnet, localTimestamp: now, pending: true },
fetcher: solanaFetcher,
onSuccess: (status) => console.log('Finalized in slot', status.slot),
onFailure: (status) => console.error('Failed', status?.err),
});