@sentio/sdk 1.19.4 → 1.19.6

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 (103) hide show
  1. package/lib/aptos/aptos-processor.d.ts +41 -0
  2. package/lib/aptos/aptos-processor.js +129 -0
  3. package/lib/aptos/aptos-processor.js.map +1 -0
  4. package/lib/aptos/bind-options.d.ts +11 -0
  5. package/lib/aptos/bind-options.js +17 -0
  6. package/lib/aptos/bind-options.js.map +1 -0
  7. package/lib/aptos/context.d.ts +12 -0
  8. package/lib/aptos/context.js +33 -0
  9. package/lib/aptos/context.js.map +1 -0
  10. package/lib/aptos/index.d.ts +5 -0
  11. package/lib/aptos/index.js +11 -0
  12. package/lib/aptos/index.js.map +1 -0
  13. package/lib/cli/webpack.config.js +1 -0
  14. package/lib/core/base-processor-template.js.map +1 -1
  15. package/lib/core/base-processor.d.ts +1 -1
  16. package/lib/core/base-processor.js.map +1 -1
  17. package/lib/core/bind-options.d.ts +0 -2
  18. package/lib/core/bind-options.js +1 -4
  19. package/lib/core/bind-options.js.map +1 -1
  20. package/lib/core/context.d.ts +10 -10
  21. package/lib/core/context.js +65 -11
  22. package/lib/core/context.js.map +1 -1
  23. package/lib/core/index.d.ts +1 -2
  24. package/lib/core/index.js +1 -4
  25. package/lib/core/index.js.map +1 -1
  26. package/lib/core/logger.d.ts +1 -1
  27. package/lib/core/logger.js +5 -5
  28. package/lib/core/logger.js.map +1 -1
  29. package/lib/core/metadata.d.ts +1 -1
  30. package/lib/core/metadata.js +3 -79
  31. package/lib/core/metadata.js.map +1 -1
  32. package/lib/core/meter.d.ts +1 -1
  33. package/lib/core/meter.js +2 -2
  34. package/lib/core/meter.js.map +1 -1
  35. package/lib/core/numberish.d.ts +1 -1
  36. package/lib/core/numberish.js +7 -7
  37. package/lib/core/numberish.js.map +1 -1
  38. package/lib/core/numberish.test.js.map +1 -1
  39. package/lib/core/solana-processor.d.ts +1 -1
  40. package/lib/core/solana-processor.js.map +1 -1
  41. package/lib/core/sui-processor.d.ts +1 -1
  42. package/lib/core/sui-processor.js.map +1 -1
  43. package/lib/gen/index.d.ts +1 -0
  44. package/lib/gen/index.js +18 -0
  45. package/lib/gen/index.js.map +1 -0
  46. package/lib/index.d.ts +2 -1
  47. package/lib/index.js +15 -2
  48. package/lib/index.js.map +1 -1
  49. package/lib/processor-runner.js +2 -2
  50. package/lib/processor-runner.js.map +1 -1
  51. package/lib/processor-state.d.ts +2 -1
  52. package/lib/processor-state.js.map +1 -1
  53. package/lib/service.d.ts +2 -2
  54. package/lib/service.js +41 -36
  55. package/lib/service.js.map +1 -1
  56. package/lib/testing/metric-utils.d.ts +1 -1
  57. package/lib/testing/metric-utils.js +2 -2
  58. package/lib/testing/metric-utils.js.map +1 -1
  59. package/lib/testing/test-processor-server.d.ts +2 -1
  60. package/lib/testing/test-processor-server.js +11 -11
  61. package/lib/testing/test-processor-server.js.map +1 -1
  62. package/lib/testing/test-provider.js +2 -2
  63. package/lib/testing/test-provider.js.map +1 -1
  64. package/lib/tests/aptos.test.js +44 -12
  65. package/lib/tests/aptos.test.js.map +1 -1
  66. package/lib/tests/souffl3.js +19 -12
  67. package/lib/tests/souffl3.js.map +1 -1
  68. package/lib/utils/chain.d.ts +1 -0
  69. package/lib/utils/chain.js +3 -1
  70. package/lib/utils/chain.js.map +1 -1
  71. package/package.json +5 -7
  72. package/src/aptos/aptos-processor.ts +171 -0
  73. package/src/aptos/bind-options.ts +15 -0
  74. package/src/aptos/context.ts +35 -0
  75. package/src/aptos/index.ts +5 -0
  76. package/src/cli/webpack.config.js +1 -0
  77. package/src/core/base-processor-template.ts +1 -1
  78. package/src/core/base-processor.ts +1 -1
  79. package/src/core/bind-options.ts +0 -1
  80. package/src/core/context.ts +74 -15
  81. package/src/core/index.ts +2 -2
  82. package/src/core/logger.ts +1 -1
  83. package/src/core/metadata.ts +4 -76
  84. package/src/core/meter.ts +1 -1
  85. package/src/core/numberish.test.ts +1 -1
  86. package/src/core/numberish.ts +1 -1
  87. package/src/core/solana-processor.ts +1 -1
  88. package/src/core/sui-processor.ts +1 -1
  89. package/src/gen/index.ts +1 -0
  90. package/src/index.ts +4 -1
  91. package/src/processor-runner.ts +1 -1
  92. package/src/processor-state.ts +3 -1
  93. package/src/service.ts +29 -29
  94. package/src/testing/metric-utils.ts +2 -2
  95. package/src/testing/test-processor-server.ts +5 -2
  96. package/src/testing/test-provider.ts +1 -1
  97. package/src/tests/aptos.test.ts +47 -11
  98. package/src/tests/souffl3.ts +31 -19
  99. package/src/utils/chain.ts +2 -0
  100. package/lib/core/aptos-processor.d.ts +0 -41
  101. package/lib/core/aptos-processor.js +0 -125
  102. package/lib/core/aptos-processor.js.map +0 -1
  103. package/src/core/aptos-processor.ts +0 -147
@@ -6,7 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const command_line_args_1 = __importDefault(require("command-line-args"));
8
8
  const nice_grpc_1 = require("nice-grpc");
9
- const processor_1 = require("./gen/processor/protos/processor");
9
+ const gen_1 = require("./gen");
10
10
  const service_1 = require("./service");
11
11
  const provider_1 = require("./provider");
12
12
  const path_1 = __importDefault(require("path"));
@@ -39,6 +39,6 @@ const server = (0, nice_grpc_1.createServer)({
39
39
  'grpc.default_compression_algorithm': compression_algorithms_1.CompressionAlgorithms.gzip,
40
40
  });
41
41
  const service = new service_1.ProcessorServiceImpl(() => (0, loader_1.load)(options.target), server.shutdown);
42
- server.add(processor_1.ProcessorDefinition, service);
42
+ server.add(gen_1.ProcessorDefinition, service);
43
43
  server.listen('0.0.0.0:' + options.port);
44
44
  //# sourceMappingURL=processor-runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";;;;;;AAEA,0EAA+C;AAC/C,yCAAwC;AACxC,gEAAsE;AACtE,uCAAgD;AAChD,yCAAwC;AAExC,gDAAuB;AACvB,w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GAAG,IAAI,GAAG,IAAI;IACnD,oCAAoC,EAAE,8CAAqB,CAAC,IAAI;CACjE,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,IAAI,8BAAoB,CAAC,GAAG,EAAE,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AACrF,MAAM,CAAC,GAAG,CAAC,+BAAmB,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { ProcessorDefinition } from './gen/processor/protos/processor'\nimport { ProcessorServiceImpl } from './service'\nimport { setProvider } from './provider'\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport { ProcessorState } from './processor-state'\nimport { load } from './loader'\nimport { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'\n\nglobal.PROCESSOR_STATE = new ProcessorState()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nconsole.log('loading', options.target)\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nsetProvider(chainsConfig, options.concurrency, options['use-chainserver'])\n\nconsole.log('Start Server', options)\n\nconst server = createServer({\n 'grpc.max_send_message_length': 64 * 1024 * 1024,\n 'grpc.max_receive_message_length': 64 * 1024 * 1024,\n 'grpc.default_compression_algorithm': CompressionAlgorithms.gzip,\n})\n\nconst service = new ProcessorServiceImpl(() => load(options.target), server.shutdown)\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n"]}
1
+ {"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";;;;;;AAEA,0EAA+C;AAC/C,yCAAwC;AACxC,+BAA2C;AAC3C,uCAAgD;AAChD,yCAAwC;AAExC,gDAAuB;AACvB,wDAAyB;AACzB,uDAAkD;AAClD,qCAA+B;AAC/B,2FAAsF;AAEtF,MAAM,CAAC,eAAe,GAAG,IAAI,gCAAc,EAAE,CAAA;AAE7C,MAAM,iBAAiB,GAAG;IACxB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE;IACrD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IAChE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE;IACtD,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE;IAC/D;QACE,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,oBAAoB;KACnC;CACF,CAAA;AAED,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,iBAAiB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;AAErE,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;AAEtC,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAA;AACvD,MAAM,YAAY,GAAG,kBAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;AAE9C,IAAA,sBAAW,EAAC,YAAY,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAE1E,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AAEpC,MAAM,MAAM,GAAG,IAAA,wBAAY,EAAC;IAC1B,8BAA8B,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAChD,iCAAiC,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IACnD,oCAAoC,EAAE,8CAAqB,CAAC,IAAI;CACjE,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,IAAI,8BAAoB,CAAC,GAAG,EAAE,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AACrF,MAAM,CAAC,GAAG,CAAC,yBAAmB,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { ProcessorDefinition } from './gen'\nimport { ProcessorServiceImpl } from './service'\nimport { setProvider } from './provider'\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport { ProcessorState } from './processor-state'\nimport { load } from './loader'\nimport { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'\n\nglobal.PROCESSOR_STATE = new ProcessorState()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nconsole.log('loading', options.target)\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nsetProvider(chainsConfig, options.concurrency, options['use-chainserver'])\n\nconsole.log('Start Server', options)\n\nconst server = createServer({\n 'grpc.max_send_message_length': 64 * 1024 * 1024,\n 'grpc.max_receive_message_length': 64 * 1024 * 1024,\n 'grpc.default_compression_algorithm': CompressionAlgorithms.gzip,\n})\n\nconst service = new ProcessorServiceImpl(() => load(options.target), server.shutdown)\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n"]}
@@ -1,4 +1,5 @@
1
- import { BaseProcessor, BoundContractView, ContractView, BaseProcessorTemplate, SolanaBaseProcessor, SuiBaseProcessor, AptosBaseProcessor } from './core';
1
+ import { BaseProcessor, BoundContractView, ContractView, BaseProcessorTemplate, SolanaBaseProcessor, SuiBaseProcessor } from './core';
2
+ import { AptosBaseProcessor } from './aptos';
2
3
  import { BaseContract } from 'ethers';
3
4
  import { TemplateInstance } from './gen/processor/protos/processor';
4
5
  import { Provider } from '@ethersproject/providers';
@@ -1 +1 @@
1
- {"version":3,"file":"processor-state.js","sourceRoot":"","sources":["../src/processor-state.ts"],"names":[],"mappings":";;;AAaA,MAAa,cAAc;IACzB,mDAAmD;IACnD,SAAS,GAAG,IAAI,GAAG,EAAsC,CAAA;IACzD,qBAAqB;IACrB,UAAU,GAAwE,EAAE,CAAA;IACpF,oCAAoC;IACpC,YAAY,GAAG,IAAI,GAAG,EAAmC,CAAA;IACzD,gBAAgB;IAChB,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAA;IACvC,0BAA0B;IAC1B,SAAS,GAAgF,EAAE,CAAA;IAC3F,wCAAwC;IACxC,kBAAkB,GAAuB,EAAE,CAAA;IAE3C,gBAAgB,GAA0B,EAAE,CAAA;IAE5C,aAAa,GAAuB,EAAE,CAAA;IAEtC,eAAe,GAAyB,EAAE,CAAA;CAC3C;AAnBD,wCAmBC","sourcesContent":["import {\n BaseProcessor,\n BoundContractView,\n ContractView,\n BaseProcessorTemplate,\n SolanaBaseProcessor,\n SuiBaseProcessor,\n AptosBaseProcessor,\n} from './core'\nimport { BaseContract } from 'ethers'\nimport { TemplateInstance } from './gen/processor/protos/processor'\nimport { Provider } from '@ethersproject/providers'\n\nexport class ProcessorState {\n // from abiName_address_chainId => contract wrapper\n contracts = new Map<string, ContractView<BaseContract>>()\n // all evm processors\n processors: BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>[] = []\n // from abiName_options to contracts\n processorMap = new Map<string, BaseProcessor<any, any>>()\n // evm providers\n providers = new Map<number, Provider>()\n // evm processor templates\n templates: BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>[] = []\n // evm processor template instances spec\n templatesInstances: TemplateInstance[] = []\n\n solanaProcessors: SolanaBaseProcessor[] = []\n\n suiProcessors: SuiBaseProcessor[] = []\n\n aptosProcessors: AptosBaseProcessor[] = []\n}\n"]}
1
+ {"version":3,"file":"processor-state.js","sourceRoot":"","sources":["../src/processor-state.ts"],"names":[],"mappings":";;;AAeA,MAAa,cAAc;IACzB,mDAAmD;IACnD,SAAS,GAAG,IAAI,GAAG,EAAsC,CAAA;IACzD,qBAAqB;IACrB,UAAU,GAAwE,EAAE,CAAA;IACpF,oCAAoC;IACpC,YAAY,GAAG,IAAI,GAAG,EAAmC,CAAA;IACzD,gBAAgB;IAChB,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAA;IACvC,0BAA0B;IAC1B,SAAS,GAAgF,EAAE,CAAA;IAC3F,wCAAwC;IACxC,kBAAkB,GAAuB,EAAE,CAAA;IAE3C,gBAAgB,GAA0B,EAAE,CAAA;IAE5C,aAAa,GAAuB,EAAE,CAAA;IAEtC,eAAe,GAAyB,EAAE,CAAA;CAC3C;AAnBD,wCAmBC","sourcesContent":["import {\n BaseProcessor,\n BoundContractView,\n ContractView,\n BaseProcessorTemplate,\n SolanaBaseProcessor,\n SuiBaseProcessor,\n} from './core'\n\nimport { AptosBaseProcessor } from './aptos'\n\nimport { BaseContract } from 'ethers'\nimport { TemplateInstance } from './gen/processor/protos/processor'\nimport { Provider } from '@ethersproject/providers'\n\nexport class ProcessorState {\n // from abiName_address_chainId => contract wrapper\n contracts = new Map<string, ContractView<BaseContract>>()\n // all evm processors\n processors: BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>[] = []\n // from abiName_options to contracts\n processorMap = new Map<string, BaseProcessor<any, any>>()\n // evm providers\n providers = new Map<number, Provider>()\n // evm processor templates\n templates: BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>[] = []\n // evm processor template instances spec\n templatesInstances: TemplateInstance[] = []\n\n solanaProcessors: SolanaBaseProcessor[] = []\n\n suiProcessors: SuiBaseProcessor[] = []\n\n aptosProcessors: AptosBaseProcessor[] = []\n}\n"]}
package/lib/service.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CallContext } from 'nice-grpc';
2
- import { BlockBinding, DataBinding, ProcessBindingResponse, ProcessBindingsRequest, ProcessBlocksRequest, ProcessConfigRequest, ProcessConfigResponse, ProcessInstructionsRequest, ProcessorServiceImplementation, ProcessResult, ProcessTransactionsRequest, StartRequest } from './gen/processor/protos/processor';
2
+ import { BlockBinding, DataBinding, ProcessBindingResponse, ProcessBindingsRequest, ProcessBlocksRequest, ProcessConfigRequest, ProcessConfigResponse, ProcessInstructionsRequest, ProcessorServiceImplementation, ProcessResult, ProcessTransactionsRequest, StartRequest } from './gen';
3
3
  import { Empty } from './gen/google/protobuf/empty';
4
4
  export declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
5
5
  private eventHandlers;
@@ -27,5 +27,5 @@ export declare class ProcessorServiceImpl implements ProcessorServiceImplementat
27
27
  processTraces(request: ProcessBindingsRequest, context: CallContext): Promise<ProcessBindingResponse>;
28
28
  processTrace(binding: DataBinding): Promise<ProcessResult>;
29
29
  processAptosEvent(binding: DataBinding): Promise<ProcessResult>;
30
- processAptosCall(binding: DataBinding): Promise<ProcessResult>;
30
+ processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult>;
31
31
  }
package/lib/service.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ProcessorServiceImpl = void 0;
7
7
  const nice_grpc_1 = require("nice-grpc");
8
8
  const chain_1 = require("./utils/chain");
9
- const processor_1 = require("./gen/processor/protos/processor");
9
+ const gen_1 = require("./gen");
10
10
  const long_1 = __importDefault(require("long"));
11
11
  const util_1 = require("util");
12
12
  const DEFAULT_MAX_BLOCK = long_1.default.ZERO;
@@ -173,13 +173,13 @@ class ProcessorServiceImpl {
173
173
  contract: {
174
174
  name: aptosProcessor.name,
175
175
  chainId: chain_1.APTOS_TESTNET_ID,
176
- address: aptosProcessor.address,
176
+ address: aptosProcessor.config.address,
177
177
  abi: '',
178
178
  },
179
179
  blockConfigs: [],
180
180
  logConfigs: [],
181
181
  traceConfigs: [],
182
- startBlock: aptosProcessor.config.startSeqNumber,
182
+ startBlock: aptosProcessor.config.startVersion,
183
183
  endBlock: DEFAULT_MAX_BLOCK,
184
184
  instructionConfig: undefined,
185
185
  aptosEventConfigs: [],
@@ -273,9 +273,9 @@ class ProcessorServiceImpl {
273
273
  }
274
274
  async processBinding(request, options) {
275
275
  switch (request.handlerType) {
276
- case processor_1.HandlerType.APT_CALL:
277
- return this.processAptosCall(request);
278
- case processor_1.HandlerType.APT_EVENT:
276
+ case gen_1.HandlerType.APT_CALL:
277
+ return this.processAptosFunctionCall(request);
278
+ case gen_1.HandlerType.APT_EVENT:
279
279
  return this.processAptosEvent(request);
280
280
  default:
281
281
  throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType);
@@ -312,7 +312,7 @@ class ProcessorServiceImpl {
312
312
  await this.configure();
313
313
  updated = true;
314
314
  }
315
- recordRuntimeInfo(result, processor_1.HandlerType.ETH_LOG);
315
+ recordRuntimeInfo(result, gen_1.HandlerType.ETH_LOG);
316
316
  return {
317
317
  result,
318
318
  configUpdated: updated,
@@ -322,7 +322,7 @@ class ProcessorServiceImpl {
322
322
  if (!this.started) {
323
323
  throw new nice_grpc_1.ServerError(nice_grpc_1.Status.UNAVAILABLE, 'Service not started.');
324
324
  }
325
- const result = processor_1.ProcessResult.fromPartial({});
325
+ const result = gen_1.ProcessResult.fromPartial({});
326
326
  if (request.chainId.toLowerCase().startsWith('sui') && global.PROCESSOR_STATE.suiProcessors) {
327
327
  const processorPromises = [];
328
328
  for (const txn of request.transactions) {
@@ -340,26 +340,31 @@ class ProcessorServiceImpl {
340
340
  }
341
341
  await Promise.all(processorPromises);
342
342
  }
343
- if (request.chainId.toLowerCase().startsWith('apt') && global.PROCESSOR_STATE.aptosProcessors) {
344
- const processorPromises = [];
345
- for (const txn of request.transactions) {
346
- processorPromises.push(new Promise((resolve, _) => {
347
- for (const processor of global.PROCESSOR_STATE.aptosProcessors) {
348
- if (processor.address === txn.programAccountId) {
349
- const res = processor.handleTransaction(JSON.parse(new util_1.TextDecoder().decode(txn.raw)), txn.slot ?? long_1.default.fromNumber(0));
350
- if (res) {
351
- res.gauges.forEach((g) => result.gauges.push(g));
352
- res.counters.forEach((c) => result.counters.push(c));
353
- res.logs.forEach((l) => result.logs.push(l));
354
- }
355
- }
356
- }
357
- resolve();
358
- }));
359
- }
360
- await Promise.all(processorPromises);
361
- }
362
- recordRuntimeInfo(result, processor_1.HandlerType.TRANSACTION);
343
+ // if (request.chainId.toLowerCase().startsWith('apt') && global.PROCESSOR_STATE.aptosProcessors) {
344
+ // const processorPromises: Promise<void>[] = []
345
+ // for (const txn of request.transactions) {
346
+ // processorPromises.push(
347
+ // new Promise((resolve, _) => {
348
+ // for (const processor of global.PROCESSOR_STATE.aptosProcessors) {
349
+ // if (processor.address === txn.programAccountId!) {
350
+ // const res = processor.handleTransaction(
351
+ // JSON.parse(new TextDecoder().decode(txn.raw)),
352
+ // txn.slot ?? Long.fromNumber(0)
353
+ // )
354
+ // if (res) {
355
+ // res.gauges.forEach((g) => result.gauges.push(g))
356
+ // res.counters.forEach((c) => result.counters.push(c))
357
+ // res.logs.forEach((l) => result.logs.push(l))
358
+ // }
359
+ // }
360
+ // }
361
+ // resolve()
362
+ // })
363
+ // )
364
+ // }
365
+ // await Promise.all(processorPromises)
366
+ // }
367
+ recordRuntimeInfo(result, gen_1.HandlerType.TRANSACTION);
363
368
  return {
364
369
  result,
365
370
  configUpdated: false,
@@ -369,7 +374,7 @@ class ProcessorServiceImpl {
369
374
  if (!this.started) {
370
375
  throw new nice_grpc_1.ServerError(nice_grpc_1.Status.UNAVAILABLE, 'Service not started.');
371
376
  }
372
- const result = processor_1.ProcessResult.fromPartial({});
377
+ const result = gen_1.ProcessResult.fromPartial({});
373
378
  // Only have instruction handlers for solana processors
374
379
  if (global.PROCESSOR_STATE.solanaProcessors) {
375
380
  const processorPromises = [];
@@ -405,7 +410,7 @@ class ProcessorServiceImpl {
405
410
  }
406
411
  await Promise.all(processorPromises);
407
412
  }
408
- recordRuntimeInfo(result, processor_1.HandlerType.INSTRUCTION);
413
+ recordRuntimeInfo(result, gen_1.HandlerType.INSTRUCTION);
409
414
  return {
410
415
  result,
411
416
  configUpdated: false,
@@ -417,7 +422,7 @@ class ProcessorServiceImpl {
417
422
  }
418
423
  const promises = request.blockBindings.map((binding) => this.processBlock(binding));
419
424
  const result = mergeProcessResults(await Promise.all(promises));
420
- recordRuntimeInfo(result, processor_1.HandlerType.BLOCK);
425
+ recordRuntimeInfo(result, gen_1.HandlerType.BLOCK);
421
426
  return {
422
427
  result,
423
428
  configUpdated: false,
@@ -444,7 +449,7 @@ class ProcessorServiceImpl {
444
449
  }
445
450
  const promises = request.bindings.map((binding) => this.processTrace(binding));
446
451
  const result = mergeProcessResults(await Promise.all(promises));
447
- recordRuntimeInfo(result, processor_1.HandlerType.ETH_TRACE);
452
+ recordRuntimeInfo(result, gen_1.HandlerType.ETH_TRACE);
448
453
  return {
449
454
  result,
450
455
  configUpdated: false,
@@ -470,10 +475,10 @@ class ProcessorServiceImpl {
470
475
  const result = await this.aptosEventHandlers[binding.handlerId](event).catch((e) => {
471
476
  throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing event: ' + jsonString + '\n' + errorString(e));
472
477
  });
473
- recordRuntimeInfo(result, processor_1.HandlerType.APT_EVENT);
478
+ recordRuntimeInfo(result, gen_1.HandlerType.APT_EVENT);
474
479
  return result;
475
480
  }
476
- async processAptosCall(binding) {
481
+ async processAptosFunctionCall(binding) {
477
482
  if (!binding.data) {
478
483
  throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Event can't be empty");
479
484
  }
@@ -483,7 +488,7 @@ class ProcessorServiceImpl {
483
488
  const result = await this.aptosCallHandlers[binding.handlerId](call).catch((e) => {
484
489
  throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing call: ' + jsonString + '\n' + errorString(e));
485
490
  });
486
- recordRuntimeInfo(result, processor_1.HandlerType.APT_CALL);
491
+ recordRuntimeInfo(result, gen_1.HandlerType.APT_CALL);
487
492
  return result;
488
493
  }
489
494
  }
@@ -527,7 +532,7 @@ function Utf8ArrayToStr(array) {
527
532
  return out;
528
533
  }
529
534
  function mergeProcessResults(results) {
530
- const res = processor_1.ProcessResult.fromPartial({});
535
+ const res = gen_1.ProcessResult.fromPartial({});
531
536
  for (const r of results) {
532
537
  res.counters = res.counters.concat(r.counters);
533
538
  res.gauges = res.gauges.concat(r.gauges);
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AACA,yCAA4D;AAC5D,yCAA+E;AAE/E,gEAoByC;AAGzC,gDAAuB;AACvB,+BAAkC;AAGlC,MAAM,iBAAiB,GAAG,cAAI,CAAC,IAAI,CAAA;AAEnC,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAEvC,MAAa,oBAAoB;IACvB,aAAa,GAA+C,EAAE,CAAA;IAC9D,aAAa,GAAiD,EAAE,CAAA;IAChE,aAAa,GAAiD,EAAE,CAAA;IAChE,kBAAkB,GAA+C,EAAE,CAAA;IACnE,iBAAiB,GAA8C,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IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;KACnC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3B,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACzB,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,CAAQ;IAC3B,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAA;AAC7B,CAAC","sourcesContent":["import { Block, Log } from '@ethersproject/abstract-provider'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { APTOS_TESTNET_ID, SOL_MAINMET_ID, SUI_DEVNET_ID } from './utils/chain'\n\nimport {\n AptosCallHandlerConfig,\n AptosEventHandlerConfig,\n BlockBinding,\n ContractConfig,\n DataBinding,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessBlocksRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessInstructionsRequest,\n ProcessorServiceImplementation,\n ProcessResult,\n ProcessTransactionsRequest,\n StartRequest,\n TemplateInstance,\n} from './gen/processor/protos/processor'\n\nimport { Empty } from './gen/google/protobuf/empty'\nimport Long from 'long'\nimport { TextDecoder } from 'util'\nimport { Trace } from './core'\n\nconst DEFAULT_MAX_BLOCK = Long.ZERO\n\nconst USER_PROCESSOR = 'user_processor'\n\nexport class ProcessorServiceImpl implements ProcessorServiceImplementation {\n private eventHandlers: ((event: Log) => Promise<ProcessResult>)[] = []\n private traceHandlers: ((trace: Trace) => Promise<ProcessResult>)[] = []\n private blockHandlers: ((block: Block) => Promise<ProcessResult>)[] = []\n private aptosEventHandlers: ((event: any) => Promise<ProcessResult>)[] = []\n private aptosCallHandlers: ((func: any) => Promise<ProcessResult>)[] = []\n\n // map from chain id to list of processors\n // private blockHandlers = new Map<string, ((block: Block) => Promise<ProcessResult>)[]>()\n // private processorsByChainId = new Map<string, BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>>()\n\n private started = false\n private contractConfigs: ContractConfig[]\n private templateInstances: TemplateInstance[]\n private readonly loader: () => void\n\n private readonly shutdownHandler?: () => void\n\n constructor(loader: () => void, shutdownHandler?: () => void) {\n this.loader = loader\n this.shutdownHandler = shutdownHandler\n }\n\n async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n return {\n // TODO project setting\n config: undefined,\n contractConfigs: this.contractConfigs,\n templateInstances: this.templateInstances,\n }\n }\n\n async configure() {\n this.eventHandlers = []\n this.templateInstances = []\n // this.processorsByChainId.clear()\n this.contractConfigs = []\n\n this.templateInstances = [...global.PROCESSOR_STATE.templatesInstances]\n\n // Part 1, prepare EVM processors\n for (const processor of global.PROCESSOR_STATE.processors) {\n // If server favor incremental update this need to change\n // Start basic config for contract\n const chainId = processor.getChainId()\n // this.processorsByChainId.set(chainId, processor)\n\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: processor.config.name,\n chainId: chainId.toString(),\n address: processor.config.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: processor.config.startBlock,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n if (processor.config.endBlock) {\n contractConfig.endBlock = processor.config.endBlock\n }\n\n // Step 1. Prepare all the block handlers\n for (const blockHandler of processor.blockHandlers) {\n const handlerId = this.blockHandlers.push(blockHandler) - 1\n // TODO wrap the block handler into one\n\n contractConfig.blockConfigs.push({\n handlerId: handlerId,\n })\n }\n\n // Step 2. Prepare all trace handlers\n for (const traceHandler of processor.traceHandlers) {\n const handlerId = this.traceHandlers.push(traceHandler.handler) - 1\n contractConfig.traceConfigs.push({\n signature: traceHandler.signature,\n handlerId: handlerId,\n })\n }\n\n // Step 3. Prepare all the event handlers\n for (const eventsHandler of processor.eventHandlers) {\n // associate id with filter\n const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1\n const logConfig: LogHandlerConfig = {\n handlerId: handlerId,\n filters: [],\n }\n\n for (const filter of eventsHandler.filters) {\n if (!filter.topics) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')\n }\n const logFilter: LogFilter = {\n topics: [],\n }\n\n for (const ts of filter.topics) {\n let hashes: string[] = []\n if (Array.isArray(ts)) {\n hashes = hashes.concat(ts)\n } else if (ts) {\n hashes.push(ts)\n }\n logFilter.topics.push({ hashes: hashes })\n }\n logConfig.filters.push(logFilter)\n }\n contractConfig.logConfigs.push(logConfig)\n }\n\n // Finish up a contract\n this.contractConfigs.push(contractConfig)\n }\n\n // Part 2, prepare solana constractors\n for (const solanaProcessor of global.PROCESSOR_STATE.solanaProcessors) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: solanaProcessor.contractName,\n chainId: SOL_MAINMET_ID,\n address: solanaProcessor.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: solanaProcessor.config.startSlot,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: {\n innerInstruction: solanaProcessor.processInnerInstruction,\n parsedInstruction: solanaProcessor.fromParsedInstruction !== null,\n rawDataInstruction: solanaProcessor.decodeInstruction !== null,\n },\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n this.contractConfigs.push(contractConfig)\n }\n\n // Part 3, prepare sui constractors\n for (const suiProcessor of global.PROCESSOR_STATE.suiProcessors) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: 'sui contract',\n chainId: SUI_DEVNET_ID,\n address: suiProcessor.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: suiProcessor.config.startSeqNumber,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n this.contractConfigs.push(contractConfig)\n }\n\n // Part 3, prepare aptos constractors\n for (const aptosProcessor of global.PROCESSOR_STATE.aptosProcessors) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: aptosProcessor.name,\n chainId: APTOS_TESTNET_ID,\n address: aptosProcessor.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: aptosProcessor.config.startSeqNumber,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n // 1. Prepare event handlers\n for (const handler of aptosProcessor.eventHandlers) {\n const handlerId = this.aptosEventHandlers.push(handler.handler) - 1\n const eventHandlerConfig: AptosEventHandlerConfig = {\n filters: handler.filters,\n handlerId,\n }\n contractConfig.aptosEventConfigs.push(eventHandlerConfig)\n }\n\n // 2. Prepare function handlers\n for (const handler of aptosProcessor.callHandlers) {\n const handlerId = this.aptosCallHandlers.push(handler.handler) - 1\n const functionHandlerConfig: AptosCallHandlerConfig = {\n filters: handler.filters.map((filter) => {\n return {\n function: filter.function,\n typeArguments: filter.typeArguments ?? [],\n withTypeArguments: filter.typeArguments ? true : false,\n }\n }),\n handlerId,\n }\n contractConfig.aptosCallConfigs.push(functionHandlerConfig)\n }\n this.contractConfigs.push(contractConfig)\n }\n }\n\n async start(request: StartRequest, context: CallContext): Promise<Empty> {\n if (this.started) {\n return {}\n }\n\n try {\n this.loader()\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n for (const instance of request.templateInstances) {\n const template = global.PROCESSOR_STATE.templates[instance.templateId]\n if (!template) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Invalid template contract:' + instance)\n }\n if (!instance.contract) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Contract Empty from:' + instance)\n }\n template.bind({\n name: instance.contract.name,\n address: instance.contract.address,\n network: Number(instance.contract.chainId),\n startBlock: instance.startBlock,\n endBlock: instance.endBlock,\n })\n }\n try {\n await this.configure()\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'Failed to start processor : ' + errorString(e))\n }\n this.started = true\n return {}\n }\n\n async stop(request: Empty, context: CallContext): Promise<Empty> {\n console.log('Server Shutting down in 5 seconds')\n if (this.shutdownHandler) {\n setTimeout(this.shutdownHandler, 5000)\n }\n return {}\n }\n\n async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.bindings.map((binding) => this.processBinding(binding))\n const result = mergeProcessResults(await Promise.all(promises))\n\n let updated = false\n if (\n global.PROCESSOR_STATE.templatesInstances &&\n this.templateInstances.length != global.PROCESSOR_STATE.templatesInstances.length\n ) {\n await this.configure()\n updated = true\n }\n\n return {\n result,\n configUpdated: updated,\n }\n }\n\n async processBinding(request: DataBinding, options?: CallContext): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.APT_CALL:\n return this.processAptosCall(request)\n case HandlerType.APT_EVENT:\n return this.processAptosEvent(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n async processLogs(request: ProcessBindingsRequest, context: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const l of request.bindings) {\n if (!l.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\n }\n // const jsonString = Buffer.from(l.log.raw.buffer).toString(\"utf-8\")\n // const jsonString = String.fromCharCode.apply(null, l.log.raw)\n\n try {\n const jsonString = Utf8ArrayToStr(l.data.raw)\n const log: Log = JSON.parse(jsonString)\n const handler = this.eventHandlers[l.handlerId]\n const promise = handler(log).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing log: ' + jsonString + '\\n' + errorString(e))\n })\n\n promises.push(promise)\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'error parse log: ' + l)\n }\n }\n\n const result = mergeProcessResults(await Promise.all(promises))\n\n let updated = false\n if (\n global.PROCESSOR_STATE.templatesInstances &&\n this.templateInstances.length != global.PROCESSOR_STATE.templatesInstances.length\n ) {\n await this.configure()\n updated = true\n }\n\n recordRuntimeInfo(result, HandlerType.ETH_LOG)\n return {\n result,\n configUpdated: updated,\n }\n }\n\n async processTransactions(\n request: ProcessTransactionsRequest,\n context: CallContext\n ): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service not started.')\n }\n\n const result = ProcessResult.fromPartial({})\n\n if (request.chainId.toLowerCase().startsWith('sui') && global.PROCESSOR_STATE.suiProcessors) {\n const processorPromises: Promise<void>[] = []\n for (const txn of request.transactions) {\n processorPromises.push(\n new Promise((resolve, _) => {\n for (const processor of global.PROCESSOR_STATE.suiProcessors) {\n const res = processor.handleTransaction(\n JSON.parse(new TextDecoder().decode(txn.raw)),\n txn.slot ?? Long.fromNumber(0)\n )\n if (res) {\n res.gauges.forEach((g) => result.gauges.push(g))\n res.counters.forEach((c) => result.counters.push(c))\n res.logs.forEach((l) => result.logs.push(l))\n }\n }\n resolve()\n })\n )\n }\n await Promise.all(processorPromises)\n }\n\n if (request.chainId.toLowerCase().startsWith('apt') && global.PROCESSOR_STATE.aptosProcessors) {\n const processorPromises: Promise<void>[] = []\n for (const txn of request.transactions) {\n processorPromises.push(\n new Promise((resolve, _) => {\n for (const processor of global.PROCESSOR_STATE.aptosProcessors) {\n if (processor.address === txn.programAccountId!) {\n const res = processor.handleTransaction(\n JSON.parse(new TextDecoder().decode(txn.raw)),\n txn.slot ?? Long.fromNumber(0)\n )\n if (res) {\n res.gauges.forEach((g) => result.gauges.push(g))\n res.counters.forEach((c) => result.counters.push(c))\n res.logs.forEach((l) => result.logs.push(l))\n }\n }\n }\n resolve()\n })\n )\n }\n await Promise.all(processorPromises)\n }\n\n recordRuntimeInfo(result, HandlerType.TRANSACTION)\n return {\n result,\n configUpdated: false,\n }\n }\n\n async processInstructions(\n request: ProcessInstructionsRequest,\n context: CallContext\n ): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service not started.')\n }\n\n const result = ProcessResult.fromPartial({})\n\n // Only have instruction handlers for solana processors\n if (global.PROCESSOR_STATE.solanaProcessors) {\n const processorPromises: Promise<void>[] = []\n for (const instruction of request.instructions) {\n if (!instruction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'instruction cannot be null')\n }\n\n processorPromises.push(\n new Promise((resolve, _) => {\n for (const processor of global.PROCESSOR_STATE.solanaProcessors) {\n if (processor.address === instruction.programAccountId) {\n let res: ProcessResult | null\n if (instruction.parsed) {\n res = processor.handleInstruction(\n JSON.parse(new TextDecoder().decode(instruction.parsed)),\n instruction.slot\n )\n } else if (instruction.instructionData) {\n res = processor.handleInstruction(instruction.instructionData, instruction.slot)\n } else {\n continue\n }\n if (res) {\n res.gauges.forEach((g) => result.gauges.push(g))\n res.counters.forEach((c) => result.counters.push(c))\n res.logs.forEach((l) => result.logs.push(l))\n } else {\n console.warn(\n `Failed to decode the instruction: ${instruction.instructionData} with slot: ${instruction.slot}`\n )\n }\n }\n }\n resolve()\n })\n )\n }\n\n await Promise.all(processorPromises)\n }\n\n recordRuntimeInfo(result, HandlerType.INSTRUCTION)\n return {\n result,\n configUpdated: false,\n }\n }\n\n async processBlocks(request: ProcessBlocksRequest, context: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.blockBindings.map((binding) => this.processBlock(binding))\n const result = mergeProcessResults(await Promise.all(promises))\n\n recordRuntimeInfo(result, HandlerType.BLOCK)\n return {\n result,\n configUpdated: false,\n }\n }\n\n async processBlock(binding: BlockBinding): Promise<ProcessResult> {\n if (!binding.block) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.block.raw)\n\n const block: Block = JSON.parse(jsonString)\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n const promise = this.blockHandlers[handlerId](block).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\\n' + errorString(e))\n })\n promises.push(promise)\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processTraces(request: ProcessBindingsRequest, context: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.bindings.map((binding) => this.processTrace(binding))\n const result = mergeProcessResults(await Promise.all(promises))\n\n recordRuntimeInfo(result, HandlerType.ETH_TRACE)\n return {\n result,\n configUpdated: false,\n }\n }\n\n async processTrace(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n const trace: Trace = JSON.parse(jsonString)\n\n return this.traceHandlers[binding.handlerId](trace).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing trace: ' + jsonString + '\\n' + errorString(e))\n })\n }\n\n async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n const event = JSON.parse(jsonString)\n // only support aptos event for now\n const result = await this.aptosEventHandlers[binding.handlerId](event).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing event: ' + jsonString + '\\n' + errorString(e))\n })\n recordRuntimeInfo(result, HandlerType.APT_EVENT)\n return result\n }\n\n async processAptosCall(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n const call = JSON.parse(jsonString)\n // only support aptos call for now\n const result = await this.aptosCallHandlers[binding.handlerId](call).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing call: ' + jsonString + '\\n' + errorString(e))\n })\n recordRuntimeInfo(result, HandlerType.APT_CALL)\n return result\n }\n}\n\n// https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript\n/* eslint-disable */\nfunction Utf8ArrayToStr(array: Uint8Array) {\n let out, i, len, c\n let char2, char3\n\n out = ''\n len = array.length\n i = 0\n while (i < len) {\n c = array[i++]\n switch (c >> 4) {\n case 0:\n case 1:\n case 2:\n case 3:\n case 4:\n case 5:\n case 6:\n case 7:\n // 0xxxxxxx\n out += String.fromCharCode(c)\n break\n case 12:\n case 13:\n // 110x xxxx 10xx xxxx\n char2 = array[i++]\n out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f))\n break\n case 14:\n // 1110 xxxx 10xx xxxx 10xx xxxx\n char2 = array[i++]\n char3 = array[i++]\n out += String.fromCharCode(((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0))\n break\n }\n }\n\n return out\n}\n\nfunction mergeProcessResults(results: ProcessResult[]): ProcessResult {\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n res.logs = res.logs.concat(r.logs)\n }\n return res\n}\n\nfunction recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {\n results.gauges.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n\n results.counters.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n\n results.logs.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n}\n\nfunction errorString(e: Error): string {\n return e.stack || e.message\n}\n"]}
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AACA,yCAA4D;AAC5D,yCAA+E;AAE/E,+BAoBc;AAGd,gDAAuB;AACvB,+BAAkC;AAGlC,MAAM,iBAAiB,GAAG,cAAI,CAAC,IAAI,CAAA;AAEnC,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAEvC,MAAa,oBAAoB;IACvB,aAAa,GAA+C,EAAE,CAAA;IAC9D,aAAa,GAAiD,EAAE,CAAA;IAChE,aAAa,GAAiD,EAAE,CAAA;IAChE,kBAAkB,GAA+C,EAAE,CAAA;IACnE,iBAAiB,GAA8C,EAAE,CAAA;IAEzE,0CAA0C;IAC1C,0FAA0F;IAC1F,qHAAqH;IAE7G,OAAO,GAAG,KAAK,CAAA;IACf,eAAe,CAAkB;IACjC,iBAAiB,CAAoB;IAC5B,MAAM,CAAY;IAElB,eAAe,CAAa;IAE7C,YAAY,MAAkB,EAAE,eAA4B;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAA6B,EAAE,OAAoB;QACjE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,IAAI,uBAAW,CAAC,kBAAM,CAAC,WAAW,EAAE,s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AAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3B,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACzB,CAAC,CAAC,WAAW,GAAG;YACd,IAAI,EAAE,WAAW;SAClB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,CAAQ;IAC3B,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAA;AAC7B,CAAC","sourcesContent":["import { Block, Log } from '@ethersproject/abstract-provider'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { APTOS_TESTNET_ID, SOL_MAINMET_ID, SUI_DEVNET_ID } from './utils/chain'\n\nimport {\n AptosCallHandlerConfig,\n AptosEventHandlerConfig,\n BlockBinding,\n ContractConfig,\n DataBinding,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessBlocksRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessInstructionsRequest,\n ProcessorServiceImplementation,\n ProcessResult,\n ProcessTransactionsRequest,\n StartRequest,\n TemplateInstance,\n} from './gen'\n\nimport { Empty } from './gen/google/protobuf/empty'\nimport Long from 'long'\nimport { TextDecoder } from 'util'\nimport { Trace } from './core'\n\nconst DEFAULT_MAX_BLOCK = Long.ZERO\n\nconst USER_PROCESSOR = 'user_processor'\n\nexport class ProcessorServiceImpl implements ProcessorServiceImplementation {\n private eventHandlers: ((event: Log) => Promise<ProcessResult>)[] = []\n private traceHandlers: ((trace: Trace) => Promise<ProcessResult>)[] = []\n private blockHandlers: ((block: Block) => Promise<ProcessResult>)[] = []\n private aptosEventHandlers: ((event: any) => Promise<ProcessResult>)[] = []\n private aptosCallHandlers: ((func: any) => Promise<ProcessResult>)[] = []\n\n // map from chain id to list of processors\n // private blockHandlers = new Map<string, ((block: Block) => Promise<ProcessResult>)[]>()\n // private processorsByChainId = new Map<string, BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>>()\n\n private started = false\n private contractConfigs: ContractConfig[]\n private templateInstances: TemplateInstance[]\n private readonly loader: () => void\n\n private readonly shutdownHandler?: () => void\n\n constructor(loader: () => void, shutdownHandler?: () => void) {\n this.loader = loader\n this.shutdownHandler = shutdownHandler\n }\n\n async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n return {\n // TODO project setting\n config: undefined,\n contractConfigs: this.contractConfigs,\n templateInstances: this.templateInstances,\n }\n }\n\n async configure() {\n this.eventHandlers = []\n this.templateInstances = []\n // this.processorsByChainId.clear()\n this.contractConfigs = []\n\n this.templateInstances = [...global.PROCESSOR_STATE.templatesInstances]\n\n // Part 1, prepare EVM processors\n for (const processor of global.PROCESSOR_STATE.processors) {\n // If server favor incremental update this need to change\n // Start basic config for contract\n const chainId = processor.getChainId()\n // this.processorsByChainId.set(chainId, processor)\n\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: processor.config.name,\n chainId: chainId.toString(),\n address: processor.config.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: processor.config.startBlock,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n if (processor.config.endBlock) {\n contractConfig.endBlock = processor.config.endBlock\n }\n\n // Step 1. Prepare all the block handlers\n for (const blockHandler of processor.blockHandlers) {\n const handlerId = this.blockHandlers.push(blockHandler) - 1\n // TODO wrap the block handler into one\n\n contractConfig.blockConfigs.push({\n handlerId: handlerId,\n })\n }\n\n // Step 2. Prepare all trace handlers\n for (const traceHandler of processor.traceHandlers) {\n const handlerId = this.traceHandlers.push(traceHandler.handler) - 1\n contractConfig.traceConfigs.push({\n signature: traceHandler.signature,\n handlerId: handlerId,\n })\n }\n\n // Step 3. Prepare all the event handlers\n for (const eventsHandler of processor.eventHandlers) {\n // associate id with filter\n const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1\n const logConfig: LogHandlerConfig = {\n handlerId: handlerId,\n filters: [],\n }\n\n for (const filter of eventsHandler.filters) {\n if (!filter.topics) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')\n }\n const logFilter: LogFilter = {\n topics: [],\n }\n\n for (const ts of filter.topics) {\n let hashes: string[] = []\n if (Array.isArray(ts)) {\n hashes = hashes.concat(ts)\n } else if (ts) {\n hashes.push(ts)\n }\n logFilter.topics.push({ hashes: hashes })\n }\n logConfig.filters.push(logFilter)\n }\n contractConfig.logConfigs.push(logConfig)\n }\n\n // Finish up a contract\n this.contractConfigs.push(contractConfig)\n }\n\n // Part 2, prepare solana constractors\n for (const solanaProcessor of global.PROCESSOR_STATE.solanaProcessors) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: solanaProcessor.contractName,\n chainId: SOL_MAINMET_ID,\n address: solanaProcessor.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: solanaProcessor.config.startSlot,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: {\n innerInstruction: solanaProcessor.processInnerInstruction,\n parsedInstruction: solanaProcessor.fromParsedInstruction !== null,\n rawDataInstruction: solanaProcessor.decodeInstruction !== null,\n },\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n this.contractConfigs.push(contractConfig)\n }\n\n // Part 3, prepare sui constractors\n for (const suiProcessor of global.PROCESSOR_STATE.suiProcessors) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: 'sui contract',\n chainId: SUI_DEVNET_ID,\n address: suiProcessor.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: suiProcessor.config.startSeqNumber,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n this.contractConfigs.push(contractConfig)\n }\n\n // Part 3, prepare aptos constractors\n for (const aptosProcessor of global.PROCESSOR_STATE.aptosProcessors) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: aptosProcessor.name,\n chainId: APTOS_TESTNET_ID,\n address: aptosProcessor.config.address,\n abi: '',\n },\n blockConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: aptosProcessor.config.startVersion,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n // 1. Prepare event handlers\n for (const handler of aptosProcessor.eventHandlers) {\n const handlerId = this.aptosEventHandlers.push(handler.handler) - 1\n const eventHandlerConfig: AptosEventHandlerConfig = {\n filters: handler.filters,\n handlerId,\n }\n contractConfig.aptosEventConfigs.push(eventHandlerConfig)\n }\n\n // 2. Prepare function handlers\n for (const handler of aptosProcessor.callHandlers) {\n const handlerId = this.aptosCallHandlers.push(handler.handler) - 1\n const functionHandlerConfig: AptosCallHandlerConfig = {\n filters: handler.filters.map((filter) => {\n return {\n function: filter.function,\n typeArguments: filter.typeArguments ?? [],\n withTypeArguments: filter.typeArguments ? true : false,\n }\n }),\n handlerId,\n }\n contractConfig.aptosCallConfigs.push(functionHandlerConfig)\n }\n this.contractConfigs.push(contractConfig)\n }\n }\n\n async start(request: StartRequest, context: CallContext): Promise<Empty> {\n if (this.started) {\n return {}\n }\n\n try {\n this.loader()\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n for (const instance of request.templateInstances) {\n const template = global.PROCESSOR_STATE.templates[instance.templateId]\n if (!template) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Invalid template contract:' + instance)\n }\n if (!instance.contract) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Contract Empty from:' + instance)\n }\n template.bind({\n name: instance.contract.name,\n address: instance.contract.address,\n network: Number(instance.contract.chainId),\n startBlock: instance.startBlock,\n endBlock: instance.endBlock,\n })\n }\n try {\n await this.configure()\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'Failed to start processor : ' + errorString(e))\n }\n this.started = true\n return {}\n }\n\n async stop(request: Empty, context: CallContext): Promise<Empty> {\n console.log('Server Shutting down in 5 seconds')\n if (this.shutdownHandler) {\n setTimeout(this.shutdownHandler, 5000)\n }\n return {}\n }\n\n async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.bindings.map((binding) => this.processBinding(binding))\n const result = mergeProcessResults(await Promise.all(promises))\n\n let updated = false\n if (\n global.PROCESSOR_STATE.templatesInstances &&\n this.templateInstances.length != global.PROCESSOR_STATE.templatesInstances.length\n ) {\n await this.configure()\n updated = true\n }\n\n return {\n result,\n configUpdated: updated,\n }\n }\n\n async processBinding(request: DataBinding, options?: CallContext): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.APT_CALL:\n return this.processAptosFunctionCall(request)\n case HandlerType.APT_EVENT:\n return this.processAptosEvent(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n async processLogs(request: ProcessBindingsRequest, context: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const l of request.bindings) {\n if (!l.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\n }\n // const jsonString = Buffer.from(l.log.raw.buffer).toString(\"utf-8\")\n // const jsonString = String.fromCharCode.apply(null, l.log.raw)\n\n try {\n const jsonString = Utf8ArrayToStr(l.data.raw)\n const log: Log = JSON.parse(jsonString)\n const handler = this.eventHandlers[l.handlerId]\n const promise = handler(log).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing log: ' + jsonString + '\\n' + errorString(e))\n })\n\n promises.push(promise)\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'error parse log: ' + l)\n }\n }\n\n const result = mergeProcessResults(await Promise.all(promises))\n\n let updated = false\n if (\n global.PROCESSOR_STATE.templatesInstances &&\n this.templateInstances.length != global.PROCESSOR_STATE.templatesInstances.length\n ) {\n await this.configure()\n updated = true\n }\n\n recordRuntimeInfo(result, HandlerType.ETH_LOG)\n return {\n result,\n configUpdated: updated,\n }\n }\n\n async processTransactions(\n request: ProcessTransactionsRequest,\n context: CallContext\n ): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service not started.')\n }\n\n const result = ProcessResult.fromPartial({})\n\n if (request.chainId.toLowerCase().startsWith('sui') && global.PROCESSOR_STATE.suiProcessors) {\n const processorPromises: Promise<void>[] = []\n for (const txn of request.transactions) {\n processorPromises.push(\n new Promise((resolve, _) => {\n for (const processor of global.PROCESSOR_STATE.suiProcessors) {\n const res = processor.handleTransaction(\n JSON.parse(new TextDecoder().decode(txn.raw)),\n txn.slot ?? Long.fromNumber(0)\n )\n if (res) {\n res.gauges.forEach((g) => result.gauges.push(g))\n res.counters.forEach((c) => result.counters.push(c))\n res.logs.forEach((l) => result.logs.push(l))\n }\n }\n resolve()\n })\n )\n }\n await Promise.all(processorPromises)\n }\n\n // if (request.chainId.toLowerCase().startsWith('apt') && global.PROCESSOR_STATE.aptosProcessors) {\n // const processorPromises: Promise<void>[] = []\n // for (const txn of request.transactions) {\n // processorPromises.push(\n // new Promise((resolve, _) => {\n // for (const processor of global.PROCESSOR_STATE.aptosProcessors) {\n // if (processor.address === txn.programAccountId!) {\n // const res = processor.handleTransaction(\n // JSON.parse(new TextDecoder().decode(txn.raw)),\n // txn.slot ?? Long.fromNumber(0)\n // )\n // if (res) {\n // res.gauges.forEach((g) => result.gauges.push(g))\n // res.counters.forEach((c) => result.counters.push(c))\n // res.logs.forEach((l) => result.logs.push(l))\n // }\n // }\n // }\n // resolve()\n // })\n // )\n // }\n // await Promise.all(processorPromises)\n // }\n\n recordRuntimeInfo(result, HandlerType.TRANSACTION)\n return {\n result,\n configUpdated: false,\n }\n }\n\n async processInstructions(\n request: ProcessInstructionsRequest,\n context: CallContext\n ): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service not started.')\n }\n\n const result = ProcessResult.fromPartial({})\n\n // Only have instruction handlers for solana processors\n if (global.PROCESSOR_STATE.solanaProcessors) {\n const processorPromises: Promise<void>[] = []\n for (const instruction of request.instructions) {\n if (!instruction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'instruction cannot be null')\n }\n\n processorPromises.push(\n new Promise((resolve, _) => {\n for (const processor of global.PROCESSOR_STATE.solanaProcessors) {\n if (processor.address === instruction.programAccountId) {\n let res: ProcessResult | null\n if (instruction.parsed) {\n res = processor.handleInstruction(\n JSON.parse(new TextDecoder().decode(instruction.parsed)),\n instruction.slot\n )\n } else if (instruction.instructionData) {\n res = processor.handleInstruction(instruction.instructionData, instruction.slot)\n } else {\n continue\n }\n if (res) {\n res.gauges.forEach((g) => result.gauges.push(g))\n res.counters.forEach((c) => result.counters.push(c))\n res.logs.forEach((l) => result.logs.push(l))\n } else {\n console.warn(\n `Failed to decode the instruction: ${instruction.instructionData} with slot: ${instruction.slot}`\n )\n }\n }\n }\n resolve()\n })\n )\n }\n\n await Promise.all(processorPromises)\n }\n\n recordRuntimeInfo(result, HandlerType.INSTRUCTION)\n return {\n result,\n configUpdated: false,\n }\n }\n\n async processBlocks(request: ProcessBlocksRequest, context: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.blockBindings.map((binding) => this.processBlock(binding))\n const result = mergeProcessResults(await Promise.all(promises))\n\n recordRuntimeInfo(result, HandlerType.BLOCK)\n return {\n result,\n configUpdated: false,\n }\n }\n\n async processBlock(binding: BlockBinding): Promise<ProcessResult> {\n if (!binding.block) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.block.raw)\n\n const block: Block = JSON.parse(jsonString)\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n const promise = this.blockHandlers[handlerId](block).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\\n' + errorString(e))\n })\n promises.push(promise)\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processTraces(request: ProcessBindingsRequest, context: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.bindings.map((binding) => this.processTrace(binding))\n const result = mergeProcessResults(await Promise.all(promises))\n\n recordRuntimeInfo(result, HandlerType.ETH_TRACE)\n return {\n result,\n configUpdated: false,\n }\n }\n\n async processTrace(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n const trace: Trace = JSON.parse(jsonString)\n\n return this.traceHandlers[binding.handlerId](trace).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing trace: ' + jsonString + '\\n' + errorString(e))\n })\n }\n\n async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n const event = JSON.parse(jsonString)\n // only support aptos event for now\n const result = await this.aptosEventHandlers[binding.handlerId](event).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing event: ' + jsonString + '\\n' + errorString(e))\n })\n recordRuntimeInfo(result, HandlerType.APT_EVENT)\n return result\n }\n\n async processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n const call = JSON.parse(jsonString)\n // only support aptos call for now\n const result = await this.aptosCallHandlers[binding.handlerId](call).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing call: ' + jsonString + '\\n' + errorString(e))\n })\n recordRuntimeInfo(result, HandlerType.APT_CALL)\n return result\n }\n}\n\n// https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript\n/* eslint-disable */\nfunction Utf8ArrayToStr(array: Uint8Array) {\n let out, i, len, c\n let char2, char3\n\n out = ''\n len = array.length\n i = 0\n while (i < len) {\n c = array[i++]\n switch (c >> 4) {\n case 0:\n case 1:\n case 2:\n case 3:\n case 4:\n case 5:\n case 6:\n case 7:\n // 0xxxxxxx\n out += String.fromCharCode(c)\n break\n case 12:\n case 13:\n // 110x xxxx 10xx xxxx\n char2 = array[i++]\n out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f))\n break\n case 14:\n // 1110 xxxx 10xx xxxx 10xx xxxx\n char2 = array[i++]\n char3 = array[i++]\n out += String.fromCharCode(((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0))\n break\n }\n }\n\n return out\n}\n\nfunction mergeProcessResults(results: ProcessResult[]): ProcessResult {\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n res.logs = res.logs.concat(r.logs)\n }\n return res\n}\n\nfunction recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {\n results.gauges.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n\n results.counters.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n\n results.logs.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n}\n\nfunction errorString(e: Error): string {\n return e.stack || e.message\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { DeepPartial } from '../gen/builtin';
2
- import { MetricValue, ProcessResult } from '@sentio/sdk';
2
+ import { MetricValue, ProcessResult } from '../gen';
3
3
  import { Numberish } from '../core';
4
4
  export declare function MetricValueToNumber(v: DeepPartial<MetricValue> | undefined): Numberish | undefined;
5
5
  export declare function firstCounterValue(result: ProcessResult | undefined, name: string): Numberish | undefined;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.firstGaugeValue = exports.firstCounterValue = exports.MetricValueToNumber = void 0;
4
- const sdk_1 = require("@sentio/sdk");
4
+ const core_1 = require("../core");
5
5
  const ethers_1 = require("ethers");
6
6
  function MetricValueToNumber(v) {
7
7
  if (v === undefined) {
@@ -18,7 +18,7 @@ function MetricValueToNumber(v) {
18
18
  return intValue;
19
19
  }
20
20
  if (v.bigDecimal !== undefined) {
21
- return new sdk_1.BigDecimal(v.bigDecimal);
21
+ return new core_1.BigDecimal(v.bigDecimal);
22
22
  }
23
23
  return undefined;
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"metric-utils.js","sourceRoot":"","sources":["../../src/testing/metric-utils.ts"],"names":[],"mappings":";;;AACA,qCAAoE;AAEpE,mCAAkC;AAElC,SAAgB,mBAAmB,CAAC,CAAuC;IACzE,IAAI,CAAC,KAAK,SAAS,EAAE;QACnB,OAAO,SAAS,CAAA;KACjB;IAED,IAAI,CAAC,CAAC,WA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ial } from '../gen/builtin'\nimport { BigDecimal, MetricValue, ProcessResult } from '@sentio/sdk'\nimport { Numberish } from '../core'\nimport { BigNumber } from 'ethers'\n\nexport function MetricValueToNumber(v: DeepPartial<MetricValue> | undefined): Numberish | undefined {\n if (v === undefined) {\n return undefined\n }\n\n if (v.doubleValue !== undefined) {\n return v.doubleValue\n }\n if (v.bigInteger !== undefined) {\n let intValue = BigNumber.from(v.bigInteger.data).toBigInt()\n if (v.bigInteger.negative) {\n intValue = -intValue\n }\n return intValue\n }\n if (v.bigDecimal !== undefined) {\n return new BigDecimal(v.bigDecimal)\n }\n return undefined\n}\n\nexport function firstCounterValue(result: ProcessResult | undefined, name: string): Numberish | undefined {\n if (!result) {\n return undefined\n }\n for (const counter of result.counters) {\n if (counter.metadata?.descriptor?.name === name) {\n return MetricValueToNumber(counter.metricValue)\n }\n }\n return undefined\n}\n\nexport function firstGaugeValue(result: ProcessResult | undefined, name: string): Numberish | undefined {\n if (!result) {\n return undefined\n }\n for (const gauge of result.gauges) {\n if (gauge.metadata?.descriptor?.name === name) {\n return MetricValueToNumber(gauge.metricValue)\n }\n }\n return undefined\n}\n"]}
1
+ {"version":3,"file":"metric-utils.js","sourceRoot":"","sources":["../../src/testing/metric-utils.ts"],"names":[],"mappings":";;;AAEA,kCAA+C;AAC/C,mCAAkC;AAElC,SAAgB,mBAAmB,CAAC,CAAuC;IACzE,IAAI,CAAC,KAAK,SAAS,EAAE;QACnB,OAAO,SAAS,CAAA;KACjB;IAED,IAAI,CAAC,CAAC,WAAW,KAAK,SAAS,EAAE;QAC/B,OAAO,CAAC,CAAC,WAAW,CAAA;KACrB;IACD,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS,EAAE;QAC9B,IAAI,QAAQ,GAAG,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC3D,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE;YACzB,QAAQ,GAAG,CAAC,QAAQ,CAAA;SACrB;QACD,OAAO,QAAQ,CAAA;KAChB;IACD,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS,EAAE;QAC9B,OAAO,IAAI,iBAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;KACpC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAnBD,kDAmBC;AAED,SAAgB,iBAAiB,CAAC,MAAiC,EAAE,IAAY;IAC/E,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,SAAS,CAAA;KACjB;IACD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE;QACrC,IAAI,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,KAAK,IAAI,EAAE;YAC/C,OAAO,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;SAChD;KACF;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAVD,8CAUC;AAED,SAAgB,eAAe,CAAC,MAAiC,EAAE,IAAY;IAC7E,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,SAAS,CAAA;KACjB;IACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE;QACjC,IAAI,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,KAAK,IAAI,EAAE;YAC7C,OAAO,mBAAmB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;SAC9C;KACF;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAVD,0CAUC","sourcesContent":["import { DeepPartial } from '../gen/builtin'\nimport { MetricValue, ProcessResult } from '../gen'\nimport { Numberish, BigDecimal } from '../core'\nimport { BigNumber } from 'ethers'\n\nexport function MetricValueToNumber(v: DeepPartial<MetricValue> | undefined): Numberish | undefined {\n if (v === undefined) {\n return undefined\n }\n\n if (v.doubleValue !== undefined) {\n return v.doubleValue\n }\n if (v.bigInteger !== undefined) {\n let intValue = BigNumber.from(v.bigInteger.data).toBigInt()\n if (v.bigInteger.negative) {\n intValue = -intValue\n }\n return intValue\n }\n if (v.bigDecimal !== undefined) {\n return new BigDecimal(v.bigDecimal)\n }\n return undefined\n}\n\nexport function firstCounterValue(result: ProcessResult | undefined, name: string): Numberish | undefined {\n if (!result) {\n return undefined\n }\n for (const counter of result.counters) {\n if (counter.metadata?.descriptor?.name === name) {\n return MetricValueToNumber(counter.metricValue)\n }\n }\n return undefined\n}\n\nexport function firstGaugeValue(result: ProcessResult | undefined, name: string): Numberish | undefined {\n if (!result) {\n return undefined\n }\n for (const gauge of result.gauges) {\n if (gauge.metadata?.descriptor?.name === name) {\n return MetricValueToNumber(gauge.metricValue)\n }\n }\n return undefined\n}\n"]}
@@ -3,6 +3,7 @@ import { CallContext } from 'nice-grpc-common';
3
3
  import { Empty } from '../gen/google/protobuf/empty';
4
4
  import { Block, Log } from '@ethersproject/abstract-provider';
5
5
  import { Networkish } from '@ethersproject/providers';
6
+ export declare const TEST_CONTEXT: CallContext;
6
7
  export declare class TestProcessorServer implements ProcessorServiceImplementation {
7
8
  service: ProcessorServiceImpl;
8
9
  contractConfig: ContractConfig[];
@@ -30,5 +31,5 @@ export declare class TestProcessorServer implements ProcessorServiceImplementati
30
31
  buildBlockBinding(block: Partial<Block> & {
31
32
  number: number;
32
33
  }, network?: Networkish): BlockBinding;
33
- processBindings(request: ProcessBindingsRequest, context: CallContext): Promise<ProcessBindingResponse>;
34
+ processBindings(request: ProcessBindingsRequest, context?: CallContext): Promise<ProcessBindingResponse>;
34
35
  }
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TestProcessorServer = void 0;
6
+ exports.TestProcessorServer = exports.TEST_CONTEXT = void 0;
7
7
  const sdk_1 = require("@sentio/sdk");
8
8
  const chain_1 = require("../utils/chain");
9
9
  const long_1 = __importDefault(require("long"));
10
10
  const providers_1 = require("@ethersproject/providers");
11
- const TEST_CONTEXT = {};
11
+ exports.TEST_CONTEXT = {};
12
12
  function cleanTest() {
13
13
  global.PROCESSOR_STATE = new sdk_1.ProcessorState();
14
14
  }
@@ -28,30 +28,30 @@ class TestProcessorServer {
28
28
  }
29
29
  (0, sdk_1.setProvider)(dummyConfig);
30
30
  }
31
- async start(request = { templateInstances: [] }, context = TEST_CONTEXT) {
31
+ async start(request = { templateInstances: [] }, context = exports.TEST_CONTEXT) {
32
32
  const res = await this.service.start(request, context);
33
33
  this.contractConfig = (await this.getConfig({})).contractConfigs;
34
34
  return res;
35
35
  }
36
- stop(request, context = TEST_CONTEXT) {
36
+ stop(request, context = exports.TEST_CONTEXT) {
37
37
  return this.service.stop(request, context);
38
38
  }
39
- getConfig(request, context = TEST_CONTEXT) {
39
+ getConfig(request, context = exports.TEST_CONTEXT) {
40
40
  return this.service.getConfig(request, context);
41
41
  }
42
- processBlocks(request, context = TEST_CONTEXT) {
42
+ processBlocks(request, context = exports.TEST_CONTEXT) {
43
43
  return this.service.processBlocks(request, context);
44
44
  }
45
- processInstructions(request, context = TEST_CONTEXT) {
45
+ processInstructions(request, context = exports.TEST_CONTEXT) {
46
46
  return this.service.processInstructions(request, context);
47
47
  }
48
- processLogs(request, context = TEST_CONTEXT) {
48
+ processLogs(request, context = exports.TEST_CONTEXT) {
49
49
  return this.service.processLogs(request, context);
50
50
  }
51
- processTraces(request, context = TEST_CONTEXT) {
51
+ processTraces(request, context = exports.TEST_CONTEXT) {
52
52
  return this.service.processTraces(request, context);
53
53
  }
54
- processTransactions(request, context = TEST_CONTEXT) {
54
+ processTransactions(request, context = exports.TEST_CONTEXT) {
55
55
  return this.service.processTransactions(request, context);
56
56
  }
57
57
  testTrace(trace, network = 1) {
@@ -194,7 +194,7 @@ class TestProcessorServer {
194
194
  }
195
195
  return binding;
196
196
  }
197
- processBindings(request, context) {
197
+ processBindings(request, context = exports.TEST_CONTEXT) {
198
198
  return this.service.processBindings(request, context);
199
199
  }
200
200
  }