@subsquid/solana-stream 0.2.0-2-0.a5e4b7 → 0.2.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/README.md +4 -0
- package/lib/{schema.d.ts → archive/schema.d.ts} +22 -32
- package/lib/archive/schema.d.ts.map +1 -0
- package/lib/{schema.js → archive/schema.js} +39 -55
- package/lib/archive/schema.js.map +1 -0
- package/lib/archive/source.d.ts +15 -0
- package/lib/archive/source.d.ts.map +1 -0
- package/lib/archive/source.js +98 -0
- package/lib/archive/source.js.map +1 -0
- package/lib/data/fields.d.ts +8 -0
- package/lib/data/fields.d.ts.map +1 -0
- package/lib/data/fields.js +46 -0
- package/lib/data/fields.js.map +1 -0
- package/lib/data/model.d.ts +79 -0
- package/lib/data/model.d.ts.map +1 -0
- package/lib/data/model.js +44 -0
- package/lib/data/model.js.map +1 -0
- package/lib/data/partial.d.ts +26 -0
- package/lib/data/partial.d.ts.map +1 -0
- package/lib/data/partial.js +3 -0
- package/lib/data/partial.js.map +1 -0
- package/lib/data/request.d.ts +108 -0
- package/lib/data/request.d.ts.map +1 -0
- package/lib/data/request.js +3 -0
- package/lib/data/request.js.map +1 -0
- package/lib/data/type-util.d.ts +20 -0
- package/lib/data/type-util.d.ts.map +1 -0
- package/lib/data/type-util.js +3 -0
- package/lib/data/type-util.js.map +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/instruction.d.ts +3 -2
- package/lib/instruction.d.ts.map +1 -1
- package/lib/instruction.js +2 -2
- package/lib/instruction.js.map +1 -1
- package/lib/rpc/client.d.ts +17 -0
- package/lib/rpc/client.d.ts.map +1 -0
- package/lib/rpc/client.js +15 -0
- package/lib/rpc/client.js.map +1 -0
- package/lib/rpc/filter.d.ts +4 -0
- package/lib/rpc/filter.d.ts.map +1 -0
- package/lib/rpc/filter.js +357 -0
- package/lib/rpc/filter.js.map +1 -0
- package/lib/rpc/mapping.d.ts +5 -0
- package/lib/rpc/mapping.d.ts.map +1 -0
- package/lib/rpc/mapping.js +12 -0
- package/lib/rpc/mapping.js.map +1 -0
- package/lib/rpc/project.d.ts +5 -0
- package/lib/rpc/project.d.ts.map +1 -0
- package/lib/rpc/project.js +60 -0
- package/lib/rpc/project.js.map +1 -0
- package/lib/rpc/source.d.ts +15 -0
- package/lib/rpc/source.d.ts.map +1 -0
- package/lib/rpc/source.js +82 -0
- package/lib/rpc/source.js.map +1 -0
- package/lib/source.d.ts +101 -17
- package/lib/source.d.ts.map +1 -1
- package/lib/source.js +269 -70
- package/lib/source.js.map +1 -1
- package/package.json +15 -9
- package/src/{schema.ts → archive/schema.ts} +35 -54
- package/src/archive/source.ts +105 -0
- package/src/data/fields.ts +50 -0
- package/src/data/model.ts +154 -0
- package/src/data/partial.ts +31 -0
- package/src/data/request.ts +142 -0
- package/src/data/type-util.ts +42 -0
- package/src/index.ts +3 -3
- package/src/instruction.ts +9 -4
- package/src/rpc/client.ts +26 -0
- package/src/rpc/filter.ts +368 -0
- package/src/rpc/mapping.ts +13 -0
- package/src/rpc/project.ts +61 -0
- package/src/rpc/source.ts +90 -0
- package/src/source.ts +368 -92
- package/lib/objects/index.d.ts +0 -4
- package/lib/objects/index.d.ts.map +0 -1
- package/lib/objects/index.js +0 -23
- package/lib/objects/index.js.map +0 -1
- package/lib/objects/items.d.ts +0 -83
- package/lib/objects/items.d.ts.map +0 -1
- package/lib/objects/items.js +0 -260
- package/lib/objects/items.js.map +0 -1
- package/lib/objects/relations.d.ts +0 -3
- package/lib/objects/relations.d.ts.map +0 -1
- package/lib/objects/relations.js +0 -82
- package/lib/objects/relations.js.map +0 -1
- package/lib/objects/types.d.ts +0 -76
- package/lib/objects/types.d.ts.map +0 -1
- package/lib/objects/types.js +0 -29
- package/lib/objects/types.js.map +0 -1
- package/lib/query.d.ts +0 -46
- package/lib/query.d.ts.map +0 -1
- package/lib/query.js +0 -96
- package/lib/query.js.map +0 -1
- package/lib/schema.d.ts.map +0 -1
- package/lib/schema.js.map +0 -1
- package/src/objects/index.ts +0 -3
- package/src/objects/items.ts +0 -296
- package/src/objects/relations.ts +0 -90
- package/src/objects/types.ts +0 -88
- package/src/query.ts +0 -149
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.filterBlockItems = filterBlockItems;
|
|
16
|
+
const util_internal_1 = require("@subsquid/util-internal");
|
|
17
|
+
const util_internal_processor_tools_1 = require("@subsquid/util-internal-processor-tools");
|
|
18
|
+
const assert_1 = __importDefault(require("assert"));
|
|
19
|
+
const instruction_1 = require("../instruction");
|
|
20
|
+
function buildTransactionFilter(dataRequest) {
|
|
21
|
+
let items = new util_internal_processor_tools_1.EntityFilter();
|
|
22
|
+
for (let req of dataRequest.transactions ?? []) {
|
|
23
|
+
let filter = new util_internal_processor_tools_1.FilterBuilder();
|
|
24
|
+
let where = req.where || {};
|
|
25
|
+
filter.getIn(tx => tx.accountKeys[0], where.feePayer);
|
|
26
|
+
items.add(filter, req.include || {});
|
|
27
|
+
}
|
|
28
|
+
return items;
|
|
29
|
+
}
|
|
30
|
+
function buildInstructionFilter(dataRequest) {
|
|
31
|
+
let items = new util_internal_processor_tools_1.EntityFilter();
|
|
32
|
+
for (let req of dataRequest.instructions ?? []) {
|
|
33
|
+
let filter = new util_internal_processor_tools_1.FilterBuilder();
|
|
34
|
+
let where = req.where || {};
|
|
35
|
+
filter.propIn('programId', where.programId);
|
|
36
|
+
filter.matchAny((i, d) => (0, instruction_1.getInstructionDescriptor)(i).startsWith(d), where.d1);
|
|
37
|
+
filter.matchAny((i, d) => (0, instruction_1.getInstructionDescriptor)(i).startsWith(d), where.d2);
|
|
38
|
+
filter.matchAny((i, d) => (0, instruction_1.getInstructionDescriptor)(i).startsWith(d), where.d4);
|
|
39
|
+
filter.getIn(instruction_1.getInstructionDescriptor, where.d8);
|
|
40
|
+
filter.getIn(i => i.accounts[0], where.a0);
|
|
41
|
+
filter.getIn(i => i.accounts[1], where.a1);
|
|
42
|
+
filter.getIn(i => i.accounts[2], where.a2);
|
|
43
|
+
filter.getIn(i => i.accounts[3], where.a3);
|
|
44
|
+
filter.getIn(i => i.accounts[4], where.a4);
|
|
45
|
+
filter.getIn(i => i.accounts[5], where.a5);
|
|
46
|
+
filter.getIn(i => i.accounts[6], where.a6);
|
|
47
|
+
filter.getIn(i => i.accounts[7], where.a7);
|
|
48
|
+
filter.getIn(i => i.accounts[8], where.a8);
|
|
49
|
+
filter.getIn(i => i.accounts[9], where.a9);
|
|
50
|
+
if (where.isCommitted != null) {
|
|
51
|
+
filter.propIn('isCommitted', [where.isCommitted]);
|
|
52
|
+
}
|
|
53
|
+
items.add(filter, req.include ?? {});
|
|
54
|
+
}
|
|
55
|
+
return items;
|
|
56
|
+
}
|
|
57
|
+
function buildLogFilter(dataRequest) {
|
|
58
|
+
let items = new util_internal_processor_tools_1.EntityFilter();
|
|
59
|
+
for (let req of dataRequest.logs ?? []) {
|
|
60
|
+
let filter = new util_internal_processor_tools_1.FilterBuilder();
|
|
61
|
+
let where = req.where ?? {};
|
|
62
|
+
filter.propIn('programId', where.programId);
|
|
63
|
+
filter.propIn('kind', where.kind);
|
|
64
|
+
items.add(filter, req.include ?? {});
|
|
65
|
+
}
|
|
66
|
+
return items;
|
|
67
|
+
}
|
|
68
|
+
function buildBalanceFilter(dataRequest) {
|
|
69
|
+
let items = new util_internal_processor_tools_1.EntityFilter();
|
|
70
|
+
for (let req of dataRequest.balances ?? []) {
|
|
71
|
+
let filter = new util_internal_processor_tools_1.FilterBuilder();
|
|
72
|
+
let where = req.where || {};
|
|
73
|
+
filter.propIn('account', where.account);
|
|
74
|
+
items.add(filter, req.include || {});
|
|
75
|
+
}
|
|
76
|
+
return items;
|
|
77
|
+
}
|
|
78
|
+
function buildTokenBalanceFilter(dataRequest) {
|
|
79
|
+
let items = new util_internal_processor_tools_1.EntityFilter();
|
|
80
|
+
for (let req of dataRequest.tokenBalances ?? []) {
|
|
81
|
+
let filter = new util_internal_processor_tools_1.FilterBuilder();
|
|
82
|
+
let where = req.where || {};
|
|
83
|
+
filter.propIn('account', where.account);
|
|
84
|
+
filter.propIn('preProgramId', where.preProgramId);
|
|
85
|
+
filter.propIn('postProgramId', where.postProgramId);
|
|
86
|
+
filter.propIn('preMint', where.preMint);
|
|
87
|
+
filter.propIn('postMint', where.postMint);
|
|
88
|
+
filter.propIn('preOwner', where.preOwner);
|
|
89
|
+
filter.propIn('postOwner', where.postOwner);
|
|
90
|
+
items.add(filter, req.include || {});
|
|
91
|
+
}
|
|
92
|
+
return items;
|
|
93
|
+
}
|
|
94
|
+
function buildRewardsFilter(dataRequest) {
|
|
95
|
+
let items = new util_internal_processor_tools_1.EntityFilter();
|
|
96
|
+
for (let req of dataRequest.rewards ?? []) {
|
|
97
|
+
let filter = new util_internal_processor_tools_1.FilterBuilder();
|
|
98
|
+
let where = req.where || {};
|
|
99
|
+
filter.propIn('pubkey', where.pubkey);
|
|
100
|
+
items.add(filter, {});
|
|
101
|
+
}
|
|
102
|
+
return items;
|
|
103
|
+
}
|
|
104
|
+
const getItemFilters = (0, util_internal_1.weakMemo)((req) => {
|
|
105
|
+
return {
|
|
106
|
+
transactions: buildTransactionFilter(req),
|
|
107
|
+
instructions: buildInstructionFilter(req),
|
|
108
|
+
logs: buildLogFilter(req),
|
|
109
|
+
balances: buildBalanceFilter(req),
|
|
110
|
+
tokenBalances: buildTokenBalanceFilter(req),
|
|
111
|
+
rewards: buildRewardsFilter(req)
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
class IncludeSet {
|
|
115
|
+
constructor() {
|
|
116
|
+
this.transactions = new Set;
|
|
117
|
+
this.instructions = new Set;
|
|
118
|
+
this.logs = new Set;
|
|
119
|
+
this.balances = new Set;
|
|
120
|
+
this.tokenBalances = new Set;
|
|
121
|
+
this.rewards = new Set;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function filterBlockItems(block, req) {
|
|
125
|
+
new BlockFilter(block, req).apply();
|
|
126
|
+
}
|
|
127
|
+
class BlockFilter {
|
|
128
|
+
constructor(block, req) {
|
|
129
|
+
this.block = block;
|
|
130
|
+
this.include = new IncludeSet();
|
|
131
|
+
this.items = getItemFilters(req);
|
|
132
|
+
}
|
|
133
|
+
transactions() {
|
|
134
|
+
return new Map(this.block.transactions.map(tx => [tx.transactionIndex, tx]));
|
|
135
|
+
}
|
|
136
|
+
getTransaction(idx) {
|
|
137
|
+
let tx = this.transactions().get(idx);
|
|
138
|
+
(0, assert_1.default)(tx);
|
|
139
|
+
return tx;
|
|
140
|
+
}
|
|
141
|
+
logsByTx() {
|
|
142
|
+
return (0, util_internal_1.groupBy)(this.block.logs, log => log.transactionIndex);
|
|
143
|
+
}
|
|
144
|
+
instructionsByTx() {
|
|
145
|
+
return (0, util_internal_1.groupBy)(this.block.instructions, i => i.transactionIndex);
|
|
146
|
+
}
|
|
147
|
+
balancesByTx() {
|
|
148
|
+
return (0, util_internal_1.groupBy)(this.block.balances, b => b.transactionIndex);
|
|
149
|
+
}
|
|
150
|
+
tokenBalancesByTx() {
|
|
151
|
+
return (0, util_internal_1.groupBy)(this.block.tokenBalances, b => b.transactionIndex);
|
|
152
|
+
}
|
|
153
|
+
filterTransactions() {
|
|
154
|
+
if (!this.items.transactions.present())
|
|
155
|
+
return;
|
|
156
|
+
for (let tx of this.block.transactions) {
|
|
157
|
+
let rel = this.items.transactions.match(tx);
|
|
158
|
+
if (rel == null)
|
|
159
|
+
continue;
|
|
160
|
+
this.include.transactions.add(tx);
|
|
161
|
+
if (rel.logs) {
|
|
162
|
+
include(this.include.logs, this.logsByTx().get(tx.transactionIndex));
|
|
163
|
+
}
|
|
164
|
+
if (rel.instructions) {
|
|
165
|
+
include(this.include.instructions, this.instructionsByTx().get(tx.transactionIndex));
|
|
166
|
+
}
|
|
167
|
+
if (rel.balances) {
|
|
168
|
+
include(this.include.balances, this.balancesByTx().get(tx.transactionIndex));
|
|
169
|
+
}
|
|
170
|
+
if (rel.tokenBalances) {
|
|
171
|
+
include(this.include.tokenBalances, this.tokenBalancesByTx().get(tx.transactionIndex));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
filterInstructions() {
|
|
176
|
+
if (!this.items.instructions.present())
|
|
177
|
+
return;
|
|
178
|
+
for (let i = 0; i < this.block.instructions.length; i++) {
|
|
179
|
+
let ins = this.block.instructions[i];
|
|
180
|
+
let rel = this.items.instructions.match(ins);
|
|
181
|
+
if (rel == null)
|
|
182
|
+
continue;
|
|
183
|
+
this.include.instructions.add(ins);
|
|
184
|
+
if (rel.innerInstructions) {
|
|
185
|
+
for (let j = i + 1; j < this.block.instructions.length; j++) {
|
|
186
|
+
let child = this.block.instructions[j];
|
|
187
|
+
if (ins.transactionIndex == child.transactionIndex &&
|
|
188
|
+
isChildAddress(ins.instructionAddress, child.instructionAddress)) {
|
|
189
|
+
this.include.instructions.add(child);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (rel.logs) {
|
|
197
|
+
let logs = this.logsByTx().get(ins.transactionIndex) ?? [];
|
|
198
|
+
include(this.include.logs, findInstructionChildren(logs, ins.instructionAddress));
|
|
199
|
+
}
|
|
200
|
+
if (rel.transaction) {
|
|
201
|
+
this.include.transactions.add(this.getTransaction(ins.transactionIndex));
|
|
202
|
+
}
|
|
203
|
+
if (rel.transactionBalances) {
|
|
204
|
+
include(this.include.balances, this.balancesByTx().get(ins.transactionIndex));
|
|
205
|
+
}
|
|
206
|
+
if (rel.transactionTokenBalances) {
|
|
207
|
+
include(this.include.tokenBalances, this.tokenBalancesByTx().get(ins.transactionIndex));
|
|
208
|
+
}
|
|
209
|
+
if (rel.transactionInstructions) {
|
|
210
|
+
include(this.include.instructions, this.instructionsByTx().get(ins.transactionIndex));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
filterLogs() {
|
|
215
|
+
if (!this.items.logs.present())
|
|
216
|
+
return;
|
|
217
|
+
for (let log of this.block.logs) {
|
|
218
|
+
let rel = this.items.logs.match(log);
|
|
219
|
+
if (rel == null)
|
|
220
|
+
continue;
|
|
221
|
+
this.include.logs.add(log);
|
|
222
|
+
if (rel.transaction) {
|
|
223
|
+
this.include.transactions.add(this.getTransaction(log.transactionIndex));
|
|
224
|
+
}
|
|
225
|
+
if (rel.instruction) {
|
|
226
|
+
this.include.instructions.add(this.getInstruction(log.transactionIndex, log.instructionAddress));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
getInstruction(transactionIdx, address) {
|
|
231
|
+
let pos = (0, util_internal_1.bisect)(this.block.instructions, null, ins => ins.transactionIndex - transactionIdx || addressCompare(ins.instructionAddress, address));
|
|
232
|
+
let ins = this.block.instructions[pos];
|
|
233
|
+
(0, assert_1.default)(ins &&
|
|
234
|
+
ins.transactionIndex == transactionIdx &&
|
|
235
|
+
addressCompare(ins.instructionAddress, address) == 0);
|
|
236
|
+
return ins;
|
|
237
|
+
}
|
|
238
|
+
filterTokenBalances() {
|
|
239
|
+
if (!this.items.tokenBalances.present())
|
|
240
|
+
return;
|
|
241
|
+
for (let balance of this.block.tokenBalances) {
|
|
242
|
+
let rel = this.items.tokenBalances.match(balance);
|
|
243
|
+
if (rel == null)
|
|
244
|
+
continue;
|
|
245
|
+
this.include.tokenBalances.add(balance);
|
|
246
|
+
if (rel.transaction) {
|
|
247
|
+
this.include.transactions.add(this.getTransaction(balance.transactionIndex));
|
|
248
|
+
}
|
|
249
|
+
if (rel.transactionInstructions) {
|
|
250
|
+
include(this.include.instructions, this.instructionsByTx().get(balance.transactionIndex));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
filterBalances() {
|
|
255
|
+
if (!this.items.balances.present())
|
|
256
|
+
return;
|
|
257
|
+
for (let balance of this.block.balances) {
|
|
258
|
+
let rel = this.items.balances.match(balance);
|
|
259
|
+
if (rel == null)
|
|
260
|
+
continue;
|
|
261
|
+
this.include.balances.add(balance);
|
|
262
|
+
if (rel.transaction) {
|
|
263
|
+
this.include.transactions.add(this.getTransaction(balance.transactionIndex));
|
|
264
|
+
}
|
|
265
|
+
if (rel.transactionInstructions) {
|
|
266
|
+
include(this.include.instructions, this.instructionsByTx().get(balance.transactionIndex));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
filterRewards() {
|
|
271
|
+
if (!this.items.rewards.present() || this.block.rewards == null)
|
|
272
|
+
return;
|
|
273
|
+
for (let reward of this.block.rewards) {
|
|
274
|
+
if (this.items.rewards.match(reward)) {
|
|
275
|
+
this.include.rewards.add(reward);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
apply() {
|
|
280
|
+
this.filterTransactions();
|
|
281
|
+
this.filterInstructions();
|
|
282
|
+
this.filterLogs();
|
|
283
|
+
this.filterBalances();
|
|
284
|
+
this.filterTokenBalances();
|
|
285
|
+
this.filterRewards();
|
|
286
|
+
this.block.transactions = this.block.transactions.filter(i => this.include.transactions.has(i));
|
|
287
|
+
this.block.instructions = this.block.instructions.filter(i => this.include.instructions.has(i));
|
|
288
|
+
this.block.logs = this.block.logs.filter(i => this.include.logs.has(i));
|
|
289
|
+
this.block.balances = this.block.balances.filter(i => this.include.balances.has(i));
|
|
290
|
+
this.block.tokenBalances = this.block.tokenBalances.filter(i => this.include.tokenBalances.has(i));
|
|
291
|
+
this.block.rewards = this.block.rewards.filter(i => this.include.rewards.has(i));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
__decorate([
|
|
295
|
+
util_internal_1.def,
|
|
296
|
+
__metadata("design:type", Function),
|
|
297
|
+
__metadata("design:paramtypes", []),
|
|
298
|
+
__metadata("design:returntype", Map)
|
|
299
|
+
], BlockFilter.prototype, "transactions", null);
|
|
300
|
+
__decorate([
|
|
301
|
+
util_internal_1.def,
|
|
302
|
+
__metadata("design:type", Function),
|
|
303
|
+
__metadata("design:paramtypes", []),
|
|
304
|
+
__metadata("design:returntype", Map)
|
|
305
|
+
], BlockFilter.prototype, "logsByTx", null);
|
|
306
|
+
__decorate([
|
|
307
|
+
util_internal_1.def,
|
|
308
|
+
__metadata("design:type", Function),
|
|
309
|
+
__metadata("design:paramtypes", []),
|
|
310
|
+
__metadata("design:returntype", Map)
|
|
311
|
+
], BlockFilter.prototype, "instructionsByTx", null);
|
|
312
|
+
__decorate([
|
|
313
|
+
util_internal_1.def,
|
|
314
|
+
__metadata("design:type", Function),
|
|
315
|
+
__metadata("design:paramtypes", []),
|
|
316
|
+
__metadata("design:returntype", Map)
|
|
317
|
+
], BlockFilter.prototype, "balancesByTx", null);
|
|
318
|
+
__decorate([
|
|
319
|
+
util_internal_1.def,
|
|
320
|
+
__metadata("design:type", Function),
|
|
321
|
+
__metadata("design:paramtypes", []),
|
|
322
|
+
__metadata("design:returntype", Map)
|
|
323
|
+
], BlockFilter.prototype, "tokenBalancesByTx", null);
|
|
324
|
+
function include(set, items) {
|
|
325
|
+
if (items == null)
|
|
326
|
+
return;
|
|
327
|
+
for (let it of items) {
|
|
328
|
+
set.add(it);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function* findInstructionChildren(items, addr) {
|
|
332
|
+
if (items.length == 0)
|
|
333
|
+
return;
|
|
334
|
+
let beg = (0, util_internal_1.bisect)(items, addr, (ins, addr) => addressCompare(ins.instructionAddress, addr));
|
|
335
|
+
while (beg < items.length && isChildAddress(items[beg].instructionAddress, addr)) {
|
|
336
|
+
yield items[beg];
|
|
337
|
+
beg += 1;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function isChildAddress(parent, addr) {
|
|
341
|
+
if (parent.length > addr.length)
|
|
342
|
+
return false;
|
|
343
|
+
for (let i = 0; i < parent.length; i++) {
|
|
344
|
+
if (parent[i] !== addr[i])
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
function addressCompare(a, b) {
|
|
350
|
+
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
351
|
+
let order = a[i] - b[i];
|
|
352
|
+
if (order)
|
|
353
|
+
return order;
|
|
354
|
+
}
|
|
355
|
+
return a.length - b.length;
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/rpc/filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA6IA,4CAEC;AAtID,2DAAsE;AACtE,2FAAmF;AACnF,oDAA2B;AAS3B,gDAAuD;AAGvD,SAAS,sBAAsB,CAAC,WAAwB;IACpD,IAAI,KAAK,GAAG,IAAI,4CAAY,EAAE,CAAA;IAC9B,KAAK,IAAI,GAAG,IAAI,WAAW,CAAC,YAAY,IAAI,EAAE,EAAE,CAAC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GD,SAAS,cAAc,CAAC,MAAgB,EAAE,IAAc;IACpD,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAA;IAC3C,CAAC;IACD,OAAO,IAAI,CAAA;AACf,CAAC;AAGD,SAAS,cAAc,CAAC,CAAW,EAAE,CAAW;IAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACpD,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACvB,IAAI,KAAK;YAAE,OAAO,KAAK,CAAA;IAC3B,CAAC;IACD,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type * as rpc from '@subsquid/solana-rpc-data';
|
|
2
|
+
import { PartialBlock } from '../data/partial';
|
|
3
|
+
import { DataRequest } from '../data/request';
|
|
4
|
+
export declare function mapBlock(src: rpc.Block, req: DataRequest): PartialBlock;
|
|
5
|
+
//# sourceMappingURL=mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/rpc/mapping.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAK3C,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,GAAG,YAAY,CAIvE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapBlock = mapBlock;
|
|
4
|
+
const solana_normalization_1 = require("@subsquid/solana-normalization");
|
|
5
|
+
const filter_1 = require("./filter");
|
|
6
|
+
const project_1 = require("./project");
|
|
7
|
+
function mapBlock(src, req) {
|
|
8
|
+
let block = (0, solana_normalization_1.mapRpcBlock)(src);
|
|
9
|
+
(0, filter_1.filterBlockItems)(block, req);
|
|
10
|
+
return (0, project_1.projectFields)(block, req.fields || {});
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping.js","sourceRoot":"","sources":["../../src/rpc/mapping.ts"],"names":[],"mappings":";;AAQA,4BAIC;AAZD,yEAA0D;AAI1D,qCAAyC;AACzC,uCAAuC;AAGvC,SAAgB,QAAQ,CAAC,GAAc,EAAE,GAAgB;IACrD,IAAI,KAAK,GAAG,IAAA,kCAAW,EAAC,GAAG,CAAC,CAAA;IAC5B,IAAA,yBAAgB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC5B,OAAO,IAAA,uBAAa,EAAC,KAAK,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Block } from '@subsquid/solana-normalization';
|
|
2
|
+
import { FieldSelection } from '../data/model';
|
|
3
|
+
import { PartialBlock } from '../data/partial';
|
|
4
|
+
export declare function projectFields(block: Block, fields: FieldSelection): PartialBlock;
|
|
5
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/rpc/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,gCAAgC,CAAA;AAEpD,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAI5C,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,GAAG,YAAY,CAqDhF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectFields = projectFields;
|
|
4
|
+
const fields_1 = require("../data/fields");
|
|
5
|
+
const instruction_1 = require("../instruction");
|
|
6
|
+
function projectFields(block, fields) {
|
|
7
|
+
return {
|
|
8
|
+
header: {
|
|
9
|
+
height: block.header.height,
|
|
10
|
+
hash: block.header.hash,
|
|
11
|
+
parentHash: block.header.parentHash,
|
|
12
|
+
...(0, fields_1.project)(fields.block, block.header)
|
|
13
|
+
},
|
|
14
|
+
transactions: block.transactions.map(tx => {
|
|
15
|
+
return {
|
|
16
|
+
transactionIndex: tx.transactionIndex,
|
|
17
|
+
...(0, fields_1.project)(fields.transaction, tx)
|
|
18
|
+
};
|
|
19
|
+
}),
|
|
20
|
+
instructions: block.instructions.map(i => {
|
|
21
|
+
let ins = {
|
|
22
|
+
transactionIndex: i.transactionIndex,
|
|
23
|
+
instructionAddress: i.instructionAddress,
|
|
24
|
+
...(0, fields_1.project)(fields.instruction, i)
|
|
25
|
+
};
|
|
26
|
+
ins[instruction_1.D8_SYM] = i[instruction_1.D8_SYM];
|
|
27
|
+
ins[instruction_1.DATA_SYM] = i[instruction_1.DATA_SYM];
|
|
28
|
+
return ins;
|
|
29
|
+
}),
|
|
30
|
+
logs: block.logs.map(log => {
|
|
31
|
+
return {
|
|
32
|
+
transactionIndex: log.transactionIndex,
|
|
33
|
+
logIndex: log.logIndex,
|
|
34
|
+
instructionAddress: log.instructionAddress,
|
|
35
|
+
...(0, fields_1.project)(fields.log, log)
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
balances: block.balances.map(b => {
|
|
39
|
+
return {
|
|
40
|
+
transactionIndex: b.transactionIndex,
|
|
41
|
+
account: b.account,
|
|
42
|
+
...(0, fields_1.project)(fields.balance, b)
|
|
43
|
+
};
|
|
44
|
+
}),
|
|
45
|
+
tokenBalances: block.tokenBalances.map(b => {
|
|
46
|
+
return {
|
|
47
|
+
transactionIndex: b.transactionIndex,
|
|
48
|
+
account: b.account,
|
|
49
|
+
...(0, fields_1.project)(fields.tokenBalance, b)
|
|
50
|
+
};
|
|
51
|
+
}),
|
|
52
|
+
rewards: block.rewards.map(r => {
|
|
53
|
+
return {
|
|
54
|
+
pubkey: r.pubkey,
|
|
55
|
+
...(0, fields_1.project)(fields.reward, r)
|
|
56
|
+
};
|
|
57
|
+
})
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/rpc/project.ts"],"names":[],"mappings":";;AAOA,sCAqDC;AA3DD,2CAAsC;AAGtC,gDAA+C;AAG/C,SAAgB,aAAa,CAAC,KAAY,EAAE,MAAsB;IAC9D,OAAO;QACH,MAAM,EAAE;YACJ,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM;YAC3B,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;YACvB,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU;YACnC,GAAG,IAAA,gBAAO,EAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;SACzC;QACD,YAAY,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YACtC,OAAO;gBACH,gBAAgB,EAAE,EAAE,CAAC,gBAAg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BACpC,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,GAAG,IAAA,gBAAO,EAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;aACrC,CAAA;QACL,CAAC,CAAC;QACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC3B,OAAO;gBACH,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,GAAG,IAAA,gBAAO,EAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;aAC/B,CAAA;QACL,CAAC,CAAC;KACL,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Base58Bytes, BlockInfo } from '@subsquid/solana-rpc';
|
|
2
|
+
import { RangeRequestList } from '@subsquid/util-internal-range';
|
|
3
|
+
import { PartialBlock } from '../data/partial';
|
|
4
|
+
import { DataRequest } from '../data/request';
|
|
5
|
+
import type { RpcSettings } from '../source';
|
|
6
|
+
export declare class RpcDataSource {
|
|
7
|
+
private options;
|
|
8
|
+
private rpc;
|
|
9
|
+
constructor(options: RpcSettings);
|
|
10
|
+
getFinalizedHeight(): Promise<number>;
|
|
11
|
+
getBlockInfo(slot: number): Promise<BlockInfo | undefined>;
|
|
12
|
+
getBlockHash(height: number): Promise<Base58Bytes | undefined>;
|
|
13
|
+
getBlockStream(requests: RangeRequestList<DataRequest>, stopOnHead?: boolean | undefined): AsyncIterable<PartialBlock[]>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/rpc/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAiD,MAAM,sBAAsB,CAAA;AAE3G,OAAO,EAAoC,gBAAgB,EAAC,MAAM,+BAA+B,CAAA;AACjG,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,WAAW,CAAA;AAI1C,qBAAa,aAAa;IAGV,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,GAAG,CAAK;gBAEI,OAAO,EAAE,WAAW;IAIxC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAW1D,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAa7D,cAAc,CACjB,QAAQ,EAAE,gBAAgB,CAAC,WAAW,CAAC,EACvC,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,GACjC,aAAa,CAAC,YAAY,EAAE,CAAC;CA0BnC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RpcDataSource = void 0;
|
|
4
|
+
const solana_rpc_1 = require("@subsquid/solana-rpc");
|
|
5
|
+
const util_internal_1 = require("@subsquid/util-internal");
|
|
6
|
+
const util_internal_range_1 = require("@subsquid/util-internal-range");
|
|
7
|
+
const mapping_1 = require("./mapping");
|
|
8
|
+
class RpcDataSource {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.rpc = new solana_rpc_1.Rpc(options.client);
|
|
12
|
+
}
|
|
13
|
+
getFinalizedHeight() {
|
|
14
|
+
return this.rpc.getFinalizedHeight();
|
|
15
|
+
}
|
|
16
|
+
async getBlockInfo(slot) {
|
|
17
|
+
let attempts = 10;
|
|
18
|
+
while (attempts) {
|
|
19
|
+
let block = await this.rpc.getBlockInfo('finalized', slot);
|
|
20
|
+
if (block || block === undefined)
|
|
21
|
+
return block;
|
|
22
|
+
await (0, util_internal_1.wait)(100);
|
|
23
|
+
attempts -= 1;
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Failed to getBlock with finalized commitment at slot ${slot} 10 times in a row`);
|
|
26
|
+
}
|
|
27
|
+
async getBlockHash(height) {
|
|
28
|
+
let headSlot = await this.rpc.getTopSlot('finalized');
|
|
29
|
+
let top = {
|
|
30
|
+
slot: headSlot,
|
|
31
|
+
height: await this.rpc.getFinalizedBlockHeight(headSlot)
|
|
32
|
+
};
|
|
33
|
+
if (top.height < height)
|
|
34
|
+
return;
|
|
35
|
+
let bottom = { slot: 0, height: 0 };
|
|
36
|
+
let slot = await (0, solana_rpc_1.findSlot)(this.rpc, height, bottom, top);
|
|
37
|
+
let block = await this.rpc.getFinalizedBlockInfo(slot);
|
|
38
|
+
return block.blockhash;
|
|
39
|
+
}
|
|
40
|
+
async *getBlockStream(requests, stopOnHead) {
|
|
41
|
+
let blockStream = (0, solana_rpc_1.ingestFinalizedBlocks)({
|
|
42
|
+
requests: toRpcRequests(requests),
|
|
43
|
+
stopOnHead,
|
|
44
|
+
rpc: this.rpc,
|
|
45
|
+
headPollInterval: 5000,
|
|
46
|
+
strideSize: this.options.strideSize ?? 5,
|
|
47
|
+
strideConcurrency: this.options.strideConcurrency ?? 5,
|
|
48
|
+
concurrentFetchThreshold: this.options.concurrentFetchThreshold ?? 50
|
|
49
|
+
});
|
|
50
|
+
for await (let batch of blockStream) {
|
|
51
|
+
let req = (0, util_internal_range_1.getRequestAt)(requests, batch[0].height) || {};
|
|
52
|
+
yield batch.map(block => {
|
|
53
|
+
try {
|
|
54
|
+
return (0, mapping_1.mapBlock)(block, req);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
throw (0, util_internal_1.addErrorContext)(err, {
|
|
58
|
+
blockHash: block.hash,
|
|
59
|
+
blockHeight: block.height,
|
|
60
|
+
blockSlot: block.slot
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.RpcDataSource = RpcDataSource;
|
|
68
|
+
function toRpcRequests(requests) {
|
|
69
|
+
return (0, util_internal_range_1.mapRangeRequestList)(requests, req => {
|
|
70
|
+
let rewards = req.rewards?.length;
|
|
71
|
+
let transactions = req.instructions?.length
|
|
72
|
+
|| req.transactions?.length
|
|
73
|
+
|| req.tokenBalances?.length
|
|
74
|
+
|| req.balances?.length
|
|
75
|
+
|| req.logs?.length;
|
|
76
|
+
return {
|
|
77
|
+
rewards: !!rewards,
|
|
78
|
+
transactions: !!transactions
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/rpc/source.ts"],"names":[],"mappings":";;;AAAA,qDAA2G;AAC3G,2DAA6D;AAC7D,uEAAiG;AAIjG,uCAAkC;AAGlC,MAAa,aAAa;IAGtB,YAAoB,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;QACpC,IAAI,CAAC,GAAG,GAAG,IAAI,gBAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACtC,CAAC;IAED,kBAAkB;QACd,OAAO,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAY;QAC3B,IAAI,QAAQ,GAAG,EAAE,CAAA;QACjB,OAAO,QAAQ,EAAE,CAAC;YACd,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;YAC1D,IAAI,KAAK,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAA;YAC9C,MAAM,IAAA,oBAAI,EAAC,GAAG,CAAC,CAAA;YACf,QAAQ,IAAI,CAAC,CAAA;QACjB,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,wDAAwD,IAAI,oBAAoB,CAA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