@sentio/sdk 2.16.1 → 2.16.2-rc.2

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 (48) hide show
  1. package/lib/aptos/aptos-processor.d.ts +3 -2
  2. package/lib/aptos/aptos-processor.js +22 -23
  3. package/lib/aptos/aptos-processor.js.map +1 -1
  4. package/lib/eth/base-processor-template.d.ts +1 -1
  5. package/lib/eth/base-processor-template.js +5 -3
  6. package/lib/eth/base-processor-template.js.map +1 -1
  7. package/lib/eth/base-processor.d.ts +4 -4
  8. package/lib/eth/base-processor.js +17 -17
  9. package/lib/eth/base-processor.js.map +1 -1
  10. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +31 -31
  11. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  12. package/lib/eth/builtin/internal/erc1155-processor.js +16 -16
  13. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  14. package/lib/eth/builtin/internal/erc20-processor.js +24 -24
  15. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  16. package/lib/eth/builtin/internal/erc20bytes-processor.js +13 -13
  17. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  18. package/lib/eth/builtin/internal/erc721-processor.js +20 -20
  19. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  20. package/lib/eth/builtin/internal/weth9-processor.js +19 -19
  21. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  22. package/lib/eth/codegen/ethers-sentio.js +11 -11
  23. package/lib/eth/codegen/ethers-sentio.js.map +1 -1
  24. package/lib/eth/codegen/event-handler.js +1 -1
  25. package/lib/eth/codegen/event-handler.js.map +1 -1
  26. package/lib/eth/codegen/functions-handler.js +1 -1
  27. package/lib/eth/codegen/functions-handler.js.map +1 -1
  28. package/lib/eth/generic-processor.test.js.map +1 -1
  29. package/lib/sui/sui-plugin.js +1 -1
  30. package/lib/sui/sui-plugin.js.map +1 -1
  31. package/lib/sui/sui-processor.d.ts +5 -3
  32. package/lib/sui/sui-processor.js +24 -2
  33. package/lib/sui/sui-processor.js.map +1 -1
  34. package/package.json +3 -3
  35. package/src/aptos/aptos-processor.ts +38 -51
  36. package/src/eth/base-processor-template.ts +5 -3
  37. package/src/eth/base-processor.ts +25 -25
  38. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +31 -31
  39. package/src/eth/builtin/internal/erc1155-processor.ts +16 -16
  40. package/src/eth/builtin/internal/erc20-processor.ts +24 -24
  41. package/src/eth/builtin/internal/erc20bytes-processor.ts +13 -13
  42. package/src/eth/builtin/internal/erc721-processor.ts +20 -20
  43. package/src/eth/builtin/internal/weth9-processor.ts +19 -19
  44. package/src/eth/codegen/ethers-sentio.ts +11 -11
  45. package/src/eth/codegen/event-handler.ts +1 -1
  46. package/src/eth/codegen/functions-handler.ts +1 -1
  47. package/src/sui/sui-plugin.ts +1 -1
  48. package/src/sui/sui-processor.ts +44 -4
@@ -28,9 +28,10 @@ export declare class AptosBaseProcessor {
28
28
  callHandlers: CallHandler<Data_AptCall>[];
29
29
  coder: MoveCoder;
30
30
  constructor(moduleName: string, options: AptosBindOptions);
31
- onTransaction(handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => PromiseOrVoid, includedFailed?: boolean, fetchConfig?: Partial<MoveFetchConfig>): this;
32
31
  onMoveEvent(handler: (event: Event, ctx: AptosContext) => void, filter: EventFilter | EventFilter[], fetchConfig?: Partial<MoveFetchConfig>): this;
33
- onEntryFunctionCall(handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => PromiseOrVoid, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[], fetchConfig?: Partial<MoveFetchConfig>): this;
32
+ protected onEntryFunctionCall(handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => PromiseOrVoid, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[], fetchConfig?: Partial<MoveFetchConfig>): this;
33
+ onTransaction(handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => PromiseOrVoid, includedFailed?: boolean, fetchConfig?: Partial<MoveFetchConfig>): this;
34
+ onEvent(handler: (event: Event, ctx: AptosContext) => void, fetchConfig?: Partial<MoveFetchConfig>): this;
34
35
  getChainId(): string;
35
36
  }
36
37
  export declare class AptosAccountProcessorState extends ListStateStorage<AptosResourcesProcessor> {
@@ -32,29 +32,6 @@ export class AptosBaseProcessor {
32
32
  this.coder = defaultMoveCoder(this.config.network);
33
33
  // this.loadTypes(this.coder)
34
34
  }
35
- // getABI(): MoveModule | undefined {
36
- // return undefined
37
- // }
38
- onTransaction(handler, includedFailed = false, fetchConfig) {
39
- const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig });
40
- // const address = this.config.address
41
- // const moduleName = this.moduleName
42
- const processor = this;
43
- this.callHandlers.push({
44
- handler: async function (data) {
45
- if (!data.transaction) {
46
- throw new ServerError(Status.INVALID_ARGUMENT, 'call is null');
47
- }
48
- const call = data.transaction;
49
- const ctx = new AptosContext(processor.moduleName, processor.config.network, processor.config.address, BigInt(data.transaction.version), call, 0, processor.config.baseLabels);
50
- await handler(call, ctx);
51
- return ctx.getProcessResult();
52
- },
53
- filters: [{ function: '', includeFailed: includedFailed }],
54
- fetchConfig: _fetchConfig,
55
- });
56
- return this;
57
- }
58
35
  onMoveEvent(handler, filter, fetchConfig) {
59
36
  let _filters = [];
60
37
  const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig });
@@ -125,6 +102,28 @@ export class AptosBaseProcessor {
125
102
  });
126
103
  return this;
127
104
  }
105
+ onTransaction(handler, includedFailed = false, fetchConfig) {
106
+ const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig });
107
+ const processor = this;
108
+ this.callHandlers.push({
109
+ handler: async function (data) {
110
+ if (!data.transaction) {
111
+ throw new ServerError(Status.INVALID_ARGUMENT, 'call is null');
112
+ }
113
+ const call = data.transaction;
114
+ const ctx = new AptosContext(processor.moduleName, processor.config.network, processor.config.address, BigInt(data.transaction.version), call, 0, processor.config.baseLabels);
115
+ await handler(call, ctx);
116
+ return ctx.getProcessResult();
117
+ },
118
+ filters: [{ function: '', includeFailed: includedFailed }],
119
+ fetchConfig: _fetchConfig,
120
+ });
121
+ return this;
122
+ }
123
+ onEvent(handler, fetchConfig) {
124
+ this.onMoveEvent(handler, { type: '' }, fetchConfig);
125
+ return this;
126
+ }
128
127
  getChainId() {
129
128
  return this.config.network;
130
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"aptos-processor.js","sourceRoot":"","sources":["../../src/aptos/aptos-processor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAa,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAoB,YAAY,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EACL,eAAe,GAMhB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAqE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGnH,MAAM,oBAAoB,GAAoB;IAC5C,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE,IAAI;CAChB,CAAA;AAUD,MAAM,gBAAgB;IACpB,IAAI,CAAS;IACb,eAAe,CAAiB;IAChC,qBAAqB,CAAiB;IACtC,OAAO,CAAwD;CAChE;AAED,MAAa,mBAAoB,SAAQ,gBAAoC;IAC3E,MAAM,CAAC,QAAQ,GAAG,IAAI,mBAAmB,EAAE,CAAA;;SADhC,mBAAmB;AAIhC,MAAM,OAAO,kBAAkB;IACpB,UAAU,CAAQ;IAC3B,MAAM,CAAgB;IACtB,aAAa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AqB,GAAG,EAAE,EAC1B,6BAA6B,GAAG,GAAG,EACnC,IAAa;QAEb,OAAO,IAAI,CAAC,UAAU,CACpB,OAAO,EACP;YACE,cAAc,EAAE,qBAAqB;YACrC,gBAAgB,EAAE,6BAA6B;SAChD,EACD,SAAS,EACT,IAAI,CACL,CAAA;IACH,CAAC;IAEM,iBAAiB,CACtB,OAAiF,EACjF,eAAe,GAAG,MAAM,EACxB,uBAAuB,GAAG,MAAM,EAChC,UAAmB;QAEnB,OAAO,IAAI,CAAC,UAAU,CACpB,OAAO,EACP,SAAS,EACT,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,EAC9E,UAAU,CACX,CAAA;IACH,CAAC;CACF;AAED,SAAS,SAAS,CAAC,OAAyB;IAC1C,IAAI,YAAY,GAAG,EAAE,CAAA;IACrB,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;QACtC,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,QAAQ,EAAE;YAC5C,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;SAC5C;aAAM;YACL,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;SACpC;KACF;IAED,OAAO;QACL,YAAY,EAAE,YAAY;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,QAAQ;QACjD,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAA;AACH,CAAC","sourcesContent":["import {\n Event,\n MoveResource,\n Transaction_UserTransaction,\n TransactionPayload_EntryFunctionPayload,\n} from './move-types.js'\n\nimport { defaultMoveCoder, MoveCoder } from './move-coder.js'\nimport { AptosBindOptions, AptosNetwork } from './network.js'\nimport { AptosContext, AptosResourcesContext } from './context.js'\nimport { ListStateStorage, mergeProcessResults } from '@sentio/runtime'\nimport {\n MoveFetchConfig,\n Data_AptResource,\n HandleInterval,\n ProcessResult,\n Data_AptEvent,\n Data_AptCall,\n} from '@sentio/protos'\nimport { ServerError, Status } from 'nice-grpc'\nimport { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, parseMoveType } from '../move/index.js'\nimport { Labels, PromiseOrVoid } from '../core/index.js'\n\nconst DEFAULT_FETCH_CONFIG: MoveFetchConfig = {\n resourceChanges: false,\n allEvents: true,\n}\n\ntype IndexConfigure = {\n address: string\n network: AptosNetwork\n startVersion: bigint\n baseLabels?: Labels\n // endSeqNumber?: Long\n}\n\nclass ResourceHandlder {\n type?: string\n versionInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: (resource: Data_AptResource) => Promise<ProcessResult>\n}\n\nexport class AptosProcessorState extends ListStateStorage<AptosBaseProcessor> {\n static INSTANCE = new AptosProcessorState()\n}\n\nexport class AptosBaseProcessor {\n readonly moduleName: string\n config: IndexConfigure\n eventHandlers: EventHandler<Data_AptEvent>[] = []\n callHandlers: CallHandler<Data_AptCall>[] = []\n coder: MoveCoder\n\n constructor(moduleName: string, options: AptosBindOptions) {\n this.moduleName = moduleName\n this.config = configure(options)\n AptosProcessorState.INSTANCE.addValue(this)\n this.coder = defaultMoveCoder(this.config.network)\n // this.loadTypes(this.coder)\n }\n\n // getABI(): MoveModule | undefined {\n // return undefined\n // }\n\n public onTransaction(\n handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => PromiseOrVoid,\n includedFailed = false,\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n const processor = this\n this.callHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')\n }\n const call = data.transaction as Transaction_UserTransaction\n const ctx = new AptosContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n BigInt(data.transaction.version),\n call,\n 0,\n processor.config.baseLabels\n )\n await handler(call, ctx)\n return ctx.getProcessResult()\n },\n filters: [{ function: '', includeFailed: includedFailed }],\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n public onMoveEvent(\n handler: (event: Event, ctx: AptosContext) => void,\n filter: EventFilter | EventFilter[],\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n let _filters: EventFilter[] = []\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const moduleName = this.moduleName\n\n const processor = this\n const allEventType = new Set(_filters.map((f) => processor.config.address + '::' + f.type))\n\n this.eventHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')\n }\n const txn = data.transaction as Transaction_UserTransaction\n if (!txn.events.length) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')\n }\n\n const processResults = []\n for (const [idx, evt] of txn.events.entries()) {\n const typeQname = parseMoveType(evt.type).qname\n if (!allEventType.has(typeQname)) {\n continue\n }\n\n const ctx = new AptosContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n BigInt(txn.version),\n txn,\n idx,\n processor.config.baseLabels\n )\n\n const decoded = await processor.coder.decodeEvent<any>(evt)\n await handler(decoded || evt, ctx)\n processResults.push(ctx.getProcessResult())\n }\n\n return mergeProcessResults(processResults)\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n public onEntryFunctionCall(\n handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => PromiseOrVoid,\n filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n let _filters: FunctionNameAndCallFilter[] = []\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n const processor = this\n\n this.callHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')\n }\n const tx = data.transaction as Transaction_UserTransaction\n\n const ctx = new AptosContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n BigInt(tx.version),\n tx,\n 0,\n processor.config.baseLabels\n )\n if (tx) {\n const payload = tx.payload as TransactionPayload_EntryFunctionPayload\n const decoded = await processor.coder.decodeFunctionPayload(payload)\n await handler(decoded, ctx)\n }\n return ctx.getProcessResult()\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n getChainId(): string {\n return this.config.network\n }\n\n // loadTypes(registry: MoveCoder) {\n // if (registry.contains(this.config.address, this.moduleName)) {\n // return\n // }\n // this.loadTypesInternal(registry)\n // }\n //\n // protected loadTypesInternal(registry: MoveCoder) {\n // // should be override by subclass\n // console.log('')\n // }\n}\n\nexport class AptosAccountProcessorState extends ListStateStorage<AptosResourcesProcessor> {\n static INSTANCE = new AptosAccountProcessorState()\n}\n\nexport class AptosResourcesProcessor {\n config: IndexConfigure\n\n resourcesHandlers: ResourceHandlder[] = []\n\n static bind(options: AptosBindOptions): AptosResourcesProcessor {\n return new AptosResourcesProcessor(options)\n }\n\n protected constructor(options: AptosBindOptions) {\n this.config = configure(options)\n AptosAccountProcessorState.INSTANCE.addValue(this)\n }\n\n getChainId(): string {\n return this.config.network\n }\n\n private onInterval(\n handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n versionInterval: HandleInterval | undefined,\n type: string | undefined\n ): this {\n const processor = this\n this.resourcesHandlers.push({\n handler: async function (data) {\n if (data.timestampMicros > Number.MAX_SAFE_INTEGER) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')\n }\n const timestamp = Number(data.timestampMicros)\n\n const ctx = new AptosResourcesContext(\n processor.config.network,\n processor.config.address,\n data.version,\n timestamp,\n processor.config.baseLabels\n )\n await handler(data.resources as MoveResource[], ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n versionInterval: versionInterval,\n type: type,\n })\n return this\n }\n\n public onTimeInterval(\n handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n type?: string\n ): this {\n return this.onInterval(\n handler,\n {\n recentInterval: timeIntervalInMinutes,\n backfillInterval: backfillTimeIntervalInMinutes,\n },\n undefined,\n type\n )\n }\n\n public onVersionInterval(\n handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,\n versionInterval = 100000,\n backfillVersionInterval = 400000,\n typePrefix?: string\n ): this {\n return this.onInterval(\n handler,\n undefined,\n { recentInterval: versionInterval, backfillInterval: backfillVersionInterval },\n typePrefix\n )\n }\n}\n\nfunction configure(options: AptosBindOptions): IndexConfigure {\n let startVersion = 0n\n if (options.startVersion !== undefined) {\n if (typeof options.startVersion === 'number') {\n startVersion = BigInt(options.startVersion)\n } else {\n startVersion = options.startVersion\n }\n }\n\n return {\n startVersion: startVersion,\n address: options.address,\n network: options.network || AptosNetwork.MAIN_NET,\n baseLabels: options.baseLabels,\n }\n}\n"]}
1
+ {"version":3,"file":"aptos-processor.js","sourceRoot":"","sources":["../../src/aptos/aptos-processor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAa,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAoB,YAAY,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EACL,eAAe,GAMhB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,W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;SAC5C;aAAM;YACL,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;SACpC;KACF;IAED,OAAO;QACL,YAAY,EAAE,YAAY;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,QAAQ;QACjD,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAA;AACH,CAAC","sourcesContent":["import {\n Event,\n MoveResource,\n Transaction_UserTransaction,\n TransactionPayload_EntryFunctionPayload,\n} from './move-types.js'\n\nimport { defaultMoveCoder, MoveCoder } from './move-coder.js'\nimport { AptosBindOptions, AptosNetwork } from './network.js'\nimport { AptosContext, AptosResourcesContext } from './context.js'\nimport { ListStateStorage, mergeProcessResults } from '@sentio/runtime'\nimport {\n MoveFetchConfig,\n Data_AptResource,\n HandleInterval,\n ProcessResult,\n Data_AptEvent,\n Data_AptCall,\n} from '@sentio/protos'\nimport { ServerError, Status } from 'nice-grpc'\nimport { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, parseMoveType } from '../move/index.js'\nimport { Labels, PromiseOrVoid } from '../core/index.js'\n\nconst DEFAULT_FETCH_CONFIG: MoveFetchConfig = {\n resourceChanges: false,\n allEvents: true,\n}\n\ntype IndexConfigure = {\n address: string\n network: AptosNetwork\n startVersion: bigint\n baseLabels?: Labels\n // endSeqNumber?: Long\n}\n\nclass ResourceHandlder {\n type?: string\n versionInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: (resource: Data_AptResource) => Promise<ProcessResult>\n}\n\nexport class AptosProcessorState extends ListStateStorage<AptosBaseProcessor> {\n static INSTANCE = new AptosProcessorState()\n}\n\nexport class AptosBaseProcessor {\n readonly moduleName: string\n config: IndexConfigure\n eventHandlers: EventHandler<Data_AptEvent>[] = []\n callHandlers: CallHandler<Data_AptCall>[] = []\n coder: MoveCoder\n\n constructor(moduleName: string, options: AptosBindOptions) {\n this.moduleName = moduleName\n this.config = configure(options)\n AptosProcessorState.INSTANCE.addValue(this)\n this.coder = defaultMoveCoder(this.config.network)\n // this.loadTypes(this.coder)\n }\n\n public onMoveEvent(\n handler: (event: Event, ctx: AptosContext) => void,\n filter: EventFilter | EventFilter[],\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n let _filters: EventFilter[] = []\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const moduleName = this.moduleName\n\n const processor = this\n const allEventType = new Set(_filters.map((f) => processor.config.address + '::' + f.type))\n\n this.eventHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')\n }\n const txn = data.transaction as Transaction_UserTransaction\n if (!txn.events.length) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')\n }\n\n const processResults = []\n for (const [idx, evt] of txn.events.entries()) {\n const typeQname = parseMoveType(evt.type).qname\n if (!allEventType.has(typeQname)) {\n continue\n }\n\n const ctx = new AptosContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n BigInt(txn.version),\n txn,\n idx,\n processor.config.baseLabels\n )\n\n const decoded = await processor.coder.decodeEvent<any>(evt)\n await handler(decoded || evt, ctx)\n processResults.push(ctx.getProcessResult())\n }\n\n return mergeProcessResults(processResults)\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n protected onEntryFunctionCall(\n handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => PromiseOrVoid,\n filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n let _filters: FunctionNameAndCallFilter[] = []\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n const processor = this\n\n this.callHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')\n }\n const tx = data.transaction as Transaction_UserTransaction\n\n const ctx = new AptosContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n BigInt(tx.version),\n tx,\n 0,\n processor.config.baseLabels\n )\n if (tx) {\n const payload = tx.payload as TransactionPayload_EntryFunctionPayload\n const decoded = await processor.coder.decodeFunctionPayload(payload)\n await handler(decoded, ctx)\n }\n return ctx.getProcessResult()\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n public onTransaction(\n handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => PromiseOrVoid,\n includedFailed = false,\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n const processor = this\n this.callHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')\n }\n const call = data.transaction as Transaction_UserTransaction\n const ctx = new AptosContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n BigInt(data.transaction.version),\n call,\n 0,\n processor.config.baseLabels\n )\n await handler(call, ctx)\n return ctx.getProcessResult()\n },\n filters: [{ function: '', includeFailed: includedFailed }],\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n public onEvent(handler: (event: Event, ctx: AptosContext) => void, fetchConfig?: Partial<MoveFetchConfig>): this {\n this.onMoveEvent(handler, { type: '' }, fetchConfig)\n return this\n }\n\n getChainId(): string {\n return this.config.network\n }\n}\n\nexport class AptosAccountProcessorState extends ListStateStorage<AptosResourcesProcessor> {\n static INSTANCE = new AptosAccountProcessorState()\n}\n\nexport class AptosResourcesProcessor {\n config: IndexConfigure\n\n resourcesHandlers: ResourceHandlder[] = []\n\n static bind(options: AptosBindOptions): AptosResourcesProcessor {\n return new AptosResourcesProcessor(options)\n }\n\n protected constructor(options: AptosBindOptions) {\n this.config = configure(options)\n AptosAccountProcessorState.INSTANCE.addValue(this)\n }\n\n getChainId(): string {\n return this.config.network\n }\n\n private onInterval(\n handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n versionInterval: HandleInterval | undefined,\n type: string | undefined\n ): this {\n const processor = this\n this.resourcesHandlers.push({\n handler: async function (data) {\n if (data.timestampMicros > Number.MAX_SAFE_INTEGER) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')\n }\n const timestamp = Number(data.timestampMicros)\n\n const ctx = new AptosResourcesContext(\n processor.config.network,\n processor.config.address,\n data.version,\n timestamp,\n processor.config.baseLabels\n )\n await handler(data.resources as MoveResource[], ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n versionInterval: versionInterval,\n type: type,\n })\n return this\n }\n\n public onTimeInterval(\n handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n type?: string\n ): this {\n return this.onInterval(\n handler,\n {\n recentInterval: timeIntervalInMinutes,\n backfillInterval: backfillTimeIntervalInMinutes,\n },\n undefined,\n type\n )\n }\n\n public onVersionInterval(\n handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,\n versionInterval = 100000,\n backfillVersionInterval = 400000,\n typePrefix?: string\n ): this {\n return this.onInterval(\n handler,\n undefined,\n { recentInterval: versionInterval, backfillInterval: backfillVersionInterval },\n typePrefix\n )\n }\n}\n\nfunction configure(options: AptosBindOptions): IndexConfigure {\n let startVersion = 0n\n if (options.startVersion !== undefined) {\n if (typeof options.startVersion === 'number') {\n startVersion = BigInt(options.startVersion)\n } else {\n startVersion = options.startVersion\n }\n }\n\n return {\n startVersion: startVersion,\n address: options.address,\n network: options.network || AptosNetwork.MAIN_NET,\n baseLabels: options.baseLabels,\n }\n}\n"]}
@@ -37,7 +37,7 @@ export declare abstract class BaseProcessorTemplate<TContract extends BaseContra
37
37
  * @param ctx
38
38
  */
39
39
  bind(options: BindOptions, ctx: EthContext): void;
40
- onEvent(handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, filter: DeferredTopicFilter | DeferredTopicFilter[], fetchConfig?: Partial<EthFetchConfig>): this;
40
+ protected onEthEvent(handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, filter: DeferredTopicFilter | DeferredTopicFilter[], fetchConfig?: Partial<EthFetchConfig>): this;
41
41
  onBlockInterval(handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, blockInterval?: number, backfillBlockInterval?: number, fetchConfig?: EthFetchConfig): this;
42
42
  onTimeInterval(handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, timeIntervalInMinutes?: number, backfillBlockInterval?: number, fetchConfig?: EthFetchConfig): this;
43
43
  onInterval(handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, timeInterval: HandleInterval | undefined, blockInterval: HandleInterval | undefined, fetchConfig: EthFetchConfig | undefined): this;
@@ -34,10 +34,12 @@ export class BaseProcessorTemplate {
34
34
  this.binds.add(sig);
35
35
  const processor = this.bindInternal(options);
36
36
  for (const eh of this.eventHandlers) {
37
- processor.onEvent(eh.handler, eh.filter, eh.fetchConfig);
37
+ // @ts-ignore friendly
38
+ processor.onEthEvent(eh.handler, eh.filter, eh.fetchConfig);
38
39
  }
39
40
  for (const th of this.traceHandlers) {
40
- processor.onTrace(th.signature, th.handler, th.fetchConfig);
41
+ // @ts-ignore friendly
42
+ processor.onEthTrace(th.signature, th.handler, th.fetchConfig);
41
43
  }
42
44
  for (const bh of this.blockHandlers) {
43
45
  processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval, bh.fetchConfig);
@@ -62,7 +64,7 @@ export class BaseProcessorTemplate {
62
64
  TemplateInstanceState.INSTANCE.addValue(instance);
63
65
  ctx._res.states.configUpdated = true;
64
66
  }
65
- onEvent(handler, filter, fetchConfig) {
67
+ onEthEvent(handler, filter, fetchConfig) {
66
68
  this.eventHandlers.push({
67
69
  handler: handler,
68
70
  filter: filter,
@@ -1 +1 @@
1
- {"version":3,"file":"base-processor-template.js","sourceRoot":"","sources":["../../src/eth/base-processor-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAoC,MAAM,gBAAgB,CAAA;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,MAAa,+BAAgC,SAAQ,gBAEpD;IACC,MAAM,CAAC,QAAQ,GAAG,IAAI,+BAA+B,EAAE,CAAA;;SAH5C,+BAA+B;AAM5C,MAAM,OAAgB,qBAAqB;IAIzC,EAAE,CAAQ;IACV,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IACzB,aAAa,GAKP,EAAE,CAAA;IACR,aAAa,GAIP,EAAE,CAAA;IACR,aAAa,GAIP,EAAE,CAAA;IAER;QACE,IAAI,CAAC,EAAE,GAAG,+BAA+B,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,MAAM,CAAA;QACrE,+BAA+B,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACzD,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,OAAoB,EAAE,GAAe;QAC/C,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAA;QAChD,MAAM,GAAG,GAAG,mBAAmB,CAAC;YAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAA;QAC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iB,EACjB,OAAsG,EACtG,WAAqC;QAErC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,WAAW,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;QAC3G,OAAO,IAAI,CAAA;IACb,CAAC;CAGF","sourcesContent":["import { BoundContractView, ContractContext, ContractView, EthContext } from './context.js'\nimport { BaseContract } from 'ethers'\nimport { BaseProcessor } from './base-processor.js'\nimport { BindOptions, getOptionsSignature } from './bind-options.js'\nimport { EthFetchConfig, HandleInterval, TemplateInstance } from '@sentio/protos'\nimport { PromiseOrVoid } from '../core/promises.js'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { BlockParams } from 'ethers/providers'\nimport { DeferredTopicFilter } from 'ethers/contract'\nimport { TypedEvent, TypedCallTrace } from './eth.js'\nimport { TemplateInstanceState } from '../core/template.js'\n\nexport class ProcessorTemplateProcessorState extends ListStateStorage<\n BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>\n> {\n static INSTANCE = new ProcessorTemplateProcessorState()\n}\n\nexport abstract class BaseProcessorTemplate<\n TContract extends BaseContract,\n TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>\n> {\n id: number\n binds = new Set<string>()\n blockHandlers: {\n handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n blockInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n fetchConfig?: EthFetchConfig\n }[] = []\n traceHandlers: {\n signature: string\n handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n fetchConfig?: EthFetchConfig\n }[] = []\n eventHandlers: {\n handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n filter: DeferredTopicFilter | DeferredTopicFilter[]\n fetchConfig?: EthFetchConfig\n }[] = []\n\n constructor() {\n this.id = ProcessorTemplateProcessorState.INSTANCE.getValues().length\n ProcessorTemplateProcessorState.INSTANCE.addValue(this)\n }\n\n /**\n * Bind template using {@param options}, using {@param ctx}'s network value if not provided in the option\n * @param options\n * @param ctx\n */\n public bind(options: BindOptions, ctx: EthContext): void {\n options.network = options.network || ctx.chainId\n const sig = getOptionsSignature({\n address: options.address,\n network: options.network,\n })\n if (this.binds.has(sig)) {\n console.log(`Same address can be bind to one template only once, ignore duplicate bind: ${sig}`)\n return\n }\n this.binds.add(sig)\n\n const processor = this.bindInternal(options)\n\n for (const eh of this.eventHandlers) {\n processor.onEvent(eh.handler, eh.filter, eh.fetchConfig)\n }\n for (const th of this.traceHandlers) {\n processor.onTrace(th.signature, th.handler, th.fetchConfig)\n }\n for (const bh of this.blockHandlers) {\n processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval, bh.fetchConfig)\n }\n\n const instance: TemplateInstance = {\n templateId: this.id,\n contract: {\n address: options.address,\n name: options.name || '',\n chainId: options.network,\n abi: '',\n },\n startBlock: 0n,\n endBlock: 0n,\n }\n if (options.startBlock) {\n instance.startBlock = BigInt(options.startBlock)\n }\n if (options.endBlock) {\n instance.endBlock = BigInt(options.endBlock)\n }\n TemplateInstanceState.INSTANCE.addValue(instance)\n ctx._res.states.configUpdated = true\n }\n\n public onEvent(\n handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: DeferredTopicFilter | DeferredTopicFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ) {\n this.eventHandlers.push({\n handler: handler,\n filter: filter,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n })\n return this\n }\n\n public onBlockInterval(\n handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n blockInterval = 1000,\n backfillBlockInterval = 4000,\n fetchConfig?: EthFetchConfig\n ) {\n return this.onInterval(\n handler,\n undefined,\n {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n },\n fetchConfig\n )\n }\n\n public onTimeInterval(\n handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillBlockInterval = 240,\n fetchConfig?: EthFetchConfig\n ) {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillBlockInterval },\n undefined,\n fetchConfig\n )\n }\n\n public onInterval(\n handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined,\n fetchConfig: EthFetchConfig | undefined\n ) {\n this.blockHandlers.push({ handler, timeIntervalInMinutes: timeInterval, blockInterval, fetchConfig })\n return this\n }\n\n public onTrace(\n signature: string,\n handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ) {\n this.traceHandlers.push({ signature, handler, fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}) })\n return this\n }\n\n protected abstract bindInternal(options: BindOptions): BaseProcessor<TContract, TBoundContractView>\n}\n"]}
1
+ {"version":3,"file":"base-processor-template.js","sourceRoot":"","sources":["../../src/eth/base-processor-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAoC,MAAM,gBAAgB,CAAA;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,MAAa,+BAAgC,SAAQ,gBAEpD;IACC,MAAM,CAAC,QAAQ,GAAG,IAAI,+BAA+B,EAAE,CAAA;;SAH5C,+BAA+B;AAM5C,MAAM,OAAgB,qBAAqB;IAIzC,EAAE,CAAQ;IACV,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IACzB,aAAa,GAKP,EAAE,CAAA;IACR,aAAa,GAIP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H,CAAC;IAEM,cAAc,CACnB,OAAmG,EACnG,qBAAqB,GAAG,EAAE,EAC1B,qBAAqB,GAAG,GAAG,EAC3B,WAA4B;QAE5B,OAAO,IAAI,CAAC,UAAU,CACpB,OAAO,EACP,EAAE,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,EAClF,SAAS,EACT,WAAW,CACZ,CAAA;IACH,CAAC;IAEM,UAAU,CACf,OAAmG,EACnG,YAAwC,EACxC,aAAyC,EACzC,WAAuC;QAEvC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAA;QACrG,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,OAAO,CACZ,SAAiB,EACjB,OAAsG,EACtG,WAAqC;QAErC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,WAAW,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;QAC3G,OAAO,IAAI,CAAA;IACb,CAAC;CAGF","sourcesContent":["import { BoundContractView, ContractContext, ContractView, EthContext } from './context.js'\nimport { BaseContract } from 'ethers'\nimport { BaseProcessor } from './base-processor.js'\nimport { BindOptions, getOptionsSignature } from './bind-options.js'\nimport { EthFetchConfig, HandleInterval, TemplateInstance } from '@sentio/protos'\nimport { PromiseOrVoid } from '../core/promises.js'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { BlockParams } from 'ethers/providers'\nimport { DeferredTopicFilter } from 'ethers/contract'\nimport { TypedEvent, TypedCallTrace } from './eth.js'\nimport { TemplateInstanceState } from '../core/template.js'\n\nexport class ProcessorTemplateProcessorState extends ListStateStorage<\n BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>\n> {\n static INSTANCE = new ProcessorTemplateProcessorState()\n}\n\nexport abstract class BaseProcessorTemplate<\n TContract extends BaseContract,\n TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>\n> {\n id: number\n binds = new Set<string>()\n blockHandlers: {\n handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n blockInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n fetchConfig?: EthFetchConfig\n }[] = []\n traceHandlers: {\n signature: string\n handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n fetchConfig?: EthFetchConfig\n }[] = []\n eventHandlers: {\n handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n filter: DeferredTopicFilter | DeferredTopicFilter[]\n fetchConfig?: EthFetchConfig\n }[] = []\n\n constructor() {\n this.id = ProcessorTemplateProcessorState.INSTANCE.getValues().length\n ProcessorTemplateProcessorState.INSTANCE.addValue(this)\n }\n\n /**\n * Bind template using {@param options}, using {@param ctx}'s network value if not provided in the option\n * @param options\n * @param ctx\n */\n public bind(options: BindOptions, ctx: EthContext): void {\n options.network = options.network || ctx.chainId\n const sig = getOptionsSignature({\n address: options.address,\n network: options.network,\n })\n if (this.binds.has(sig)) {\n console.log(`Same address can be bind to one template only once, ignore duplicate bind: ${sig}`)\n return\n }\n this.binds.add(sig)\n\n const processor = this.bindInternal(options)\n\n for (const eh of this.eventHandlers) {\n // @ts-ignore friendly\n processor.onEthEvent(eh.handler, eh.filter, eh.fetchConfig)\n }\n for (const th of this.traceHandlers) {\n // @ts-ignore friendly\n processor.onEthTrace(th.signature, th.handler, th.fetchConfig)\n }\n for (const bh of this.blockHandlers) {\n processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval, bh.fetchConfig)\n }\n\n const instance: TemplateInstance = {\n templateId: this.id,\n contract: {\n address: options.address,\n name: options.name || '',\n chainId: options.network,\n abi: '',\n },\n startBlock: 0n,\n endBlock: 0n,\n }\n if (options.startBlock) {\n instance.startBlock = BigInt(options.startBlock)\n }\n if (options.endBlock) {\n instance.endBlock = BigInt(options.endBlock)\n }\n TemplateInstanceState.INSTANCE.addValue(instance)\n ctx._res.states.configUpdated = true\n }\n\n protected onEthEvent(\n handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: DeferredTopicFilter | DeferredTopicFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ) {\n this.eventHandlers.push({\n handler: handler,\n filter: filter,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n })\n return this\n }\n\n public onBlockInterval(\n handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n blockInterval = 1000,\n backfillBlockInterval = 4000,\n fetchConfig?: EthFetchConfig\n ) {\n return this.onInterval(\n handler,\n undefined,\n {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n },\n fetchConfig\n )\n }\n\n public onTimeInterval(\n handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillBlockInterval = 240,\n fetchConfig?: EthFetchConfig\n ) {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillBlockInterval },\n undefined,\n fetchConfig\n )\n }\n\n public onInterval(\n handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined,\n fetchConfig: EthFetchConfig | undefined\n ) {\n this.blockHandlers.push({ handler, timeIntervalInMinutes: timeInterval, blockInterval, fetchConfig })\n return this\n }\n\n public onTrace(\n signature: string,\n handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ) {\n this.traceHandlers.push({ signature, handler, fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}) })\n return this\n }\n\n protected abstract bindInternal(options: BindOptions): BaseProcessor<TContract, TBoundContractView>\n}\n"]}
@@ -63,12 +63,12 @@ export declare abstract class BaseProcessor<TContract extends BaseContract, TBou
63
63
  constructor(config: BindOptions);
64
64
  protected abstract CreateBoundContractView(): TBoundContractView;
65
65
  getChainId(): EthChainId;
66
- onEvent(handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, filter: DeferredTopicFilter | DeferredTopicFilter[], fetchConfig?: Partial<EthFetchConfig>): this;
66
+ onEvent(handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, fetchConfig?: Partial<EthFetchConfig>): this;
67
+ protected onEthEvent(handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, filter: DeferredTopicFilter | DeferredTopicFilter[], fetchConfig?: Partial<EthFetchConfig>): this;
67
68
  onBlockInterval(handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, blockInterval?: number, backfillBlockInterval?: number, fetchConfig?: Partial<EthFetchConfig>): this;
68
69
  onTimeInterval(handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number, fetchConfig?: Partial<EthFetchConfig>): this;
69
70
  onInterval(handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, timeInterval: HandleInterval | undefined, blockInterval: HandleInterval | undefined, fetchConfig: Partial<EthFetchConfig> | undefined): this;
70
- onAllEvents(handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, fetchConfig?: Partial<EthFetchConfig>): this;
71
- onTrace(signatures: string | string[], handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, fetchConfig?: Partial<EthFetchConfig>): this;
72
- onAllTraces(handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, fetchConfig?: Partial<EthFetchConfig>): this;
71
+ protected onEthTrace(signatures: string | string[], handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, fetchConfig?: Partial<EthFetchConfig>): this;
72
+ onTrace(handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, fetchConfig?: Partial<EthFetchConfig>): this;
73
73
  }
74
74
  export {};
@@ -130,7 +130,20 @@ export class BaseProcessor {
130
130
  getChainId() {
131
131
  return this.config.network;
132
132
  }
133
- onEvent(handler, filter, fetchConfig) {
133
+ onEvent(handler, fetchConfig) {
134
+ const _filters = [];
135
+ const tmpContract = this.CreateBoundContractView();
136
+ for (const fragment of tmpContract.rawContract.interface.fragments) {
137
+ if (fragment.type === 'event') {
138
+ const filter = tmpContract.rawContract.filters[fragment.format()];
139
+ _filters.push(filter());
140
+ }
141
+ }
142
+ return this.onEthEvent(function (log, ctx) {
143
+ return handler(log, ctx);
144
+ }, _filters, fetchConfig);
145
+ }
146
+ onEthEvent(handler, filter, fetchConfig) {
134
147
  const chainId = this.getChainId();
135
148
  let _filters = [];
136
149
  if (Array.isArray(filter)) {
@@ -193,20 +206,7 @@ export class BaseProcessor {
193
206
  });
194
207
  return this;
195
208
  }
196
- onAllEvents(handler, fetchConfig) {
197
- const _filters = [];
198
- const tmpContract = this.CreateBoundContractView();
199
- for (const fragment of tmpContract.rawContract.interface.fragments) {
200
- if (fragment.type === 'event') {
201
- const filter = tmpContract.rawContract.filters[fragment.format()];
202
- _filters.push(filter());
203
- }
204
- }
205
- return this.onEvent(function (log, ctx) {
206
- return handler(log, ctx);
207
- }, _filters, fetchConfig);
208
- }
209
- onTrace(signatures, handler, fetchConfig) {
209
+ onEthTrace(signatures, handler, fetchConfig) {
210
210
  const chainId = this.getChainId();
211
211
  const contractName = this.config.name;
212
212
  const processor = this;
@@ -252,7 +252,7 @@ export class BaseProcessor {
252
252
  });
253
253
  return this;
254
254
  }
255
- onAllTraces(handler, fetchConfig) {
255
+ onTrace(handler, fetchConfig) {
256
256
  const tmpContract = this.CreateBoundContractView();
257
257
  const sighashes = [];
258
258
  for (const fragment of tmpContract.rawContract.interface.fragments) {
@@ -263,7 +263,7 @@ export class BaseProcessor {
263
263
  sighashes.push(sighash);
264
264
  }
265
265
  }
266
- return this.onTrace(sighashes, function (trace, ctx) {
266
+ return this.onEthTrace(sighashes, function (trace, ctx) {
267
267
  return handler(trace, ctx);
268
268
  }, fetchConfig);
269
269
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base-processor.js","sourceRoot":"","sources":["../../src/eth/base-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,eAAe,EAAgB,aAAa,EAAE,MAAM,cAAc,CAAA;AAC9F,OAAO,EAML,cAAc,EAEd,aAAa,GACd,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAyC,MAAM,UAAU,CAAA;AAC5F,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAO7C,MAAM,OAAO,aAAa;IACxB,OAAO,CAA4B;IACnC,OAAO,CAAgD;IACvD,WAAW,CAAgB;CAC5B;AAED,MAAM,OAAO,YAAY;IACvB,UAAU,CAAU;IACpB,OAAO,CAAkD;IACzD,WAAW,CAAgB;CAC5B;AAED,MAAM,OAAO,YAAY;IACvB,aAAa,CAAiB;IAC9B,qBAAqB,CAAiB;IACtC,OAAO,CAAkD;IACzD,WAAW,CAAgB;CAC5B;AAED,MAAM,OAAO,kBAAkB;IAC7B,OAAO,CAAwD;IAC/D,WAAW,CAAgB;CAC5B;AAED,MAAM,mBAAmB;IACvB,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,IAAI,CAAQ;IACZ,UAAU,CAAQ;IAClB,QAAQ,CAAS;IACjB,UAAU,C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AAU,EAAE;gBAChC,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAA;gBACnC,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;gBAChD,MAAM,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;gBAC5D,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;aACxB;SACF;QACD,OAAO,IAAI,CAAC,OAAO,CACjB,SAAS,EACT,UAAU,KAAK,EAAE,GAAG;YAClB,OAAO,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAC5B,CAAC,EACD,WAAW,CACZ,CAAA;IACH,CAAC;CACF","sourcesContent":["import { BaseContract, DeferredTopicFilter, TransactionResponseParams } from 'ethers'\n\nimport { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'\nimport {\n AddressType,\n Data_EthBlock,\n Data_EthLog,\n Data_EthTrace,\n Data_EthTransaction,\n EthFetchConfig,\n HandleInterval,\n ProcessResult,\n} from '@sentio/protos'\nimport { BindOptions } from './bind-options.js'\nimport { PromiseOrVoid } from '../core/promises.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { fixEmptyKey, formatEthData, RichBlock, TypedCallTrace, TypedEvent } from './eth.js'\nimport sha3 from 'js-sha3'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { EthChainId } from '../core/chain.js'\n\nexport interface AddressOrTypeEventFilter extends DeferredTopicFilter {\n addressType?: AddressType\n address?: string\n}\n\nexport class EventsHandler {\n filters: AddressOrTypeEventFilter[]\n handler: (event: Data_EthLog) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class TraceHandler {\n signatures: string[]\n handler: (trace: Data_EthTrace) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class BlockHandler {\n blockInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: (block: Data_EthBlock) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class TransactionHandler {\n handler: (block: Data_EthTransaction) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nclass BindInternalOptions {\n address: string\n network: EthChainId\n name: string\n startBlock: bigint\n endBlock?: bigint\n baseLabels?: { [key: string]: string }\n}\n\nexport class GlobalProcessorState extends ListStateStorage<GlobalProcessor> {\n static INSTANCE = new GlobalProcessorState()\n}\n\nexport class GlobalProcessor {\n config: BindInternalOptions\n blockHandlers: BlockHandler[] = []\n transactionHandler: TransactionHandler[] = []\n\n static bind(config: Omit<BindOptions, 'address'>): GlobalProcessor {\n const processor = new GlobalProcessor(config)\n GlobalProcessorState.INSTANCE.addValue(processor)\n return processor\n }\n\n constructor(config: Omit<BindOptions, 'address'>) {\n this.config = {\n address: '*',\n name: config.name || 'Global',\n network: config.network || EthChainId.ETHEREUM,\n startBlock: 0n,\n }\n if (config.startBlock) {\n this.config.startBlock = BigInt(config.startBlock)\n }\n if (config.endBlock) {\n this.config.endBlock = BigInt(config.endBlock)\n }\n }\n\n public onBlockInterval(\n handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,\n blockInterval = 250,\n backfillBlockInterval = 1000,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n undefined,\n {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n },\n fetchConfig\n )\n }\n\n public onTimeInterval(\n handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },\n undefined,\n fetchConfig\n )\n }\n\n public getChainId(): EthChainId {\n return this.config.network\n }\n\n public onInterval(\n handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined,\n fetchConfig: Partial<EthFetchConfig> | undefined\n ): this {\n const chainId = this.getChainId()\n\n this.blockHandlers.push({\n handler: async function (data: Data_EthBlock) {\n const { block } = formatEthData(data)\n\n if (!block) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Block is empty')\n }\n\n const ctx = new GlobalContext(chainId, new Date(block.timestamp * 1000), block, undefined, undefined)\n await handler(block, ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n blockInterval: blockInterval,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n })\n return this\n }\n\n public onTransaction(\n handler: (transaction: TransactionResponseParams, ctx: GlobalContext) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const chainId = this.getChainId()\n this.transactionHandler.push({\n handler: async function (data: Data_EthTransaction) {\n const { trace, block, transaction, transactionReceipt } = formatEthData(data)\n\n if (!transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is empty')\n }\n const ctx = new GlobalContext(chainId, data.timestamp, block, undefined, trace, transaction, transactionReceipt)\n await handler(transaction, ctx)\n return ctx.getProcessResult()\n },\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n })\n return this\n }\n}\n\nexport abstract class BaseProcessor<\n TContract extends BaseContract,\n TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>\n> {\n blockHandlers: BlockHandler[] = []\n eventHandlers: EventsHandler[] = []\n traceHandlers: TraceHandler[] = []\n\n config: BindInternalOptions\n\n constructor(config: BindOptions) {\n this.config = {\n address: config.address,\n name: config.name || '',\n network: config.network || EthChainId.ETHEREUM,\n startBlock: 0n,\n baseLabels: config.baseLabels,\n }\n if (config.startBlock) {\n this.config.startBlock = BigInt(config.startBlock)\n }\n if (config.endBlock) {\n this.config.endBlock = BigInt(config.endBlock)\n }\n }\n\n protected abstract CreateBoundContractView(): TBoundContractView\n\n public getChainId(): EthChainId {\n return this.config.network\n }\n\n public onEvent(\n handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: DeferredTopicFilter | DeferredTopicFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const chainId = this.getChainId()\n let _filters: DeferredTopicFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n const contractName = this.config.name\n const processor = this\n this.eventHandlers.push({\n filters: _filters,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n handler: async function (data: Data_EthLog) {\n const { log, block, transaction, transactionReceipt } = formatEthData(data)\n if (!log) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')\n }\n const contractView = processor.CreateBoundContractView()\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n data.timestamp,\n block,\n log,\n undefined,\n transaction,\n transactionReceipt\n )\n const logParam = log as any as { topics: Array<string>; data: string }\n\n const parsed = contractView.rawContract.interface.parseLog(logParam)\n\n if (parsed) {\n const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }\n await handler(event, ctx)\n return ctx.getProcessResult()\n }\n return ProcessResult.fromPartial({})\n },\n })\n return this\n }\n\n public onBlockInterval(\n handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n blockInterval = 250,\n backfillBlockInterval = 1000,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n undefined,\n {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n },\n fetchConfig\n )\n }\n\n public onTimeInterval(\n handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },\n undefined,\n fetchConfig\n )\n }\n\n public onInterval(\n handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined,\n fetchConfig: Partial<EthFetchConfig> | undefined\n ): this {\n const chainId = this.getChainId()\n const processor = this\n const contractName = this.config.name\n\n this.blockHandlers.push({\n handler: async function (data: Data_EthBlock) {\n const { block } = formatEthData(data)\n\n if (!block) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Block is empty')\n }\n\n const contractView = processor.CreateBoundContractView()\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n new Date(block.timestamp * 1000),\n block,\n undefined,\n undefined\n )\n await handler(block, ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n blockInterval: blockInterval,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n })\n return this\n }\n\n public onAllEvents(\n handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const _filters: DeferredTopicFilter[] = []\n const tmpContract = this.CreateBoundContractView()\n\n for (const fragment of tmpContract.rawContract.interface.fragments) {\n if (fragment.type === 'event') {\n const filter = tmpContract.rawContract.filters[fragment.format()]\n _filters.push(filter())\n }\n }\n return this.onEvent(\n function (log, ctx) {\n return handler(log, ctx)\n },\n _filters,\n fetchConfig\n )\n }\n\n public onTrace(\n signatures: string | string[],\n handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const chainId = this.getChainId()\n const contractName = this.config.name\n const processor = this\n if (typeof signatures === 'string') {\n signatures = [signatures]\n }\n\n this.traceHandlers.push({\n signatures,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n handler: async function (data: Data_EthTrace) {\n const contractView = processor.CreateBoundContractView()\n const contractInterface = contractView.rawContract.interface\n const { trace, block, transaction, transactionReceipt } = formatEthData(data)\n const sighash = trace?.action.input?.slice(0, 10)\n if (!sighash) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'trace has no sighash')\n }\n const fragment = contractInterface.getFunction(sighash)\n\n if (!trace || !fragment) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'trace is null')\n }\n const typedTrace = trace as TypedCallTrace\n typedTrace.name = fragment.name\n typedTrace.functionSignature = fragment.format()\n // const trace = data.trace as Trace\n if (!trace?.action.input) {\n return ProcessResult.fromPartial({})\n }\n const traceData = '0x' + trace.action.input.slice(10)\n try {\n typedTrace.args = contractInterface.getAbiCoder().decode(fragment.inputs, traceData, true)\n } catch (e) {\n if (!trace.error) {\n throw e\n }\n console.error('Failed to decode successful trace', e)\n }\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n data.timestamp,\n block,\n undefined,\n trace,\n transaction,\n transactionReceipt\n )\n await handler(typedTrace, ctx)\n return ctx.getProcessResult()\n },\n })\n return this\n }\n\n public onAllTraces(\n handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const tmpContract = this.CreateBoundContractView()\n const sighashes = []\n\n for (const fragment of tmpContract.rawContract.interface.fragments) {\n if (fragment.type === 'function') {\n const signature = fragment.format()\n const test = new TextEncoder().encode(signature)\n const sighash = '0x' + sha3.keccak_256(test).substring(0, 8)\n sighashes.push(sighash)\n }\n }\n return this.onTrace(\n sighashes,\n function (trace, ctx) {\n return handler(trace, ctx)\n },\n fetchConfig\n )\n }\n}\n"]}
1
+ {"version":3,"file":"base-processor.js","sourceRoot":"","sources":["../../src/eth/base-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,eAAe,EAAgB,aAAa,EAAE,MAAM,cAAc,CAAA;AAC9F,OAAO,EAML,cAAc,EAEd,a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A;QAC5B,CAAC,EACD,WAAW,CACZ,CAAA;IACH,CAAC;CACF","sourcesContent":["import { BaseContract, DeferredTopicFilter, TransactionResponseParams } from 'ethers'\n\nimport { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'\nimport {\n AddressType,\n Data_EthBlock,\n Data_EthLog,\n Data_EthTrace,\n Data_EthTransaction,\n EthFetchConfig,\n HandleInterval,\n ProcessResult,\n} from '@sentio/protos'\nimport { BindOptions } from './bind-options.js'\nimport { PromiseOrVoid } from '../core/promises.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { fixEmptyKey, formatEthData, RichBlock, TypedCallTrace, TypedEvent } from './eth.js'\nimport sha3 from 'js-sha3'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { EthChainId } from '../core/chain.js'\n\nexport interface AddressOrTypeEventFilter extends DeferredTopicFilter {\n addressType?: AddressType\n address?: string\n}\n\nexport class EventsHandler {\n filters: AddressOrTypeEventFilter[]\n handler: (event: Data_EthLog) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class TraceHandler {\n signatures: string[]\n handler: (trace: Data_EthTrace) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class BlockHandler {\n blockInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: (block: Data_EthBlock) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class TransactionHandler {\n handler: (block: Data_EthTransaction) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nclass BindInternalOptions {\n address: string\n network: EthChainId\n name: string\n startBlock: bigint\n endBlock?: bigint\n baseLabels?: { [key: string]: string }\n}\n\nexport class GlobalProcessorState extends ListStateStorage<GlobalProcessor> {\n static INSTANCE = new GlobalProcessorState()\n}\n\nexport class GlobalProcessor {\n config: BindInternalOptions\n blockHandlers: BlockHandler[] = []\n transactionHandler: TransactionHandler[] = []\n\n static bind(config: Omit<BindOptions, 'address'>): GlobalProcessor {\n const processor = new GlobalProcessor(config)\n GlobalProcessorState.INSTANCE.addValue(processor)\n return processor\n }\n\n constructor(config: Omit<BindOptions, 'address'>) {\n this.config = {\n address: '*',\n name: config.name || 'Global',\n network: config.network || EthChainId.ETHEREUM,\n startBlock: 0n,\n }\n if (config.startBlock) {\n this.config.startBlock = BigInt(config.startBlock)\n }\n if (config.endBlock) {\n this.config.endBlock = BigInt(config.endBlock)\n }\n }\n\n public onBlockInterval(\n handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,\n blockInterval = 250,\n backfillBlockInterval = 1000,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n undefined,\n {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n },\n fetchConfig\n )\n }\n\n public onTimeInterval(\n handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },\n undefined,\n fetchConfig\n )\n }\n\n public getChainId(): EthChainId {\n return this.config.network\n }\n\n public onInterval(\n handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined,\n fetchConfig: Partial<EthFetchConfig> | undefined\n ): this {\n const chainId = this.getChainId()\n\n this.blockHandlers.push({\n handler: async function (data: Data_EthBlock) {\n const { block } = formatEthData(data)\n\n if (!block) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Block is empty')\n }\n\n const ctx = new GlobalContext(chainId, new Date(block.timestamp * 1000), block, undefined, undefined)\n await handler(block, ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n blockInterval: blockInterval,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n })\n return this\n }\n\n public onTransaction(\n handler: (transaction: TransactionResponseParams, ctx: GlobalContext) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const chainId = this.getChainId()\n this.transactionHandler.push({\n handler: async function (data: Data_EthTransaction) {\n const { trace, block, transaction, transactionReceipt } = formatEthData(data)\n\n if (!transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is empty')\n }\n const ctx = new GlobalContext(chainId, data.timestamp, block, undefined, trace, transaction, transactionReceipt)\n await handler(transaction, ctx)\n return ctx.getProcessResult()\n },\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n })\n return this\n }\n}\n\nexport abstract class BaseProcessor<\n TContract extends BaseContract,\n TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>\n> {\n blockHandlers: BlockHandler[] = []\n eventHandlers: EventsHandler[] = []\n traceHandlers: TraceHandler[] = []\n\n config: BindInternalOptions\n\n constructor(config: BindOptions) {\n this.config = {\n address: config.address,\n name: config.name || '',\n network: config.network || EthChainId.ETHEREUM,\n startBlock: 0n,\n baseLabels: config.baseLabels,\n }\n if (config.startBlock) {\n this.config.startBlock = BigInt(config.startBlock)\n }\n if (config.endBlock) {\n this.config.endBlock = BigInt(config.endBlock)\n }\n }\n\n protected abstract CreateBoundContractView(): TBoundContractView\n\n public getChainId(): EthChainId {\n return this.config.network\n }\n\n public onEvent(\n handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const _filters: DeferredTopicFilter[] = []\n const tmpContract = this.CreateBoundContractView()\n\n for (const fragment of tmpContract.rawContract.interface.fragments) {\n if (fragment.type === 'event') {\n const filter = tmpContract.rawContract.filters[fragment.format()]\n _filters.push(filter())\n }\n }\n return this.onEthEvent(\n function (log, ctx) {\n return handler(log, ctx)\n },\n _filters,\n fetchConfig\n )\n }\n\n protected onEthEvent(\n handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: DeferredTopicFilter | DeferredTopicFilter[],\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const chainId = this.getChainId()\n let _filters: DeferredTopicFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n const contractName = this.config.name\n const processor = this\n this.eventHandlers.push({\n filters: _filters,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n handler: async function (data: Data_EthLog) {\n const { log, block, transaction, transactionReceipt } = formatEthData(data)\n if (!log) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')\n }\n const contractView = processor.CreateBoundContractView()\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n data.timestamp,\n block,\n log,\n undefined,\n transaction,\n transactionReceipt\n )\n const logParam = log as any as { topics: Array<string>; data: string }\n\n const parsed = contractView.rawContract.interface.parseLog(logParam)\n\n if (parsed) {\n const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }\n await handler(event, ctx)\n return ctx.getProcessResult()\n }\n return ProcessResult.fromPartial({})\n },\n })\n return this\n }\n\n public onBlockInterval(\n handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n blockInterval = 250,\n backfillBlockInterval = 1000,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n undefined,\n {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n },\n fetchConfig\n )\n }\n\n public onTimeInterval(\n handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },\n undefined,\n fetchConfig\n )\n }\n\n public onInterval(\n handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined,\n fetchConfig: Partial<EthFetchConfig> | undefined\n ): this {\n const chainId = this.getChainId()\n const processor = this\n const contractName = this.config.name\n\n this.blockHandlers.push({\n handler: async function (data: Data_EthBlock) {\n const { block } = formatEthData(data)\n\n if (!block) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Block is empty')\n }\n\n const contractView = processor.CreateBoundContractView()\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n new Date(block.timestamp * 1000),\n block,\n undefined,\n undefined\n )\n await handler(block, ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n blockInterval: blockInterval,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n })\n return this\n }\n\n protected onEthTrace(\n signatures: string | string[],\n handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const chainId = this.getChainId()\n const contractName = this.config.name\n const processor = this\n if (typeof signatures === 'string') {\n signatures = [signatures]\n }\n\n this.traceHandlers.push({\n signatures,\n fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),\n handler: async function (data: Data_EthTrace) {\n const contractView = processor.CreateBoundContractView()\n const contractInterface = contractView.rawContract.interface\n const { trace, block, transaction, transactionReceipt } = formatEthData(data)\n const sighash = trace?.action.input?.slice(0, 10)\n if (!sighash) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'trace has no sighash')\n }\n const fragment = contractInterface.getFunction(sighash)\n\n if (!trace || !fragment) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'trace is null')\n }\n const typedTrace = trace as TypedCallTrace\n typedTrace.name = fragment.name\n typedTrace.functionSignature = fragment.format()\n // const trace = data.trace as Trace\n if (!trace?.action.input) {\n return ProcessResult.fromPartial({})\n }\n const traceData = '0x' + trace.action.input.slice(10)\n try {\n typedTrace.args = contractInterface.getAbiCoder().decode(fragment.inputs, traceData, true)\n } catch (e) {\n if (!trace.error) {\n throw e\n }\n console.error('Failed to decode successful trace', e)\n }\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n data.timestamp,\n block,\n undefined,\n trace,\n transaction,\n transactionReceipt\n )\n await handler(typedTrace, ctx)\n return ctx.getProcessResult()\n },\n })\n return this\n }\n\n public onTrace(\n handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: Partial<EthFetchConfig>\n ): this {\n const tmpContract = this.CreateBoundContractView()\n const sighashes = []\n\n for (const fragment of tmpContract.rawContract.interface.fragments) {\n if (fragment.type === 'function') {\n const signature = fragment.format()\n const test = new TextEncoder().encode(signature)\n const sighash = '0x' + sha3.keccak_256(test).substring(0, 8)\n sighashes.push(sighash)\n }\n }\n return this.onEthTrace(\n sighashes,\n function (trace, ctx) {\n return handler(trace, ctx)\n },\n fetchConfig\n )\n }\n}\n"]}
@@ -265,94 +265,94 @@ class EACAggregatorProxyProcessor extends BaseProcessor {
265
265
  if (!filter) {
266
266
  filter = templateContract.filters["AnswerUpdated(int256,uint256,uint256)"](null, null, null);
267
267
  }
268
- return super.onEvent(handler, filter, fetchConfig);
268
+ return super.onEthEvent(handler, filter, fetchConfig);
269
269
  }
270
270
  onEventNewRound(handler, filter, fetchConfig) {
271
271
  if (!filter) {
272
272
  filter = templateContract.filters["NewRound(uint256,address,uint256)"](null, null, null);
273
273
  }
274
- return super.onEvent(handler, filter, fetchConfig);
274
+ return super.onEthEvent(handler, filter, fetchConfig);
275
275
  }
276
276
  onEventOwnershipTransferRequested(handler, filter, fetchConfig) {
277
277
  if (!filter) {
278
278
  filter = templateContract.filters["OwnershipTransferRequested(address,address)"](null, null);
279
279
  }
280
- return super.onEvent(handler, filter, fetchConfig);
280
+ return super.onEthEvent(handler, filter, fetchConfig);
281
281
  }
282
282
  onEventOwnershipTransferred(handler, filter, fetchConfig) {
283
283
  if (!filter) {
284
284
  filter = templateContract.filters["OwnershipTransferred(address,address)"](null, null);
285
285
  }
286
- return super.onEvent(handler, filter, fetchConfig);
286
+ return super.onEthEvent(handler, filter, fetchConfig);
287
287
  }
288
288
  onCallAcceptOwnership(handler, fetchConfig) {
289
- return super.onTrace("0x79ba5097", handler, fetchConfig);
289
+ return super.onEthTrace("0x79ba5097", handler, fetchConfig);
290
290
  }
291
291
  onCallAccessController(handler, fetchConfig) {
292
- return super.onTrace("0xbc43cbaf", handler, fetchConfig);
292
+ return super.onEthTrace("0xbc43cbaf", handler, fetchConfig);
293
293
  }
294
294
  onCallAggregator(handler, fetchConfig) {
295
- return super.onTrace("0x245a7bfc", handler, fetchConfig);
295
+ return super.onEthTrace("0x245a7bfc", handler, fetchConfig);
296
296
  }
297
297
  onCallConfirmAggregator(handler, fetchConfig) {
298
- return super.onTrace("0xa928c096", handler, fetchConfig);
298
+ return super.onEthTrace("0xa928c096", handler, fetchConfig);
299
299
  }
300
300
  onCallDecimals(handler, fetchConfig) {
301
- return super.onTrace("0x313ce567", handler, fetchConfig);
301
+ return super.onEthTrace("0x313ce567", handler, fetchConfig);
302
302
  }
303
303
  onCallDescription(handler, fetchConfig) {
304
- return super.onTrace("0x7284e416", handler, fetchConfig);
304
+ return super.onEthTrace("0x7284e416", handler, fetchConfig);
305
305
  }
306
306
  onCallGetAnswer(handler, fetchConfig) {
307
- return super.onTrace("0xb5ab58dc", handler, fetchConfig);
307
+ return super.onEthTrace("0xb5ab58dc", handler, fetchConfig);
308
308
  }
309
309
  onCallGetRoundData(handler, fetchConfig) {
310
- return super.onTrace("0x9a6fc8f5", handler, fetchConfig);
310
+ return super.onEthTrace("0x9a6fc8f5", handler, fetchConfig);
311
311
  }
312
312
  onCallGetTimestamp(handler, fetchConfig) {
313
- return super.onTrace("0xb633620c", handler, fetchConfig);
313
+ return super.onEthTrace("0xb633620c", handler, fetchConfig);
314
314
  }
315
315
  onCallLatestAnswer(handler, fetchConfig) {
316
- return super.onTrace("0x50d25bcd", handler, fetchConfig);
316
+ return super.onEthTrace("0x50d25bcd", handler, fetchConfig);
317
317
  }
318
318
  onCallLatestRound(handler, fetchConfig) {
319
- return super.onTrace("0x668a0f02", handler, fetchConfig);
319
+ return super.onEthTrace("0x668a0f02", handler, fetchConfig);
320
320
  }
321
321
  onCallLatestRoundData(handler, fetchConfig) {
322
- return super.onTrace("0xfeaf968c", handler, fetchConfig);
322
+ return super.onEthTrace("0xfeaf968c", handler, fetchConfig);
323
323
  }
324
324
  onCallLatestTimestamp(handler, fetchConfig) {
325
- return super.onTrace("0x8205bf6a", handler, fetchConfig);
325
+ return super.onEthTrace("0x8205bf6a", handler, fetchConfig);
326
326
  }
327
327
  onCallOwner(handler, fetchConfig) {
328
- return super.onTrace("0x8da5cb5b", handler, fetchConfig);
328
+ return super.onEthTrace("0x8da5cb5b", handler, fetchConfig);
329
329
  }
330
330
  onCallPhaseAggregators(handler, fetchConfig) {
331
- return super.onTrace("0xc1597304", handler, fetchConfig);
331
+ return super.onEthTrace("0xc1597304", handler, fetchConfig);
332
332
  }
333
333
  onCallPhaseId(handler, fetchConfig) {
334
- return super.onTrace("0x58303b10", handler, fetchConfig);
334
+ return super.onEthTrace("0x58303b10", handler, fetchConfig);
335
335
  }
336
336
  onCallProposeAggregator(handler, fetchConfig) {
337
- return super.onTrace("0xf8a2abd3", handler, fetchConfig);
337
+ return super.onEthTrace("0xf8a2abd3", handler, fetchConfig);
338
338
  }
339
339
  onCallProposedAggregator(handler, fetchConfig) {
340
- return super.onTrace("0xe8c4be30", handler, fetchConfig);
340
+ return super.onEthTrace("0xe8c4be30", handler, fetchConfig);
341
341
  }
342
342
  onCallProposedGetRoundData(handler, fetchConfig) {
343
- return super.onTrace("0x6001ac53", handler, fetchConfig);
343
+ return super.onEthTrace("0x6001ac53", handler, fetchConfig);
344
344
  }
345
345
  onCallProposedLatestRoundData(handler, fetchConfig) {
346
- return super.onTrace("0x8f6b4d91", handler, fetchConfig);
346
+ return super.onEthTrace("0x8f6b4d91", handler, fetchConfig);
347
347
  }
348
348
  onCallSetController(handler, fetchConfig) {
349
- return super.onTrace("0x92eefe9b", handler, fetchConfig);
349
+ return super.onEthTrace("0x92eefe9b", handler, fetchConfig);
350
350
  }
351
351
  onCallTransferOwnership(handler, fetchConfig) {
352
- return super.onTrace("0xf2fde38b", handler, fetchConfig);
352
+ return super.onEthTrace("0xf2fde38b", handler, fetchConfig);
353
353
  }
354
354
  onCallVersion(handler, fetchConfig) {
355
- return super.onTrace("0x54fd4d50", handler, fetchConfig);
355
+ return super.onEthTrace("0x54fd4d50", handler, fetchConfig);
356
356
  }
357
357
  static filters = {
358
358
  AnswerUpdated(current, roundId, updatedAt) {
@@ -401,25 +401,25 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate {
401
401
  if (!filter) {
402
402
  filter = templateContract.filters["AnswerUpdated(int256,uint256,uint256)"](null, null, null);
403
403
  }
404
- return super.onEvent(handler, filter, fetchConfig);
404
+ return super.onEthEvent(handler, filter, fetchConfig);
405
405
  }
406
406
  onEventNewRound(handler, filter, fetchConfig) {
407
407
  if (!filter) {
408
408
  filter = templateContract.filters["NewRound(uint256,address,uint256)"](null, null, null);
409
409
  }
410
- return super.onEvent(handler, filter, fetchConfig);
410
+ return super.onEthEvent(handler, filter, fetchConfig);
411
411
  }
412
412
  onEventOwnershipTransferRequested(handler, filter, fetchConfig) {
413
413
  if (!filter) {
414
414
  filter = templateContract.filters["OwnershipTransferRequested(address,address)"](null, null);
415
415
  }
416
- return super.onEvent(handler, filter, fetchConfig);
416
+ return super.onEthEvent(handler, filter, fetchConfig);
417
417
  }
418
418
  onEventOwnershipTransferred(handler, filter, fetchConfig) {
419
419
  if (!filter) {
420
420
  filter = templateContract.filters["OwnershipTransferred(address,address)"](null, null);
421
421
  }
422
- return super.onEvent(handler, filter, fetchConfig);
422
+ return super.onEthEvent(handler, filter, fetchConfig);
423
423
  }
424
424
  }
425
425
  export function getEACAggregatorProxyContract(chainId, address) {