@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.
- package/CHANGELOG.md +6 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/utils/string.js +2 -1
- package/dist/utils/string.js.map +1 -1
- package/package.json +3 -4
- package/dist/blockchain.service.test.d.ts +0 -1
- package/dist/blockchain.service.test.js +0 -27
- package/dist/blockchain.service.test.js.map +0 -1
- package/dist/ethereum/api.ethereum.test.d.ts +0 -1
- package/dist/ethereum/api.ethereum.test.js +0 -266
- package/dist/ethereum/api.ethereum.test.js.map +0 -1
- package/dist/ethereum/api.service.ethereum.test.d.ts +0 -1
- package/dist/ethereum/api.service.ethereum.test.js +0 -91
- package/dist/ethereum/api.service.ethereum.test.js.map +0 -1
- package/dist/ethereum/ethers/celo/celo-ws-provider.spec.d.ts +0 -1
- package/dist/ethereum/ethers/celo/celo-ws-provider.spec.js +0 -33
- package/dist/ethereum/ethers/celo/celo-ws-provider.spec.js.map +0 -1
- package/dist/ethereum/ethers/json-rpc-batch-provider.spec.d.ts +0 -1
- package/dist/ethereum/ethers/json-rpc-batch-provider.spec.js +0 -63
- package/dist/ethereum/ethers/json-rpc-batch-provider.spec.js.map +0 -1
- package/dist/ethereum/ethers/op/op-provider.spec.d.ts +0 -1
- package/dist/ethereum/ethers/op/op-provider.spec.js +0 -32
- package/dist/ethereum/ethers/op/op-provider.spec.js.map +0 -1
- package/dist/indexer/dictionary/utils.spec.d.ts +0 -1
- package/dist/indexer/dictionary/utils.spec.js +0 -101
- package/dist/indexer/dictionary/utils.spec.js.map +0 -1
- package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.d.ts +0 -1
- package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.js +0 -519
- package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.js.map +0 -1
- package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.d.ts +0 -1
- package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js +0 -585
- package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js.map +0 -1
- package/dist/indexer/dictionary/v2/utils.spec.d.ts +0 -1
- package/dist/indexer/dictionary/v2/utils.spec.js +0 -92
- package/dist/indexer/dictionary/v2/utils.spec.js.map +0 -1
- package/dist/indexer/unfinalizedBlocks.service.spec.d.ts +0 -1
- package/dist/indexer/unfinalizedBlocks.service.spec.js +0 -169
- package/dist/indexer/unfinalizedBlocks.service.spec.js.map +0 -1
- package/dist/utils/project.spec.d.ts +0 -1
- package/dist/utils/project.spec.js +0 -99
- package/dist/utils/project.spec.js.map +0 -1
- package/dist/utils/string.spec.d.ts +0 -1
- package/dist/utils/string.spec.js +0 -103
- package/dist/utils/string.spec.js.map +0 -1
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
const node_core_1 = require("@subql/node-core");
|
|
6
|
-
const types_ethereum_1 = require("@subql/types-ethereum");
|
|
7
|
-
const graphql_1 = require("graphql");
|
|
8
|
-
const ethDictionaryV1_1 = require("./ethDictionaryV1");
|
|
9
|
-
const mockTempDs = [
|
|
10
|
-
{
|
|
11
|
-
name: 'ERC721',
|
|
12
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
13
|
-
assets: new Map(),
|
|
14
|
-
mapping: {
|
|
15
|
-
file: '',
|
|
16
|
-
handlers: [
|
|
17
|
-
{
|
|
18
|
-
handler: 'handleERC721',
|
|
19
|
-
kind: types_ethereum_1.EthereumHandlerKind.Event,
|
|
20
|
-
filter: {
|
|
21
|
-
topics: ['Transfer(address, address, uint256)'],
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: 'ERC1155',
|
|
29
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
30
|
-
assets: new Map(),
|
|
31
|
-
mapping: {
|
|
32
|
-
file: '',
|
|
33
|
-
handlers: [
|
|
34
|
-
{
|
|
35
|
-
handler: 'handleERC1155',
|
|
36
|
-
kind: types_ethereum_1.EthereumHandlerKind.Event,
|
|
37
|
-
filter: {
|
|
38
|
-
topics: [
|
|
39
|
-
'TransferSingle(address, address, address, uint256, uint256)',
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
function testSubqueryProject(endpoint, ds, mockTempDs) {
|
|
48
|
-
return {
|
|
49
|
-
network: {
|
|
50
|
-
endpoint,
|
|
51
|
-
chainId: '1',
|
|
52
|
-
},
|
|
53
|
-
dataSources: ds,
|
|
54
|
-
id: 'test',
|
|
55
|
-
root: './',
|
|
56
|
-
schema: new graphql_1.GraphQLSchema({}),
|
|
57
|
-
templates: mockTempDs,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
describe('Eth Dictionary V1', () => {
|
|
61
|
-
it('Can resovle chain aliases', async () => {
|
|
62
|
-
ethDictionaryV1_1.EthDictionaryV1.prototype.init = jest.fn();
|
|
63
|
-
const dictionary = await ethDictionaryV1_1.EthDictionaryV1.create({
|
|
64
|
-
network: { chainId: '336', dictionary: 'https://foo.bar' },
|
|
65
|
-
}, new node_core_1.NodeConfig({}, true), '');
|
|
66
|
-
expect(dictionary.chainId).toBe('0xf1cf9022c7ebb34b162d5b5e34e705a5a740b2d0ecc1009fb89023e62a488108');
|
|
67
|
-
jest.clearAllMocks();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe('buildDictionaryV1QueryEntries', () => {
|
|
71
|
-
describe('Log filters', () => {
|
|
72
|
-
it('Build filter for !null', () => {
|
|
73
|
-
const ds = {
|
|
74
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
75
|
-
assets: new Map(),
|
|
76
|
-
options: {
|
|
77
|
-
abi: 'erc20',
|
|
78
|
-
address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
|
|
79
|
-
},
|
|
80
|
-
startBlock: 1,
|
|
81
|
-
mapping: {
|
|
82
|
-
file: '',
|
|
83
|
-
handlers: [
|
|
84
|
-
{
|
|
85
|
-
handler: 'handleLog',
|
|
86
|
-
kind: types_ethereum_1.EthereumHandlerKind.Event,
|
|
87
|
-
filter: {
|
|
88
|
-
topics: [
|
|
89
|
-
'Transfer(address, address, uint256)',
|
|
90
|
-
undefined,
|
|
91
|
-
undefined,
|
|
92
|
-
'!null',
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
const result = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)([ds]);
|
|
100
|
-
expect(result).toEqual([
|
|
101
|
-
{
|
|
102
|
-
entity: 'evmLogs',
|
|
103
|
-
conditions: [
|
|
104
|
-
{
|
|
105
|
-
field: 'address',
|
|
106
|
-
matcher: 'equalTo',
|
|
107
|
-
value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
field: 'topics0',
|
|
111
|
-
value: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
|
|
112
|
-
matcher: 'equalTo',
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
field: 'topics3',
|
|
116
|
-
value: false,
|
|
117
|
-
matcher: 'isNull',
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
]);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
describe('Transaction filters', () => {
|
|
125
|
-
it('Build a filter for contract creation transactions', () => {
|
|
126
|
-
const ds = {
|
|
127
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
128
|
-
assets: new Map(),
|
|
129
|
-
startBlock: 1,
|
|
130
|
-
mapping: {
|
|
131
|
-
file: '',
|
|
132
|
-
handlers: [
|
|
133
|
-
{
|
|
134
|
-
handler: 'handleTransaction',
|
|
135
|
-
kind: types_ethereum_1.EthereumHandlerKind.Call,
|
|
136
|
-
filter: {
|
|
137
|
-
to: null,
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
const result = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)([ds]);
|
|
144
|
-
expect(result).toEqual([
|
|
145
|
-
{
|
|
146
|
-
entity: 'evmTransactions',
|
|
147
|
-
conditions: [{ field: 'to', matcher: 'isNull', value: true }],
|
|
148
|
-
},
|
|
149
|
-
]);
|
|
150
|
-
});
|
|
151
|
-
it('Build a filter with include ds option and contract address', () => {
|
|
152
|
-
const ds = {
|
|
153
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
154
|
-
assets: new Map(),
|
|
155
|
-
options: {
|
|
156
|
-
abi: 'erc20',
|
|
157
|
-
address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
|
|
158
|
-
},
|
|
159
|
-
startBlock: 1,
|
|
160
|
-
mapping: {
|
|
161
|
-
file: '',
|
|
162
|
-
handlers: [
|
|
163
|
-
{
|
|
164
|
-
handler: 'handleTransfer',
|
|
165
|
-
kind: types_ethereum_1.EthereumHandlerKind.Call,
|
|
166
|
-
filter: {
|
|
167
|
-
function: 'approve(address spender, uint256 rawAmount)',
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
const result = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)([ds]);
|
|
174
|
-
expect(result).toEqual([
|
|
175
|
-
{
|
|
176
|
-
entity: 'evmTransactions',
|
|
177
|
-
conditions: [
|
|
178
|
-
{
|
|
179
|
-
field: 'to',
|
|
180
|
-
matcher: 'equalTo',
|
|
181
|
-
value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
182
|
-
},
|
|
183
|
-
{ field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },
|
|
184
|
-
],
|
|
185
|
-
},
|
|
186
|
-
]);
|
|
187
|
-
});
|
|
188
|
-
it('If ds option and filter both provide contract address, it should use ds options one', () => {
|
|
189
|
-
const ds = {
|
|
190
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
191
|
-
assets: new Map(),
|
|
192
|
-
options: {
|
|
193
|
-
abi: 'erc20',
|
|
194
|
-
address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
|
|
195
|
-
},
|
|
196
|
-
startBlock: 1,
|
|
197
|
-
mapping: {
|
|
198
|
-
file: '',
|
|
199
|
-
handlers: [
|
|
200
|
-
{
|
|
201
|
-
handler: 'handleTransfer',
|
|
202
|
-
kind: types_ethereum_1.EthereumHandlerKind.Call,
|
|
203
|
-
filter: {
|
|
204
|
-
to: '0xabcde',
|
|
205
|
-
function: 'approve(address spender, uint256 rawAmount)',
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
],
|
|
209
|
-
},
|
|
210
|
-
};
|
|
211
|
-
const result = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)([ds]);
|
|
212
|
-
expect(result).toEqual([
|
|
213
|
-
{
|
|
214
|
-
entity: 'evmTransactions',
|
|
215
|
-
conditions: [
|
|
216
|
-
{
|
|
217
|
-
field: 'to',
|
|
218
|
-
matcher: 'equalTo',
|
|
219
|
-
value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
220
|
-
},
|
|
221
|
-
{ field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },
|
|
222
|
-
],
|
|
223
|
-
},
|
|
224
|
-
]);
|
|
225
|
-
});
|
|
226
|
-
it('If ds option provide contract address, it should use ds options "address"', () => {
|
|
227
|
-
const ds = {
|
|
228
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
229
|
-
assets: new Map(),
|
|
230
|
-
options: {
|
|
231
|
-
abi: 'erc20',
|
|
232
|
-
address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
|
|
233
|
-
},
|
|
234
|
-
startBlock: 1,
|
|
235
|
-
mapping: {
|
|
236
|
-
file: '',
|
|
237
|
-
handlers: [
|
|
238
|
-
{
|
|
239
|
-
handler: 'handleTransfer',
|
|
240
|
-
kind: types_ethereum_1.EthereumHandlerKind.Call,
|
|
241
|
-
filter: {
|
|
242
|
-
function: 'approve(address spender, uint256 rawAmount)',
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
],
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
const result = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)([ds]);
|
|
249
|
-
expect(result).toEqual([
|
|
250
|
-
{
|
|
251
|
-
entity: 'evmTransactions',
|
|
252
|
-
conditions: [
|
|
253
|
-
{
|
|
254
|
-
field: 'to',
|
|
255
|
-
matcher: 'equalTo',
|
|
256
|
-
value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
257
|
-
},
|
|
258
|
-
{ field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },
|
|
259
|
-
],
|
|
260
|
-
},
|
|
261
|
-
]);
|
|
262
|
-
});
|
|
263
|
-
it('If filter provide contract address, it should use filter "to"', () => {
|
|
264
|
-
const ds = {
|
|
265
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
266
|
-
assets: new Map(),
|
|
267
|
-
options: {
|
|
268
|
-
abi: 'erc20',
|
|
269
|
-
},
|
|
270
|
-
startBlock: 1,
|
|
271
|
-
mapping: {
|
|
272
|
-
file: '',
|
|
273
|
-
handlers: [
|
|
274
|
-
{
|
|
275
|
-
handler: 'handleTransfer',
|
|
276
|
-
kind: types_ethereum_1.EthereumHandlerKind.Call,
|
|
277
|
-
filter: {
|
|
278
|
-
to: '0xabcde',
|
|
279
|
-
function: 'approve(address spender, uint256 rawAmount)',
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
],
|
|
283
|
-
},
|
|
284
|
-
};
|
|
285
|
-
const result = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)([ds]);
|
|
286
|
-
expect(result).toEqual([
|
|
287
|
-
{
|
|
288
|
-
entity: 'evmTransactions',
|
|
289
|
-
conditions: [
|
|
290
|
-
{
|
|
291
|
-
field: 'to',
|
|
292
|
-
matcher: 'equalTo',
|
|
293
|
-
value: '0xabcde',
|
|
294
|
-
},
|
|
295
|
-
{ field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },
|
|
296
|
-
],
|
|
297
|
-
},
|
|
298
|
-
]);
|
|
299
|
-
});
|
|
300
|
-
it('Creates a valid filter with a single event handler that has 0 filters but a contract address', () => {
|
|
301
|
-
const ds = {
|
|
302
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
303
|
-
assets: new Map(),
|
|
304
|
-
options: {
|
|
305
|
-
abi: 'erc20',
|
|
306
|
-
address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
307
|
-
},
|
|
308
|
-
startBlock: 1,
|
|
309
|
-
mapping: {
|
|
310
|
-
file: '',
|
|
311
|
-
handlers: [
|
|
312
|
-
{
|
|
313
|
-
handler: 'handleTransfer',
|
|
314
|
-
kind: types_ethereum_1.EthereumHandlerKind.Event,
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
handler: 'handleTransfer',
|
|
318
|
-
kind: types_ethereum_1.EthereumHandlerKind.Call,
|
|
319
|
-
},
|
|
320
|
-
],
|
|
321
|
-
},
|
|
322
|
-
};
|
|
323
|
-
const result = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)([ds]);
|
|
324
|
-
expect(result).toEqual([
|
|
325
|
-
{
|
|
326
|
-
entity: 'evmLogs',
|
|
327
|
-
conditions: [
|
|
328
|
-
{
|
|
329
|
-
field: 'address',
|
|
330
|
-
matcher: 'equalTo',
|
|
331
|
-
value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
332
|
-
},
|
|
333
|
-
],
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
entity: 'evmTransactions',
|
|
337
|
-
conditions: [
|
|
338
|
-
{
|
|
339
|
-
field: 'to',
|
|
340
|
-
matcher: 'equalTo',
|
|
341
|
-
value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
342
|
-
},
|
|
343
|
-
],
|
|
344
|
-
},
|
|
345
|
-
]);
|
|
346
|
-
});
|
|
347
|
-
it('builds a filter when theres a block handler with modulo filter', () => {
|
|
348
|
-
const ds = {
|
|
349
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
350
|
-
assets: new Map(),
|
|
351
|
-
options: {
|
|
352
|
-
abi: 'erc20',
|
|
353
|
-
},
|
|
354
|
-
startBlock: 1,
|
|
355
|
-
mapping: {
|
|
356
|
-
file: '',
|
|
357
|
-
handlers: [
|
|
358
|
-
{
|
|
359
|
-
handler: 'handleTransfer',
|
|
360
|
-
kind: types_ethereum_1.EthereumHandlerKind.Call,
|
|
361
|
-
filter: {
|
|
362
|
-
to: '0xabcde',
|
|
363
|
-
function: 'approve(address spender, uint256 rawAmount)',
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
handler: 'handleBlock',
|
|
368
|
-
kind: types_ethereum_1.EthereumHandlerKind.Block,
|
|
369
|
-
filter: {
|
|
370
|
-
modulo: 200,
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
],
|
|
374
|
-
},
|
|
375
|
-
};
|
|
376
|
-
const result = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)([ds]);
|
|
377
|
-
expect(result).toEqual([
|
|
378
|
-
{
|
|
379
|
-
entity: 'evmTransactions',
|
|
380
|
-
conditions: [
|
|
381
|
-
{
|
|
382
|
-
field: 'to',
|
|
383
|
-
matcher: 'equalTo',
|
|
384
|
-
value: '0xabcde',
|
|
385
|
-
},
|
|
386
|
-
{ field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },
|
|
387
|
-
],
|
|
388
|
-
},
|
|
389
|
-
]);
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
describe('Correct dictionary query with dynamic ds', () => {
|
|
393
|
-
it('Build correct erc1155 transfer single query', () => {
|
|
394
|
-
const ds = {
|
|
395
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
396
|
-
assets: new Map(),
|
|
397
|
-
startBlock: 1,
|
|
398
|
-
mapping: {
|
|
399
|
-
file: '',
|
|
400
|
-
handlers: [
|
|
401
|
-
{
|
|
402
|
-
handler: 'handleDyanmicDs',
|
|
403
|
-
kind: types_ethereum_1.EthereumHandlerKind.Event,
|
|
404
|
-
filter: {
|
|
405
|
-
topics: [
|
|
406
|
-
'TransferSingle(address, address, address, uint256, uint256)',
|
|
407
|
-
],
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
],
|
|
411
|
-
},
|
|
412
|
-
};
|
|
413
|
-
const result = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)([ds]);
|
|
414
|
-
expect(result).toEqual([
|
|
415
|
-
{
|
|
416
|
-
entity: 'evmLogs',
|
|
417
|
-
conditions: [
|
|
418
|
-
{
|
|
419
|
-
field: 'topics0',
|
|
420
|
-
value: '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',
|
|
421
|
-
matcher: 'equalTo',
|
|
422
|
-
},
|
|
423
|
-
],
|
|
424
|
-
},
|
|
425
|
-
]);
|
|
426
|
-
});
|
|
427
|
-
it('Builds a groupded query for multiple dynamic ds', () => {
|
|
428
|
-
const ds = {
|
|
429
|
-
kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
|
|
430
|
-
assets: new Map(),
|
|
431
|
-
startBlock: 1,
|
|
432
|
-
mapping: {
|
|
433
|
-
file: '',
|
|
434
|
-
handlers: [
|
|
435
|
-
{
|
|
436
|
-
handler: 'handleDyanmicDs',
|
|
437
|
-
kind: types_ethereum_1.EthereumHandlerKind.Event,
|
|
438
|
-
filter: {
|
|
439
|
-
topics: [
|
|
440
|
-
'TransferMultiple(address, address, address, uint256, uint256)',
|
|
441
|
-
],
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
],
|
|
445
|
-
},
|
|
446
|
-
};
|
|
447
|
-
const duplicateDataSources = [
|
|
448
|
-
{ ...mockTempDs[0], options: { address: 'address1' } },
|
|
449
|
-
{ ...mockTempDs[0], options: { address: 'address2' } },
|
|
450
|
-
{ ...mockTempDs[1], options: { address: 'address3' } },
|
|
451
|
-
];
|
|
452
|
-
const dataSources = [ds, ...duplicateDataSources];
|
|
453
|
-
const queryEntry = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)(dataSources);
|
|
454
|
-
expect(queryEntry).toEqual([
|
|
455
|
-
{
|
|
456
|
-
conditions: [
|
|
457
|
-
{
|
|
458
|
-
field: 'topics0',
|
|
459
|
-
matcher: 'equalTo',
|
|
460
|
-
value: '0xeb9b7dd0d144caae51d14067d0d112bc1839fbf62e856fca78f6b4d9bfb51962',
|
|
461
|
-
},
|
|
462
|
-
],
|
|
463
|
-
entity: 'evmLogs',
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
conditions: [
|
|
467
|
-
{
|
|
468
|
-
field: 'address',
|
|
469
|
-
matcher: 'in',
|
|
470
|
-
value: ['address1', 'address2'],
|
|
471
|
-
},
|
|
472
|
-
{
|
|
473
|
-
field: 'topics0',
|
|
474
|
-
matcher: 'equalTo',
|
|
475
|
-
value: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
|
|
476
|
-
},
|
|
477
|
-
],
|
|
478
|
-
entity: 'evmLogs',
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
conditions: [
|
|
482
|
-
{
|
|
483
|
-
field: 'address',
|
|
484
|
-
matcher: 'equalTo',
|
|
485
|
-
value: 'address3',
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
field: 'topics0',
|
|
489
|
-
matcher: 'equalTo',
|
|
490
|
-
value: '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',
|
|
491
|
-
},
|
|
492
|
-
],
|
|
493
|
-
entity: 'evmLogs',
|
|
494
|
-
},
|
|
495
|
-
]);
|
|
496
|
-
});
|
|
497
|
-
it('Drops the address if multiple datasources have the same filters, but one without an address', () => {
|
|
498
|
-
const duplicateDataSources = [
|
|
499
|
-
{ ...mockTempDs[0], options: { address: 'address1' } },
|
|
500
|
-
{ ...mockTempDs[0], options: { address: 'address2' } },
|
|
501
|
-
{ ...mockTempDs[0], options: { address: undefined } },
|
|
502
|
-
];
|
|
503
|
-
const queryEntry = (0, ethDictionaryV1_1.buildDictionaryV1QueryEntries)(duplicateDataSources);
|
|
504
|
-
expect(queryEntry).toEqual([
|
|
505
|
-
{
|
|
506
|
-
conditions: [
|
|
507
|
-
{
|
|
508
|
-
field: 'topics0',
|
|
509
|
-
matcher: 'equalTo',
|
|
510
|
-
value: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
|
|
511
|
-
},
|
|
512
|
-
],
|
|
513
|
-
entity: 'evmLogs',
|
|
514
|
-
},
|
|
515
|
-
]);
|
|
516
|
-
});
|
|
517
|
-
});
|
|
518
|
-
});
|
|
519
|
-
//# sourceMappingURL=ethDictionaryV1.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ethDictionaryV1.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/ethDictionaryV1.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,gDAA8C;AAC9C,0DAI+B;AAC/B,qCAAwC;AAKxC,uDAG2B;AAE3B,MAAM,UAAU,GA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AClB,KAAK,EACH,oEAAoE;yBACvE;qBACF;oBACD,MAAM,EAAE,SAAS;iBAClB;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6FAA6F,EAAE,GAAG,EAAE;YACrG,MAAM,oBAAoB,GAAG;gBAC3B,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;gBACtD,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;gBACtD,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;aAC1B,CAAC;YAE9B,MAAM,UAAU,GAAG,IAAA,+CAA6B,EAAC,oBAAoB,CAAC,CAAC;YAEvE,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;gBACzB;oBACE,UAAU,EAAE;wBACV;4BACE,KAAK,EAAE,SAAS;4BAChB,OAAO,EAAE,SAAS;4BAClB,KAAK,EACH,oEAAoE;yBACvE;qBACF;oBACD,MAAM,EAAE,SAAS;iBAClB;aACF,CAAC,CAAC;QACL,CAAC,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 { NodeConfig } from '@subql/node-core';\nimport {\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport { GraphQLSchema } from 'graphql';\nimport {\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport {\n buildDictionaryV1QueryEntries,\n EthDictionaryV1,\n} from './ethDictionaryV1';\n\nconst mockTempDs: EthereumProjectDsTemplate[] = [\n {\n name: 'ERC721',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleERC721',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n },\n {\n name: 'ERC1155',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleERC1155',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'TransferSingle(address, address, address, uint256, uint256)',\n ],\n },\n },\n ],\n },\n },\n];\nfunction testSubqueryProject(\n endpoint: string,\n ds: any,\n mockTempDs,\n): SubqueryProject {\n return {\n network: {\n endpoint,\n chainId: '1',\n },\n dataSources: ds as any,\n id: 'test',\n root: './',\n schema: new GraphQLSchema({}),\n templates: mockTempDs as any,\n } as any;\n}\n\ndescribe('Eth Dictionary V1', () => {\n it('Can resovle chain aliases', async () => {\n (EthDictionaryV1.prototype as any).init = jest.fn();\n const dictionary = await EthDictionaryV1.create(\n {\n network: { chainId: '336', dictionary: 'https://foo.bar' } as any,\n } as any,\n new NodeConfig({} as any, true),\n '',\n );\n\n expect((dictionary as any).chainId).toBe(\n '0xf1cf9022c7ebb34b162d5b5e34e705a5a740b2d0ecc1009fb89023e62a488108',\n );\n\n jest.clearAllMocks();\n });\n});\n\ndescribe('buildDictionaryV1QueryEntries', () => {\n describe('Log filters', () => {\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 '!null',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV1QueryEntries([ds]);\n\n expect(result).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'address',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n {\n field: 'topics0',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n matcher: 'equalTo',\n },\n {\n field: 'topics3',\n value: false,\n matcher: 'isNull',\n },\n ],\n },\n ]);\n });\n });\n\n describe('Transaction filters', () => {\n it('Build a filter for contract creation transactions', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [{ field: 'to', matcher: 'isNull', value: true }],\n },\n ]);\n });\n\n it('Build a filter with include ds option and 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.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('If ds option and filter both provide contract address, it should use ds options one', () => {\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.Call,\n filter: {\n to: '0xabcde',\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('If ds option provide contract address, it should use ds options \"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.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('If filter provide contract address, it should use filter \"to\"', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: '0xabcde',\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0xabcde',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\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\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'address',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n ],\n },\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\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 },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: '0xabcde',\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleBlock',\n kind: EthereumHandlerKind.Block,\n filter: {\n modulo: 200,\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0xabcde',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n });\n\n describe('Correct dictionary query with dynamic ds', () => {\n it('Build correct erc1155 transfer single query', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleDyanmicDs',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'TransferSingle(address, address, address, uint256, uint256)',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'topics0',\n value:\n '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',\n matcher: 'equalTo',\n },\n ],\n },\n ]);\n });\n\n it('Builds a groupded query for multiple dynamic ds', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleDyanmicDs',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'TransferMultiple(address, address, address, uint256, uint256)',\n ],\n },\n },\n ],\n },\n };\n\n const duplicateDataSources = [\n { ...mockTempDs[0], options: { address: 'address1' } },\n { ...mockTempDs[0], options: { address: 'address2' } },\n { ...mockTempDs[1], options: { address: 'address3' } },\n ];\n\n const dataSources = [ds, ...duplicateDataSources];\n\n const queryEntry = buildDictionaryV1QueryEntries(dataSources);\n\n expect(queryEntry).toEqual([\n {\n conditions: [\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xeb9b7dd0d144caae51d14067d0d112bc1839fbf62e856fca78f6b4d9bfb51962',\n },\n ],\n entity: 'evmLogs',\n },\n {\n conditions: [\n {\n field: 'address',\n matcher: 'in',\n value: ['address1', 'address2'],\n },\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n },\n ],\n entity: 'evmLogs',\n },\n {\n conditions: [\n {\n field: 'address',\n matcher: 'equalTo',\n value: 'address3',\n },\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',\n },\n ],\n entity: 'evmLogs',\n },\n ]);\n });\n\n it('Drops the address if multiple datasources have the same filters, but one without an address', () => {\n const duplicateDataSources = [\n { ...mockTempDs[0], options: { address: 'address1' } },\n { ...mockTempDs[0], options: { address: 'address2' } },\n { ...mockTempDs[0], options: { address: undefined } },\n ] as SubqlRuntimeDatasource[];\n\n const queryEntry = buildDictionaryV1QueryEntries(duplicateDataSources);\n\n expect(queryEntry).toEqual([\n {\n conditions: [\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n },\n ],\n entity: 'evmLogs',\n },\n ]);\n });\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|