@sentio/sdk 2.40.0-rc.17 → 2.40.0-rc.18

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 (46) hide show
  1. package/lib/eth/account-processor.d.ts +21 -7
  2. package/lib/eth/account-processor.d.ts.map +1 -1
  3. package/lib/eth/account-processor.js +2 -2
  4. package/lib/eth/account-processor.js.map +1 -1
  5. package/lib/eth/base-processor-template.d.ts +24 -8
  6. package/lib/eth/base-processor-template.d.ts.map +1 -1
  7. package/lib/eth/base-processor-template.js.map +1 -1
  8. package/lib/eth/base-processor.d.ts +30 -10
  9. package/lib/eth/base-processor.d.ts.map +1 -1
  10. package/lib/eth/base-processor.js +6 -6
  11. package/lib/eth/base-processor.js.map +1 -1
  12. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +24 -8
  13. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  14. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  15. package/lib/eth/builtin/internal/erc1155-processor.d.ts +24 -8
  16. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  17. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  18. package/lib/eth/builtin/internal/erc20-processor.d.ts +18 -6
  19. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  20. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  21. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +12 -4
  22. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  23. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  24. package/lib/eth/builtin/internal/erc721-processor.d.ts +18 -6
  25. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  26. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  27. package/lib/eth/builtin/internal/weth9-processor.d.ts +24 -8
  28. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  29. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  30. package/lib/eth/codegen/event-handler.js +1 -1
  31. package/lib/eth/eth-plugin.d.ts +27 -9
  32. package/lib/eth/eth-plugin.d.ts.map +1 -1
  33. package/lib/eth/eth-plugin.js +13 -13
  34. package/lib/eth/eth-plugin.js.map +1 -1
  35. package/package.json +3 -3
  36. package/src/eth/account-processor.ts +28 -12
  37. package/src/eth/base-processor-template.ts +16 -8
  38. package/src/eth/base-processor.ts +25 -16
  39. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +16 -8
  40. package/src/eth/builtin/internal/erc1155-processor.ts +16 -8
  41. package/src/eth/builtin/internal/erc20-processor.ts +12 -6
  42. package/src/eth/builtin/internal/erc20bytes-processor.ts +8 -4
  43. package/src/eth/builtin/internal/erc721-processor.ts +12 -6
  44. package/src/eth/builtin/internal/weth9-processor.ts +16 -8
  45. package/src/eth/codegen/event-handler.ts +1 -1
  46. package/src/eth/eth-plugin.ts +27 -22
@@ -31,14 +31,14 @@ export const defaultPreprocessHandler = () => (<PreprocessResult>{ ethCallParams
31
31
  export class EventsHandler {
32
32
  filters: AddressOrTypeEventFilter[]
33
33
  handler: (event: Data_EthLog) => Promise<ProcessResult>
34
- preprocessHandler?: (event: Data_EthLog) => Promise<PreprocessResult>
34
+ preprocessHandler?: (event: Data_EthLog, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
35
35
  fetchConfig: EthFetchConfig
36
36
  }
37
37
 
38
38
  export class TraceHandler {
39
39
  signatures: string[]
40
40
  handler: (trace: Data_EthTrace) => Promise<ProcessResult>
41
- preprocessHandler?: (event: Data_EthTrace) => Promise<PreprocessResult>
41
+ preprocessHandler?: (event: Data_EthTrace, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
42
42
  fetchConfig: EthFetchConfig
43
43
  }
44
44
 
@@ -46,13 +46,13 @@ export class BlockHandler {
46
46
  blockInterval?: HandleInterval
47
47
  timeIntervalInMinutes?: HandleInterval
48
48
  handler: (block: Data_EthBlock) => Promise<ProcessResult>
49
- preprocessHandler?: (event: Data_EthBlock) => Promise<PreprocessResult>
49
+ preprocessHandler?: (event: Data_EthBlock, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
50
50
  fetchConfig: EthFetchConfig
51
51
  }
52
52
 
53
53
  export class TransactionHandler {
54
54
  handler: (block: Data_EthTransaction) => Promise<ProcessResult>
55
- preprocessHandler?: (event: Data_EthTransaction) => Promise<PreprocessResult>
55
+ preprocessHandler?: (event: Data_EthTransaction, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
56
56
  fetchConfig: EthFetchConfig
57
57
  }
58
58
 
@@ -314,7 +314,8 @@ export abstract class BaseProcessor<
314
314
  fetchConfig?: Partial<EthFetchConfig>,
315
315
  preprocessHandler: (
316
316
  event: TypedEvent,
317
- ctx: ContractContext<TContract, TBoundContractView>
317
+ ctx: ContractContext<TContract, TBoundContractView>,
318
+ preprocessStore: { [k: string]: any }
318
319
  ) => Promise<PreprocessResult> = defaultPreprocessHandler
319
320
  ): this {
320
321
  const chainId = this.getChainId()
@@ -382,7 +383,10 @@ export abstract class BaseProcessor<
382
383
  }
383
384
  return ProcessResult.fromPartial({})
384
385
  },
385
- preprocessHandler: async function (data: Data_EthLog): Promise<PreprocessResult> {
386
+ preprocessHandler: async function (
387
+ data: Data_EthLog,
388
+ preprocessStore: { [k: string]: any }
389
+ ): Promise<PreprocessResult> {
386
390
  const { log, block, transaction, transactionReceipt } = formatEthData(data)
387
391
  if (!log) {
388
392
  throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')
@@ -427,7 +431,7 @@ export abstract class BaseProcessor<
427
431
  }
428
432
  if (parsed) {
429
433
  const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }
430
- return preprocessHandler(event, ctx)
434
+ return preprocessHandler(event, ctx, preprocessStore)
431
435
  }
432
436
  return PreprocessResult.fromPartial({})
433
437
  }
@@ -442,7 +446,8 @@ export abstract class BaseProcessor<
442
446
  fetchConfig?: Partial<EthFetchConfig>,
443
447
  preprocessHandler: (
444
448
  block: RichBlock,
445
- ctx: ContractContext<TContract, TBoundContractView>
449
+ ctx: ContractContext<TContract, TBoundContractView>,
450
+ preprocessStore: { [k: string]: any }
446
451
  ) => Promise<PreprocessResult> = defaultPreprocessHandler
447
452
  ): this {
448
453
  return this.onInterval(
@@ -464,7 +469,8 @@ export abstract class BaseProcessor<
464
469
  fetchConfig?: Partial<EthFetchConfig>,
465
470
  preprocessHandler: (
466
471
  block: RichBlock,
467
- ctx: ContractContext<TContract, TBoundContractView>
472
+ ctx: ContractContext<TContract, TBoundContractView>,
473
+ preprocessStore: { [k: string]: any }
468
474
  ) => Promise<PreprocessResult> = defaultPreprocessHandler
469
475
  ): this {
470
476
  return this.onInterval(
@@ -483,7 +489,8 @@ export abstract class BaseProcessor<
483
489
  fetchConfig: Partial<EthFetchConfig> | undefined,
484
490
  preprocessHandler: (
485
491
  block: RichBlock,
486
- ctx: ContractContext<TContract, TBoundContractView>
492
+ ctx: ContractContext<TContract, TBoundContractView>,
493
+ preprocessStore: { [k: string]: any }
487
494
  ) => Promise<PreprocessResult> = defaultPreprocessHandler
488
495
  ): this {
489
496
  const chainId = this.getChainId()
@@ -516,7 +523,7 @@ export abstract class BaseProcessor<
516
523
  await handler(block, ctx)
517
524
  return ctx.stopAndGetResult()
518
525
  },
519
- preprocessHandler: async function (data: Data_EthBlock) {
526
+ preprocessHandler: async function (data: Data_EthBlock, preprocessStore: { [k: string]: any }) {
520
527
  const { block } = formatEthData(data)
521
528
 
522
529
  if (!block) {
@@ -537,7 +544,7 @@ export abstract class BaseProcessor<
537
544
  undefined,
538
545
  processor.config.baseLabels
539
546
  )
540
- return preprocessHandler(block, ctx)
547
+ return preprocessHandler(block, ctx, preprocessStore)
541
548
  },
542
549
  timeIntervalInMinutes: timeInterval,
543
550
  blockInterval: blockInterval,
@@ -552,7 +559,8 @@ export abstract class BaseProcessor<
552
559
  fetchConfig?: Partial<EthFetchConfig>,
553
560
  preprocessHandler: (
554
561
  trace: TypedCallTrace,
555
- ctx: ContractContext<TContract, TBoundContractView>
562
+ ctx: ContractContext<TContract, TBoundContractView>,
563
+ preprocessStore: { [k: string]: any }
556
564
  ) => Promise<PreprocessResult> = defaultPreprocessHandler
557
565
  ): this {
558
566
  const chainId = this.getChainId()
@@ -610,7 +618,7 @@ export abstract class BaseProcessor<
610
618
  await handler(typedTrace, ctx)
611
619
  return ctx.stopAndGetResult()
612
620
  },
613
- preprocessHandler: async function (data: Data_EthTrace) {
621
+ preprocessHandler: async function (data: Data_EthTrace, preprocessStore: { [k: string]: any }) {
614
622
  const contractView = processor.CreateBoundContractView()
615
623
  const contractInterface = contractView.rawContract.interface
616
624
  const { trace, block, transaction, transactionReceipt } = formatEthData(data)
@@ -651,7 +659,7 @@ export abstract class BaseProcessor<
651
659
  transactionReceipt,
652
660
  processor.config.baseLabels
653
661
  )
654
- return preprocessHandler(typedTrace, ctx)
662
+ return preprocessHandler(typedTrace, ctx, preprocessStore)
655
663
  }
656
664
  })
657
665
  return this
@@ -662,7 +670,8 @@ export abstract class BaseProcessor<
662
670
  fetchConfig?: Partial<EthFetchConfig>,
663
671
  preprocessHandler: (
664
672
  trace: TypedCallTrace,
665
- ctx: ContractContext<TContract, TBoundContractView>
673
+ ctx: ContractContext<TContract, TBoundContractView>,
674
+ preprocessStore: { [k: string]: any }
666
675
  ) => Promise<PreprocessResult> = defaultPreprocessHandler
667
676
  ): this {
668
677
  const tmpContract = this.CreateBoundContractView()
@@ -2257,7 +2257,8 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
2257
2257
  fetchConfig?: Partial<EthFetchConfig>,
2258
2258
  preprocessHandler?: (
2259
2259
  event: AnswerUpdatedEvent,
2260
- ctx: EACAggregatorProxyContext
2260
+ ctx: EACAggregatorProxyContext,
2261
+ preprocessStore: { [k: string]: any }
2261
2262
  ) => Promise<PreprocessResult>
2262
2263
  ): this {
2263
2264
  if (!filter) {
@@ -2274,7 +2275,8 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
2274
2275
  fetchConfig?: Partial<EthFetchConfig>,
2275
2276
  preprocessHandler?: (
2276
2277
  event: NewRoundEvent,
2277
- ctx: EACAggregatorProxyContext
2278
+ ctx: EACAggregatorProxyContext,
2279
+ preprocessStore: { [k: string]: any }
2278
2280
  ) => Promise<PreprocessResult>
2279
2281
  ): this {
2280
2282
  if (!filter) {
@@ -2298,7 +2300,8 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
2298
2300
  fetchConfig?: Partial<EthFetchConfig>,
2299
2301
  preprocessHandler?: (
2300
2302
  event: OwnershipTransferRequestedEvent,
2301
- ctx: EACAggregatorProxyContext
2303
+ ctx: EACAggregatorProxyContext,
2304
+ preprocessStore: { [k: string]: any }
2302
2305
  ) => Promise<PreprocessResult>
2303
2306
  ): this {
2304
2307
  if (!filter) {
@@ -2320,7 +2323,8 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
2320
2323
  fetchConfig?: Partial<EthFetchConfig>,
2321
2324
  preprocessHandler?: (
2322
2325
  event: OwnershipTransferredEvent,
2323
- ctx: EACAggregatorProxyContext
2326
+ ctx: EACAggregatorProxyContext,
2327
+ preprocessStore: { [k: string]: any }
2324
2328
  ) => Promise<PreprocessResult>
2325
2329
  ): this {
2326
2330
  if (!filter) {
@@ -2841,7 +2845,8 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
2841
2845
  fetchConfig?: Partial<EthFetchConfig>,
2842
2846
  preprocessHandler?: (
2843
2847
  event: AnswerUpdatedEvent,
2844
- ctx: EACAggregatorProxyContext
2848
+ ctx: EACAggregatorProxyContext,
2849
+ preprocessStore: { [k: string]: any }
2845
2850
  ) => Promise<PreprocessResult>
2846
2851
  ): this {
2847
2852
  if (!filter) {
@@ -2858,7 +2863,8 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
2858
2863
  fetchConfig?: Partial<EthFetchConfig>,
2859
2864
  preprocessHandler?: (
2860
2865
  event: NewRoundEvent,
2861
- ctx: EACAggregatorProxyContext
2866
+ ctx: EACAggregatorProxyContext,
2867
+ preprocessStore: { [k: string]: any }
2862
2868
  ) => Promise<PreprocessResult>
2863
2869
  ): this {
2864
2870
  if (!filter) {
@@ -2882,7 +2888,8 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
2882
2888
  fetchConfig?: Partial<EthFetchConfig>,
2883
2889
  preprocessHandler?: (
2884
2890
  event: OwnershipTransferRequestedEvent,
2885
- ctx: EACAggregatorProxyContext
2891
+ ctx: EACAggregatorProxyContext,
2892
+ preprocessStore: { [k: string]: any }
2886
2893
  ) => Promise<PreprocessResult>
2887
2894
  ): this {
2888
2895
  if (!filter) {
@@ -2904,7 +2911,8 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
2904
2911
  fetchConfig?: Partial<EthFetchConfig>,
2905
2912
  preprocessHandler?: (
2906
2913
  event: OwnershipTransferredEvent,
2907
- ctx: EACAggregatorProxyContext
2914
+ ctx: EACAggregatorProxyContext,
2915
+ preprocessStore: { [k: string]: any }
2908
2916
  ) => Promise<PreprocessResult>
2909
2917
  ): this {
2910
2918
  if (!filter) {
@@ -1054,7 +1054,8 @@ export class ERC1155Processor extends BaseProcessor<
1054
1054
  fetchConfig?: Partial<EthFetchConfig>,
1055
1055
  preprocessHandler?: (
1056
1056
  event: ApprovalForAllEvent,
1057
- ctx: ERC1155Context
1057
+ ctx: ERC1155Context,
1058
+ preprocessStore: { [k: string]: any }
1058
1059
  ) => Promise<PreprocessResult>
1059
1060
  ): this {
1060
1061
  if (!filter) {
@@ -1073,7 +1074,8 @@ export class ERC1155Processor extends BaseProcessor<
1073
1074
  fetchConfig?: Partial<EthFetchConfig>,
1074
1075
  preprocessHandler?: (
1075
1076
  event: TransferBatchEvent,
1076
- ctx: ERC1155Context
1077
+ ctx: ERC1155Context,
1078
+ preprocessStore: { [k: string]: any }
1077
1079
  ) => Promise<PreprocessResult>
1078
1080
  ): this {
1079
1081
  if (!filter) {
@@ -1090,7 +1092,8 @@ export class ERC1155Processor extends BaseProcessor<
1090
1092
  fetchConfig?: Partial<EthFetchConfig>,
1091
1093
  preprocessHandler?: (
1092
1094
  event: TransferSingleEvent,
1093
- ctx: ERC1155Context
1095
+ ctx: ERC1155Context,
1096
+ preprocessStore: { [k: string]: any }
1094
1097
  ) => Promise<PreprocessResult>
1095
1098
  ): this {
1096
1099
  if (!filter) {
@@ -1107,7 +1110,8 @@ export class ERC1155Processor extends BaseProcessor<
1107
1110
  fetchConfig?: Partial<EthFetchConfig>,
1108
1111
  preprocessHandler?: (
1109
1112
  event: URIEvent,
1110
- ctx: ERC1155Context
1113
+ ctx: ERC1155Context,
1114
+ preprocessStore: { [k: string]: any }
1111
1115
  ) => Promise<PreprocessResult>
1112
1116
  ): this {
1113
1117
  if (!filter) {
@@ -1326,7 +1330,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
1326
1330
  fetchConfig?: Partial<EthFetchConfig>,
1327
1331
  preprocessHandler?: (
1328
1332
  event: ApprovalForAllEvent,
1329
- ctx: ERC1155Context
1333
+ ctx: ERC1155Context,
1334
+ preprocessStore: { [k: string]: any }
1330
1335
  ) => Promise<PreprocessResult>
1331
1336
  ): this {
1332
1337
  if (!filter) {
@@ -1345,7 +1350,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
1345
1350
  fetchConfig?: Partial<EthFetchConfig>,
1346
1351
  preprocessHandler?: (
1347
1352
  event: TransferBatchEvent,
1348
- ctx: ERC1155Context
1353
+ ctx: ERC1155Context,
1354
+ preprocessStore: { [k: string]: any }
1349
1355
  ) => Promise<PreprocessResult>
1350
1356
  ): this {
1351
1357
  if (!filter) {
@@ -1362,7 +1368,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
1362
1368
  fetchConfig?: Partial<EthFetchConfig>,
1363
1369
  preprocessHandler?: (
1364
1370
  event: TransferSingleEvent,
1365
- ctx: ERC1155Context
1371
+ ctx: ERC1155Context,
1372
+ preprocessStore: { [k: string]: any }
1366
1373
  ) => Promise<PreprocessResult>
1367
1374
  ): this {
1368
1375
  if (!filter) {
@@ -1379,7 +1386,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
1379
1386
  fetchConfig?: Partial<EthFetchConfig>,
1380
1387
  preprocessHandler?: (
1381
1388
  event: URIEvent,
1382
- ctx: ERC1155Context
1389
+ ctx: ERC1155Context,
1390
+ preprocessStore: { [k: string]: any }
1383
1391
  ) => Promise<PreprocessResult>
1384
1392
  ): this {
1385
1393
  if (!filter) {
@@ -1828,7 +1828,8 @@ export class ERC20Processor extends BaseProcessor<
1828
1828
  fetchConfig?: Partial<EthFetchConfig>,
1829
1829
  preprocessHandler?: (
1830
1830
  event: ApprovalEvent,
1831
- ctx: ERC20Context
1831
+ ctx: ERC20Context,
1832
+ preprocessStore: { [k: string]: any }
1832
1833
  ) => Promise<PreprocessResult>
1833
1834
  ): this {
1834
1835
  if (!filter) {
@@ -1849,7 +1850,8 @@ export class ERC20Processor extends BaseProcessor<
1849
1850
  fetchConfig?: Partial<EthFetchConfig>,
1850
1851
  preprocessHandler?: (
1851
1852
  event: OwnershipTransferredEvent,
1852
- ctx: ERC20Context
1853
+ ctx: ERC20Context,
1854
+ preprocessStore: { [k: string]: any }
1853
1855
  ) => Promise<PreprocessResult>
1854
1856
  ): this {
1855
1857
  if (!filter) {
@@ -1866,7 +1868,8 @@ export class ERC20Processor extends BaseProcessor<
1866
1868
  fetchConfig?: Partial<EthFetchConfig>,
1867
1869
  preprocessHandler?: (
1868
1870
  event: TransferEvent,
1869
- ctx: ERC20Context
1871
+ ctx: ERC20Context,
1872
+ preprocessStore: { [k: string]: any }
1870
1873
  ) => Promise<PreprocessResult>
1871
1874
  ): this {
1872
1875
  if (!filter) {
@@ -2241,7 +2244,8 @@ export class ERC20ProcessorTemplate extends BaseProcessorTemplate<
2241
2244
  fetchConfig?: Partial<EthFetchConfig>,
2242
2245
  preprocessHandler?: (
2243
2246
  event: ApprovalEvent,
2244
- ctx: ERC20Context
2247
+ ctx: ERC20Context,
2248
+ preprocessStore: { [k: string]: any }
2245
2249
  ) => Promise<PreprocessResult>
2246
2250
  ): this {
2247
2251
  if (!filter) {
@@ -2262,7 +2266,8 @@ export class ERC20ProcessorTemplate extends BaseProcessorTemplate<
2262
2266
  fetchConfig?: Partial<EthFetchConfig>,
2263
2267
  preprocessHandler?: (
2264
2268
  event: OwnershipTransferredEvent,
2265
- ctx: ERC20Context
2269
+ ctx: ERC20Context,
2270
+ preprocessStore: { [k: string]: any }
2266
2271
  ) => Promise<PreprocessResult>
2267
2272
  ): this {
2268
2273
  if (!filter) {
@@ -2279,7 +2284,8 @@ export class ERC20ProcessorTemplate extends BaseProcessorTemplate<
2279
2284
  fetchConfig?: Partial<EthFetchConfig>,
2280
2285
  preprocessHandler?: (
2281
2286
  event: TransferEvent,
2282
- ctx: ERC20Context
2287
+ ctx: ERC20Context,
2288
+ preprocessStore: { [k: string]: any }
2283
2289
  ) => Promise<PreprocessResult>
2284
2290
  ): this {
2285
2291
  if (!filter) {
@@ -940,7 +940,8 @@ export class ERC20BytesProcessor extends BaseProcessor<
940
940
  fetchConfig?: Partial<EthFetchConfig>,
941
941
  preprocessHandler?: (
942
942
  event: ApprovalEvent,
943
- ctx: ERC20BytesContext
943
+ ctx: ERC20BytesContext,
944
+ preprocessStore: { [k: string]: any }
944
945
  ) => Promise<PreprocessResult>
945
946
  ): this {
946
947
  if (!filter) {
@@ -959,7 +960,8 @@ export class ERC20BytesProcessor extends BaseProcessor<
959
960
  fetchConfig?: Partial<EthFetchConfig>,
960
961
  preprocessHandler?: (
961
962
  event: TransferEvent,
962
- ctx: ERC20BytesContext
963
+ ctx: ERC20BytesContext,
964
+ preprocessStore: { [k: string]: any }
963
965
  ) => Promise<PreprocessResult>
964
966
  ): this {
965
967
  if (!filter) {
@@ -1184,7 +1186,8 @@ export class ERC20BytesProcessorTemplate extends BaseProcessorTemplate<
1184
1186
  fetchConfig?: Partial<EthFetchConfig>,
1185
1187
  preprocessHandler?: (
1186
1188
  event: ApprovalEvent,
1187
- ctx: ERC20BytesContext
1189
+ ctx: ERC20BytesContext,
1190
+ preprocessStore: { [k: string]: any }
1188
1191
  ) => Promise<PreprocessResult>
1189
1192
  ): this {
1190
1193
  if (!filter) {
@@ -1203,7 +1206,8 @@ export class ERC20BytesProcessorTemplate extends BaseProcessorTemplate<
1203
1206
  fetchConfig?: Partial<EthFetchConfig>,
1204
1207
  preprocessHandler?: (
1205
1208
  event: TransferEvent,
1206
- ctx: ERC20BytesContext
1209
+ ctx: ERC20BytesContext,
1210
+ preprocessStore: { [k: string]: any }
1207
1211
  ) => Promise<PreprocessResult>
1208
1212
  ): this {
1209
1213
  if (!filter) {
@@ -1550,7 +1550,8 @@ export class ERC721Processor extends BaseProcessor<
1550
1550
  fetchConfig?: Partial<EthFetchConfig>,
1551
1551
  preprocessHandler?: (
1552
1552
  event: ApprovalEvent,
1553
- ctx: ERC721Context
1553
+ ctx: ERC721Context,
1554
+ preprocessStore: { [k: string]: any }
1554
1555
  ) => Promise<PreprocessResult>
1555
1556
  ): this {
1556
1557
  if (!filter) {
@@ -1569,7 +1570,8 @@ export class ERC721Processor extends BaseProcessor<
1569
1570
  fetchConfig?: Partial<EthFetchConfig>,
1570
1571
  preprocessHandler?: (
1571
1572
  event: ApprovalForAllEvent,
1572
- ctx: ERC721Context
1573
+ ctx: ERC721Context,
1574
+ preprocessStore: { [k: string]: any }
1573
1575
  ) => Promise<PreprocessResult>
1574
1576
  ): this {
1575
1577
  if (!filter) {
@@ -1588,7 +1590,8 @@ export class ERC721Processor extends BaseProcessor<
1588
1590
  fetchConfig?: Partial<EthFetchConfig>,
1589
1591
  preprocessHandler?: (
1590
1592
  event: TransferEvent,
1591
- ctx: ERC721Context
1593
+ ctx: ERC721Context,
1594
+ preprocessStore: { [k: string]: any }
1592
1595
  ) => Promise<PreprocessResult>
1593
1596
  ): this {
1594
1597
  if (!filter) {
@@ -1907,7 +1910,8 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
1907
1910
  fetchConfig?: Partial<EthFetchConfig>,
1908
1911
  preprocessHandler?: (
1909
1912
  event: ApprovalEvent,
1910
- ctx: ERC721Context
1913
+ ctx: ERC721Context,
1914
+ preprocessStore: { [k: string]: any }
1911
1915
  ) => Promise<PreprocessResult>
1912
1916
  ): this {
1913
1917
  if (!filter) {
@@ -1926,7 +1930,8 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
1926
1930
  fetchConfig?: Partial<EthFetchConfig>,
1927
1931
  preprocessHandler?: (
1928
1932
  event: ApprovalForAllEvent,
1929
- ctx: ERC721Context
1933
+ ctx: ERC721Context,
1934
+ preprocessStore: { [k: string]: any }
1930
1935
  ) => Promise<PreprocessResult>
1931
1936
  ): this {
1932
1937
  if (!filter) {
@@ -1945,7 +1950,8 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
1945
1950
  fetchConfig?: Partial<EthFetchConfig>,
1946
1951
  preprocessHandler?: (
1947
1952
  event: TransferEvent,
1948
- ctx: ERC721Context
1953
+ ctx: ERC721Context,
1954
+ preprocessStore: { [k: string]: any }
1949
1955
  ) => Promise<PreprocessResult>
1950
1956
  ): this {
1951
1957
  if (!filter) {
@@ -1085,7 +1085,8 @@ export class WETH9Processor extends BaseProcessor<
1085
1085
  fetchConfig?: Partial<EthFetchConfig>,
1086
1086
  preprocessHandler?: (
1087
1087
  event: ApprovalEvent,
1088
- ctx: WETH9Context
1088
+ ctx: WETH9Context,
1089
+ preprocessStore: { [k: string]: any }
1089
1090
  ) => Promise<PreprocessResult>
1090
1091
  ): this {
1091
1092
  if (!filter) {
@@ -1104,7 +1105,8 @@ export class WETH9Processor extends BaseProcessor<
1104
1105
  fetchConfig?: Partial<EthFetchConfig>,
1105
1106
  preprocessHandler?: (
1106
1107
  event: TransferEvent,
1107
- ctx: WETH9Context
1108
+ ctx: WETH9Context,
1109
+ preprocessStore: { [k: string]: any }
1108
1110
  ) => Promise<PreprocessResult>
1109
1111
  ): this {
1110
1112
  if (!filter) {
@@ -1123,7 +1125,8 @@ export class WETH9Processor extends BaseProcessor<
1123
1125
  fetchConfig?: Partial<EthFetchConfig>,
1124
1126
  preprocessHandler?: (
1125
1127
  event: DepositEvent,
1126
- ctx: WETH9Context
1128
+ ctx: WETH9Context,
1129
+ preprocessStore: { [k: string]: any }
1127
1130
  ) => Promise<PreprocessResult>
1128
1131
  ): this {
1129
1132
  if (!filter) {
@@ -1138,7 +1141,8 @@ export class WETH9Processor extends BaseProcessor<
1138
1141
  fetchConfig?: Partial<EthFetchConfig>,
1139
1142
  preprocessHandler?: (
1140
1143
  event: WithdrawalEvent,
1141
- ctx: WETH9Context
1144
+ ctx: WETH9Context,
1145
+ preprocessStore: { [k: string]: any }
1142
1146
  ) => Promise<PreprocessResult>
1143
1147
  ): this {
1144
1148
  if (!filter) {
@@ -1397,7 +1401,8 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
1397
1401
  fetchConfig?: Partial<EthFetchConfig>,
1398
1402
  preprocessHandler?: (
1399
1403
  event: ApprovalEvent,
1400
- ctx: WETH9Context
1404
+ ctx: WETH9Context,
1405
+ preprocessStore: { [k: string]: any }
1401
1406
  ) => Promise<PreprocessResult>
1402
1407
  ): this {
1403
1408
  if (!filter) {
@@ -1416,7 +1421,8 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
1416
1421
  fetchConfig?: Partial<EthFetchConfig>,
1417
1422
  preprocessHandler?: (
1418
1423
  event: TransferEvent,
1419
- ctx: WETH9Context
1424
+ ctx: WETH9Context,
1425
+ preprocessStore: { [k: string]: any }
1420
1426
  ) => Promise<PreprocessResult>
1421
1427
  ): this {
1422
1428
  if (!filter) {
@@ -1435,7 +1441,8 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
1435
1441
  fetchConfig?: Partial<EthFetchConfig>,
1436
1442
  preprocessHandler?: (
1437
1443
  event: DepositEvent,
1438
- ctx: WETH9Context
1444
+ ctx: WETH9Context,
1445
+ preprocessStore: { [k: string]: any }
1439
1446
  ) => Promise<PreprocessResult>
1440
1447
  ): this {
1441
1448
  if (!filter) {
@@ -1450,7 +1457,8 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
1450
1457
  fetchConfig?: Partial<EthFetchConfig>,
1451
1458
  preprocessHandler?: (
1452
1459
  event: WithdrawalEvent,
1453
- ctx: WETH9Context
1460
+ ctx: WETH9Context,
1461
+ preprocessStore: { [k: string]: any }
1454
1462
  ) => Promise<PreprocessResult>
1455
1463
  ): this {
1456
1464
  if (!filter) {
@@ -12,7 +12,7 @@ export function generateEventHandler(event: EventDeclaration, contractName: stri
12
12
  handler: (event: ${eventNamePrefix}Event, ctx: ${contractName}Context) => void,
13
13
  filter?: ${eventNamePrefix}EventFilter | ${eventNamePrefix}EventFilter[],
14
14
  fetchConfig?: Partial<EthFetchConfig>,
15
- preprocessHandler?: (event: ${eventNamePrefix}Event, ctx: ${contractName}Context) => Promise<PreprocessResult>
15
+ preprocessHandler?: (event: ${eventNamePrefix}Event, ctx: ${contractName}Context, preprocessStore: {[k: string]: any}) => Promise<PreprocessResult>
16
16
  ): this {
17
17
  if (!filter) {
18
18
  filter = templateContract.filters['${filterName}'](${event.inputs.map(() => 'null').join(',')})
@@ -35,10 +35,13 @@ interface Handlers {
35
35
  }
36
36
 
37
37
  interface PreprocessHandlers {
38
- eventHandlers: ((event: Data_EthLog) => Promise<PreprocessResult>)[]
39
- traceHandlers: ((trace: Data_EthTrace) => Promise<PreprocessResult>)[]
40
- blockHandlers: ((block: Data_EthBlock) => Promise<PreprocessResult>)[]
41
- transactionHandlers: ((txn: Data_EthTransaction) => Promise<PreprocessResult>)[]
38
+ eventHandlers: ((event: Data_EthLog, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>)[]
39
+ traceHandlers: ((trace: Data_EthTrace, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>)[]
40
+ blockHandlers: ((block: Data_EthBlock, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>)[]
41
+ transactionHandlers: ((
42
+ txn: Data_EthTransaction,
43
+ preprocessStore: { [k: string]: any }
44
+ ) => Promise<PreprocessResult>)[]
42
45
  }
43
46
 
44
47
  export class EthPlugin extends Plugin {
@@ -278,16 +281,16 @@ export class EthPlugin extends Plugin {
278
281
  }
279
282
  }
280
283
 
281
- preprocessBinding(request: DataBinding): Promise<PreprocessResult> {
284
+ preprocessBinding(request: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
282
285
  switch (request.handlerType) {
283
286
  case HandlerType.ETH_LOG:
284
- return this.preprocessLog(request)
287
+ return this.preprocessLog(request, preprocessStore)
285
288
  case HandlerType.ETH_TRACE:
286
- return this.preprocessTrace(request)
289
+ return this.preprocessTrace(request, preprocessStore)
287
290
  case HandlerType.ETH_BLOCK:
288
- return this.preprocessBlock(request)
291
+ return this.preprocessBlock(request, preprocessStore)
289
292
  case HandlerType.ETH_TRANSACTION:
290
- return this.preprocessTransaction(request)
293
+ return this.preprocessTransaction(request, preprocessStore)
291
294
  default:
292
295
  throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
293
296
  }
@@ -326,7 +329,7 @@ export class EthPlugin extends Plugin {
326
329
  return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length
327
330
  }
328
331
 
329
- async preprocessLog(request: DataBinding): Promise<PreprocessResult> {
332
+ async preprocessLog(request: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
330
333
  if (!request.data?.ethLog?.log) {
331
334
  throw new ServerError(Status.INVALID_ARGUMENT, "Log can't be null")
332
335
  }
@@ -335,7 +338,7 @@ export class EthPlugin extends Plugin {
335
338
  const promises: Promise<PreprocessResult>[] = []
336
339
  for (const handlerId of request.handlerIds) {
337
340
  const handler = this.preprocessHandlers.eventHandlers[handlerId]
338
- const promise = handler(ethLog).catch((e) => {
341
+ const promise = handler(ethLog, preprocessStore).catch((e) => {
339
342
  throw new ServerError(
340
343
  Status.INTERNAL,
341
344
  'error processing log: ' + JSON.stringify(ethLog.log) + '\n' + errorString(e)
@@ -346,7 +349,7 @@ export class EthPlugin extends Plugin {
346
349
  return mergePreprocessResults(await Promise.all(promises))
347
350
  }
348
351
 
349
- async preprocessTrace(binding: DataBinding): Promise<PreprocessResult> {
352
+ async preprocessTrace(binding: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
350
353
  if (!binding.data?.ethTrace?.trace) {
351
354
  throw new ServerError(Status.INVALID_ARGUMENT, "Trace can't be null")
352
355
  }
@@ -355,7 +358,7 @@ export class EthPlugin extends Plugin {
355
358
  const promises: Promise<PreprocessResult>[] = []
356
359
 
357
360
  for (const handlerId of binding.handlerIds) {
358
- const promise = this.preprocessHandlers.traceHandlers[handlerId](ethTrace).catch((e) => {
361
+ const promise = this.preprocessHandlers.traceHandlers[handlerId](ethTrace, preprocessStore).catch((e) => {
359
362
  throw new ServerError(
360
363
  Status.INTERNAL,
361
364
  'error processing trace: ' + JSON.stringify(ethTrace.trace) + '\n' + errorString(e)
@@ -366,7 +369,7 @@ export class EthPlugin extends Plugin {
366
369
  return mergePreprocessResults(await Promise.all(promises))
367
370
  }
368
371
 
369
- async preprocessBlock(binding: DataBinding): Promise<PreprocessResult> {
372
+ async preprocessBlock(binding: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
370
373
  if (!binding.data?.ethBlock?.block) {
371
374
  throw new ServerError(Status.INVALID_ARGUMENT, "Block can't be empty")
372
375
  }
@@ -374,7 +377,7 @@ export class EthPlugin extends Plugin {
374
377
 
375
378
  const promises: Promise<PreprocessResult>[] = []
376
379
  for (const handlerId of binding.handlerIds) {
377
- const promise = this.preprocessHandlers.blockHandlers[handlerId](ethBlock).catch((e) => {
380
+ const promise = this.preprocessHandlers.blockHandlers[handlerId](ethBlock, preprocessStore).catch((e) => {
378
381
  throw new ServerError(
379
382
  Status.INTERNAL,
380
383
  'error processing block: ' + ethBlock.block?.number + '\n' + errorString(e)
@@ -385,7 +388,7 @@ export class EthPlugin extends Plugin {
385
388
  return mergePreprocessResults(await Promise.all(promises))
386
389
  }
387
390
 
388
- async preprocessTransaction(binding: DataBinding): Promise<PreprocessResult> {
391
+ async preprocessTransaction(binding: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
389
392
  if (!binding.data?.ethTransaction?.transaction) {
390
393
  throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
391
394
  }
@@ -394,12 +397,14 @@ export class EthPlugin extends Plugin {
394
397
  const promises: Promise<PreprocessResult>[] = []
395
398
 
396
399
  for (const handlerId of binding.handlerIds) {
397
- const promise = this.preprocessHandlers.transactionHandlers[handlerId](ethTransaction).catch((e) => {
398
- throw new ServerError(
399
- Status.INTERNAL,
400
- 'error processing transaction: ' + JSON.stringify(ethTransaction.transaction) + '\n' + errorString(e)
401
- )
402
- })
400
+ const promise = this.preprocessHandlers.transactionHandlers[handlerId](ethTransaction, preprocessStore).catch(
401
+ (e) => {
402
+ throw new ServerError(
403
+ Status.INTERNAL,
404
+ 'error processing transaction: ' + JSON.stringify(ethTransaction.transaction) + '\n' + errorString(e)
405
+ )
406
+ }
407
+ )
403
408
  promises.push(promise)
404
409
  }
405
410
  return mergePreprocessResults(await Promise.all(promises))