@sentio/sdk 2.39.7-rc.9 → 2.40.0-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.
- package/lib/aptos/codegen/types.test.js.map +1 -1
- package/lib/aptos/ext/coin-event.test.js.map +1 -1
- package/lib/aptos/ext/coin.test.js.map +1 -1
- package/lib/core/event-logger.test.js.map +1 -1
- package/lib/core/normalization.test.js.map +1 -1
- package/lib/core/numberish.test.js.map +1 -1
- package/lib/eth/account-processor.d.ts +14 -8
- package/lib/eth/account-processor.d.ts.map +1 -1
- package/lib/eth/account-processor.js +43 -21
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +9 -6
- package/lib/eth/base-processor-template.d.ts.map +1 -1
- package/lib/eth/base-processor-template.js +25 -12
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +13 -8
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +109 -28
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +32 -32
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +62 -62
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts +17 -17
- package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +32 -32
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts +25 -25
- package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +48 -48
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +14 -14
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +26 -26
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts +21 -21
- package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +40 -40
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts +20 -20
- package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +38 -38
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/event-handler.d.ts.map +1 -1
- package/lib/eth/codegen/event-handler.js +3 -2
- package/lib/eth/codegen/event-handler.js.map +1 -1
- package/lib/eth/codegen/file.d.ts.map +1 -1
- package/lib/eth/codegen/file.js +6 -4
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/codegen/functions-handler.js +4 -3
- package/lib/eth/codegen/functions-handler.js.map +1 -1
- package/lib/eth/context.d.ts +6 -5
- package/lib/eth/context.d.ts.map +1 -1
- package/lib/eth/context.js +7 -5
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts +22 -10
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +105 -10
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.js +1 -1
- package/lib/eth/eth.js.map +1 -1
- package/lib/eth/eth.test.js.map +1 -1
- package/lib/eth/generic-processor.test.js.map +1 -1
- package/lib/eth/index.d.ts +2 -2
- package/lib/eth/index.d.ts.map +1 -1
- package/lib/eth/index.js +2 -2
- package/lib/eth/index.js.map +1 -1
- package/lib/eth/provider.d.ts.map +1 -1
- package/lib/eth/provider.js +12 -18
- package/lib/eth/provider.js.map +1 -1
- package/lib/eth/provider.test.js.map +1 -1
- package/lib/store/convert.test.js.map +1 -1
- package/lib/store/schema.js +1 -1
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +2 -1
- package/lib/store/store.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +2 -1
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +3 -0
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/utils/dex-price.test.js.map +1 -1
- package/lib/utils/erc20.test.js.map +1 -1
- package/lib/utils/price.test.js.map +1 -1
- package/package.json +6 -7
- package/src/eth/account-processor.ts +93 -22
- package/src/eth/base-processor-template.ts +60 -14
- package/src/eth/base-processor.ts +181 -37
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +302 -62
- package/src/eth/builtin/internal/erc1155-processor.ts +137 -32
- package/src/eth/builtin/internal/erc20-processor.ts +235 -48
- package/src/eth/builtin/internal/erc20bytes-processor.ts +124 -26
- package/src/eth/builtin/internal/erc721-processor.ts +191 -40
- package/src/eth/builtin/internal/weth9-processor.ts +170 -38
- package/src/eth/codegen/event-handler.ts +3 -2
- package/src/eth/codegen/file.ts +6 -4
- package/src/eth/codegen/functions-handler.ts +4 -3
- package/src/eth/context.ts +23 -7
- package/src/eth/eth-plugin.ts +142 -14
- package/src/eth/eth.ts +1 -1
- package/src/eth/index.ts +2 -2
- package/src/eth/provider.ts +15 -19
- package/src/store/schema.ts +1 -1
- package/src/store/store.ts +22 -13
- package/src/testing/test-processor-server.ts +9 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BaseContract, DeferredTopicFilter, TransactionResponseParams } from 'ethers'
|
1
|
+
import { BaseContract, DeferredTopicFilter, LogDescription, TransactionResponseParams } from 'ethers'
|
2
2
|
|
3
3
|
import { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'
|
4
4
|
import {
|
@@ -9,6 +9,8 @@ import {
|
|
9
9
|
Data_EthTransaction,
|
10
10
|
EthFetchConfig,
|
11
11
|
HandleInterval,
|
12
|
+
PreparedData,
|
13
|
+
PreprocessResult,
|
12
14
|
ProcessResult
|
13
15
|
} from '@sentio/protos'
|
14
16
|
import { BindOptions } from './bind-options.js'
|
@@ -24,15 +26,19 @@ export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
|
24
26
|
address?: string
|
25
27
|
}
|
26
28
|
|
29
|
+
export const defaultPreprocessHandler = () => (<PreprocessResult>{ ethCallParams: [] }) as any
|
30
|
+
|
27
31
|
export class EventsHandler {
|
28
32
|
filters: AddressOrTypeEventFilter[]
|
29
33
|
handler: (event: Data_EthLog) => Promise<ProcessResult>
|
34
|
+
preprocessHandler?: (event: Data_EthLog) => Promise<PreprocessResult>
|
30
35
|
fetchConfig: EthFetchConfig
|
31
36
|
}
|
32
37
|
|
33
38
|
export class TraceHandler {
|
34
39
|
signatures: string[]
|
35
40
|
handler: (trace: Data_EthTrace) => Promise<ProcessResult>
|
41
|
+
preprocessHandler?: (event: Data_EthTrace) => Promise<PreprocessResult>
|
36
42
|
fetchConfig: EthFetchConfig
|
37
43
|
}
|
38
44
|
|
@@ -40,11 +46,13 @@ export class BlockHandler {
|
|
40
46
|
blockInterval?: HandleInterval
|
41
47
|
timeIntervalInMinutes?: HandleInterval
|
42
48
|
handler: (block: Data_EthBlock) => Promise<ProcessResult>
|
49
|
+
preprocessHandler?: (event: Data_EthBlock) => Promise<PreprocessResult>
|
43
50
|
fetchConfig: EthFetchConfig
|
44
51
|
}
|
45
52
|
|
46
53
|
export class TransactionHandler {
|
47
54
|
handler: (block: Data_EthTransaction) => Promise<ProcessResult>
|
55
|
+
preprocessHandler?: (event: Data_EthTransaction) => Promise<PreprocessResult>
|
48
56
|
fetchConfig: EthFetchConfig
|
49
57
|
}
|
50
58
|
|
@@ -282,7 +290,11 @@ export abstract class BaseProcessor<
|
|
282
290
|
|
283
291
|
public onEvent(
|
284
292
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
285
|
-
fetchConfig?: Partial<EthFetchConfig
|
293
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
294
|
+
preprocessHandler: (
|
295
|
+
event: TypedEvent,
|
296
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
297
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
286
298
|
): this {
|
287
299
|
const _filters: DeferredTopicFilter[] = []
|
288
300
|
const tmpContract = this.CreateBoundContractView()
|
@@ -293,19 +305,17 @@ export abstract class BaseProcessor<
|
|
293
305
|
_filters.push(filter())
|
294
306
|
}
|
295
307
|
}
|
296
|
-
return this.onEthEvent(
|
297
|
-
function (log, ctx) {
|
298
|
-
return handler(log, ctx)
|
299
|
-
},
|
300
|
-
_filters,
|
301
|
-
fetchConfig
|
302
|
-
)
|
308
|
+
return this.onEthEvent(handler, _filters, fetchConfig, preprocessHandler)
|
303
309
|
}
|
304
310
|
|
305
311
|
protected onEthEvent(
|
306
312
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
307
313
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
308
|
-
fetchConfig?: Partial<EthFetchConfig
|
314
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
315
|
+
preprocessHandler: (
|
316
|
+
event: TypedEvent,
|
317
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
318
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
309
319
|
): this {
|
310
320
|
const chainId = this.getChainId()
|
311
321
|
let _filters: DeferredTopicFilter[] = []
|
@@ -321,7 +331,7 @@ export abstract class BaseProcessor<
|
|
321
331
|
this.eventHandlers.push({
|
322
332
|
filters: _filters,
|
323
333
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
|
324
|
-
handler: async function (data: Data_EthLog) {
|
334
|
+
handler: async function (data: Data_EthLog, preparedData?: PreparedData) {
|
325
335
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
326
336
|
if (!log) {
|
327
337
|
throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')
|
@@ -347,18 +357,14 @@ export abstract class BaseProcessor<
|
|
347
357
|
undefined,
|
348
358
|
transaction,
|
349
359
|
transactionReceipt,
|
350
|
-
processor.config.baseLabels
|
360
|
+
processor.config.baseLabels,
|
361
|
+
preparedData
|
351
362
|
)
|
352
363
|
const logParam = log as any as { topics: Array<string>; data: string }
|
353
364
|
|
365
|
+
let parsed: LogDescription | null = null
|
354
366
|
try {
|
355
|
-
|
356
|
-
|
357
|
-
if (parsed) {
|
358
|
-
const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }
|
359
|
-
await handler(event, ctx)
|
360
|
-
return ctx.stopAndGetResult()
|
361
|
-
}
|
367
|
+
parsed = contractView.rawContract.interface.parseLog(logParam)
|
362
368
|
} catch (e) {
|
363
369
|
// RangeError data out-of-bounds
|
364
370
|
if (e instanceof Error) {
|
@@ -369,7 +375,61 @@ export abstract class BaseProcessor<
|
|
369
375
|
}
|
370
376
|
throw e
|
371
377
|
}
|
378
|
+
if (parsed) {
|
379
|
+
const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }
|
380
|
+
await handler(event, ctx)
|
381
|
+
return ctx.stopAndGetResult()
|
382
|
+
}
|
372
383
|
return ProcessResult.fromPartial({})
|
384
|
+
},
|
385
|
+
preprocessHandler: async function (data: Data_EthLog): Promise<PreprocessResult> {
|
386
|
+
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
387
|
+
if (!log) {
|
388
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')
|
389
|
+
}
|
390
|
+
let contractView
|
391
|
+
try {
|
392
|
+
contractView = processor.CreateBoundContractView()
|
393
|
+
} catch (e) {
|
394
|
+
throw e
|
395
|
+
// console.log(e)
|
396
|
+
}
|
397
|
+
if (processor.config.address === '*') {
|
398
|
+
contractView.address = log.address
|
399
|
+
}
|
400
|
+
|
401
|
+
const ctx = new ContractContext<TContract, TBoundContractView>(
|
402
|
+
contractName,
|
403
|
+
contractView,
|
404
|
+
chainId,
|
405
|
+
data.timestamp,
|
406
|
+
block,
|
407
|
+
log,
|
408
|
+
undefined,
|
409
|
+
transaction,
|
410
|
+
transactionReceipt,
|
411
|
+
processor.config.baseLabels
|
412
|
+
)
|
413
|
+
const logParam = log as any as { topics: Array<string>; data: string }
|
414
|
+
|
415
|
+
let parsed: LogDescription | null = null
|
416
|
+
try {
|
417
|
+
parsed = contractView.rawContract.interface.parseLog(logParam)
|
418
|
+
} catch (e) {
|
419
|
+
// RangeError data out-of-bounds
|
420
|
+
if (e instanceof Error) {
|
421
|
+
if (e.message.includes('data out-of-bounds')) {
|
422
|
+
console.error("Can't decode", log, 'may because of incompatible ABIs, e.g. string vs indexed string', e)
|
423
|
+
return PreprocessResult.fromPartial({})
|
424
|
+
}
|
425
|
+
}
|
426
|
+
throw e
|
427
|
+
}
|
428
|
+
if (parsed) {
|
429
|
+
const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }
|
430
|
+
return preprocessHandler(event, ctx)
|
431
|
+
}
|
432
|
+
return PreprocessResult.fromPartial({})
|
373
433
|
}
|
374
434
|
})
|
375
435
|
return this
|
@@ -379,7 +439,11 @@ export abstract class BaseProcessor<
|
|
379
439
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
380
440
|
blockInterval = 250,
|
381
441
|
backfillBlockInterval = 1000,
|
382
|
-
fetchConfig?: Partial<EthFetchConfig
|
442
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
443
|
+
preprocessHandler: (
|
444
|
+
block: RichBlock,
|
445
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
446
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
383
447
|
): this {
|
384
448
|
return this.onInterval(
|
385
449
|
handler,
|
@@ -388,7 +452,8 @@ export abstract class BaseProcessor<
|
|
388
452
|
recentInterval: blockInterval,
|
389
453
|
backfillInterval: backfillBlockInterval
|
390
454
|
},
|
391
|
-
fetchConfig
|
455
|
+
fetchConfig,
|
456
|
+
preprocessHandler
|
392
457
|
)
|
393
458
|
}
|
394
459
|
|
@@ -396,13 +461,18 @@ export abstract class BaseProcessor<
|
|
396
461
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
397
462
|
timeIntervalInMinutes = 60,
|
398
463
|
backfillTimeIntervalInMinutes = 240,
|
399
|
-
fetchConfig?: Partial<EthFetchConfig
|
464
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
465
|
+
preprocessHandler: (
|
466
|
+
block: RichBlock,
|
467
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
468
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
400
469
|
): this {
|
401
470
|
return this.onInterval(
|
402
471
|
handler,
|
403
472
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
|
404
473
|
undefined,
|
405
|
-
fetchConfig
|
474
|
+
fetchConfig,
|
475
|
+
preprocessHandler
|
406
476
|
)
|
407
477
|
}
|
408
478
|
|
@@ -410,14 +480,18 @@ export abstract class BaseProcessor<
|
|
410
480
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
411
481
|
timeInterval: HandleInterval | undefined,
|
412
482
|
blockInterval: HandleInterval | undefined,
|
413
|
-
fetchConfig: Partial<EthFetchConfig> | undefined
|
483
|
+
fetchConfig: Partial<EthFetchConfig> | undefined,
|
484
|
+
preprocessHandler: (
|
485
|
+
block: RichBlock,
|
486
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
487
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
414
488
|
): this {
|
415
489
|
const chainId = this.getChainId()
|
416
490
|
const processor = this
|
417
491
|
const contractName = this.config.name
|
418
492
|
|
419
493
|
this.blockHandlers.push({
|
420
|
-
handler: async function (data: Data_EthBlock) {
|
494
|
+
handler: async function (data: Data_EthBlock, preparedData?: PreparedData) {
|
421
495
|
const { block } = formatEthData(data)
|
422
496
|
|
423
497
|
if (!block) {
|
@@ -436,11 +510,35 @@ export abstract class BaseProcessor<
|
|
436
510
|
undefined,
|
437
511
|
undefined,
|
438
512
|
undefined,
|
439
|
-
processor.config.baseLabels
|
513
|
+
processor.config.baseLabels,
|
514
|
+
preparedData
|
440
515
|
)
|
441
516
|
await handler(block, ctx)
|
442
517
|
return ctx.stopAndGetResult()
|
443
518
|
},
|
519
|
+
preprocessHandler: async function (data: Data_EthBlock) {
|
520
|
+
const { block } = formatEthData(data)
|
521
|
+
|
522
|
+
if (!block) {
|
523
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'Block is empty')
|
524
|
+
}
|
525
|
+
|
526
|
+
const contractView = processor.CreateBoundContractView()
|
527
|
+
|
528
|
+
const ctx = new ContractContext<TContract, TBoundContractView>(
|
529
|
+
contractName,
|
530
|
+
contractView,
|
531
|
+
chainId,
|
532
|
+
new Date(block.timestamp * 1000),
|
533
|
+
block,
|
534
|
+
undefined,
|
535
|
+
undefined,
|
536
|
+
undefined,
|
537
|
+
undefined,
|
538
|
+
processor.config.baseLabels
|
539
|
+
)
|
540
|
+
return preprocessHandler(block, ctx)
|
541
|
+
},
|
444
542
|
timeIntervalInMinutes: timeInterval,
|
445
543
|
blockInterval: blockInterval,
|
446
544
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
@@ -451,7 +549,11 @@ export abstract class BaseProcessor<
|
|
451
549
|
protected onEthTrace(
|
452
550
|
signatures: string | string[],
|
453
551
|
handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
454
|
-
fetchConfig?: Partial<EthFetchConfig
|
552
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
553
|
+
preprocessHandler: (
|
554
|
+
trace: TypedCallTrace,
|
555
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
556
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
455
557
|
): this {
|
456
558
|
const chainId = this.getChainId()
|
457
559
|
const contractName = this.config.name
|
@@ -463,7 +565,7 @@ export abstract class BaseProcessor<
|
|
463
565
|
this.traceHandlers.push({
|
464
566
|
signatures,
|
465
567
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
|
466
|
-
handler: async function (data: Data_EthTrace) {
|
568
|
+
handler: async function (data: Data_EthTrace, preparedData?: PreparedData) {
|
467
569
|
const contractView = processor.CreateBoundContractView()
|
468
570
|
const contractInterface = contractView.rawContract.interface
|
469
571
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
@@ -502,10 +604,54 @@ export abstract class BaseProcessor<
|
|
502
604
|
trace,
|
503
605
|
transaction,
|
504
606
|
transactionReceipt,
|
505
|
-
processor.config.baseLabels
|
607
|
+
processor.config.baseLabels,
|
608
|
+
preparedData
|
506
609
|
)
|
507
610
|
await handler(typedTrace, ctx)
|
508
611
|
return ctx.stopAndGetResult()
|
612
|
+
},
|
613
|
+
preprocessHandler: async function (data: Data_EthTrace) {
|
614
|
+
const contractView = processor.CreateBoundContractView()
|
615
|
+
const contractInterface = contractView.rawContract.interface
|
616
|
+
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
617
|
+
const sighash = trace?.action.input?.slice(0, 10)
|
618
|
+
if (!sighash) {
|
619
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'trace has no sighash')
|
620
|
+
}
|
621
|
+
const fragment = contractInterface.getFunction(sighash)
|
622
|
+
|
623
|
+
if (!trace || !fragment) {
|
624
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'trace is null')
|
625
|
+
}
|
626
|
+
const typedTrace = trace as TypedCallTrace
|
627
|
+
typedTrace.name = fragment.name
|
628
|
+
typedTrace.functionSignature = fragment.format()
|
629
|
+
// const trace = data.trace as Trace
|
630
|
+
if (!trace?.action.input) {
|
631
|
+
return PreprocessResult.fromPartial({})
|
632
|
+
}
|
633
|
+
const traceData = '0x' + trace.action.input.slice(10)
|
634
|
+
try {
|
635
|
+
typedTrace.args = contractInterface.getAbiCoder().decode(fragment.inputs, traceData, true)
|
636
|
+
} catch (e) {
|
637
|
+
if (!trace.error) {
|
638
|
+
throw e
|
639
|
+
}
|
640
|
+
console.error('Failed to decode successful trace', e)
|
641
|
+
}
|
642
|
+
const ctx = new ContractContext<TContract, TBoundContractView>(
|
643
|
+
contractName,
|
644
|
+
contractView,
|
645
|
+
chainId,
|
646
|
+
data.timestamp,
|
647
|
+
block,
|
648
|
+
undefined,
|
649
|
+
trace,
|
650
|
+
transaction,
|
651
|
+
transactionReceipt,
|
652
|
+
processor.config.baseLabels
|
653
|
+
)
|
654
|
+
return preprocessHandler(typedTrace, ctx)
|
509
655
|
}
|
510
656
|
})
|
511
657
|
return this
|
@@ -513,7 +659,11 @@ export abstract class BaseProcessor<
|
|
513
659
|
|
514
660
|
public onTrace(
|
515
661
|
handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
516
|
-
fetchConfig?: Partial<EthFetchConfig
|
662
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
663
|
+
preprocessHandler: (
|
664
|
+
trace: TypedCallTrace,
|
665
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
666
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
517
667
|
): this {
|
518
668
|
const tmpContract = this.CreateBoundContractView()
|
519
669
|
const sighashes = []
|
@@ -526,12 +676,6 @@ export abstract class BaseProcessor<
|
|
526
676
|
sighashes.push(sighash)
|
527
677
|
}
|
528
678
|
}
|
529
|
-
return this.onEthTrace(
|
530
|
-
sighashes,
|
531
|
-
function (trace, ctx) {
|
532
|
-
return handler(trace, ctx)
|
533
|
-
},
|
534
|
-
fetchConfig
|
535
|
-
)
|
679
|
+
return this.onEthTrace(sighashes, handler, fetchConfig, preprocessHandler)
|
536
680
|
}
|
537
681
|
}
|