four-flap-meme-sdk 1.4.92 → 1.4.93

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 (142) hide show
  1. package/README.zh-CN.pdf +0 -0
  2. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  3. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.js +1 -1
  6. package/package.json +3 -38
  7. package/dist/sol/constants.d.ts +0 -126
  8. package/dist/sol/constants.js +0 -145
  9. package/dist/sol/dex/blockrazor/client.d.ts +0 -51
  10. package/dist/sol/dex/blockrazor/client.js +0 -96
  11. package/dist/sol/dex/blockrazor/constants.d.ts +0 -34
  12. package/dist/sol/dex/blockrazor/constants.js +0 -55
  13. package/dist/sol/dex/blockrazor/geyser.d.ts +0 -128
  14. package/dist/sol/dex/blockrazor/geyser.js +0 -530
  15. package/dist/sol/dex/blockrazor/index.d.ts +0 -18
  16. package/dist/sol/dex/blockrazor/index.js +0 -23
  17. package/dist/sol/dex/blockrazor/send.d.ts +0 -135
  18. package/dist/sol/dex/blockrazor/send.js +0 -254
  19. package/dist/sol/dex/blockrazor/types.d.ts +0 -191
  20. package/dist/sol/dex/blockrazor/types.js +0 -5
  21. package/dist/sol/dex/index.d.ts +0 -10
  22. package/dist/sol/dex/index.js +0 -16
  23. package/dist/sol/dex/jup/client.d.ts +0 -33
  24. package/dist/sol/dex/jup/client.js +0 -110
  25. package/dist/sol/dex/jup/index.d.ts +0 -16
  26. package/dist/sol/dex/jup/index.js +0 -148
  27. package/dist/sol/dex/jup/legacy.d.ts +0 -623
  28. package/dist/sol/dex/jup/legacy.js +0 -416
  29. package/dist/sol/dex/jup/lend.d.ts +0 -640
  30. package/dist/sol/dex/jup/lend.js +0 -603
  31. package/dist/sol/dex/jup/portfolio.d.ts +0 -362
  32. package/dist/sol/dex/jup/portfolio.js +0 -367
  33. package/dist/sol/dex/jup/price.d.ts +0 -173
  34. package/dist/sol/dex/jup/price.js +0 -220
  35. package/dist/sol/dex/jup/recurring.d.ts +0 -437
  36. package/dist/sol/dex/jup/recurring.js +0 -320
  37. package/dist/sol/dex/jup/send.d.ts +0 -282
  38. package/dist/sol/dex/jup/send.js +0 -295
  39. package/dist/sol/dex/jup/studio.d.ts +0 -457
  40. package/dist/sol/dex/jup/studio.js +0 -488
  41. package/dist/sol/dex/jup/tokens.d.ts +0 -767
  42. package/dist/sol/dex/jup/tokens.js +0 -697
  43. package/dist/sol/dex/jup/trigger.d.ts +0 -511
  44. package/dist/sol/dex/jup/trigger.js +0 -397
  45. package/dist/sol/dex/jup/types.d.ts +0 -433
  46. package/dist/sol/dex/jup/types.js +0 -5
  47. package/dist/sol/dex/jup/ultra.d.ts +0 -646
  48. package/dist/sol/dex/jup/ultra.js +0 -853
  49. package/dist/sol/dex/meteora/client.d.ts +0 -76
  50. package/dist/sol/dex/meteora/client.js +0 -219
  51. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  52. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  53. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  54. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  55. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  56. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  57. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  58. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  59. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  60. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  61. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  62. package/dist/sol/dex/meteora/dbc.js +0 -619
  63. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  64. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  65. package/dist/sol/dex/meteora/dlmm.d.ts +0 -157
  66. package/dist/sol/dex/meteora/dlmm.js +0 -671
  67. package/dist/sol/dex/meteora/index.d.ts +0 -25
  68. package/dist/sol/dex/meteora/index.js +0 -65
  69. package/dist/sol/dex/meteora/types.d.ts +0 -787
  70. package/dist/sol/dex/meteora/types.js +0 -110
  71. package/dist/sol/dex/orca/index.d.ts +0 -10
  72. package/dist/sol/dex/orca/index.js +0 -16
  73. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  74. package/dist/sol/dex/orca/orca-bundle.js +0 -173
  75. package/dist/sol/dex/orca/orca.d.ts +0 -65
  76. package/dist/sol/dex/orca/orca.js +0 -474
  77. package/dist/sol/dex/orca/types.d.ts +0 -263
  78. package/dist/sol/dex/orca/types.js +0 -38
  79. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  80. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
  81. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  82. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  83. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  84. package/dist/sol/dex/orca/wavebreak.js +0 -497
  85. package/dist/sol/dex/pump/index.d.ts +0 -9
  86. package/dist/sol/dex/pump/index.js +0 -14
  87. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  88. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  89. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  90. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  91. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  92. package/dist/sol/dex/pump/pump-swap.js +0 -199
  93. package/dist/sol/dex/pump/pump.d.ts +0 -35
  94. package/dist/sol/dex/pump/pump.js +0 -352
  95. package/dist/sol/dex/pump/types.d.ts +0 -215
  96. package/dist/sol/dex/pump/types.js +0 -5
  97. package/dist/sol/dex/raydium/index.d.ts +0 -8
  98. package/dist/sol/dex/raydium/index.js +0 -12
  99. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  100. package/dist/sol/dex/raydium/launchlab.js +0 -210
  101. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  102. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  103. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  104. package/dist/sol/dex/raydium/raydium.js +0 -366
  105. package/dist/sol/dex/raydium/types.d.ts +0 -240
  106. package/dist/sol/dex/raydium/types.js +0 -5
  107. package/dist/sol/index.d.ts +0 -10
  108. package/dist/sol/index.js +0 -16
  109. package/dist/sol/jito/bundle.d.ts +0 -90
  110. package/dist/sol/jito/bundle.js +0 -263
  111. package/dist/sol/jito/index.d.ts +0 -7
  112. package/dist/sol/jito/index.js +0 -7
  113. package/dist/sol/jito/tip.d.ts +0 -51
  114. package/dist/sol/jito/tip.js +0 -83
  115. package/dist/sol/jito/types.d.ts +0 -100
  116. package/dist/sol/jito/types.js +0 -5
  117. package/dist/sol/token/create-complete.d.ts +0 -115
  118. package/dist/sol/token/create-complete.js +0 -235
  119. package/dist/sol/token/create-token.d.ts +0 -57
  120. package/dist/sol/token/create-token.js +0 -230
  121. package/dist/sol/token/index.d.ts +0 -9
  122. package/dist/sol/token/index.js +0 -14
  123. package/dist/sol/token/metadata-upload.d.ts +0 -86
  124. package/dist/sol/token/metadata-upload.js +0 -173
  125. package/dist/sol/token/metadata.d.ts +0 -92
  126. package/dist/sol/token/metadata.js +0 -274
  127. package/dist/sol/token/types.d.ts +0 -153
  128. package/dist/sol/token/types.js +0 -5
  129. package/dist/sol/types.d.ts +0 -176
  130. package/dist/sol/types.js +0 -7
  131. package/dist/sol/utils/balance.d.ts +0 -160
  132. package/dist/sol/utils/balance.js +0 -638
  133. package/dist/sol/utils/connection.d.ts +0 -78
  134. package/dist/sol/utils/connection.js +0 -168
  135. package/dist/sol/utils/index.d.ts +0 -9
  136. package/dist/sol/utils/index.js +0 -9
  137. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  138. package/dist/sol/utils/lp-inspect.js +0 -900
  139. package/dist/sol/utils/transfer.d.ts +0 -196
  140. package/dist/sol/utils/transfer.js +0 -307
  141. package/dist/sol/utils/wallet.d.ts +0 -107
  142. package/dist/sol/utils/wallet.js +0 -210
@@ -1,530 +0,0 @@
1
- /**
2
- * BlockRazor Geyser Stream 服务
3
- * @module sol/dex/blockrazor/geyser
4
- *
5
- * Geyser Stream 是基于 Yellowstone gRPC 的高性能 Solana 数据流服务。
6
- *
7
- * @see https://blockrazor.gitbook.io/blockrazor/solana/geyser-stream
8
- */
9
- import { GEYSER_STREAM_ENDPOINTS } from './constants.js';
10
- // ============================================================================
11
- // Geyser Proto 定义
12
- // ============================================================================
13
- /**
14
- * Geyser Proto 定义(内联)
15
- *
16
- * 用于动态加载 gRPC 服务
17
- */
18
- export const GEYSER_PROTO_DEFINITION = `
19
- syntax = "proto3";
20
-
21
- package geyser;
22
-
23
- service Geyser {
24
- rpc Subscribe(stream SubscribeRequest) returns (stream SubscribeUpdate);
25
- }
26
-
27
- message SubscribeRequest {
28
- map<string, SubscribeRequestFilterAccounts> accounts = 1;
29
- map<string, SubscribeRequestFilterSlots> slots = 2;
30
- map<string, SubscribeRequestFilterTransactions> transactions = 3;
31
- map<string, SubscribeRequestFilterBlocks> blocks = 4;
32
- map<string, SubscribeRequestFilterBlocksMeta> blocks_meta = 5;
33
- map<string, SubscribeRequestFilterEntry> entry = 6;
34
- optional CommitmentLevel commitment = 7;
35
- repeated SubscribeRequestAccountsDataSlice accounts_data_slice = 8;
36
- optional SubscribeRequestPing ping = 9;
37
- }
38
-
39
- enum CommitmentLevel {
40
- PROCESSED = 0;
41
- CONFIRMED = 1;
42
- FINALIZED = 2;
43
- }
44
-
45
- message SubscribeRequestFilterAccounts {
46
- repeated string account = 1;
47
- repeated string owner = 2;
48
- repeated SubscribeRequestFilterAccountsFilter filters = 3;
49
- optional bool nonempty_txn_signature = 4;
50
- }
51
-
52
- message SubscribeRequestFilterAccountsFilter {
53
- oneof filter {
54
- SubscribeRequestFilterAccountsFilterMemcmp memcmp = 1;
55
- uint64 datasize = 2;
56
- bool token_account_state = 3;
57
- SubscribeRequestFilterAccountsFilterLamports lamports = 4;
58
- }
59
- }
60
-
61
- message SubscribeRequestFilterAccountsFilterMemcmp {
62
- uint64 offset = 1;
63
- oneof data {
64
- bytes bytes = 2;
65
- string base58 = 3;
66
- string base64 = 4;
67
- }
68
- }
69
-
70
- message SubscribeRequestFilterAccountsFilterLamports {
71
- oneof cmp {
72
- uint64 eq = 1;
73
- uint64 ne = 2;
74
- uint64 lt = 3;
75
- uint64 gt = 4;
76
- }
77
- }
78
-
79
- message SubscribeRequestFilterSlots {
80
- optional bool filter_by_commitment = 1;
81
- optional bool interleave_global_updates = 2;
82
- }
83
-
84
- message SubscribeRequestFilterTransactions {
85
- optional bool vote = 1;
86
- optional bool failed = 2;
87
- optional string signature = 3;
88
- repeated string account_include = 4;
89
- repeated string account_exclude = 5;
90
- repeated string account_required = 6;
91
- }
92
-
93
- message SubscribeRequestFilterBlocks {
94
- repeated string account_include = 1;
95
- optional bool include_transactions = 2;
96
- optional bool include_accounts = 3;
97
- optional bool include_entries = 4;
98
- }
99
-
100
- message SubscribeRequestFilterBlocksMeta {}
101
-
102
- message SubscribeRequestFilterEntry {}
103
-
104
- message SubscribeRequestAccountsDataSlice {
105
- uint64 offset = 1;
106
- uint64 length = 2;
107
- }
108
-
109
- message SubscribeRequestPing {
110
- int32 id = 1;
111
- }
112
-
113
- message SubscribeUpdate {
114
- repeated string filters = 1;
115
- oneof update_oneof {
116
- SubscribeUpdateAccount account = 2;
117
- SubscribeUpdateSlot slot = 3;
118
- SubscribeUpdateTransaction transaction = 4;
119
- SubscribeUpdateTransactionInfo transaction_info = 10;
120
- SubscribeUpdateBlock block = 5;
121
- SubscribeUpdatePing ping = 6;
122
- SubscribeUpdatePong pong = 7;
123
- SubscribeUpdateBlockMeta block_meta = 8;
124
- SubscribeUpdateEntry entry = 9;
125
- }
126
- uint64 created_at = 11;
127
- }
128
-
129
- message SubscribeUpdateAccount {
130
- SubscribeUpdateAccountInfo account = 1;
131
- uint64 slot = 2;
132
- optional bool is_startup = 3;
133
- }
134
-
135
- message SubscribeUpdateAccountInfo {
136
- bytes pubkey = 1;
137
- uint64 lamports = 2;
138
- bytes owner = 3;
139
- bool executable = 4;
140
- uint64 rent_epoch = 5;
141
- bytes data = 6;
142
- uint64 write_version = 7;
143
- optional bytes txn_signature = 8;
144
- }
145
-
146
- message SubscribeUpdateSlot {
147
- uint64 slot = 1;
148
- optional uint64 parent = 2;
149
- CommitmentLevel status = 3;
150
- optional int64 dead_error = 4;
151
- }
152
-
153
- message SubscribeUpdateTransaction {
154
- SubscribeUpdateTransactionInfo transaction = 1;
155
- uint64 slot = 2;
156
- }
157
-
158
- message SubscribeUpdateTransactionInfo {
159
- bytes signature = 1;
160
- bool is_vote = 2;
161
- bytes transaction = 3;
162
- bytes meta = 4;
163
- optional uint64 index = 5;
164
- }
165
-
166
- message SubscribeUpdateBlock {
167
- uint64 slot = 1;
168
- string blockhash = 2;
169
- SubscribeUpdateBlockRewards rewards = 3;
170
- UnixTimestamp block_time = 4;
171
- BlockHeight block_height = 5;
172
- uint64 parent_slot = 6;
173
- string parent_blockhash = 7;
174
- uint64 executed_transaction_count = 8;
175
- uint64 entries_count = 9;
176
- repeated SubscribeUpdateTransactionInfo transactions = 10;
177
- repeated SubscribeUpdateAccountInfo updated_account_count = 11;
178
- repeated SubscribeUpdateEntry entries = 12;
179
- }
180
-
181
- message SubscribeUpdateBlockRewards {
182
- bytes rewards = 1;
183
- }
184
-
185
- message UnixTimestamp {
186
- int64 timestamp = 1;
187
- }
188
-
189
- message BlockHeight {
190
- uint64 block_height = 1;
191
- }
192
-
193
- message SubscribeUpdatePing {}
194
-
195
- message SubscribeUpdatePong {
196
- int32 id = 1;
197
- }
198
-
199
- message SubscribeUpdateBlockMeta {
200
- uint64 slot = 1;
201
- string blockhash = 2;
202
- SubscribeUpdateBlockRewards rewards = 3;
203
- UnixTimestamp block_time = 4;
204
- BlockHeight block_height = 5;
205
- uint64 parent_slot = 6;
206
- string parent_blockhash = 7;
207
- uint64 executed_transaction_count = 8;
208
- uint64 entries_count = 9;
209
- }
210
-
211
- message SubscribeUpdateEntry {
212
- uint64 slot = 1;
213
- uint64 index = 2;
214
- uint64 num_hashes = 3;
215
- bytes hash = 4;
216
- uint64 executed_transaction_count = 5;
217
- optional uint64 starting_transaction_index = 6;
218
- }
219
- `;
220
- // ============================================================================
221
- // 辅助函数
222
- // ============================================================================
223
- /**
224
- * 获取 Geyser Stream 端点
225
- *
226
- * @param region 区域
227
- * @returns gRPC 端点地址
228
- */
229
- export function getGeyserEndpoint(region = 'tokyo') {
230
- switch (region) {
231
- case 'tokyo':
232
- return GEYSER_STREAM_ENDPOINTS.TOKYO;
233
- case 'frankfurt':
234
- return GEYSER_STREAM_ENDPOINTS.FRANKFURT;
235
- case 'newyork':
236
- return GEYSER_STREAM_ENDPOINTS.NEW_YORK;
237
- case 'amsterdam':
238
- return GEYSER_STREAM_ENDPOINTS.AMSTERDAM;
239
- default:
240
- return GEYSER_STREAM_ENDPOINTS.TOKYO;
241
- }
242
- }
243
- /**
244
- * 构建 Geyser 订阅请求
245
- *
246
- * @param config 订阅配置
247
- * @returns gRPC 请求对象
248
- */
249
- export function buildGeyserSubscribeRequest(config) {
250
- const request = {};
251
- // 账户订阅
252
- if (config.subscribeAccounts && config.accountParams) {
253
- const { filterKey, owners, accounts, filters, nonemptyTxnSignature } = config.accountParams;
254
- request.accounts = {
255
- [filterKey]: {
256
- owner: owners || [],
257
- account: accounts || [],
258
- filters: filters || [],
259
- nonempty_txn_signature: nonemptyTxnSignature || false,
260
- },
261
- };
262
- }
263
- // 区块订阅
264
- if (config.subscribeBlocks && config.blockParams) {
265
- const { filterKey, accountInclude, includeTransactions, includeAccounts, includeEntries } = config.blockParams;
266
- request.blocks = {
267
- [filterKey]: {
268
- account_include: accountInclude || [],
269
- include_transactions: includeTransactions ?? true,
270
- include_accounts: includeAccounts ?? false,
271
- include_entries: includeEntries ?? false,
272
- },
273
- };
274
- }
275
- // 交易订阅
276
- if (config.subscribeTransactions && config.transactionParams) {
277
- const { filterKey, vote, failed, accountInclude, accountExclude, accountRequired, signature } = config.transactionParams;
278
- request.transactions = {
279
- [filterKey]: {
280
- vote: vote ?? false,
281
- failed: failed ?? false,
282
- account_include: accountInclude || [],
283
- account_exclude: accountExclude || [],
284
- account_required: accountRequired || [],
285
- signature: signature || null,
286
- },
287
- };
288
- }
289
- // Commitment
290
- request.commitment = config.commitment || 'CONFIRMED';
291
- return request;
292
- }
293
- // ============================================================================
294
- // 配置工厂函数
295
- // ============================================================================
296
- /**
297
- * 创建默认账户订阅配置
298
- *
299
- * @param owners 拥有者地址列表
300
- * @param accounts 特定账户地址列表
301
- * @returns 订阅配置
302
- */
303
- export function createAccountSubscribeConfig(owners, accounts) {
304
- return {
305
- commitment: 'CONFIRMED',
306
- subscribeAccounts: true,
307
- accountParams: {
308
- filterKey: 'account-filter',
309
- owners: owners || [],
310
- accounts: accounts || [],
311
- filters: [],
312
- nonemptyTxnSignature: false,
313
- },
314
- };
315
- }
316
- /**
317
- * 创建默认交易订阅配置
318
- *
319
- * @param accountInclude 包含涉及这些账户的交易
320
- * @param accountRequired 交易必须涉及这些账户
321
- * @returns 订阅配置
322
- */
323
- export function createTransactionSubscribeConfig(accountInclude, accountRequired) {
324
- return {
325
- commitment: 'CONFIRMED',
326
- subscribeTransactions: true,
327
- transactionParams: {
328
- filterKey: 'tx-filter',
329
- vote: false,
330
- failed: false,
331
- accountInclude: accountInclude || [],
332
- accountExclude: [],
333
- accountRequired: accountRequired || [],
334
- signature: null,
335
- },
336
- };
337
- }
338
- /**
339
- * 创建默认区块订阅配置
340
- *
341
- * @param accountInclude 包含涉及这些账户的区块
342
- * @param includeTransactions 是否包含交易
343
- * @returns 订阅配置
344
- */
345
- export function createBlockSubscribeConfig(accountInclude, includeTransactions = true) {
346
- return {
347
- commitment: 'CONFIRMED',
348
- subscribeBlocks: true,
349
- blockParams: {
350
- filterKey: 'block-filter',
351
- accountInclude: accountInclude || [],
352
- includeTransactions,
353
- includeAccounts: false,
354
- includeEntries: false,
355
- },
356
- };
357
- }
358
- // ============================================================================
359
- // Geyser 订阅
360
- // ============================================================================
361
- /**
362
- * 创建 Geyser 订阅(需要 @grpc/grpc-js 和 @grpc/proto-loader)
363
- *
364
- * 注意:此函数需要安装 gRPC 依赖:
365
- * ```bash
366
- * npm install @grpc/grpc-js @grpc/proto-loader
367
- * ```
368
- *
369
- * @param clientConfig 客户端配置
370
- * @param subscribeConfig 订阅配置
371
- * @param handlers 事件处理器
372
- * @returns 流控制对象
373
- *
374
- * @example
375
- * ```typescript
376
- * import { Sol } from 'four-flap-meme-sdk'
377
- * import bs58 from 'bs58'
378
- *
379
- * const stream = await Sol.createGeyserSubscription(
380
- * {
381
- * host: Sol.getGeyserEndpoint('tokyo'),
382
- * token: 'your-auth-token',
383
- * },
384
- * Sol.createTransactionSubscribeConfig(
385
- * ['your-account-address'], // 监听涉及此账户的交易
386
- * ),
387
- * {
388
- * onTransaction: (update, raw) => {
389
- * console.log(`交易: ${bs58.encode(update.transaction.signature)}`)
390
- * },
391
- * onError: (err) => console.error('错误:', err),
392
- * onEnd: () => console.log('流结束'),
393
- * },
394
- * )
395
- *
396
- * // 关闭流
397
- * stream.close()
398
- * ```
399
- */
400
- export async function createGeyserSubscription(clientConfig, subscribeConfig, handlers) {
401
- // 动态导入 gRPC 依赖(可选依赖)
402
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
403
- let grpc;
404
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
405
- let protoLoader;
406
- try {
407
- // 使用动态 require 避免类型检查问题
408
- // eslint-disable-next-line @typescript-eslint/no-require-imports
409
- grpc = require('@grpc/grpc-js');
410
- // eslint-disable-next-line @typescript-eslint/no-require-imports
411
- protoLoader = require('@grpc/proto-loader');
412
- }
413
- catch {
414
- throw new Error('Geyser Stream requires @grpc/grpc-js and @grpc/proto-loader. ' +
415
- 'Install them with: npm install @grpc/grpc-js @grpc/proto-loader');
416
- }
417
- // 使用内联 proto 定义
418
- const packageDefinition = protoLoader.loadSync(GEYSER_PROTO_DEFINITION, {
419
- keepCase: true,
420
- longs: String,
421
- enums: String,
422
- defaults: true,
423
- oneofs: true,
424
- });
425
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
426
- const geyserProto = grpc.loadPackageDefinition(packageDefinition).geyser;
427
- // 创建 SSL 凭证
428
- const sslCreds = grpc.credentials.createSsl();
429
- // 创建 metadata
430
- const metadata = new grpc.Metadata();
431
- metadata.add('x-token', clientConfig.token);
432
- // 创建客户端
433
- const client = new geyserProto.Geyser(clientConfig.host, sslCreds);
434
- // 建立流
435
- const stream = client.Subscribe(metadata);
436
- // 处理更新
437
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
438
- stream.on('data', (update) => {
439
- const geyserUpdate = update;
440
- switch (geyserUpdate.update_oneof) {
441
- case 'account':
442
- if (geyserUpdate.account && handlers.onAccount) {
443
- handlers.onAccount(geyserUpdate.account, geyserUpdate.account.account.pubkey);
444
- }
445
- break;
446
- case 'block':
447
- if (geyserUpdate.block && handlers.onBlock) {
448
- handlers.onBlock(geyserUpdate.block);
449
- }
450
- break;
451
- case 'transaction':
452
- if (geyserUpdate.transaction && handlers.onTransaction) {
453
- handlers.onTransaction(geyserUpdate.transaction, geyserUpdate.transaction.transaction.signature);
454
- }
455
- break;
456
- }
457
- });
458
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
459
- stream.on('error', (err) => {
460
- if (handlers.onError) {
461
- handlers.onError(err instanceof Error ? err : new Error(String(err)));
462
- }
463
- });
464
- stream.on('end', () => {
465
- if (handlers.onEnd) {
466
- handlers.onEnd();
467
- }
468
- });
469
- // 发送订阅请求
470
- const request = buildGeyserSubscribeRequest(subscribeConfig);
471
- stream.write(request);
472
- return {
473
- close: () => stream.end(),
474
- write: (data) => stream.write(data),
475
- };
476
- }
477
- // ============================================================================
478
- // 简化版订阅方法
479
- // ============================================================================
480
- /**
481
- * 简化版:订阅账户更新
482
- *
483
- * @param token 认证 Token
484
- * @param accounts 账户地址列表
485
- * @param onUpdate 更新回调
486
- * @param region 区域(默认 tokyo)
487
- * @returns 流控制对象
488
- */
489
- export async function subscribeGeyserAccounts(token, accounts, onUpdate, region = 'tokyo') {
490
- const bs58 = await import('bs58');
491
- return createGeyserSubscription({ host: getGeyserEndpoint(region), token }, createAccountSubscribeConfig(undefined, accounts), {
492
- onAccount: (update) => {
493
- const pubkey = bs58.default.encode(update.account.pubkey);
494
- onUpdate(pubkey, update.account.lamports, update.slot);
495
- },
496
- });
497
- }
498
- /**
499
- * 简化版:订阅交易更新
500
- *
501
- * @param token 认证 Token
502
- * @param accountInclude 包含涉及这些账户的交易
503
- * @param onUpdate 更新回调
504
- * @param region 区域(默认 tokyo)
505
- * @returns 流控制对象
506
- */
507
- export async function subscribeGeyserTransactions(token, accountInclude, onUpdate, region = 'tokyo') {
508
- const bs58 = await import('bs58');
509
- return createGeyserSubscription({ host: getGeyserEndpoint(region), token }, createTransactionSubscribeConfig(accountInclude), {
510
- onTransaction: (update) => {
511
- const signature = bs58.default.encode(update.transaction.signature);
512
- onUpdate(signature, update.transaction.isVote, update.slot);
513
- },
514
- });
515
- }
516
- /**
517
- * 简化版:订阅区块更新
518
- *
519
- * @param token 认证 Token
520
- * @param onUpdate 更新回调
521
- * @param region 区域(默认 tokyo)
522
- * @returns 流控制对象
523
- */
524
- export async function subscribeGeyserBlocks(token, onUpdate, region = 'tokyo') {
525
- return createGeyserSubscription({ host: getGeyserEndpoint(region), token }, createBlockSubscribeConfig(), {
526
- onBlock: (update) => {
527
- onUpdate(update.slot, update.blockhash, update.transactions.length);
528
- },
529
- });
530
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * BlockRazor Solana Service
3
- * @module sol/dex/blockrazor
4
- *
5
- * BlockRazor 提供 Solana 服务:
6
- * - 高性能交易落地 (Transaction Landing)
7
- * - 三明治攻击缓解模式 (Sandwich Mitigation)
8
- * - Revert 保护
9
- * - Geyser Stream (gRPC 实时数据流)
10
- *
11
- * @see https://blockrazor.gitbook.io/blockrazor/solana/send-transaction
12
- * @see https://blockrazor.gitbook.io/blockrazor/solana/geyser-stream
13
- */
14
- export * from './types.js';
15
- export * from './constants.js';
16
- export { setBlockRazorConfig, getBlockRazorConfig, getBlockRazorEndpoint, getRandomBlockRazorTipAccount, validateSendParams, } from './client.js';
17
- export { blockRazorSendTransaction, blockRazorSendTransactionV2, blockRazorHealth, blockRazorHealthV2, blockRazorFastSend, blockRazorSafeSend, blockRazorSendWithRevertProtection, startBlockRazorKeepAlive, } from './send.js';
18
- export { GEYSER_PROTO_DEFINITION, getGeyserEndpoint, buildGeyserSubscribeRequest, createAccountSubscribeConfig, createTransactionSubscribeConfig, createBlockSubscribeConfig, createGeyserSubscription, subscribeGeyserAccounts, subscribeGeyserTransactions, subscribeGeyserBlocks, } from './geyser.js';
@@ -1,23 +0,0 @@
1
- /**
2
- * BlockRazor Solana Service
3
- * @module sol/dex/blockrazor
4
- *
5
- * BlockRazor 提供 Solana 服务:
6
- * - 高性能交易落地 (Transaction Landing)
7
- * - 三明治攻击缓解模式 (Sandwich Mitigation)
8
- * - Revert 保护
9
- * - Geyser Stream (gRPC 实时数据流)
10
- *
11
- * @see https://blockrazor.gitbook.io/blockrazor/solana/send-transaction
12
- * @see https://blockrazor.gitbook.io/blockrazor/solana/geyser-stream
13
- */
14
- // 类型导出
15
- export * from './types.js';
16
- // 常量导出
17
- export * from './constants.js';
18
- // 客户端管理
19
- export { setBlockRazorConfig, getBlockRazorConfig, getBlockRazorEndpoint, getRandomBlockRazorTipAccount, validateSendParams, } from './client.js';
20
- // Send Transaction
21
- export { blockRazorSendTransaction, blockRazorSendTransactionV2, blockRazorHealth, blockRazorHealthV2, blockRazorFastSend, blockRazorSafeSend, blockRazorSendWithRevertProtection, startBlockRazorKeepAlive, } from './send.js';
22
- // Geyser Stream
23
- export { GEYSER_PROTO_DEFINITION, getGeyserEndpoint, buildGeyserSubscribeRequest, createAccountSubscribeConfig, createTransactionSubscribeConfig, createBlockSubscribeConfig, createGeyserSubscription, subscribeGeyserAccounts, subscribeGeyserTransactions, subscribeGeyserBlocks, } from './geyser.js';
@@ -1,135 +0,0 @@
1
- /**
2
- * BlockRazor 交易发送服务
3
- * @module sol/dex/blockrazor/send
4
- *
5
- * @see https://blockrazor.gitbook.io/blockrazor/solana/send-transaction
6
- */
7
- import type { BlockRazorConfig, BlockRazorMode, BlockRazorSendParams, BlockRazorSendResponse, BlockRazorHealthResponse } from './types.js';
8
- /**
9
- * 发送交易 (V1 - HTTP JSON)
10
- *
11
- * @param params 发送参数
12
- * @param config BlockRazor 配置
13
- * @returns 发送响应
14
- *
15
- * @example
16
- * ```typescript
17
- * import { Sol } from 'four-flap-meme-sdk'
18
- *
19
- * Sol.setBlockRazorConfig({ apiKey: 'your-auth-token' })
20
- *
21
- * // 快速模式发送
22
- * const result = await Sol.blockRazorSendTransaction({
23
- * transaction: base64SignedTx,
24
- * mode: 'fast',
25
- * })
26
- *
27
- * console.log(`签名: ${result.signature}`)
28
- *
29
- * // 三明治缓解模式
30
- * const result2 = await Sol.blockRazorSendTransaction({
31
- * transaction: base64SignedTx,
32
- * mode: 'sandwichMitigation',
33
- * safeWindow: 5,
34
- * })
35
- * ```
36
- */
37
- export declare function blockRazorSendTransaction(params: BlockRazorSendParams, config?: BlockRazorConfig): Promise<BlockRazorSendResponse>;
38
- /**
39
- * 发送交易 V2 (更快的 HTTP Plain Text)
40
- *
41
- * V2 优势:
42
- * - 绕过 CORS Preflight (节省 50-100ms)
43
- * - 使用 Plain Text 而非 JSON
44
- * - Base64 编码更快
45
- *
46
- * @param transaction Base64 编码的已签名交易
47
- * @param options 可选参数
48
- * @param config BlockRazor 配置
49
- * @returns 交易签名
50
- *
51
- * @example
52
- * ```typescript
53
- * // 快速发送
54
- * const signature = await Sol.blockRazorSendTransactionV2(base64Tx)
55
- *
56
- * // 带参数发送
57
- * const signature = await Sol.blockRazorSendTransactionV2(
58
- * base64Tx,
59
- * {
60
- * mode: 'sandwichMitigation',
61
- * safeWindow: 5,
62
- * revertProtection: true,
63
- * },
64
- * )
65
- * ```
66
- */
67
- export declare function blockRazorSendTransactionV2(transaction: string, options?: {
68
- mode?: BlockRazorMode;
69
- safeWindow?: number;
70
- revertProtection?: boolean;
71
- }, config?: BlockRazorConfig): Promise<string>;
72
- /**
73
- * 健康检查 (V1)
74
- *
75
- * 用于保持连接活跃。
76
- *
77
- * @param config BlockRazor 配置
78
- * @returns 健康状态
79
- */
80
- export declare function blockRazorHealth(config?: BlockRazorConfig): Promise<BlockRazorHealthResponse>;
81
- /**
82
- * 健康检查 V2
83
- *
84
- * @param config BlockRazor 配置
85
- * @returns 是否健康
86
- */
87
- export declare function blockRazorHealthV2(config?: BlockRazorConfig): Promise<boolean>;
88
- /**
89
- * 快速发送交易
90
- *
91
- * 使用 V2 + fast 模式发送。
92
- *
93
- * @param transaction Base64 编码的已签名交易
94
- * @param config BlockRazor 配置
95
- * @returns 交易签名
96
- */
97
- export declare function blockRazorFastSend(transaction: string, config?: BlockRazorConfig): Promise<string>;
98
- /**
99
- * 安全发送交易(三明治缓解)
100
- *
101
- * 使用 V2 + sandwichMitigation 模式发送。
102
- *
103
- * @param transaction Base64 编码的已签名交易
104
- * @param safeWindow 安全窗口(默认 5)
105
- * @param config BlockRazor 配置
106
- * @returns 交易签名
107
- */
108
- export declare function blockRazorSafeSend(transaction: string, safeWindow?: number, config?: BlockRazorConfig): Promise<string>;
109
- /**
110
- * 发送交易带 Revert 保护
111
- *
112
- * @param transaction Base64 编码的已签名交易
113
- * @param config BlockRazor 配置
114
- * @returns 交易签名
115
- */
116
- export declare function blockRazorSendWithRevertProtection(transaction: string, config?: BlockRazorConfig): Promise<string>;
117
- /**
118
- * 启动 Keep-Alive 定时器
119
- *
120
- * 定期发送健康检查以保持连接活跃。
121
- *
122
- * @param intervalMs 间隔时间(毫秒,默认 30000)
123
- * @param config BlockRazor 配置
124
- * @returns 定时器 ID(用于停止)
125
- *
126
- * @example
127
- * ```typescript
128
- * // 启动 keep-alive
129
- * const timerId = Sol.startBlockRazorKeepAlive(30000)
130
- *
131
- * // 停止
132
- * clearInterval(timerId)
133
- * ```
134
- */
135
- export declare function startBlockRazorKeepAlive(intervalMs?: number, config?: BlockRazorConfig): ReturnType<typeof setInterval>;