tx-indexer 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{classification.types-w82k4B1F.d.ts → classification.types-DlJe6bDZ.d.ts} +2 -6
- package/dist/{client-BS9KUBU7.d.ts → client-yGDWPKKf.d.ts} +6 -81
- package/dist/client.d.ts +2 -2
- package/dist/client.js +396 -256
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.js +396 -256
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -181,14 +181,10 @@ declare const TransactionClassificationSchema: z.ZodObject<{
|
|
|
181
181
|
fee_only: "fee_only";
|
|
182
182
|
other: "other";
|
|
183
183
|
}>;
|
|
184
|
-
direction: z.ZodEnum<{
|
|
185
|
-
incoming: "incoming";
|
|
186
|
-
outgoing: "outgoing";
|
|
187
|
-
self: "self";
|
|
188
|
-
neutral: "neutral";
|
|
189
|
-
}>;
|
|
190
184
|
primaryAmount: z.ZodNullable<z.ZodAny>;
|
|
191
185
|
secondaryAmount: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
186
|
+
sender: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
187
|
+
receiver: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
192
188
|
counterparty: z.ZodNullable<z.ZodObject<{
|
|
193
189
|
type: z.ZodEnum<{
|
|
194
190
|
unknown: "unknown";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Rpc, GetBalanceApi, GetTokenAccountsByOwnerApi, GetSignaturesForAddressApi, GetTransactionApi, RpcSubscriptions, Address, Signature } from '@solana/kit';
|
|
2
|
-
import { R as RawTransaction, T as TxLeg, a as TransactionClassification } from './classification.types-
|
|
2
|
+
import { R as RawTransaction, T as TxLeg, a as TransactionClassification } from './classification.types-DlJe6bDZ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Union type of all RPC APIs used by the transaction indexer.
|
|
@@ -72,12 +72,13 @@ declare function fetchTransactionsBatch(rpc: Rpc<GetTransactionApi>, signatures:
|
|
|
72
72
|
* detecting and accounting for network fees. Each leg represents a debit or credit
|
|
73
73
|
* for a specific account and token, enabling transaction classification and validation.
|
|
74
74
|
*
|
|
75
|
+
* All accounts are tagged as "external:" - the classification layer determines
|
|
76
|
+
* the transaction type and direction from the initiator's (fee payer's) perspective.
|
|
77
|
+
*
|
|
75
78
|
* @param tx - Raw transaction data with balance changes
|
|
76
|
-
* @param walletAddress - Optional wallet address for perspective. When provided, legs are tagged
|
|
77
|
-
* as "wallet:" or "external:". When omitted (observer mode), all legs are tagged as "external:".
|
|
78
79
|
* @returns Array of transaction legs representing all balance movements
|
|
79
80
|
*/
|
|
80
|
-
declare function transactionToLegs(tx: RawTransaction
|
|
81
|
+
declare function transactionToLegs(tx: RawTransaction): TxLeg[];
|
|
81
82
|
|
|
82
83
|
interface SpamFilterConfig {
|
|
83
84
|
minSolAmount?: number;
|
|
@@ -151,107 +152,31 @@ interface TokenAccountBalance {
|
|
|
151
152
|
*/
|
|
152
153
|
declare function fetchWalletBalance(rpc: Rpc<GetBalanceApi & GetTokenAccountsByOwnerApi>, walletAddress: Address, tokenMints?: readonly string[]): Promise<WalletBalance>;
|
|
153
154
|
|
|
154
|
-
/**
|
|
155
|
-
* Configuration options for creating a transaction indexer.
|
|
156
|
-
*
|
|
157
|
-
* Use either `rpcUrl` to let the SDK create a client, or provide an existing `client`
|
|
158
|
-
* to share connections across your application.
|
|
159
|
-
*/
|
|
160
155
|
type TxIndexerOptions = {
|
|
161
|
-
/** Solana RPC URL (SDK creates a new client) */
|
|
162
156
|
rpcUrl: string;
|
|
163
|
-
/** Optional WebSocket URL for subscriptions */
|
|
164
157
|
wsUrl?: string;
|
|
165
158
|
} | {
|
|
166
|
-
/** Existing Solana client to reuse (shares connections) */
|
|
167
159
|
client: SolanaClient;
|
|
168
160
|
};
|
|
169
|
-
/**
|
|
170
|
-
* Options for fetching and filtering transaction history.
|
|
171
|
-
*/
|
|
172
161
|
interface GetTransactionsOptions {
|
|
173
|
-
/** Maximum number of transactions to return (default: 10) */
|
|
174
162
|
limit?: number;
|
|
175
|
-
/** Fetch transactions before this signature (for pagination) */
|
|
176
163
|
before?: Signature;
|
|
177
|
-
/** Fetch transactions until this signature (for pagination) */
|
|
178
164
|
until?: Signature;
|
|
179
|
-
/** Whether to filter out spam transactions (default: true) */
|
|
180
165
|
filterSpam?: boolean;
|
|
181
|
-
/** Custom spam filter configuration */
|
|
182
166
|
spamConfig?: SpamFilterConfig;
|
|
183
167
|
}
|
|
184
|
-
/**
|
|
185
|
-
* A fully classified transaction with raw data, classification metadata, and accounting legs.
|
|
186
|
-
*/
|
|
187
168
|
interface ClassifiedTransaction {
|
|
188
|
-
/** Raw transaction data from the blockchain */
|
|
189
169
|
tx: RawTransaction;
|
|
190
|
-
/** Classification metadata (type, direction, amounts, counterparty) */
|
|
191
170
|
classification: TransactionClassification;
|
|
192
|
-
/** Accounting legs representing all balance movements */
|
|
193
171
|
legs: ReturnType<typeof transactionToLegs>;
|
|
194
172
|
}
|
|
195
|
-
/**
|
|
196
|
-
* Transaction indexer client for querying and classifying Solana transactions.
|
|
197
|
-
*
|
|
198
|
-
* Provides methods to fetch wallet balances, transaction history, and individual transactions
|
|
199
|
-
* with automatic protocol detection and classification.
|
|
200
|
-
*/
|
|
201
173
|
interface TxIndexer {
|
|
202
|
-
/** Direct access to the underlying Solana RPC client */
|
|
203
174
|
rpc: ReturnType<typeof createSolanaClient>["rpc"];
|
|
204
|
-
/**
|
|
205
|
-
* Fetches the SOL and SPL token balances for a wallet.
|
|
206
|
-
*
|
|
207
|
-
* @param walletAddress - Wallet address to query balances for
|
|
208
|
-
* @param tokenMints - Optional array of token mint addresses to filter
|
|
209
|
-
* @returns Wallet balance data including SOL and token balances
|
|
210
|
-
*/
|
|
211
175
|
getBalance(walletAddress: Address, tokenMints?: readonly string[]): Promise<WalletBalance>;
|
|
212
|
-
/**
|
|
213
|
-
* Fetches and classifies transaction history for a wallet.
|
|
214
|
-
*
|
|
215
|
-
* @param walletAddress - Wallet address to fetch transaction history for
|
|
216
|
-
* @param options - Configuration options for fetching and filtering
|
|
217
|
-
* @returns Array of classified transactions with full metadata
|
|
218
|
-
*/
|
|
219
176
|
getTransactions(walletAddress: Address, options?: GetTransactionsOptions): Promise<ClassifiedTransaction[]>;
|
|
220
|
-
|
|
221
|
-
* Fetches and classifies a single transaction by its signature.
|
|
222
|
-
*
|
|
223
|
-
* @param signature - Transaction signature to fetch
|
|
224
|
-
* @param walletAddress - Optional wallet address for classification perspective.
|
|
225
|
-
* When omitted, returns classification from observer mode (neutral perspective).
|
|
226
|
-
* @returns Classified transaction with full metadata, or null if transaction not found
|
|
227
|
-
*/
|
|
228
|
-
getTransaction(signature: Signature, walletAddress?: Address): Promise<ClassifiedTransaction | null>;
|
|
229
|
-
/**
|
|
230
|
-
* Fetches a raw transaction without classification.
|
|
231
|
-
*
|
|
232
|
-
* @param signature - Transaction signature to fetch
|
|
233
|
-
* @returns Raw transaction data from the blockchain, or null if not found
|
|
234
|
-
*/
|
|
177
|
+
getTransaction(signature: Signature): Promise<ClassifiedTransaction | null>;
|
|
235
178
|
getRawTransaction(signature: Signature): Promise<RawTransaction | null>;
|
|
236
179
|
}
|
|
237
|
-
/**
|
|
238
|
-
* Creates a transaction indexer client for querying and classifying Solana transactions.
|
|
239
|
-
*
|
|
240
|
-
* Accepts either an RPC URL (SDK creates client) or an existing SolanaClient (for sharing
|
|
241
|
-
* connections across your app or with React providers).
|
|
242
|
-
*
|
|
243
|
-
* @param options - Configuration with RPC URL or existing client
|
|
244
|
-
* @returns Transaction indexer client
|
|
245
|
-
*
|
|
246
|
-
* @example
|
|
247
|
-
* // Option 1: SDK creates client
|
|
248
|
-
* const indexer = createIndexer({ rpcUrl: "https://api.mainnet-beta.solana.com" });
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* // Option 2: Provide existing client (share connections)
|
|
252
|
-
* const myClient = createSolanaClient("https://...");
|
|
253
|
-
* const indexer = createIndexer({ client: myClient });
|
|
254
|
-
*/
|
|
255
180
|
declare function createIndexer(options: TxIndexerOptions): TxIndexer;
|
|
256
181
|
|
|
257
182
|
export { type ClassifiedTransaction as C, type FetchTransactionsConfig as F, type GetTransactionsOptions as G, type IndexerRpcApi as I, type SolanaClient as S, type TxIndexer as T, type WalletBalance as W, type TxIndexerOptions as a, createSolanaClient as b, createIndexer as c, parseSignature as d, type TokenAccountBalance as e, fetchWalletBalance as f, fetchWalletSignatures as g, fetchTransaction as h, fetchTransactionsBatch as i, isSpamTransaction as j, filterSpamTransactions as k, type SpamFilterConfig as l, parseAddress as p, transactionToLegs as t };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '@solana/kit';
|
|
2
|
-
export { C as ClassifiedTransaction, F as FetchTransactionsConfig, G as GetTransactionsOptions, T as TxIndexer, a as TxIndexerOptions, c as createIndexer } from './client-
|
|
3
|
-
import './classification.types-
|
|
2
|
+
export { C as ClassifiedTransaction, F as FetchTransactionsConfig, G as GetTransactionsOptions, T as TxIndexer, a as TxIndexerOptions, c as createIndexer } from './client-yGDWPKKf.js';
|
|
3
|
+
import './classification.types-DlJe6bDZ.js';
|
|
4
4
|
import 'zod';
|