sol-parser-sdk-nodejs 0.3.0 → 0.4.4
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 +100 -352
- package/README_CN.md +107 -253
- package/dist/accounts/mod.d.ts +3 -0
- package/dist/accounts/mod.js +18 -1
- package/dist/accounts/pumpfun.d.ts +6 -0
- package/dist/accounts/pumpfun.js +157 -0
- package/dist/accounts/rpc_wallet.d.ts +5 -0
- package/dist/accounts/rpc_wallet.js +18 -0
- package/dist/accounts/rust_aliases.d.ts +10 -0
- package/dist/accounts/rust_aliases.js +21 -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_fill_pumpfun.js +17 -0
- 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 +172 -44
- package/dist/core/metadata.d.ts +1 -0
- package/dist/core/pumpfun_fee_enrich.d.ts +4 -0
- package/dist/core/pumpfun_fee_enrich.js +80 -0
- package/dist/core/unified_parser.d.ts +2 -2
- package/dist/core/unified_parser.js +8 -6
- package/dist/grpc/client.d.ts +32 -1
- package/dist/grpc/client.js +400 -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/log_instr_dedup.d.ts +2 -0
- package/dist/grpc/log_instr_dedup.js +330 -0
- package/dist/grpc/order_buffer.d.ts +27 -0
- package/dist/grpc/order_buffer.js +166 -0
- package/dist/grpc/program_ids.d.ts +26 -0
- package/dist/grpc/program_ids.js +55 -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 +57 -2
- package/dist/grpc/types.js +199 -7
- package/dist/grpc/yellowstone_parse.d.ts +8 -1
- package/dist/grpc/yellowstone_parse.js +27 -11
- package/dist/index.d.ts +39 -8
- package/dist/index.js +184 -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.d.ts +1 -0
- package/dist/instr/mod.js +16 -3
- 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 +20 -15
- package/dist/instr/pump_fees_ix.d.ts +2 -0
- package/dist/instr/pump_fees_ix.js +166 -0
- package/dist/instr/pumpfun_ix.js +57 -0
- 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 +84 -30
- 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 +8 -0
- package/dist/instr/rust_aliases.js +16 -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 +62 -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 +123 -23
- package/dist/logs/program_log_discriminators.d.ts +10 -0
- package/dist/logs/program_log_discriminators.js +10 -0
- package/dist/logs/pump.d.ts +2 -0
- package/dist/logs/pump.js +51 -4
- package/dist/logs/pump_fees.d.ts +23 -0
- package/dist/logs/pump_fees.js +364 -0
- 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/rpc_transaction.d.ts +2 -0
- package/dist/rpc_transaction.js +14 -6
- 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 +49 -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/dist/logs/pump.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.parsePumpFunLogDecoded = parsePumpFunLogDecoded;
|
|
|
4
4
|
exports.parseTradeFromData = parseTradeFromData;
|
|
5
5
|
exports.parseCreateFromData = parseCreateFromData;
|
|
6
6
|
exports.parseMigrateFromData = parseMigrateFromData;
|
|
7
|
+
exports.parseMigrateBondingCurveCreatorFromData = parseMigrateBondingCurveCreatorFromData;
|
|
7
8
|
exports.pumpDiscriminators = pumpDiscriminators;
|
|
8
9
|
const dex_event_js_1 = require("../core/dex_event.js");
|
|
9
10
|
const binary_js_1 = require("../util/binary.js");
|
|
@@ -16,6 +17,7 @@ function disc(bytes) {
|
|
|
16
17
|
const DISC_CREATE = disc([27, 114, 169, 77, 222, 235, 99, 118]);
|
|
17
18
|
const DISC_TRADE = disc([189, 219, 127, 211, 78, 230, 97, 238]);
|
|
18
19
|
const DISC_MIGRATE = disc([189, 233, 93, 185, 92, 148, 234, 148]);
|
|
20
|
+
const DISC_MIGRATE_BONDING_CURVE_CREATOR = disc([155, 167, 104, 220, 213, 108, 243, 3]);
|
|
19
21
|
function bnU64(v) {
|
|
20
22
|
return v ?? 0n;
|
|
21
23
|
}
|
|
@@ -33,6 +35,9 @@ function parsePumpFunLogDecoded(programData, metadata) {
|
|
|
33
35
|
return parseTradeFromData(data, metadata, false);
|
|
34
36
|
if (disc === DISC_MIGRATE)
|
|
35
37
|
return parseMigrateFromData(data, metadata);
|
|
38
|
+
if (disc === DISC_MIGRATE_BONDING_CURVE_CREATOR) {
|
|
39
|
+
return parseMigrateBondingCurveCreatorFromData(data, metadata);
|
|
40
|
+
}
|
|
36
41
|
return null;
|
|
37
42
|
}
|
|
38
43
|
function parseTradeFromData(data, metadata, isCreatedBuy) {
|
|
@@ -138,12 +143,13 @@ function parseTradeFromData(data, metadata, isCreatedBuy) {
|
|
|
138
143
|
token_program: (0, dex_event_js_1.defaultPubkey)(),
|
|
139
144
|
creator_vault: (0, dex_event_js_1.defaultPubkey)(),
|
|
140
145
|
};
|
|
141
|
-
if (ix_name === "buy")
|
|
146
|
+
if (ix_name === "buy" || ix_name === "buy_v2")
|
|
142
147
|
return { PumpFunBuy: trade };
|
|
143
|
-
if (ix_name === "sell")
|
|
148
|
+
if (ix_name === "sell" || ix_name === "sell_v2")
|
|
144
149
|
return { PumpFunSell: trade };
|
|
145
|
-
if (ix_name === "buy_exact_sol_in")
|
|
150
|
+
if (ix_name === "buy_exact_sol_in" || ix_name === "buy_exact_quote_in_v2") {
|
|
146
151
|
return { PumpFunBuyExactSolIn: trade };
|
|
152
|
+
}
|
|
147
153
|
return { PumpFunTrade: trade };
|
|
148
154
|
}
|
|
149
155
|
function parseCreateFromData(data, metadata) {
|
|
@@ -245,7 +251,48 @@ function parseMigrateFromData(data, metadata) {
|
|
|
245
251
|
};
|
|
246
252
|
return { PumpFunMigrate: ev };
|
|
247
253
|
}
|
|
254
|
+
function parseMigrateBondingCurveCreatorFromData(data, metadata) {
|
|
255
|
+
if (data.length < 8 + 32 * 5)
|
|
256
|
+
return null;
|
|
257
|
+
let o = 0;
|
|
258
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
259
|
+
o += 8;
|
|
260
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
261
|
+
if (!mint)
|
|
262
|
+
return null;
|
|
263
|
+
o += 32;
|
|
264
|
+
const bonding_curve = (0, binary_js_1.readPubkey)(data, o);
|
|
265
|
+
if (!bonding_curve)
|
|
266
|
+
return null;
|
|
267
|
+
o += 32;
|
|
268
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
269
|
+
if (!sharing_config)
|
|
270
|
+
return null;
|
|
271
|
+
o += 32;
|
|
272
|
+
const old_creator = (0, binary_js_1.readPubkey)(data, o);
|
|
273
|
+
if (!old_creator)
|
|
274
|
+
return null;
|
|
275
|
+
o += 32;
|
|
276
|
+
const new_creator = (0, binary_js_1.readPubkey)(data, o);
|
|
277
|
+
if (!new_creator)
|
|
278
|
+
return null;
|
|
279
|
+
const ev = {
|
|
280
|
+
metadata,
|
|
281
|
+
timestamp,
|
|
282
|
+
mint,
|
|
283
|
+
bonding_curve,
|
|
284
|
+
sharing_config,
|
|
285
|
+
old_creator,
|
|
286
|
+
new_creator,
|
|
287
|
+
};
|
|
288
|
+
return { PumpFunMigrateBondingCurveCreator: ev };
|
|
289
|
+
}
|
|
248
290
|
/** u64 discriminator little-endian */
|
|
249
291
|
function pumpDiscriminators() {
|
|
250
|
-
return {
|
|
292
|
+
return {
|
|
293
|
+
CREATE: DISC_CREATE,
|
|
294
|
+
TRADE: DISC_TRADE,
|
|
295
|
+
MIGRATE: DISC_MIGRATE,
|
|
296
|
+
MIGRATE_BONDING_CURVE_CREATOR: DISC_MIGRATE_BONDING_CURVE_CREATOR,
|
|
297
|
+
};
|
|
251
298
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { EventMetadata } from "../core/metadata.js";
|
|
2
|
+
import type { DexEvent, PumpFeesFeeTier, PumpFeesFees, PumpFeesShareholder } from "../core/dex_event.js";
|
|
3
|
+
export declare function readFeesAt(data: Uint8Array, offset: number): {
|
|
4
|
+
value: PumpFeesFees;
|
|
5
|
+
next: number;
|
|
6
|
+
} | null;
|
|
7
|
+
export declare function readShareholdersVec(data: Uint8Array, offset: number): {
|
|
8
|
+
value: PumpFeesShareholder[];
|
|
9
|
+
next: number;
|
|
10
|
+
} | null;
|
|
11
|
+
export declare function readFeeTiersVec(data: Uint8Array, offset: number): {
|
|
12
|
+
value: PumpFeesFeeTier[];
|
|
13
|
+
next: number;
|
|
14
|
+
} | null;
|
|
15
|
+
export declare function parseCreateFeeSharingConfigFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
16
|
+
export declare function parseInitializeFeeConfigFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
17
|
+
export declare function parseResetFeeSharingConfigFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
18
|
+
export declare function parseRevokeFeeSharingAuthorityFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
19
|
+
export declare function parseTransferFeeSharingAuthorityFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
20
|
+
export declare function parseUpdateAdminFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
21
|
+
export declare function parseUpdateFeeConfigFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
22
|
+
export declare function parseUpdateFeeSharesFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
23
|
+
export declare function parseUpsertFeeTiersFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readFeesAt = readFeesAt;
|
|
4
|
+
exports.readShareholdersVec = readShareholdersVec;
|
|
5
|
+
exports.readFeeTiersVec = readFeeTiersVec;
|
|
6
|
+
exports.parseCreateFeeSharingConfigFromData = parseCreateFeeSharingConfigFromData;
|
|
7
|
+
exports.parseInitializeFeeConfigFromData = parseInitializeFeeConfigFromData;
|
|
8
|
+
exports.parseResetFeeSharingConfigFromData = parseResetFeeSharingConfigFromData;
|
|
9
|
+
exports.parseRevokeFeeSharingAuthorityFromData = parseRevokeFeeSharingAuthorityFromData;
|
|
10
|
+
exports.parseTransferFeeSharingAuthorityFromData = parseTransferFeeSharingAuthorityFromData;
|
|
11
|
+
exports.parseUpdateAdminFromData = parseUpdateAdminFromData;
|
|
12
|
+
exports.parseUpdateFeeConfigFromData = parseUpdateFeeConfigFromData;
|
|
13
|
+
exports.parseUpdateFeeSharesFromData = parseUpdateFeeSharesFromData;
|
|
14
|
+
exports.parseUpsertFeeTiersFromData = parseUpsertFeeTiersFromData;
|
|
15
|
+
const dex_event_js_1 = require("../core/dex_event.js");
|
|
16
|
+
const binary_js_1 = require("../util/binary.js");
|
|
17
|
+
const MAX_SHAREHOLDERS = 64;
|
|
18
|
+
const MAX_FEE_TIERS = 64;
|
|
19
|
+
function bnI64(v) {
|
|
20
|
+
return v ?? 0n;
|
|
21
|
+
}
|
|
22
|
+
function bnU64(v) {
|
|
23
|
+
return v ?? 0n;
|
|
24
|
+
}
|
|
25
|
+
function readFeesAt(data, offset) {
|
|
26
|
+
if (offset + 24 > data.length)
|
|
27
|
+
return null;
|
|
28
|
+
const lp_fee_bps = bnU64((0, binary_js_1.readU64LE)(data, offset));
|
|
29
|
+
offset += 8;
|
|
30
|
+
const protocol_fee_bps = bnU64((0, binary_js_1.readU64LE)(data, offset));
|
|
31
|
+
offset += 8;
|
|
32
|
+
const creator_fee_bps = bnU64((0, binary_js_1.readU64LE)(data, offset));
|
|
33
|
+
offset += 8;
|
|
34
|
+
return { value: { lp_fee_bps, protocol_fee_bps, creator_fee_bps }, next: offset };
|
|
35
|
+
}
|
|
36
|
+
function readShareholdersVec(data, offset) {
|
|
37
|
+
const n = (0, binary_js_1.readU32LE)(data, offset);
|
|
38
|
+
if (n === null || n > MAX_SHAREHOLDERS)
|
|
39
|
+
return null;
|
|
40
|
+
offset += 4;
|
|
41
|
+
const value = [];
|
|
42
|
+
for (let i = 0; i < n; i++) {
|
|
43
|
+
const address = (0, binary_js_1.readPubkey)(data, offset);
|
|
44
|
+
if (!address)
|
|
45
|
+
return null;
|
|
46
|
+
offset += 32;
|
|
47
|
+
const share_bps = (0, binary_js_1.readU16LE)(data, offset);
|
|
48
|
+
if (share_bps === null)
|
|
49
|
+
return null;
|
|
50
|
+
offset += 2;
|
|
51
|
+
value.push({ address, share_bps });
|
|
52
|
+
}
|
|
53
|
+
return { value, next: offset };
|
|
54
|
+
}
|
|
55
|
+
function readFeeTiersVec(data, offset) {
|
|
56
|
+
const n = (0, binary_js_1.readU32LE)(data, offset);
|
|
57
|
+
if (n === null || n > MAX_FEE_TIERS)
|
|
58
|
+
return null;
|
|
59
|
+
offset += 4;
|
|
60
|
+
const value = [];
|
|
61
|
+
for (let i = 0; i < n; i++) {
|
|
62
|
+
const market_cap_lamports_threshold = (0, binary_js_1.readU128LE)(data, offset);
|
|
63
|
+
if (market_cap_lamports_threshold === null)
|
|
64
|
+
return null;
|
|
65
|
+
offset += 16;
|
|
66
|
+
const fees = readFeesAt(data, offset);
|
|
67
|
+
if (!fees)
|
|
68
|
+
return null;
|
|
69
|
+
offset = fees.next;
|
|
70
|
+
value.push({ market_cap_lamports_threshold, fees: fees.value });
|
|
71
|
+
}
|
|
72
|
+
return { value, next: offset };
|
|
73
|
+
}
|
|
74
|
+
function readOptionPubkeyAt(data, offset) {
|
|
75
|
+
const tag = (0, binary_js_1.readU8)(data, offset);
|
|
76
|
+
if (tag === null)
|
|
77
|
+
return null;
|
|
78
|
+
offset += 1;
|
|
79
|
+
if (tag === 0)
|
|
80
|
+
return { value: undefined, next: offset };
|
|
81
|
+
if (tag !== 1)
|
|
82
|
+
return null;
|
|
83
|
+
const value = (0, binary_js_1.readPubkey)(data, offset);
|
|
84
|
+
if (!value)
|
|
85
|
+
return null;
|
|
86
|
+
return { value, next: offset + 32 };
|
|
87
|
+
}
|
|
88
|
+
function readConfigStatusAt(data, offset) {
|
|
89
|
+
const tag = (0, binary_js_1.readU8)(data, offset);
|
|
90
|
+
if (tag === null)
|
|
91
|
+
return null;
|
|
92
|
+
if (tag === 0)
|
|
93
|
+
return { value: "Paused", next: offset + 1 };
|
|
94
|
+
if (tag === 1)
|
|
95
|
+
return { value: "Active", next: offset + 1 };
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
function parseCreateFeeSharingConfigFromData(data, metadata) {
|
|
99
|
+
let o = 0;
|
|
100
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
101
|
+
if (o + 8 > data.length)
|
|
102
|
+
return null;
|
|
103
|
+
o += 8;
|
|
104
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
105
|
+
if (!mint)
|
|
106
|
+
return null;
|
|
107
|
+
o += 32;
|
|
108
|
+
const bonding_curve = (0, binary_js_1.readPubkey)(data, o);
|
|
109
|
+
if (!bonding_curve)
|
|
110
|
+
return null;
|
|
111
|
+
o += 32;
|
|
112
|
+
const pool = readOptionPubkeyAt(data, o);
|
|
113
|
+
if (!pool)
|
|
114
|
+
return null;
|
|
115
|
+
o = pool.next;
|
|
116
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
117
|
+
if (!sharing_config)
|
|
118
|
+
return null;
|
|
119
|
+
o += 32;
|
|
120
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
121
|
+
if (!admin)
|
|
122
|
+
return null;
|
|
123
|
+
o += 32;
|
|
124
|
+
const initial_shareholders = readShareholdersVec(data, o);
|
|
125
|
+
if (!initial_shareholders)
|
|
126
|
+
return null;
|
|
127
|
+
o = initial_shareholders.next;
|
|
128
|
+
const status = readConfigStatusAt(data, o);
|
|
129
|
+
if (!status)
|
|
130
|
+
return null;
|
|
131
|
+
o = status.next;
|
|
132
|
+
if (o !== data.length)
|
|
133
|
+
return null;
|
|
134
|
+
return {
|
|
135
|
+
PumpFeesCreateFeeSharingConfig: {
|
|
136
|
+
metadata,
|
|
137
|
+
timestamp,
|
|
138
|
+
mint,
|
|
139
|
+
bonding_curve,
|
|
140
|
+
pool: pool.value,
|
|
141
|
+
sharing_config,
|
|
142
|
+
admin,
|
|
143
|
+
initial_shareholders: initial_shareholders.value,
|
|
144
|
+
status: status.value,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function parseInitializeFeeConfigFromData(data, metadata) {
|
|
149
|
+
if (data.length !== 8 + 32 + 32)
|
|
150
|
+
return null;
|
|
151
|
+
let o = 0;
|
|
152
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
153
|
+
o += 8;
|
|
154
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
155
|
+
if (!admin)
|
|
156
|
+
return null;
|
|
157
|
+
o += 32;
|
|
158
|
+
const fee_config = (0, binary_js_1.readPubkey)(data, o);
|
|
159
|
+
if (!fee_config)
|
|
160
|
+
return null;
|
|
161
|
+
return { PumpFeesInitializeFeeConfig: { metadata, timestamp, admin, fee_config } };
|
|
162
|
+
}
|
|
163
|
+
function parseResetFeeSharingConfigFromData(data, metadata) {
|
|
164
|
+
let o = 0;
|
|
165
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
166
|
+
if (o + 8 > data.length)
|
|
167
|
+
return null;
|
|
168
|
+
o += 8;
|
|
169
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
170
|
+
if (!mint)
|
|
171
|
+
return null;
|
|
172
|
+
o += 32;
|
|
173
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
174
|
+
if (!sharing_config)
|
|
175
|
+
return null;
|
|
176
|
+
o += 32;
|
|
177
|
+
const old_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
178
|
+
if (!old_admin)
|
|
179
|
+
return null;
|
|
180
|
+
o += 32;
|
|
181
|
+
const old_shareholders = readShareholdersVec(data, o);
|
|
182
|
+
if (!old_shareholders)
|
|
183
|
+
return null;
|
|
184
|
+
o = old_shareholders.next;
|
|
185
|
+
const new_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
186
|
+
if (!new_admin)
|
|
187
|
+
return null;
|
|
188
|
+
o += 32;
|
|
189
|
+
const new_shareholders = readShareholdersVec(data, o);
|
|
190
|
+
if (!new_shareholders)
|
|
191
|
+
return null;
|
|
192
|
+
o = new_shareholders.next;
|
|
193
|
+
if (o !== data.length)
|
|
194
|
+
return null;
|
|
195
|
+
return {
|
|
196
|
+
PumpFeesResetFeeSharingConfig: {
|
|
197
|
+
metadata,
|
|
198
|
+
timestamp,
|
|
199
|
+
mint,
|
|
200
|
+
sharing_config,
|
|
201
|
+
old_admin,
|
|
202
|
+
old_shareholders: old_shareholders.value,
|
|
203
|
+
new_admin,
|
|
204
|
+
new_shareholders: new_shareholders.value,
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function parseRevokeFeeSharingAuthorityFromData(data, metadata) {
|
|
209
|
+
if (data.length !== 8 + 32 + 32 + 32)
|
|
210
|
+
return null;
|
|
211
|
+
let o = 0;
|
|
212
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
213
|
+
o += 8;
|
|
214
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
215
|
+
if (!mint)
|
|
216
|
+
return null;
|
|
217
|
+
o += 32;
|
|
218
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
219
|
+
if (!sharing_config)
|
|
220
|
+
return null;
|
|
221
|
+
o += 32;
|
|
222
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
223
|
+
if (!admin)
|
|
224
|
+
return null;
|
|
225
|
+
return { PumpFeesRevokeFeeSharingAuthority: { metadata, timestamp, mint, sharing_config, admin } };
|
|
226
|
+
}
|
|
227
|
+
function parseTransferFeeSharingAuthorityFromData(data, metadata) {
|
|
228
|
+
if (data.length !== 8 + 32 + 32 + 32 + 32)
|
|
229
|
+
return null;
|
|
230
|
+
let o = 0;
|
|
231
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
232
|
+
o += 8;
|
|
233
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
234
|
+
if (!mint)
|
|
235
|
+
return null;
|
|
236
|
+
o += 32;
|
|
237
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
238
|
+
if (!sharing_config)
|
|
239
|
+
return null;
|
|
240
|
+
o += 32;
|
|
241
|
+
const old_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
242
|
+
if (!old_admin)
|
|
243
|
+
return null;
|
|
244
|
+
o += 32;
|
|
245
|
+
const new_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
246
|
+
if (!new_admin)
|
|
247
|
+
return null;
|
|
248
|
+
return {
|
|
249
|
+
PumpFeesTransferFeeSharingAuthority: { metadata, timestamp, mint, sharing_config, old_admin, new_admin },
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function parseUpdateAdminFromData(data, metadata) {
|
|
253
|
+
if (data.length !== 8 + 32 + 32)
|
|
254
|
+
return null;
|
|
255
|
+
let o = 0;
|
|
256
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
257
|
+
o += 8;
|
|
258
|
+
const old_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
259
|
+
if (!old_admin)
|
|
260
|
+
return null;
|
|
261
|
+
o += 32;
|
|
262
|
+
const new_admin = (0, binary_js_1.readPubkey)(data, o);
|
|
263
|
+
if (!new_admin)
|
|
264
|
+
return null;
|
|
265
|
+
return { PumpFeesUpdateAdmin: { metadata, timestamp, old_admin, new_admin } };
|
|
266
|
+
}
|
|
267
|
+
function parseUpdateFeeConfigFromData(data, metadata) {
|
|
268
|
+
let o = 0;
|
|
269
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
270
|
+
if (o + 8 > data.length)
|
|
271
|
+
return null;
|
|
272
|
+
o += 8;
|
|
273
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
274
|
+
if (!admin)
|
|
275
|
+
return null;
|
|
276
|
+
o += 32;
|
|
277
|
+
const fee_config = (0, binary_js_1.readPubkey)(data, o);
|
|
278
|
+
if (!fee_config)
|
|
279
|
+
return null;
|
|
280
|
+
o += 32;
|
|
281
|
+
const fee_tiers = readFeeTiersVec(data, o);
|
|
282
|
+
if (!fee_tiers)
|
|
283
|
+
return null;
|
|
284
|
+
o = fee_tiers.next;
|
|
285
|
+
const flat_fees = readFeesAt(data, o);
|
|
286
|
+
if (!flat_fees)
|
|
287
|
+
return null;
|
|
288
|
+
o = flat_fees.next;
|
|
289
|
+
if (o !== data.length)
|
|
290
|
+
return null;
|
|
291
|
+
return {
|
|
292
|
+
PumpFeesUpdateFeeConfig: {
|
|
293
|
+
metadata,
|
|
294
|
+
timestamp,
|
|
295
|
+
admin,
|
|
296
|
+
fee_config,
|
|
297
|
+
fee_tiers: fee_tiers.value,
|
|
298
|
+
flat_fees: flat_fees.value,
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function parseUpdateFeeSharesFromData(data, metadata) {
|
|
303
|
+
let o = 0;
|
|
304
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
305
|
+
if (o + 8 > data.length)
|
|
306
|
+
return null;
|
|
307
|
+
o += 8;
|
|
308
|
+
const mint = (0, binary_js_1.readPubkey)(data, o);
|
|
309
|
+
if (!mint)
|
|
310
|
+
return null;
|
|
311
|
+
o += 32;
|
|
312
|
+
const sharing_config = (0, binary_js_1.readPubkey)(data, o);
|
|
313
|
+
if (!sharing_config)
|
|
314
|
+
return null;
|
|
315
|
+
o += 32;
|
|
316
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
317
|
+
if (!admin)
|
|
318
|
+
return null;
|
|
319
|
+
o += 32;
|
|
320
|
+
const new_shareholders = readShareholdersVec(data, o);
|
|
321
|
+
if (!new_shareholders)
|
|
322
|
+
return null;
|
|
323
|
+
o = new_shareholders.next;
|
|
324
|
+
if (o !== data.length)
|
|
325
|
+
return null;
|
|
326
|
+
return {
|
|
327
|
+
PumpFeesUpdateFeeShares: {
|
|
328
|
+
metadata,
|
|
329
|
+
timestamp,
|
|
330
|
+
mint,
|
|
331
|
+
sharing_config,
|
|
332
|
+
admin,
|
|
333
|
+
bonding_curve: (0, dex_event_js_1.defaultPubkey)(),
|
|
334
|
+
pump_creator_vault: (0, dex_event_js_1.defaultPubkey)(),
|
|
335
|
+
new_shareholders: new_shareholders.value,
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function parseUpsertFeeTiersFromData(data, metadata) {
|
|
340
|
+
let o = 0;
|
|
341
|
+
const timestamp = bnI64((0, binary_js_1.readI64LE)(data, o));
|
|
342
|
+
if (o + 8 > data.length)
|
|
343
|
+
return null;
|
|
344
|
+
o += 8;
|
|
345
|
+
const admin = (0, binary_js_1.readPubkey)(data, o);
|
|
346
|
+
if (!admin)
|
|
347
|
+
return null;
|
|
348
|
+
o += 32;
|
|
349
|
+
const fee_config = (0, binary_js_1.readPubkey)(data, o);
|
|
350
|
+
if (!fee_config)
|
|
351
|
+
return null;
|
|
352
|
+
o += 32;
|
|
353
|
+
const fee_tiers = readFeeTiersVec(data, o);
|
|
354
|
+
if (!fee_tiers)
|
|
355
|
+
return null;
|
|
356
|
+
o = fee_tiers.next;
|
|
357
|
+
const offset = (0, binary_js_1.readU8)(data, o);
|
|
358
|
+
if (offset === null)
|
|
359
|
+
return null;
|
|
360
|
+
o += 1;
|
|
361
|
+
if (o !== data.length)
|
|
362
|
+
return null;
|
|
363
|
+
return { PumpFeesUpsertFeeTiers: { metadata, timestamp, admin, fee_config, fee_tiers: fee_tiers.value, offset } };
|
|
364
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust `logs` 模块中 `parse_*_log` / `parse_log_*` 命名风格的别名(与现有 TS 实现对应)。
|
|
3
|
+
*/
|
|
4
|
+
export { parseMeteoraDammLog as parse_meteora_damm_log } from "./meteora_damm.js";
|
|
5
|
+
export { parseMeteoraDlmmLog as parse_meteora_dlmm_log } from "./meteora_dlmm.js";
|
|
6
|
+
export { parseLogOptimized as parse_log_optimized, parseLogUnified as parse_log_unified } from "./optimized_matcher.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parse_log_unified = exports.parse_log_optimized = exports.parse_meteora_dlmm_log = exports.parse_meteora_damm_log = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Rust `logs` 模块中 `parse_*_log` / `parse_log_*` 命名风格的别名(与现有 TS 实现对应)。
|
|
6
|
+
*/
|
|
7
|
+
var meteora_damm_js_1 = require("./meteora_damm.js");
|
|
8
|
+
Object.defineProperty(exports, "parse_meteora_damm_log", { enumerable: true, get: function () { return meteora_damm_js_1.parseMeteoraDammLog; } });
|
|
9
|
+
var meteora_dlmm_js_1 = require("./meteora_dlmm.js");
|
|
10
|
+
Object.defineProperty(exports, "parse_meteora_dlmm_log", { enumerable: true, get: function () { return meteora_dlmm_js_1.parseMeteoraDlmmLog; } });
|
|
11
|
+
var optimized_matcher_js_1 = require("./optimized_matcher.js");
|
|
12
|
+
Object.defineProperty(exports, "parse_log_optimized", { enumerable: true, get: function () { return optimized_matcher_js_1.parseLogOptimized; } });
|
|
13
|
+
Object.defineProperty(exports, "parse_log_unified", { enumerable: true, get: function () { return optimized_matcher_js_1.parseLogUnified; } });
|
package/dist/rpc_parser.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { DexEvent } from "./core/dex_event.js";
|
|
|
3
3
|
import type { EventTypeFilter } from "./grpc/types.js";
|
|
4
4
|
import type { ParseError } from "./core/error.js";
|
|
5
5
|
export { parseRpcTransaction, fillAccountsFromTransactionDataRpc, fillDataRpc, applyAccountFillsToLogEvents, } from "./rpc_transaction.js";
|
|
6
|
+
export { convertRpcToGrpc, convert_rpc_to_grpc, type ConvertRpcToGrpcOk, type ConvertRpcToGrpcErr, } from "./grpc/rpc_to_grpc.js";
|
|
6
7
|
/**
|
|
7
8
|
* 通过 RPC 拉取交易并解析:
|
|
8
9
|
* 外层 + 内层编译指令 + 日志;不含账户字段填充(需另行调用 RPC 填充 API)。
|
package/dist/rpc_parser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyAccountFillsToLogEvents = exports.fillDataRpc = exports.fillAccountsFromTransactionDataRpc = exports.parseRpcTransaction = void 0;
|
|
3
|
+
exports.convert_rpc_to_grpc = exports.convertRpcToGrpc = exports.applyAccountFillsToLogEvents = exports.fillDataRpc = exports.fillAccountsFromTransactionDataRpc = exports.parseRpcTransaction = void 0;
|
|
4
4
|
exports.parseTransactionFromRpc = parseTransactionFromRpc;
|
|
5
5
|
const rpc_transaction_js_1 = require("./rpc_transaction.js");
|
|
6
6
|
var rpc_transaction_js_2 = require("./rpc_transaction.js");
|
|
@@ -8,6 +8,9 @@ Object.defineProperty(exports, "parseRpcTransaction", { enumerable: true, get: f
|
|
|
8
8
|
Object.defineProperty(exports, "fillAccountsFromTransactionDataRpc", { enumerable: true, get: function () { return rpc_transaction_js_2.fillAccountsFromTransactionDataRpc; } });
|
|
9
9
|
Object.defineProperty(exports, "fillDataRpc", { enumerable: true, get: function () { return rpc_transaction_js_2.fillDataRpc; } });
|
|
10
10
|
Object.defineProperty(exports, "applyAccountFillsToLogEvents", { enumerable: true, get: function () { return rpc_transaction_js_2.applyAccountFillsToLogEvents; } });
|
|
11
|
+
var rpc_to_grpc_js_1 = require("./grpc/rpc_to_grpc.js");
|
|
12
|
+
Object.defineProperty(exports, "convertRpcToGrpc", { enumerable: true, get: function () { return rpc_to_grpc_js_1.convertRpcToGrpc; } });
|
|
13
|
+
Object.defineProperty(exports, "convert_rpc_to_grpc", { enumerable: true, get: function () { return rpc_to_grpc_js_1.convert_rpc_to_grpc; } });
|
|
11
14
|
/**
|
|
12
15
|
* 通过 RPC 拉取交易并解析:
|
|
13
16
|
* 外层 + 内层编译指令 + 日志;不含账户字段填充(需另行调用 RPC 填充 API)。
|
|
@@ -14,6 +14,8 @@ export declare function applyAccountFillsToLogEvents(events: DexEvent[], msg: Me
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function parseRpcTransaction(tx: VersionedTransactionResponse, signature: string, filter?: EventTypeFilter, options?: {
|
|
16
16
|
grpcRecvUs?: number;
|
|
17
|
+
txIndex?: number;
|
|
18
|
+
blockTimeUs?: number;
|
|
17
19
|
}): {
|
|
18
20
|
ok: true;
|
|
19
21
|
events: DexEvent[];
|
package/dist/rpc_transaction.js
CHANGED
|
@@ -13,7 +13,9 @@ const bs58_1 = __importDefault(require("bs58"));
|
|
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
|
14
14
|
const account_dispatcher_rpc_js_1 = require("./core/account_dispatcher_rpc.js");
|
|
15
15
|
const common_filler_rpc_js_1 = require("./core/common_filler_rpc.js");
|
|
16
|
+
const pumpfun_fee_enrich_js_1 = require("./core/pumpfun_fee_enrich.js");
|
|
16
17
|
const rpc_invoke_map_js_1 = require("./core/rpc_invoke_map.js");
|
|
18
|
+
const log_instr_dedup_js_1 = require("./grpc/log_instr_dedup.js");
|
|
17
19
|
const mod_js_1 = require("./instr/mod.js");
|
|
18
20
|
const optimized_matcher_js_1 = require("./logs/optimized_matcher.js");
|
|
19
21
|
const DEFAULT_PK = web3_js_1.PublicKey.default.toBase58();
|
|
@@ -71,6 +73,7 @@ function applyRpcFills(events, msg, meta) {
|
|
|
71
73
|
*/
|
|
72
74
|
function applyAccountFillsToLogEvents(events, msg, meta) {
|
|
73
75
|
applyRpcFills(events, msg, meta);
|
|
76
|
+
(0, pumpfun_fee_enrich_js_1.enrichPumpfunSameTxPostMerge)(events);
|
|
74
77
|
}
|
|
75
78
|
/**
|
|
76
79
|
* 解析已获取的 `VersionedTransactionResponse`(顺序:指令 → 日志 → 账户/数据填充)。
|
|
@@ -88,21 +91,26 @@ function parseRpcTransaction(tx, signature, filter, options) {
|
|
|
88
91
|
}
|
|
89
92
|
const meta = tx.meta ?? null;
|
|
90
93
|
const slot = tx.slot;
|
|
91
|
-
const blockTimeUs = tx.blockTime != null ? tx.blockTime * 1_000_000 : undefined;
|
|
94
|
+
const blockTimeUs = options?.blockTimeUs ?? (tx.blockTime != null ? tx.blockTime * 1_000_000 : undefined);
|
|
92
95
|
const grpcRecvUs = options?.grpcRecvUs ?? Math.floor(Date.now() * 1000);
|
|
96
|
+
const txIndex = options?.txIndex ?? 0;
|
|
93
97
|
const rb = recentBlockhashBytes(msg.recentBlockhash);
|
|
94
|
-
const
|
|
95
|
-
parseOuterAndInnerInstructions(msg, meta, signature, slot,
|
|
98
|
+
const instructionEvents = [];
|
|
99
|
+
parseOuterAndInnerInstructions(msg, meta, signature, slot, txIndex, blockTimeUs, grpcRecvUs, filter, instructionEvents);
|
|
100
|
+
const logEvents = [];
|
|
96
101
|
let isCreatedBuy = false;
|
|
97
102
|
for (const log of meta?.logMessages ?? []) {
|
|
98
|
-
const e = (0, optimized_matcher_js_1.parseLogOptimized)(log, signature, slot,
|
|
103
|
+
const e = (0, optimized_matcher_js_1.parseLogOptimized)(log, signature, slot, txIndex, blockTimeUs, grpcRecvUs, filter, isCreatedBuy, rb);
|
|
99
104
|
if (e) {
|
|
100
105
|
if ("PumpFunCreate" in e || "PumpFunCreateV2" in e)
|
|
101
106
|
isCreatedBuy = true;
|
|
102
|
-
|
|
107
|
+
logEvents.push(e);
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
|
-
applyRpcFills(
|
|
110
|
+
applyRpcFills(instructionEvents, msg, meta);
|
|
111
|
+
applyRpcFills(logEvents, msg, meta);
|
|
112
|
+
const events = (0, log_instr_dedup_js_1.dedupeLogInstructionEvents)(logEvents, instructionEvents);
|
|
113
|
+
(0, pumpfun_fee_enrich_js_1.enrichPumpfunSameTxPostMerge)(events);
|
|
106
114
|
return { ok: true, events };
|
|
107
115
|
}
|
|
108
116
|
var account_dispatcher_rpc_js_2 = require("./core/account_dispatcher_rpc.js");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V0 交易:从链上拉取 ALT 账户,拼出与运行时一致的完整账户 key 列表(静态 + 查找表展开)。
|
|
3
|
+
*/
|
|
4
|
+
import { AddressLookupTableAccount, Connection } from "@solana/web3.js";
|
|
5
|
+
import type { ShredWasmTx } from "./instruction_parse.js";
|
|
6
|
+
/** 批量拉取 ALT,供同一 Entry 内多笔交易复用 */
|
|
7
|
+
export declare function loadAddressLookupTableAccounts(connection: Connection, lookupTableAddresses: readonly string[]): Promise<Map<string, AddressLookupTableAccount>>;
|
|
8
|
+
/** 使用已拉取的 ALT 构造完整账户表(base58);失败时退回仅静态表 */
|
|
9
|
+
export declare function fullAccountKeyStringsFromShredTx(tx: ShredWasmTx, altByAddress: Map<string, AddressLookupTableAccount>): string[];
|
|
@@ -0,0 +1,70 @@
|
|
|
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.loadAddressLookupTableAccounts = loadAddressLookupTableAccounts;
|
|
7
|
+
exports.fullAccountKeyStringsFromShredTx = fullAccountKeyStringsFromShredTx;
|
|
8
|
+
/**
|
|
9
|
+
* V0 交易:从链上拉取 ALT 账户,拼出与运行时一致的完整账户 key 列表(静态 + 查找表展开)。
|
|
10
|
+
*/
|
|
11
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
12
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
13
|
+
/** 批量拉取 ALT,供同一 Entry 内多笔交易复用 */
|
|
14
|
+
async function loadAddressLookupTableAccounts(connection, lookupTableAddresses) {
|
|
15
|
+
const map = new Map();
|
|
16
|
+
if (lookupTableAddresses.length === 0)
|
|
17
|
+
return map;
|
|
18
|
+
const pks = lookupTableAddresses.map((s) => new web3_js_1.PublicKey(s));
|
|
19
|
+
const infos = await connection.getMultipleAccountsInfo(pks);
|
|
20
|
+
for (let i = 0; i < pks.length; i++) {
|
|
21
|
+
const info = infos[i];
|
|
22
|
+
if (!info?.data)
|
|
23
|
+
continue;
|
|
24
|
+
const state = web3_js_1.AddressLookupTableAccount.deserialize(info.data);
|
|
25
|
+
const alt = new web3_js_1.AddressLookupTableAccount({ key: pks[i], state });
|
|
26
|
+
map.set(pks[i].toBase58(), alt);
|
|
27
|
+
}
|
|
28
|
+
return map;
|
|
29
|
+
}
|
|
30
|
+
/** 使用已拉取的 ALT 构造完整账户表(base58);失败时退回仅静态表 */
|
|
31
|
+
function fullAccountKeyStringsFromShredTx(tx, altByAddress) {
|
|
32
|
+
if (tx.messageVersion !== "v0" || !tx.addressTableLookups?.length) {
|
|
33
|
+
return tx.accounts;
|
|
34
|
+
}
|
|
35
|
+
const lookups = tx.addressTableLookups;
|
|
36
|
+
const altAccounts = [];
|
|
37
|
+
for (const l of lookups) {
|
|
38
|
+
const alt = altByAddress.get(l.accountKey);
|
|
39
|
+
if (!alt) {
|
|
40
|
+
return tx.accounts;
|
|
41
|
+
}
|
|
42
|
+
altAccounts.push(alt);
|
|
43
|
+
}
|
|
44
|
+
const header = tx.header;
|
|
45
|
+
const rb = tx.recentBlockhash;
|
|
46
|
+
if (!header || !rb || rb.length !== 32) {
|
|
47
|
+
return tx.accounts;
|
|
48
|
+
}
|
|
49
|
+
const msg = new web3_js_1.MessageV0({
|
|
50
|
+
header,
|
|
51
|
+
staticAccountKeys: tx.accounts.map((s) => new web3_js_1.PublicKey(s)),
|
|
52
|
+
recentBlockhash: bs58_1.default.encode(rb),
|
|
53
|
+
compiledInstructions: (tx.instructions ?? []).map((ix) => ({
|
|
54
|
+
programIdIndex: ix.programIdIndex,
|
|
55
|
+
accountKeyIndexes: Array.from(ix.accounts),
|
|
56
|
+
data: Buffer.from(ix.data),
|
|
57
|
+
})),
|
|
58
|
+
addressTableLookups: lookups.map((l) => ({
|
|
59
|
+
accountKey: new web3_js_1.PublicKey(l.accountKey),
|
|
60
|
+
writableIndexes: Array.from(l.writableIndexes),
|
|
61
|
+
readonlyIndexes: Array.from(l.readonlyIndexes),
|
|
62
|
+
})),
|
|
63
|
+
});
|
|
64
|
+
const keys = msg.getAccountKeys({ addressLookupTableAccounts: altAccounts });
|
|
65
|
+
const out = [];
|
|
66
|
+
for (let i = 0; i < keys.length; i++) {
|
|
67
|
+
out.push(keys.get(i).toBase58());
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|