@subql/node-ethereum 3.11.1-0 → 3.11.1-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.
@@ -1 +1 @@
1
- {"version":3,"file":"ethDictionaryV2.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,gDAK0B;AAC1B,0DAM+B;AAK/B,uDAG2B;AAE3B,MAAM,kBAAkB,GAAG,uCAAuC,CAAC;AAEnE,MAAM,aAAa,GAAG,0CAA0C,CAAC;AACjE,MAAM,MAAM,GAAwB;IAClC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,UAAU,EAAE,OAAO;QACnB,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,mBAAmB;oBAC5B,IAAI,EAAE,oCAAmB,CAAC,IAAI;oBAC9B,MAAM,EAAE;wBACN,QAAQ,EAAE,6CAA6C;qBACxD;iBACF;gBACD;oBACE,OAAO,EAAE,WAAW;oBACpB,IAAI,EAAE,oCAAmB,CAAC,KAAK;oBAC/B,MAAM,EAAE;wBACN,MAAM,EAAE;4BACN,oEAAoE;yBACrE;qBACF;iBACF;aACF;SACF;KACF;CACF,CAAC;AAEF,gBAAgB;AAChB,MAAM,OAAO,GAAwB;IACnC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,UAAU,EAAE,OAAO;QACnB,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,mBAAmB;oBAC5B,IAAI,EAAE,oCAAmB,CAAC,IAAI;oBAC9B,MAAM,EAAE;wBACN,EAAE,EAAE,IAAI;qBACT;iBACF;aACF;S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M,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE;gBACJ;oBACE,OAAO,EAAE,CAAC,4CAA4C,CAAC;oBACvD,OAAO,EAAE;wBACP,oEAAoE;qBACrE;iBACF;aACF;YACD,YAAY,EAAE;gBACZ;oBACE,IAAI,EAAE,CAAC,aAAa,CAAC;oBACrB,QAAQ,EAAE,CAAC,YAAY,CAAC;iBACzB;aACF;SACF,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 NodeConfig,\n BlockHeightMap,\n IBlock,\n DictionaryResponse,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlDatasource,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport {\n EthereumProjectDs,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport {\n buildDictionaryV2QueryEntry,\n EthDictionaryV2,\n} from './ethDictionaryV2';\n\nconst DEFAULT_DICTIONARY = 'http://localhost:3000/rpc/eth-mainnet';\n\nconst HTTP_ENDPOINT = 'https://polygon.api.onfinality.io/public';\nconst mockDs: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 3678215,\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\n// tx to is null\nconst mockDs2: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 3678215,\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 },\n];\n\nconst nodeConfig = new NodeConfig({\n subquery: 'polygon-starter',\n subqueryName: 'polygon-starter',\n dictionaryTimeout: 10,\n networkEndpoint: [HTTP_ENDPOINT],\n networkDictionary: [`${DEFAULT_DICTIONARY}/polygon`],\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, 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 ethBlock3678215: EthereumBlock;\n let ethBlock3678250: EthereumBlock;\n\n const dsMap = makeBlockHeightMap(mockDs);\n\n beforeEach(async () => {\n ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n undefined,\n { network: { chainId: '10' } } as SubqueryProject,\n '10',\n );\n\n ethDictionaryV2.updateQueriesMap(dsMap);\n });\n\n it('convert ds to v2 dictionary queries', () => {\n //Polygon\n const query = (ethDictionaryV2 as any).queriesMap.get(3678215);\n expect(query.logs.length).toBe(1);\n expect(query.transactions.length).toBe(1);\n }, 100000);\n\n it('query response match with entries', async () => {\n //Polygon\n const ethBlocks = (await ethDictionaryV2.getData(\n 3678215,\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 3678215, 3678250,\n ]);\n\n ethBlock3678215 = ethBlocks.batchBlocks[0].block;\n ethBlock3678250 = ethBlocks.batchBlocks[1].block;\n\n expect(ethBlock3678215.number).toBe(3678215);\n expect(ethBlock3678250.number).toBe(3678250);\n\n // To match with dictionaryQueryEntries[0].func\n expect(ethBlock3678215.transactions[0].input.indexOf('0x60806040')).toBe(0);\n\n expect(ethBlock3678250.logs.length).toBe(1);\n // This matches with dictionaryQueryEntries[0].topics\n expect(ethBlock3678250.logs[0].topics).toContain(\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n );\n }, 100000);\n\n it('able to convert raw v2 Blocks into eth blocks when getData', async () => {\n //Polygon\n const ethBlocks = (await ethDictionaryV2.getData(\n 3678215,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n expect(ethBlocks.batchBlocks[0].block.number).toStrictEqual(3678215);\n expect(ethBlocks.lastBufferedHeight).toStrictEqual(3678250);\n\n // Can include input and hash\n // https://polygonscan.com/tx/0xb1b5f7882fa8d62d3650948c08066e928b7b5c9d607d2fe8c7e6ce57caf06774\n expect(ethBlocks.batchBlocks[1].block.transactions[1].hash).toBe(\n `0xb1b5f7882fa8d62d3650948c08066e928b7b5c9d607d2fe8c7e6ce57caf06774`,\n );\n expect(ethBlocks.batchBlocks[1].block.transactions[1].input).toBe(\n `0x23b872dd000000000000000000000000244a79a2e79e8d884d9c9cc425d88f9e2ed988ca000000000000000000000000d22c4c383ce5efa0364d5fab5ce1313c24a52bda0000000000000000000000000000000000000000000000000000000000000159`,\n );\n\n // relate logs\n // https://polygonscan.com/tx/0xb1b5f7882fa8d62d3650948c08066e928b7b5c9d607d2fe8c7e6ce57caf06774#eventlog\n expect(ethBlocks.batchBlocks[1].block.logs[0].data).toBe(`0x`);\n }, 500000);\n});\n\n// TODO, check this\nit.skip('able to get transaction with field to is null', async () => {\n const dsMap = makeBlockHeightMap(mockDs2);\n const ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n undefined,\n { network: { chainId: '10' } } as SubqueryProject,\n '10',\n );\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions, queryEndBlock } = (\n ethDictionaryV2 as any\n ).getQueryConditions(3678215, (ethDictionaryV2 as any)._metadata.end);\n\n expect(conditions).toBe({ transactions: [{ to: null }] });\n const ethBlocks = (await ethDictionaryV2.getData(\n 3678215,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n}, 50000);\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 '!null',\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('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 function: ['0x7ef9ea98'],\n },\n ],\n });\n });\n});\n"]}
1
+ {"version":3,"file":"ethDictionaryV2.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;AAEnC,gDAK0B;AAC1B,0DAM+B;AAC/B,kEAA0C;AAK1C,gDAAgD;AAChD,uDAG2B;AAE3B,MAAM,kBAAkB,GAAG,uCAAuC,CAAC;AAEnE,MAAM,aAAa,GAAG,0CAA0C,CAAC;AACjE,MAAM,MAAM,GAAwB;IAClC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,UAAU,EAAE,OAAO;QACnB,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,mBAAmB;oBAC5B,IAAI,EAAE,oCAAmB,CAAC,IAAI;oBAC9B,MAAM,EAAE;wBACN,QAAQ,EAAE,6CAA6C;qBACxD;iBACF;gBACD;oBACE,OAAO,EAAE,WAAW;oBACpB,IAAI,EAAE,oCAAmB,CAAC,KAAK;oBAC/B,MAAM,EAAE;wBACN,MAAM,EAAE;4BACN,oEAAoE;yBACrE;qBACF;iBACF;aACF;SACF;KACF;CACF,CAAC;AAEF,gBAAgB;AAChB,MAAM,OAAO,GAAwB;IACnC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACj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,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,6CAA2B,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE;gBACJ;oBACE,OAAO,EAAE,CAAC,4CAA4C,CAAC;oBACvD,OAAO,EAAE;wBACP,oEAAoE;qBACrE;iBACF;aACF;YACD,YAAY,EAAE;gBACZ;oBACE,IAAI,EAAE,CAAC,aAAa,CAAC;oBACrB,QAAQ,EAAE,CAAC,YAAY,CAAC;iBACzB;aACF;SACF,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 NodeConfig,\n BlockHeightMap,\n IBlock,\n DictionaryResponse,\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 SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport {\n buildDictionaryV2QueryEntry,\n EthDictionaryV2,\n} from './ethDictionaryV2';\n\nconst DEFAULT_DICTIONARY = 'http://localhost:3000/rpc/eth-mainnet';\n\nconst HTTP_ENDPOINT = 'https://polygon.api.onfinality.io/public';\nconst mockDs: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 3678215,\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\n// tx to is null\nconst mockDs2: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 3678215,\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 },\n];\n\nconst nodeConfig = new NodeConfig({\n subquery: 'polygon-starter',\n subqueryName: 'polygon-starter',\n dictionaryTimeout: 10,\n networkEndpoint: [HTTP_ENDPOINT],\n networkDictionary: [`${DEFAULT_DICTIONARY}/polygon`],\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, 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 ethBlock3678215: EthereumBlock;\n let ethBlock3678250: EthereumBlock;\n\n const dsMap = makeBlockHeightMap(mockDs);\n\n beforeEach(async () => {\n ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n { network: { chainId: '10' } } as SubqueryProject,\n new EthereumApi(HTTP_ENDPOINT, 1, new EventEmitter2()),\n );\n\n ethDictionaryV2.updateQueriesMap(dsMap);\n });\n\n it('convert ds to v2 dictionary queries', () => {\n //Polygon\n const query = (ethDictionaryV2 as any).queriesMap.get(3678215);\n expect(query.logs.length).toBe(1);\n expect(query.transactions.length).toBe(1);\n }, 100000);\n\n it('query response match with entries', async () => {\n //Polygon\n const ethBlocks = (await ethDictionaryV2.getData(\n 3678215,\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 3678215, 3678250,\n ]);\n\n ethBlock3678215 = ethBlocks.batchBlocks[0].block;\n ethBlock3678250 = ethBlocks.batchBlocks[1].block;\n\n expect(ethBlock3678215.number).toBe(3678215);\n expect(ethBlock3678250.number).toBe(3678250);\n\n // To match with dictionaryQueryEntries[0].func\n expect(ethBlock3678215.transactions[0].input.indexOf('0x60806040')).toBe(0);\n\n expect(ethBlock3678250.logs.length).toBe(1);\n // This matches with dictionaryQueryEntries[0].topics\n expect(ethBlock3678250.logs[0].topics).toContain(\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n );\n }, 100000);\n\n it('able to convert raw v2 Blocks into eth blocks when getData', async () => {\n //Polygon\n const ethBlocks = (await ethDictionaryV2.getData(\n 3678215,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n expect(ethBlocks.batchBlocks[0].block.number).toStrictEqual(3678215);\n expect(ethBlocks.lastBufferedHeight).toStrictEqual(3678250);\n\n // Can include input and hash\n // https://polygonscan.com/tx/0xb1b5f7882fa8d62d3650948c08066e928b7b5c9d607d2fe8c7e6ce57caf06774\n expect(ethBlocks.batchBlocks[1].block.transactions[1].hash).toBe(\n `0xb1b5f7882fa8d62d3650948c08066e928b7b5c9d607d2fe8c7e6ce57caf06774`,\n );\n expect(ethBlocks.batchBlocks[1].block.transactions[1].input).toBe(\n `0x23b872dd000000000000000000000000244a79a2e79e8d884d9c9cc425d88f9e2ed988ca000000000000000000000000d22c4c383ce5efa0364d5fab5ce1313c24a52bda0000000000000000000000000000000000000000000000000000000000000159`,\n );\n\n // relate logs\n // https://polygonscan.com/tx/0xb1b5f7882fa8d62d3650948c08066e928b7b5c9d607d2fe8c7e6ce57caf06774#eventlog\n expect(ethBlocks.batchBlocks[1].block.logs[0].data).toBe(`0x`);\n }, 500000);\n\n // TODO, check this\n it.skip('able to get transaction with field to is null', async () => {\n const dsMap = makeBlockHeightMap(mockDs2);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions, queryEndBlock } = (\n ethDictionaryV2 as any\n ).getQueryConditions(3678215, (ethDictionaryV2 as any)._metadata.end);\n\n expect(conditions).toBe({ transactions: [{ to: null }] });\n const ethBlocks = (await ethDictionaryV2.getData(\n 3678215,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n });\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 '!null',\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('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 function: ['0x7ef9ea98'],\n },\n ],\n });\n });\n});\n"]}
@@ -1,4 +1,5 @@
1
1
  import { IBlock } from '@subql/node-core';
2
2
  import { EthereumBlock } from '@subql/types-ethereum';
3
+ import { EthereumApi } from '../../../ethereum';
3
4
  import { RawEthBlock } from './types';
4
- export declare function rawBlockToEthBlock(block: RawEthBlock): IBlock<EthereumBlock>;
5
+ export declare function rawBlockToEthBlock(block: RawEthBlock, api: EthereumApi): IBlock<EthereumBlock>;
@@ -5,13 +5,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.rawBlockToEthBlock = void 0;
6
6
  const providers_1 = require("@ethersproject/providers");
7
7
  const utils_ethereum_1 = require("../../../ethereum/utils.ethereum");
8
- function rawBlockToEthBlock(block) {
9
- var _a, _b;
8
+ function rawBlockToEthBlock(block, api) {
9
+ var _a, _b, _c;
10
10
  try {
11
- const formatter = new providers_1.Formatter();
11
+ // Use the formatter from the api, it could have custom formats e.g l1Gas fields
12
+ const formatter = (_a = api === null || api === void 0 ? void 0 : api.api.formatter) !== null && _a !== void 0 ? _a : new providers_1.Formatter();
12
13
  const ethBlock = (0, utils_ethereum_1.formatBlock)(Object.assign(Object.assign({}, block.header), { transactions: [] }));
13
- ethBlock.logs = providers_1.Formatter.arrayOf(formatter.filterLog.bind(formatter))((_a = block.logs) !== null && _a !== void 0 ? _a : []).map((l) => (0, utils_ethereum_1.formatLog)(l, ethBlock));
14
- ethBlock.transactions = ((_b = block.transactions) !== null && _b !== void 0 ? _b : []).map((tx) => (Object.assign(Object.assign({}, (0, utils_ethereum_1.formatTransaction)(tx, ethBlock)), { logs: ethBlock.logs.filter((l) => l.transactionHash === tx.hash) })));
14
+ ethBlock.logs = providers_1.Formatter.arrayOf(formatter.filterLog.bind(formatter))((_b = block.logs) !== null && _b !== void 0 ? _b : []).map((l) => (0, utils_ethereum_1.formatLog)(l, ethBlock));
15
+ ethBlock.transactions = ((_c = block.transactions) !== null && _c !== void 0 ? _c : []).map((tx) => (Object.assign(Object.assign({}, (0, utils_ethereum_1.formatTransaction)(tx, ethBlock)), { logs: ethBlock.logs.filter((l) => l.transactionHash === tx.hash), receipt: () => api
16
+ .getTransactionReceipt(tx.hash)
17
+ .then((r) => (0, utils_ethereum_1.formatReceipt)(r, ethBlock)) })));
15
18
  return (0, utils_ethereum_1.formatBlockUtil)(ethBlock);
16
19
  }
17
20
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/utils.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAEnC,wDAAqD;AAGrD,qEAK0C;AAG1C,SAAgB,kBAAkB,CAAC,KAAkB;;IACnD,IAAI;QACF,MAAM,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAC;QAElC,MAAM,QAAQ,GAAG,IAAA,4BAAW,kCACvB,KAAK,CAAC,MAAM,KACf,YAAY,EAAE,EAAE,IAChB,CAAC;QAEH,QAAQ,CAAC,IAAI,GAAG,qBAAS,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CACpE,MAAA,KAAK,CAAC,IAAI,mCAAI,EAAE,CACjB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,0BAAS,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;QAErC,QAAQ,CAAC,YAAY,GAAG,CAAC,MAAA,KAAK,CAAC,YAAY,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,iCAC1D,IAAA,kCAAiB,EAAC,EAAE,EAAE,QAAQ,CAAC,KAClC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,KAAK,EAAE,CAAC,IAAI,CAAC,IAEhE,CAAC,CAAC;QAEJ,OAAO,IAAA,gCAAe,EAAC,QAAQ,CAAC,CAAC;KAClC;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,4CAA4C,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,CAC/E,CAAC;KACH;AACH,CAAC;AAzBD,gDAyBC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Formatter } from '@ethersproject/providers';\nimport { IBlock } from '@subql/node-core';\nimport { EthereumBlock } from '@subql/types-ethereum';\nimport {\n formatBlock,\n formatBlockUtil,\n formatLog,\n formatTransaction,\n} from '../../../ethereum/utils.ethereum';\nimport { RawEthBlock } from './types';\n\nexport function rawBlockToEthBlock(block: RawEthBlock): IBlock<EthereumBlock> {\n try {\n const formatter = new Formatter();\n\n const ethBlock = formatBlock({\n ...block.header,\n transactions: [],\n });\n\n ethBlock.logs = Formatter.arrayOf(formatter.filterLog.bind(formatter))(\n block.logs ?? [],\n ).map((l) => formatLog(l, ethBlock));\n\n ethBlock.transactions = (block.transactions ?? []).map((tx) => ({\n ...formatTransaction(tx, ethBlock),\n logs: ethBlock.logs.filter((l) => l.transactionHash === tx.hash),\n // TODO add method for receipts\n }));\n\n return formatBlockUtil(ethBlock);\n } catch (e) {\n throw new Error(\n `Convert raw block to Eth block failed at ${block.header.number},${e.message}`,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRo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QAAQ,CAAC,CAAC;KAClC;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,4CAA4C,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,CAC/E,CAAC;KACH;AACH,CAAC;AAhCD,gDAgCC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Formatter } from '@ethersproject/providers';\nimport { IBlock } from '@subql/node-core';\nimport { EthereumBlock, EthereumReceipt } from '@subql/types-ethereum';\nimport { EthereumApi } from '../../../ethereum';\nimport {\n formatBlock,\n formatBlockUtil,\n formatLog,\n formatReceipt,\n formatTransaction,\n} from '../../../ethereum/utils.ethereum';\nimport { RawEthBlock } from './types';\n\nexport function rawBlockToEthBlock(\n block: RawEthBlock,\n api: EthereumApi,\n): IBlock<EthereumBlock> {\n try {\n // Use the formatter from the api, it could have custom formats e.g l1Gas fields\n const formatter = api?.api.formatter ?? new Formatter();\n\n const ethBlock = formatBlock({\n ...block.header,\n transactions: [],\n });\n\n ethBlock.logs = Formatter.arrayOf(formatter.filterLog.bind(formatter))(\n block.logs ?? [],\n ).map((l) => formatLog(l, ethBlock));\n\n ethBlock.transactions = (block.transactions ?? []).map((tx) => ({\n ...formatTransaction(tx, ethBlock),\n logs: ethBlock.logs.filter((l) => l.transactionHash === tx.hash),\n receipt: <R extends EthereumReceipt>(): Promise<R> =>\n api\n .getTransactionReceipt(tx.hash)\n .then((r) => formatReceipt<R>(r, ethBlock)),\n }));\n\n return formatBlockUtil(ethBlock);\n } catch (e) {\n throw new Error(\n `Convert raw block to Eth block failed at ${block.header.number},${e.message}`,\n );\n }\n}\n"]}
@@ -62,17 +62,18 @@ async function fetchDictionaryBlock() {
62
62
  });
63
63
  return (await res.json()).result.blocks[0];
64
64
  }
65
- async function fetchRPCBlock() {
66
- const api = new ethereum_1.EthereumApi(RPC_URL, 1, new eventemitter2_1.default());
67
- return api.fetchBlock(4085662);
68
- }
69
65
  describe('rawBlockToEthBlock', () => {
70
- it('successfully convers a block', async () => {
71
- const [raw, rpcBlock] = await Promise.all([
66
+ const api = new ethereum_1.EthereumApi(RPC_URL, 1, new eventemitter2_1.default());
67
+ let raw;
68
+ let rpcBlock;
69
+ beforeAll(async () => {
70
+ [raw, rpcBlock] = await Promise.all([
72
71
  fetchDictionaryBlock(),
73
- fetchRPCBlock(),
72
+ api.fetchBlock(4085662),
74
73
  ]);
75
- const block = (0, utils_1.rawBlockToEthBlock)(raw);
74
+ });
75
+ it('successfully convers a block', () => {
76
+ const block = (0, utils_1.rawBlockToEthBlock)(raw, api);
76
77
  expect(block.getHeader()).toEqual({
77
78
  blockHash: '0xde8e614cc05b483fe092fd0aff435011138c15c9ede862579074218d4aff5132',
78
79
  blockHeight: 4085662,
@@ -94,5 +95,9 @@ describe('rawBlockToEthBlock', () => {
94
95
  expect(txRest).toEqual(rpcTxRest);
95
96
  }
96
97
  }, 15000);
98
+ it('can fetch receipts', async () => {
99
+ const block = (0, utils_1.rawBlockToEthBlock)(raw, api);
100
+ await expect(block.block.transactions[0].receipt()).resolves.not.toThrow();
101
+ });
97
102
  });
98
103
  //# sourceMappingURL=utils.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/utils.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;AAInC,kEAA0C;AAC1C,4DAA+B;AAC/B,gDAAgD;AAEhD,mCAA6C;AAE7C,MAAM,cAAc,GAAG,uCAAuC,CAAC;AAC/D,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAE3C,KAAK,UAAU,oBAAoB;IACjC,MAAM,GAAG,GAAG,MAAM,IAAA,oBAAK,EAAC,cAAc,EAAE;QACtC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,I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BAKL,CAAkE,CAAC;YAEpE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SACnC;IACH,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { IBlock } from '@subql/node-core';\nimport { EthereumBlock } from '@subql/types-ethereum';\nimport EventEmitter2 from 'eventemitter2';\nimport fetch from 'node-fetch';\nimport { EthereumApi } from '../../../ethereum';\nimport { RawEthBlock } from './types';\nimport { rawBlockToEthBlock } from './utils';\n\nconst DICTIONARY_URL = 'http://localhost:3000/rpc/eth-mainnet';\nconst RPC_URL = 'https://eth.llamarpc.com';\n\nasync function fetchDictionaryBlock(): Promise<RawEthBlock> {\n const res = await fetch(DICTIONARY_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'subql_filterBlocks',\n params: [\n {\n fromBlock: '0x3e579e',\n toBlock: '0x3e579e',\n limit: '0x1',\n blockFilter: {\n logs: [\n {\n address: ['0x6f28B146804dBa2D6f944C03528A8FDbc673df2C'],\n topics0: [\n '0xb76d0edd90c6a07aa3ff7a222d7f5933e29c6acc660c059c97837f05c4ca1a84',\n ],\n },\n ],\n },\n fieldSelector: {\n blockHeader: true,\n logs: {\n transaction: true,\n },\n transactions: {\n log: true,\n },\n },\n },\n ],\n }),\n });\n\n return (await res.json()).result.blocks[0];\n}\n\nasync function fetchRPCBlock(): Promise<IBlock<EthereumBlock>> {\n const api = new EthereumApi(RPC_URL, 1, new EventEmitter2());\n\n return api.fetchBlock(4085662);\n}\n\ndescribe('rawBlockToEthBlock', () => {\n it('successfully convers a block', async () => {\n const [raw, rpcBlock] = await Promise.all([\n fetchDictionaryBlock(),\n fetchRPCBlock(),\n ]);\n\n const block = rawBlockToEthBlock(raw);\n\n expect(block.getHeader()).toEqual({\n blockHash:\n '0xde8e614cc05b483fe092fd0aff435011138c15c9ede862579074218d4aff5132',\n blockHeight: 4085662,\n parentHash:\n '0x669c7a2c66e38c144ad1e2845ec345b6ce7e2107edbdb331ab88d355982126a7',\n });\n\n expect(block.block.transactions.length).toBeGreaterThan(0);\n expect(block.block.logs.length).toBeGreaterThan(0);\n\n // Dictionry is going to return a subset of events/transactions so we base off dictionary block\n for (const log of block.block.logs) {\n // Remove linked types\n const { block: _1, transaction: _2, ...logRest } = log;\n const {\n block: _3,\n transaction: _4,\n ...rpcLogRest\n } = rpcBlock.block.logs[log.logIndex];\n expect(JSON.stringify(logRest)).toEqual(JSON.stringify(rpcLogRest));\n }\n\n for (const tx of block.block.transactions) {\n // Cast to any to remove toJSON which results in different key order\n const { logs: _1, receipt: _3, toJSON: _5, ...txRest } = tx as any;\n const {\n logs: _2,\n receipt: _4,\n toJSON: _6,\n ...rpcTxRest\n } = rpcBlock.block.transactions[Number(tx.transactionIndex)] as any;\n\n expect(txRest).toEqual(rpcTxRest);\n }\n }, 15000);\n});\n"]}
1
+ {"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/utils.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;AAInC,kEAA0C;AAC1C,4DAA+B;AAC/B,gDAAgD;AAEhD,mCAA6C;AAE7C,MAAM,cAAc,GAAG,uCAAuC,CAAC;AAC/D,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAE3C,KAAK,UAAU,oBAAoB;IACjC,MAAM,GAAG,GAAG,MAAM,IAAA,oBAAK,EAAC,cAAc,EAAE;QACtC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,OAAO,EAAE,KAAK;YACd,EAAE,EAAE,CAAC;YACL,MAAM,EAAE,oBAAoB;YAC5B,M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O,CAAC,SAAS,CAAC,CAAC;SACnC;IACH,CAAC,EAAE,KAAK,CAAC,CAAC;IAEV,EAAE,CAAC,oBAAoB,EAAE,KAAK,IAAI,EAAE;QAClC,MAAM,KAAK,GAAG,IAAA,0BAAkB,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAE3C,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAC7E,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 { IBlock } from '@subql/node-core';\nimport { EthereumBlock } from '@subql/types-ethereum';\nimport EventEmitter2 from 'eventemitter2';\nimport fetch from 'node-fetch';\nimport { EthereumApi } from '../../../ethereum';\nimport { RawEthBlock } from './types';\nimport { rawBlockToEthBlock } from './utils';\n\nconst DICTIONARY_URL = 'http://localhost:3000/rpc/eth-mainnet';\nconst RPC_URL = 'https://eth.llamarpc.com';\n\nasync function fetchDictionaryBlock(): Promise<RawEthBlock> {\n const res = await fetch(DICTIONARY_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'subql_filterBlocks',\n params: [\n {\n fromBlock: '0x3e579e',\n toBlock: '0x3e579e',\n limit: '0x1',\n blockFilter: {\n logs: [\n {\n address: ['0x6f28B146804dBa2D6f944C03528A8FDbc673df2C'],\n topics0: [\n '0xb76d0edd90c6a07aa3ff7a222d7f5933e29c6acc660c059c97837f05c4ca1a84',\n ],\n },\n ],\n },\n fieldSelector: {\n blockHeader: true,\n logs: {\n transaction: true,\n },\n transactions: {\n log: true,\n },\n },\n },\n ],\n }),\n });\n\n return (await res.json()).result.blocks[0];\n}\n\ndescribe('rawBlockToEthBlock', () => {\n const api = new EthereumApi(RPC_URL, 1, new EventEmitter2());\n let raw: RawEthBlock;\n let rpcBlock: IBlock<EthereumBlock>;\n\n beforeAll(async () => {\n [raw, rpcBlock] = await Promise.all([\n fetchDictionaryBlock(),\n api.fetchBlock(4085662),\n ]);\n });\n\n it('successfully convers a block', () => {\n const block = rawBlockToEthBlock(raw, api);\n\n expect(block.getHeader()).toEqual({\n blockHash:\n '0xde8e614cc05b483fe092fd0aff435011138c15c9ede862579074218d4aff5132',\n blockHeight: 4085662,\n parentHash:\n '0x669c7a2c66e38c144ad1e2845ec345b6ce7e2107edbdb331ab88d355982126a7',\n });\n\n expect(block.block.transactions.length).toBeGreaterThan(0);\n expect(block.block.logs.length).toBeGreaterThan(0);\n\n // Dictionry is going to return a subset of events/transactions so we base off dictionary block\n for (const log of block.block.logs) {\n // Remove linked types\n const { block: _1, transaction: _2, ...logRest } = log;\n const {\n block: _3,\n transaction: _4,\n ...rpcLogRest\n } = rpcBlock.block.logs[log.logIndex];\n expect(JSON.stringify(logRest)).toEqual(JSON.stringify(rpcLogRest));\n }\n\n for (const tx of block.block.transactions) {\n // Cast to any to remove toJSON which results in different key order\n const { logs: _1, receipt: _3, toJSON: _5, ...txRest } = tx as any;\n const {\n logs: _2,\n receipt: _4,\n toJSON: _6,\n ...rpcTxRest\n } = rpcBlock.block.transactions[Number(tx.transactionIndex)] as any;\n\n expect(txRest).toEqual(rpcTxRest);\n }\n }, 15000);\n\n it('can fetch receipts', async () => {\n const block = rawBlockToEthBlock(raw, api);\n\n await expect(block.block.transactions[0].receipt()).resolves.not.toThrow();\n });\n});\n"]}
@@ -89,14 +89,7 @@ FetchModule = __decorate([
89
89
  node_core_1.ConnectionPoolService,
90
90
  node_core_1.IndexingBenchmarkService,
91
91
  node_core_1.PoiBenchmarkService,
92
- {
93
- provide: ethDictionary_service_1.EthDictionaryService,
94
- useFactory: async (project, nodeConfig, eventEmitter) => {
95
- const dictionaryService = new ethDictionary_service_1.EthDictionaryService(project, nodeConfig, eventEmitter);
96
- return dictionaryService;
97
- },
98
- inject: ['ISubqueryProject', node_core_1.NodeConfig, event_emitter_1.EventEmitter2],
99
- },
92
+ ethDictionary_service_1.EthDictionaryService,
100
93
  sandbox_service_1.SandboxService,
101
94
  ds_processor_service_1.DsProcessorService,
102
95
  dynamic_ds_service_1.DynamicDsService,
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.module.js","sourceRoot":"","sources":["../../src/indexer/fetch.module.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;AAEnC,2CAAwC;AACxC,yDAAsD;AACtD,gDAc0B;AAG1B,2EAAsE;AACtE,uDAG2B;AAC3B,8EAA0E;AAC1E,iEAA4D;AAC5D,6DAAwD;AACxD,mDAA+C;AAC/C,uDAAmD;AACnD,uDAAmD;AACnD,uDAAmD;AACnD,2EAAuE;AAsJhE,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IApJvB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,gCAAoB;YACpB,wBAAY;YACZ,6BAAiB;YACjB,yCAAkB;YAClB;gBACE,OAAO,EAAE,sBAAU;gBACnB,UAAU,EAAE,KAAK,EACf,OAAwB,EACxB,qBAAmE,EACnE,YAA2B,EAC3B,UAAsB,EACtB,EAAE;oBACF,MAAM,UAAU,GAAG,IAAI,yCAAkB,CACvC,OAAO,EACP,qBAAqB,EACrB,YAAY,EACZ,UAAU,CACX,CAAC;oBACF,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC;oBACxB,OAAO,UAAU,CAAC;gBACpB,CAAC;gBACD,MAAM,EAAE;oBACN,kBAAkB;oBAClB,iCAAqB;oBACrB,6BAAa;oBACb,sBAAU;iBACX;aACF;YACD,gCAAc;YACd,sCAA0B;YAC1B,iCAAqB;YACrB;gBACE,OAAO,EAAE,6BAAiB;gBAC1B,UAAU,EAAE,CAAC,UAAsB,EAAE,EAAE;oBACrC,OAAO,IAAI,6BAA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AA0B;iBAC3B;aACF;YACD,4BAAY;YACZ,iCAAqB;YACrB,oCAAwB;YACxB,+BAAmB;YACnB;gBACE,OAAO,EAAE,4CAAoB;gBAC7B,UAAU,EAAE,KAAK,EACf,OAAwB,EACxB,UAAsB,EACtB,YAA2B,EAE3B,EAAE;oBACF,MAAM,iBAAiB,GAAG,IAAI,4CAAoB,CAChD,OAAO,EACP,UAAU,EACV,YAAY,CACb,CAAC;oBACF,OAAO,iBAAiB,CAAC;gBAC3B,CAAC;gBACD,MAAM,EAAE,CAAC,kBAAkB,EAAE,sBAAU,EAAE,6BAAa,CAAC;aACxD;YACD,gCAAc;YACd,yCAAkB;YAClB,qCAAgB;YAChB,sBAAU;YACV,0BAAc;YACd;gBACE,QAAQ,EAAE,gCAAc;gBACxB,OAAO,EAAE,iBAAiB;aAC3B;YACD,oDAAwB;SACzB;QACD,OAAO,EAAE,CAAC,wBAAY,EAAE,6BAAiB,CAAC;KAC3C,CAAC;GACW,WAAW,CAAG;AAAd,kCAAW","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Module } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n PoiBenchmarkService,\n IndexingBenchmarkService,\n StoreService,\n PoiService,\n ApiService,\n NodeConfig,\n ConnectionPoolService,\n ConnectionPoolStateManager,\n SmartBatchService,\n StoreCacheService,\n IProjectUpgradeService,\n PoiSyncService,\n InMemoryCacheService,\n} from '@subql/node-core';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumApiConnection } from '../ethereum/api.connection';\nimport { EthereumApiService } from '../ethereum/api.service.ethereum';\nimport {\n BlockDispatcherService,\n WorkerBlockDispatcherService,\n} from './blockDispatcher';\nimport { EthDictionaryService } from './dictionary/ethDictionary.service';\nimport { DsProcessorService } from './ds-processor.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport { FetchService } from './fetch.service';\nimport { IndexerManager } from './indexer.manager';\nimport { ProjectService } from './project.service';\nimport { SandboxService } from './sandbox.service';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\n@Module({\n providers: [\n InMemoryCacheService,\n StoreService,\n StoreCacheService,\n EthereumApiService,\n {\n provide: ApiService,\n useFactory: async (\n project: SubqueryProject,\n connectionPoolService: ConnectionPoolService<EthereumApiConnection>,\n eventEmitter: EventEmitter2,\n nodeConfig: NodeConfig,\n ) => {\n const apiService = new EthereumApiService(\n project,\n connectionPoolService,\n eventEmitter,\n nodeConfig,\n );\n await apiService.init();\n return apiService;\n },\n inject: [\n 'ISubqueryProject',\n ConnectionPoolService,\n EventEmitter2,\n NodeConfig,\n ],\n },\n IndexerManager,\n ConnectionPoolStateManager,\n ConnectionPoolService,\n {\n provide: SmartBatchService,\n useFactory: (nodeConfig: NodeConfig) => {\n return new SmartBatchService(nodeConfig.batchSize);\n },\n inject: [NodeConfig],\n },\n {\n provide: SmartBatchService,\n useFactory: (nodeConfig: NodeConfig) => {\n return new SmartBatchService(nodeConfig.batchSize);\n },\n inject: [NodeConfig],\n },\n {\n provide: 'IBlockDispatcher',\n useFactory: (\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n projectService: ProjectService,\n projectUpgradeService: IProjectUpgradeService,\n apiService: EthereumApiService,\n indexerManager: IndexerManager,\n smartBatchService: SmartBatchService,\n cacheService: InMemoryCacheService,\n storeService: StoreService,\n storeCacheService: StoreCacheService,\n poiSyncService: PoiSyncService,\n project: SubqueryProject,\n dynamicDsService: DynamicDsService,\n unfinalizedBlocks: UnfinalizedBlocksService,\n connectionPoolState: ConnectionPoolStateManager<EthereumApiConnection>,\n ) =>\n nodeConfig.workers !== undefined\n ? new WorkerBlockDispatcherService(\n nodeConfig,\n eventEmitter,\n projectService,\n projectUpgradeService,\n smartBatchService,\n cacheService,\n storeService,\n storeCacheService,\n poiSyncService,\n project,\n dynamicDsService,\n unfinalizedBlocks,\n connectionPoolState,\n )\n : new BlockDispatcherService(\n apiService,\n nodeConfig,\n indexerManager,\n eventEmitter,\n projectService,\n projectUpgradeService,\n smartBatchService,\n storeService,\n storeCacheService,\n poiSyncService,\n project,\n dynamicDsService,\n ),\n inject: [\n NodeConfig,\n EventEmitter2,\n 'IProjectService',\n 'IProjectUpgradeService',\n ApiService,\n IndexerManager,\n SmartBatchService,\n InMemoryCacheService,\n StoreService,\n StoreCacheService,\n PoiSyncService,\n 'ISubqueryProject',\n DynamicDsService,\n UnfinalizedBlocksService,\n ConnectionPoolStateManager,\n ],\n },\n FetchService,\n ConnectionPoolService,\n IndexingBenchmarkService,\n PoiBenchmarkService,\n {\n provide: EthDictionaryService,\n useFactory: async (\n project: SubqueryProject,\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n // eslint-disable-next-line @typescript-eslint/require-await\n ) => {\n const dictionaryService = new EthDictionaryService(\n project,\n nodeConfig,\n eventEmitter,\n );\n return dictionaryService;\n },\n inject: ['ISubqueryProject', NodeConfig, EventEmitter2],\n },\n SandboxService,\n DsProcessorService,\n DynamicDsService,\n PoiService,\n PoiSyncService,\n {\n useClass: ProjectService,\n provide: 'IProjectService',\n },\n UnfinalizedBlocksService,\n ],\n exports: [StoreService, StoreCacheService],\n})\nexport class FetchModule {}\n"]}
1
+ {"version":3,"file":"fetch.module.js","sourceRoot":"","sources":["../../src/indexer/fetch.module.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;AAEnC,2CAAwC;AACxC,yDAAsD;AACtD,gDAc0B;AAG1B,2EAAsE;AACtE,uDAG2B;AAC3B,8EAA0E;AAC1E,iEAA4D;AAC5D,6DAAwD;AACxD,mDAA+C;AAC/C,uDAAmD;AACnD,uDAAmD;AACnD,uDAAmD;AACnD,2EAAuE;AAsIhE,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IApIvB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,gCAAoB;YACpB,wBAAY;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cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,CACpB;oBACH,CAAC,CAAC,IAAI,wCAAsB,CACxB,UAAU,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,gBAAgB,CACjB;gBACP,MAAM,EAAE;oBACN,sBAAU;oBACV,6BAAa;oBACb,iBAAiB;oBACjB,wBAAwB;oBACxB,sBAAU;oBACV,gCAAc;oBACd,6BAAiB;oBACjB,gCAAoB;oBACpB,wBAAY;oBACZ,6BAAiB;oBACjB,0BAAc;oBACd,kBAAkB;oBAClB,qCAAgB;oBAChB,oDAAwB;oBACxB,sCAA0B;iBAC3B;aACF;YACD,4BAAY;YACZ,iCAAqB;YACrB,oCAAwB;YACxB,+BAAmB;YACnB,4CAAoB;YACpB,gCAAc;YACd,yCAAkB;YAClB,qCAAgB;YAChB,sBAAU;YACV,0BAAc;YACd;gBACE,QAAQ,EAAE,gCAAc;gBACxB,OAAO,EAAE,iBAAiB;aAC3B;YACD,oDAAwB;SACzB;QACD,OAAO,EAAE,CAAC,wBAAY,EAAE,6BAAiB,CAAC;KAC3C,CAAC;GACW,WAAW,CAAG;AAAd,kCAAW","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Module } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n PoiBenchmarkService,\n IndexingBenchmarkService,\n StoreService,\n PoiService,\n ApiService,\n NodeConfig,\n ConnectionPoolService,\n ConnectionPoolStateManager,\n SmartBatchService,\n StoreCacheService,\n IProjectUpgradeService,\n PoiSyncService,\n InMemoryCacheService,\n} from '@subql/node-core';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumApiConnection } from '../ethereum/api.connection';\nimport { EthereumApiService } from '../ethereum/api.service.ethereum';\nimport {\n BlockDispatcherService,\n WorkerBlockDispatcherService,\n} from './blockDispatcher';\nimport { EthDictionaryService } from './dictionary/ethDictionary.service';\nimport { DsProcessorService } from './ds-processor.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport { FetchService } from './fetch.service';\nimport { IndexerManager } from './indexer.manager';\nimport { ProjectService } from './project.service';\nimport { SandboxService } from './sandbox.service';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\n@Module({\n providers: [\n InMemoryCacheService,\n StoreService,\n StoreCacheService,\n EthereumApiService,\n {\n provide: ApiService,\n useFactory: async (\n project: SubqueryProject,\n connectionPoolService: ConnectionPoolService<EthereumApiConnection>,\n eventEmitter: EventEmitter2,\n nodeConfig: NodeConfig,\n ) => {\n const apiService = new EthereumApiService(\n project,\n connectionPoolService,\n eventEmitter,\n nodeConfig,\n );\n await apiService.init();\n return apiService;\n },\n inject: [\n 'ISubqueryProject',\n ConnectionPoolService,\n EventEmitter2,\n NodeConfig,\n ],\n },\n IndexerManager,\n ConnectionPoolStateManager,\n ConnectionPoolService,\n {\n provide: SmartBatchService,\n useFactory: (nodeConfig: NodeConfig) => {\n return new SmartBatchService(nodeConfig.batchSize);\n },\n inject: [NodeConfig],\n },\n {\n provide: SmartBatchService,\n useFactory: (nodeConfig: NodeConfig) => {\n return new SmartBatchService(nodeConfig.batchSize);\n },\n inject: [NodeConfig],\n },\n {\n provide: 'IBlockDispatcher',\n useFactory: (\n nodeConfig: NodeConfig,\n eventEmitter: EventEmitter2,\n projectService: ProjectService,\n projectUpgradeService: IProjectUpgradeService,\n apiService: EthereumApiService,\n indexerManager: IndexerManager,\n smartBatchService: SmartBatchService,\n cacheService: InMemoryCacheService,\n storeService: StoreService,\n storeCacheService: StoreCacheService,\n poiSyncService: PoiSyncService,\n project: SubqueryProject,\n dynamicDsService: DynamicDsService,\n unfinalizedBlocks: UnfinalizedBlocksService,\n connectionPoolState: ConnectionPoolStateManager<EthereumApiConnection>,\n ) =>\n nodeConfig.workers !== undefined\n ? new WorkerBlockDispatcherService(\n nodeConfig,\n eventEmitter,\n projectService,\n projectUpgradeService,\n smartBatchService,\n cacheService,\n storeService,\n storeCacheService,\n poiSyncService,\n project,\n dynamicDsService,\n unfinalizedBlocks,\n connectionPoolState,\n )\n : new BlockDispatcherService(\n apiService,\n nodeConfig,\n indexerManager,\n eventEmitter,\n projectService,\n projectUpgradeService,\n smartBatchService,\n storeService,\n storeCacheService,\n poiSyncService,\n project,\n dynamicDsService,\n ),\n inject: [\n NodeConfig,\n EventEmitter2,\n 'IProjectService',\n 'IProjectUpgradeService',\n ApiService,\n IndexerManager,\n SmartBatchService,\n InMemoryCacheService,\n StoreService,\n StoreCacheService,\n PoiSyncService,\n 'ISubqueryProject',\n DynamicDsService,\n UnfinalizedBlocksService,\n ConnectionPoolStateManager,\n ],\n },\n FetchService,\n ConnectionPoolService,\n IndexingBenchmarkService,\n PoiBenchmarkService,\n EthDictionaryService,\n SandboxService,\n DsProcessorService,\n DynamicDsService,\n PoiService,\n PoiSyncService,\n {\n useClass: ProjectService,\n provide: 'IProjectService',\n },\n UnfinalizedBlocksService,\n ],\n exports: [StoreService, StoreCacheService],\n})\nexport class FetchModule {}\n"]}
@@ -6,13 +6,12 @@ import { SubqueryProject } from '../configure/SubqueryProject';
6
6
  import { EthereumApi } from '../ethereum';
7
7
  import { IEthereumBlockDispatcher } from './blockDispatcher';
8
8
  import { EthDictionaryService } from './dictionary/ethDictionary.service';
9
- import { DynamicDsService } from './dynamic-ds.service';
10
9
  import { ProjectService } from './project.service';
11
10
  import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
12
11
  export declare class FetchService extends BaseFetchService<SubqlDatasource, IEthereumBlockDispatcher, EthereumBlock> {
13
12
  private apiService;
14
13
  private unfinalizedBlocksService;
15
- constructor(apiService: ApiService, nodeConfig: NodeConfig, projectService: ProjectService, project: SubqueryProject, blockDispatcher: IEthereumBlockDispatcher, dictionaryService: EthDictionaryService, dynamicDsService: DynamicDsService, unfinalizedBlocksService: UnfinalizedBlocksService, eventEmitter: EventEmitter2, schedulerRegistry: SchedulerRegistry);
14
+ constructor(apiService: ApiService, nodeConfig: NodeConfig, projectService: ProjectService, project: SubqueryProject, blockDispatcher: IEthereumBlockDispatcher, dictionaryService: EthDictionaryService, unfinalizedBlocksService: UnfinalizedBlocksService, eventEmitter: EventEmitter2, schedulerRegistry: SchedulerRegistry);
16
15
  get api(): EthereumApi;
17
16
  protected getGenesisHash(): string;
18
17
  protected getFinalizedHeight(): Promise<number>;
@@ -23,14 +23,13 @@ const node_core_1 = require("@subql/node-core");
23
23
  const SubqueryProject_1 = require("../configure/SubqueryProject");
24
24
  const utils_ethereum_1 = require("../ethereum/utils.ethereum");
25
25
  const ethDictionary_service_1 = require("./dictionary/ethDictionary.service");
26
- const dynamic_ds_service_1 = require("./dynamic-ds.service");
27
26
  const project_service_1 = require("./project.service");
28
27
  const unfinalizedBlocks_service_1 = require("./unfinalizedBlocks.service");
29
28
  const BLOCK_TIME_VARIANCE = 5000;
30
29
  const INTERVAL_PERCENT = 0.9;
31
30
  let FetchService = class FetchService extends node_core_1.BaseFetchService {
32
- constructor(apiService, nodeConfig, projectService, project, blockDispatcher, dictionaryService, dynamicDsService, unfinalizedBlocksService, eventEmitter, schedulerRegistry) {
33
- super(nodeConfig, projectService, project.network, blockDispatcher, dictionaryService, dynamicDsService, eventEmitter, schedulerRegistry);
31
+ constructor(apiService, nodeConfig, projectService, project, blockDispatcher, dictionaryService, unfinalizedBlocksService, eventEmitter, schedulerRegistry) {
32
+ super(nodeConfig, projectService, project.network, blockDispatcher, dictionaryService, eventEmitter, schedulerRegistry);
34
33
  this.apiService = apiService;
35
34
  this.unfinalizedBlocksService = unfinalizedBlocksService;
36
35
  }
@@ -74,7 +73,6 @@ FetchService = __decorate([
74
73
  node_core_1.NodeConfig,
75
74
  project_service_1.ProjectService,
76
75
  SubqueryProject_1.SubqueryProject, Object, ethDictionary_service_1.EthDictionaryService,
77
- dynamic_ds_service_1.DynamicDsService,
78
76
  unfinalizedBlocks_service_1.UnfinalizedBlocksService,
79
77
  event_emitter_1.EventEmitter2,
80
78
  schedule_1.SchedulerRegistry])
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.service.js","sourceRoot":"","sources":["../../src/indexer/fetch.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,yDAAsD;AACtD,+CAAqD;AAErD,4DAAyE;AACzE,gDAK0B;AAE1B,kEAA+D;AAE/D,+DAGoC;AAEpC,8EAA0E;AAC1E,6DAAwD;AACxD,uDAAmD;AACnD,2EAAuE;AAEvE,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAGtB,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,4BAIjC;IACC,YACU,UAAsB,EAC9B,UAAsB,EACK,cAA8B,EAC7B,OAAwB,EAEpD,eAAyC,EACzC,iBAAuC,EACvC,gBAAkC,EAC1B,wBAAkD,EAC1D,YAA2B,EAC3B,iBAAoC;QAEpC,KAAK,CACH,UAAU,EACV,cAAc,EACd,OAAO,CAAC,OAAO,EACf,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,CAClB,CAAC;QArBM,eAAU,GAAV,UAAU,CAAY;QAQtB,6BAAwB,GAAxB,wBAAwB,CAA0B;IAc5D,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;IACnC,CAAC;IAES,cAAc;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC;IACjD,CAAC;IAES,KAAK,CAAC,kBAAkB;QAChC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,i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B;AA1EY,oCAAY","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 { SchedulerRegistry } from '@nestjs/schedule';\n\nimport { isCustomDs, EthereumHandlerKind } from '@subql/common-ethereum';\nimport {\n NodeConfig,\n BaseFetchService,\n ApiService,\n getModulos,\n} from '@subql/node-core';\nimport { EthereumBlock, SubqlDatasource } from '@subql/types-ethereum';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumApi } from '../ethereum';\nimport {\n calcInterval,\n ethereumBlockToHeader,\n} from '../ethereum/utils.ethereum';\nimport { IEthereumBlockDispatcher } from './blockDispatcher';\nimport { EthDictionaryService } from './dictionary/ethDictionary.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport { ProjectService } from './project.service';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\nconst BLOCK_TIME_VARIANCE = 5000;\n\nconst INTERVAL_PERCENT = 0.9;\n\n@Injectable()\nexport class FetchService extends BaseFetchService<\n SubqlDatasource,\n IEthereumBlockDispatcher,\n EthereumBlock\n> {\n constructor(\n private apiService: ApiService,\n nodeConfig: NodeConfig,\n @Inject('IProjectService') projectService: ProjectService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n @Inject('IBlockDispatcher')\n blockDispatcher: IEthereumBlockDispatcher,\n dictionaryService: EthDictionaryService,\n dynamicDsService: DynamicDsService,\n private unfinalizedBlocksService: UnfinalizedBlocksService,\n eventEmitter: EventEmitter2,\n schedulerRegistry: SchedulerRegistry,\n ) {\n super(\n nodeConfig,\n projectService,\n project.network,\n blockDispatcher,\n dictionaryService,\n dynamicDsService,\n eventEmitter,\n schedulerRegistry,\n );\n }\n\n get api(): EthereumApi {\n return this.apiService.unsafeApi;\n }\n\n protected getGenesisHash(): string {\n return this.apiService.networkMeta.genesisHash;\n }\n\n protected async getFinalizedHeight(): Promise<number> {\n const block = await this.api.getFinalizedBlock();\n\n const header = ethereumBlockToHeader(block);\n\n this.unfinalizedBlocksService.registerFinalizedBlock(header);\n return header.blockHeight;\n }\n\n protected async getBestHeight(): Promise<number> {\n return this.api.getBestBlockHeight();\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n protected async getChainInterval(): Promise<number> {\n const CHAIN_INTERVAL = calcInterval(this.api) * INTERVAL_PERCENT;\n\n return Math.min(BLOCK_TIME_VARIANCE, CHAIN_INTERVAL);\n }\n\n protected getModulos(): number[] {\n return getModulos(\n this.projectService.getAllDataSources(),\n isCustomDs,\n EthereumHandlerKind.Block,\n );\n }\n\n protected async initBlockDispatcher(): Promise<void> {\n await this.blockDispatcher.init(this.resetForNewDs.bind(this));\n }\n\n protected async preLoopHook(): Promise<void> {\n // Ethereum doesn't need to do anything here\n return Promise.resolve();\n }\n}\n"]}
1
+ {"version":3,"file":"fetch.service.js","sourceRoot":"","sources":["../../src/indexer/fetch.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,yDAAsD;AACtD,+CAAqD;AAErD,4DAAyE;AACzE,gDAK0B;AAE1B,kEAA+D;AAE/D,+DAGoC;AAEpC,8EAA0E;AAC1E,uDAAmD;AACnD,2EAAuE;AAEvE,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAGtB,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,4BAIjC;IACC,YACU,UAAsB,EAC9B,UAAsB,EACK,cAA8B,EAC7B,OAAwB,EAEpD,eAAyC,EACzC,iBAAuC,EAC/B,wBAAkD,EAC1D,YAA2B,EAC3B,iBAAoC;QAEpC,KAAK,CACH,UAAU,EACV,cAAc,EACd,OAAO,CAAC,OAAO,EACf,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,CAClB,CAAC;QAnBM,eAAU,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BAAU,GAAE;IASR,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;IACzB,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAJP,sBAAU;QAClB,sBAAU;QACqB,gCAAc;QACpB,iCAAe,UAGjC,4CAAoB;QACL,oDAAwB;QAC5C,6BAAa;QACR,4BAAiB;GAf3B,YAAY,CAwExB;AAxEY,oCAAY","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 { SchedulerRegistry } from '@nestjs/schedule';\n\nimport { isCustomDs, EthereumHandlerKind } from '@subql/common-ethereum';\nimport {\n NodeConfig,\n BaseFetchService,\n ApiService,\n getModulos,\n} from '@subql/node-core';\nimport { EthereumBlock, SubqlDatasource } from '@subql/types-ethereum';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumApi } from '../ethereum';\nimport {\n calcInterval,\n ethereumBlockToHeader,\n} from '../ethereum/utils.ethereum';\nimport { IEthereumBlockDispatcher } from './blockDispatcher';\nimport { EthDictionaryService } from './dictionary/ethDictionary.service';\nimport { ProjectService } from './project.service';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\nconst BLOCK_TIME_VARIANCE = 5000;\n\nconst INTERVAL_PERCENT = 0.9;\n\n@Injectable()\nexport class FetchService extends BaseFetchService<\n SubqlDatasource,\n IEthereumBlockDispatcher,\n EthereumBlock\n> {\n constructor(\n private apiService: ApiService,\n nodeConfig: NodeConfig,\n @Inject('IProjectService') projectService: ProjectService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n @Inject('IBlockDispatcher')\n blockDispatcher: IEthereumBlockDispatcher,\n dictionaryService: EthDictionaryService,\n private unfinalizedBlocksService: UnfinalizedBlocksService,\n eventEmitter: EventEmitter2,\n schedulerRegistry: SchedulerRegistry,\n ) {\n super(\n nodeConfig,\n projectService,\n project.network,\n blockDispatcher,\n dictionaryService,\n eventEmitter,\n schedulerRegistry,\n );\n }\n\n get api(): EthereumApi {\n return this.apiService.unsafeApi;\n }\n\n protected getGenesisHash(): string {\n return this.apiService.networkMeta.genesisHash;\n }\n\n protected async getFinalizedHeight(): Promise<number> {\n const block = await this.api.getFinalizedBlock();\n\n const header = ethereumBlockToHeader(block);\n\n this.unfinalizedBlocksService.registerFinalizedBlock(header);\n return header.blockHeight;\n }\n\n protected async getBestHeight(): Promise<number> {\n return this.api.getBestBlockHeight();\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n protected async getChainInterval(): Promise<number> {\n const CHAIN_INTERVAL = calcInterval(this.api) * INTERVAL_PERCENT;\n\n return Math.min(BLOCK_TIME_VARIANCE, CHAIN_INTERVAL);\n }\n\n protected getModulos(): number[] {\n return getModulos(\n this.projectService.getAllDataSources(),\n isCustomDs,\n EthereumHandlerKind.Block,\n );\n }\n\n protected async initBlockDispatcher(): Promise<void> {\n await this.blockDispatcher.init(this.resetForNewDs.bind(this));\n }\n\n protected async preLoopHook(): Promise<void> {\n // Ethereum doesn't need to do anything here\n return Promise.resolve();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subql/node-ethereum",
3
- "version": "3.11.1-0",
3
+ "version": "3.11.1-1",
4
4
  "description": "",
5
5
  "author": "Ian He",
6
6
  "license": "GPL-3.0",
@@ -27,7 +27,7 @@
27
27
  "@nestjs/schedule": "^3.0.1",
28
28
  "@subql/common": "^3.4.2-1",
29
29
  "@subql/common-ethereum": "3.4.2-0",
30
- "@subql/node-core": "^7.5.1-3",
30
+ "@subql/node-core": "7.5.1-5",
31
31
  "@subql/testing": "^2.1.1-0",
32
32
  "@subql/types-ethereum": "3.4.1-0",
33
33
  "cacheable-lookup": "6",
@@ -66,5 +66,5 @@
66
66
  "/dist",
67
67
  "/bin"
68
68
  ],
69
- "stableVersion": "3.11.0"
69
+ "stableVersion": "3.11.1-0"
70
70
  }