@subql/node-ethereum 5.3.0 → 5.4.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/app.module.js +1 -1
  4. package/dist/app.module.js.map +1 -1
  5. package/dist/configure/NodeConfig.js +1 -1
  6. package/dist/configure/NodeConfig.js.map +1 -1
  7. package/dist/configure/SubqueryProject.js +1 -1
  8. package/dist/configure/SubqueryProject.js.map +1 -1
  9. package/dist/configure/configure.module.js +1 -1
  10. package/dist/configure/configure.module.js.map +1 -1
  11. package/dist/ethereum/api.connection.js +1 -1
  12. package/dist/ethereum/api.connection.js.map +1 -1
  13. package/dist/ethereum/api.ethereum.js +1 -1
  14. package/dist/ethereum/api.ethereum.js.map +1 -1
  15. package/dist/ethereum/api.ethereum.test.js +1 -1
  16. package/dist/ethereum/api.ethereum.test.js.map +1 -1
  17. package/dist/ethereum/api.service.ethereum.js +1 -1
  18. package/dist/ethereum/api.service.ethereum.js.map +1 -1
  19. package/dist/ethereum/api.service.ethereum.test.js +1 -1
  20. package/dist/ethereum/api.service.ethereum.test.js.map +1 -1
  21. package/dist/ethereum/block.ethereum.js +1 -1
  22. package/dist/ethereum/block.ethereum.js.map +1 -1
  23. package/dist/ethereum/ethers/celo/celo-provider.d.ts +3 -3
  24. package/dist/ethereum/ethers/celo/celo-provider.js +1 -1
  25. package/dist/ethereum/ethers/celo/celo-provider.js.map +1 -1
  26. package/dist/ethereum/ethers/celo/celo-ws-provider.spec.js +1 -1
  27. package/dist/ethereum/ethers/celo/celo-ws-provider.spec.js.map +1 -1
  28. package/dist/ethereum/ethers/op/op-provider.js +1 -1
  29. package/dist/ethereum/ethers/op/op-provider.js.map +1 -1
  30. package/dist/ethereum/ethers/op/op-provider.spec.js +1 -1
  31. package/dist/ethereum/ethers/op/op-provider.spec.js.map +1 -1
  32. package/dist/ethereum/index.js +1 -1
  33. package/dist/ethereum/index.js.map +1 -1
  34. package/dist/ethereum/safe-api.js +1 -1
  35. package/dist/ethereum/safe-api.js.map +1 -1
  36. package/dist/ethereum/utils.ethereum.js +1 -1
  37. package/dist/ethereum/utils.ethereum.js.map +1 -1
  38. package/dist/indexer/blockDispatcher/block-dispatcher.service.js +1 -1
  39. package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -1
  40. package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js +1 -1
  41. package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js.map +1 -1
  42. package/dist/indexer/blockDispatcher/index.js +1 -1
  43. package/dist/indexer/blockDispatcher/index.js.map +1 -1
  44. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +1 -1
  45. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -1
  46. package/dist/indexer/dictionary/ethDictionary.service.js +1 -1
  47. package/dist/indexer/dictionary/ethDictionary.service.js.map +1 -1
  48. package/dist/indexer/dictionary/utils.js +1 -1
  49. package/dist/indexer/dictionary/utils.js.map +1 -1
  50. package/dist/indexer/dictionary/utils.spec.js +1 -1
  51. package/dist/indexer/dictionary/utils.spec.js.map +1 -1
  52. package/dist/indexer/dictionary/v1/ethDictionaryV1.js +1 -1
  53. package/dist/indexer/dictionary/v1/ethDictionaryV1.js.map +1 -1
  54. package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.js +1 -1
  55. package/dist/indexer/dictionary/v1/ethDictionaryV1.spec.js.map +1 -1
  56. package/dist/indexer/dictionary/v1/index.js +1 -1
  57. package/dist/indexer/dictionary/v1/index.js.map +1 -1
  58. package/dist/indexer/dictionary/v2/ethDictionaryV2.js +1 -1
  59. package/dist/indexer/dictionary/v2/ethDictionaryV2.js.map +1 -1
  60. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js +1 -1
  61. package/dist/indexer/dictionary/v2/ethDictionaryV2.spec.js.map +1 -1
  62. package/dist/indexer/dictionary/v2/index.js +1 -1
  63. package/dist/indexer/dictionary/v2/index.js.map +1 -1
  64. package/dist/indexer/dictionary/v2/types.js +1 -1
  65. package/dist/indexer/dictionary/v2/types.js.map +1 -1
  66. package/dist/indexer/dictionary/v2/utils.js +1 -1
  67. package/dist/indexer/dictionary/v2/utils.js.map +1 -1
  68. package/dist/indexer/dictionary/v2/utils.spec.js +1 -1
  69. package/dist/indexer/dictionary/v2/utils.spec.js.map +1 -1
  70. package/dist/indexer/ds-processor.service.js +1 -1
  71. package/dist/indexer/ds-processor.service.js.map +1 -1
  72. package/dist/indexer/dynamic-ds.service.js +1 -1
  73. package/dist/indexer/dynamic-ds.service.js.map +1 -1
  74. package/dist/indexer/fetch.module.js +1 -1
  75. package/dist/indexer/fetch.module.js.map +1 -1
  76. package/dist/indexer/fetch.service.js +1 -1
  77. package/dist/indexer/fetch.service.js.map +1 -1
  78. package/dist/indexer/indexer.manager.js +1 -1
  79. package/dist/indexer/indexer.manager.js.map +1 -1
  80. package/dist/indexer/project.service.js +3 -1
  81. package/dist/indexer/project.service.js.map +1 -1
  82. package/dist/indexer/project.service.test.js +1 -1
  83. package/dist/indexer/project.service.test.js.map +1 -1
  84. package/dist/indexer/types.js +1 -1
  85. package/dist/indexer/types.js.map +1 -1
  86. package/dist/indexer/unfinalizedBlocks.service.js +2 -1
  87. package/dist/indexer/unfinalizedBlocks.service.js.map +1 -1
  88. package/dist/indexer/unfinalizedBlocks.service.spec.js +1 -1
  89. package/dist/indexer/unfinalizedBlocks.service.spec.js.map +1 -1
  90. package/dist/indexer/worker/worker-fetch.module.js +1 -1
  91. package/dist/indexer/worker/worker-fetch.module.js.map +1 -1
  92. package/dist/indexer/worker/worker.js +1 -1
  93. package/dist/indexer/worker/worker.js.map +1 -1
  94. package/dist/indexer/worker/worker.module.js +1 -1
  95. package/dist/indexer/worker/worker.module.js.map +1 -1
  96. package/dist/indexer/worker/worker.service.js +1 -1
  97. package/dist/indexer/worker/worker.service.js.map +1 -1
  98. package/dist/init.js +1 -1
  99. package/dist/init.js.map +1 -1
  100. package/dist/main.js +1 -1
  101. package/dist/main.js.map +1 -1
  102. package/dist/subcommands/forceClean.init.js +1 -1
  103. package/dist/subcommands/forceClean.init.js.map +1 -1
  104. package/dist/subcommands/forceClean.module.js +1 -1
  105. package/dist/subcommands/forceClean.module.js.map +1 -1
  106. package/dist/subcommands/reindex.init.js +1 -1
  107. package/dist/subcommands/reindex.init.js.map +1 -1
  108. package/dist/subcommands/reindex.module.js +1 -1
  109. package/dist/subcommands/reindex.module.js.map +1 -1
  110. package/dist/subcommands/testing.init.js +1 -1
  111. package/dist/subcommands/testing.init.js.map +1 -1
  112. package/dist/subcommands/testing.module.js +1 -1
  113. package/dist/subcommands/testing.module.js.map +1 -1
  114. package/dist/subcommands/testing.service.js +1 -1
  115. package/dist/subcommands/testing.service.js.map +1 -1
  116. package/dist/utils/project.js +1 -1
  117. package/dist/utils/project.js.map +1 -1
  118. package/dist/utils/string.js +1 -1
  119. package/dist/utils/string.js.map +1 -1
  120. package/dist/yargs.js +1 -1
  121. package/dist/yargs.js.map +1 -1
  122. package/package.json +7 -6
@@ -1 +1 @@
1
- {"version":3,"file":"ethDictionaryV1.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/ethDictionaryV1.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,gDAA8C;AAC9C,0DAI+B;AAC/B,qCAAwC;AAKxC,uDAG2B;AAE3B,MAAM,UAAU,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;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AAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;gBACtD,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;aAC1B,CAAC;YAE9B,MAAM,UAAU,GAAG,IAAA,+CAA6B,EAAC,oBAAoB,CAAC,CAAC;YAEvE,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;gBACzB;oBACE,UAAU,EAAE;wBACV;4BACE,KAAK,EAAE,SAAS;4BAChB,OAAO,EAAE,SAAS;4BAClB,KAAK,EACH,oEAAoE;yBACvE;qBACF;oBACD,MAAM,EAAE,SAAS;iBAClB;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NodeConfig } from '@subql/node-core';\nimport {\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport { GraphQLSchema } from 'graphql';\nimport {\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport {\n buildDictionaryV1QueryEntries,\n EthDictionaryV1,\n} from './ethDictionaryV1';\n\nconst mockTempDs: EthereumProjectDsTemplate[] = [\n {\n name: 'ERC721',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleERC721',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n },\n {\n name: 'ERC1155',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleERC1155',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'TransferSingle(address, address, address, uint256, uint256)',\n ],\n },\n },\n ],\n },\n },\n];\nfunction testSubqueryProject(\n endpoint: string,\n ds: any,\n mockTempDs,\n): SubqueryProject {\n return {\n network: {\n endpoint,\n chainId: '1',\n },\n dataSources: ds as any,\n id: 'test',\n root: './',\n schema: new GraphQLSchema({}),\n templates: mockTempDs as any,\n } as any;\n}\n\ndescribe('Eth Dictionary V1', () => {\n it('Can resovle chain aliases', async () => {\n (EthDictionaryV1.prototype as any).init = jest.fn();\n const dictionary = await EthDictionaryV1.create(\n {\n network: { chainId: '336', dictionary: 'https://foo.bar' } as any,\n } as any,\n new NodeConfig({} as any, true),\n '',\n );\n\n expect((dictionary as any).chainId).toBe(\n '0xf1cf9022c7ebb34b162d5b5e34e705a5a740b2d0ecc1009fb89023e62a488108',\n );\n\n jest.clearAllMocks();\n });\n});\n\ndescribe('buildDictionaryV1QueryEntries', () => {\n describe('Log filters', () => {\n it('Build filter for !null', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV1QueryEntries([ds]);\n\n expect(result).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'address',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n {\n field: 'topics0',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n matcher: 'equalTo',\n },\n {\n field: 'topics3',\n value: false,\n matcher: 'isNull',\n },\n ],\n },\n ]);\n });\n });\n\n describe('Transaction filters', () => {\n it('Build a filter for contract creation transactions', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [{ field: 'to', matcher: 'isNull', value: true }],\n },\n ]);\n });\n\n it('Build a filter with include ds option and contract address', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('If ds option and filter both provide contract address, it should use ds options one', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: '0xabcde',\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('If ds option provide contract address, it should use ds options \"address\"', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('If filter provide contract address, it should use filter \"to\"', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: '0xabcde',\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0xabcde',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('Creates a valid filter with a single event handler that has 0 filters but a contract address', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Event,\n },\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'address',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n ],\n },\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n ],\n },\n ]);\n });\n\n it('builds a filter when theres a block handler with modulo filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: '0xabcde',\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleBlock',\n kind: EthereumHandlerKind.Block,\n filter: {\n modulo: 200,\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0xabcde',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n });\n\n describe('Correct dictionary query with dynamic ds', () => {\n it('Build correct erc1155 transfer single query', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleDyanmicDs',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'TransferSingle(address, address, address, uint256, uint256)',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'topics0',\n value:\n '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',\n matcher: 'equalTo',\n },\n ],\n },\n ]);\n });\n\n it('Builds a groupded query for multiple dynamic ds', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleDyanmicDs',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'TransferMultiple(address, address, address, uint256, uint256)',\n ],\n },\n },\n ],\n },\n };\n\n const duplicateDataSources = [\n { ...mockTempDs[0], options: { address: 'address1' } },\n { ...mockTempDs[0], options: { address: 'address2' } },\n { ...mockTempDs[1], options: { address: 'address3' } },\n ];\n\n const dataSources = [ds, ...duplicateDataSources];\n\n const queryEntry = buildDictionaryV1QueryEntries(dataSources);\n\n expect(queryEntry).toEqual([\n {\n conditions: [\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xeb9b7dd0d144caae51d14067d0d112bc1839fbf62e856fca78f6b4d9bfb51962',\n },\n ],\n entity: 'evmLogs',\n },\n {\n conditions: [\n {\n field: 'address',\n matcher: 'in',\n value: ['address1', 'address2'],\n },\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n },\n ],\n entity: 'evmLogs',\n },\n {\n conditions: [\n {\n field: 'address',\n matcher: 'equalTo',\n value: 'address3',\n },\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',\n },\n ],\n entity: 'evmLogs',\n },\n ]);\n });\n\n it('Drops the address if multiple datasources have the same filters, but one without an address', () => {\n const duplicateDataSources = [\n { ...mockTempDs[0], options: { address: 'address1' } },\n { ...mockTempDs[0], options: { address: 'address2' } },\n { ...mockTempDs[0], options: { address: undefined } },\n ] as SubqlRuntimeDatasource[];\n\n const queryEntry = buildDictionaryV1QueryEntries(duplicateDataSources);\n\n expect(queryEntry).toEqual([\n {\n conditions: [\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n },\n ],\n entity: 'evmLogs',\n },\n ]);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"ethDictionaryV1.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/ethDictionaryV1.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,gDAA8C;AAC9C,0DAI+B;AAC/B,qCAAwC;AAKxC,uDAG2B;AAE3B,MAAM,UAAU,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;4BACN,6DAA6D;yBAC9D;qBACF;iBACF;aACF;SACF;KACF;CACF,CAAC;AACF,SAAS,mBAAmB,CAC1B,QAAgB,EAChB,EAAO,EACP,UAAU;IAEV,OAAO;QACL,OAAO,EAAE;YACP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AS;iBAClB;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NodeConfig } from '@subql/node-core';\nimport {\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport { GraphQLSchema } from 'graphql';\nimport {\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport {\n buildDictionaryV1QueryEntries,\n EthDictionaryV1,\n} from './ethDictionaryV1';\n\nconst mockTempDs: EthereumProjectDsTemplate[] = [\n {\n name: 'ERC721',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleERC721',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n },\n {\n name: 'ERC1155',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleERC1155',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'TransferSingle(address, address, address, uint256, uint256)',\n ],\n },\n },\n ],\n },\n },\n];\nfunction testSubqueryProject(\n endpoint: string,\n ds: any,\n mockTempDs,\n): SubqueryProject {\n return {\n network: {\n endpoint,\n chainId: '1',\n },\n dataSources: ds as any,\n id: 'test',\n root: './',\n schema: new GraphQLSchema({}),\n templates: mockTempDs as any,\n } as any;\n}\n\ndescribe('Eth Dictionary V1', () => {\n it('Can resovle chain aliases', async () => {\n (EthDictionaryV1.prototype as any).init = jest.fn();\n const dictionary = await EthDictionaryV1.create(\n {\n network: { chainId: '336', dictionary: 'https://foo.bar' } as any,\n } as any,\n new NodeConfig({} as any, true),\n '',\n );\n\n expect((dictionary as any).chainId).toBe(\n '0xf1cf9022c7ebb34b162d5b5e34e705a5a740b2d0ecc1009fb89023e62a488108',\n );\n\n jest.clearAllMocks();\n });\n});\n\ndescribe('buildDictionaryV1QueryEntries', () => {\n describe('Log filters', () => {\n it('Build filter for !null', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV1QueryEntries([ds]);\n\n expect(result).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'address',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n {\n field: 'topics0',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n matcher: 'equalTo',\n },\n {\n field: 'topics3',\n value: false,\n matcher: 'isNull',\n },\n ],\n },\n ]);\n });\n });\n\n describe('Transaction filters', () => {\n it('Build a filter for contract creation transactions', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [{ field: 'to', matcher: 'isNull', value: true }],\n },\n ]);\n });\n\n it('Build a filter with include ds option and contract address', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('If ds option and filter both provide contract address, it should use ds options one', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: '0xabcde',\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('If ds option provide contract address, it should use ds options \"address\"', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('If filter provide contract address, it should use filter \"to\"', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: '0xabcde',\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0xabcde',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n\n it('Creates a valid filter with a single event handler that has 0 filters but a contract address', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Event,\n },\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'address',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n ],\n },\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n ],\n },\n ]);\n });\n\n it('builds a filter when theres a block handler with modulo filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: '0xabcde',\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleBlock',\n kind: EthereumHandlerKind.Block,\n filter: {\n modulo: 200,\n },\n },\n ],\n },\n };\n\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmTransactions',\n conditions: [\n {\n field: 'to',\n matcher: 'equalTo',\n value: '0xabcde',\n },\n { field: 'func', matcher: 'equalTo', value: '0x095ea7b3' },\n ],\n },\n ]);\n });\n });\n\n describe('Correct dictionary query with dynamic ds', () => {\n it('Build correct erc1155 transfer single query', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleDyanmicDs',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'TransferSingle(address, address, address, uint256, uint256)',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV1QueryEntries([ds]);\n expect(result).toEqual([\n {\n entity: 'evmLogs',\n conditions: [\n {\n field: 'topics0',\n value:\n '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',\n matcher: 'equalTo',\n },\n ],\n },\n ]);\n });\n\n it('Builds a groupded query for multiple dynamic ds', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleDyanmicDs',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'TransferMultiple(address, address, address, uint256, uint256)',\n ],\n },\n },\n ],\n },\n };\n\n const duplicateDataSources = [\n { ...mockTempDs[0], options: { address: 'address1' } },\n { ...mockTempDs[0], options: { address: 'address2' } },\n { ...mockTempDs[1], options: { address: 'address3' } },\n ];\n\n const dataSources = [ds, ...duplicateDataSources];\n\n const queryEntry = buildDictionaryV1QueryEntries(dataSources);\n\n expect(queryEntry).toEqual([\n {\n conditions: [\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xeb9b7dd0d144caae51d14067d0d112bc1839fbf62e856fca78f6b4d9bfb51962',\n },\n ],\n entity: 'evmLogs',\n },\n {\n conditions: [\n {\n field: 'address',\n matcher: 'in',\n value: ['address1', 'address2'],\n },\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n },\n ],\n entity: 'evmLogs',\n },\n {\n conditions: [\n {\n field: 'address',\n matcher: 'equalTo',\n value: 'address3',\n },\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62',\n },\n ],\n entity: 'evmLogs',\n },\n ]);\n });\n\n it('Drops the address if multiple datasources have the same filters, but one without an address', () => {\n const duplicateDataSources = [\n { ...mockTempDs[0], options: { address: 'address1' } },\n { ...mockTempDs[0], options: { address: 'address2' } },\n { ...mockTempDs[0], options: { address: undefined } },\n ] as SubqlRuntimeDatasource[];\n\n const queryEntry = buildDictionaryV1QueryEntries(duplicateDataSources);\n\n expect(queryEntry).toEqual([\n {\n conditions: [\n {\n field: 'topics0',\n matcher: 'equalTo',\n value:\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n },\n ],\n entity: 'evmLogs',\n },\n ]);\n });\n });\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
5
  if (k2 === undefined) k2 = k;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;AAEnC,oDAAkC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nexport * from './ethDictionaryV1';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;AAEnC,oDAAkC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nexport * from './ethDictionaryV1';\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.EthDictionaryV2 = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"ethDictionaryV2.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AA8JnC,kEAmDC;AA/MD,4DAAyD;AACzD,gDAO0B;AAC1B,0DAM+B;AAC/B,mCAAgC;AAChC,8DAAmE;AAOnE,kDAAwE;AACxE,0CAA8C;AAC9C,oCAA8D;AAO9D,mCAA6C;AAE7C,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,eAAe,CAAC,CAAC;AAE1C,SAAS,cAAc,CACrB,SAAyC;IAEzC,MAAM,iBAAiB,GAAG,o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C,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,0BAAkB,EAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAE9C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO;oBACL,WAAW,EAAE,EAAE;oBACf,kBAAkB,EAAE,SAAS,EAAE,gEAAgE;iBACzF,CAAC;YACX,CAAC;YACD,OAAO;gBACL,WAAW,EAAE,MAAM;gBACnB,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM;aAC3D,CAAC;QACJ,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,kCAAkC,CAAC,CAAC;YACpD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;CACF;AAvED,0CAuEC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NOT_NULL_FILTER } from '@subql/common-ethereum';\nimport {\n NodeConfig,\n DictionaryV2,\n RawDictionaryResponseData,\n DictionaryResponse,\n getLogger,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumHandlerKind,\n EthereumLogFilter,\n EthereumTransactionFilter,\n SubqlDatasource,\n} from '@subql/types-ethereum';\nimport { uniqBy } from 'lodash';\nimport { EthereumNodeConfig } from '../../../configure/NodeConfig';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport { eventToTopic, functionToSighash } from '../../../utils/string';\nimport { yargsOptions } from '../../../yargs';\nimport { groupedDataSources, validAddresses } from '../utils';\nimport {\n RawEthBlock,\n EthDictionaryV2QueryEntry,\n EthDictionaryTxConditions,\n EthDictionaryLogConditions,\n} from './types';\nimport { rawBlockToEthBlock } from './utils';\n\nconst MIN_FETCH_LIMIT = 200;\n\nconst logger = getLogger('dictionary-v2');\n\nfunction applyAddresses(\n addresses?: (string | undefined | null)[],\n): string[] | undefined {\n const queryAddressLimit = yargsOptions.argv['query-address-limit'];\n if (\n !addresses ||\n !addresses.length ||\n addresses.length > queryAddressLimit ||\n addresses.filter((v) => !v).length // DONT use find because 'undefined' and 'null' as falsey\n ) {\n return [];\n }\n\n return validAddresses(addresses).map((a) => a.toLowerCase());\n}\n\nfunction callFilterToDictionaryCondition(\n filter?: EthereumTransactionFilter,\n addresses?: (string | undefined | null)[],\n): EthDictionaryTxConditions {\n const txConditions: EthDictionaryTxConditions = {};\n const toArray: (string | null)[] = [];\n const fromArray: string[] = [];\n const funcArray: string[] = [];\n\n if (filter?.from) {\n fromArray.push(filter.from.toLowerCase());\n }\n\n const assignTo = (value: string | null | undefined) => {\n if (value === null) {\n toArray.push(null);\n } else if (value !== undefined) {\n toArray.push(value.toLowerCase());\n }\n };\n\n const optionsAddresses = applyAddresses(addresses);\n if (!optionsAddresses?.length) {\n assignTo(filter?.to);\n } else {\n if (filter?.to || filter?.to === null) {\n logger.warn(\n `TransactionFilter 'to' conflicts with 'address' in data source options, using data source option`,\n );\n }\n optionsAddresses.forEach(assignTo);\n }\n\n if (filter?.function) {\n funcArray.push(functionToSighash(filter.function));\n }\n\n if (toArray.length !== 0) {\n txConditions.to = toArray;\n }\n if (fromArray.length !== 0) {\n txConditions.from = fromArray;\n }\n\n if (funcArray.length !== 0) {\n txConditions.data = funcArray;\n }\n\n return txConditions;\n}\n\nfunction eventFilterToDictionaryCondition(\n filter?: EthereumLogFilter,\n addresses?: (string | undefined | null)[],\n): EthDictionaryLogConditions {\n const logConditions: EthDictionaryLogConditions = {};\n logConditions.address = applyAddresses(addresses);\n if (filter?.topics) {\n for (let i = 0; i < Math.min(filter.topics.length, 4); i++) {\n const topic = filter.topics[i];\n if (!topic) {\n continue;\n }\n const field = `topics${i}`;\n // Initialized\n if (!logConditions[field]) {\n logConditions[field] = [];\n }\n if (topic === NOT_NULL_FILTER) {\n logConditions[field] = []; // TODO, check if !null\n } else {\n logConditions[field].push(eventToTopic(topic));\n }\n }\n }\n return logConditions;\n}\n\nfunction sanitiseDictionaryConditions(\n dictionaryConditions: EthDictionaryV2QueryEntry,\n): EthDictionaryV2QueryEntry {\n if (!dictionaryConditions.logs?.length) {\n delete dictionaryConditions.logs;\n } else {\n dictionaryConditions.logs = uniqBy(dictionaryConditions.logs, (log) =>\n JSON.stringify(log),\n );\n }\n\n if (!dictionaryConditions.transactions?.length) {\n delete dictionaryConditions.transactions;\n } else {\n dictionaryConditions.transactions = uniqBy(\n dictionaryConditions.transactions,\n (tx) => JSON.stringify(tx),\n );\n }\n\n return dictionaryConditions;\n}\n\nexport function buildDictionaryV2QueryEntry(\n dataSources: EthereumProjectDs[],\n): EthDictionaryV2QueryEntry {\n const dictionaryConditions: EthDictionaryV2QueryEntry = {\n logs: [],\n transactions: [],\n };\n\n const groupedHandlers = groupedDataSources(dataSources);\n for (const [handler, addresses] of groupedHandlers) {\n // No filters, cant use dictionary\n if (!handler.filter && !addresses?.length) return {};\n\n switch (handler.kind) {\n case EthereumHandlerKind.Block:\n if (handler.filter?.modulo === undefined) {\n return {};\n }\n break;\n case EthereumHandlerKind.Call: {\n if (\n (handler.filter &&\n Object.values(handler.filter).filter((v) => v !== undefined)\n .length) ||\n validAddresses(addresses).length\n ) {\n dictionaryConditions.transactions ??= [];\n dictionaryConditions.transactions.push(\n callFilterToDictionaryCondition(handler.filter, addresses),\n );\n }\n break;\n }\n case EthereumHandlerKind.Event: {\n if (\n handler.filter?.topics?.length ||\n validAddresses(addresses).length\n ) {\n dictionaryConditions.logs ??= [];\n dictionaryConditions.logs.push(\n eventFilterToDictionaryCondition(handler.filter, addresses),\n );\n }\n\n break;\n }\n default:\n }\n }\n\n return sanitiseDictionaryConditions(dictionaryConditions);\n}\n\nexport class EthDictionaryV2 extends DictionaryV2<\n EthereumBlock,\n SubqlDatasource,\n EthDictionaryV2QueryEntry\n> {\n #skipTransactions: boolean;\n\n constructor(\n endpoint: string,\n nodeConfig: NodeConfig,\n project: SubqueryProject,\n private api: EthereumApi,\n ) {\n super(endpoint, project.network.chainId, nodeConfig);\n this.#skipTransactions = !!new EthereumNodeConfig(nodeConfig)\n .skipTransactions;\n }\n\n static async create(\n endpoint: string,\n nodeConfig: NodeConfig,\n project: SubqueryProject,\n api: EthereumApi,\n ): Promise<EthDictionaryV2> {\n const dictionary = new EthDictionaryV2(endpoint, nodeConfig, project, api);\n await dictionary.init();\n return dictionary;\n }\n\n buildDictionaryQueryEntries(\n dataSources: (EthereumProjectDs | EthereumProjectDsTemplate)[],\n ): EthDictionaryV2QueryEntry {\n return buildDictionaryV2QueryEntry(dataSources);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getData(\n startBlock: number,\n endBlock: number,\n limit: number = MIN_FETCH_LIMIT,\n ): Promise<DictionaryResponse<IBlock<EthereumBlock> | number> | undefined> {\n return super.getData(startBlock, endBlock, limit, {\n blockHeader: true,\n logs: { transaction: !this.#skipTransactions },\n transactions: { log: true },\n });\n }\n\n convertResponseBlocks<RFB = RawEthBlock>(\n data: RawDictionaryResponseData<RFB>,\n ): DictionaryResponse<IBlock<EthereumBlock>> | undefined {\n try {\n const blocks: IBlock<EthereumBlock>[] = (\n (data.blocks as RawEthBlock[]) || []\n ).map((b) => rawBlockToEthBlock(b, this.api));\n\n if (!blocks.length) {\n return {\n batchBlocks: [],\n lastBufferedHeight: undefined, // This will get set to the request end block in the base class.\n } as any;\n }\n return {\n batchBlocks: blocks,\n lastBufferedHeight: blocks[blocks.length - 1].block.number,\n };\n } catch (e: any) {\n logger.error(e, `Failed to handle block response}`);\n throw e;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ethDictionaryV2.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;A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EAAE,QAAQ,EAAE,KAAK,EAAE;YAChD,WAAW,EAAE,IAAI;YACjB,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC9C,YAAY,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,qBAAqB,CACnB,IAAoC;QAEpC,IAAI,CAAC;YACH,MAAM,MAAM,GAA4B,CACrC,IAAI,CAAC,MAAwB,IAAI,EAAE,CACrC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,0BAAkB,EAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAE9C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO;oBACL,WAAW,EAAE,EAAE;oBACf,kBAAkB,EAAE,SAAS,EAAE,gEAAgE;iBACzF,CAAC;YACX,CAAC;YACD,OAAO;gBACL,WAAW,EAAE,MAAM;gBACnB,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM;aAC3D,CAAC;QACJ,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,kCAAkC,CAAC,CAAC;YACpD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;CACF;AAvED,0CAuEC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NOT_NULL_FILTER } from '@subql/common-ethereum';\nimport {\n NodeConfig,\n DictionaryV2,\n RawDictionaryResponseData,\n DictionaryResponse,\n getLogger,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumHandlerKind,\n EthereumLogFilter,\n EthereumTransactionFilter,\n SubqlDatasource,\n} from '@subql/types-ethereum';\nimport { uniqBy } from 'lodash';\nimport { EthereumNodeConfig } from '../../../configure/NodeConfig';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport { eventToTopic, functionToSighash } from '../../../utils/string';\nimport { yargsOptions } from '../../../yargs';\nimport { groupedDataSources, validAddresses } from '../utils';\nimport {\n RawEthBlock,\n EthDictionaryV2QueryEntry,\n EthDictionaryTxConditions,\n EthDictionaryLogConditions,\n} from './types';\nimport { rawBlockToEthBlock } from './utils';\n\nconst MIN_FETCH_LIMIT = 200;\n\nconst logger = getLogger('dictionary-v2');\n\nfunction applyAddresses(\n addresses?: (string | undefined | null)[],\n): string[] | undefined {\n const queryAddressLimit = yargsOptions.argv['query-address-limit'];\n if (\n !addresses ||\n !addresses.length ||\n addresses.length > queryAddressLimit ||\n addresses.filter((v) => !v).length // DONT use find because 'undefined' and 'null' as falsey\n ) {\n return [];\n }\n\n return validAddresses(addresses).map((a) => a.toLowerCase());\n}\n\nfunction callFilterToDictionaryCondition(\n filter?: EthereumTransactionFilter,\n addresses?: (string | undefined | null)[],\n): EthDictionaryTxConditions {\n const txConditions: EthDictionaryTxConditions = {};\n const toArray: (string | null)[] = [];\n const fromArray: string[] = [];\n const funcArray: string[] = [];\n\n if (filter?.from) {\n fromArray.push(filter.from.toLowerCase());\n }\n\n const assignTo = (value: string | null | undefined) => {\n if (value === null) {\n toArray.push(null);\n } else if (value !== undefined) {\n toArray.push(value.toLowerCase());\n }\n };\n\n const optionsAddresses = applyAddresses(addresses);\n if (!optionsAddresses?.length) {\n assignTo(filter?.to);\n } else {\n if (filter?.to || filter?.to === null) {\n logger.warn(\n `TransactionFilter 'to' conflicts with 'address' in data source options, using data source option`,\n );\n }\n optionsAddresses.forEach(assignTo);\n }\n\n if (filter?.function) {\n funcArray.push(functionToSighash(filter.function));\n }\n\n if (toArray.length !== 0) {\n txConditions.to = toArray;\n }\n if (fromArray.length !== 0) {\n txConditions.from = fromArray;\n }\n\n if (funcArray.length !== 0) {\n txConditions.data = funcArray;\n }\n\n return txConditions;\n}\n\nfunction eventFilterToDictionaryCondition(\n filter?: EthereumLogFilter,\n addresses?: (string | undefined | null)[],\n): EthDictionaryLogConditions {\n const logConditions: EthDictionaryLogConditions = {};\n logConditions.address = applyAddresses(addresses);\n if (filter?.topics) {\n for (let i = 0; i < Math.min(filter.topics.length, 4); i++) {\n const topic = filter.topics[i];\n if (!topic) {\n continue;\n }\n const field = `topics${i}`;\n // Initialized\n if (!logConditions[field]) {\n logConditions[field] = [];\n }\n if (topic === NOT_NULL_FILTER) {\n logConditions[field] = []; // TODO, check if !null\n } else {\n logConditions[field].push(eventToTopic(topic));\n }\n }\n }\n return logConditions;\n}\n\nfunction sanitiseDictionaryConditions(\n dictionaryConditions: EthDictionaryV2QueryEntry,\n): EthDictionaryV2QueryEntry {\n if (!dictionaryConditions.logs?.length) {\n delete dictionaryConditions.logs;\n } else {\n dictionaryConditions.logs = uniqBy(dictionaryConditions.logs, (log) =>\n JSON.stringify(log),\n );\n }\n\n if (!dictionaryConditions.transactions?.length) {\n delete dictionaryConditions.transactions;\n } else {\n dictionaryConditions.transactions = uniqBy(\n dictionaryConditions.transactions,\n (tx) => JSON.stringify(tx),\n );\n }\n\n return dictionaryConditions;\n}\n\nexport function buildDictionaryV2QueryEntry(\n dataSources: EthereumProjectDs[],\n): EthDictionaryV2QueryEntry {\n const dictionaryConditions: EthDictionaryV2QueryEntry = {\n logs: [],\n transactions: [],\n };\n\n const groupedHandlers = groupedDataSources(dataSources);\n for (const [handler, addresses] of groupedHandlers) {\n // No filters, cant use dictionary\n if (!handler.filter && !addresses?.length) return {};\n\n switch (handler.kind) {\n case EthereumHandlerKind.Block:\n if (handler.filter?.modulo === undefined) {\n return {};\n }\n break;\n case EthereumHandlerKind.Call: {\n if (\n (handler.filter &&\n Object.values(handler.filter).filter((v) => v !== undefined)\n .length) ||\n validAddresses(addresses).length\n ) {\n dictionaryConditions.transactions ??= [];\n dictionaryConditions.transactions.push(\n callFilterToDictionaryCondition(handler.filter, addresses),\n );\n }\n break;\n }\n case EthereumHandlerKind.Event: {\n if (\n handler.filter?.topics?.length ||\n validAddresses(addresses).length\n ) {\n dictionaryConditions.logs ??= [];\n dictionaryConditions.logs.push(\n eventFilterToDictionaryCondition(handler.filter, addresses),\n );\n }\n\n break;\n }\n default:\n }\n }\n\n return sanitiseDictionaryConditions(dictionaryConditions);\n}\n\nexport class EthDictionaryV2 extends DictionaryV2<\n EthereumBlock,\n SubqlDatasource,\n EthDictionaryV2QueryEntry\n> {\n #skipTransactions: boolean;\n\n constructor(\n endpoint: string,\n nodeConfig: NodeConfig,\n project: SubqueryProject,\n private api: EthereumApi,\n ) {\n super(endpoint, project.network.chainId, nodeConfig);\n this.#skipTransactions = !!new EthereumNodeConfig(nodeConfig)\n .skipTransactions;\n }\n\n static async create(\n endpoint: string,\n nodeConfig: NodeConfig,\n project: SubqueryProject,\n api: EthereumApi,\n ): Promise<EthDictionaryV2> {\n const dictionary = new EthDictionaryV2(endpoint, nodeConfig, project, api);\n await dictionary.init();\n return dictionary;\n }\n\n buildDictionaryQueryEntries(\n dataSources: (EthereumProjectDs | EthereumProjectDsTemplate)[],\n ): EthDictionaryV2QueryEntry {\n return buildDictionaryV2QueryEntry(dataSources);\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getData(\n startBlock: number,\n endBlock: number,\n limit: number = MIN_FETCH_LIMIT,\n ): Promise<DictionaryResponse<IBlock<EthereumBlock> | number> | undefined> {\n return super.getData(startBlock, endBlock, limit, {\n blockHeader: true,\n logs: { transaction: !this.#skipTransactions },\n transactions: { log: true },\n });\n }\n\n convertResponseBlocks<RFB = RawEthBlock>(\n data: RawDictionaryResponseData<RFB>,\n ): DictionaryResponse<IBlock<EthereumBlock>> | undefined {\n try {\n const blocks: IBlock<EthereumBlock>[] = (\n (data.blocks as RawEthBlock[]) || []\n ).map((b) => rawBlockToEthBlock(b, this.api));\n\n if (!blocks.length) {\n return {\n batchBlocks: [],\n lastBufferedHeight: undefined, // This will get set to the request end block in the base class.\n } as any;\n }\n return {\n batchBlocks: blocks,\n lastBufferedHeight: blocks[blocks.length - 1].block.number,\n };\n } catch (e: any) {\n logger.error(e, `Failed to handle block response}`);\n throw e;\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -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,4DAAyD;AACzD,gDAK0B;AAC1B,0DAM+B;AAC/B,kEAA0C;AAM1C,gDAAgD;AAChD,uDAG2B;AAE3B,MAAM,kBAAkB,GAAG,+CAA+C,CAAC;AAC3E,MAAM,aAAa,GAAG,8CAA8C,CAAC;AACrE,MAAM,MAAM,GAAwB;IAClC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,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,M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ier: GPL-3.0\n\nimport { NOT_NULL_FILTER } from '@subql/common-ethereum';\nimport {\n BlockHeightMap,\n DictionaryResponse,\n IBlock,\n NodeConfig,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlDatasource,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport EventEmitter2 from 'eventemitter2';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport {\n buildDictionaryV2QueryEntry,\n EthDictionaryV2,\n} from './ethDictionaryV2';\n\nconst DEFAULT_DICTIONARY = 'https://ethereum.node.subquery.network/public';\nconst HTTP_ENDPOINT = 'https://ethereum.rpc.subquery.network/public';\nconst mockDs: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address indexed from, address indexed to, uint256 amount)',\n ],\n },\n },\n ],\n },\n },\n];\n\nconst templateTs: EthereumProjectDsTemplate = {\n name: 'template',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n // address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n // startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n};\n\n// tx to is null\nconst mockDs2: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n processor: { file: '' },\n },\n];\n\nconst nodeConfig = new NodeConfig({\n subquery: 'eth-starter',\n subqueryName: 'eth-starter',\n dictionaryTimeout: 10,\n networkEndpoint: { [HTTP_ENDPOINT]: {} },\n networkDictionary: [DEFAULT_DICTIONARY],\n});\n\nfunction makeBlockHeightMap(mockDs: SubqlDatasource[]): BlockHeightMap<any> {\n const m = new Map<number, any>();\n mockDs.forEach((ds, index, dataSources) => {\n m.set(ds.startBlock || 1, dataSources.slice(0, index + 1));\n });\n return new BlockHeightMap(m);\n}\n\n// enable this once dictionary v2 is online\ndescribe('eth dictionary v2', () => {\n let ethDictionaryV2: EthDictionaryV2;\n\n const dsMap = makeBlockHeightMap(mockDs);\n\n beforeAll(async () => {\n ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n { network: { chainId: '1' } } as SubqueryProject,\n new EthereumApi(HTTP_ENDPOINT, 1, new EventEmitter2()),\n );\n }, 10000);\n\n beforeEach(() => {\n ethDictionaryV2.updateQueriesMap(dsMap);\n });\n\n it('converts ds to v2 dictionary queries', () => {\n const query = (ethDictionaryV2 as any).queriesMap.get(19217803);\n expect(query.logs.length).toBe(1);\n expect(query.transactions.length).toBe(1);\n });\n\n it('query response match with entries', async () => {\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n expect(ethBlocks.batchBlocks.map((b) => b.block.number)).toStrictEqual([\n 19217803, 19217804,\n ]);\n\n const ethBlock19217803 = ethBlocks.batchBlocks[0].block;\n const ethBlock19217804 = ethBlocks.batchBlocks[1].block;\n\n expect(ethBlock19217803.number).toBe(19217803);\n expect(ethBlock19217804.number).toBe(19217804);\n\n // Sighash of approval tx\n expect(\n ethBlock19217803.transactions.filter(\n (tx) => tx.input.indexOf('0x095ea7b3') === 0,\n ).length,\n ).toBe(4);\n\n expect(ethBlock19217804.logs.length).toBe(233);\n\n // This matches with dictionaryQueryEntries[0].topics\n expect(ethBlock19217804.logs[0].topics).toContain(\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n );\n }, 10000);\n\n // Geth currently throwing errors with this request\n it.skip('is able to get transaction with field to is null', async () => {\n const dsMap = makeBlockHeightMap(mockDs2);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({ transactions: [{ to: [null] }] });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 1,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, transactions } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toBe(\n '0xa9ba70126240a8418739a103527860948a2be32de2eb9a8f590591faa174c08b',\n );\n\n // https://etherscan.io/tx/0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1\n expect(\n transactions.find(\n (tx) =>\n tx.hash ===\n '0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1',\n ),\n ).toBeDefined();\n });\n\n it('is able to query with not null topics', async () => {\n /**\n * Dictionary v1 supported filtering logs where a topic was null or not null.\n * V2 doesn't yet support this but we should still be able to make a dictionary query that gets relevant logs.\n * It will just include events that will be filtered out later.\n * */\n\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 19476187,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n NOT_NULL_FILTER,\n ],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, logs } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toEqual(\n '0xa798861151ed58ad67d80d1cf61dc30e65d003bc958e99a7969a05a67e69e0b2',\n );\n\n const log = logs.find((l) => l.logIndex === 184);\n expect(log).toBeDefined();\n expect(log!.transactionHash).toEqual(\n '0x5491f3f4b7ca6cc81f992a17e19bc9bafff408518c643c5a254de44b5a7b6d72',\n );\n\n // Uncomment this when not null filter supported\n // expect(logs.filter(l => !l.topics[3]).length).toEqual(6) // There are 6 events with no topic3\n }, 100000);\n\n it('returns a lastBufferedHeight if there are no block results', async () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x30baa3ba9d7089fd8d020a994db75d14cf7ec83b',\n },\n startBlock: 18723210,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const res = await ethDictionaryV2.getData(18723210, 18733210, 100);\n\n expect(res?.batchBlocks.length).toEqual(0);\n expect(res?.lastBufferedHeight).toEqual(18733210);\n });\n});\n\ndescribe('buildDictionaryV2QueryEntry', () => {\n it('Build filter for !null', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n NOT_NULL_FILTER,\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n });\n\n it('Build filter tx filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('Creates a valid filter with a single event handler that has 0 filters but a contract address', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Event,\n },\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n },\n ],\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n },\n ],\n });\n });\n\n it('build query entries for multiple ds', () => {\n const ds: SubqlRuntimeDatasource[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'EnsRegistry',\n address: '0x314159265dd8dbb310642f98f50c066173c1259b',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n // one duplicate one\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleNewOwnerOldRegistry',\n filter: {\n topics: ['NewOwner(bytes32,bytes32,address)'],\n },\n },\n ],\n },\n },\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'Resolver',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleABIChanged',\n filter: {\n topics: ['ABIChanged(bytes32,uint256)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAddrChanged',\n filter: {\n topics: ['AddrChanged(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleMulticoinAddrChanged',\n filter: {\n topics: ['AddressChanged(bytes32,uint256,bytes)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAuthorisationChanged',\n filter: {\n topics: ['AuthorisationChanged(bytes32,address,address,bool)'],\n },\n },\n ],\n },\n },\n ];\n\n const queryEntry = buildDictionaryV2QueryEntry(ds);\n // Total 7 handlers were given, 1 is duplicate\n expect(queryEntry.logs!.length).toBe(6);\n });\n\n it('should unique QueryEntry for duplicate dataSources', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleLogSame',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n {\n handler: 'handleTxSame',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n transactions: [\n {\n from: ['mockaddress'],\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('should group a small number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 10; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ds);\n\n expect(result).toEqual({\n logs: [\n {\n address: [\n '0x0',\n '0x1',\n '0x2',\n '0x3',\n '0x4',\n '0x5',\n '0x6',\n '0x7',\n '0x8',\n '0x9',\n ],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('should remove address filter with large number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 200; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ds);\n\n expect(result).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('builds a filter when theres a block handler with modulo filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleBlock',\n kind: EthereumHandlerKind.Block,\n filter: {\n modulo: 100,\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n});\n"]}
1
+ {"version":3,"file":"ethDictionaryV2.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;AAEnC,4DAAyD;AACzD,gDAK0B;AAC1B,0DAM+B;AAC/B,kEAA0C;AAM1C,gDAAgD;AAChD,uDAG2B;AAE3B,MAAM,kBAAkB,GAAG,+CAA+C,CAAC;AAC3E,MAAM,aAAa,GA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;qBACF;oBACD;wBACE,OAAO,EAAE,UAAU;wBACnB,IAAI,EAAE,oCAAmB,CAAC,IAAI;wBAC9B,MAAM,EAAE;4BACN,QAAQ,EAAE,yCAAyC;yBACpD;qBACF;iBACF;aACF;SACF,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,6CAA2B,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,YAAY,EAAE;gBACZ;oBACE,EAAE,EAAE,CAAC,4CAA4C,CAAC;oBAClD,IAAI,EAAE,CAAC,YAAY,CAAC;iBACrB;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { NOT_NULL_FILTER } from '@subql/common-ethereum';\nimport {\n BlockHeightMap,\n DictionaryResponse,\n IBlock,\n NodeConfig,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlDatasource,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport EventEmitter2 from 'eventemitter2';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport {\n buildDictionaryV2QueryEntry,\n EthDictionaryV2,\n} from './ethDictionaryV2';\n\nconst DEFAULT_DICTIONARY = 'https://ethereum.node.subquery.network/public';\nconst HTTP_ENDPOINT = 'https://ethereum.rpc.subquery.network/public';\nconst mockDs: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address indexed from, address indexed to, uint256 amount)',\n ],\n },\n },\n ],\n },\n },\n];\n\nconst templateTs: EthereumProjectDsTemplate = {\n name: 'template',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n // address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n // startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n};\n\n// tx to is null\nconst mockDs2: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n processor: { file: '' },\n },\n];\n\nconst nodeConfig = new NodeConfig({\n subquery: 'eth-starter',\n subqueryName: 'eth-starter',\n dictionaryTimeout: 10,\n networkEndpoint: { [HTTP_ENDPOINT]: {} },\n networkDictionary: [DEFAULT_DICTIONARY],\n});\n\nfunction makeBlockHeightMap(mockDs: SubqlDatasource[]): BlockHeightMap<any> {\n const m = new Map<number, any>();\n mockDs.forEach((ds, index, dataSources) => {\n m.set(ds.startBlock || 1, dataSources.slice(0, index + 1));\n });\n return new BlockHeightMap(m);\n}\n\n// enable this once dictionary v2 is online\ndescribe('eth dictionary v2', () => {\n let ethDictionaryV2: EthDictionaryV2;\n\n const dsMap = makeBlockHeightMap(mockDs);\n\n beforeAll(async () => {\n ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n { network: { chainId: '1' } } as SubqueryProject,\n new EthereumApi(HTTP_ENDPOINT, 1, new EventEmitter2()),\n );\n }, 10000);\n\n beforeEach(() => {\n ethDictionaryV2.updateQueriesMap(dsMap);\n });\n\n it('converts ds to v2 dictionary queries', () => {\n const query = (ethDictionaryV2 as any).queriesMap.get(19217803);\n expect(query.logs.length).toBe(1);\n expect(query.transactions.length).toBe(1);\n });\n\n it('query response match with entries', async () => {\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n expect(ethBlocks.batchBlocks.map((b) => b.block.number)).toStrictEqual([\n 19217803, 19217804,\n ]);\n\n const ethBlock19217803 = ethBlocks.batchBlocks[0].block;\n const ethBlock19217804 = ethBlocks.batchBlocks[1].block;\n\n expect(ethBlock19217803.number).toBe(19217803);\n expect(ethBlock19217804.number).toBe(19217804);\n\n // Sighash of approval tx\n expect(\n ethBlock19217803.transactions.filter(\n (tx) => tx.input.indexOf('0x095ea7b3') === 0,\n ).length,\n ).toBe(4);\n\n expect(ethBlock19217804.logs.length).toBe(233);\n\n // This matches with dictionaryQueryEntries[0].topics\n expect(ethBlock19217804.logs[0].topics).toContain(\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n );\n }, 10000);\n\n // Geth currently throwing errors with this request\n it.skip('is able to get transaction with field to is null', async () => {\n const dsMap = makeBlockHeightMap(mockDs2);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({ transactions: [{ to: [null] }] });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 1,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, transactions } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toBe(\n '0xa9ba70126240a8418739a103527860948a2be32de2eb9a8f590591faa174c08b',\n );\n\n // https://etherscan.io/tx/0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1\n expect(\n transactions.find(\n (tx) =>\n tx.hash ===\n '0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1',\n ),\n ).toBeDefined();\n });\n\n it('is able to query with not null topics', async () => {\n /**\n * Dictionary v1 supported filtering logs where a topic was null or not null.\n * V2 doesn't yet support this but we should still be able to make a dictionary query that gets relevant logs.\n * It will just include events that will be filtered out later.\n * */\n\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 19476187,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n NOT_NULL_FILTER,\n ],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, logs } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toEqual(\n '0xa798861151ed58ad67d80d1cf61dc30e65d003bc958e99a7969a05a67e69e0b2',\n );\n\n const log = logs.find((l) => l.logIndex === 184);\n expect(log).toBeDefined();\n expect(log!.transactionHash).toEqual(\n '0x5491f3f4b7ca6cc81f992a17e19bc9bafff408518c643c5a254de44b5a7b6d72',\n );\n\n // Uncomment this when not null filter supported\n // expect(logs.filter(l => !l.topics[3]).length).toEqual(6) // There are 6 events with no topic3\n }, 100000);\n\n it('returns a lastBufferedHeight if there are no block results', async () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x30baa3ba9d7089fd8d020a994db75d14cf7ec83b',\n },\n startBlock: 18723210,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const res = await ethDictionaryV2.getData(18723210, 18733210, 100);\n\n expect(res?.batchBlocks.length).toEqual(0);\n expect(res?.lastBufferedHeight).toEqual(18733210);\n });\n});\n\ndescribe('buildDictionaryV2QueryEntry', () => {\n it('Build filter for !null', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n NOT_NULL_FILTER,\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n });\n\n it('Build filter tx filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('Creates a valid filter with a single event handler that has 0 filters but a contract address', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Event,\n },\n {\n handler: 'handleTransfer',\n kind: EthereumHandlerKind.Call,\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n },\n ],\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n },\n ],\n });\n });\n\n it('build query entries for multiple ds', () => {\n const ds: SubqlRuntimeDatasource[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'EnsRegistry',\n address: '0x314159265dd8dbb310642f98f50c066173c1259b',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n // one duplicate one\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleNewOwnerOldRegistry',\n filter: {\n topics: ['NewOwner(bytes32,bytes32,address)'],\n },\n },\n ],\n },\n },\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'Resolver',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleABIChanged',\n filter: {\n topics: ['ABIChanged(bytes32,uint256)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAddrChanged',\n filter: {\n topics: ['AddrChanged(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleMulticoinAddrChanged',\n filter: {\n topics: ['AddressChanged(bytes32,uint256,bytes)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAuthorisationChanged',\n filter: {\n topics: ['AuthorisationChanged(bytes32,address,address,bool)'],\n },\n },\n ],\n },\n },\n ];\n\n const queryEntry = buildDictionaryV2QueryEntry(ds);\n // Total 7 handlers were given, 1 is duplicate\n expect(queryEntry.logs!.length).toBe(6);\n });\n\n it('should unique QueryEntry for duplicate dataSources', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleLogSame',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n {\n handler: 'handleTxSame',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n transactions: [\n {\n from: ['mockaddress'],\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('should group a small number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 10; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ds);\n\n expect(result).toEqual({\n logs: [\n {\n address: [\n '0x0',\n '0x1',\n '0x2',\n '0x3',\n '0x4',\n '0x5',\n '0x6',\n '0x7',\n '0x8',\n '0x9',\n ],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('should remove address filter with large number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 200; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ds);\n\n expect(result).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('builds a filter when theres a block handler with modulo filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleBlock',\n kind: EthereumHandlerKind.Block,\n filter: {\n modulo: 100,\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
5
  if (k2 === undefined) k2 = k;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;AAEnC,oDAAkC;AAClC,0CAAwB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nexport * from './ethDictionaryV2';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;AAEnC,oDAAkC;AAClC,0CAAwB","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nexport * from './ethDictionaryV2';\nexport * from './types';\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/types.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { DictionaryV2QueryEntry } from '@subql/node-core';\n\nexport interface RawEthBlock {\n header: {\n parentHash: string;\n sha3Uncles: string;\n miner: string;\n stateRoot: string;\n transactionRoot: string;\n receiptsRoot: string;\n logsBloom: string;\n difficulty: bigint;\n number: bigint;\n gasLimit: bigint;\n gasUsed: bigint;\n timestamp: bigint;\n extraData: string;\n mixHash: string;\n nonce: string;\n baseFeePerGas: bigint;\n withdrawalsRoot: string;\n blobGasUsed: bigint;\n excessBlobGas: bigint;\n parentBeaconBlockRoot: string;\n hash: string;\n };\n transactions: RawEthTransaction[];\n logs: RawEthLog[];\n}\n\nexport interface RawEthTransaction {\n type: string;\n nonce: bigint;\n to: string;\n gas: bigint;\n gasPrice: bigint;\n maxPriorityFeePerGas: bigint;\n maxFeePerGas: bigint;\n value: bigint;\n v: bigint;\n r: string;\n s: string;\n input: string;\n hash: string;\n from: string;\n func: string;\n gasLimit: bigint;\n}\n\nexport interface RawEthLog {\n address: string;\n topics: string[];\n data: string;\n blockNumber: bigint;\n transactionHash: string;\n transactionIndex: bigint;\n blockHash: string;\n logIndex: bigint;\n removed: boolean;\n}\n\n/**\n * Eth dictionary RPC request filter conditions\n */\nexport interface EthDictionaryV2QueryEntry extends DictionaryV2QueryEntry {\n logs?: EthDictionaryLogConditions[];\n transactions?: EthDictionaryTxConditions[];\n}\n\nexport interface EthDictionaryLogConditions {\n address?: string[];\n topics0?: string[];\n topics1?: string[];\n topics2?: string[];\n}\n\nexport interface EthDictionaryTxConditions {\n to?: (string | null)[];\n from?: string[];\n data?: string[];\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/types.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { DictionaryV2QueryEntry } from '@subql/node-core';\n\nexport interface RawEthBlock {\n header: {\n parentHash: string;\n sha3Uncles: string;\n miner: string;\n stateRoot: string;\n transactionRoot: string;\n receiptsRoot: string;\n logsBloom: string;\n difficulty: bigint;\n number: bigint;\n gasLimit: bigint;\n gasUsed: bigint;\n timestamp: bigint;\n extraData: string;\n mixHash: string;\n nonce: string;\n baseFeePerGas: bigint;\n withdrawalsRoot: string;\n blobGasUsed: bigint;\n excessBlobGas: bigint;\n parentBeaconBlockRoot: string;\n hash: string;\n };\n transactions: RawEthTransaction[];\n logs: RawEthLog[];\n}\n\nexport interface RawEthTransaction {\n type: string;\n nonce: bigint;\n to: string;\n gas: bigint;\n gasPrice: bigint;\n maxPriorityFeePerGas: bigint;\n maxFeePerGas: bigint;\n value: bigint;\n v: bigint;\n r: string;\n s: string;\n input: string;\n hash: string;\n from: string;\n func: string;\n gasLimit: bigint;\n}\n\nexport interface RawEthLog {\n address: string;\n topics: string[];\n data: string;\n blockNumber: bigint;\n transactionHash: string;\n transactionIndex: bigint;\n blockHash: string;\n logIndex: bigint;\n removed: boolean;\n}\n\n/**\n * Eth dictionary RPC request filter conditions\n */\nexport interface EthDictionaryV2QueryEntry extends DictionaryV2QueryEntry {\n logs?: EthDictionaryLogConditions[];\n transactions?: EthDictionaryTxConditions[];\n}\n\nexport interface EthDictionaryLogConditions {\n address?: string[];\n topics0?: string[];\n topics1?: string[];\n topics2?: string[];\n}\n\nexport interface EthDictionaryTxConditions {\n to?: (string | null)[];\n from?: string[];\n data?: string[];\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.rawBlockToEthBlock = rawBlockToEthBlock;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/utils.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAenC,gDA8BC;AA3CD,wDAAqD;AAIrD,qEAM0C;AAG1C,SAAgB,kBAAkB,CAChC,KAAkB,EAClB,GAAgB;IAEhB,IAAI,CAAC;QACH,gFAAgF;QAChF,MAAM,SAAS,GAAG,GAAG,EAAE,GAAG,CAAC,SAAS,IAAI,IAAI,qBAAS,EAAE,CAAC;QAExD,MAAM,QAAQ,GAAG,IAAA,4BAAW,EAAC;YAC3B,GAAG,KAAK,CAAC,MAAM;YACf,YAAY,EAAE,EAAE;SACjB,CAAC,CAAC;QAEH,QAAQ,CAAC,IAAI,GAAG,qBAAS,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CACpE,KAAK,CAAC,IAAI,IAAI,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,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC9D,GAAG,IAAA,kCAAiB,EAAC,EAAE,EAAE,QAAQ,CAAC;YAClC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,KAAK,EAAE,CAAC,IAAI,CAAC;YAChE,OAAO,EAAE,GAA0C,EAAE,CACnD,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,8BAAa,EAAI,CAAC,CAAC,CAAC;SACtE,CAAC,CAAC,CAAC;QAEJ,OAAO,IAAA,gCAAe,EAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,4CAA4C,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,CAC/E,CAAC;IACJ,CAAC;AACH,CAAC","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.getTransactionReceipt(tx.hash).then((r) => formatReceipt<R>(r)),\n }));\n\n return formatBlockUtil(ethBlock);\n } catch (e: any) {\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","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/utils.ts"],"names":[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CAAC;QAChB,MAAM,IAAI,KAAK,CACb,4CAA4C,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,CAC/E,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2020-2025 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.getTransactionReceipt(tx.hash).then((r) => formatReceipt<R>(r)),\n }));\n\n return formatBlockUtil(ethBlock);\n } catch (e: any) {\n throw new Error(\n `Convert raw block to Eth block failed at ${block.header.number},${e.message}`,\n );\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -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,+CAA+C,CAAC;AACvE,MAAM,OAAO,GAAG,8CAA8C,CAAC;AAE/D,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,MAAM,EAAE;gBACN;oBACE,SAAS,EAAE,UAAU;oBACrB,OAAO,EAAE,UAAU;oBACnB,KAAK,EAAE,KAAK;oBACZ,WAAW,EAAE;wBACX,IAAI,EAAE;4BACJ;gCACE,OAAO,EAAE,CAAC,4CAA4C,CAAC;gCACvD,OAAO,EAAE;oCACP,oEAAoE;iCACrE;6BACF;yBACF;qBACF;oBACD,aAAa,EAAE;wBACb,WAAW,EAAE,IAAI;wBACjB,IAAI,EAAE;4BACJ,WAAW,EAAE,IAAI;yBAClB;wBACD,YAAY,EAAE;4BACZ,GAAG,EAAE,IAAI;yBACV;qBACF;iBACF;aACF;SACF,CAAC;KACH,CAAC,CAAC;IAEH,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,MAAM,GAAG,GAAG,IAAI,sBAAW,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,uBAAa,EAAE,CAAC,CAAC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,CAAC;QACtE,CAAC;QAED,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;YAC1C,oEAAoE;YACpE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,EAAS,CAAC;YACnE,MAAM,EACJ,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,EAAE,EACX,MAAM,EAAE,EAAE,EACV,GAAG,SAAS,EACb,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAQ,CAAC;YAEpE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;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 = 'https://ethereum.node.subquery.network/public';\nconst RPC_URL = 'https://ethereum.rpc.subquery.network/public';\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 converts 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"]}
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,+CAA+C,CAAC;AACvE,MAAM,OAAO,GAAG,8CAA8C,CAAC;AAE/D,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,MAAM,EAAE;gBACN;oBACE,SAAS,EAAE,UAAU;oBACrB,OAAO,EAAE,UAAU;oBACnB,KAAK,EAAE,KAAK;oBACZ,WAAW,EAAE;wBACX,IAAI,EAAE;4BACJ;gCACE,OAAO,EAAE,CAAC,4CAA4C,CAAC;gCACvD,OAAO,EAAE;oCACP,oEAAoE;iCACrE;6BACF;yBACF;qBACF;oBACD,aAAa,EAAE;wBACb,WAAW,EAAE,IAAI;wBACjB,IAAI,EAAE;4BACJ,WAAW,EAAE,IAAI;yBAClB;wBACD,YAAY,EAAE;4BACZ,GAAG,EAAE,IAAI;yBACV;qBACF;iBACF;aACF;SACF,CAAC;KACH,CAAC,CAAC;IAEH,OAAO,CAAC,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,EACT,WAAW,EAAE,EAAE,EACf,GAAG,UAAU,EACd,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;QACtE,CAAC;QAED,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;YAC1C,oEAAoE;YACpE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,EAAS,CAAC;YACnE,MAAM,EACJ,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,EAAE,EACX,MAAM,EAAE,EAAE,EACV,GAAG,SAAS,EACb,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAQ,CAAC;YAEpE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;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-2025 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 = 'https://ethereum.node.subquery.network/public';\nconst RPC_URL = 'https://ethereum.rpc.subquery.network/public';\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 converts 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"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1 +1 @@
1
- {"version":3,"file":"ds-processor.service.js","sourceRoot":"","sources":["../../src/indexer/ds-processor.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;AAEnC,2CAA4C;AAC5C,4DAKgC;AAChC,gDAA0D;AAGnD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,kCAIvC;IACW,UAAU,GAAG,4BAAU,CAAC;CACnC,CAAA;AANY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAM9B","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Injectable } from '@nestjs/common';\nimport {\n isCustomDs,\n SubqlEthereumCustomDataSource,\n SubqlEthereumDataSource,\n SubqlDatasourceProcessor,\n} from '@subql/common-ethereum';\nimport { BaseDsProcessorService } from '@subql/node-core';\n\n@Injectable()\nexport class DsProcessorService extends BaseDsProcessorService<\n SubqlEthereumDataSource,\n SubqlEthereumCustomDataSource<string>,\n SubqlDatasourceProcessor<string, Record<string, unknown>>\n> {\n protected isCustomDs = isCustomDs;\n}\n"]}
1
+ {"version":3,"file":"ds-processor.service.js","sourceRoot":"","sources":["../../src/indexer/ds-processor.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;AAEnC,2CAA4C;AAC5C,4DAKgC;AAChC,gDAA0D;AAGnD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,kCAIvC;IACW,UAAU,GAAG,4BAAU,CAAC;CACnC,CAAA;AANY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAM9B","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Injectable } from '@nestjs/common';\nimport {\n isCustomDs,\n SubqlEthereumCustomDataSource,\n SubqlEthereumDataSource,\n SubqlDatasourceProcessor,\n} from '@subql/common-ethereum';\nimport { BaseDsProcessorService } from '@subql/node-core';\n\n@Injectable()\nexport class DsProcessorService extends BaseDsProcessorService<\n SubqlEthereumDataSource,\n SubqlEthereumCustomDataSource<string>,\n SubqlDatasourceProcessor<string, Record<string, unknown>>\n> {\n protected isCustomDs = isCustomDs;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-ds.service.js","sourceRoot":"","sources":["../../src/indexer/dynamic-ds.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,4DAIgC;AAChC,gDAG0B;AAC1B,yDAAiD;AACjD,qDAA+C;AAK/C,iEAA4D;AAGrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,4BAGrC;IAEoB;IADnB,YACmB,kBAAsC,EAC3B,OAAwB;QAEpD,KAAK,CAAC,OAAO,CAAC,CAAC;QAHE,uBAAkB,GAAlB,kBAAkB,CAAoB;IAIzD,CAAC;IAES,KAAK,CAAC,aAAa,CAC3B,MAAwB;QAExB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAC5B,MAAM,CAAC,YAAY,EACnB,MAAM,CAAC,UAAU,CAClB,CAAC;QAEF,IAAI,CAAC;YACH,IAAI,IAAA,4BAAU,EAAC,KAAK,CAAC,EAAE,CAAC;gBACtB,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG;oBACxB,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO;oBAC1B,GAAG,MAAM,CAAC,IAAI;iBACf,CAAC;gBACF,MAAM,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1D,CAAC;iBAAM,IAAI,IAAA,6BAAW,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,KAAK,CAAC,OAAO,GAAG;oBACd,GAAG,KAAK,CAAC,OAAO;oBAChB,GAAG,MAAM,CAAC,IAAI;iBACf,CAAC;gBAEF,MAAM,QAAQ,GAAG,IAAA,gCAAY,EAAC,+CAA6B,EAAE,KAAK,CAAC,CAAC;gBAEpE,MAAM,MAAM,GAAG,IAAA,8BAAY,EAAC,QAAQ,EAAE;oBACpC,SAAS,EAAE,IAAI;oBACf,oBAAoB,EAAE,KAAK;iBAC5B,CAAC,CAAC;gBACH,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;oBAClB,MAAM,IAAI,KAAK,CACb,0BAA0B,MAAM;yBAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;yBACxB,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CACF,CAAA;AAnDY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCADU,yCAAkB;GAL9C,gBAAgB,CAmD5B","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport {\n EthereumRuntimeDataSourceImpl,\n isCustomDs,\n isRuntimeDs,\n} from '@subql/common-ethereum';\nimport {\n DatasourceParams,\n DynamicDsService as BaseDynamicDsService,\n} from '@subql/node-core';\nimport { plainToClass } from 'class-transformer';\nimport { validateSync } from 'class-validator';\nimport {\n EthereumProjectDs,\n SubqueryProject,\n} from '../configure/SubqueryProject';\nimport { DsProcessorService } from './ds-processor.service';\n\n@Injectable()\nexport class DynamicDsService extends BaseDynamicDsService<\n EthereumProjectDs,\n SubqueryProject\n> {\n constructor(\n private readonly dsProcessorService: DsProcessorService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n ) {\n super(project);\n }\n\n protected async getDatasource(\n params: DatasourceParams,\n ): Promise<EthereumProjectDs> {\n const dsObj = this.getTemplate<EthereumProjectDs>(\n params.templateName,\n params.startBlock,\n );\n\n try {\n if (isCustomDs(dsObj)) {\n dsObj.processor.options = {\n ...dsObj.processor.options,\n ...params.args,\n };\n await this.dsProcessorService.validateCustomDs([dsObj]);\n } else if (isRuntimeDs(dsObj)) {\n dsObj.options = {\n ...dsObj.options,\n ...params.args,\n };\n\n const parsedDs = plainToClass(EthereumRuntimeDataSourceImpl, dsObj);\n\n const errors = validateSync(parsedDs, {\n whitelist: true,\n forbidNonWhitelisted: false,\n });\n if (errors.length) {\n throw new Error(\n `Dynamic ds is invalid\\n${errors\n .map((e) => e.toString())\n .join('\\n')}`,\n );\n }\n }\n return dsObj;\n } catch (e: any) {\n throw new Error(`Unable to create dynamic datasource.\\n ${e.message}`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"dynamic-ds.service.js","sourceRoot":"","sources":["../../src/indexer/dynamic-ds.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AACpD,4DAIgC;AAChC,gDAG0B;AAC1B,yDAAiD;AACjD,qDAA+C;AAK/C,iEAA4D;AAGrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,4BAGrC;IAEoB;IADnB,YACmB,kBAAsC,EAC3B,OAAwB;QAEpD,KAAK,CAAC,OAAO,CAAC,CAAC;QAHE,uBAAkB,GAAlB,kBAAkB,CAAoB;IAIzD,CAAC;IAES,KAAK,CAAC,aAAa,CAC3B,MAAwB;QAExB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAC5B,MAAM,CAAC,YAAY,EACnB,MAAM,CAAC,UAAU,CAClB,CAAC;QAEF,IAAI,CAAC;YACH,IAAI,IAAA,4BAAU,EAAC,KAAK,CAAC,EAAE,CAAC;gBACtB,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG;oBACxB,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO;oBAC1B,GAAG,MAAM,CAAC,IAAI;iBACf,CAAC;gBACF,MAAM,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1D,CAAC;iBAAM,IAAI,IAAA,6BAAW,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,KAAK,CAAC,OAAO,GAAG;oBACd,GAAG,KAAK,CAAC,OAAO;oBAChB,GAAG,MAAM,CAAC,IAAI;iBACf,CAAC;gBAEF,MAAM,QAAQ,GAAG,IAAA,gCAAY,EAAC,+CAA6B,EAAE,KAAK,CAAC,CAAC;gBAEpE,MAAM,MAAM,GAAG,IAAA,8BAAY,EAAC,QAAQ,EAAE;oBACpC,SAAS,EAAE,IAAI;oBACf,oBAAoB,EAAE,KAAK;iBAC5B,CAAC,CAAC;gBACH,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;oBAClB,MAAM,IAAI,KAAK,CACb,0BAA0B,MAAM;yBAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;yBACxB,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CACF,CAAA;AAnDY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCADU,yCAAkB;GAL9C,gBAAgB,CAmD5B","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport {\n EthereumRuntimeDataSourceImpl,\n isCustomDs,\n isRuntimeDs,\n} from '@subql/common-ethereum';\nimport {\n DatasourceParams,\n DynamicDsService as BaseDynamicDsService,\n} from '@subql/node-core';\nimport { plainToClass } from 'class-transformer';\nimport { validateSync } from 'class-validator';\nimport {\n EthereumProjectDs,\n SubqueryProject,\n} from '../configure/SubqueryProject';\nimport { DsProcessorService } from './ds-processor.service';\n\n@Injectable()\nexport class DynamicDsService extends BaseDynamicDsService<\n EthereumProjectDs,\n SubqueryProject\n> {\n constructor(\n private readonly dsProcessorService: DsProcessorService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n ) {\n super(project);\n }\n\n protected async getDatasource(\n params: DatasourceParams,\n ): Promise<EthereumProjectDs> {\n const dsObj = this.getTemplate<EthereumProjectDs>(\n params.templateName,\n params.startBlock,\n );\n\n try {\n if (isCustomDs(dsObj)) {\n dsObj.processor.options = {\n ...dsObj.processor.options,\n ...params.args,\n };\n await this.dsProcessorService.validateCustomDs([dsObj]);\n } else if (isRuntimeDs(dsObj)) {\n dsObj.options = {\n ...dsObj.options,\n ...params.args,\n };\n\n const parsedDs = plainToClass(EthereumRuntimeDataSourceImpl, dsObj);\n\n const errors = validateSync(parsedDs, {\n whitelist: true,\n forbidNonWhitelisted: false,\n });\n if (errors.length) {\n throw new Error(\n `Dynamic ds is invalid\\n${errors\n .map((e) => e.toString())\n .join('\\n')}`,\n );\n }\n }\n return dsObj;\n } catch (e: any) {\n throw new Error(`Unable to create dynamic datasource.\\n ${e.message}`);\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
2
+ // Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
3
3
  // SPDX-License-Identifier: GPL-3.0
4
4
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;