@subql/node-ethereum 1.10.1-2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/README.md +3 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/configure/SubqueryProject.d.ts +9 -11
- package/dist/configure/SubqueryProject.js +19 -9
- package/dist/configure/SubqueryProject.js.map +1 -1
- package/dist/configure/configure.module.js +5 -7
- package/dist/configure/configure.module.js.map +1 -1
- package/dist/ethereum/api.connection.d.ts +11 -0
- package/dist/ethereum/api.connection.js +27 -0
- package/dist/ethereum/api.connection.js.map +1 -0
- package/dist/ethereum/api.ethereum.d.ts +18 -5
- package/dist/ethereum/api.ethereum.js +138 -81
- package/dist/ethereum/api.ethereum.js.map +1 -1
- package/dist/ethereum/api.service.ethereum.d.ts +11 -3
- package/dist/ethereum/api.service.ethereum.js +68 -18
- package/dist/ethereum/api.service.ethereum.js.map +1 -1
- package/dist/ethereum/api.service.ethereum.test.d.ts +1 -0
- package/dist/ethereum/api.service.ethereum.test.js +73 -0
- package/dist/ethereum/api.service.ethereum.test.js.map +1 -0
- package/dist/ethereum/block.ethereum.d.ts +1 -1
- package/dist/ethereum/block.ethereum.js +10 -12
- package/dist/ethereum/block.ethereum.js.map +1 -1
- package/dist/ethereum/ethers/json-rpc-batch-provider.d.ts +21 -0
- package/dist/ethereum/ethers/json-rpc-batch-provider.js +114 -0
- package/dist/ethereum/ethers/json-rpc-batch-provider.js.map +1 -0
- package/dist/ethereum/ethers/json-rpc-provider.d.ts +7 -0
- package/dist/ethereum/ethers/json-rpc-provider.js +68 -0
- package/dist/ethereum/ethers/json-rpc-provider.js.map +1 -0
- package/dist/ethereum/ethers/web/_version.d.ts +1 -0
- package/dist/ethereum/ethers/web/_version.js +6 -0
- package/dist/ethereum/ethers/web/_version.js.map +1 -0
- package/dist/ethereum/ethers/web/geturl.d.ts +3 -0
- package/dist/ethereum/ethers/web/geturl.js +116 -0
- package/dist/ethereum/ethers/web/geturl.js.map +1 -0
- package/dist/ethereum/ethers/web/index.d.ts +49 -0
- package/dist/ethereum/ethers/web/index.js +437 -0
- package/dist/ethereum/ethers/web/index.js.map +1 -0
- package/dist/ethereum/ethers/web/types.d.ts +26 -0
- package/dist/ethereum/ethers/web/types.js +4 -0
- package/dist/ethereum/ethers/web/types.js.map +1 -0
- package/dist/ethereum/safe-api.d.ts +34 -0
- package/dist/ethereum/safe-api.js +114 -0
- package/dist/ethereum/safe-api.js.map +1 -0
- package/dist/ethereum/utils.ethereum.d.ts +1 -1
- package/dist/ethereum/utils.ethereum.js +22 -87
- package/dist/ethereum/utils.ethereum.js.map +1 -1
- package/dist/indexer/blockDispatcher/block-dispatcher.service.d.ts +17 -0
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js +55 -0
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -0
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.d.ts +4 -0
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js +5 -0
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js.map +1 -0
- package/dist/indexer/blockDispatcher/index.d.ts +4 -0
- package/dist/indexer/blockDispatcher/index.js +10 -0
- package/dist/indexer/blockDispatcher/index.js.map +1 -0
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.d.ts +15 -0
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +88 -0
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -0
- package/dist/indexer/dictionary.service.d.ts +1 -0
- package/dist/indexer/dictionary.service.js +22 -2
- package/dist/indexer/dictionary.service.js.map +1 -1
- package/dist/indexer/ds-processor.service.d.ts +1 -1
- package/dist/indexer/ds-processor.service.js +4 -0
- package/dist/indexer/ds-processor.service.js.map +1 -1
- package/dist/indexer/dynamic-ds.service.d.ts +3 -19
- package/dist/indexer/dynamic-ds.service.js +20 -72
- package/dist/indexer/dynamic-ds.service.js.map +1 -1
- package/dist/indexer/fetch.module.js +40 -12
- package/dist/indexer/fetch.module.js.map +1 -1
- package/dist/indexer/fetch.service.d.ts +16 -7
- package/dist/indexer/fetch.service.js +188 -78
- package/dist/indexer/fetch.service.js.map +1 -1
- package/dist/indexer/indexer.manager.d.ts +11 -17
- package/dist/indexer/indexer.manager.js +68 -71
- package/dist/indexer/indexer.manager.js.map +1 -1
- package/dist/indexer/indexer.module.js +32 -8
- package/dist/indexer/indexer.module.js.map +1 -1
- package/dist/indexer/project.service.d.ts +11 -8
- package/dist/indexer/project.service.js +76 -82
- package/dist/indexer/project.service.js.map +1 -1
- package/dist/indexer/sandbox.service.js +11 -2
- package/dist/indexer/sandbox.service.js.map +1 -1
- package/dist/indexer/types.d.ts +2 -1
- package/dist/indexer/types.js.map +1 -1
- package/dist/indexer/unfinalizedBlocks.service.d.ts +36 -0
- package/dist/indexer/unfinalizedBlocks.service.js +197 -0
- package/dist/indexer/unfinalizedBlocks.service.js.map +1 -0
- package/dist/indexer/unfinalizedBlocks.spec.d.ts +1 -0
- package/dist/indexer/unfinalizedBlocks.spec.js +195 -0
- package/dist/indexer/unfinalizedBlocks.spec.js.map +1 -0
- package/dist/indexer/worker/worker.d.ts +22 -6
- package/dist/indexer/worker/worker.js +16 -3
- package/dist/indexer/worker/worker.js.map +1 -1
- package/dist/indexer/worker/worker.service.d.ts +10 -6
- package/dist/indexer/worker/worker.service.js +23 -10
- package/dist/indexer/worker/worker.service.js.map +1 -1
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.d.ts +11 -0
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js +32 -0
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js.map +1 -0
- package/dist/init.js +2 -2
- package/dist/init.js.map +1 -1
- package/dist/main.js +6 -1
- package/dist/main.js.map +1 -1
- package/dist/meta/meta.module.js +8 -0
- package/dist/meta/meta.module.js.map +1 -1
- package/dist/meta/meta.service.d.ts +18 -3
- package/dist/meta/meta.service.js +89 -5
- package/dist/meta/meta.service.js.map +1 -1
- package/dist/subcommands/forceClean.service.d.ts +3 -1
- package/dist/subcommands/forceClean.service.js +30 -6
- package/dist/subcommands/forceClean.service.js.map +1 -1
- package/dist/subcommands/reindex.init.js +6 -1
- package/dist/subcommands/reindex.init.js.map +1 -1
- package/dist/subcommands/reindex.module.js +20 -1
- package/dist/subcommands/reindex.module.js.map +1 -1
- package/dist/subcommands/reindex.service.d.ts +7 -3
- package/dist/subcommands/reindex.service.js +44 -50
- package/dist/subcommands/reindex.service.js.map +1 -1
- package/dist/subcommands/testing.init.d.ts +1 -0
- package/dist/subcommands/testing.init.js +34 -0
- package/dist/subcommands/testing.init.js.map +1 -0
- package/dist/subcommands/testing.module.d.ts +4 -0
- package/dist/subcommands/testing.module.js +77 -0
- package/dist/subcommands/testing.module.js.map +1 -0
- package/dist/subcommands/testing.service.d.ts +9 -0
- package/dist/subcommands/testing.service.js +43 -0
- package/dist/subcommands/testing.service.js.map +1 -0
- package/dist/utils/project.d.ts +3 -0
- package/dist/utils/project.js +45 -1
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/reindex.d.ts +6 -0
- package/dist/utils/reindex.js +48 -0
- package/dist/utils/reindex.js.map +1 -0
- package/dist/utils/string.js +10 -2
- package/dist/utils/string.js.map +1 -1
- package/dist/yargs.d.ts +97 -49
- package/dist/yargs.js +130 -69
- package/dist/yargs.js.map +1 -1
- package/package.json +13 -12
- package/dist/indexer/worker/block-dispatcher.service.d.ts +0 -69
- package/dist/indexer/worker/block-dispatcher.service.js +0 -356
- package/dist/indexer/worker/block-dispatcher.service.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;AAEtC,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,0CAA8E;AAC9E,4DAYgC;AAEhC,wCAAuD;AACvD,sD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eAAe;IACf,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9D,IAAI,WAAW,KAAK,SAAS,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,cAAc,KAAK,2BAA2B,CAAC,CAAC;KACjE;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AArBD,oDAqBC;AAED,KAAK,UAAU,WAAW;IACxB,MAAM,GAAG,GAAG,cAAI,CAAC,GAAG,CAAC;IACrB,MAAM,MAAM,GAAG,YAAE,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,YAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC;AAChD,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,MAAc;IACjD,IAAI,MAAM,YAAY,oBAAW;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IACtD,IAAI,MAAM,YAAY,mBAAU,IAAI,MAAM,YAAY,qBAAY,EAAE;QAClE,OAAO,WAAW,EAAE,CAAC;KACtB;AACH,CAAC;AALD,wCAKC;AAEM,KAAK,UAAU,YAAY,CAChC,OAAwB,EACxB,MAAc,EACd,YAA0B;IAE1B,MAAM,cAAc,GAAG,IAAA,+BAAuB,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D,MAAM,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AAPD,oCAOC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport { GithubReader, IPFSReader, LocalReader, Reader } from '@subql/common';\nimport {\n ChainTypes,\n CustomDatasourceV0_2_0,\n isCustomDs,\n loadChainTypes,\n loadChainTypesFromJs,\n parseChainTypes,\n RuntimeDataSourceV0_2_0,\n SubqlRuntimeHandler,\n SubqlCustomHandler,\n SubqlHandler,\n EthereumHandlerKind,\n} from '@subql/common-ethereum';\nimport { StoreService } from '@subql/node-core';\nimport { getAllEntitiesRelations } from '@subql/utils';\nimport yaml from 'js-yaml';\nimport tar from 'tar';\nimport { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject';\n\nexport async function prepareProjectDir(projectPath: string): Promise<string> {\n const stats = fs.statSync(projectPath);\n if (stats.isFile()) {\n const sep = path.sep;\n const tmpDir = os.tmpdir();\n const tempPath = fs.mkdtempSync(`${tmpDir}${sep}`);\n // Will promote errors if incorrect format/extension\n await tar.x({ file: projectPath, cwd: tempPath });\n return tempPath.concat('/package');\n } else if (stats.isDirectory()) {\n return projectPath;\n }\n}\n\n// We cache this to avoid repeated reads from fs\nconst projectEntryCache: Record<string, string> = {};\n\nexport function getProjectEntry(root: string): string {\n const pkgPath = path.join(root, 'package.json');\n try {\n if (!projectEntryCache[pkgPath]) {\n const content = fs.readFileSync(pkgPath).toString();\n const pkg = JSON.parse(content);\n if (!pkg.main) {\n return './dist';\n }\n projectEntryCache[pkgPath] = pkg.main.startsWith('./')\n ? pkg.main\n : `./${pkg.main}`;\n }\n\n return projectEntryCache[pkgPath];\n } catch (err) {\n throw new Error(`can not find package.json within directory ${root}`);\n }\n}\n\nexport function isBaseHandler(\n handler: SubqlHandler,\n): handler is SubqlRuntimeHandler {\n return Object.values<string>(EthereumHandlerKind).includes(handler.kind);\n}\n\nexport function isCustomHandler(\n handler: SubqlHandler,\n): handler is SubqlCustomHandler {\n return !isBaseHandler(handler);\n}\n\nexport async function updateDataSourcesV0_2_0(\n _dataSources: (RuntimeDataSourceV0_2_0 | CustomDatasourceV0_2_0)[],\n reader: Reader,\n root: string,\n): Promise<SubqlProjectDs[]> {\n // force convert to updated ds\n return Promise.all(\n _dataSources.map(async (dataSource) => {\n const entryScript = await loadDataSourceScript(\n reader,\n dataSource.mapping.file,\n );\n const file = await updateDataSourcesEntry(\n reader,\n dataSource.mapping.file,\n root,\n entryScript,\n );\n if (dataSource.assets) {\n for (const [, asset] of Object.entries(dataSource.assets)) {\n if (reader instanceof LocalReader) {\n asset.file = path.resolve(root, asset.file);\n } else {\n const res = await reader.getFile(asset.file);\n const outputPath = path.resolve(\n root,\n asset.file.replace('ipfs://', ''),\n );\n await fs.promises.writeFile(outputPath, res as string);\n asset.file = outputPath;\n }\n }\n }\n if (isCustomDs(dataSource)) {\n if (dataSource.processor) {\n dataSource.processor.file = await updateProcessor(\n reader,\n root,\n dataSource.processor.file,\n );\n }\n if (dataSource.assets) {\n for (const [, asset] of dataSource.assets) {\n if (reader instanceof LocalReader) {\n asset.file = path.resolve(root, asset.file);\n } else {\n const res = await reader.getFile(asset.file);\n const outputPath = path.resolve(\n root,\n asset.file.replace('ipfs://', ''),\n );\n await fs.promises.writeFile(outputPath, res as string);\n asset.file = outputPath;\n }\n }\n }\n return {\n ...dataSource,\n mapping: { ...dataSource.mapping, entryScript, file },\n };\n } else {\n return {\n ...dataSource,\n mapping: { ...dataSource.mapping, entryScript, file },\n };\n }\n }),\n );\n}\n\nasync function updateDataSourcesEntry(\n reader: Reader,\n file: string,\n root: string,\n script: string,\n): Promise<string> {\n if (reader instanceof LocalReader) return file;\n else if (reader instanceof IPFSReader || reader instanceof GithubReader) {\n const outputPath = `${path.resolve(root, file.replace('ipfs://', ''))}.js`;\n await fs.promises.writeFile(outputPath, script);\n return outputPath;\n }\n}\n\nasync function updateProcessor(\n reader: Reader,\n root: string,\n file: string,\n): Promise<string> {\n if (reader instanceof LocalReader) {\n return path.resolve(root, file);\n } else {\n const res = await reader.getFile(file);\n const outputPath = `${path.resolve(root, file.replace('ipfs://', ''))}.js`;\n await fs.promises.writeFile(outputPath, res);\n return outputPath;\n }\n}\n\nexport async function getChainTypes(\n reader: Reader,\n root: string,\n file: string,\n): Promise<ChainTypes> {\n // If the project is load from local, we will direct load them\n if (reader instanceof LocalReader) {\n return loadChainTypes(file, root);\n } else {\n // If it is stored in ipfs or other resources, we will use the corresponding reader to read the file\n // Because ipfs not provide extension of the file, it is difficult to determine its format\n // We will use yaml.load to try to load the script and parse them to supported chain types\n // if it failed, we will give it another another attempt, and assume the script written in js\n // we will download it to a temp folder, and load them within sandbox\n const res = await reader.getFile(file);\n let raw: unknown;\n try {\n raw = yaml.load(res);\n return parseChainTypes(raw);\n } catch (e) {\n const chainTypesPath = `${path.resolve(\n root,\n file.replace('ipfs://', ''),\n )}.js`;\n await fs.promises.writeFile(chainTypesPath, res);\n raw = loadChainTypesFromJs(chainTypesPath); //root not required, as it been packed in single js\n return parseChainTypes(raw);\n }\n }\n}\n\nexport async function loadDataSourceScript(\n reader: Reader,\n file?: string,\n): Promise<string> {\n let entry: string;\n //For RuntimeDataSourceV0_0_1\n if (!file) {\n const pkg = await reader.getPkg();\n if (pkg === undefined) throw new Error('Project package.json is not found');\n if (pkg.main) {\n entry = pkg.main.startsWith('./') ? pkg.main : `./${pkg.main}`;\n } else {\n entry = './dist';\n }\n }\n //Else get file\n const entryScript = await reader.getFile(file ? file : entry);\n if (entryScript === undefined) {\n throw new Error(`Entry file ${entry} for datasource not exist`);\n }\n return entryScript;\n}\n\nasync function makeTempDir(): Promise<string> {\n const sep = path.sep;\n const tmpDir = os.tmpdir();\n return fs.promises.mkdtemp(`${tmpDir}${sep}`);\n}\n\nexport async function getProjectRoot(reader: Reader): Promise<string> {\n if (reader instanceof LocalReader) return reader.root;\n if (reader instanceof IPFSReader || reader instanceof GithubReader) {\n return makeTempDir();\n }\n}\n\nexport async function initDbSchema(\n project: SubqueryProject,\n schema: string,\n storeService: StoreService,\n): Promise<void> {\n const modelsRelation = getAllEntitiesRelations(project.schema);\n await storeService.init(modelsRelation, schema);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;AAEtC,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,0CAA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AC;aACd;SACF;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAbD,sDAaC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport { GithubReader, IPFSReader, LocalReader, Reader } from '@subql/common';\nimport {\n ChainTypes,\n CustomDatasourceV0_2_0,\n isCustomDs,\n parseChainTypes,\n RuntimeDataSourceV0_2_0,\n SubqlRuntimeHandler,\n SubqlCustomHandler,\n SubqlHandler,\n EthereumHandlerKind,\n EthereumDatasourceKind,\n SubqlEthereumHandlerKind,\n loadChainTypesFromJs,\n loadChainTypes,\n} from '@subql/common-ethereum';\nimport { retryOnFail, StoreService } from '@subql/node-core';\nimport { getAllEntitiesRelations } from '@subql/utils';\nimport yaml from 'js-yaml';\nimport tar from 'tar';\nimport { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject';\n\nexport async function prepareProjectDir(projectPath: string): Promise<string> {\n const stats = fs.statSync(projectPath);\n if (stats.isFile()) {\n const sep = path.sep;\n const tmpDir = os.tmpdir();\n const tempPath = fs.mkdtempSync(`${tmpDir}${sep}`);\n // Will promote errors if incorrect format/extension\n await tar.x({ file: projectPath, cwd: tempPath });\n return tempPath.concat('/package');\n } else if (stats.isDirectory()) {\n return projectPath;\n }\n}\n\n// We cache this to avoid repeated reads from fs\nconst projectEntryCache: Record<string, string> = {};\n\nexport function getProjectEntry(root: string): string {\n const pkgPath = path.join(root, 'package.json');\n try {\n if (!projectEntryCache[pkgPath]) {\n const content = fs.readFileSync(pkgPath).toString();\n const pkg = JSON.parse(content);\n if (!pkg.main) {\n return './dist';\n }\n projectEntryCache[pkgPath] = pkg.main.startsWith('./')\n ? pkg.main\n : `./${pkg.main}`;\n }\n\n return projectEntryCache[pkgPath];\n } catch (err) {\n throw new Error(`can not find package.json within directory ${root}`);\n }\n}\n\nexport function isBaseHandler(\n handler: SubqlHandler,\n): handler is SubqlRuntimeHandler {\n return Object.values<string>(EthereumHandlerKind).includes(handler.kind);\n}\n\nexport function isCustomHandler(\n handler: SubqlHandler,\n): handler is SubqlCustomHandler {\n return !isBaseHandler(handler);\n}\n\nexport async function updateDataSourcesV0_2_0(\n _dataSources: (RuntimeDataSourceV0_2_0 | CustomDatasourceV0_2_0)[],\n reader: Reader,\n root: string,\n): Promise<SubqlProjectDs[]> {\n // force convert to updated ds\n return Promise.all(\n _dataSources.map(async (dataSource) => {\n if (dataSource.kind === 'flare/Runtime') {\n dataSource.kind = EthereumDatasourceKind.Runtime;\n }\n dataSource.mapping.handlers = dataSource.mapping.handlers.map(\n (handler) => {\n switch (handler.kind) {\n case 'flare/BlockHandler': {\n handler.kind = EthereumHandlerKind.Block;\n break;\n }\n case 'flare/TransactionHandler': {\n handler.kind = EthereumHandlerKind.Call;\n break;\n }\n case 'flare/LogHandler': {\n handler.kind = EthereumHandlerKind.Event;\n break;\n }\n default:\n }\n\n return handler;\n },\n );\n\n const entryScript = await loadDataSourceScript(\n reader,\n dataSource.mapping.file,\n );\n const file = await updateDataSourcesEntry(\n reader,\n dataSource.mapping.file,\n root,\n entryScript,\n );\n if (dataSource.assets) {\n for (const [, asset] of Object.entries(dataSource.assets)) {\n if (reader instanceof LocalReader) {\n asset.file = path.resolve(root, asset.file);\n } else {\n const res = await reader.getFile(asset.file);\n const outputPath = path.resolve(\n root,\n asset.file.replace('ipfs://', ''),\n );\n await fs.promises.writeFile(outputPath, res as string);\n asset.file = outputPath;\n }\n }\n }\n if (isCustomDs(dataSource)) {\n if (dataSource.processor) {\n dataSource.processor.file = await updateProcessor(\n reader,\n root,\n dataSource.processor.file,\n );\n }\n if (dataSource.assets) {\n for (const [, asset] of dataSource.assets) {\n if (reader instanceof LocalReader) {\n asset.file = path.resolve(root, asset.file);\n } else {\n const res = await reader.getFile(asset.file);\n const outputPath = path.resolve(\n root,\n asset.file.replace('ipfs://', ''),\n );\n await fs.promises.writeFile(outputPath, res as string);\n asset.file = outputPath;\n }\n }\n }\n return {\n ...dataSource,\n mapping: { ...dataSource.mapping, entryScript, file },\n };\n } else {\n return {\n ...dataSource,\n mapping: { ...dataSource.mapping, entryScript, file },\n };\n }\n }),\n );\n}\n\nasync function updateDataSourcesEntry(\n reader: Reader,\n file: string,\n root: string,\n script: string,\n): Promise<string> {\n if (reader instanceof LocalReader) return file;\n else if (reader instanceof IPFSReader || reader instanceof GithubReader) {\n const outputPath = `${path.resolve(root, file.replace('ipfs://', ''))}.js`;\n await fs.promises.writeFile(outputPath, script);\n return outputPath;\n }\n}\n\nasync function updateProcessor(\n reader: Reader,\n root: string,\n file: string,\n): Promise<string> {\n if (reader instanceof LocalReader) {\n return path.resolve(root, file);\n } else {\n const res = await reader.getFile(file);\n const outputPath = `${path.resolve(root, file.replace('ipfs://', ''))}.js`;\n await fs.promises.writeFile(outputPath, res);\n return outputPath;\n }\n}\n\nexport async function getChainTypes(\n reader: Reader,\n root: string,\n file: string,\n): Promise<ChainTypes> {\n // If the project is load from local, we will direct load them\n if (reader instanceof LocalReader) {\n return loadChainTypes(file, root);\n } else {\n // If it is stored in ipfs or other resources, we will use the corresponding reader to read the file\n // Because ipfs not provide extension of the file, it is difficult to determine its format\n // We will use yaml.load to try to load the script and parse them to supported chain types\n // if it failed, we will give it another another attempt, and assume the script written in js\n // we will download it to a temp folder, and load them within sandbox\n const res = await reader.getFile(file);\n let raw: unknown;\n try {\n raw = yaml.load(res);\n return parseChainTypes(raw);\n } catch (e) {\n const chainTypesPath = `${path.resolve(\n root,\n file.replace('ipfs://', ''),\n )}.js`;\n await fs.promises.writeFile(chainTypesPath, res);\n raw = loadChainTypesFromJs(chainTypesPath); //root not required, as it been packed in single js\n return parseChainTypes(raw);\n }\n }\n}\n\nexport async function loadDataSourceScript(\n reader: Reader,\n file?: string,\n): Promise<string> {\n let entry: string;\n //For RuntimeDataSourceV0_0_1\n if (!file) {\n const pkg = await reader.getPkg();\n if (pkg === undefined) throw new Error('Project package.json is not found');\n if (pkg.main) {\n entry = pkg.main.startsWith('./') ? pkg.main : `./${pkg.main}`;\n } else {\n entry = './dist';\n }\n }\n //Else get file\n const entryScript = await reader.getFile(file ? file : entry);\n if (entryScript === undefined) {\n throw new Error(`Entry file ${entry} for datasource not exist`);\n }\n return entryScript;\n}\n\nasync function makeTempDir(): Promise<string> {\n const sep = path.sep;\n const tmpDir = os.tmpdir();\n return fs.promises.mkdtemp(`${tmpDir}${sep}`);\n}\n\nexport async function getProjectRoot(reader: Reader): Promise<string> {\n if (reader instanceof LocalReader) return reader.root;\n if (reader instanceof IPFSReader || reader instanceof GithubReader) {\n return makeTempDir();\n }\n}\n\nexport async function initDbSchema(\n project: SubqueryProject,\n schema: string,\n storeService: StoreService,\n): Promise<void> {\n const modelsRelation = getAllEntitiesRelations(project.schema);\n await storeService.init(modelsRelation, schema);\n}\n\nexport async function initHotSchemaReload(\n schema: string,\n storeService: StoreService,\n): Promise<void> {\n await storeService.initHotSchemaReloadQueries(schema);\n}\n\nconst handledErrors = ['timeout'];\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function retryOnFailEth<T>(\n request: () => Promise<T>,\n errors = handledErrors,\n): Promise<T> {\n return retryOnFail(request, (e) => !!errors.find((t) => t === e?.reason));\n}\n\nexport function onlyHasLogDataSources(dataSources: SubqlProjectDs[]): boolean {\n for (const ds of dataSources) {\n for (const handler of ds.mapping.handlers) {\n if (\n handler.kind !== SubqlEthereumHandlerKind.EthEvent &&\n handler.kind !== SubqlEthereumHandlerKind.FlareEvent\n ) {\n return false;\n }\n }\n }\n\n return true;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MmrService, StoreService } from '@subql/node-core';
|
|
2
|
+
import { Sequelize } from 'sequelize';
|
|
3
|
+
import { DynamicDsService } from '../indexer/dynamic-ds.service';
|
|
4
|
+
import { UnfinalizedBlocksService } from '../indexer/unfinalizedBlocks.service';
|
|
5
|
+
import { ForceCleanService } from '../subcommands/forceClean.service';
|
|
6
|
+
export declare function reindex(startHeight: number, blockOffset: number | undefined, targetBlockHeight: number, lastProcessedHeight: number, storeService: StoreService, unfinalizedBlockService: UnfinalizedBlocksService, dynamicDsService: DynamicDsService, mmrService: MmrService, sequelize: Sequelize, forceCleanService?: ForceCleanService): Promise<void>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2020-2022 OnFinality Limited authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.reindex = void 0;
|
|
6
|
+
const node_core_1 = require("@subql/node-core");
|
|
7
|
+
const logger = (0, node_core_1.getLogger)('Reindex');
|
|
8
|
+
async function reindex(startHeight, blockOffset, targetBlockHeight, lastProcessedHeight, storeService, unfinalizedBlockService, dynamicDsService, mmrService, sequelize, forceCleanService) {
|
|
9
|
+
if (!lastProcessedHeight || lastProcessedHeight < targetBlockHeight) {
|
|
10
|
+
logger.warn(`Skipping reindexing to block ${targetBlockHeight}: current indexing height ${lastProcessedHeight} is behind requested block`);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
// if startHeight is greater than the targetHeight, just force clean
|
|
14
|
+
if (targetBlockHeight < startHeight) {
|
|
15
|
+
logger.info(`targetHeight: ${targetBlockHeight} is less than startHeight: ${startHeight}. Hence executing force-clean`);
|
|
16
|
+
if (!forceCleanService) {
|
|
17
|
+
logger.error('ForceCleanService not provided, cannot force clean');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
await forceCleanService.forceClean();
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
logger.info(`Reindexing to block: ${targetBlockHeight}`);
|
|
24
|
+
const transaction = await sequelize.transaction();
|
|
25
|
+
try {
|
|
26
|
+
await Promise.all([
|
|
27
|
+
storeService.rewind(targetBlockHeight, transaction),
|
|
28
|
+
unfinalizedBlockService.resetUnfinalizedBlocks(),
|
|
29
|
+
unfinalizedBlockService.resetLastFinalizedVerifiedHeight(),
|
|
30
|
+
dynamicDsService.resetDynamicDatasource(targetBlockHeight),
|
|
31
|
+
]);
|
|
32
|
+
if (blockOffset) {
|
|
33
|
+
await mmrService.deleteMmrNode(targetBlockHeight + 1, blockOffset);
|
|
34
|
+
}
|
|
35
|
+
// Flush metadata changes from above Promise.all
|
|
36
|
+
await storeService.storeCache.metadata.flush(transaction);
|
|
37
|
+
await transaction.commit();
|
|
38
|
+
logger.info('Reindex Success');
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
logger.error(err, 'Reindexing failed');
|
|
42
|
+
await transaction.rollback();
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.reindex = reindex;
|
|
48
|
+
//# sourceMappingURL=reindex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reindex.js","sourceRoot":"","sources":["../../src/utils/reindex.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;AAEtC,gDAAuE;AAMvE,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,SAAS,CAAC,CAAC;AAE7B,KAAK,UAAU,OAAO,CAC3B,WAAmB,EACnB,WAA+B,EAC/B,iBAAyB,EACzB,mBAA2B,EAC3B,YAA0B,EAC1B,uBAAiD,EACjD,gBAAkC,EAClC,UAAsB,EACtB,SAAoB,EACpB,iBAAqC;IAErC,IAAI,CAAC,mBAAmB,IAAI,mBAAmB,GAAG,iBAAiB,EAAE;QACnE,MAAM,CAAC,IAAI,CACT,gCAAgC,iBAAiB,6BAA6B,mBAAmB,4BAA4B,CAC9H,CAAC;QACF,OAAO;KACR;IAED,oEAAoE;IACpE,IAAI,iBAAiB,GAAG,WAAW,EAAE;QACnC,MAAM,CAAC,IAAI,CACT,iBAAiB,iBAAiB,8BAA8B,WAAW,+BAA+B,CAC3G,CAAC;QACF,IAAI,CAAC,iBAAiB,EAAE;YACtB,MAAM,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;YACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QACD,MAAM,iBAAiB,CAAC,UAAU,EAAE,CAAC;KACtC;SAAM;QACL,MAAM,CAAC,IAAI,CAAC,wBAAwB,iBAAiB,EAAE,CAAC,CAAC;QACzD,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC;QAClD,IAAI;YACF,MAAM,OAAO,CAAC,GAAG,CAAC;gBAChB,YAAY,CAAC,MAAM,CAAC,iBAAiB,EAAE,WAAW,CAAC;gBACnD,uBAAuB,CAAC,sBAAsB,EAAE;gBAChD,uBAAuB,CAAC,gCAAgC,EAAE;gBAC1D,gBAAgB,CAAC,sBAAsB,CAAC,iBAAiB,CAAC;aAC3D,CAAC,CAAC;YAEH,IAAI,WAAW,EAAE;gBACf,MAAM,UAAU,CAAC,aAAa,CAAC,iBAAiB,GAAG,CAAC,EAAE,WAAW,CAAC,CAAC;aACpE;YAED,gDAAgD;YAChD,MAAM,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAE1D,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;SAChC;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;YACvC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC7B,MAAM,GAAG,CAAC;SACX;KACF;AACH,CAAC;AAvDD,0BAuDC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getLogger, MmrService, StoreService } from '@subql/node-core';\nimport { Sequelize } from 'sequelize';\nimport { DynamicDsService } from '../indexer/dynamic-ds.service';\nimport { UnfinalizedBlocksService } from '../indexer/unfinalizedBlocks.service';\nimport { ForceCleanService } from '../subcommands/forceClean.service';\n\nconst logger = getLogger('Reindex');\n\nexport async function reindex(\n startHeight: number,\n blockOffset: number | undefined,\n targetBlockHeight: number,\n lastProcessedHeight: number,\n storeService: StoreService,\n unfinalizedBlockService: UnfinalizedBlocksService,\n dynamicDsService: DynamicDsService,\n mmrService: MmrService,\n sequelize: Sequelize,\n forceCleanService?: ForceCleanService,\n): Promise<void> {\n if (!lastProcessedHeight || lastProcessedHeight < targetBlockHeight) {\n logger.warn(\n `Skipping reindexing to block ${targetBlockHeight}: current indexing height ${lastProcessedHeight} is behind requested block`,\n );\n return;\n }\n\n // if startHeight is greater than the targetHeight, just force clean\n if (targetBlockHeight < startHeight) {\n logger.info(\n `targetHeight: ${targetBlockHeight} is less than startHeight: ${startHeight}. Hence executing force-clean`,\n );\n if (!forceCleanService) {\n logger.error('ForceCleanService not provided, cannot force clean');\n process.exit(1);\n }\n await forceCleanService.forceClean();\n } else {\n logger.info(`Reindexing to block: ${targetBlockHeight}`);\n const transaction = await sequelize.transaction();\n try {\n await Promise.all([\n storeService.rewind(targetBlockHeight, transaction),\n unfinalizedBlockService.resetUnfinalizedBlocks(),\n unfinalizedBlockService.resetLastFinalizedVerifiedHeight(),\n dynamicDsService.resetDynamicDatasource(targetBlockHeight),\n ]);\n\n if (blockOffset) {\n await mmrService.deleteMmrNode(targetBlockHeight + 1, blockOffset);\n }\n\n // Flush metadata changes from above Promise.all\n await storeService.storeCache.metadata.flush(transaction);\n\n await transaction.commit();\n logger.info('Reindex Success');\n } catch (err) {\n logger.error(err, 'Reindexing failed');\n await transaction.rollback();\n throw err;\n }\n }\n}\n"]}
|
package/dist/utils/string.js
CHANGED
|
@@ -17,16 +17,24 @@ function hexStringEq(a, b) {
|
|
|
17
17
|
return stringNormalizedEq((0, bytes_1.hexStripZeros)(a), (0, bytes_1.hexStripZeros)(b));
|
|
18
18
|
}
|
|
19
19
|
exports.hexStringEq = hexStringEq;
|
|
20
|
+
const eventTopicsCache = {};
|
|
21
|
+
const functionSighashCache = {};
|
|
20
22
|
function eventToTopic(input) {
|
|
21
23
|
if ((0, bytes_1.isHexString)(input))
|
|
22
24
|
return input;
|
|
23
|
-
|
|
25
|
+
if (!eventTopicsCache[input]) {
|
|
26
|
+
eventTopicsCache[input] = (0, hash_1.id)(abi_1.EventFragment.fromString(input).format());
|
|
27
|
+
}
|
|
28
|
+
return eventTopicsCache[input];
|
|
24
29
|
}
|
|
25
30
|
exports.eventToTopic = eventToTopic;
|
|
26
31
|
function functionToSighash(input) {
|
|
27
32
|
if ((0, bytes_1.isHexString)(input))
|
|
28
33
|
return input;
|
|
29
|
-
|
|
34
|
+
if (!functionSighashCache[input]) {
|
|
35
|
+
functionSighashCache[input] = (0, bytes_1.hexDataSlice)((0, hash_1.id)(abi_1.FunctionFragment.fromString(input).format()), 0, 4);
|
|
36
|
+
}
|
|
37
|
+
return functionSighashCache[input];
|
|
30
38
|
}
|
|
31
39
|
exports.functionToSighash = functionToSighash;
|
|
32
40
|
//# sourceMappingURL=string.js.map
|
package/dist/utils/string.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;AAEtC,4CAAqE;AACrE,gDAAgF;AAChF,8CAAyC;AAEzC,SAAgB,kBAAkB,CAAC,CAAS,EAAE,CAAS;IACrD,OAAO,CAAC,CAAC,WAAW,EAAE,MAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,WAAW,EAAE,CAAA,CAAC;AAC9C,CAAC;AAFD,gDAEC;AAED,SAAgB,WAAW,CAAC,CAAS,EAAE,CAAS;IAC9C,IAAI,CAAC,IAAA,mBAAW,EAAC,CAAC,CAAC,IAAI,CAAC,IAAA,mBAAW,EAAC,CAAC,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KAC/C;IACD,OAAO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;KACxE;IAED,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AARD,oCAQC;AAED,SAAgB,iBAAiB,CAAC,KAAa;IAC7C,IAAI,IAAA,mBAAW,EAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAErC,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE;QAChC,oBAAoB,CAAC,KAAK,CAAC,GAAG,IAAA,oBAAY,EACxC,IAAA,SAAE,EAAC,sBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,EAC/C,CAAC,EACD,CAAC,CACF,CAAC;KACH;IAED,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAZD,8CAYC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { EventFragment, FunctionFragment } from '@ethersproject/abi';\nimport { isHexString, hexStripZeros, hexDataSlice } from '@ethersproject/bytes';\nimport { id } from '@ethersproject/hash';\n\nexport function stringNormalizedEq(a: string, b: string): boolean {\n return a.toLowerCase() === b?.toLowerCase();\n}\n\nexport function hexStringEq(a: string, b: string): boolean {\n if (!isHexString(a) || !isHexString(b)) {\n throw new Error('Inputs are not hex strings');\n }\n return stringNormalizedEq(hexStripZeros(a), hexStripZeros(b));\n}\n\nconst eventTopicsCache: Record<string, string> = {};\nconst functionSighashCache: Record<string, string> = {};\n\nexport function eventToTopic(input: string): string {\n if (isHexString(input)) return input;\n\n if (!eventTopicsCache[input]) {\n eventTopicsCache[input] = id(EventFragment.fromString(input).format());\n }\n\n return eventTopicsCache[input];\n}\n\nexport function functionToSighash(input: string): string {\n if (isHexString(input)) return input;\n\n if (!functionSighashCache[input]) {\n functionSighashCache[input] = hexDataSlice(\n id(FunctionFragment.fromString(input).format()),\n 0,\n 4,\n );\n }\n\n return functionSighashCache[input];\n}\n"]}
|
package/dist/yargs.d.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
export declare const yargsOptions: import("yargs").Argv<import("yargs").Omit<{
|
|
2
2
|
targetHeight: number;
|
|
3
|
-
}, "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
demandOption: true;
|
|
7
|
-
default: string;
|
|
3
|
+
}, "batch-size" | "block-confirmations" | "config" | "db-schema" | "debug" | "dictionary-resolver" | "dictionary-timeout" | "disable-historical" | "ipfs" | "local" | "log-level" | "mmr-path" | "multi-chain" | "network-dictionary" | "network-endpoint" | "output-fmt" | "port" | "profiler" | "proof-of-index" | "query-limit" | "scale-batch-size" | "pg-ca" | "pg-key" | "pg-cert" | "store-cache-threshold" | "store-get-cache-size" | "store-cache-async" | "subquery" | "subquery-name" | "subscription" | "timeout" | "timestamp-field" | "unfinalized-blocks" | "unsafe" | "workers"> & import("yargs").InferredOptionTypes<{
|
|
4
|
+
'batch-size': {
|
|
5
|
+
demandOption: false;
|
|
8
6
|
describe: string;
|
|
9
|
-
type: "
|
|
7
|
+
type: "number";
|
|
10
8
|
};
|
|
11
|
-
'
|
|
12
|
-
deprecated: true;
|
|
9
|
+
'block-confirmations': {
|
|
13
10
|
demandOption: false;
|
|
11
|
+
default: number;
|
|
14
12
|
describe: string;
|
|
15
|
-
type: "
|
|
13
|
+
type: "number";
|
|
16
14
|
};
|
|
17
15
|
config: {
|
|
18
16
|
alias: string;
|
|
@@ -20,55 +18,68 @@ export declare const yargsOptions: import("yargs").Argv<import("yargs").Omit<{
|
|
|
20
18
|
describe: string;
|
|
21
19
|
type: "string";
|
|
22
20
|
};
|
|
23
|
-
local: {
|
|
24
|
-
deprecated: true;
|
|
25
|
-
type: "boolean";
|
|
26
|
-
demandOption: false;
|
|
27
|
-
describe: string;
|
|
28
|
-
};
|
|
29
21
|
'db-schema': {
|
|
30
22
|
demandOption: false;
|
|
31
23
|
describe: string;
|
|
32
24
|
type: "string";
|
|
33
25
|
};
|
|
34
|
-
|
|
35
|
-
type: "boolean";
|
|
26
|
+
debug: {
|
|
36
27
|
demandOption: false;
|
|
37
28
|
describe: string;
|
|
29
|
+
type: "boolean";
|
|
30
|
+
default: boolean;
|
|
38
31
|
};
|
|
39
|
-
|
|
32
|
+
'dictionary-resolver': {
|
|
40
33
|
demandOption: false;
|
|
41
34
|
describe: string;
|
|
42
35
|
type: "boolean";
|
|
43
36
|
default: boolean;
|
|
44
37
|
};
|
|
45
|
-
'
|
|
38
|
+
'dictionary-timeout': {
|
|
46
39
|
demandOption: false;
|
|
47
40
|
describe: string;
|
|
48
41
|
type: "number";
|
|
49
42
|
};
|
|
50
|
-
'
|
|
43
|
+
'disable-historical': {
|
|
44
|
+
demandOption: false;
|
|
45
|
+
default: boolean;
|
|
46
|
+
describe: string;
|
|
51
47
|
type: "boolean";
|
|
48
|
+
};
|
|
49
|
+
ipfs: {
|
|
52
50
|
demandOption: false;
|
|
53
51
|
describe: string;
|
|
54
|
-
|
|
52
|
+
type: "string";
|
|
55
53
|
};
|
|
56
|
-
|
|
54
|
+
local: {
|
|
55
|
+
deprecated: true;
|
|
56
|
+
type: "boolean";
|
|
57
57
|
demandOption: false;
|
|
58
58
|
describe: string;
|
|
59
|
-
type: "number";
|
|
60
59
|
};
|
|
61
|
-
|
|
60
|
+
'log-level': {
|
|
62
61
|
demandOption: false;
|
|
63
62
|
describe: string;
|
|
64
|
-
type: "
|
|
65
|
-
|
|
63
|
+
type: "string";
|
|
64
|
+
choices: string[];
|
|
66
65
|
};
|
|
67
|
-
|
|
66
|
+
'mmr-path': {
|
|
67
|
+
alias: string;
|
|
68
68
|
demandOption: false;
|
|
69
69
|
describe: string;
|
|
70
|
-
type: "
|
|
70
|
+
type: "string";
|
|
71
|
+
};
|
|
72
|
+
'multi-chain': {
|
|
73
|
+
demandOption: false;
|
|
71
74
|
default: boolean;
|
|
75
|
+
describe: string;
|
|
76
|
+
type: "boolean";
|
|
77
|
+
};
|
|
78
|
+
'network-dictionary': {
|
|
79
|
+
alias: string;
|
|
80
|
+
demandOption: false;
|
|
81
|
+
describe: string;
|
|
82
|
+
type: "string";
|
|
72
83
|
};
|
|
73
84
|
'network-endpoint': {
|
|
74
85
|
demandOption: false;
|
|
@@ -81,74 +92,111 @@ export declare const yargsOptions: import("yargs").Argv<import("yargs").Omit<{
|
|
|
81
92
|
type: "string";
|
|
82
93
|
choices: string[];
|
|
83
94
|
};
|
|
84
|
-
|
|
95
|
+
port: {
|
|
96
|
+
alias: string;
|
|
85
97
|
demandOption: false;
|
|
86
98
|
describe: string;
|
|
87
|
-
type: "
|
|
88
|
-
choices: string[];
|
|
99
|
+
type: "number";
|
|
89
100
|
};
|
|
90
|
-
|
|
101
|
+
profiler: {
|
|
91
102
|
demandOption: false;
|
|
92
103
|
describe: string;
|
|
93
104
|
type: "boolean";
|
|
94
105
|
default: boolean;
|
|
95
106
|
};
|
|
96
|
-
'
|
|
107
|
+
'proof-of-index': {
|
|
97
108
|
demandOption: false;
|
|
98
109
|
describe: string;
|
|
99
110
|
type: "boolean";
|
|
100
111
|
default: boolean;
|
|
101
112
|
};
|
|
102
|
-
'
|
|
103
|
-
|
|
113
|
+
'query-limit': {
|
|
114
|
+
demandOption: false;
|
|
115
|
+
describe: string;
|
|
116
|
+
type: "number";
|
|
117
|
+
default: number;
|
|
118
|
+
};
|
|
119
|
+
'scale-batch-size': {
|
|
120
|
+
type: "boolean";
|
|
121
|
+
demandOption: false;
|
|
122
|
+
describe: string;
|
|
123
|
+
default: boolean;
|
|
124
|
+
};
|
|
125
|
+
'pg-ca': {
|
|
104
126
|
demandOption: false;
|
|
105
127
|
describe: string;
|
|
106
128
|
type: "string";
|
|
107
129
|
};
|
|
108
|
-
'
|
|
130
|
+
'pg-key': {
|
|
131
|
+
demandOption: false;
|
|
132
|
+
describe: string;
|
|
133
|
+
type: "string";
|
|
134
|
+
};
|
|
135
|
+
'pg-cert': {
|
|
136
|
+
demandOption: false;
|
|
137
|
+
describe: string;
|
|
138
|
+
type: "string";
|
|
139
|
+
};
|
|
140
|
+
'store-cache-threshold': {
|
|
109
141
|
demandOption: false;
|
|
110
142
|
describe: string;
|
|
111
143
|
type: "number";
|
|
112
144
|
};
|
|
113
|
-
'
|
|
145
|
+
'store-get-cache-size': {
|
|
146
|
+
demandOption: false;
|
|
147
|
+
describe: string;
|
|
148
|
+
type: "number";
|
|
149
|
+
};
|
|
150
|
+
'store-cache-async': {
|
|
151
|
+
demandOption: false;
|
|
152
|
+
describe: string;
|
|
153
|
+
type: "boolean";
|
|
154
|
+
};
|
|
155
|
+
subquery: {
|
|
114
156
|
alias: string;
|
|
157
|
+
demandOption: true;
|
|
158
|
+
default: string;
|
|
159
|
+
describe: string;
|
|
160
|
+
type: "string";
|
|
161
|
+
};
|
|
162
|
+
'subquery-name': {
|
|
163
|
+
deprecated: true;
|
|
115
164
|
demandOption: false;
|
|
116
165
|
describe: string;
|
|
117
166
|
type: "string";
|
|
118
167
|
};
|
|
119
|
-
|
|
168
|
+
subscription: {
|
|
120
169
|
demandOption: false;
|
|
121
170
|
describe: string;
|
|
122
171
|
type: "boolean";
|
|
123
172
|
default: boolean;
|
|
124
173
|
};
|
|
125
|
-
|
|
174
|
+
timeout: {
|
|
126
175
|
demandOption: false;
|
|
127
176
|
describe: string;
|
|
128
|
-
type: "
|
|
177
|
+
type: "number";
|
|
129
178
|
};
|
|
130
|
-
|
|
131
|
-
alias: string;
|
|
179
|
+
'timestamp-field': {
|
|
132
180
|
demandOption: false;
|
|
133
181
|
describe: string;
|
|
134
|
-
type: "
|
|
182
|
+
type: "boolean";
|
|
183
|
+
default: boolean;
|
|
135
184
|
};
|
|
136
|
-
'
|
|
185
|
+
'unfinalized-blocks': {
|
|
137
186
|
demandOption: false;
|
|
138
187
|
default: boolean;
|
|
139
188
|
describe: string;
|
|
140
189
|
type: "boolean";
|
|
141
190
|
};
|
|
142
|
-
|
|
143
|
-
|
|
191
|
+
unsafe: {
|
|
192
|
+
type: "boolean";
|
|
144
193
|
demandOption: false;
|
|
145
194
|
describe: string;
|
|
146
|
-
type: "number";
|
|
147
195
|
};
|
|
148
|
-
|
|
196
|
+
workers: {
|
|
197
|
+
alias: string;
|
|
149
198
|
demandOption: false;
|
|
150
199
|
describe: string;
|
|
151
200
|
type: "number";
|
|
152
|
-
default: number;
|
|
153
201
|
};
|
|
154
202
|
}>>;
|