@subql/node-ethereum 6.2.1 → 6.2.2-1

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 +3 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/configure/SubqueryProject.js +7 -0
  4. package/dist/configure/SubqueryProject.js.map +1 -1
  5. package/dist/utils/project.d.ts +14 -1
  6. package/dist/utils/project.js +100 -0
  7. package/dist/utils/project.js.map +1 -1
  8. package/dist/utils/string.d.ts +8 -0
  9. package/dist/utils/string.js +202 -1
  10. package/dist/utils/string.js.map +1 -1
  11. package/package.json +4 -3
  12. package/dist/blockchain.service.test.d.ts +0 -1
  13. package/dist/blockchain.service.test.js +0 -27
  14. package/dist/blockchain.service.test.js.map +0 -1
  15. package/dist/ethereum/api.ethereum.test.d.ts +0 -1
  16. package/dist/ethereum/api.ethereum.test.js +0 -266
  17. package/dist/ethereum/api.ethereum.test.js.map +0 -1
  18. package/dist/ethereum/api.service.ethereum.test.d.ts +0 -1
  19. package/dist/ethereum/api.service.ethereum.test.js +0 -91
  20. package/dist/ethereum/api.service.ethereum.test.js.map +0 -1
  21. package/dist/ethereum/ethers/celo/celo-ws-provider.spec.d.ts +0 -1
  22. package/dist/ethereum/ethers/celo/celo-ws-provider.spec.js +0 -33
  23. package/dist/ethereum/ethers/celo/celo-ws-provider.spec.js.map +0 -1
  24. package/dist/ethereum/ethers/json-rpc-batch-provider.spec.d.ts +0 -1
  25. package/dist/ethereum/ethers/json-rpc-batch-provider.spec.js +0 -63
  26. package/dist/ethereum/ethers/json-rpc-batch-provider.spec.js.map +0 -1
  27. package/dist/ethereum/ethers/op/op-provider.spec.d.ts +0 -1
  28. package/dist/ethereum/ethers/op/op-provider.spec.js +0 -32
  29. package/dist/ethereum/ethers/op/op-provider.spec.js.map +0 -1
  30. package/dist/indexer/dictionary/utils.spec.d.ts +0 -1
  31. package/dist/indexer/dictionary/utils.spec.js +0 -101
  32. package/dist/indexer/dictionary/utils.spec.js.map +0 -1
  33. package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.d.ts +0 -1
  34. package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.js +0 -519
  35. package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.js.map +0 -1
  36. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.d.ts +0 -1
  37. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js +0 -585
  38. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js.map +0 -1
  39. package/dist/indexer/dictionary/v2/utils.spec.d.ts +0 -1
  40. package/dist/indexer/dictionary/v2/utils.spec.js +0 -92
  41. package/dist/indexer/dictionary/v2/utils.spec.js.map +0 -1
  42. package/dist/indexer/unfinalizedBlocks.service.spec.d.ts +0 -1
  43. package/dist/indexer/unfinalizedBlocks.service.spec.js +0 -169
  44. package/dist/indexer/unfinalizedBlocks.service.spec.js.map +0 -1
@@ -1,101 +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 types_ethereum_1 = require("@subql/types-ethereum");
6
- const utils_1 = require("./utils");
7
- describe('Dictionary utils', () => {
8
- it('can filter eth ds with multiple dynamic ds/templates', () => {
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
- const ds = {
48
- kind: types_ethereum_1.EthereumDatasourceKind.Runtime,
49
- assets: new Map(),
50
- startBlock: 1,
51
- mapping: {
52
- file: '',
53
- handlers: [
54
- {
55
- handler: 'handleDyanmicDs',
56
- kind: types_ethereum_1.EthereumHandlerKind.Event,
57
- filter: {
58
- topics: [
59
- 'TransferSingle(address, address, address, uint256, uint256)',
60
- ],
61
- },
62
- },
63
- ],
64
- },
65
- };
66
- const duplicateDataSources = [
67
- { ...mockTempDs[0], options: { address: 'address1' } },
68
- { ...mockTempDs[0], options: { address: 'address2' } },
69
- { ...mockTempDs[1], options: { address: 'address3' } },
70
- ];
71
- const dataSources = [ds, ...duplicateDataSources];
72
- // Runtime + ERC721 + ERC721 + ERC1155
73
- expect(dataSources.length).toBe(4);
74
- const grouped = (0, utils_1.groupedDataSources)(dataSources);
75
- expect(grouped).toEqual([
76
- [
77
- {
78
- handler: 'handleDyanmicDs',
79
- kind: 'ethereum/LogHandler',
80
- filter: {
81
- topics: [
82
- 'TransferSingle(address, address, address, uint256, uint256)',
83
- ],
84
- },
85
- },
86
- [undefined, 'address3'],
87
- ],
88
- [
89
- {
90
- handler: 'handleERC721',
91
- kind: 'ethereum/LogHandler',
92
- filter: {
93
- topics: ['Transfer(address, address, uint256)'],
94
- },
95
- },
96
- ['address1', 'address2'],
97
- ],
98
- ]);
99
- });
100
- });
101
- //# sourceMappingURL=utils.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../../src/indexer/dictionary/utils.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,0DAI+B;AAE/B,mCAA6C;AAE7C,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,UAAU,GAAgC;YAC9C;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,uCAAsB,CAAC,OAAO;gBACpC,MAAM,EAAE,IAAI,GAAG,EAAE;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,EAAE;oBACR,QAAQ,EAAE;wBACR;4BACE,OAAO,EAAE,cAAc;4BACvB,IAAI,EAAE,oCAAmB,CAAC,KAAK;4BAC/B,MAAM,EAAE;gCACN,MAAM,EAAE,CAAC,qCAAqC,CAAC;6BAChD;yBACF;qBACF;iBACF;aACF;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,uCAAsB,CAAC,OAAO;gBACpC,MAAM,EAAE,IAAI,GAAG,EAAE;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,EAAE;oBACR,QAAQ,EAAE;wBACR;4BACE,OAAO,EAAE,eAAe;4BACxB,IAAI,EAAE,oCAAmB,CAAC,KAAK;4BAC/B,MAAM,EAAE;gCACN,MAAM,EAAE;oCACN,6DAA6D;iCAC9D;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC;QAEF,MAAM,EAAE,GAA2B;YACjC,IAAI,EAAE,uCAAsB,CAAC,OAAO;YACpC,MAAM,EAAE,IAAI,GAAG,EAAE;YACjB,UAAU,EAAE,CAAC;YACb,OAAO,EAAE;gBACP,IAAI,EAAE,EAAE;gBACR,QAAQ,EAAE;oBACR;wBACE,OAAO,EAAE,iBAAiB;wBAC1B,IAAI,EAAE,oCAAmB,CAAC,KAAK;wBAC/B,MAAM,EAAE;4BACN,MAAM,EAAE;gCACN,6DAA6D;6BAC9D;yBACF;qBACF;iBACF;aACF;SACF,CAAC;QAEF,MAAM,oBAAoB,GAAG;YAC3B,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;YACtD,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;YACtD,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;SACvD,CAAC;QAEF,MAAM,WAAW,GAAG,CAAC,EAAE,EAAE,GAAG,oBAAoB,CAAC,CAAC;QAClD,sCAAsC;QACtC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEnC,MAAM,OAAO,GAAG,IAAA,0BAAkB,EAAC,WAAW,CAAC,CAAC;QAEhD,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;YACtB;gBACE;oBACE,OAAO,EAAE,iBAAiB;oBAC1B,IAAI,EAAE,qBAAqB;oBAC3B,MAAM,EAAE;wBACN,MAAM,EAAE;4BACN,6DAA6D;yBAC9D;qBACF;iBACF;gBACD,CAAC,SAAS,EAAE,UAAU,CAAC;aACxB;YACD;gBACE;oBACE,OAAO,EAAE,cAAc;oBACvB,IAAI,EAAE,qBAAqB;oBAC3B,MAAM,EAAE;wBACN,MAAM,EAAE,CAAC,qCAAqC,CAAC;qBAChD;iBACF;gBACD,CAAC,UAAU,EAAE,UAAU,CAAC;aACzB;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 {\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport { EthereumProjectDsTemplate } from '../../configure/SubqueryProject';\nimport { groupedDataSources } from './utils';\n\ndescribe('Dictionary utils', () => {\n it('can filter eth ds with multiple dynamic ds/templates', () => {\n const 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 ];\n\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\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 // Runtime + ERC721 + ERC721 + ERC1155\n expect(dataSources.length).toBe(4);\n\n const grouped = groupedDataSources(dataSources);\n\n expect(grouped).toEqual([\n [\n {\n handler: 'handleDyanmicDs',\n kind: 'ethereum/LogHandler',\n filter: {\n topics: [\n 'TransferSingle(address, address, address, uint256, uint256)',\n ],\n },\n },\n [undefined, 'address3'],\n ],\n [\n {\n handler: 'handleERC721',\n kind: 'ethereum/LogHandler',\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ['address1', 'address2'],\n ],\n ]);\n });\n});\n"]}
@@ -1 +0,0 @@
1
- export {};
@@ -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