@subql/node-ethereum 6.2.2-0 → 6.3.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/utils/string.js +2 -1
  4. package/dist/utils/string.js.map +1 -1
  5. package/package.json +3 -4
  6. package/dist/blockchain.service.test.d.ts +0 -1
  7. package/dist/blockchain.service.test.js +0 -27
  8. package/dist/blockchain.service.test.js.map +0 -1
  9. package/dist/ethereum/api.ethereum.test.d.ts +0 -1
  10. package/dist/ethereum/api.ethereum.test.js +0 -266
  11. package/dist/ethereum/api.ethereum.test.js.map +0 -1
  12. package/dist/ethereum/api.service.ethereum.test.d.ts +0 -1
  13. package/dist/ethereum/api.service.ethereum.test.js +0 -91
  14. package/dist/ethereum/api.service.ethereum.test.js.map +0 -1
  15. package/dist/ethereum/ethers/celo/celo-ws-provider.spec.d.ts +0 -1
  16. package/dist/ethereum/ethers/celo/celo-ws-provider.spec.js +0 -33
  17. package/dist/ethereum/ethers/celo/celo-ws-provider.spec.js.map +0 -1
  18. package/dist/ethereum/ethers/json-rpc-batch-provider.spec.d.ts +0 -1
  19. package/dist/ethereum/ethers/json-rpc-batch-provider.spec.js +0 -63
  20. package/dist/ethereum/ethers/json-rpc-batch-provider.spec.js.map +0 -1
  21. package/dist/ethereum/ethers/op/op-provider.spec.d.ts +0 -1
  22. package/dist/ethereum/ethers/op/op-provider.spec.js +0 -32
  23. package/dist/ethereum/ethers/op/op-provider.spec.js.map +0 -1
  24. package/dist/indexer/dictionary/utils.spec.d.ts +0 -1
  25. package/dist/indexer/dictionary/utils.spec.js +0 -101
  26. package/dist/indexer/dictionary/utils.spec.js.map +0 -1
  27. package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.d.ts +0 -1
  28. package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.js +0 -519
  29. package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.js.map +0 -1
  30. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.d.ts +0 -1
  31. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js +0 -585
  32. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js.map +0 -1
  33. package/dist/indexer/dictionary/v2/utils.spec.d.ts +0 -1
  34. package/dist/indexer/dictionary/v2/utils.spec.js +0 -92
  35. package/dist/indexer/dictionary/v2/utils.spec.js.map +0 -1
  36. package/dist/indexer/unfinalizedBlocks.service.spec.d.ts +0 -1
  37. package/dist/indexer/unfinalizedBlocks.service.spec.js +0 -169
  38. package/dist/indexer/unfinalizedBlocks.service.spec.js.map +0 -1
  39. package/dist/utils/project.spec.d.ts +0 -1
  40. package/dist/utils/project.spec.js +0 -99
  41. package/dist/utils/project.spec.js.map +0 -1
  42. package/dist/utils/string.spec.d.ts +0 -1
  43. package/dist/utils/string.spec.js +0 -103
  44. package/dist/utils/string.spec.js.map +0 -1
@@ -1,585 +0,0 @@
1
- "use strict";
2
- // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
- // SPDX-License-Identifier: GPL-3.0
4
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- const common_ethereum_1 = require("@subql/common-ethereum");
9
- const node_core_1 = require("@subql/node-core");
10
- const types_ethereum_1 = require("@subql/types-ethereum");
11
- const eventemitter2_1 = __importDefault(require("eventemitter2"));
12
- const ethereum_1 = require("../../../ethereum");
13
- const ethDictionaryV2_1 = require("./ethDictionaryV2");
14
- const DEFAULT_DICTIONARY = 'https://ethereum.node.subquery.network/public';
15
- const HTTP_ENDPOINT = 'https://ethereum.rpc.subquery.network/public';
16
- const mockDs = [
17
- {
18
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
19
- assets: new Map(),
20
- startBlock: 19217803,
21
- mapping: {
22
- file: './dist/index.js',
23
- handlers: [
24
- {
25
- handler: 'handleTransaction',
26
- kind: types_ethereum_1.EthereumHandlerKind.Call,
27
- filter: {
28
- function: 'approve(address spender, uint256 rawAmount)',
29
- },
30
- },
31
- {
32
- handler: 'handleLog',
33
- kind: types_ethereum_1.EthereumHandlerKind.Event,
34
- filter: {
35
- topics: [
36
- 'Transfer(address indexed from, address indexed to, uint256 amount)',
37
- ],
38
- },
39
- },
40
- ],
41
- },
42
- },
43
- ];
44
- const templateTs = {
45
- name: 'template',
46
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
47
- assets: new Map(),
48
- options: {
49
- abi: 'erc20',
50
- // address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
51
- },
52
- // startBlock: 1,
53
- mapping: {
54
- file: '',
55
- handlers: [
56
- {
57
- handler: 'handleLog',
58
- kind: types_ethereum_1.EthereumHandlerKind.Event,
59
- filter: {
60
- topics: ['Transfer(address, address, uint256)'],
61
- },
62
- },
63
- ],
64
- },
65
- };
66
- // tx to is null
67
- const mockDs2 = [
68
- {
69
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
70
- assets: new Map(),
71
- startBlock: 19217803,
72
- mapping: {
73
- file: './dist/index.js',
74
- handlers: [
75
- {
76
- handler: 'handleTransaction',
77
- kind: types_ethereum_1.EthereumHandlerKind.Call,
78
- filter: {
79
- to: null,
80
- },
81
- },
82
- ],
83
- },
84
- processor: { file: '' },
85
- },
86
- ];
87
- const nodeConfig = new node_core_1.NodeConfig({
88
- subquery: 'eth-starter',
89
- subqueryName: 'eth-starter',
90
- dictionaryTimeout: 10,
91
- networkEndpoint: { [HTTP_ENDPOINT]: {} },
92
- networkDictionary: [DEFAULT_DICTIONARY],
93
- });
94
- function makeBlockHeightMap(mockDs) {
95
- const m = new Map();
96
- mockDs.forEach((ds, index, dataSources) => {
97
- m.set(ds.startBlock || 1, dataSources.slice(0, index + 1));
98
- });
99
- return new node_core_1.BlockHeightMap(m);
100
- }
101
- // enable this once dictionary v2 is online
102
- describe('eth dictionary v2', () => {
103
- let ethDictionaryV2;
104
- let ethApi;
105
- const dsMap = makeBlockHeightMap(mockDs);
106
- beforeAll(async () => {
107
- ethApi = new ethereum_1.EthereumApi(HTTP_ENDPOINT, 1, new eventemitter2_1.default());
108
- ethDictionaryV2 = await ethDictionaryV2_1.EthDictionaryV2.create(DEFAULT_DICTIONARY, nodeConfig, { network: { chainId: '1' } }, ethApi);
109
- }, 10000);
110
- beforeEach(() => {
111
- ethDictionaryV2.updateQueriesMap(dsMap);
112
- });
113
- it('converts ds to v2 dictionary queries', () => {
114
- const query = ethDictionaryV2.queriesMap.get(19217803);
115
- expect(query.logs.length).toBe(1);
116
- expect(query.transactions.length).toBe(1);
117
- });
118
- it('query response match with entries', async () => {
119
- const ethBlocks = (await ethDictionaryV2.getData(19217803, ethDictionaryV2._metadata.end, 2));
120
- expect(ethBlocks.batchBlocks.map((b) => b.block.number)).toStrictEqual([
121
- 19217803, 19217804,
122
- ]);
123
- const ethBlock19217803 = ethBlocks.batchBlocks[0].block;
124
- const ethBlock19217804 = ethBlocks.batchBlocks[1].block;
125
- expect(ethBlock19217803.number).toBe(19217803);
126
- expect(ethBlock19217804.number).toBe(19217804);
127
- // Sighash of approval tx
128
- expect(ethBlock19217803.transactions.filter((tx) => tx.input.indexOf('0x095ea7b3') === 0).length).toBe(4);
129
- // Run the same filters on an RPC block to compare results
130
- const rpcBlock19217804 = await ethApi.fetchBlock(19217804);
131
- const rpcLogs19217804 = [
132
- ...rpcBlock19217804.block.transactions
133
- .filter((tx) => tx.input.indexOf('0x095ea7b3') === 0)
134
- .flatMap((tx) => tx.logs),
135
- ...rpcBlock19217804.block.logs.filter((l) => l.topics[0] ===
136
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'),
137
- ];
138
- expect(ethBlock19217804.logs.length).toBe(rpcLogs19217804.length);
139
- // This matches with dictionaryQueryEntries[0].topics
140
- expect(ethBlock19217804.logs[0].topics).toContain('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef');
141
- }, 10000);
142
- // Geth currently throwing errors with this request
143
- it.skip('is able to get transaction with field to is null', async () => {
144
- const dsMap = makeBlockHeightMap(mockDs2);
145
- ethDictionaryV2.updateQueriesMap(dsMap);
146
- const { conditions } = ethDictionaryV2.getQueryConditions(19217803, ethDictionaryV2._metadata.end);
147
- expect(conditions).toEqual({ transactions: [{ to: [null] }] });
148
- const ethBlocks = (await ethDictionaryV2.getData(19217803, ethDictionaryV2._metadata.end, 1));
149
- const { hash, transactions } = ethBlocks.batchBlocks[0].block;
150
- expect(hash).toBe('0xa9ba70126240a8418739a103527860948a2be32de2eb9a8f590591faa174c08b');
151
- // https://etherscan.io/tx/0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1
152
- expect(transactions.find((tx) => tx.hash ===
153
- '0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1')).toBeDefined();
154
- });
155
- it('is able to query with not null topics', async () => {
156
- /**
157
- * Dictionary v1 supported filtering logs where a topic was null or not null.
158
- * V2 doesn't yet support this but we should still be able to make a dictionary query that gets relevant logs.
159
- * It will just include events that will be filtered out later.
160
- * */
161
- const ds = {
162
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
163
- assets: new Map(),
164
- options: {
165
- abi: 'erc20',
166
- },
167
- startBlock: 19476187,
168
- mapping: {
169
- file: '',
170
- handlers: [
171
- {
172
- handler: 'handleLog',
173
- kind: types_ethereum_1.EthereumHandlerKind.Event,
174
- filter: {
175
- topics: [
176
- 'Transfer(address, address, uint256)',
177
- undefined,
178
- undefined,
179
- common_ethereum_1.NOT_NULL_FILTER,
180
- ],
181
- },
182
- },
183
- ],
184
- },
185
- };
186
- const dsMap = makeBlockHeightMap([ds]);
187
- ethDictionaryV2.updateQueriesMap(dsMap);
188
- const { conditions } = ethDictionaryV2.getQueryConditions(19476187, ethDictionaryV2._metadata.end);
189
- expect(conditions).toEqual({
190
- logs: [
191
- {
192
- address: [],
193
- topics0: [
194
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
195
- ],
196
- topics3: [],
197
- },
198
- ],
199
- });
200
- const ethBlocks = (await ethDictionaryV2.getData(19476187, ethDictionaryV2._metadata.end, 2));
201
- const { hash, logs } = ethBlocks.batchBlocks[0].block;
202
- expect(hash).toEqual('0xa798861151ed58ad67d80d1cf61dc30e65d003bc958e99a7969a05a67e69e0b2');
203
- const log = logs.find((l) => l.logIndex === 184);
204
- expect(log).toBeDefined();
205
- expect(log.transactionHash).toEqual('0x5491f3f4b7ca6cc81f992a17e19bc9bafff408518c643c5a254de44b5a7b6d72');
206
- // Uncomment this when not null filter supported
207
- // expect(logs.filter(l => !l.topics[3]).length).toEqual(6) // There are 6 events with no topic3
208
- }, 100000);
209
- it('returns a lastBufferedHeight if there are no block results', async () => {
210
- const ds = {
211
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
212
- assets: new Map(),
213
- options: {
214
- abi: 'erc20',
215
- address: '0x30baa3ba9d7089fd8d020a994db75d14cf7ec83b',
216
- },
217
- startBlock: 18723210,
218
- mapping: {
219
- file: '',
220
- handlers: [
221
- {
222
- handler: 'handleLog',
223
- kind: types_ethereum_1.EthereumHandlerKind.Event,
224
- filter: {
225
- topics: ['Transfer(address, address, uint256)'],
226
- },
227
- },
228
- ],
229
- },
230
- };
231
- const dsMap = makeBlockHeightMap([ds]);
232
- ethDictionaryV2.updateQueriesMap(dsMap);
233
- const res = await ethDictionaryV2.getData(18723210, 18733210, 100);
234
- expect(res?.batchBlocks.length).toEqual(0);
235
- expect(res?.lastBufferedHeight).toEqual(18733210);
236
- }, 10_000);
237
- });
238
- describe('buildDictionaryV2QueryEntry', () => {
239
- it('Build filter for !null', () => {
240
- const ds = {
241
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
242
- assets: new Map(),
243
- options: {
244
- abi: 'erc20',
245
- address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
246
- },
247
- startBlock: 1,
248
- mapping: {
249
- file: '',
250
- handlers: [
251
- {
252
- handler: 'handleLog',
253
- kind: types_ethereum_1.EthereumHandlerKind.Event,
254
- filter: {
255
- topics: [
256
- 'Transfer(address, address, uint256)',
257
- undefined,
258
- undefined,
259
- common_ethereum_1.NOT_NULL_FILTER,
260
- ],
261
- },
262
- },
263
- ],
264
- },
265
- };
266
- const result = (0, ethDictionaryV2_1.buildDictionaryV2QueryEntry)([ds]);
267
- expect(result).toEqual({
268
- logs: [
269
- {
270
- address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],
271
- topics0: [
272
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
273
- ],
274
- topics3: [],
275
- },
276
- ],
277
- });
278
- });
279
- it('Build filter tx filter', () => {
280
- const ds = {
281
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
282
- assets: new Map(),
283
- options: {
284
- abi: 'erc20',
285
- address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
286
- },
287
- startBlock: 1,
288
- mapping: {
289
- file: '',
290
- handlers: [
291
- {
292
- handler: 'handleTx',
293
- kind: types_ethereum_1.EthereumHandlerKind.Call,
294
- filter: {
295
- function: 'setminimumStakingAmount(uint256 amount)',
296
- },
297
- },
298
- ],
299
- },
300
- };
301
- const result = (0, ethDictionaryV2_1.buildDictionaryV2QueryEntry)([ds]);
302
- expect(result).toEqual({
303
- transactions: [
304
- {
305
- to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],
306
- data: ['0x7ef9ea98'],
307
- },
308
- ],
309
- });
310
- });
311
- it('Creates a valid filter with a single event handler that has 0 filters but a contract address', () => {
312
- const ds = {
313
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
314
- assets: new Map(),
315
- options: {
316
- abi: 'erc20',
317
- address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
318
- },
319
- startBlock: 1,
320
- mapping: {
321
- file: '',
322
- handlers: [
323
- {
324
- handler: 'handleTransfer',
325
- kind: types_ethereum_1.EthereumHandlerKind.Event,
326
- },
327
- {
328
- handler: 'handleTransfer',
329
- kind: types_ethereum_1.EthereumHandlerKind.Call,
330
- },
331
- ],
332
- },
333
- };
334
- const result = (0, ethDictionaryV2_1.buildDictionaryV2QueryEntry)([ds]);
335
- expect(result).toEqual({
336
- transactions: [
337
- {
338
- to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],
339
- },
340
- ],
341
- logs: [
342
- {
343
- address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],
344
- },
345
- ],
346
- });
347
- });
348
- it('build query entries for multiple ds', () => {
349
- const ds = [
350
- {
351
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
352
- startBlock: 3327417,
353
- options: {
354
- abi: 'EnsRegistry',
355
- address: '0x314159265dd8dbb310642f98f50c066173c1259b',
356
- },
357
- assets: new Map(),
358
- mapping: {
359
- file: './dist/index.js',
360
- handlers: [
361
- // one duplicate one
362
- {
363
- kind: types_ethereum_1.EthereumHandlerKind.Event,
364
- handler: 'handleTransferOldRegistry',
365
- filter: {
366
- topics: ['Transfer(bytes32,address)'],
367
- },
368
- },
369
- {
370
- kind: types_ethereum_1.EthereumHandlerKind.Event,
371
- handler: 'handleTransferOldRegistry',
372
- filter: {
373
- topics: ['Transfer(bytes32,address)'],
374
- },
375
- },
376
- {
377
- kind: types_ethereum_1.EthereumHandlerKind.Event,
378
- handler: 'handleNewOwnerOldRegistry',
379
- filter: {
380
- topics: ['NewOwner(bytes32,bytes32,address)'],
381
- },
382
- },
383
- ],
384
- },
385
- },
386
- {
387
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
388
- startBlock: 3327417,
389
- options: {
390
- abi: 'Resolver',
391
- },
392
- assets: new Map(),
393
- mapping: {
394
- file: './dist/index.js',
395
- handlers: [
396
- {
397
- kind: types_ethereum_1.EthereumHandlerKind.Event,
398
- handler: 'handleABIChanged',
399
- filter: {
400
- topics: ['ABIChanged(bytes32,uint256)'],
401
- },
402
- },
403
- {
404
- kind: types_ethereum_1.EthereumHandlerKind.Event,
405
- handler: 'handleAddrChanged',
406
- filter: {
407
- topics: ['AddrChanged(bytes32,address)'],
408
- },
409
- },
410
- {
411
- kind: types_ethereum_1.EthereumHandlerKind.Event,
412
- handler: 'handleMulticoinAddrChanged',
413
- filter: {
414
- topics: ['AddressChanged(bytes32,uint256,bytes)'],
415
- },
416
- },
417
- {
418
- kind: types_ethereum_1.EthereumHandlerKind.Event,
419
- handler: 'handleAuthorisationChanged',
420
- filter: {
421
- topics: ['AuthorisationChanged(bytes32,address,address,bool)'],
422
- },
423
- },
424
- ],
425
- },
426
- },
427
- ];
428
- const queryEntry = (0, ethDictionaryV2_1.buildDictionaryV2QueryEntry)(ds);
429
- // Total 7 handlers were given, 1 is duplicate
430
- expect(queryEntry.logs.length).toBe(6);
431
- });
432
- it('should unique QueryEntry for duplicate dataSources', () => {
433
- const ds = {
434
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
435
- assets: new Map(),
436
- options: {
437
- abi: 'erc20',
438
- address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
439
- },
440
- startBlock: 1,
441
- mapping: {
442
- file: '',
443
- handlers: [
444
- {
445
- handler: 'handleLog',
446
- kind: types_ethereum_1.EthereumHandlerKind.Event,
447
- filter: {
448
- topics: ['Transfer(address, address, uint256)'],
449
- },
450
- },
451
- {
452
- handler: 'handleLogSame',
453
- kind: types_ethereum_1.EthereumHandlerKind.Event,
454
- filter: {
455
- topics: ['Transfer(address, address, uint256)'],
456
- },
457
- },
458
- {
459
- handler: 'handleTx',
460
- kind: types_ethereum_1.EthereumHandlerKind.Call,
461
- filter: {
462
- function: 'setminimumStakingAmount(uint256 amount)',
463
- from: 'mockAddress',
464
- },
465
- },
466
- {
467
- handler: 'handleTxSame',
468
- kind: types_ethereum_1.EthereumHandlerKind.Call,
469
- filter: {
470
- function: 'setminimumStakingAmount(uint256 amount)',
471
- from: 'mockAddress',
472
- },
473
- },
474
- ],
475
- },
476
- };
477
- const result = (0, ethDictionaryV2_1.buildDictionaryV2QueryEntry)([ds]);
478
- expect(result).toEqual({
479
- logs: [
480
- {
481
- address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],
482
- topics0: [
483
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
484
- ],
485
- },
486
- ],
487
- transactions: [
488
- {
489
- from: ['mockaddress'],
490
- to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],
491
- data: ['0x7ef9ea98'],
492
- },
493
- ],
494
- });
495
- });
496
- it('should group a small number of dynamic ds', () => {
497
- const ds = [];
498
- for (let i = 0; i < 10; i++) {
499
- // Bad nodejs types
500
- const tmp = global.structuredClone(templateTs);
501
- (tmp.options.address = `0x${i}`), ds.push(tmp);
502
- }
503
- const result = (0, ethDictionaryV2_1.buildDictionaryV2QueryEntry)(ds);
504
- expect(result).toEqual({
505
- logs: [
506
- {
507
- address: [
508
- '0x0',
509
- '0x1',
510
- '0x2',
511
- '0x3',
512
- '0x4',
513
- '0x5',
514
- '0x6',
515
- '0x7',
516
- '0x8',
517
- '0x9',
518
- ],
519
- topics0: [
520
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
521
- ],
522
- },
523
- ],
524
- });
525
- });
526
- it('should remove address filter with large number of dynamic ds', () => {
527
- const ds = [];
528
- for (let i = 0; i < 200; i++) {
529
- // Bad nodejs types
530
- const tmp = global.structuredClone(templateTs);
531
- (tmp.options.address = `0x${i}`), ds.push(tmp);
532
- }
533
- const result = (0, ethDictionaryV2_1.buildDictionaryV2QueryEntry)(ds);
534
- expect(result).toEqual({
535
- logs: [
536
- {
537
- address: [],
538
- topics0: [
539
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
540
- ],
541
- },
542
- ],
543
- });
544
- });
545
- it('builds a filter when theres a block handler with modulo filter', () => {
546
- const ds = {
547
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
548
- assets: new Map(),
549
- options: {
550
- abi: 'erc20',
551
- address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
552
- },
553
- startBlock: 1,
554
- mapping: {
555
- file: '',
556
- handlers: [
557
- {
558
- handler: 'handleBlock',
559
- kind: types_ethereum_1.EthereumHandlerKind.Block,
560
- filter: {
561
- modulo: 100,
562
- },
563
- },
564
- {
565
- handler: 'handleTx',
566
- kind: types_ethereum_1.EthereumHandlerKind.Call,
567
- filter: {
568
- function: 'setminimumStakingAmount(uint256 amount)',
569
- },
570
- },
571
- ],
572
- },
573
- };
574
- const result = (0, ethDictionaryV2_1.buildDictionaryV2QueryEntry)([ds]);
575
- expect(result).toEqual({
576
- transactions: [
577
- {
578
- to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],
579
- data: ['0x7ef9ea98'],
580
- },
581
- ],
582
- });
583
- });
584
- });
585
- //# sourceMappingURL=ethDictionaryV2.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ethDictionaryV2.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;AAEnC,4DAAyD;AACzD,gDAK0B;AAC1B,0DAM+B;AAC/B,kEAA0C;AAM1C,gDAAgD;AAChD,uDAG2B;AAE3B,MAAM,kBAAkB,GAAG,+CAA+C,CAAC;AAC3E,MAAM,aAAa,GAAG,8CAA8C,CAAC;AACrE,MAAM,MAAM,GAAwB;IAClC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,mBA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C,IAAI,EAAE,uCAAsB,CAAC,OAAO;YACpC,MAAM,EAAE,IAAI,GAAG,EAAE;YACjB,OAAO,EAAE;gBACP,GAAG,EAAE,OAAO;gBACZ,OAAO,EAAE,4CAA4C;aACtD;YACD,UAAU,EAAE,CAAC;YACb,OAAO,EAAE;gBACP,IAAI,EAAE,EAAE;gBACR,QAAQ,EAAE;oBACR;wBACE,OAAO,EAAE,aAAa;wBACtB,IAAI,EAAE,oCAAmB,CAAC,KAAK;wBAC/B,MAAM,EAAE;4BACN,MAAM,EAAE,GAAG;yBACZ;qBACF;oBACD;wBACE,OAAO,EAAE,UAAU;wBACnB,IAAI,EAAE,oCAAmB,CAAC,IAAI;wBAC9B,MAAM,EAAE;4BACN,QAAQ,EAAE,yCAAyC;yBACpD;qBACF;iBACF;aACF;SACF,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,6CAA2B,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,YAAY,EAAE;gBACZ;oBACE,EAAE,EAAE,CAAC,4CAA4C,CAAC;oBAClD,IAAI,EAAE,CAAC,YAAY,CAAC;iBACrB;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NOT_NULL_FILTER } from '@subql/common-ethereum';\nimport {\n BlockHeightMap,\n DictionaryResponse,\n IBlock,\n NodeConfig,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlDatasource,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport EventEmitter2 from 'eventemitter2';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport {\n buildDictionaryV2QueryEntry,\n EthDictionaryV2,\n} from './ethDictionaryV2';\n\nconst DEFAULT_DICTIONARY = 'https://ethereum.node.subquery.network/public';\nconst HTTP_ENDPOINT = 'https://ethereum.rpc.subquery.network/public';\nconst mockDs: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address indexed from, address indexed to, uint256 amount)',\n ],\n },\n },\n ],\n },\n },\n];\n\nconst templateTs: EthereumProjectDsTemplate = {\n name: 'template',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n // address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n // startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n};\n\n// tx to is null\nconst mockDs2: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n processor: { file: '' },\n },\n];\n\nconst nodeConfig = new NodeConfig({\n subquery: 'eth-starter',\n subqueryName: 'eth-starter',\n dictionaryTimeout: 10,\n networkEndpoint: { [HTTP_ENDPOINT]: {} },\n networkDictionary: [DEFAULT_DICTIONARY],\n});\n\nfunction makeBlockHeightMap(mockDs: SubqlDatasource[]): BlockHeightMap<any> {\n const m = new Map<number, any>();\n mockDs.forEach((ds, index, dataSources) => {\n m.set(ds.startBlock || 1, dataSources.slice(0, index + 1));\n });\n return new BlockHeightMap(m);\n}\n\n// enable this once dictionary v2 is online\ndescribe('eth dictionary v2', () => {\n let ethDictionaryV2: EthDictionaryV2;\n let ethApi: EthereumApi;\n\n const dsMap = makeBlockHeightMap(mockDs);\n\n beforeAll(async () => {\n ethApi = new EthereumApi(HTTP_ENDPOINT, 1, new EventEmitter2());\n ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n { network: { chainId: '1' } } as SubqueryProject,\n ethApi,\n );\n }, 10000);\n\n beforeEach(() => {\n ethDictionaryV2.updateQueriesMap(dsMap);\n });\n\n it('converts ds to v2 dictionary queries', () => {\n const query = (ethDictionaryV2 as any).queriesMap.get(19217803);\n expect(query.logs.length).toBe(1);\n expect(query.transactions.length).toBe(1);\n });\n\n it('query response match with entries', async () => {\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n expect(ethBlocks.batchBlocks.map((b) => b.block.number)).toStrictEqual([\n 19217803, 19217804,\n ]);\n\n const ethBlock19217803 = ethBlocks.batchBlocks[0].block;\n const ethBlock19217804 = ethBlocks.batchBlocks[1].block;\n\n expect(ethBlock19217803.number).toBe(19217803);\n expect(ethBlock19217804.number).toBe(19217804);\n\n // Sighash of approval tx\n expect(\n ethBlock19217803.transactions.filter(\n (tx) => tx.input.indexOf('0x095ea7b3') === 0,\n ).length,\n ).toBe(4);\n\n // Run the same filters on an RPC block to compare results\n const rpcBlock19217804 = await ethApi.fetchBlock(19217804);\n const rpcLogs19217804 = [\n ...rpcBlock19217804.block.transactions\n .filter((tx) => tx.input.indexOf('0x095ea7b3') === 0)\n .flatMap((tx) => tx.logs),\n ...rpcBlock19217804.block.logs.filter(\n (l) =>\n l.topics[0] ===\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ),\n ];\n\n expect(ethBlock19217804.logs.length).toBe(rpcLogs19217804.length);\n\n // This matches with dictionaryQueryEntries[0].topics\n expect(ethBlock19217804.logs[0].topics).toContain(\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n );\n }, 10000);\n\n // Geth currently throwing errors with this request\n it.skip('is able to get transaction with field to is null', async () => {\n const dsMap = makeBlockHeightMap(mockDs2);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({ transactions: [{ to: [null] }] });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 1,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, transactions } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toBe(\n '0xa9ba70126240a8418739a103527860948a2be32de2eb9a8f590591faa174c08b',\n );\n\n // https://etherscan.io/tx/0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1\n expect(\n transactions.find(\n (tx) =>\n tx.hash ===\n '0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1',\n ),\n ).toBeDefined();\n });\n\n it('is able to query with not null topics', async () => {\n /**\n * Dictionary v1 supported filtering logs where a topic was null or not null.\n * V2 doesn't yet support this but we should still be able to make a dictionary query that gets relevant logs.\n * It will just include events that will be filtered out later.\n * */\n\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 19476187,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n NOT_NULL_FILTER,\n ],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, logs } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toEqual(\n '0xa798861151ed58ad67d80d1cf61dc30e65d003bc958e99a7969a05a67e69e0b2',\n );\n\n const log = logs.find((l) => l.logIndex === 184);\n expect(log).toBeDefined();\n expect(log!.transactionHash).toEqual(\n '0x5491f3f4b7ca6cc81f992a17e19bc9bafff408518c643c5a254de44b5a7b6d72',\n );\n\n // Uncomment this when not null filter supported\n // expect(logs.filter(l => !l.topics[3]).length).toEqual(6) // There are 6 events with no topic3\n }, 100000);\n\n it('returns a lastBufferedHeight if there are no block results', async () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x30baa3ba9d7089fd8d020a994db75d14cf7ec83b',\n },\n startBlock: 18723210,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const res = await ethDictionaryV2.getData(18723210, 18733210, 100);\n\n expect(res?.batchBlocks.length).toEqual(0);\n expect(res?.lastBufferedHeight).toEqual(18733210);\n }, 10_000);\n});\n\ndescribe('buildDictionaryV2QueryEntry', () => {\n it('Build filter for !null', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n NOT_NULL_FILTER,\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n });\n\n it('Build filter tx filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('Creates a valid filter with a single event handler that has 0 filters but a contract address', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Event,\n },\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n },\n ],\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n },\n ],\n });\n });\n\n it('build query entries for multiple ds', () => {\n const ds: SubqlRuntimeDatasource[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'EnsRegistry',\n address: '0x314159265dd8dbb310642f98f50c066173c1259b',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n // one duplicate one\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleNewOwnerOldRegistry',\n filter: {\n topics: ['NewOwner(bytes32,bytes32,address)'],\n },\n },\n ],\n },\n },\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'Resolver',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleABIChanged',\n filter: {\n topics: ['ABIChanged(bytes32,uint256)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAddrChanged',\n filter: {\n topics: ['AddrChanged(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleMulticoinAddrChanged',\n filter: {\n topics: ['AddressChanged(bytes32,uint256,bytes)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAuthorisationChanged',\n filter: {\n topics: ['AuthorisationChanged(bytes32,address,address,bool)'],\n },\n },\n ],\n },\n },\n ];\n\n const queryEntry = buildDictionaryV2QueryEntry(ds);\n // Total 7 handlers were given, 1 is duplicate\n expect(queryEntry.logs!.length).toBe(6);\n });\n\n it('should unique QueryEntry for duplicate dataSources', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleLogSame',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n {\n handler: 'handleTxSame',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n transactions: [\n {\n from: ['mockaddress'],\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('should group a small number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 10; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ds);\n\n expect(result).toEqual({\n logs: [\n {\n address: [\n '0x0',\n '0x1',\n '0x2',\n '0x3',\n '0x4',\n '0x5',\n '0x6',\n '0x7',\n '0x8',\n '0x9',\n ],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('should remove address filter with large number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 200; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ds);\n\n expect(result).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('builds a filter when theres a block handler with modulo filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleBlock',\n kind: EthereumHandlerKind.Block,\n filter: {\n modulo: 100,\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n});\n"]}
@@ -1 +0,0 @@
1
- export {};