@sentio/sdk 1.23.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/lib/aptos/aptos-processor.js +6 -18
  2. package/lib/aptos/aptos-processor.js.map +1 -1
  3. package/lib/aptos/context.d.ts +1 -1
  4. package/lib/aptos/context.js +1 -0
  5. package/lib/aptos/context.js.map +1 -1
  6. package/lib/core/base-processor.js +6 -25
  7. package/lib/core/base-processor.js.map +1 -1
  8. package/lib/core/context.d.ts +7 -5
  9. package/lib/core/context.js +15 -0
  10. package/lib/core/context.js.map +1 -1
  11. package/lib/core/event-tracker.d.ts +22 -0
  12. package/lib/core/event-tracker.js +53 -0
  13. package/lib/core/event-tracker.js.map +1 -0
  14. package/lib/core/index.d.ts +1 -0
  15. package/lib/core/index.js +4 -1
  16. package/lib/core/index.js.map +1 -1
  17. package/lib/core/solana-processor.js +1 -5
  18. package/lib/core/solana-processor.js.map +1 -1
  19. package/lib/core/sui-processor.js +1 -5
  20. package/lib/core/sui-processor.js.map +1 -1
  21. package/lib/gen/processor/protos/processor.d.ts +72 -0
  22. package/lib/gen/processor/protos/processor.js +481 -2
  23. package/lib/gen/processor/protos/processor.js.map +1 -1
  24. package/lib/processor-state.d.ts +4 -0
  25. package/lib/processor-state.js +2 -0
  26. package/lib/processor-state.js.map +1 -1
  27. package/lib/service.d.ts +2 -0
  28. package/lib/service.js +24 -1
  29. package/lib/service.js.map +1 -1
  30. package/lib/tests/erc20.js +3 -0
  31. package/lib/tests/erc20.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/aptos/aptos-processor.ts +6 -18
  34. package/src/aptos/context.ts +2 -1
  35. package/src/core/base-processor.ts +5 -25
  36. package/src/core/context.ts +29 -5
  37. package/src/core/event-tracker.ts +66 -0
  38. package/src/core/index.ts +1 -0
  39. package/src/core/solana-processor.ts +1 -5
  40. package/src/core/sui-processor.ts +1 -5
  41. package/src/gen/processor/protos/processor.ts +600 -1
  42. package/src/processor-state.ts +6 -0
  43. package/src/service.ts +28 -1
  44. package/src/tests/erc20.ts +4 -0
@@ -3,6 +3,8 @@ import { AptosBaseProcessor } from './aptos';
3
3
  import { BaseContract } from 'ethers';
4
4
  import { TemplateInstance } from './gen';
5
5
  import { Provider } from '@ethersproject/providers';
6
+ import { EventTracker } from './core';
7
+ import { Metric } from './core/meter';
6
8
  export declare class ProcessorState {
7
9
  contracts: Map<string, ContractView<BaseContract>>;
8
10
  processors: BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>[];
@@ -13,4 +15,6 @@ export declare class ProcessorState {
13
15
  solanaProcessors: SolanaBaseProcessor[];
14
16
  suiProcessors: SuiBaseProcessor[];
15
17
  aptosProcessors: AptosBaseProcessor[];
18
+ eventTrackers: EventTracker[];
19
+ metrics: Metric[];
16
20
  }
@@ -17,6 +17,8 @@ class ProcessorState {
17
17
  solanaProcessors = [];
18
18
  suiProcessors = [];
19
19
  aptosProcessors = [];
20
+ eventTrackers = [];
21
+ metrics = [];
20
22
  }
21
23
  exports.ProcessorState = ProcessorState;
22
24
  //# sourceMappingURL=processor-state.js.map
@@ -1 +1 @@
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'\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":";;;AAiBA,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;IAE1C,aAAa,GAAmB,EAAE,CAAA;IAElC,OAAO,GAAa,EAAE,CAAA;CACvB;AAvBD,wCAuBC","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'\nimport { Provider } from '@ethersproject/providers'\nimport { EventTracker } from './core'\nimport { Metric } from './core/meter'\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 eventTrackers: EventTracker[] = []\n\n metrics: Metric[] = []\n}\n"]}
package/lib/service.d.ts CHANGED
@@ -10,6 +10,8 @@ export declare class ProcessorServiceImpl implements ProcessorServiceImplementat
10
10
  private started;
11
11
  private contractConfigs;
12
12
  private templateInstances;
13
+ private metricConfigs;
14
+ private eventTrackingConfigs;
13
15
  private readonly loader;
14
16
  private readonly shutdownHandler?;
15
17
  constructor(loader: () => void, shutdownHandler?: () => void);
package/lib/service.js CHANGED
@@ -23,6 +23,8 @@ class ProcessorServiceImpl {
23
23
  started = false;
24
24
  contractConfigs;
25
25
  templateInstances;
26
+ metricConfigs;
27
+ eventTrackingConfigs;
26
28
  loader;
27
29
  shutdownHandler;
28
30
  constructor(loader, shutdownHandler) {
@@ -38,6 +40,8 @@ class ProcessorServiceImpl {
38
40
  config: undefined,
39
41
  contractConfigs: this.contractConfigs,
40
42
  templateInstances: this.templateInstances,
43
+ eventTrackingConfigs: this.eventTrackingConfigs,
44
+ metricConfigs: this.metricConfigs,
41
45
  accountConfigs: [],
42
46
  };
43
47
  }
@@ -47,6 +51,24 @@ class ProcessorServiceImpl {
47
51
  // this.processorsByChainId.clear()
48
52
  this.contractConfigs = [];
49
53
  this.templateInstances = [...global.PROCESSOR_STATE.templatesInstances];
54
+ this.eventTrackingConfigs = [];
55
+ this.metricConfigs = [];
56
+ // part 0, prepare metrics and event tracking configs
57
+ for (const metric of global.PROCESSOR_STATE.metrics) {
58
+ this.metricConfigs.push({
59
+ ...metric.descriptor,
60
+ });
61
+ }
62
+ for (const eventTracker of global.PROCESSOR_STATE.eventTrackers) {
63
+ this.eventTrackingConfigs.push({
64
+ distinctAggregationByDays: eventTracker.options.distinctByDays || [],
65
+ eventName: eventTracker.eventName,
66
+ retentionConfig: undefined,
67
+ totalByDay: eventTracker.options.totalByDay || false,
68
+ totalPerEntity: undefined,
69
+ unique: eventTracker.options.unique || false,
70
+ });
71
+ }
50
72
  // Part 1, prepare EVM processors
51
73
  for (const processor of global.PROCESSOR_STATE.processors) {
52
74
  // If server favor incremental update this need to change
@@ -167,7 +189,7 @@ class ProcessorServiceImpl {
167
189
  };
168
190
  this.contractConfigs.push(contractConfig);
169
191
  }
170
- // Part 3, prepare aptos constractors
192
+ // Part 4, prepare aptos constractors
171
193
  for (const aptosProcessor of global.PROCESSOR_STATE.aptosProcessors) {
172
194
  const contractConfig = {
173
195
  processorType: USER_PROCESSOR,
@@ -544,6 +566,7 @@ function mergeProcessResults(results) {
544
566
  res.counters = res.counters.concat(r.counters);
545
567
  res.gauges = res.gauges.concat(r.gauges);
546
568
  res.logs = res.logs.concat(r.logs);
569
+ res.events = res.events.concat(res.events);
547
570
  }
548
571
  return res;
549
572
  }
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AACA,yCAA4D;AAC5D,yCAA6D;AAE7D,+BAoBc;AAGd,gDAAuB;AACvB,+BAAkC;AAIlC,MAAM,iBAAiB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,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 { 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'\nimport { Instruction } from '@project-serum/anchor'\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 accountConfigs: [],\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.moduleName,\n chainId: aptosProcessor.getChainId(),\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.map((f) => {\n return {\n type: f.type,\n account: f.account || '',\n }\n }),\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 includeFailed: filter.includeFailed || 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 parsedInstruction: Instruction | null = null\n if (instruction.parsed) {\n parsedInstruction = processor.getParsedInstruction(\n JSON.parse(new TextDecoder().decode(instruction.parsed))\n )\n } else if (instruction.instructionData) {\n parsedInstruction = processor.getParsedInstruction(instruction.instructionData)\n }\n if (parsedInstruction == null) {\n continue\n }\n const insHandler = processor.getInstructionHandler(parsedInstruction)\n if (insHandler == null) {\n continue\n }\n const res = processor.handleInstruction(\n parsedInstruction,\n instruction.accounts,\n insHandler,\n instruction.slot\n )\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\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
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AACA,yCAA4D;AAC5D,yCAA6D;AAE7D,+BAsBc;AAGd,gDAAuB;AACvB,+BAAkC;AAIlC,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;IACrC,aAAa,CAAgB;IAC7B,oBAAoB,CAAuB;IAClC,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,sBAAsB,CAAC,CAAA;SAClE;Q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AC;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 { SOL_MAINMET_ID, SUI_DEVNET_ID } from './utils/chain'\n\nimport {\n AptosCallHandlerConfig,\n AptosEventHandlerConfig,\n BlockBinding,\n ContractConfig,\n DataBinding,\n EventTrackingConfig,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n MetricConfig,\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'\nimport { Instruction } from '@project-serum/anchor'\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 metricConfigs: MetricConfig[]\n private eventTrackingConfigs: EventTrackingConfig[]\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 eventTrackingConfigs: this.eventTrackingConfigs,\n metricConfigs: this.metricConfigs,\n accountConfigs: [],\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 this.eventTrackingConfigs = []\n this.metricConfigs = []\n\n // part 0, prepare metrics and event tracking configs\n for (const metric of global.PROCESSOR_STATE.metrics) {\n this.metricConfigs.push({\n ...metric.descriptor,\n })\n }\n\n for (const eventTracker of global.PROCESSOR_STATE.eventTrackers) {\n this.eventTrackingConfigs.push({\n distinctAggregationByDays: eventTracker.options.distinctByDays || [],\n eventName: eventTracker.eventName,\n retentionConfig: undefined,\n totalByDay: eventTracker.options.totalByDay || false,\n totalPerEntity: undefined,\n unique: eventTracker.options.unique || false,\n })\n }\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 4, 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.moduleName,\n chainId: aptosProcessor.getChainId(),\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.map((f) => {\n return {\n type: f.type,\n account: f.account || '',\n }\n }),\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 includeFailed: filter.includeFailed || 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 parsedInstruction: Instruction | null = null\n if (instruction.parsed) {\n parsedInstruction = processor.getParsedInstruction(\n JSON.parse(new TextDecoder().decode(instruction.parsed))\n )\n } else if (instruction.instructionData) {\n parsedInstruction = processor.getParsedInstruction(instruction.instructionData)\n }\n if (parsedInstruction == null) {\n continue\n }\n const insHandler = processor.getInstructionHandler(parsedInstruction)\n if (insHandler == null) {\n continue\n }\n const res = processor.handleInstruction(\n parsedInstruction,\n instruction.accounts,\n insHandler,\n instruction.slot\n )\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\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 res.events = res.events.concat(res.events)\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"]}
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.filter = void 0;
4
4
  const erc20_1 = require("../builtin/erc20");
5
+ const event_tracker_1 = require("../core/event-tracker");
5
6
  exports.filter = erc20_1.ERC20Processor.filters.Transfer('0x0000000000000000000000000000000000000000', '0xb329e39ebefd16f40d38f07643652ce17ca5bac1');
7
+ const tracker = event_tracker_1.EventTracker.register('sdf');
6
8
  const processorTemplate = new erc20_1.ERC20ProcessorTemplate().onEventTransfer(async function (event, ctx) {
7
9
  console.log('');
8
10
  });
@@ -26,6 +28,7 @@ erc20_1.ERC20Processor.bind({
26
28
  erc20_1.ERC20Processor.bind({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', network: 56, name: 'usdc' })
27
29
  .onEventTransfer(async function (event, ctx) {
28
30
  ctx.meter.Counter('c2').add(2);
31
+ tracker.trackEvent(ctx, { distinctId: event.args.from });
29
32
  }, exports.filter)
30
33
  .onBlock(async function (block, ctx) {
31
34
  ctx.meter.Gauge('g2').record(20, { k: 'v' });
@@ -1 +1 @@
1
- {"version":3,"file":"erc20.js","sourceRoot":"","sources":["../../src/tests/erc20.ts"],"names":[],"mappings":";;;AAAA,4CAAyE;AAE5D,QAAA,MAAM,GAAG,sBAAc,CAAC,OAAO,CAAC,QAAQ,CACnD,4CAA4C,EAC5C,4CAA4C,CAC7C,CAAA;AAED,MAAM,iBAAiB,GAAG,IAAI,8BAAsB,EAAE,CAAC,eAAe,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IAC/F,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA;AAEF,sBAAc,CAAC,IAAI,CAAC;IAClB,OAAO,EAAE,4CAA4C;IACrD,cAAc;IACd,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,QAAQ;CACrB,CAAC;KACC,eAAe,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IACzC,iBAAiB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,4CAA4C,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IAC9G,4EAA4E;IAC5E,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChC,CAAC,EAAE,cAAM,CAAC;KACT,OAAO,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IACjC,GAA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I,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;AAEpF,2CAA2C;AAC3C,8CAA8C;AAC9C,qCAAqC;AACrC,eAAe;AACf,2CAA2C;AAC3C,mDAAmD;AACnD,OAAO","sourcesContent":["import { ERC20Processor, ERC20ProcessorTemplate } from '../builtin/erc20'\n\nexport const filter = ERC20Processor.filters.Transfer(\n '0x0000000000000000000000000000000000000000',\n '0xb329e39ebefd16f40d38f07643652ce17ca5bac1'\n)\n\nconst processorTemplate = new ERC20ProcessorTemplate().onEventTransfer(async function (event, ctx) {\n console.log('')\n})\n\nERC20Processor.bind({\n address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9',\n // network: 1,\n name: 'x2y2',\n startBlock: 14201940,\n})\n .onEventTransfer(async function (event, ctx) {\n processorTemplate.bind({ address: '0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9', network: 3, name: 'dynamic' })\n // template.bind('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 3, 'dynamic')\n ctx.meter.Counter('c1').add(1)\n }, filter)\n .onBlock(async function (block, ctx) {\n ctx.meter.Gauge('g1').record(10, { k: 'v' })\n })\n .onCallApprove(function (call, ctx) {\n ctx.meter.Counter('added').add(call.args.amount, { spender: call.args.spender })\n })\n\nERC20Processor.bind({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', network: 56, name: 'usdc' })\n .onEventTransfer(async function (event, ctx) {\n ctx.meter.Counter('c2').add(2)\n }, filter)\n .onBlock(async function (block, ctx) {\n ctx.meter.Gauge('g2').record(20, { k: 'v' })\n })\n// .onEventApproval(async function (event, ctx) {\n// BigNumber.from(10 ** 18)\n// // console.log(n)\n// })\nERC20Processor.bind({ address: 'xxxx', network: 56 })\n\nERC20Processor.bind({ address: 'yyyy', network: 1 })\nERC20Processor.bind({ address: 'yyyy', network: 1 })\nERC20Processor.bind({ address: 'yyyy', network: 1, startBlock: 21, name: 'ytoken' })\n\n// const template = Erc20Processor.template\n// .onTransfer(async function (event, ctx) {\n// ctx.meter.Counter('c2').add(2)\n// }, filter)\n// .onBlock(async function (block, ctx) {\n// ctx.meter.Gauge('h1').record(20, { k: 'v' })\n// })\n"]}
1
+ {"version":3,"file":"erc20.js","sourceRoot":"","sources":["../../src/tests/erc20.ts"],"names":[],"mappings":";;;AAAA,4CAAyE;AACzE,yDAAoD;AAEvC,QAAA,MAAM,GAAG,sBAAc,CAAC,OAAO,CAAC,QAAQ,CACnD,4CAA4C,EAC5C,4CAA4C,CAC7C,CAAA;AAED,MAAM,OAAO,GAAG,4BAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAE5C,MAAM,iBAAiB,GAAG,IAAI,8BAAsB,EAAE,CAAC,eAAe,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IAC/F,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA;AAEF,sBAAc,CAAC,IAAI,CAAC;IAClB,OAAO,EAAE,4CAA4C;IACrD,cAAc;IACd,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,QAAQ;CACrB,CAAC;KACC,eAAe,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IACzC,iBAAiB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,4CAA4C,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IAC9G,4EAA4E;IAC5E,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChC,CAAC,EAAE,cAAM,CAAC;KACT,OAAO,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IACjC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,E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AACpD,sBAAc,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;AAEpF,2CAA2C;AAC3C,8CAA8C;AAC9C,qCAAqC;AACrC,eAAe;AACf,2CAA2C;AAC3C,mDAAmD;AACnD,OAAO","sourcesContent":["import { ERC20Processor, ERC20ProcessorTemplate } from '../builtin/erc20'\nimport { EventTracker } from '../core/event-tracker'\n\nexport const filter = ERC20Processor.filters.Transfer(\n '0x0000000000000000000000000000000000000000',\n '0xb329e39ebefd16f40d38f07643652ce17ca5bac1'\n)\n\nconst tracker = EventTracker.register('sdf')\n\nconst processorTemplate = new ERC20ProcessorTemplate().onEventTransfer(async function (event, ctx) {\n console.log('')\n})\n\nERC20Processor.bind({\n address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9',\n // network: 1,\n name: 'x2y2',\n startBlock: 14201940,\n})\n .onEventTransfer(async function (event, ctx) {\n processorTemplate.bind({ address: '0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9', network: 3, name: 'dynamic' })\n // template.bind('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 3, 'dynamic')\n ctx.meter.Counter('c1').add(1)\n }, filter)\n .onBlock(async function (block, ctx) {\n ctx.meter.Gauge('g1').record(10, { k: 'v' })\n })\n .onCallApprove(function (call, ctx) {\n ctx.meter.Counter('added').add(call.args.amount, { spender: call.args.spender })\n })\n\nERC20Processor.bind({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', network: 56, name: 'usdc' })\n .onEventTransfer(async function (event, ctx) {\n ctx.meter.Counter('c2').add(2)\n tracker.trackEvent(ctx, { distinctId: event.args.from })\n }, filter)\n .onBlock(async function (block, ctx) {\n ctx.meter.Gauge('g2').record(20, { k: 'v' })\n })\n// .onEventApproval(async function (event, ctx) {\n// BigNumber.from(10 ** 18)\n// // console.log(n)\n// })\nERC20Processor.bind({ address: 'xxxx', network: 56 })\n\nERC20Processor.bind({ address: 'yyyy', network: 1 })\nERC20Processor.bind({ address: 'yyyy', network: 1 })\nERC20Processor.bind({ address: 'yyyy', network: 1, startBlock: 21, name: 'ytoken' })\n\n// const template = Erc20Processor.template\n// .onTransfer(async function (event, ctx) {\n// ctx.meter.Counter('c2').add(2)\n// }, filter)\n// .onBlock(async function (block, ctx) {\n// ctx.meter.Gauge('h1').record(20, { k: 'v' })\n// })\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "1.23.0",
4
+ "version": "1.24.0",
5
5
  "scripts": {
6
6
  "compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
7
7
  "compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli && cp src/utils/*.csv lib/utils",
@@ -85,13 +85,9 @@ export class AptosBaseProcessor {
85
85
  tx
86
86
  )
87
87
  if (tx) {
88
- handler(tx, ctx)
89
- }
90
- return {
91
- gauges: ctx.gauges,
92
- counters: ctx.counters,
93
- logs: ctx.logs,
88
+ await handler(tx, ctx)
94
89
  }
90
+ return ctx.getProcessResult()
95
91
  },
96
92
  filters: [],
97
93
  })
@@ -130,14 +126,10 @@ export class AptosBaseProcessor {
130
126
  txn.events = []
131
127
  for (const evt of events) {
132
128
  const decoded = processor.decodeEvent(evt as EventInstance)
133
- handler(decoded, ctx)
129
+ await handler(decoded, ctx)
134
130
  }
135
131
  }
136
- return {
137
- gauges: ctx.gauges,
138
- counters: ctx.counters,
139
- logs: ctx.logs,
140
- }
132
+ return ctx.getProcessResult()
141
133
  },
142
134
  filters: _filters,
143
135
  })
@@ -173,13 +165,9 @@ export class AptosBaseProcessor {
173
165
  if (tx) {
174
166
  const payload = tx.payload as TransactionPayload_EntryFunctionPayload
175
167
  const decoded = processor.decodeFunctionPayload(payload)
176
- handler(decoded, ctx)
177
- }
178
- return {
179
- gauges: ctx.gauges,
180
- counters: ctx.counters,
181
- logs: ctx.logs,
168
+ await handler(decoded, ctx)
182
169
  }
170
+ return ctx.getProcessResult()
183
171
  },
184
172
  filters: _filters,
185
173
  })
@@ -30,7 +30,7 @@ export class AptosContext extends BaseContext {
30
30
  }
31
31
  }
32
32
 
33
- getMetaData(descriptor: DataDescriptor | undefined, labels: Labels): RecordMetaData {
33
+ getMetaData(descriptor: DataDescriptor, labels: Labels): RecordMetaData {
34
34
  return {
35
35
  address: this.address,
36
36
  contractName: this.moduleName,
@@ -40,6 +40,7 @@ export class AptosContext extends BaseContext {
40
40
  logIndex: 0,
41
41
  chainId: getChainId(this.network),
42
42
  dataDescriptor: descriptor,
43
+ name: descriptor.name,
43
44
  labels: normalizeLabels(labels),
44
45
  }
45
46
  }
@@ -98,17 +98,9 @@ export abstract class BaseProcessor<
98
98
 
99
99
  // TODO fix this bug
100
100
  await handler(event, ctx)
101
- return {
102
- gauges: ctx.gauges,
103
- counters: ctx.counters,
104
- logs: ctx.logs,
105
- }
106
- }
107
- return {
108
- gauges: [],
109
- counters: [],
110
- logs: [],
101
+ return ctx.getProcessResult()
111
102
  }
103
+ return ProcessResult.fromPartial({})
112
104
  },
113
105
  })
114
106
  return this
@@ -128,11 +120,7 @@ export abstract class BaseProcessor<
128
120
  undefined
129
121
  )
130
122
  await handler(block, ctx)
131
- return {
132
- gauges: ctx.gauges,
133
- counters: ctx.counters,
134
- logs: ctx.logs,
135
- }
123
+ return ctx.getProcessResult()
136
124
  })
137
125
  return this
138
126
  }
@@ -163,11 +151,7 @@ export abstract class BaseProcessor<
163
151
  const contractInterface = contractView.rawContract.interface
164
152
  const fragment = contractInterface.getFunction(signature)
165
153
  if (!trace.action.input) {
166
- return {
167
- gauges: [],
168
- counters: [],
169
- logs: [],
170
- }
154
+ return ProcessResult.fromPartial({})
171
155
  }
172
156
  const traceData = '0x' + trace.action.input.slice(10)
173
157
  trace.args = contractInterface._abiCoder.decode(fragment.inputs, traceData)
@@ -181,11 +165,7 @@ export abstract class BaseProcessor<
181
165
  trace
182
166
  )
183
167
  await handler(trace, ctx)
184
- return {
185
- gauges: ctx.gauges,
186
- counters: ctx.counters,
187
- logs: ctx.logs,
188
- }
168
+ return ctx.getProcessResult()
189
169
  },
190
170
  })
191
171
  return this
@@ -1,4 +1,12 @@
1
- import { CounterResult, GaugeResult, LogResult, DataDescriptor, RecordMetaData } from '../gen'
1
+ import {
2
+ CounterResult,
3
+ GaugeResult,
4
+ LogResult,
5
+ DataDescriptor,
6
+ RecordMetaData,
7
+ EventTrackingResult,
8
+ ProcessResult,
9
+ } from '../gen'
2
10
  import { BaseContract, EventFilter } from 'ethers'
3
11
  import { Block, Log } from '@ethersproject/abstract-provider'
4
12
  import { Meter, normalizeLabels } from './meter'
@@ -12,6 +20,7 @@ export abstract class BaseContext {
12
20
  gauges: GaugeResult[] = []
13
21
  counters: CounterResult[] = []
14
22
  logs: LogResult[] = []
23
+ events: EventTrackingResult[] = []
15
24
  meter: Meter
16
25
  logger: Logger
17
26
 
@@ -20,7 +29,17 @@ export abstract class BaseContext {
20
29
  this.logger = new Logger(this)
21
30
  }
22
31
 
23
- abstract getMetaData(descriptor: DataDescriptor | undefined, labels: Labels): RecordMetaData
32
+ getProcessResult(): ProcessResult {
33
+ const res: ProcessResult = {
34
+ gauges: this.gauges,
35
+ counters: this.counters,
36
+ logs: this.logs,
37
+ events: this.events,
38
+ }
39
+ return res
40
+ }
41
+
42
+ abstract getMetaData(descriptor: DataDescriptor, labels: Labels): RecordMetaData
24
43
  }
25
44
 
26
45
  export abstract class EthContext extends BaseContext {
@@ -72,7 +91,7 @@ export class ContractContext<
72
91
  this.contract = view
73
92
  }
74
93
 
75
- getMetaData(descriptor: DataDescriptor | undefined, labels: Labels): RecordMetaData {
94
+ getMetaData(descriptor: DataDescriptor, labels: Labels): RecordMetaData {
76
95
  if (this.log) {
77
96
  return {
78
97
  address: this.contract.rawContract.address,
@@ -83,6 +102,7 @@ export class ContractContext<
83
102
  logIndex: this.log.logIndex,
84
103
  chainId: this.chainId.toString(),
85
104
  dataDescriptor: descriptor,
105
+ name: descriptor.name,
86
106
  labels: normalizeLabels(labels),
87
107
  }
88
108
  }
@@ -96,6 +116,7 @@ export class ContractContext<
96
116
  logIndex: -1,
97
117
  chainId: this.chainId.toString(),
98
118
  dataDescriptor: descriptor,
119
+ name: descriptor.name,
99
120
  labels: normalizeLabels(labels),
100
121
  }
101
122
  }
@@ -109,6 +130,7 @@ export class ContractContext<
109
130
  logIndex: -1,
110
131
  chainId: this.chainId.toString(),
111
132
  dataDescriptor: descriptor,
133
+ name: descriptor.name,
112
134
  labels: normalizeLabels(labels),
113
135
  }
114
136
  }
@@ -168,7 +190,7 @@ export class SolanaContext extends BaseContext {
168
190
  this.blockNumber = slot
169
191
  }
170
192
 
171
- getMetaData(descriptor: DataDescriptor | undefined, labels: Labels): RecordMetaData {
193
+ getMetaData(descriptor: DataDescriptor, labels: Labels): RecordMetaData {
172
194
  return {
173
195
  address: this.address,
174
196
  contractName: this.programName,
@@ -178,6 +200,7 @@ export class SolanaContext extends BaseContext {
178
200
  logIndex: 0,
179
201
  chainId: SOL_MAINMET_ID, // TODO set in context
180
202
  dataDescriptor: descriptor,
203
+ name: descriptor.name,
181
204
  labels: normalizeLabels(labels),
182
205
  }
183
206
  }
@@ -194,7 +217,7 @@ export class SuiContext extends BaseContext {
194
217
  this.blockNumber = slot
195
218
  }
196
219
 
197
- getMetaData(descriptor: DataDescriptor | undefined, labels: Labels): RecordMetaData {
220
+ getMetaData(descriptor: DataDescriptor, labels: Labels): RecordMetaData {
198
221
  return {
199
222
  address: this.address,
200
223
  contractName: this.moduleName,
@@ -204,6 +227,7 @@ export class SuiContext extends BaseContext {
204
227
  logIndex: 0,
205
228
  chainId: SUI_DEVNET_ID, // TODO set in context
206
229
  dataDescriptor: descriptor,
230
+ name: descriptor.name,
207
231
  labels: normalizeLabels(labels),
208
232
  }
209
233
  }