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

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 (55) 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 +23 -23
  15. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  16. package/lib/eth/builtin/internal/erc1155-processor.d.ts +24 -8
  17. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  18. package/lib/eth/builtin/internal/erc1155-processor.js +8 -8
  19. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  20. package/lib/eth/builtin/internal/erc20-processor.d.ts +18 -6
  21. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  22. package/lib/eth/builtin/internal/erc20-processor.js +18 -18
  23. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  24. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +12 -4
  25. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  26. package/lib/eth/builtin/internal/erc20bytes-processor.js +9 -9
  27. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  28. package/lib/eth/builtin/internal/erc721-processor.d.ts +18 -6
  29. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  30. package/lib/eth/builtin/internal/erc721-processor.js +14 -14
  31. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  32. package/lib/eth/builtin/internal/weth9-processor.d.ts +24 -8
  33. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  34. package/lib/eth/builtin/internal/weth9-processor.js +11 -11
  35. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  36. package/lib/eth/codegen/event-handler.js +1 -1
  37. package/lib/eth/codegen/function-calls.js +1 -1
  38. package/lib/eth/codegen/function-calls.js.map +1 -1
  39. package/lib/eth/eth-plugin.d.ts +27 -9
  40. package/lib/eth/eth-plugin.d.ts.map +1 -1
  41. package/lib/eth/eth-plugin.js +13 -13
  42. package/lib/eth/eth-plugin.js.map +1 -1
  43. package/package.json +3 -3
  44. package/src/eth/account-processor.ts +28 -12
  45. package/src/eth/base-processor-template.ts +16 -8
  46. package/src/eth/base-processor.ts +25 -16
  47. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +39 -31
  48. package/src/eth/builtin/internal/erc1155-processor.ts +24 -16
  49. package/src/eth/builtin/internal/erc20-processor.ts +42 -24
  50. package/src/eth/builtin/internal/erc20bytes-processor.ts +29 -13
  51. package/src/eth/builtin/internal/erc721-processor.ts +26 -20
  52. package/src/eth/builtin/internal/weth9-processor.ts +27 -19
  53. package/src/eth/codegen/event-handler.ts +1 -1
  54. package/src/eth/codegen/function-calls.ts +1 -1
  55. package/src/eth/eth-plugin.ts +27 -22
@@ -134,7 +134,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
134
134
  const result = iface.decodeFunctionResult("name", ret).toArray();
135
135
  return result.length == 1 ? result[0] : result;
136
136
  }
137
- console.log("missing eth call key:", "name", key);
137
+ console.debug("missing eth call key:", "name", key);
138
138
  }
139
139
  return await this.contract.getFunction("name()")(overrides || {});
140
140
  } catch (e) {
@@ -167,7 +167,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
167
167
  .toArray();
168
168
  return result.length == 1 ? result[0] : result;
169
169
  }
170
- console.log("missing eth call key:", "totalSupply", key);
170
+ console.debug("missing eth call key:", "totalSupply", key);
171
171
  }
172
172
  return await this.contract.getFunction("totalSupply()")(overrides || {});
173
173
  } catch (e) {
@@ -198,7 +198,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
198
198
  const result = iface.decodeFunctionResult("decimals", ret).toArray();
199
199
  return result.length == 1 ? result[0] : result;
200
200
  }
201
- console.log("missing eth call key:", "decimals", key);
201
+ console.debug("missing eth call key:", "decimals", key);
202
202
  }
203
203
  return await this.contract.getFunction("decimals()")(overrides || {});
204
204
  } catch (e) {
@@ -230,7 +230,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
230
230
  const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
231
231
  return result.length == 1 ? result[0] : result;
232
232
  }
233
- console.log("missing eth call key:", "balanceOf", arg0, key);
233
+ console.debug("missing eth call key:", "balanceOf", arg0, key);
234
234
  }
235
235
  return await this.contract.getFunction("balanceOf(address)")(
236
236
  arg0,
@@ -264,7 +264,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
264
264
  const result = iface.decodeFunctionResult("symbol", ret).toArray();
265
265
  return result.length == 1 ? result[0] : result;
266
266
  }
267
- console.log("missing eth call key:", "symbol", key);
267
+ console.debug("missing eth call key:", "symbol", key);
268
268
  }
269
269
  return await this.contract.getFunction("symbol()")(overrides || {});
270
270
  } catch (e) {
@@ -297,7 +297,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
297
297
  const result = iface.decodeFunctionResult("allowance", ret).toArray();
298
298
  return result.length == 1 ? result[0] : result;
299
299
  }
300
- console.log("missing eth call key:", "allowance", arg0, arg1, key);
300
+ console.debug("missing eth call key:", "allowance", arg0, arg1, key);
301
301
  }
302
302
  return await this.contract.getFunction("allowance(address,address)")(
303
303
  arg0,
@@ -337,7 +337,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
337
337
  const result = iface.decodeFunctionResult("approve", ret).toArray();
338
338
  return result.length == 1 ? result[0] : result;
339
339
  }
340
- console.log("missing eth call key:", "approve", guy, wad, key);
340
+ console.debug("missing eth call key:", "approve", guy, wad, key);
341
341
  }
342
342
  return await this.contract
343
343
  .getFunction("approve(address,uint256)")
@@ -378,7 +378,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
378
378
  .toArray();
379
379
  return result.length == 1 ? result[0] : result;
380
380
  }
381
- console.log(
381
+ console.debug(
382
382
  "missing eth call key:",
383
383
  "transferFrom",
384
384
  src,
@@ -420,7 +420,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
420
420
  .toArray();
421
421
  return result.length == 1 ? result[0] : result;
422
422
  }
423
- console.log("missing eth call key:", "withdraw", wad, key);
423
+ console.debug("missing eth call key:", "withdraw", wad, key);
424
424
  }
425
425
  return await this.contract
426
426
  .getFunction("withdraw(uint256)")
@@ -456,7 +456,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
456
456
  .toArray();
457
457
  return result.length == 1 ? result[0] : result;
458
458
  }
459
- console.log("missing eth call key:", "transfer", dst, wad, key);
459
+ console.debug("missing eth call key:", "transfer", dst, wad, key);
460
460
  }
461
461
  return await this.contract
462
462
  .getFunction("transfer(address,uint256)")
@@ -488,7 +488,7 @@ export class WETH9ContractView extends ContractView<WETH9> {
488
488
  const result = iface.decodeFunctionResult("deposit", ret).toArray();
489
489
  return result.length == 1 ? result[0] : result;
490
490
  }
491
- console.log("missing eth call key:", "deposit", key);
491
+ console.debug("missing eth call key:", "deposit", key);
492
492
  }
493
493
  return await this.contract
494
494
  .getFunction("deposit()")
@@ -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(',')})
@@ -58,7 +58,7 @@ export function generateViewFunction(view: boolean, fn: FunctionDeclaration, inc
58
58
  const result = iface.decodeFunctionResult("${fn.name}", ret).toArray()
59
59
  return result.length == 1? result[0]: result
60
60
  }
61
- console.log("missing eth call key:", "${fn.name}", ${
61
+ console.debug("missing eth call key:", "${fn.name}", ${
62
62
  fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
63
63
  }key)
64
64
  }
@@ -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))