@subql/node-ethereum 3.11.0 → 3.11.1-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/dist/.tsbuildinfo +1 -1
- package/dist/ethereum/api.connection.d.ts +4 -4
- package/dist/ethereum/api.connection.js.map +1 -1
- package/dist/ethereum/api.ethereum.d.ts +4 -3
- package/dist/ethereum/api.ethereum.js +6 -3
- package/dist/ethereum/api.ethereum.js.map +1 -1
- package/dist/ethereum/api.ethereum.test.js +13 -1
- package/dist/ethereum/api.ethereum.test.js.map +1 -1
- package/dist/ethereum/api.service.ethereum.d.ts +2 -2
- package/dist/ethereum/api.service.ethereum.js.map +1 -1
- package/dist/ethereum/block.ethereum.js +6 -2
- package/dist/ethereum/block.ethereum.js.map +1 -1
- package/dist/ethereum/utils.ethereum.d.ts +8 -1
- package/dist/ethereum/utils.ethereum.js +17 -1
- package/dist/ethereum/utils.ethereum.js.map +1 -1
- package/dist/indexer/blockDispatcher/block-dispatcher.service.d.ts +2 -3
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js +1 -4
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -1
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.d.ts +2 -1
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js.map +1 -1
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.d.ts +2 -1
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +0 -12
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -1
- package/dist/indexer/dictionary/ethDictionary.service.d.ts +9 -0
- package/dist/indexer/dictionary/ethDictionary.service.js +59 -0
- package/dist/indexer/dictionary/ethDictionary.service.js.map +1 -0
- package/dist/indexer/dictionary/utils.d.ts +3 -0
- package/dist/indexer/dictionary/utils.js +24 -0
- package/dist/indexer/dictionary/utils.js.map +1 -0
- package/dist/indexer/dictionary/utils.spec.js +83 -0
- package/dist/indexer/dictionary/utils.spec.js.map +1 -0
- package/dist/indexer/dictionary/v1/ethDictionaryV1.d.ts +16 -0
- package/dist/indexer/dictionary/v1/ethDictionaryV1.js +202 -0
- package/dist/indexer/dictionary/v1/ethDictionaryV1.js.map +1 -0
- package/dist/indexer/{fetch.service.spec.js → dictionary/v1/ethDictionaryV1.spec.js} +45 -23
- package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.js.map +1 -0
- package/dist/indexer/dictionary/v1/index.d.ts +1 -0
- package/dist/indexer/dictionary/v1/index.js +20 -0
- package/dist/indexer/dictionary/v1/index.js.map +1 -0
- package/dist/indexer/dictionary/v2/ethDictionaryV2.d.ts +14 -0
- package/dist/indexer/dictionary/v2/ethDictionaryV2.js +188 -0
- package/dist/indexer/dictionary/v2/ethDictionaryV2.js.map +1 -0
- package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.d.ts +1 -0
- package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js +232 -0
- package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js.map +1 -0
- package/dist/indexer/dictionary/v2/index.d.ts +2 -0
- package/dist/indexer/dictionary/v2/index.js +21 -0
- package/dist/indexer/dictionary/v2/index.js.map +1 -0
- package/dist/indexer/dictionary/v2/types.d.ts +75 -0
- package/dist/indexer/dictionary/v2/types.js +5 -0
- package/dist/indexer/dictionary/v2/types.js.map +1 -0
- package/dist/indexer/dictionary/v2/utils.d.ts +4 -0
- package/dist/indexer/dictionary/v2/utils.js +22 -0
- package/dist/indexer/dictionary/v2/utils.js.map +1 -0
- package/dist/indexer/dictionary/v2/utils.spec.d.ts +1 -0
- package/dist/indexer/dictionary/v2/utils.spec.js +98 -0
- package/dist/indexer/dictionary/v2/utils.spec.js.map +1 -0
- package/dist/indexer/fetch.module.js +4 -3
- package/dist/indexer/fetch.module.js.map +1 -1
- package/dist/indexer/fetch.service.d.ts +4 -14
- package/dist/indexer/fetch.service.js +4 -177
- package/dist/indexer/fetch.service.js.map +1 -1
- package/dist/indexer/indexer.manager.d.ts +5 -5
- package/dist/indexer/indexer.manager.js +3 -3
- package/dist/indexer/indexer.manager.js.map +1 -1
- package/dist/indexer/unfinalizedBlocks.service.d.ts +1 -5
- package/dist/indexer/unfinalizedBlocks.service.js +5 -21
- package/dist/indexer/unfinalizedBlocks.service.js.map +1 -1
- package/dist/indexer/worker/worker.service.d.ts +4 -4
- package/dist/indexer/worker/worker.service.js +1 -1
- package/dist/indexer/worker/worker.service.js.map +1 -1
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.d.ts +2 -2
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js +2 -6
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js.map +1 -1
- package/dist/subcommands/testing.service.d.ts +2 -2
- package/dist/subcommands/testing.service.js.map +1 -1
- package/package.json +8 -7
- package/dist/indexer/dictionary.service.d.ts +0 -11
- package/dist/indexer/dictionary.service.js +0 -72
- package/dist/indexer/dictionary.service.js.map +0 -1
- package/dist/indexer/dictionary.service.spec.js +0 -15
- package/dist/indexer/dictionary.service.spec.js.map +0 -1
- package/dist/indexer/fetch.service.spec.js.map +0 -1
- /package/dist/indexer/{dictionary.service.spec.d.ts → dictionary/utils.spec.d.ts} +0 -0
- /package/dist/indexer/{fetch.service.spec.d.ts → dictionary/v1/ethDictionaryV1.spec.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.unfinalizedBlocks.service.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.unfinalizedBlocks.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;AAEnC,mDAA8C;AAC9C,2CAA4C;
|
|
1
|
+
{"version":3,"file":"worker.unfinalizedBlocks.service.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.unfinalizedBlocks.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;AAEnC,mDAA8C;AAC9C,2CAA4C;AAUrC,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAGzC,YAAoB,IAA2B;QAA3B,SAAI,GAAJ,IAAI,CAAuB;QAC7C,IAAI,6BAAY,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;IACH,CAAC;IAED,KAAK,CAAC,6BAA6B,CAAC,MAAc;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,wBAAwB,CAC5B,KAA2B;QAE3B,OAAO,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,qEAAqE;IACrE,IAAI,CAAC,OAAgD;QACnD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,sBAAsB;QACpB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,gCAAgC;QAC9B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,qEAAqE;IACrE,4BAA4B;QAC1B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;CACF,CAAA;AAjCY,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;;GACA,8BAA8B,CAiC1C;AAjCY,wEAA8B","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { isMainThread } from 'worker_threads';\nimport { Injectable } from '@nestjs/common';\nimport {\n Header,\n HostUnfinalizedBlocks,\n IBlock,\n IUnfinalizedBlocksService,\n} from '@subql/node-core';\nimport { BlockContent } from '../types';\n\n@Injectable()\nexport class WorkerUnfinalizedBlocksService\n implements IUnfinalizedBlocksService<BlockContent>\n{\n constructor(private host: HostUnfinalizedBlocks) {\n if (isMainThread) {\n throw new Error('Expected to be worker thread');\n }\n }\n\n async processUnfinalizedBlockHeader(header: Header): Promise<number | null> {\n return this.host.unfinalizedBlocksProcess(header);\n }\n\n async processUnfinalizedBlocks(\n block: IBlock<BlockContent>,\n ): Promise<number | null> {\n return this.host.unfinalizedBlocksProcess(block.getHeader());\n }\n\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n init(reindex: (targetHeight: number) => Promise<void>): Promise<number> {\n throw new Error('This method should not be called from a worker');\n }\n resetUnfinalizedBlocks(): void {\n throw new Error('This method should not be called from a worker');\n }\n resetLastFinalizedVerifiedHeight(): void {\n throw new Error('This method should not be called from a worker');\n }\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n getMetadataUnfinalizedBlocks(): Promise<Header[]> {\n throw new Error('This method should not be called from a worker');\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeConfig, TestingService as BaseTestingService, TestRunner } from '@subql/node-core';
|
|
1
|
+
import { NodeConfig, TestingService as BaseTestingService, TestRunner, IBlock } from '@subql/node-core';
|
|
2
2
|
import { EthereumProjectDs, SubqueryProject } from '../configure/SubqueryProject';
|
|
3
3
|
import { EthereumApi } from '../ethereum';
|
|
4
4
|
import SafeEthProvider from '../ethereum/safe-api';
|
|
@@ -10,5 +10,5 @@ export declare class TestingService extends BaseTestingService<EthereumApi, Safe
|
|
|
10
10
|
close: () => Promise<void>,
|
|
11
11
|
runner: TestRunner<EthereumApi, SafeEthProvider, BlockContent, EthereumProjectDs>
|
|
12
12
|
]>;
|
|
13
|
-
indexBlock(block: BlockContent
|
|
13
|
+
indexBlock(block: IBlock<BlockContent>, handler: string, indexerManager: IndexerManager): Promise<void>;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.service.js","sourceRoot":"","sources":["../../src/subcommands/testing.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,uCAA2C;AAE3C,
|
|
1
|
+
{"version":3,"file":"testing.service.js","sourceRoot":"","sources":["../../src/subcommands/testing.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,uCAA2C;AAE3C,gDAM0B;AAC1B,kEAGsC;AAMtC,qDAAiD;AAG1C,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,0BAKnC;IACC,YACE,UAAsB,EACM,OAAwB;QAEpD,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,aAAa;QAWjB,MAAM,WAAW,GAAG,MAAM,kBAAW,CAAC,wBAAwB,CAC5D,8BAAa,EACb;YACE,MAAM,EAAE,IAAI,sBAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;SAChD,CACF,CAAC;QAEF,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;QAEzB,MAAM,cAAc,GAAmB,WAAW,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAE1E,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC;QAE5B,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,sBAAU,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,UAAU,CACd,KAA2B,EAC3B,OAAe,EACf,cAA8B;QAE9B,MAAM,cAAc,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACzE,CAAC;CACF,CAAA;AA/CY,cAAc;IAD1B,IAAA,mBAAU,GAAE;IASR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCADf,sBAAU;QACe,iCAAe;GAR3C,cAAc,CA+C1B;AA/CY,wCAAc","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { NestFactory } from '@nestjs/core';\n\nimport {\n NodeConfig,\n TestingService as BaseTestingService,\n NestLogger,\n TestRunner,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumProjectDs,\n SubqueryProject,\n} from '../configure/SubqueryProject';\nimport { EthereumApi } from '../ethereum';\nimport SafeEthProvider from '../ethereum/safe-api';\nimport { IndexerManager } from '../indexer/indexer.manager';\nimport { ProjectService } from '../indexer/project.service';\nimport { BlockContent } from '../indexer/types';\nimport { TestingModule } from './testing.module';\n\n@Injectable()\nexport class TestingService extends BaseTestingService<\n EthereumApi,\n SafeEthProvider,\n BlockContent,\n EthereumProjectDs\n> {\n constructor(\n nodeConfig: NodeConfig,\n @Inject('ISubqueryProject') project: SubqueryProject,\n ) {\n super(nodeConfig, project);\n }\n\n async getTestRunner(): Promise<\n [\n close: () => Promise<void>,\n runner: TestRunner<\n EthereumApi,\n SafeEthProvider,\n BlockContent,\n EthereumProjectDs\n >,\n ]\n > {\n const testContext = await NestFactory.createApplicationContext(\n TestingModule,\n {\n logger: new NestLogger(!!this.nodeConfig.debug),\n },\n );\n\n await testContext.init();\n\n const projectService: ProjectService = testContext.get('IProjectService');\n\n await projectService.init();\n\n return [testContext.close.bind(testContext), testContext.get(TestRunner)];\n }\n\n async indexBlock(\n block: IBlock<BlockContent>,\n handler: string,\n indexerManager: IndexerManager,\n ): Promise<void> {\n await indexerManager.indexBlock(block, this.getDsWithHandler(handler));\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subql/node-ethereum",
|
|
3
|
-
"version": "3.11.0",
|
|
3
|
+
"version": "3.11.1-0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Ian He",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"@nestjs/event-emitter": "^2.0.0",
|
|
26
26
|
"@nestjs/platform-express": "^9.4.0",
|
|
27
27
|
"@nestjs/schedule": "^3.0.1",
|
|
28
|
-
"@subql/common": "^3.4.1",
|
|
29
|
-
"@subql/common-ethereum": "3.4.
|
|
30
|
-
"@subql/node-core": "^7.5.
|
|
31
|
-
"@subql/testing": "^2.1.0",
|
|
32
|
-
"@subql/types-ethereum": "3.4.0",
|
|
28
|
+
"@subql/common": "^3.4.2-1",
|
|
29
|
+
"@subql/common-ethereum": "3.4.2-0",
|
|
30
|
+
"@subql/node-core": "^7.5.1-3",
|
|
31
|
+
"@subql/testing": "^2.1.1-0",
|
|
32
|
+
"@subql/types-ethereum": "3.4.1-0",
|
|
33
33
|
"cacheable-lookup": "6",
|
|
34
34
|
"cron-converter": "^1.0.2",
|
|
35
35
|
"ethers": "^5.7.0",
|
|
@@ -65,5 +65,6 @@
|
|
|
65
65
|
"files": [
|
|
66
66
|
"/dist",
|
|
67
67
|
"/bin"
|
|
68
|
-
]
|
|
68
|
+
],
|
|
69
|
+
"stableVersion": "3.11.0"
|
|
69
70
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
2
|
-
import { NodeConfig, DictionaryService as CoreDictionaryService } from '@subql/node-core';
|
|
3
|
-
import { MetaData } from '@subql/utils';
|
|
4
|
-
import { SubqueryProject } from '../configure/SubqueryProject';
|
|
5
|
-
export declare class DictionaryService extends CoreDictionaryService {
|
|
6
|
-
protected project: SubqueryProject;
|
|
7
|
-
private constructor();
|
|
8
|
-
static create(project: SubqueryProject, nodeConfig: NodeConfig, eventEmitter: EventEmitter2): Promise<DictionaryService>;
|
|
9
|
-
protected validateChainMeta(metaData: MetaData): boolean;
|
|
10
|
-
private static getEvmChainId;
|
|
11
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
|
|
3
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
5
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
-
};
|
|
10
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
11
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
12
|
-
};
|
|
13
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
14
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
var DictionaryService_1;
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.DictionaryService = void 0;
|
|
22
|
-
const common_1 = require("@nestjs/common");
|
|
23
|
-
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
24
|
-
const common_2 = require("@subql/common");
|
|
25
|
-
const node_core_1 = require("@subql/node-core");
|
|
26
|
-
const json5_1 = __importDefault(require("json5"));
|
|
27
|
-
const SubqueryProject_1 = require("../configure/SubqueryProject");
|
|
28
|
-
const CHAIN_ALIASES_URL = 'https://raw.githubusercontent.com/subquery/templates/main/chainAliases.json5';
|
|
29
|
-
const logger = (0, node_core_1.getLogger)('dictionary');
|
|
30
|
-
let DictionaryService = DictionaryService_1 = class DictionaryService extends node_core_1.DictionaryService {
|
|
31
|
-
constructor(project, nodeConfig, eventEmitter, chainId, dictionaryUrl) {
|
|
32
|
-
super(dictionaryUrl !== null && dictionaryUrl !== void 0 ? dictionaryUrl : project.network.dictionary, chainId !== null && chainId !== void 0 ? chainId : project.network.chainId, nodeConfig, eventEmitter);
|
|
33
|
-
this.project = project;
|
|
34
|
-
}
|
|
35
|
-
static async create(project, nodeConfig, eventEmitter) {
|
|
36
|
-
var _a;
|
|
37
|
-
/*Some dictionarys for EVM are built with other SDKs as they are chains with an EVM runtime
|
|
38
|
-
* we maintain a list of aliases so we can map the evmChainId to the genesis hash of the other SDKs
|
|
39
|
-
* e.g moonbeam is built with Substrate SDK but can be used as an EVM dictionary
|
|
40
|
-
*/
|
|
41
|
-
const chainAliases = await this.getEvmChainId();
|
|
42
|
-
const chainAlias = chainAliases[project.network.chainId];
|
|
43
|
-
const url = (_a = project.network.dictionary) !== null && _a !== void 0 ? _a : (await node_core_1.DictionaryService.resolveDictionary(common_2.NETWORK_FAMILY.ethereum, chainAlias, nodeConfig.dictionaryRegistry));
|
|
44
|
-
return new DictionaryService_1(project, nodeConfig, eventEmitter, chainAlias, url);
|
|
45
|
-
}
|
|
46
|
-
validateChainMeta(metaData) {
|
|
47
|
-
// Due to dictionary metadata doesn't include chainId, in here we only validate endpoint genesisHash with metadata
|
|
48
|
-
return this.apiGenesisHash === metaData.genesisHash;
|
|
49
|
-
}
|
|
50
|
-
static async getEvmChainId() {
|
|
51
|
-
try {
|
|
52
|
-
// Use fetch added in nodejs 18, it is missing from @types/node though so we need the cast
|
|
53
|
-
const response = await global.fetch(CHAIN_ALIASES_URL);
|
|
54
|
-
const raw = await response.text();
|
|
55
|
-
// We use JSON5 here because the file has comments in it
|
|
56
|
-
return json5_1.default.parse(raw);
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
logger.warn(e, `Unable to get chain aliases. If you're using a Substrate based network with EVM then the dictionary may not work`);
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
DictionaryService = DictionaryService_1 = __decorate([
|
|
65
|
-
(0, common_1.Injectable)(),
|
|
66
|
-
__param(0, (0, common_1.Inject)('ISubqueryProject')),
|
|
67
|
-
__metadata("design:paramtypes", [SubqueryProject_1.SubqueryProject,
|
|
68
|
-
node_core_1.NodeConfig,
|
|
69
|
-
event_emitter_1.EventEmitter2, String, String])
|
|
70
|
-
], DictionaryService);
|
|
71
|
-
exports.DictionaryService = DictionaryService;
|
|
72
|
-
//# sourceMappingURL=dictionary.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.service.js","sourceRoot":"","sources":["../../src/indexer/dictionary.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,yDAAsD;AACtD,0CAA+C;AAC/C,gDAI0B;AAE1B,kDAA0B;AAC1B,kEAA+D;AAE/D,MAAM,iBAAiB,GACrB,8EAA8E,CAAC;AAEjF,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,YAAY,CAAC,CAAC;AAGhC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAkB,SAAQ,6BAAqB;IAC1D,YACwC,OAAwB,EAC9D,UAAsB,EACtB,YAA2B,EAC3B,OAAgB,EAChB,aAAsB;QAEtB,KAAK,CACH,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,OAAO,CAAC,OAAO,CAAC,UAAU,EAC3C,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,OAAO,CAAC,OAAO,CAAC,OAAO,EAClC,UAAU,EACV,YAAY,CACb,CAAC;QAXoC,YAAO,GAAP,OAAO,CAAiB;IAYhE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,OAAwB,EACxB,UAAsB,EACtB,YAA2B;;QAE3B;;;WAGG;QACH,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEzD,MAAM,GAAG,GACP,MAAA,OAAO,CAAC,OAAO,CAAC,UAAU,mCAC1B,CAAC,MAAM,6BAAqB,CAAC,iBAAiB,CAC5C,uBAAc,CAAC,QAAQ,EACvB,UAAU,EACV,UAAU,CAAC,kBAAkB,CAC9B,CAAC,CAAC;QAEL,OAAO,IAAI,mBAAiB,CAC1B,OAAO,EACP,UAAU,EACV,YAAY,EACZ,UAAU,EACV,GAAG,CACJ,CAAC;IACJ,CAAC;IAES,iBAAiB,CAAC,QAAkB;QAC5C,kHAAkH;QAClH,OAAO,IAAI,CAAC,cAAc,KAAK,QAAQ,CAAC,WAAW,CAAC;IACtD,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,aAAa;QAChC,IAAI;YACF,0FAA0F;YAC1F,MAAM,QAAQ,GAAG,MAAO,MAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YAChE,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAElC,wDAAwD;YACxD,OAAO,eAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACzB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,IAAI,CACT,CAAC,EACD,kHAAkH,CACnH,CAAC;YACF,OAAO,EAAE,CAAC;SACX;IACH,CAAC;CACF,CAAA;AAlEY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAAoB,iCAAe;QAClD,sBAAU;QACR,6BAAa;GAJlB,iBAAiB,CAkE7B;AAlEY,8CAAiB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { NETWORK_FAMILY } from '@subql/common';\nimport {\n NodeConfig,\n DictionaryService as CoreDictionaryService,\n getLogger,\n} from '@subql/node-core';\nimport { MetaData } from '@subql/utils';\nimport JSON5 from 'json5';\nimport { SubqueryProject } from '../configure/SubqueryProject';\n\nconst CHAIN_ALIASES_URL =\n 'https://raw.githubusercontent.com/subquery/templates/main/chainAliases.json5';\n\nconst logger = getLogger('dictionary');\n\n@Injectable()\nexport class DictionaryService extends CoreDictionaryService {\n private constructor(\n @Inject('ISubqueryProject') protected project: SubqueryProject,\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n chainId?: string,\n dictionaryUrl?: string,\n ) {\n super(\n dictionaryUrl ?? project.network.dictionary,\n chainId ?? project.network.chainId,\n nodeConfig,\n eventEmitter,\n );\n }\n\n static async create(\n project: SubqueryProject,\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n ): Promise<DictionaryService> {\n /*Some dictionarys for EVM are built with other SDKs as they are chains with an EVM runtime\n * we maintain a list of aliases so we can map the evmChainId to the genesis hash of the other SDKs\n * e.g moonbeam is built with Substrate SDK but can be used as an EVM dictionary\n */\n const chainAliases = await this.getEvmChainId();\n const chainAlias = chainAliases[project.network.chainId];\n\n const url =\n project.network.dictionary ??\n (await CoreDictionaryService.resolveDictionary(\n NETWORK_FAMILY.ethereum,\n chainAlias,\n nodeConfig.dictionaryRegistry,\n ));\n\n return new DictionaryService(\n project,\n nodeConfig,\n eventEmitter,\n chainAlias,\n url,\n );\n }\n\n protected validateChainMeta(metaData: MetaData): boolean {\n // Due to dictionary metadata doesn't include chainId, in here we only validate endpoint genesisHash with metadata\n return this.apiGenesisHash === metaData.genesisHash;\n }\n\n private static async getEvmChainId(): Promise<Record<string, string>> {\n try {\n // Use fetch added in nodejs 18, it is missing from @types/node though so we need the cast\n const response = await (global as any).fetch(CHAIN_ALIASES_URL);\n const raw = await response.text();\n\n // We use JSON5 here because the file has comments in it\n return JSON5.parse(raw);\n } catch (e) {\n logger.warn(\n e,\n `Unable to get chain aliases. If you're using a Substrate based network with EVM then the dictionary may not work`,\n );\n return {};\n }\n }\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2020-2024 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 dictionary_service_1 = require("./dictionary.service");
|
|
7
|
-
describe('Dictionary service', () => {
|
|
8
|
-
it('Can resovle chain aliases', async () => {
|
|
9
|
-
const dictionary = await dictionary_service_1.DictionaryService.create({
|
|
10
|
-
network: { chainId: '336', dictionary: 'https://foo.bar' },
|
|
11
|
-
}, new node_core_1.NodeConfig({}, true), null);
|
|
12
|
-
expect(dictionary.chainId).toBe('0xf1cf9022c7ebb34b162d5b5e34e705a5a740b2d0ecc1009fb89023e62a488108');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
//# sourceMappingURL=dictionary.service.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.service.spec.js","sourceRoot":"","sources":["../../src/indexer/dictionary.service.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,gDAA8C;AAC9C,6DAAyD;AAEzD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,UAAU,GAAG,MAAM,sCAAiB,CAAC,MAAM,CAC/C;YACE,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAS;SAC3D,EACR,IAAI,sBAAU,CAAC,EAAS,EAAE,IAAI,CAAC,EAC/B,IAAI,CACL,CAAC;QAEF,MAAM,CAAE,UAAkB,CAAC,OAAO,CAAC,CAAC,IAAI,CACtC,oEAAoE,CACrE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NodeConfig } from '@subql/node-core';\nimport { DictionaryService } from './dictionary.service';\n\ndescribe('Dictionary service', () => {\n it('Can resovle chain aliases', async () => {\n const dictionary = await DictionaryService.create(\n {\n network: { chainId: '336', dictionary: 'https://foo.bar' } as any,\n } as any,\n new NodeConfig({} as any, true),\n null,\n );\n\n expect((dictionary as any).chainId).toBe(\n '0xf1cf9022c7ebb34b162d5b5e34e705a5a740b2d0ecc1009fb89023e62a488108',\n );\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.service.spec.js","sourceRoot":"","sources":["../../src/indexer/fetch.service.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,0DAI+B;AAC/B,qCAAwC;AAKxC,mDAA4E;AAE5E,gEAAgE;AAChE,MAAM,aAAa,GAAG,0BAA0B,CAAC;AACjD,MAAM,UAAU,GAAgC;IAC9C;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,OAAO,EAAE;YACP,IAAI,EAAE,EAAE;YACR,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,cAAc;oBACvB,IAAI,EAAE,oCAAmB,CAAC,KAAK;oBAC/B,MAAM,EAAE;wBACN,MAAM,EAAE,CAAC,qCAAqC,CAAC;qBAChD;iBACF;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,OAAO,EAAE;YACP,IAAI,EAAE,EAAE;YACR,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,eAAe;oBACxB,IAAI,EAAE,oCAAmB,CAAC,KAAK;oBAC/B,MAAM,EAAE;wBACN,MAAM,EAAE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ACJ,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,CACL,CAAC;YAEF,MAAM,UAAU,GAAI,YAAoB,CAAC,2BAA2B,CAClE,WAAW,CACZ,CAAC;YAEF,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;gBACzB;oBACE,MAAM,EAAE,SAAS;oBACjB,UAAU,EAAE;wBACV;4BACE,KAAK,EAAE,SAAS;4BAChB,KAAK,EACH,oEAAoE;4BACtE,OAAO,EAAE,SAAS;yBACnB;qBACF;iBACF;gBACD;oBACE,MAAM,EAAE,SAAS;oBACjB,UAAU,EAAE;wBACV;4BACE,KAAK,EAAE,SAAS;4BAChB,2EAA2E;4BAC3E,KAAK,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;4BAC/B,OAAO,EAAE,IAAI;yBACd;wBACD;4BACE,KAAK,EAAE,SAAS;4BAChB,KAAK,EACH,oEAAoE;4BACtE,OAAO,EAAE,SAAS;yBACnB;qBACF;iBACF;gBACD;oBACE,MAAM,EAAE,SAAS;oBACjB,UAAU,EAAE;wBACV,0FAA0F;wBAC1F;4BACE,KAAK,EAAE,SAAS;4BAChB,KAAK,EAAE,UAAU;4BACjB,OAAO,EAAE,SAAS;yBACnB;wBACD;4BACE,KAAK,EAAE,SAAS;4BAChB,KAAK,EACH,oEAAoE;4BACtE,OAAO,EAAE,SAAS;yBACnB;qBACF;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 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 { GraphQLSchema } from 'graphql';\nimport {\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../configure/SubqueryProject';\nimport { buildDictionaryQueryEntries, FetchService } from './fetch.service';\n\n// const HTTP_ENDPOINT = 'https://eth.api.onfinality.io/public';\nconst HTTP_ENDPOINT = 'https://eth.llamarpc.com';\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];\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('Dictionary queries', () => {\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 = buildDictionaryQueryEntries([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 = buildDictionaryQueryEntries([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 = buildDictionaryQueryEntries([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 = buildDictionaryQueryEntries([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 = buildDictionaryQueryEntries([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 = buildDictionaryQueryEntries([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 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 = buildDictionaryQueryEntries([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 '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\n const project = testSubqueryProject(\n HTTP_ENDPOINT,\n dataSources,\n mockTempDs,\n );\n\n const fetchService = new FetchService(\n null,\n null,\n null,\n project,\n null,\n null,\n null,\n null,\n null,\n null,\n );\n\n const queryEntry = (fetchService as any).buildDictionaryQueryEntries(\n dataSources,\n );\n\n expect(queryEntry).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'topics0',\n value:\n '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',\n matcher: 'equalTo',\n },\n ],\n },\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'address',\n // This is what we're looking to happen with multiple instances of template\n value: ['address1', 'address2'],\n matcher: 'in',\n },\n {\n field: 'topics0',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n matcher: 'equalTo',\n },\n ],\n },\n {\n entity: 'evmLogs',\n conditions: [\n // This condition should not be grouped because there is a single instance of the tamplate\n {\n field: 'address',\n value: 'address3',\n matcher: 'equalTo',\n },\n {\n field: 'topics0',\n value:\n '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',\n matcher: 'equalTo',\n },\n ],\n },\n ]);\n });\n });\n});\n"]}
|
|
File without changes
|
|
File without changes
|