@subsquid/solana-normalization 0.0.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/lib/data.d.ts +124 -0
- package/lib/data.d.ts.map +1 -0
- package/lib/data.js +3 -0
- package/lib/data.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -0
- package/lib/log-parser.d.ts +55 -0
- package/lib/log-parser.d.ts.map +1 -0
- package/lib/log-parser.js +125 -0
- package/lib/log-parser.js.map +1 -0
- package/lib/mapping.d.ts +4 -0
- package/lib/mapping.d.ts.map +1 -0
- package/lib/mapping.js +424 -0
- package/lib/mapping.js.map +1 -0
- package/package.json +27 -0
- package/src/data.ts +154 -0
- package/src/index.ts +2 -0
- package/src/log-parser.ts +146 -0
- package/src/mapping.ts +535 -0
package/lib/mapping.js
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
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.mapRpcBlock = void 0;
|
|
7
|
+
const util_internal_1 = require("@subsquid/util-internal");
|
|
8
|
+
const assert_1 = __importDefault(require("assert"));
|
|
9
|
+
const log_parser_1 = require("./log-parser");
|
|
10
|
+
function mapRpcBlock(src) {
|
|
11
|
+
let header = {
|
|
12
|
+
hash: src.hash,
|
|
13
|
+
height: src.height,
|
|
14
|
+
slot: src.slot,
|
|
15
|
+
parentSlot: src.block.parentSlot,
|
|
16
|
+
parentHash: src.block.previousBlockhash,
|
|
17
|
+
timestamp: src.block.blockTime ?? 0
|
|
18
|
+
};
|
|
19
|
+
let instructions = [];
|
|
20
|
+
let logs = [];
|
|
21
|
+
let balances = [];
|
|
22
|
+
let tokenBalances = [];
|
|
23
|
+
let transactions = src.block.transactions
|
|
24
|
+
?.map((tx, i) => {
|
|
25
|
+
try {
|
|
26
|
+
return mapRpcTransaction(i, tx, instructions, logs, balances, tokenBalances);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw (0, util_internal_1.addErrorContext)(err, {
|
|
30
|
+
blockTransaction: tx.transaction.signatures[0]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}) ?? [];
|
|
34
|
+
let rewards = src.block.rewards?.map(s => {
|
|
35
|
+
let reward = {
|
|
36
|
+
pubkey: s.pubkey,
|
|
37
|
+
lamports: BigInt(s.lamports),
|
|
38
|
+
postBalance: BigInt(s.postBalance)
|
|
39
|
+
};
|
|
40
|
+
if (s.rewardType) {
|
|
41
|
+
reward.rewardType = s.rewardType;
|
|
42
|
+
}
|
|
43
|
+
if (s.commission != null) {
|
|
44
|
+
reward.commission = s.commission;
|
|
45
|
+
}
|
|
46
|
+
return reward;
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
header,
|
|
50
|
+
transactions,
|
|
51
|
+
instructions,
|
|
52
|
+
logs,
|
|
53
|
+
balances,
|
|
54
|
+
tokenBalances,
|
|
55
|
+
rewards: rewards || []
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.mapRpcBlock = mapRpcBlock;
|
|
59
|
+
function mapRpcTransaction(transactionIndex, src, instructions, logs, balances, tokenBalances) {
|
|
60
|
+
let tx = {
|
|
61
|
+
transactionIndex,
|
|
62
|
+
version: src.version,
|
|
63
|
+
accountKeys: src.transaction.message.accountKeys,
|
|
64
|
+
addressTableLookups: src.transaction.message.addressTableLookups ?? [],
|
|
65
|
+
numReadonlySignedAccounts: src.transaction.message.header.numReadonlySignedAccounts,
|
|
66
|
+
numReadonlyUnsignedAccounts: src.transaction.message.header.numReadonlyUnsignedAccounts,
|
|
67
|
+
numRequiredSignatures: src.transaction.message.header.numRequiredSignatures,
|
|
68
|
+
recentBlockhash: src.transaction.message.recentBlockhash,
|
|
69
|
+
signatures: src.transaction.signatures,
|
|
70
|
+
err: src.meta.err,
|
|
71
|
+
computeUnitsConsumed: BigInt(src.meta.computeUnitsConsumed ?? 0),
|
|
72
|
+
fee: BigInt(src.meta.fee),
|
|
73
|
+
loadedAddresses: src.meta.loadedAddresses ?? { readonly: [], writable: [] },
|
|
74
|
+
hasDroppedLogMessages: false
|
|
75
|
+
};
|
|
76
|
+
let accounts;
|
|
77
|
+
if (tx.version === 'legacy') {
|
|
78
|
+
accounts = tx.accountKeys;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
(0, assert_1.default)(src.meta?.loadedAddresses);
|
|
82
|
+
accounts = tx.accountKeys.concat(src.meta.loadedAddresses.writable, src.meta.loadedAddresses.readonly);
|
|
83
|
+
}
|
|
84
|
+
let getAccount = (index) => {
|
|
85
|
+
(0, assert_1.default)(index < accounts.length);
|
|
86
|
+
return accounts[index];
|
|
87
|
+
};
|
|
88
|
+
new InstructionParser(getAccount, tx, src, src.meta.logMessages?.map(log_parser_1.parseLogMessage), instructions, logs).parse();
|
|
89
|
+
balances.push(...mapBalances(getAccount, transactionIndex, src));
|
|
90
|
+
tokenBalances.push(...mapTokenBalances(getAccount, transactionIndex, src));
|
|
91
|
+
return tx;
|
|
92
|
+
}
|
|
93
|
+
const PROGRAMS_MISSING_INVOKE_LOG = new Set([
|
|
94
|
+
'AddressLookupTab1e1111111111111111111111111',
|
|
95
|
+
'BPFLoader1111111111111111111111111111111111',
|
|
96
|
+
'BPFLoader2111111111111111111111111111111111',
|
|
97
|
+
'BPFLoaderUpgradeab1e11111111111111111111111',
|
|
98
|
+
'Ed25519SigVerify111111111111111111111111111',
|
|
99
|
+
'KeccakSecp256k11111111111111111111111111111',
|
|
100
|
+
'NativeLoader1111111111111111111111111111111',
|
|
101
|
+
'ZkTokenProof1111111111111111111111111111111',
|
|
102
|
+
]);
|
|
103
|
+
class InstructionParser {
|
|
104
|
+
constructor(getAccount, tx, src, messages, instructions, logs) {
|
|
105
|
+
this.getAccount = getAccount;
|
|
106
|
+
this.tx = tx;
|
|
107
|
+
this.src = src;
|
|
108
|
+
this.instructions = instructions;
|
|
109
|
+
this.logs = logs;
|
|
110
|
+
this.pos = 0;
|
|
111
|
+
this.messagePos = 0;
|
|
112
|
+
this.messagesTruncated = false;
|
|
113
|
+
this.lastAddress = [];
|
|
114
|
+
if (messages == null) {
|
|
115
|
+
this.messages = [];
|
|
116
|
+
this.messagesTruncated = true;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.messages = messages;
|
|
120
|
+
}
|
|
121
|
+
let err = this.src.meta.err;
|
|
122
|
+
if (err) {
|
|
123
|
+
if ('InstructionError' in err) {
|
|
124
|
+
let pos = err['InstructionError'][0];
|
|
125
|
+
(0, assert_1.default)(typeof pos == 'number');
|
|
126
|
+
(0, assert_1.default)(0 <= pos && pos < this.src.transaction.message.instructions.length);
|
|
127
|
+
this.errorPos = pos;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
parse() {
|
|
132
|
+
while (this.pos < this.src.transaction.message.instructions.length) {
|
|
133
|
+
let instruction = this.src.transaction.message.instructions[this.pos];
|
|
134
|
+
let inner = this.src.meta.innerInstructions
|
|
135
|
+
?.filter(i => i.index === this.pos)
|
|
136
|
+
.flatMap(i => i.instructions) ?? [];
|
|
137
|
+
if (this.errorPos == null || this.errorPos >= this.pos) {
|
|
138
|
+
let instructions = [instruction].concat(inner);
|
|
139
|
+
let end = this.traverse(instructions, 0, 1);
|
|
140
|
+
(0, assert_1.default)(end == instructions.length);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.assert(inner.length == 0, false, 0, 'seemingly non-executed instruction has inner instructions');
|
|
144
|
+
this.push(1, instruction);
|
|
145
|
+
}
|
|
146
|
+
this.pos += 1;
|
|
147
|
+
}
|
|
148
|
+
this.tx.hasDroppedLogMessages = this.tx.hasDroppedLogMessages || this.messagesTruncated;
|
|
149
|
+
}
|
|
150
|
+
traverse(instructions, pos, stackHeight) {
|
|
151
|
+
this.assert(pos < instructions.length, true, 0, 'unexpected and of inner instructions');
|
|
152
|
+
let instruction = instructions[pos];
|
|
153
|
+
this.assert(instruction.stackHeight == null || instruction.stackHeight == stackHeight, false, pos, 'instruction has unexpected stack height');
|
|
154
|
+
let msg;
|
|
155
|
+
if (this.messagePos < this.messages.length) {
|
|
156
|
+
msg = this.messages[this.messagePos];
|
|
157
|
+
}
|
|
158
|
+
if (msg?.kind == 'truncate') {
|
|
159
|
+
this.messagePos += 1;
|
|
160
|
+
this.messagesTruncated = true;
|
|
161
|
+
}
|
|
162
|
+
if (this.messagesTruncated) {
|
|
163
|
+
this.push(stackHeight, instruction);
|
|
164
|
+
return this.logLessTraversal(stackHeight, instructions, pos + 1);
|
|
165
|
+
}
|
|
166
|
+
let programId = this.getAccount(instruction.programIdIndex);
|
|
167
|
+
if (msg?.kind === 'invoke' && msg.programId === programId) {
|
|
168
|
+
this.assert(msg.stackHeight == stackHeight, true, pos, 'invoke message has unexpected stack height');
|
|
169
|
+
this.messagePos += 1;
|
|
170
|
+
return this.invokeInstruction(stackHeight, instructions, pos);
|
|
171
|
+
}
|
|
172
|
+
if (PROGRAMS_MISSING_INVOKE_LOG.has(programId)) {
|
|
173
|
+
let dropped = this.dropInvokeLessInstructionMessages(pos);
|
|
174
|
+
let ins = this.push(stackHeight, instruction);
|
|
175
|
+
ins.hasDroppedLogMessages = ins.hasDroppedLogMessages || dropped;
|
|
176
|
+
this.tx.hasDroppedLogMessages = this.tx.hasDroppedLogMessages || dropped;
|
|
177
|
+
return this.invokeLessTraversal(dropped, stackHeight, instructions, pos + 1);
|
|
178
|
+
}
|
|
179
|
+
// FIXME: add an option to ignore this
|
|
180
|
+
throw this.error(true, pos, 'missing invoke message');
|
|
181
|
+
}
|
|
182
|
+
dropInvokeLessInstructionMessages(pos) {
|
|
183
|
+
let initialPos = this.messagePos;
|
|
184
|
+
while (this.messagePos < this.messages.length && !this.messagesTruncated) {
|
|
185
|
+
let msg = this.messages[this.messagePos];
|
|
186
|
+
switch (msg.kind) {
|
|
187
|
+
case 'log':
|
|
188
|
+
case 'data':
|
|
189
|
+
case 'cu':
|
|
190
|
+
case 'other':
|
|
191
|
+
this.messagePos += 1;
|
|
192
|
+
break;
|
|
193
|
+
case 'truncate':
|
|
194
|
+
this.messagePos += 1;
|
|
195
|
+
this.messagesTruncated = true;
|
|
196
|
+
return true;
|
|
197
|
+
case 'invoke':
|
|
198
|
+
return this.messagePos - initialPos > 0;
|
|
199
|
+
case 'invoke-result':
|
|
200
|
+
throw this.error(true, pos, `invoke result message does not match any invoke`);
|
|
201
|
+
default:
|
|
202
|
+
throw (0, util_internal_1.unexpectedCase)();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
invokeInstruction(stackHeight, instructions, instructionPos) {
|
|
208
|
+
let ins = this.push(stackHeight, instructions[instructionPos]);
|
|
209
|
+
let pos = instructionPos + 1;
|
|
210
|
+
while (true) {
|
|
211
|
+
let token = this.takeInstructionMessages(ins, instructionPos);
|
|
212
|
+
switch (token.kind) {
|
|
213
|
+
case 'invoke':
|
|
214
|
+
pos = this.traverse(instructions, pos, stackHeight + 1);
|
|
215
|
+
break;
|
|
216
|
+
case 'invoke-result':
|
|
217
|
+
if (token.programId != ins.programId) {
|
|
218
|
+
throw this.error(true, instructionPos, `invoke result message and instruction program ids don't match`);
|
|
219
|
+
}
|
|
220
|
+
if (token.error) {
|
|
221
|
+
ins.error = token.error;
|
|
222
|
+
}
|
|
223
|
+
pos = this.invokeLessTraversal(true, stackHeight, instructions, pos);
|
|
224
|
+
this.messagePos += 1;
|
|
225
|
+
return pos;
|
|
226
|
+
case 'truncate':
|
|
227
|
+
ins.hasDroppedLogMessages = true;
|
|
228
|
+
return this.logLessTraversal(stackHeight, instructions, pos);
|
|
229
|
+
default:
|
|
230
|
+
throw (0, util_internal_1.unexpectedCase)();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
takeInstructionMessages(ins, pos) {
|
|
235
|
+
if (this.messagesTruncated)
|
|
236
|
+
return new log_parser_1.LogTruncatedMessage();
|
|
237
|
+
while (this.messagePos < this.messages.length) {
|
|
238
|
+
let msg = this.messages[this.messagePos];
|
|
239
|
+
switch (msg.kind) {
|
|
240
|
+
case 'log':
|
|
241
|
+
case 'data':
|
|
242
|
+
case 'other':
|
|
243
|
+
this.logs.push({
|
|
244
|
+
transactionIndex: ins.transactionIndex,
|
|
245
|
+
logIndex: this.messagePos,
|
|
246
|
+
instructionAddress: ins.instructionAddress,
|
|
247
|
+
programId: ins.programId,
|
|
248
|
+
kind: msg.kind,
|
|
249
|
+
message: msg.message
|
|
250
|
+
});
|
|
251
|
+
break;
|
|
252
|
+
case 'cu':
|
|
253
|
+
if (ins.programId != msg.programId) {
|
|
254
|
+
throw this.error(true, pos, 'unexpected programId in compute unit message');
|
|
255
|
+
}
|
|
256
|
+
ins.computeUnitsConsumed = msg.consumed;
|
|
257
|
+
break;
|
|
258
|
+
case 'invoke':
|
|
259
|
+
case 'invoke-result':
|
|
260
|
+
return msg;
|
|
261
|
+
case 'truncate':
|
|
262
|
+
this.messagesTruncated = true;
|
|
263
|
+
this.messagePos += 1;
|
|
264
|
+
return msg;
|
|
265
|
+
default:
|
|
266
|
+
throw (0, util_internal_1.unexpectedCase)();
|
|
267
|
+
}
|
|
268
|
+
this.messagePos += 1;
|
|
269
|
+
}
|
|
270
|
+
throw this.error(false, pos, 'unexpected end of log messages');
|
|
271
|
+
}
|
|
272
|
+
invokeLessTraversal(messagesDropped, parentStackHeight, instructions, pos) {
|
|
273
|
+
return this.logLessTraversal(parentStackHeight, instructions, pos, (ins, pos) => {
|
|
274
|
+
ins.hasDroppedLogMessages = ins.hasDroppedLogMessages || messagesDropped;
|
|
275
|
+
if (PROGRAMS_MISSING_INVOKE_LOG.has(ins.programId)) {
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
throw this.error(false, pos, 'invoke message is missing');
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
logLessTraversal(parentStackHeight, instructions, pos, cb) {
|
|
283
|
+
while (pos < instructions.length) {
|
|
284
|
+
let instruction = instructions[pos];
|
|
285
|
+
let stackHeight = instruction.stackHeight ?? 2;
|
|
286
|
+
if (stackHeight > parentStackHeight) {
|
|
287
|
+
let ins = this.push(stackHeight, instruction);
|
|
288
|
+
cb?.(ins, pos);
|
|
289
|
+
pos += 1;
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
return pos;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return pos;
|
|
296
|
+
}
|
|
297
|
+
push(stackHeight, src) {
|
|
298
|
+
(0, assert_1.default)(stackHeight > 0);
|
|
299
|
+
if (src.stackHeight != null) {
|
|
300
|
+
(0, assert_1.default)(stackHeight === src.stackHeight);
|
|
301
|
+
}
|
|
302
|
+
let address = this.lastAddress.slice();
|
|
303
|
+
while (address.length > stackHeight) {
|
|
304
|
+
address.pop();
|
|
305
|
+
}
|
|
306
|
+
if (address.length === stackHeight) {
|
|
307
|
+
address[stackHeight - 1] += 1;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
(0, assert_1.default)(address.length + 1 == stackHeight);
|
|
311
|
+
address[stackHeight - 1] = 0;
|
|
312
|
+
}
|
|
313
|
+
let i = {
|
|
314
|
+
transactionIndex: this.tx.transactionIndex,
|
|
315
|
+
instructionAddress: address,
|
|
316
|
+
programId: this.getAccount(src.programIdIndex),
|
|
317
|
+
accounts: src.accounts.map(a => this.getAccount(a)),
|
|
318
|
+
data: src.data,
|
|
319
|
+
isCommitted: !this.tx.err,
|
|
320
|
+
hasDroppedLogMessages: this.messagesTruncated
|
|
321
|
+
};
|
|
322
|
+
this.instructions.push(i);
|
|
323
|
+
this.lastAddress = address;
|
|
324
|
+
return i;
|
|
325
|
+
}
|
|
326
|
+
assert(ok, withMessagePos, innerPos, msg) {
|
|
327
|
+
if (!ok)
|
|
328
|
+
throw this.error(withMessagePos, innerPos, msg);
|
|
329
|
+
}
|
|
330
|
+
error(withMessagePos, innerPos, msg) {
|
|
331
|
+
let loc = `stopped at instruction ${this.pos}`;
|
|
332
|
+
if (innerPos > 0) {
|
|
333
|
+
loc += `, inner instruction ${innerPos - 1})`;
|
|
334
|
+
}
|
|
335
|
+
if (withMessagePos && this.messagePos < this.messages.length) {
|
|
336
|
+
loc += ` and log message ${this.messagePos}`;
|
|
337
|
+
}
|
|
338
|
+
return new Error(`Failed to process transaction ${this.tx.signatures[0]}: ${loc}: ${msg}`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function mapBalances(getAccount, transactionIndex, tx) {
|
|
342
|
+
let balances = [];
|
|
343
|
+
let pre = tx.meta.preBalances;
|
|
344
|
+
let post = tx.meta.postBalances;
|
|
345
|
+
(0, assert_1.default)(pre.length == post.length);
|
|
346
|
+
for (let i = 0; i < pre.length; i++) {
|
|
347
|
+
if (pre[i] === post[i]) {
|
|
348
|
+
// nothing changed, don't create an entry
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
balances.push({
|
|
352
|
+
transactionIndex,
|
|
353
|
+
account: getAccount(i),
|
|
354
|
+
pre: BigInt(pre[i]),
|
|
355
|
+
post: BigInt(post[i])
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
balances.sort((a, b) => {
|
|
360
|
+
if (a.account < b.account)
|
|
361
|
+
return -1;
|
|
362
|
+
if (a.account > b.account)
|
|
363
|
+
return 1;
|
|
364
|
+
return 0;
|
|
365
|
+
});
|
|
366
|
+
return balances;
|
|
367
|
+
}
|
|
368
|
+
function mapTokenBalances(getAccount, transactionIndex, tx) {
|
|
369
|
+
let balances = [];
|
|
370
|
+
let preBalances = new Map(tx.meta.preTokenBalances?.map(b => [getAccount(b.accountIndex), b]));
|
|
371
|
+
let postBalances = new Map(tx.meta.postTokenBalances?.map(b => [getAccount(b.accountIndex), b]));
|
|
372
|
+
for (let [account, post] of postBalances.entries()) {
|
|
373
|
+
let pre = preBalances.get(account);
|
|
374
|
+
if (pre) {
|
|
375
|
+
balances.push({
|
|
376
|
+
transactionIndex,
|
|
377
|
+
account,
|
|
378
|
+
preProgramId: pre.programId ?? undefined,
|
|
379
|
+
preMint: pre.mint,
|
|
380
|
+
preDecimals: pre.uiTokenAmount.decimals,
|
|
381
|
+
preOwner: pre.owner ?? undefined,
|
|
382
|
+
preAmount: BigInt(pre.uiTokenAmount.amount),
|
|
383
|
+
postProgramId: post.programId ?? undefined,
|
|
384
|
+
postMint: post.mint,
|
|
385
|
+
postDecimals: post.uiTokenAmount.decimals,
|
|
386
|
+
postOwner: post.owner ?? undefined,
|
|
387
|
+
postAmount: BigInt(post.uiTokenAmount.amount)
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
balances.push({
|
|
392
|
+
transactionIndex,
|
|
393
|
+
account,
|
|
394
|
+
postProgramId: post.programId ?? undefined,
|
|
395
|
+
postMint: post.mint,
|
|
396
|
+
postDecimals: post.uiTokenAmount.decimals,
|
|
397
|
+
postOwner: post.owner ?? undefined,
|
|
398
|
+
postAmount: BigInt(post.uiTokenAmount.amount)
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
for (let [account, pre] of preBalances.entries()) {
|
|
403
|
+
if (postBalances.has(account))
|
|
404
|
+
continue;
|
|
405
|
+
balances.push({
|
|
406
|
+
transactionIndex,
|
|
407
|
+
account,
|
|
408
|
+
preProgramId: pre.programId ?? undefined,
|
|
409
|
+
preMint: pre.mint,
|
|
410
|
+
preDecimals: pre.uiTokenAmount.decimals,
|
|
411
|
+
preOwner: pre.owner ?? undefined,
|
|
412
|
+
preAmount: BigInt(pre.uiTokenAmount.amount)
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
balances.sort((a, b) => {
|
|
416
|
+
if (a.account < b.account)
|
|
417
|
+
return -1;
|
|
418
|
+
if (a.account > b.account)
|
|
419
|
+
return 1;
|
|
420
|
+
return 0;
|
|
421
|
+
});
|
|
422
|
+
return balances;
|
|
423
|
+
}
|
|
424
|
+
//# sourceMappingURL=mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping.js","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":";;;;;;AAEA,2DAAuE;AACvE,oDAA2B;AAE3B,6CAA8G;AAG9G,SAAgB,WAAW,CAAC,GAAc;IACtC,IAAI,MAAM,GAAgB;QACtB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,UAAU;QAChC,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,iBAAiB;QACvC,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC;KACtC,CAAA;IAED,IAAI,YAAY,GAAkB,EAAE,CAAA;IACpC,IAAI,IAAI,GAAiB,EAAE,CAAA;IAC3B,IAAI,QAAQ,GAAc,EAAE,CAAA;IAC5B,IAAI,aAAa,GAAmB,EAAE,CAAA;IAEtC,IAAI,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY;QACrC,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;QACZ,IAAI,CAAC;YACD,OAAO,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;QAChF,CAAC;QAAC,OAAM,GAAQ,EAAE,CAAC;YACf,MAAM,IAAA,+BAAe,EAAC,GAAG,EAAE;gBACvB,gBAAgB,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;aACjD,CAAC,CAAA;QACN,CAAC;IACL,CAAC,CA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0-or-later",
|
|
6
|
+
"repository": "git@github.com:subsquid/squid.git",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@subsquid/solana-rpc-data": "^0.0.0",
|
|
17
|
+
"@subsquid/util-internal": "^3.2.0",
|
|
18
|
+
"@subsquid/util-internal-validation": "^0.4.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^18.18.14",
|
|
22
|
+
"typescript": "~5.3.2"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "rm -rf lib && tsc"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/data.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type {Base58Bytes} from '@subsquid/solana-rpc-data'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export interface BlockHeader {
|
|
5
|
+
hash: Base58Bytes
|
|
6
|
+
height: number
|
|
7
|
+
slot: number
|
|
8
|
+
parentSlot: number
|
|
9
|
+
parentHash: Base58Bytes
|
|
10
|
+
timestamp: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export interface Transaction {
|
|
15
|
+
/**
|
|
16
|
+
* Transaction position in block
|
|
17
|
+
*/
|
|
18
|
+
transactionIndex: number
|
|
19
|
+
version: 'legacy' | number
|
|
20
|
+
// transaction message
|
|
21
|
+
accountKeys: Base58Bytes[]
|
|
22
|
+
addressTableLookups: AddressTableLookup[]
|
|
23
|
+
numReadonlySignedAccounts: number
|
|
24
|
+
numReadonlyUnsignedAccounts: number
|
|
25
|
+
numRequiredSignatures: number
|
|
26
|
+
recentBlockhash: Base58Bytes
|
|
27
|
+
signatures: Base58Bytes[]
|
|
28
|
+
// meta fields
|
|
29
|
+
err: null | object
|
|
30
|
+
computeUnitsConsumed: bigint
|
|
31
|
+
fee: bigint
|
|
32
|
+
loadedAddresses: {
|
|
33
|
+
readonly: Base58Bytes[]
|
|
34
|
+
writable: Base58Bytes[]
|
|
35
|
+
}
|
|
36
|
+
hasDroppedLogMessages: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
export interface AddressTableLookup {
|
|
41
|
+
accountKey: Base58Bytes
|
|
42
|
+
readonlyIndexes: number[]
|
|
43
|
+
writableIndexes: number[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
export interface Instruction {
|
|
48
|
+
transactionIndex: number
|
|
49
|
+
instructionAddress: number[]
|
|
50
|
+
programId: Base58Bytes
|
|
51
|
+
accounts: Base58Bytes[]
|
|
52
|
+
data: Base58Bytes
|
|
53
|
+
// execution result extracted from logs
|
|
54
|
+
computeUnitsConsumed?: bigint
|
|
55
|
+
error?: string
|
|
56
|
+
/**
|
|
57
|
+
* `true` when transaction completed successfully, `false` otherwise
|
|
58
|
+
*/
|
|
59
|
+
isCommitted: boolean
|
|
60
|
+
hasDroppedLogMessages: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
export interface LogMessage {
|
|
65
|
+
transactionIndex: number
|
|
66
|
+
logIndex: number
|
|
67
|
+
instructionAddress: number[]
|
|
68
|
+
programId: Base58Bytes
|
|
69
|
+
kind: 'log' | 'data' | 'other'
|
|
70
|
+
message: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
export interface Balance {
|
|
75
|
+
transactionIndex: number
|
|
76
|
+
account: Base58Bytes
|
|
77
|
+
pre: bigint
|
|
78
|
+
post: bigint
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
export type TokenBalance = PreTokenBalance | PostTokenBalance | PrePostTokenBalance
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export interface PreTokenBalance {
|
|
86
|
+
transactionIndex: number
|
|
87
|
+
account: Base58Bytes
|
|
88
|
+
|
|
89
|
+
preProgramId?: Base58Bytes
|
|
90
|
+
preMint: Base58Bytes
|
|
91
|
+
preDecimals: number
|
|
92
|
+
preOwner?: Base58Bytes
|
|
93
|
+
preAmount: bigint
|
|
94
|
+
|
|
95
|
+
postProgramId?: undefined
|
|
96
|
+
postMint?: undefined
|
|
97
|
+
postDecimals?: undefined
|
|
98
|
+
postOwner?: undefined
|
|
99
|
+
postAmount?: undefined
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
export interface PostTokenBalance {
|
|
104
|
+
transactionIndex: number
|
|
105
|
+
account: Base58Bytes
|
|
106
|
+
|
|
107
|
+
preProgramId?: undefined
|
|
108
|
+
preMint?: undefined
|
|
109
|
+
preDecimals?: undefined
|
|
110
|
+
preOwner?: undefined
|
|
111
|
+
preAmount?: undefined
|
|
112
|
+
|
|
113
|
+
postProgramId?: Base58Bytes
|
|
114
|
+
postMint: Base58Bytes
|
|
115
|
+
postDecimals: number
|
|
116
|
+
postOwner?: Base58Bytes
|
|
117
|
+
postAmount: bigint
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
export interface PrePostTokenBalance {
|
|
122
|
+
transactionIndex: number
|
|
123
|
+
account: Base58Bytes
|
|
124
|
+
preProgramId?: Base58Bytes
|
|
125
|
+
preMint: Base58Bytes
|
|
126
|
+
preDecimals: number
|
|
127
|
+
preOwner?: Base58Bytes
|
|
128
|
+
preAmount: bigint
|
|
129
|
+
postProgramId?: Base58Bytes
|
|
130
|
+
postMint: Base58Bytes
|
|
131
|
+
postDecimals: number
|
|
132
|
+
postOwner?: Base58Bytes
|
|
133
|
+
postAmount: bigint
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
export interface Reward {
|
|
138
|
+
pubkey: Base58Bytes
|
|
139
|
+
lamports: bigint
|
|
140
|
+
postBalance: bigint
|
|
141
|
+
rewardType?: string
|
|
142
|
+
commission?: number
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
export interface Block {
|
|
147
|
+
header: BlockHeader
|
|
148
|
+
transactions: Transaction[]
|
|
149
|
+
instructions: Instruction[]
|
|
150
|
+
logs: LogMessage[]
|
|
151
|
+
balances: Balance[]
|
|
152
|
+
tokenBalances: TokenBalance[]
|
|
153
|
+
rewards: Reward[]
|
|
154
|
+
}
|
package/src/index.ts
ADDED