sol-parser-sdk-nodejs 0.3.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.
Files changed (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +449 -0
  3. package/README_CN.md +343 -0
  4. package/dist/accounts/mod.d.ts +11 -0
  5. package/dist/accounts/mod.js +53 -0
  6. package/dist/accounts/nonce.d.ts +5 -0
  7. package/dist/accounts/nonce.js +32 -0
  8. package/dist/accounts/pumpswap.d.ts +8 -0
  9. package/dist/accounts/pumpswap.js +192 -0
  10. package/dist/accounts/token.d.ts +5 -0
  11. package/dist/accounts/token.js +98 -0
  12. package/dist/accounts/types.d.ts +9 -0
  13. package/dist/accounts/types.js +2 -0
  14. package/dist/accounts/utils.d.ts +1 -0
  15. package/dist/accounts/utils.js +12 -0
  16. package/dist/core/account_dispatcher_rpc.d.ts +11 -0
  17. package/dist/core/account_dispatcher_rpc.js +155 -0
  18. package/dist/core/account_fill_bonk.d.ts +4 -0
  19. package/dist/core/account_fill_bonk.js +20 -0
  20. package/dist/core/account_fill_meteora.d.ts +14 -0
  21. package/dist/core/account_fill_meteora.js +26 -0
  22. package/dist/core/account_fill_orca.d.ts +5 -0
  23. package/dist/core/account_fill_orca.js +18 -0
  24. package/dist/core/account_fill_pumpfun.d.ts +7 -0
  25. package/dist/core/account_fill_pumpfun.js +75 -0
  26. package/dist/core/account_fill_pumpswap.d.ts +10 -0
  27. package/dist/core/account_fill_pumpswap.js +78 -0
  28. package/dist/core/account_fill_raydium.d.ts +20 -0
  29. package/dist/core/account_fill_raydium.js +104 -0
  30. package/dist/core/clock.d.ts +2 -0
  31. package/dist/core/clock.js +7 -0
  32. package/dist/core/common_filler_rpc.d.ts +6 -0
  33. package/dist/core/common_filler_rpc.js +21 -0
  34. package/dist/core/dex_event.d.ts +1009 -0
  35. package/dist/core/dex_event.js +14 -0
  36. package/dist/core/error.d.ts +43 -0
  37. package/dist/core/error.js +16 -0
  38. package/dist/core/json_utils.d.ts +8 -0
  39. package/dist/core/json_utils.js +18 -0
  40. package/dist/core/metadata.d.ts +10 -0
  41. package/dist/core/metadata.js +13 -0
  42. package/dist/core/rpc_invoke_map.d.ts +23 -0
  43. package/dist/core/rpc_invoke_map.js +157 -0
  44. package/dist/core/unified_parser.d.ts +19 -0
  45. package/dist/core/unified_parser.js +48 -0
  46. package/dist/grpc/client.d.ts +52 -0
  47. package/dist/grpc/client.js +309 -0
  48. package/dist/grpc/client_stub.d.ts +5 -0
  49. package/dist/grpc/client_stub.js +5 -0
  50. package/dist/grpc/types.d.ts +132 -0
  51. package/dist/grpc/types.js +304 -0
  52. package/dist/grpc/yellowstone_parse.d.ts +9 -0
  53. package/dist/grpc/yellowstone_parse.js +46 -0
  54. package/dist/index.d.ts +18 -0
  55. package/dist/index.js +99 -0
  56. package/dist/instr/bonk_ix.d.ts +5 -0
  57. package/dist/instr/bonk_ix.js +52 -0
  58. package/dist/instr/meteora_damm_ix.d.ts +6 -0
  59. package/dist/instr/meteora_damm_ix.js +349 -0
  60. package/dist/instr/mod.d.ts +15 -0
  61. package/dist/instr/mod.js +95 -0
  62. package/dist/instr/orca_whirlpool_ix.d.ts +5 -0
  63. package/dist/instr/orca_whirlpool_ix.js +73 -0
  64. package/dist/instr/program_ids.d.ts +14 -0
  65. package/dist/instr/program_ids.js +18 -0
  66. package/dist/instr/pumpfun_ix.d.ts +5 -0
  67. package/dist/instr/pumpfun_ix.js +167 -0
  68. package/dist/instr/pumpswap_ix.d.ts +5 -0
  69. package/dist/instr/pumpswap_ix.js +215 -0
  70. package/dist/instr/raydium_amm_v4_ix.d.ts +6 -0
  71. package/dist/instr/raydium_amm_v4_ix.js +46 -0
  72. package/dist/instr/raydium_clmm_ix.d.ts +5 -0
  73. package/dist/instr/raydium_clmm_ix.js +85 -0
  74. package/dist/instr/raydium_cpmm_ix.d.ts +5 -0
  75. package/dist/instr/raydium_cpmm_ix.js +63 -0
  76. package/dist/instr/utils.d.ts +10 -0
  77. package/dist/instr/utils.js +33 -0
  78. package/dist/logs/meteora_amm.d.ts +8 -0
  79. package/dist/logs/meteora_amm.js +113 -0
  80. package/dist/logs/meteora_damm.d.ts +6 -0
  81. package/dist/logs/meteora_damm.js +509 -0
  82. package/dist/logs/meteora_dlmm.d.ts +6 -0
  83. package/dist/logs/meteora_dlmm.js +201 -0
  84. package/dist/logs/optimized_matcher.d.ts +5 -0
  85. package/dist/logs/optimized_matcher.js +194 -0
  86. package/dist/logs/orca.d.ts +6 -0
  87. package/dist/logs/orca.js +148 -0
  88. package/dist/logs/program_data.d.ts +2 -0
  89. package/dist/logs/program_data.js +22 -0
  90. package/dist/logs/program_log_discriminators.d.ts +59 -0
  91. package/dist/logs/program_log_discriminators.js +67 -0
  92. package/dist/logs/pump.d.ts +12 -0
  93. package/dist/logs/pump.js +251 -0
  94. package/dist/logs/pump_amm.d.ts +9 -0
  95. package/dist/logs/pump_amm.js +418 -0
  96. package/dist/logs/raydium_amm.d.ts +9 -0
  97. package/dist/logs/raydium_amm.js +224 -0
  98. package/dist/logs/raydium_clmm.d.ts +8 -0
  99. package/dist/logs/raydium_clmm.js +141 -0
  100. package/dist/logs/raydium_cpmm.d.ts +7 -0
  101. package/dist/logs/raydium_cpmm.js +121 -0
  102. package/dist/logs/raydium_launchpad.d.ts +12 -0
  103. package/dist/logs/raydium_launchpad.js +92 -0
  104. package/dist/parser_alias.d.ts +3 -0
  105. package/dist/parser_alias.js +2 -0
  106. package/dist/rpc_parser.d.ts +16 -0
  107. package/dist/rpc_parser.js +36 -0
  108. package/dist/rpc_transaction.d.ts +25 -0
  109. package/dist/rpc_transaction.js +111 -0
  110. package/dist/util/binary.d.ts +14 -0
  111. package/dist/util/binary.js +82 -0
  112. package/dist/warmup.d.ts +3 -0
  113. package/dist/warmup.js +23 -0
  114. package/package.json +44 -0
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.metadataForDexEvent = metadataForDexEvent;
4
+ exports.defaultPubkey = defaultPubkey;
5
+ const ZERO = "11111111111111111111111111111111";
6
+ function metadataForDexEvent(ev) {
7
+ if ("Error" in ev)
8
+ return null;
9
+ const inner = Object.values(ev)[0];
10
+ return inner?.metadata ?? null;
11
+ }
12
+ function defaultPubkey() {
13
+ return ZERO;
14
+ }
@@ -0,0 +1,43 @@
1
+ /** 解析错误(RPC / 日志等路径共用) */
2
+ export type ParseError = {
3
+ kind: "InsufficientData";
4
+ expected: number;
5
+ actual: number;
6
+ context: string;
7
+ } | {
8
+ kind: "InvalidDiscriminator";
9
+ expected?: Uint8Array;
10
+ found: Uint8Array;
11
+ context: string;
12
+ } | {
13
+ kind: "Base64DecodeError";
14
+ context: string;
15
+ } | {
16
+ kind: "InsufficientAccounts";
17
+ expected: number;
18
+ actual: number;
19
+ context: string;
20
+ } | {
21
+ kind: "InvalidLogFormat";
22
+ reason: string;
23
+ } | {
24
+ kind: "InvalidInstructionFormat";
25
+ reason: string;
26
+ } | {
27
+ kind: "UnknownEventType";
28
+ discriminator: Uint8Array;
29
+ program: string;
30
+ } | {
31
+ kind: "UnsupportedProgram";
32
+ program_id: string;
33
+ } | {
34
+ kind: "RpcError";
35
+ message: string;
36
+ } | {
37
+ kind: "ConversionError";
38
+ message: string;
39
+ } | {
40
+ kind: "MissingField";
41
+ field: string;
42
+ };
43
+ export declare function formatParseError(e: ParseError): string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatParseError = formatParseError;
4
+ function formatParseError(e) {
5
+ switch (e.kind) {
6
+ case "RpcError":
7
+ case "ConversionError":
8
+ return e.message;
9
+ case "MissingField":
10
+ return `缺少字段: ${e.field}`;
11
+ case "InsufficientData":
12
+ return `数据长度不足: 需要 ${e.expected} 字节,实际 ${e.actual} (${e.context})`;
13
+ default:
14
+ return JSON.stringify(e);
15
+ }
16
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `JSON.stringify` 默认无法处理 `bigint`。
3
+ * 下列工具将树中所有 `bigint` 转为十进制字符串,便于与 Go `DexEvent` / Python 字典经 JSON 输出对齐。
4
+ */
5
+ /** 供 `JSON.stringify(value, replacer)` 使用 */
6
+ export declare function bigintToJsonReplacer(_key: string, value: unknown): unknown;
7
+ /** 将含 `bigint` 的值序列化为 JSON 字符串(`DexEvent`、元数据等) */
8
+ export declare function dexEventToJsonString(value: unknown, space?: string | number): string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * `JSON.stringify` 默认无法处理 `bigint`。
4
+ * 下列工具将树中所有 `bigint` 转为十进制字符串,便于与 Go `DexEvent` / Python 字典经 JSON 输出对齐。
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.bigintToJsonReplacer = bigintToJsonReplacer;
8
+ exports.dexEventToJsonString = dexEventToJsonString;
9
+ /** 供 `JSON.stringify(value, replacer)` 使用 */
10
+ function bigintToJsonReplacer(_key, value) {
11
+ if (typeof value === "bigint")
12
+ return value.toString();
13
+ return value;
14
+ }
15
+ /** 将含 `bigint` 的值序列化为 JSON 字符串(`DexEvent`、元数据等) */
16
+ function dexEventToJsonString(value, space) {
17
+ return JSON.stringify(value, bigintToJsonReplacer, space);
18
+ }
@@ -0,0 +1,10 @@
1
+ /** 事件元数据(signature 为 Base58 字符串) */
2
+ export interface EventMetadata {
3
+ signature: string;
4
+ slot: number;
5
+ tx_index: number;
6
+ block_time_us: number;
7
+ grpc_recv_us: number;
8
+ recent_blockhash?: string;
9
+ }
10
+ export declare function makeMetadata(signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number, recentBlockhash?: string): EventMetadata;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeMetadata = makeMetadata;
4
+ function makeMetadata(signature, slot, txIndex, blockTimeUs, grpcRecvUs, recentBlockhash) {
5
+ return {
6
+ signature,
7
+ slot,
8
+ tx_index: txIndex,
9
+ block_time_us: blockTimeUs ?? 0,
10
+ grpc_recv_us: grpcRecvUs,
11
+ recent_blockhash: recentBlockhash,
12
+ };
13
+ }
@@ -0,0 +1,23 @@
1
+ import { Message, MessageV0, PublicKey, type ConfirmedTransactionMeta } from "@solana/web3.js";
2
+ export type InvokePair = readonly [outerIndex: number, innerIndex: number];
3
+ /**
4
+ * 将账户表项转为 Base58(与 `PublicKey.toBase58()` 一致)。
5
+ * 兼容:已是地址字符串、标准 `PublicKey`、以及多份 `@solana/web3.js` 副本导致 `instanceof` 失效的情况。
6
+ */
7
+ export declare function accountKeyToBase58(account: unknown): string | undefined;
8
+ export declare function isCompiledVersionedMessage(msg: unknown): msg is Message | MessageV0;
9
+ export declare function getAccountKeyResolver(message: Message | MessageV0, meta: ConfirmedTransactionMeta | null): {
10
+ get(i: number): PublicKey | undefined;
11
+ length: number;
12
+ };
13
+ export declare function decodeIxData(data: Uint8Array | string): Uint8Array;
14
+ export declare function buildProgramInvokesMap(message: Message | MessageV0, meta: ConfirmedTransactionMeta | null, resolver: {
15
+ get(i: number): PublicKey | undefined;
16
+ }): Map<string, InvokePair[]>;
17
+ export declare function instructionAccountIndices(message: Message | MessageV0, meta: ConfirmedTransactionMeta | null, invoke: InvokePair): number[] | null;
18
+ export declare function countInstructionAccounts(message: Message | MessageV0, meta: ConfirmedTransactionMeta | null, invoke: InvokePair): number;
19
+ export declare function findMaxAccountsInvoke(programId: string, invokes: Map<string, InvokePair[]>, message: Message | MessageV0, meta: ConfirmedTransactionMeta | null): InvokePair | null;
20
+ export declare function makeInvokeAccountGetter(resolver: {
21
+ get(i: number): PublicKey | undefined;
22
+ }, invoke: InvokePair, message: Message | MessageV0, meta: ConfirmedTransactionMeta | null): ((i: number) => string) | null;
23
+ export declare function getInstructionDataBytes(message: Message | MessageV0, meta: ConfirmedTransactionMeta | null, invoke: InvokePair): Uint8Array | null;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.accountKeyToBase58 = accountKeyToBase58;
7
+ exports.isCompiledVersionedMessage = isCompiledVersionedMessage;
8
+ exports.getAccountKeyResolver = getAccountKeyResolver;
9
+ exports.decodeIxData = decodeIxData;
10
+ exports.buildProgramInvokesMap = buildProgramInvokesMap;
11
+ exports.instructionAccountIndices = instructionAccountIndices;
12
+ exports.countInstructionAccounts = countInstructionAccounts;
13
+ exports.findMaxAccountsInvoke = findMaxAccountsInvoke;
14
+ exports.makeInvokeAccountGetter = makeInvokeAccountGetter;
15
+ exports.getInstructionDataBytes = getInstructionDataBytes;
16
+ /**
17
+ * 从 web3.js 交易构建「程序 → 指令调用 (outer, inner)」映射,供 RPC 路径账户填充。
18
+ * 构造 `program_invokes`(按程序 ID 聚合 invoke,选账户数最多的那次)。
19
+ */
20
+ const bs58_1 = __importDefault(require("bs58"));
21
+ const web3_js_1 = require("@solana/web3.js");
22
+ /**
23
+ * 将账户表项转为 Base58(与 `PublicKey.toBase58()` 一致)。
24
+ * 兼容:已是地址字符串、标准 `PublicKey`、以及多份 `@solana/web3.js` 副本导致 `instanceof` 失效的情况。
25
+ */
26
+ function accountKeyToBase58(account) {
27
+ if (account === undefined || account === null)
28
+ return undefined;
29
+ if (typeof account === "string") {
30
+ try {
31
+ return new web3_js_1.PublicKey(account).toBase58();
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ }
37
+ const maybeFn = account.toBase58;
38
+ if (typeof maybeFn === "function") {
39
+ try {
40
+ return maybeFn.call(account);
41
+ }
42
+ catch {
43
+ /* fall through */
44
+ }
45
+ }
46
+ try {
47
+ return new web3_js_1.PublicKey(account).toBase58();
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ }
53
+ function isCompiledVersionedMessage(msg) {
54
+ if (msg === null || typeof msg !== "object")
55
+ return false;
56
+ return ("compiledInstructions" in msg &&
57
+ Array.isArray(msg.compiledInstructions) &&
58
+ typeof msg.getAccountKeys === "function");
59
+ }
60
+ function getAccountKeyResolver(message, meta) {
61
+ if (message.version === "legacy") {
62
+ const keys = message.getAccountKeys();
63
+ return { get: (i) => keys.get(i), length: keys.length };
64
+ }
65
+ const loaded = meta?.loadedAddresses;
66
+ const keys = message.getAccountKeys(loaded ? { accountKeysFromLookups: loaded } : undefined);
67
+ return { get: (i) => keys.get(i), length: keys.length };
68
+ }
69
+ function decodeIxData(data) {
70
+ if (typeof data === "string")
71
+ return Uint8Array.from(bs58_1.default.decode(data));
72
+ if (data instanceof Uint8Array)
73
+ return data;
74
+ return new Uint8Array(data);
75
+ }
76
+ function buildProgramInvokesMap(message, meta, resolver) {
77
+ const m = new Map();
78
+ const push = (pid, inv) => {
79
+ const arr = m.get(pid);
80
+ if (arr)
81
+ arr.push(inv);
82
+ else
83
+ m.set(pid, [inv]);
84
+ };
85
+ message.compiledInstructions.forEach((ix, idx) => {
86
+ const pidx = Number(ix.programIdIndex);
87
+ const pk = accountKeyToBase58(resolver.get(pidx));
88
+ if (pk)
89
+ push(pk, [idx, -1]);
90
+ });
91
+ for (const group of meta?.innerInstructions ?? []) {
92
+ const outer = group.index;
93
+ group.instructions.forEach((raw, j) => {
94
+ const ix = raw;
95
+ const pidx = Number(ix.programIdIndex);
96
+ const pk = accountKeyToBase58(resolver.get(pidx));
97
+ if (pk)
98
+ push(pk, [outer, j]);
99
+ });
100
+ }
101
+ return m;
102
+ }
103
+ function instructionAccountIndices(message, meta, invoke) {
104
+ const [outerIdx, innerIdx] = invoke;
105
+ if (innerIdx < 0) {
106
+ const ix = message.compiledInstructions[outerIdx];
107
+ return ix ? [...ix.accountKeyIndexes] : null;
108
+ }
109
+ const g = meta?.innerInstructions?.find((x) => x.index === outerIdx);
110
+ const ix = g?.instructions[innerIdx];
111
+ return ix ? [...ix.accounts] : null;
112
+ }
113
+ function countInstructionAccounts(message, meta, invoke) {
114
+ return instructionAccountIndices(message, meta, invoke)?.length ?? 0;
115
+ }
116
+ function findMaxAccountsInvoke(programId, invokes, message, meta) {
117
+ const list = invokes.get(programId);
118
+ if (!list?.length)
119
+ return null;
120
+ let best = list[0];
121
+ let bestN = countInstructionAccounts(message, meta, best);
122
+ for (let i = 1; i < list.length; i++) {
123
+ const inv = list[i];
124
+ const n = countInstructionAccounts(message, meta, inv);
125
+ if (n > bestN) {
126
+ best = inv;
127
+ bestN = n;
128
+ }
129
+ }
130
+ return best;
131
+ }
132
+ const DEFAULT_PK = web3_js_1.PublicKey.default.toBase58();
133
+ function makeInvokeAccountGetter(resolver, invoke, message, meta) {
134
+ const indices = instructionAccountIndices(message, meta, invoke);
135
+ if (!indices)
136
+ return null;
137
+ return (i) => {
138
+ const ai = indices[i];
139
+ if (ai === undefined)
140
+ return DEFAULT_PK;
141
+ return accountKeyToBase58(resolver.get(ai)) ?? DEFAULT_PK;
142
+ };
143
+ }
144
+ function getInstructionDataBytes(message, meta, invoke) {
145
+ const [outerIdx, innerIdx] = invoke;
146
+ if (innerIdx < 0) {
147
+ const ix = message.compiledInstructions[outerIdx];
148
+ if (!ix)
149
+ return null;
150
+ return decodeIxData(ix.data);
151
+ }
152
+ const g = meta?.innerInstructions?.find((x) => x.index === outerIdx);
153
+ const ix = g?.instructions[innerIdx];
154
+ if (!ix)
155
+ return null;
156
+ return decodeIxData(ix.data);
157
+ }
@@ -0,0 +1,19 @@
1
+ import type { DexEvent } from "./dex_event.js";
2
+ import type { EventTypeFilter } from "../grpc/types.js";
3
+ import { nowUs } from "./clock.js";
4
+ export type EventListener = {
5
+ onDexEvent: (event: DexEvent) => void;
6
+ };
7
+ export type StreamingEventListener = {
8
+ onDexEventStreaming: (event: DexEvent) => void;
9
+ };
10
+ /** 从交易解析事件;当前主路径为日志解析 */
11
+ export declare function parseTransactionEvents(_instructionData: Uint8Array, _accounts: string[], logs: string[], signature: string, slot: number, _txIndex: number, blockTimeUs: number | undefined, _programId: string): DexEvent[];
12
+ export declare function parseLogsOnly(logs: string[], signature: string, slot: number, blockTimeUs: number | undefined): DexEvent[];
13
+ export declare function parseTransactionWithListener(instructionData: Uint8Array, accounts: string[], logs: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, programId: string, listener: EventListener): void;
14
+ export declare function parseTransactionEventsStreaming(_instructionData: Uint8Array, _accounts: string[], logs: string[], signature: string, slot: number, _txIndex: number, blockTimeUs: number | undefined, _programId: string, callback: (event: DexEvent) => void): void;
15
+ export declare function parseLogsStreaming(logs: string[], signature: string, slot: number, blockTimeUs: number | undefined, callback: (event: DexEvent) => void): void;
16
+ export declare function parseTransactionWithStreamingListener(instructionData: Uint8Array, accounts: string[], logs: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, programId: string, listener: StreamingEventListener): void;
17
+ /** 带完整 gRPC 元数据字段的日志解析 */
18
+ export declare function parseLog(log: string, signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number, eventTypeFilter: EventTypeFilter | undefined, isCreatedBuy: boolean, recentBlockhash?: Uint8Array): DexEvent | null;
19
+ export { nowUs };
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nowUs = void 0;
4
+ exports.parseTransactionEvents = parseTransactionEvents;
5
+ exports.parseLogsOnly = parseLogsOnly;
6
+ exports.parseTransactionWithListener = parseTransactionWithListener;
7
+ exports.parseTransactionEventsStreaming = parseTransactionEventsStreaming;
8
+ exports.parseLogsStreaming = parseLogsStreaming;
9
+ exports.parseTransactionWithStreamingListener = parseTransactionWithStreamingListener;
10
+ exports.parseLog = parseLog;
11
+ const optimized_matcher_js_1 = require("../logs/optimized_matcher.js");
12
+ const clock_js_1 = require("./clock.js");
13
+ Object.defineProperty(exports, "nowUs", { enumerable: true, get: function () { return clock_js_1.nowUs; } });
14
+ /** 从交易解析事件;当前主路径为日志解析 */
15
+ function parseTransactionEvents(_instructionData, _accounts, logs, signature, slot, _txIndex, blockTimeUs, _programId) {
16
+ return parseLogsOnly(logs, signature, slot, blockTimeUs);
17
+ }
18
+ function parseLogsOnly(logs, signature, slot, blockTimeUs) {
19
+ const out = [];
20
+ for (const log of logs) {
21
+ const e = (0, optimized_matcher_js_1.parseLogUnified)(log, signature, slot, blockTimeUs);
22
+ if (e)
23
+ out.push(e);
24
+ }
25
+ return out;
26
+ }
27
+ function parseTransactionWithListener(instructionData, accounts, logs, signature, slot, txIndex, blockTimeUs, programId, listener) {
28
+ for (const e of parseTransactionEvents(instructionData, accounts, logs, signature, slot, txIndex, blockTimeUs, programId)) {
29
+ listener.onDexEvent(e);
30
+ }
31
+ }
32
+ function parseTransactionEventsStreaming(_instructionData, _accounts, logs, signature, slot, _txIndex, blockTimeUs, _programId, callback) {
33
+ parseLogsStreaming(logs, signature, slot, blockTimeUs, callback);
34
+ }
35
+ function parseLogsStreaming(logs, signature, slot, blockTimeUs, callback) {
36
+ for (const log of logs) {
37
+ const e = (0, optimized_matcher_js_1.parseLogUnified)(log, signature, slot, blockTimeUs);
38
+ if (e)
39
+ callback(e);
40
+ }
41
+ }
42
+ function parseTransactionWithStreamingListener(instructionData, accounts, logs, signature, slot, txIndex, blockTimeUs, programId, listener) {
43
+ parseTransactionEventsStreaming(instructionData, accounts, logs, signature, slot, txIndex, blockTimeUs, programId, (ev) => listener.onDexEventStreaming(ev));
44
+ }
45
+ /** 带完整 gRPC 元数据字段的日志解析 */
46
+ function parseLog(log, signature, slot, txIndex, blockTimeUs, grpcRecvUs, eventTypeFilter, isCreatedBuy, recentBlockhash) {
47
+ return (0, optimized_matcher_js_1.parseLogOptimized)(log, signature, slot, txIndex, blockTimeUs, grpcRecvUs, eventTypeFilter, isCreatedBuy, recentBlockhash);
48
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Yellowstone gRPC 客户端实现 - 基于 @triton-one/yellowstone-grpc
3
+ */
4
+ import { CommitmentLevel } from "@triton-one/yellowstone-grpc";
5
+ import { type ClientConfig, type TransactionFilter, type SubscribeCallbacks } from "./types.js";
6
+ export { SubscribeCallbacks };
7
+ /** Yellowstone gRPC 客户端包装器 */
8
+ export declare class YellowstoneGrpc {
9
+ private client;
10
+ private config;
11
+ private connected;
12
+ private subscribers;
13
+ constructor(endpoint: string, xToken: string, config?: ClientConfig);
14
+ /** 连接到 gRPC 服务器 */
15
+ connect(): Promise<void>;
16
+ /** 断开连接 */
17
+ disconnect(): Promise<void>;
18
+ /** 检查是否已连接 */
19
+ isConnected(): boolean;
20
+ /** 获取客户端配置 */
21
+ getConfig(): ClientConfig;
22
+ /** 转换 SlotStatus */
23
+ private convertSlotStatus;
24
+ /** 转换订阅更新 */
25
+ private convertUpdate;
26
+ /** 订阅交易 */
27
+ subscribeTransactions(filter: TransactionFilter, callbacks: SubscribeCallbacks): Promise<{
28
+ id: string;
29
+ cancel: () => void;
30
+ }>;
31
+ /** 取消订阅 */
32
+ unsubscribe(subId: string): void;
33
+ /** 获取最新区块哈希 */
34
+ getLatestBlockhash(commitment?: CommitmentLevel): Promise<{
35
+ slot: number;
36
+ blockhash: string;
37
+ lastValidBlockHeight: number;
38
+ }>;
39
+ /** 获取区块高度 */
40
+ getBlockHeight(commitment?: CommitmentLevel): Promise<number>;
41
+ /** 获取当前 Slot */
42
+ getSlot(commitment?: CommitmentLevel): Promise<number>;
43
+ /** 获取服务器版本 */
44
+ getVersion(): Promise<string>;
45
+ /** 验证区块哈希是否有效 */
46
+ isBlockhashValid(blockhash: string, commitment?: CommitmentLevel): Promise<{
47
+ slot: number;
48
+ valid: boolean;
49
+ }>;
50
+ /** 发送 Ping 请求 */
51
+ ping(count: number): Promise<number>;
52
+ }