sol-parser-sdk-nodejs 0.3.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/.env.example +24 -0
- package/README.md +94 -352
- package/README_CN.md +101 -253
- package/dist/accounts/mod.d.ts +2 -0
- package/dist/accounts/mod.js +5 -1
- package/dist/accounts/rpc_wallet.d.ts +5 -0
- package/dist/accounts/rpc_wallet.js +18 -0
- package/dist/accounts/rust_aliases.d.ts +9 -0
- package/dist/accounts/rust_aliases.js +19 -0
- package/dist/accounts/wallet_resolve.d.ts +1 -0
- package/dist/accounts/wallet_resolve.js +28 -0
- package/dist/common/constants.d.ts +10 -0
- package/dist/common/constants.js +13 -0
- package/dist/core/account_dispatcher_rpc.js +26 -5
- package/dist/core/account_fill_meteora.d.ts +4 -2
- package/dist/core/account_fill_meteora.js +5 -2
- package/dist/core/account_pubkey_cache.d.ts +12 -0
- package/dist/core/account_pubkey_cache.js +26 -0
- package/dist/core/clock.d.ts +6 -0
- package/dist/core/clock.js +13 -0
- package/dist/core/dex_event.d.ts +25 -44
- package/dist/core/metadata.d.ts +1 -0
- package/dist/core/unified_parser.d.ts +2 -2
- package/dist/core/unified_parser.js +6 -6
- package/dist/grpc/client.d.ts +6 -0
- package/dist/grpc/client.js +121 -64
- package/dist/grpc/event_parser.d.ts +6 -0
- package/dist/grpc/event_parser.js +15 -0
- package/dist/grpc/geyser_connect.d.ts +30 -0
- package/dist/grpc/geyser_connect.js +40 -0
- package/dist/grpc/program_ids.d.ts +25 -0
- package/dist/grpc/program_ids.js +54 -0
- package/dist/grpc/rpc_to_grpc.d.ts +18 -0
- package/dist/grpc/rpc_to_grpc.js +127 -0
- package/dist/grpc/subscribe_builder.d.ts +13 -0
- package/dist/grpc/subscribe_builder.js +66 -0
- package/dist/grpc/transaction_meta.d.ts +29 -0
- package/dist/grpc/transaction_meta.js +208 -0
- package/dist/grpc/types.d.ts +53 -2
- package/dist/grpc/types.js +98 -7
- package/dist/grpc/yellowstone_parse.d.ts +5 -0
- package/dist/grpc/yellowstone_parse.js +15 -2
- package/dist/index.d.ts +36 -6
- package/dist/index.js +172 -2
- package/dist/instr/bonk_ix.d.ts +4 -1
- package/dist/instr/bonk_ix.js +106 -27
- package/dist/instr/meteora_damm_ix.d.ts +4 -2
- package/dist/instr/meteora_damm_ix.js +248 -13
- package/dist/instr/mod.js +7 -2
- package/dist/instr/orca_whirlpool_ix.d.ts +4 -1
- package/dist/instr/orca_whirlpool_ix.js +45 -16
- package/dist/instr/program_ids.d.ts +7 -13
- package/dist/instr/program_ids.js +19 -15
- package/dist/instr/pumpswap_ix.d.ts +1 -1
- package/dist/instr/pumpswap_ix.js +78 -57
- package/dist/instr/raydium_amm_v4_ix.d.ts +1 -1
- package/dist/instr/raydium_amm_v4_ix.js +94 -28
- package/dist/instr/raydium_clmm_ix.d.ts +1 -1
- package/dist/instr/raydium_clmm_ix.js +59 -26
- package/dist/instr/raydium_cpmm_ix.d.ts +1 -1
- package/dist/instr/raydium_cpmm_ix.js +46 -12
- package/dist/instr/rust_aliases.d.ts +7 -0
- package/dist/instr/rust_aliases.js +14 -0
- package/dist/instr/utils.d.ts +1 -1
- package/dist/instr/utils.js +2 -1
- package/dist/logs/discriminator_lut.d.ts +19 -0
- package/dist/logs/discriminator_lut.js +60 -0
- package/dist/logs/meteora_damm.d.ts +3 -4
- package/dist/logs/meteora_damm.js +3 -369
- package/dist/logs/optimized_matcher.d.ts +2 -2
- package/dist/logs/optimized_matcher.js +3 -3
- package/dist/logs/rust_aliases.d.ts +6 -0
- package/dist/logs/rust_aliases.js +13 -0
- package/dist/rpc_parser.d.ts +1 -0
- package/dist/rpc_parser.js +4 -1
- package/dist/shredstream/alt_lookup.d.ts +9 -0
- package/dist/shredstream/alt_lookup.js +70 -0
- package/dist/shredstream/client.d.ts +62 -0
- package/dist/shredstream/client.js +399 -0
- package/dist/shredstream/config.d.ts +30 -0
- package/dist/shredstream/config.js +34 -0
- package/dist/shredstream/entries_decode.d.ts +28 -0
- package/dist/shredstream/entries_decode.js +251 -0
- package/dist/shredstream/index.d.ts +17 -0
- package/dist/shredstream/index.js +33 -0
- package/dist/shredstream/instruction_parse.d.ts +34 -0
- package/dist/shredstream/instruction_parse.js +47 -0
- package/dist/shredstream/proto_types.d.ts +9 -0
- package/dist/shredstream/proto_types.js +2 -0
- package/dist/shredstream/shredstream.proto +15 -0
- package/dist/shredstream/wire_to_shred_tx.d.ts +2 -0
- package/dist/shredstream/wire_to_shred_tx.js +59 -0
- package/package.json +28 -11
package/README_CN.md
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h1>⚡ Sol Parser SDK - Node.js</h1>
|
|
3
|
-
<h3><em>高性能 Solana DEX
|
|
3
|
+
<h3><em>高性能 Solana DEX 事件解析(Node.js / TypeScript)</em></h3>
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<p align="center">
|
|
11
|
-
<a href="https://www.npmjs.com/package/sol-parser-sdk-nodejs">
|
|
12
|
-
<img src="https://img.shields.io/badge/npm-sol--parser--sdk--nodejs-red.svg" alt="npm">
|
|
13
|
-
</a>
|
|
14
|
-
<a href="https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/LICENSE">
|
|
15
|
-
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
|
|
16
|
-
</a>
|
|
17
|
-
</p>
|
|
18
|
-
|
|
19
|
-
<p align="center">
|
|
20
|
-
<img src="https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js">
|
|
21
|
-
<img src="https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript">
|
|
22
|
-
<img src="https://img.shields.io/badge/Solana-9945FF?style=for-the-badge&logo=solana&logoColor=white" alt="Solana">
|
|
23
|
-
<img src="https://img.shields.io/badge/gRPC-4285F4?style=for-the-badge&logo=grpc&logoColor=white" alt="gRPC">
|
|
7
|
+
<a href="https://www.npmjs.com/package/sol-parser-sdk-nodejs"><img src="https://img.shields.io/badge/npm-sol--parser--sdk--nodejs-red.svg" alt="npm"></a>
|
|
8
|
+
<a href="https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
|
|
24
9
|
</p>
|
|
25
10
|
|
|
26
11
|
<p align="center">
|
|
@@ -33,140 +18,74 @@
|
|
|
33
18
|
|
|
34
19
|
---
|
|
35
20
|
|
|
36
|
-
##
|
|
37
|
-
|
|
38
|
-
本 SDK 提供多种语言版本:
|
|
21
|
+
## 其他语言 SDK
|
|
39
22
|
|
|
40
|
-
| 语言 | 仓库 |
|
|
41
|
-
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
23
|
+
| 语言 | 仓库 |
|
|
24
|
+
|------|------|
|
|
25
|
+
| Rust | [sol-parser-sdk](https://github.com/0xfnzero/sol-parser-sdk) |
|
|
26
|
+
| Node.js | [sol-parser-sdk-nodejs](https://github.com/0xfnzero/sol-parser-sdk-nodejs) |
|
|
27
|
+
| Python | [sol-parser-sdk-python](https://github.com/0xfnzero/sol-parser-sdk-python) |
|
|
28
|
+
| Go | [sol-parser-sdk-golang](https://github.com/0xfnzero/sol-parser-sdk-golang) |
|
|
46
29
|
|
|
47
30
|
---
|
|
48
31
|
|
|
49
|
-
##
|
|
50
|
-
|
|
51
|
-
### ⚡ 实时解析
|
|
52
|
-
- **零延迟** 基于日志的事件解析
|
|
53
|
-
- **gRPC 流式传输** 支持 Yellowstone/Geyser 协议
|
|
54
|
-
- **多协议** 单次订阅同时监听多个 DEX
|
|
55
|
-
- **事件类型过滤** 精准解析所需事件
|
|
56
|
-
|
|
57
|
-
### 🏗️ 支持的协议
|
|
58
|
-
- ✅ **PumpFun** - Meme 代币交易
|
|
59
|
-
- ✅ **PumpSwap** - PumpFun 交换协议
|
|
60
|
-
- ✅ **Raydium AMM V4** - 自动做市商
|
|
61
|
-
- ✅ **Raydium CLMM** - 集中流动性
|
|
62
|
-
- ✅ **Raydium CPMM** - 集中池
|
|
63
|
-
- ✅ **Orca Whirlpool** - 集中流动性 AMM
|
|
64
|
-
- ✅ **Meteora DAMM V2** - 动态 AMM
|
|
65
|
-
- ✅ **Meteora DLMM** - 动态流动性做市商
|
|
66
|
-
- ✅ **Bonk Launchpad** - 代币发射平台
|
|
32
|
+
## 怎么用
|
|
67
33
|
|
|
68
|
-
|
|
34
|
+
### 1. 安装
|
|
69
35
|
|
|
70
|
-
|
|
36
|
+
**npm**
|
|
71
37
|
|
|
72
|
-
|
|
38
|
+
```bash
|
|
39
|
+
npm install sol-parser-sdk-nodejs
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**源码**(monorepo 里目录可能是 `sol-parser-sdk-ts`)
|
|
73
43
|
|
|
74
44
|
```bash
|
|
75
45
|
git clone https://github.com/0xfnzero/sol-parser-sdk-nodejs
|
|
76
46
|
cd sol-parser-sdk-nodejs
|
|
77
|
-
npm install
|
|
78
|
-
npm run build
|
|
47
|
+
npm install
|
|
48
|
+
# npm run build # 若从 dist 引用而非 tsx 跑 examples,再执行
|
|
79
49
|
```
|
|
80
50
|
|
|
81
|
-
###
|
|
51
|
+
### 2. 环境变量(Yellowstone gRPC 示例)
|
|
82
52
|
|
|
83
|
-
|
|
53
|
+
在**包根目录**(与 `package.json` 同级):
|
|
84
54
|
|
|
85
55
|
```bash
|
|
86
|
-
|
|
87
|
-
GRPC_URL
|
|
88
|
-
|
|
89
|
-
# PumpFun 详细性能指标(单事件明细 + 每 10 秒统计)
|
|
90
|
-
GRPC_TOKEN=你的token node examples/pumpfun_with_metrics.mjs
|
|
91
|
-
|
|
92
|
-
# PumpSwap 详细性能指标(单事件明细 + 每 10 秒统计)
|
|
93
|
-
GRPC_TOKEN=你的token node examples/pumpswap_with_metrics.mjs
|
|
94
|
-
|
|
95
|
-
# PumpSwap 超低延迟测试
|
|
96
|
-
GRPC_TOKEN=你的token node examples/pumpswap_low_latency.mjs
|
|
56
|
+
cp .env.example .env
|
|
57
|
+
# 填写 GRPC_URL、GRPC_TOKEN
|
|
97
58
|
```
|
|
98
59
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
| 变量 | 说明 |
|
|
102
|
-
|------|------|
|
|
103
|
-
| **`GRPC_URL`** | Yellowstone gRPC 端点(优先使用)。例:`https://solana-yellowstone-grpc.publicnode.com:443` |
|
|
104
|
-
| **`GRPC_TOKEN`** | 对应端点的 `x-token`(优先使用) |
|
|
105
|
-
| **`GEYSER_ENDPOINT`** | 与 `GRPC_URL` 同义,兼容旧配置 |
|
|
106
|
-
| **`GEYSER_API_TOKEN`** | 与 `GRPC_TOKEN` 同义,兼容旧配置 |
|
|
107
|
-
| **`MAX_EVENTS`** | `*_grpc_json.mjs` 与 `npm run test:grpc`:解析满 N 条事件后退出;`0` 表示持续运行直到 Ctrl+C |
|
|
108
|
-
| **`TIMEOUT_MS`** | 仅 `npm run test:grpc`:运行 N 毫秒后自动退出;`0` 表示不超时(可与 `MAX_EVENTS` 同时设,先满足任一条件即退出) |
|
|
109
|
-
| **`JSON_PRETTY`** | `npm run test:grpc`:设为 `1` 或 `true` 时多行缩进打印(默认单行紧凑 JSON) |
|
|
110
|
-
| **`JSON_MAX_CHARS`** | `npm run test:grpc`:每条事件 JSON 最大字符数;不设或 `0` 表示不截断 |
|
|
111
|
-
|
|
112
|
-
部分脚本对公共节点带默认 token;生产环境请显式设置 `GRPC_TOKEN`。
|
|
113
|
-
|
|
114
|
-
### 示例列表
|
|
115
|
-
|
|
116
|
-
以下命令均在**本包根目录**执行,且已 `npm run build`。
|
|
60
|
+
在该目录下执行下面的 `npx tsx`,以便加载 `.env`。
|
|
117
61
|
|
|
118
|
-
|
|
119
|
-
|------|----------|------|
|
|
120
|
-
| **本包脚本** | | |
|
|
121
|
-
| gRPC 集成测试(PumpFun + PumpSwap,账户填充后的 DexEvent) | `npm run test:grpc` | [scripts/test-grpc-ts.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/scripts/test-grpc-ts.mjs) |
|
|
122
|
-
| 调试:打印 meta / 日志结构 | `npm run debug:grpc` | [scripts/debug-grpc-ts.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/scripts/debug-grpc-ts.mjs) |
|
|
123
|
-
| **PumpFun** | | |
|
|
124
|
-
| gRPC 订阅并输出**完整 JSON** DexEvent(字段与 Rust 对齐) | `node examples/pumpfun_grpc_json.mjs` | [examples/pumpfun_grpc_json.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpfun_grpc_json.mjs) |
|
|
125
|
-
| PumpFun 事件解析 + 性能指标 | `node examples/pumpfun_with_metrics.mjs` | [examples/pumpfun_with_metrics.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpfun_with_metrics.mjs) |
|
|
126
|
-
| PumpFun 交易类型过滤 | `node examples/pumpfun_trade_filter.mjs` | [examples/pumpfun_trade_filter.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpfun_trade_filter.mjs) |
|
|
127
|
-
| PumpFun 快速连接测试 | `node examples/pumpfun_quick_test.mjs` | [examples/pumpfun_quick_test.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpfun_quick_test.mjs) |
|
|
128
|
-
| **PumpSwap** | | |
|
|
129
|
-
| gRPC 订阅并输出**完整 JSON** DexEvent(字段与 Rust 对齐) | `node examples/pumpswap_grpc_json.mjs` | [examples/pumpswap_grpc_json.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpswap_grpc_json.mjs) |
|
|
130
|
-
| PumpSwap 事件 + 性能统计 | `node examples/pumpswap_with_metrics.mjs` | [examples/pumpswap_with_metrics.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpswap_with_metrics.mjs) |
|
|
131
|
-
| PumpSwap 超低延迟 | `node examples/pumpswap_low_latency.mjs` | [examples/pumpswap_low_latency.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpswap_low_latency.mjs) |
|
|
132
|
-
| **Meteora DAMM** | | |
|
|
133
|
-
| Meteora DAMM V2 事件 | `node examples/meteora_damm_grpc.mjs` | [examples/meteora_damm_grpc.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/meteora_damm_grpc.mjs) |
|
|
134
|
-
| **多协议** | | |
|
|
135
|
-
| 同时订阅所有 DEX 协议 | `node examples/multi_protocol_grpc.mjs` | [examples/multi_protocol_grpc.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/multi_protocol_grpc.mjs) |
|
|
136
|
-
| **工具 / 测试** | | |
|
|
137
|
-
| 验证 onUpdate 同步抛错不会打断 gRPC 流 | `node examples/grpc_onupdate_error_test.mjs` | [examples/grpc_onupdate_error_test.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/grpc_onupdate_error_test.mjs) |
|
|
138
|
-
| 通过签名解析交易(RPC,非 gRPC) | `TX_SIGNATURE=<sig> node examples/parse_tx_by_signature.mjs` | [examples/parse_tx_by_signature.mjs](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/parse_tx_by_signature.mjs) |
|
|
62
|
+
### 3. 冒烟
|
|
139
63
|
|
|
140
|
-
|
|
64
|
+
```bash
|
|
65
|
+
npx tsx scripts/test-grpc-ts.ts
|
|
66
|
+
```
|
|
141
67
|
|
|
142
|
-
|
|
68
|
+
需要 `GRPC_URL`、`GRPC_TOKEN`。更多变量见 `.env.example`(如 `MAX_EVENTS`、`TIMEOUT_MS`)。
|
|
143
69
|
|
|
144
|
-
|
|
145
|
-
import { createRequire } from "module";
|
|
146
|
-
import { fileURLToPath } from "url";
|
|
147
|
-
import path from "path";
|
|
70
|
+
### 4. 最小 gRPC 订阅示例
|
|
148
71
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const {
|
|
72
|
+
```typescript
|
|
73
|
+
import {
|
|
152
74
|
YellowstoneGrpc,
|
|
153
75
|
parseDexEventsFromGrpcTransactionInfo,
|
|
154
76
|
dexEventToJsonString,
|
|
155
|
-
}
|
|
77
|
+
} from "sol-parser-sdk-nodejs";
|
|
156
78
|
|
|
157
|
-
const ENDPOINT =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
"https://solana-yellowstone-grpc.publicnode.com:443";
|
|
161
|
-
const X_TOKEN =
|
|
162
|
-
process.env.GRPC_TOKEN || process.env.GEYSER_API_TOKEN || "";
|
|
79
|
+
const ENDPOINT = process.env.GRPC_URL?.trim() ?? "";
|
|
80
|
+
const X_TOKEN = process.env.GRPC_TOKEN?.trim() ?? "";
|
|
81
|
+
if (!ENDPOINT || !X_TOKEN) throw new Error("GRPC_URL and GRPC_TOKEN are required");
|
|
163
82
|
|
|
164
83
|
const client = new YellowstoneGrpc(ENDPOINT, X_TOKEN);
|
|
165
84
|
|
|
166
85
|
const filter = {
|
|
167
86
|
account_include: [
|
|
168
87
|
"6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P", // PumpFun
|
|
169
|
-
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA", // PumpSwap
|
|
88
|
+
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA", // PumpSwap
|
|
170
89
|
],
|
|
171
90
|
account_exclude: [],
|
|
172
91
|
account_required: [],
|
|
@@ -176,168 +95,97 @@ const filter = {
|
|
|
176
95
|
|
|
177
96
|
const sub = await client.subscribeTransactions(filter, {
|
|
178
97
|
onUpdate: (update) => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const slot = update.transaction
|
|
182
|
-
if (!txInfo.transactionRaw || !txInfo.metaRaw) return;
|
|
183
|
-
|
|
98
|
+
const txInfo = update.transaction?.transaction;
|
|
99
|
+
if (!txInfo?.transactionRaw || !txInfo.metaRaw) return;
|
|
100
|
+
const slot = update.transaction!.slot;
|
|
184
101
|
const events = parseDexEventsFromGrpcTransactionInfo(txInfo, slot, undefined);
|
|
185
|
-
for (const ev of events)
|
|
186
|
-
console.log(dexEventToJsonString(ev, 2));
|
|
187
|
-
}
|
|
102
|
+
for (const ev of events) console.log(dexEventToJsonString(ev, 2));
|
|
188
103
|
},
|
|
189
|
-
onError: (err) => console.error(
|
|
190
|
-
onEnd: () =>
|
|
104
|
+
onError: (err) => console.error(err.message),
|
|
105
|
+
onEnd: () => {},
|
|
191
106
|
});
|
|
192
107
|
|
|
193
|
-
console.log(
|
|
108
|
+
console.log("subscribed", sub.id);
|
|
194
109
|
```
|
|
195
110
|
|
|
196
|
-
|
|
111
|
+
更轻量:仅用日志用 `parseLogsOnly`;要补账户可再配合 `applyAccountFillsToLogEvents`。
|
|
197
112
|
|
|
198
|
-
|
|
113
|
+
### 5. ShredStream(HTTP,不是 Yellowstone gRPC)
|
|
199
114
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
### 事件类型
|
|
203
|
-
每个协议均支持:
|
|
204
|
-
- 📈 **交易/兑换事件** - 买入/卖出交易
|
|
205
|
-
- 💧 **流动性事件** - 存入/提取
|
|
206
|
-
- 🏊 **池子事件** - 池子创建/初始化
|
|
207
|
-
- 🎯 **仓位事件** - 开仓/平仓(CLMM)
|
|
208
|
-
|
|
209
|
-
### PumpFun 事件
|
|
210
|
-
- `PumpFunBuy` - 买入代币
|
|
211
|
-
- `PumpFunSell` - 卖出代币
|
|
212
|
-
- `PumpFunBuyExactSolIn` - 指定 SOL 数量买入
|
|
213
|
-
- `PumpFunCreate` - 创建新代币
|
|
214
|
-
- `PumpFunTrade` - 通用交易(兜底)
|
|
215
|
-
|
|
216
|
-
### PumpSwap 事件
|
|
217
|
-
- `PumpSwapBuy` - 通过池子买入代币
|
|
218
|
-
- `PumpSwapSell` - 通过池子卖出代币
|
|
219
|
-
- `PumpSwapCreatePool` - 创建流动性池
|
|
220
|
-
- `PumpSwapLiquidityAdded` - 添加流动性
|
|
221
|
-
- `PumpSwapLiquidityRemoved` - 移除流动性
|
|
222
|
-
|
|
223
|
-
### Raydium 事件
|
|
224
|
-
- `RaydiumAmmV4Swap` - AMM V4 兑换
|
|
225
|
-
- `RaydiumClmmSwap` - CLMM 兑换
|
|
226
|
-
- `RaydiumCpmmSwap` - CPMM 兑换
|
|
227
|
-
|
|
228
|
-
### Orca 事件
|
|
229
|
-
- `OrcaWhirlpoolSwap` - Whirlpool 兑换
|
|
230
|
-
|
|
231
|
-
### Meteora 事件
|
|
232
|
-
- `MeteoraDammV2Swap` - DAMM V2 兑换
|
|
233
|
-
- `MeteoraDammV2AddLiquidity` - 添加流动性
|
|
234
|
-
- `MeteoraDammV2RemoveLiquidity` - 移除流动性
|
|
235
|
-
- `MeteoraDammV2CreatePosition` - 创建仓位
|
|
236
|
-
- `MeteoraDammV2ClosePosition` - 关闭仓位
|
|
237
|
-
|
|
238
|
-
### Bonk 事件
|
|
239
|
-
- `BonkTrade` - Bonk Launchpad 交易
|
|
115
|
+
使用 **`SHREDSTREAM_URL`** / **`SHRED_URL`**(默认 `http://127.0.0.1:10800`)或命令行 **`--url`**,**不用** `GRPC_URL`。
|
|
240
116
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
## 📁 项目结构
|
|
117
|
+
客户端在 **TypeScript** 中解码 gRPC `entries` 负载(布局与 Go `shredstream/entries_decode` 一致),并用 `@solana/web3.js` 反序列化线格式交易,**无需 WebAssembly / wasm-pack**。
|
|
244
118
|
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
├── src/
|
|
248
|
-
│ ├── core/
|
|
249
|
-
│ │ ├── unified_parser.ts # parseLogsOnly 等
|
|
250
|
-
│ │ ├── dex_event.ts # DexEvent 类型定义
|
|
251
|
-
│ │ ├── rpc_invoke_map.ts # 程序 invoke 映射、accountKeyToBase58
|
|
252
|
-
│ │ └── json_utils.ts # dexEventToJsonString
|
|
253
|
-
│ ├── grpc/
|
|
254
|
-
│ │ ├── client.ts # YellowstoneGrpc 客户端
|
|
255
|
-
│ │ ├── yellowstone_parse.ts # parseDexEventsFromGrpcTransactionInfo
|
|
256
|
-
│ │ └── types.ts # ClientConfig、TransactionFilter 等
|
|
257
|
-
│ ├── rpc_transaction.ts # parseRpcTransaction、applyAccountFillsToLogEvents
|
|
258
|
-
│ ├── logs/
|
|
259
|
-
│ │ └── optimized_matcher.ts # 日志解析(所有协议)
|
|
260
|
-
│ ├── instr/
|
|
261
|
-
│ │ └── *.ts # 指令解析器
|
|
262
|
-
│ └── index.ts # 公共 API 导出
|
|
263
|
-
├── dist/ # 编译后的 JavaScript
|
|
264
|
-
├── scripts/
|
|
265
|
-
│ ├── test-grpc-ts.mjs # npm run test:grpc
|
|
266
|
-
│ └── debug-grpc-ts.mjs # npm run debug:grpc
|
|
267
|
-
├── examples/
|
|
268
|
-
│ ├── pumpfun_grpc_json.mjs
|
|
269
|
-
│ ├── pumpswap_grpc_json.mjs
|
|
270
|
-
│ ├── grpc_onupdate_error_test.mjs
|
|
271
|
-
│ ├── pumpfun_with_metrics.mjs
|
|
272
|
-
│ ├── pumpfun_trade_filter.mjs
|
|
273
|
-
│ ├── pumpfun_quick_test.mjs
|
|
274
|
-
│ ├── pumpswap_with_metrics.mjs
|
|
275
|
-
│ ├── pumpswap_low_latency.mjs
|
|
276
|
-
│ ├── meteora_damm_grpc.mjs
|
|
277
|
-
│ ├── multi_protocol_grpc.mjs
|
|
278
|
-
│ └── parse_tx_by_signature.mjs
|
|
279
|
-
└── package.json
|
|
119
|
+
```bash
|
|
120
|
+
npx tsx examples/shredstream_example.ts -- --url=http://127.0.0.1:10800
|
|
280
121
|
```
|
|
281
122
|
|
|
282
|
-
|
|
123
|
+
`shredstream_pumpfun_json.ts` 另需 Solana **`RPC_URL`**(或 `--rpc`)解析 ALT。
|
|
283
124
|
|
|
284
|
-
|
|
125
|
+
---
|
|
285
126
|
|
|
286
|
-
|
|
127
|
+
## 示例列表
|
|
287
128
|
|
|
288
|
-
|
|
289
|
-
const ENDPOINT =
|
|
290
|
-
process.env.GRPC_URL ||
|
|
291
|
-
process.env.GEYSER_ENDPOINT ||
|
|
292
|
-
"https://solana-yellowstone-grpc.publicnode.com:443";
|
|
293
|
-
const TOKEN =
|
|
294
|
-
process.env.GRPC_TOKEN || process.env.GEYSER_API_TOKEN || "";
|
|
295
|
-
const client = new YellowstoneGrpc(ENDPOINT, TOKEN);
|
|
296
|
-
```
|
|
129
|
+
在**包根目录**执行,`npm install` 后即可。示例用 `npx tsx` 直接加载 **`src/`**,**不必先 `npm run build`**。**源码**列每个文件单独一行,链接指向 GitHub 上的对应源码(GitHub / npm 均可点击)。
|
|
297
130
|
|
|
298
|
-
|
|
131
|
+
| 描述 | 运行命令 | 源码 |
|
|
132
|
+
|------|----------|------|
|
|
133
|
+
| **本包脚本** | | |
|
|
134
|
+
| gRPC 集成测试(PumpFun + PumpSwap,账户填充后的 `DexEvent`) | `npx tsx scripts/test-grpc-ts.ts` | [test-grpc-ts.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/scripts/test-grpc-ts.ts) |
|
|
135
|
+
| 调试:打印 `metaRaw` / 日志结构 | `npx tsx scripts/debug-grpc-ts.ts` | [debug-grpc-ts.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/scripts/debug-grpc-ts.ts) |
|
|
136
|
+
| **PumpFun** | | |
|
|
137
|
+
| gRPC 输出完整 JSON `DexEvent` | `npx tsx examples/pumpfun_grpc_json.ts` | [pumpfun_grpc_json.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpfun_grpc_json.ts) |
|
|
138
|
+
| PumpFun 事件 + 性能指标 | `npx tsx examples/pumpfun_with_metrics.ts` | [pumpfun_with_metrics.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpfun_with_metrics.ts) |
|
|
139
|
+
| PumpFun 交易类型过滤 | `npx tsx examples/pumpfun_trade_filter.ts` | [pumpfun_trade_filter.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpfun_trade_filter.ts) |
|
|
140
|
+
| PumpFun 快速连接测试 | `npx tsx examples/pumpfun_quick_test.ts` | [pumpfun_quick_test.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpfun_quick_test.ts) |
|
|
141
|
+
| **PumpSwap** | | |
|
|
142
|
+
| gRPC 输出完整 JSON `DexEvent` | `npx tsx examples/pumpswap_grpc_json.ts` | [pumpswap_grpc_json.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpswap_grpc_json.ts) |
|
|
143
|
+
| PumpSwap 事件 + 性能指标 | `npx tsx examples/pumpswap_with_metrics.ts` | [pumpswap_with_metrics.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpswap_with_metrics.ts) |
|
|
144
|
+
| PumpSwap 超低延迟 | `npx tsx examples/pumpswap_low_latency.ts` | [pumpswap_low_latency.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/pumpswap_low_latency.ts) |
|
|
145
|
+
| **Meteora DAMM** | | |
|
|
146
|
+
| Meteora DAMM V2 事件 | `npx tsx examples/meteora_damm_grpc.ts` | [meteora_damm_grpc.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/meteora_damm_grpc.ts) |
|
|
147
|
+
| **ShredStream**(HTTP,**非** Yellowstone gRPC;端点见上文步骤 5) | | |
|
|
148
|
+
| 超低延迟订阅、队列与延迟统计。端点:`--url` / `SHREDSTREAM_URL` / `.env`(默认 `http://127.0.0.1:10800`)。 | `npx tsx examples/shredstream_example.ts` | [shredstream_example.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/shredstream_example.ts) |
|
|
149
|
+
| ShredStream → PumpFun `DexEvent` JSON;需 Solana **RPC** 解析 ALT(`RPC_URL` 或 `--rpc`)。 | `npx tsx examples/shredstream_pumpfun_json.ts` | [shredstream_pumpfun_json.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/shredstream_pumpfun_json.ts) |
|
|
150
|
+
| **多协议** | | |
|
|
151
|
+
| 同时订阅所有 DEX 协议 | `npx tsx examples/multi_protocol_grpc.ts` | [multi_protocol_grpc.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/multi_protocol_grpc.ts) |
|
|
152
|
+
| **工具** | | |
|
|
153
|
+
| 验证 onUpdate 同步错误不会打断 gRPC 流 | `npx tsx examples/grpc_onupdate_error_test.ts` | [grpc_onupdate_error_test.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/grpc_onupdate_error_test.ts) |
|
|
154
|
+
| 按签名解析交易(`parseTransactionFromRpc`;非 gRPC)。在 `.env` 或环境中设置 `TX_SIGNATURE`。 | `npx tsx examples/parse_tx_by_signature.ts` | [parse_tx_by_signature.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/parse_tx_by_signature.ts) |
|
|
299
155
|
|
|
300
|
-
|
|
301
|
-
- **`applyAccountFillsToLogEvents(events, message, meta)`** — 若你已有日志解析结果,用手里的 message + meta 补全字段。
|
|
302
|
-
- **`parseRpcTransaction` / `parseTransactionFromRpc`** — 完整 RPC 交易解析(指令 + 日志 + 填充)。
|
|
156
|
+
**`npm run` 别名**(与上表 ShredStream 行同一源码文件,每行一条):
|
|
303
157
|
|
|
304
|
-
|
|
158
|
+
- `npm run example:shredstream` → [shredstream_example.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/shredstream_example.ts)
|
|
159
|
+
- `npm run example:shredstream:subscribe` → [shredstream_example.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/shredstream_example.ts)
|
|
160
|
+
- `npm run example:shredstream:pumpfun-json` → [shredstream_pumpfun_json.ts](https://github.com/0xfnzero/sol-parser-sdk-nodejs/blob/main/examples/shredstream_pumpfun_json.ts)
|
|
305
161
|
|
|
306
|
-
|
|
307
|
-
const sub = await client.subscribeTransactions(filter, callbacks);
|
|
162
|
+
**环境变量:** gRPC 示例需要 **`GRPC_URL`**、**`GRPC_TOKEN`**。ShredStream 使用 **`SHREDSTREAM_URL`** / **`SHRED_URL`** 或 **`--url`**;**`shredstream_pumpfun_json`** 另需 **`RPC_URL`** / **`--rpc`**。详见 **`.env.example`**。
|
|
308
163
|
|
|
309
|
-
|
|
310
|
-
client.unsubscribe(sub.id);
|
|
311
|
-
```
|
|
164
|
+
---
|
|
312
165
|
|
|
313
|
-
|
|
166
|
+
## 协议
|
|
314
167
|
|
|
315
|
-
|
|
316
|
-
const { dexEventToJsonString } = require("./dist/index.js");
|
|
168
|
+
PumpFun、PumpSwap、Raydium AMM V4 / CLMM / CPMM、Orca Whirlpool、Meteora DAMM V2 / DLMM、Bonk Launchpad(见 `src/instr/`)。
|
|
317
169
|
|
|
318
|
-
|
|
319
|
-
// 正确处理 BigInt 序列化
|
|
320
|
-
console.log(dexEventToJsonString(ev));
|
|
321
|
-
}
|
|
322
|
-
```
|
|
170
|
+
---
|
|
323
171
|
|
|
324
|
-
|
|
172
|
+
## 常用 API
|
|
325
173
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
4. **避免对 BigInt 使用 JSON.stringify** — 请使用 `dexEventToJsonString`
|
|
330
|
-
5. **监控延迟** — 生产环境检查 `metadata.grpc_recv_us`
|
|
174
|
+
- `parseDexEventsFromGrpcTransactionInfo` — 需要 `transactionRaw` + `metaRaw`(与 Rust gRPC 对齐)。
|
|
175
|
+
- `parseRpcTransaction` / `parseTransactionFromRpc` — HTTP RPC 全量解析。
|
|
176
|
+
- `dexEventToJsonString` — 含 BigInt 的安全 JSON 输出。
|
|
331
177
|
|
|
332
178
|
---
|
|
333
179
|
|
|
334
|
-
##
|
|
180
|
+
## 开发
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npm run build
|
|
184
|
+
npm run check:migration # 对齐与校验,需先 build
|
|
185
|
+
```
|
|
335
186
|
|
|
336
|
-
|
|
187
|
+
---
|
|
337
188
|
|
|
338
|
-
##
|
|
189
|
+
## 许可证
|
|
339
190
|
|
|
340
|
-
|
|
341
|
-
- **官网**: https://fnzero.dev/
|
|
342
|
-
- **Telegram**: https://t.me/fnzero_group
|
|
343
|
-
- **Discord**: https://discord.gg/vuazbGkqQE
|
|
191
|
+
MIT — https://github.com/0xfnzero/sol-parser-sdk-nodejs
|
package/dist/accounts/mod.d.ts
CHANGED
|
@@ -7,5 +7,7 @@ export { parseNonceAccount, isNonceAccount } from "./nonce.js";
|
|
|
7
7
|
export { parseTokenAccount } from "./token.js";
|
|
8
8
|
export { parsePumpswapGlobalConfig, parsePumpswapPool, parsePumpswapAccount, isGlobalConfigAccount, isPoolAccount, } from "./pumpswap.js";
|
|
9
9
|
export { hasDiscriminator } from "./utils.js";
|
|
10
|
+
export { userWalletPubkeyForOnchainAccount } from "./wallet_resolve.js";
|
|
11
|
+
export { rpcResolveUserWalletPubkey } from "./rpc_wallet.js";
|
|
10
12
|
/** 账户数据统一解析入口 */
|
|
11
13
|
export declare function parseAccountUnified(account: AccountData, metadata: EventMetadata, eventTypeFilter?: EventTypeFilter): DexEvent | null;
|
package/dist/accounts/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasDiscriminator = exports.isPoolAccount = exports.isGlobalConfigAccount = exports.parsePumpswapAccount = exports.parsePumpswapPool = exports.parsePumpswapGlobalConfig = exports.parseTokenAccount = exports.isNonceAccount = exports.parseNonceAccount = void 0;
|
|
3
|
+
exports.rpcResolveUserWalletPubkey = exports.userWalletPubkeyForOnchainAccount = exports.hasDiscriminator = exports.isPoolAccount = exports.isGlobalConfigAccount = exports.parsePumpswapAccount = exports.parsePumpswapPool = exports.parsePumpswapGlobalConfig = exports.parseTokenAccount = exports.isNonceAccount = exports.parseNonceAccount = void 0;
|
|
4
4
|
exports.parseAccountUnified = parseAccountUnified;
|
|
5
5
|
const program_ids_js_1 = require("../instr/program_ids.js");
|
|
6
6
|
const nonce_js_1 = require("./nonce.js");
|
|
@@ -19,6 +19,10 @@ Object.defineProperty(exports, "isGlobalConfigAccount", { enumerable: true, get:
|
|
|
19
19
|
Object.defineProperty(exports, "isPoolAccount", { enumerable: true, get: function () { return pumpswap_js_2.isPoolAccount; } });
|
|
20
20
|
var utils_js_1 = require("./utils.js");
|
|
21
21
|
Object.defineProperty(exports, "hasDiscriminator", { enumerable: true, get: function () { return utils_js_1.hasDiscriminator; } });
|
|
22
|
+
var wallet_resolve_js_1 = require("./wallet_resolve.js");
|
|
23
|
+
Object.defineProperty(exports, "userWalletPubkeyForOnchainAccount", { enumerable: true, get: function () { return wallet_resolve_js_1.userWalletPubkeyForOnchainAccount; } });
|
|
24
|
+
var rpc_wallet_js_1 = require("./rpc_wallet.js");
|
|
25
|
+
Object.defineProperty(exports, "rpcResolveUserWalletPubkey", { enumerable: true, get: function () { return rpc_wallet_js_1.rpcResolveUserWalletPubkey; } });
|
|
22
26
|
const ACCOUNT_EVENT_TYPES = [
|
|
23
27
|
"TokenAccount",
|
|
24
28
|
"NonceAccount",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rpcResolveUserWalletPubkey = rpcResolveUserWalletPubkey;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const wallet_resolve_js_1 = require("./wallet_resolve.js");
|
|
6
|
+
async function rpcResolveUserWalletPubkey(connection, addressBs58) {
|
|
7
|
+
let pk;
|
|
8
|
+
try {
|
|
9
|
+
pk = new web3_js_1.PublicKey(addressBs58);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const acc = await connection.getAccountInfo(pk);
|
|
15
|
+
if (!acc)
|
|
16
|
+
return null;
|
|
17
|
+
return (0, wallet_resolve_js_1.userWalletPubkeyForOnchainAccount)(addressBs58, acc.owner.toBase58(), acc.data, acc.executable);
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust `accounts` 模块蛇形命名别名(与 `parse_nonce_account` 等对应)。
|
|
3
|
+
*/
|
|
4
|
+
export { parseAccountUnified as parse_account_unified } from "./mod.js";
|
|
5
|
+
export { parseNonceAccount as parse_nonce_account } from "./nonce.js";
|
|
6
|
+
export { parseTokenAccount as parse_token_account } from "./token.js";
|
|
7
|
+
export { parsePumpswapGlobalConfig as parse_pumpswap_global_config, parsePumpswapPool as parse_pumpswap_pool, } from "./pumpswap.js";
|
|
8
|
+
export { rpcResolveUserWalletPubkey as rpc_resolve_user_wallet_pubkey } from "./rpc_wallet.js";
|
|
9
|
+
export { userWalletPubkeyForOnchainAccount as user_wallet_pubkey_for_onchain_account } from "./wallet_resolve.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.user_wallet_pubkey_for_onchain_account = exports.rpc_resolve_user_wallet_pubkey = exports.parse_pumpswap_pool = exports.parse_pumpswap_global_config = exports.parse_token_account = exports.parse_nonce_account = exports.parse_account_unified = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Rust `accounts` 模块蛇形命名别名(与 `parse_nonce_account` 等对应)。
|
|
6
|
+
*/
|
|
7
|
+
var mod_js_1 = require("./mod.js");
|
|
8
|
+
Object.defineProperty(exports, "parse_account_unified", { enumerable: true, get: function () { return mod_js_1.parseAccountUnified; } });
|
|
9
|
+
var nonce_js_1 = require("./nonce.js");
|
|
10
|
+
Object.defineProperty(exports, "parse_nonce_account", { enumerable: true, get: function () { return nonce_js_1.parseNonceAccount; } });
|
|
11
|
+
var token_js_1 = require("./token.js");
|
|
12
|
+
Object.defineProperty(exports, "parse_token_account", { enumerable: true, get: function () { return token_js_1.parseTokenAccount; } });
|
|
13
|
+
var pumpswap_js_1 = require("./pumpswap.js");
|
|
14
|
+
Object.defineProperty(exports, "parse_pumpswap_global_config", { enumerable: true, get: function () { return pumpswap_js_1.parsePumpswapGlobalConfig; } });
|
|
15
|
+
Object.defineProperty(exports, "parse_pumpswap_pool", { enumerable: true, get: function () { return pumpswap_js_1.parsePumpswapPool; } });
|
|
16
|
+
var rpc_wallet_js_1 = require("./rpc_wallet.js");
|
|
17
|
+
Object.defineProperty(exports, "rpc_resolve_user_wallet_pubkey", { enumerable: true, get: function () { return rpc_wallet_js_1.rpcResolveUserWalletPubkey; } });
|
|
18
|
+
var wallet_resolve_js_1 = require("./wallet_resolve.js");
|
|
19
|
+
Object.defineProperty(exports, "user_wallet_pubkey_for_onchain_account", { enumerable: true, get: function () { return wallet_resolve_js_1.userWalletPubkeyForOnchainAccount; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function userWalletPubkeyForOnchainAccount(address: string, owner: string, data: Uint8Array, executable: boolean): string | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userWalletPubkeyForOnchainAccount = userWalletPubkeyForOnchainAccount;
|
|
4
|
+
/**
|
|
5
|
+
* 与 Rust `accounts/utils::user_wallet_pubkey_for_onchain_account` 对齐:
|
|
6
|
+
* 由链上账户 owner / data / executable 推断「用户钱包」公钥(Base58)。
|
|
7
|
+
*/
|
|
8
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
9
|
+
const binary_js_1 = require("../util/binary.js");
|
|
10
|
+
const TOKEN_PROGRAM = new web3_js_1.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").toBase58();
|
|
11
|
+
const TOKEN_2022 = new web3_js_1.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb").toBase58();
|
|
12
|
+
const SYSTEM = web3_js_1.SystemProgram.programId.toBase58();
|
|
13
|
+
/** SPL Token `Account` 布局长度(与 `spl_token::state::Account::LEN` 一致) */
|
|
14
|
+
const SPL_TOKEN_ACCOUNT_LEN = 165;
|
|
15
|
+
function isTokenProgramOwner(owner) {
|
|
16
|
+
return owner === TOKEN_PROGRAM || owner === TOKEN_2022;
|
|
17
|
+
}
|
|
18
|
+
function userWalletPubkeyForOnchainAccount(address, owner, data, executable) {
|
|
19
|
+
if (executable)
|
|
20
|
+
return null;
|
|
21
|
+
if (owner === SYSTEM) {
|
|
22
|
+
return data.length === 0 ? address : null;
|
|
23
|
+
}
|
|
24
|
+
if (isTokenProgramOwner(owner) && data.length === SPL_TOKEN_ACCOUNT_LEN) {
|
|
25
|
+
return (0, binary_js_1.readPubkey)(data, 32);
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 与 Rust `sol-parser-sdk/src/common/constants.rs` 对齐的流处理默认值。
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFAULT_CONNECT_TIMEOUT = 10;
|
|
5
|
+
export declare const DEFAULT_REQUEST_TIMEOUT = 60;
|
|
6
|
+
export declare const DEFAULT_CHANNEL_SIZE = 1000;
|
|
7
|
+
export declare const DEFAULT_MAX_DECODING_MESSAGE_SIZE: number;
|
|
8
|
+
export declare const DEFAULT_METRICS_WINDOW_SECONDS = 5;
|
|
9
|
+
export declare const DEFAULT_METRICS_PRINT_INTERVAL_SECONDS = 10;
|
|
10
|
+
export declare const SLOW_PROCESSING_THRESHOLD_US = 3000;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SLOW_PROCESSING_THRESHOLD_US = exports.DEFAULT_METRICS_PRINT_INTERVAL_SECONDS = exports.DEFAULT_METRICS_WINDOW_SECONDS = exports.DEFAULT_MAX_DECODING_MESSAGE_SIZE = exports.DEFAULT_CHANNEL_SIZE = exports.DEFAULT_REQUEST_TIMEOUT = exports.DEFAULT_CONNECT_TIMEOUT = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 与 Rust `sol-parser-sdk/src/common/constants.rs` 对齐的流处理默认值。
|
|
6
|
+
*/
|
|
7
|
+
exports.DEFAULT_CONNECT_TIMEOUT = 10;
|
|
8
|
+
exports.DEFAULT_REQUEST_TIMEOUT = 60;
|
|
9
|
+
exports.DEFAULT_CHANNEL_SIZE = 1000;
|
|
10
|
+
exports.DEFAULT_MAX_DECODING_MESSAGE_SIZE = 1024 * 1024 * 10;
|
|
11
|
+
exports.DEFAULT_METRICS_WINDOW_SECONDS = 5;
|
|
12
|
+
exports.DEFAULT_METRICS_PRINT_INTERVAL_SECONDS = 10;
|
|
13
|
+
exports.SLOW_PROCESSING_THRESHOLD_US = 3000;
|