@sentio/sdk 2.59.0-rc.3 → 2.59.0-rc.31
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/api.d.ts +1 -0
- package/lib/aptos/api.d.ts.map +1 -1
- package/lib/aptos/api.js +13 -1
- package/lib/aptos/api.js.map +1 -1
- package/lib/aptos/aptos-plugin.d.ts +8 -4
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +51 -8
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +21 -19
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +102 -50
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +5 -4
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.js +8 -8
- package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +803 -317
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +1458 -635
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +66 -65
- package/lib/aptos/builtin/0x3.d.ts.map +1 -1
- package/lib/aptos/builtin/0x3.js +131 -131
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.d.ts +29 -28
- package/lib/aptos/builtin/0x4.d.ts.map +1 -1
- package/lib/aptos/builtin/0x4.js +57 -57
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +31 -4
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/data.d.ts +45 -0
- package/lib/aptos/data.d.ts.map +1 -0
- package/lib/aptos/data.js +99 -0
- package/lib/aptos/data.js.map +1 -0
- package/lib/aptos/index.d.ts +1 -0
- package/lib/aptos/index.d.ts.map +1 -1
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos/models.d.ts +1 -0
- package/lib/aptos/models.d.ts.map +1 -1
- package/lib/aptos/move-coder.d.ts +8 -2
- package/lib/aptos/move-coder.d.ts.map +1 -1
- package/lib/aptos/move-coder.js +84 -1
- package/lib/aptos/move-coder.js.map +1 -1
- package/lib/aptos/network.d.ts +1 -0
- package/lib/aptos/network.d.ts.map +1 -1
- package/lib/aptos/network.js +1 -0
- package/lib/aptos/network.js.map +1 -1
- package/lib/btc/btc-plugin.d.ts +4 -1
- package/lib/btc/btc-plugin.d.ts.map +1 -1
- package/lib/btc/btc-plugin.js +27 -0
- package/lib/btc/btc-plugin.js.map +1 -1
- package/lib/btc/btc-processor.d.ts +6 -5
- package/lib/btc/btc-processor.d.ts.map +1 -1
- package/lib/btc/btc-processor.js +35 -9
- package/lib/btc/btc-processor.js.map +1 -1
- package/lib/btc/types.d.ts +2 -1
- package/lib/btc/types.d.ts.map +1 -1
- package/lib/core/base-context.d.ts +4 -2
- package/lib/core/base-context.d.ts.map +1 -1
- package/lib/core/base-context.js +8 -3
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/event-logger.d.ts +5 -0
- package/lib/core/event-logger.d.ts.map +1 -1
- package/lib/core/event-logger.js +36 -1
- package/lib/core/event-logger.js.map +1 -1
- package/lib/core/handler-options.d.ts +25 -0
- package/lib/core/handler-options.d.ts.map +1 -0
- package/lib/core/handler-options.js +21 -0
- package/lib/core/handler-options.js.map +1 -0
- package/lib/core/index.d.ts +3 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +3 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/meter.d.ts +45 -2
- package/lib/core/meter.d.ts.map +1 -1
- package/lib/core/meter.js +124 -2
- package/lib/core/meter.js.map +1 -1
- package/lib/core/numberish.d.ts +2 -1
- package/lib/core/numberish.d.ts.map +1 -1
- package/lib/core/numberish.js +35 -1
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/partition-handler-manager.d.ts +44 -0
- package/lib/core/partition-handler-manager.d.ts.map +1 -0
- package/lib/core/partition-handler-manager.js +76 -0
- package/lib/core/partition-handler-manager.js.map +1 -0
- package/lib/cosmos/cosmos-processor.d.ts +3 -2
- package/lib/cosmos/cosmos-processor.d.ts.map +1 -1
- package/lib/cosmos/cosmos-processor.js +11 -1
- package/lib/cosmos/cosmos-processor.js.map +1 -1
- package/lib/cosmos/types.d.ts +1 -0
- package/lib/cosmos/types.d.ts.map +1 -1
- package/lib/eth/base-processor.d.ts +23 -17
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +173 -34
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/bind-options.d.ts +6 -0
- package/lib/eth/bind-options.d.ts.map +1 -1
- package/lib/eth/bind-options.js +2 -0
- package/lib/eth/bind-options.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +32 -31
- 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 -16
- 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 -24
- 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 -13
- 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 -20
- 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 -19
- 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.js +2 -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 +1 -0
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/codegen/functions-handler.js +2 -2
- package/lib/eth/codegen/functions-handler.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts +5 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +53 -5
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts +2 -7
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +8 -1
- package/lib/eth/eth.js.map +1 -1
- package/lib/fuel/codegen/codegen.js +5 -5
- package/lib/fuel/codegen/codegen.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts +4 -1
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +41 -0
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor-template.d.ts +7 -4
- package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
- package/lib/fuel/fuel-processor-template.js +11 -9
- package/lib/fuel/fuel-processor-template.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts +7 -7
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +91 -28
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/fuel/types.d.ts +3 -0
- package/lib/fuel/types.d.ts.map +1 -1
- package/lib/move/filter.d.ts +5 -0
- package/lib/move/filter.d.ts.map +1 -1
- package/lib/move/filter.js +5 -0
- package/lib/move/filter.js.map +1 -1
- package/lib/move/shared-network-codegen.d.ts.map +1 -1
- package/lib/move/shared-network-codegen.js +5 -4
- package/lib/move/shared-network-codegen.js.map +1 -1
- package/lib/solana/solana-processor.d.ts +10 -4
- package/lib/solana/solana-processor.d.ts.map +1 -1
- package/lib/solana/solana-processor.js +13 -4
- package/lib/solana/solana-processor.js.map +1 -1
- package/lib/stark/starknet-processor.d.ts +3 -1
- package/lib/stark/starknet-processor.d.ts.map +1 -1
- package/lib/stark/starknet-processor.js +32 -14
- package/lib/stark/starknet-processor.js.map +1 -1
- package/lib/store/codegen.d.ts.map +1 -1
- package/lib/store/codegen.js +36 -2
- package/lib/store/codegen.js.map +1 -1
- package/lib/store/schema.d.ts.map +1 -1
- package/lib/store/schema.js +3 -1
- package/lib/store/schema.js.map +1 -1
- package/lib/store/store.d.ts +4 -3
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +41 -1
- package/lib/store/store.js.map +1 -1
- package/lib/store/types.d.ts +20 -1
- package/lib/store/types.d.ts.map +1 -1
- package/lib/store/types.js +22 -0
- package/lib/store/types.js.map +1 -1
- package/lib/sui/builtin/0x1.d.ts +11 -6
- package/lib/sui/builtin/0x1.d.ts.map +1 -1
- package/lib/sui/builtin/0x1.js +13 -13
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +123 -59
- package/lib/sui/builtin/0x2.d.ts.map +1 -1
- package/lib/sui/builtin/0x2.js +397 -119
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +89 -61
- package/lib/sui/builtin/0x3.d.ts.map +1 -1
- package/lib/sui/builtin/0x3.js +222 -104
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/models.d.ts +1 -0
- package/lib/sui/models.d.ts.map +1 -1
- package/lib/sui/sui-object-processor-template.js +1 -1
- package/lib/sui/sui-object-processor-template.js.map +1 -1
- package/lib/sui/sui-object-processor.d.ts +2 -0
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +4 -0
- package/lib/sui/sui-object-processor.js.map +1 -1
- package/lib/sui/sui-plugin.d.ts +6 -3
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +68 -24
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +6 -4
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +48 -11
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/eth-facet.d.ts +2 -1
- package/lib/testing/eth-facet.d.ts.map +1 -1
- package/lib/testing/eth-facet.js.map +1 -1
- package/lib/utils/block.d.ts +2 -0
- package/lib/utils/block.d.ts.map +1 -1
- package/lib/utils/block.js +13 -0
- package/lib/utils/block.js.map +1 -1
- package/package.json +9 -8
- package/src/aptos/abis/0x1.json +9650 -5284
- package/src/aptos/abis/0x3.json +13 -13
- package/src/aptos/abis/0x4.json +42 -42
- package/src/aptos/api.ts +13 -1
- package/src/aptos/aptos-plugin.ts +62 -13
- package/src/aptos/aptos-processor.ts +114 -74
- package/src/aptos/aptos-resource-processor-template.ts +9 -8
- package/src/aptos/builtin/0x1.ts +3105 -705
- package/src/aptos/builtin/0x3.ts +304 -131
- package/src/aptos/builtin/0x4.ts +125 -57
- package/src/aptos/codegen/codegen.ts +40 -5
- package/src/aptos/data.ts +123 -0
- package/src/aptos/index.ts +2 -0
- package/src/aptos/models.ts +2 -0
- package/src/aptos/move-coder.ts +96 -3
- package/src/aptos/network.ts +1 -0
- package/src/btc/btc-plugin.ts +38 -0
- package/src/btc/btc-processor.ts +35 -10
- package/src/btc/types.ts +2 -1
- package/src/core/base-context.ts +8 -3
- package/src/core/event-logger.ts +45 -1
- package/src/core/handler-options.ts +40 -0
- package/src/core/index.ts +17 -1
- package/src/core/meter.ts +159 -4
- package/src/core/numberish.ts +34 -1
- package/src/core/partition-handler-manager.ts +94 -0
- package/src/cosmos/cosmos-processor.ts +12 -1
- package/src/cosmos/types.ts +1 -0
- package/src/eth/base-processor.ts +163 -41
- package/src/eth/bind-options.ts +7 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +118 -62
- package/src/eth/builtin/internal/erc1155-processor.ts +76 -32
- package/src/eth/builtin/internal/erc20-processor.ts +79 -48
- package/src/eth/builtin/internal/erc20bytes-processor.ts +47 -26
- package/src/eth/builtin/internal/erc721-processor.ts +77 -40
- package/src/eth/builtin/internal/weth9-processor.ts +79 -38
- package/src/eth/codegen/event-handler.ts +2 -2
- package/src/eth/codegen/file.ts +1 -0
- package/src/eth/codegen/functions-handler.ts +2 -2
- package/src/eth/eth-plugin.ts +76 -10
- package/src/eth/eth.ts +12 -1
- package/src/fuel/codegen/codegen.ts +5 -5
- package/src/fuel/fuel-plugin.ts +56 -0
- package/src/fuel/fuel-processor-template.ts +17 -10
- package/src/fuel/fuel-processor.ts +90 -22
- package/src/fuel/types.ts +3 -0
- package/src/move/filter.ts +5 -0
- package/src/move/shared-network-codegen.ts +5 -4
- package/src/solana/solana-processor.ts +28 -6
- package/src/stark/starknet-processor.ts +31 -13
- package/src/store/codegen.ts +50 -2
- package/src/store/schema.ts +3 -1
- package/src/store/store.ts +57 -4
- package/src/store/types.ts +30 -1
- package/src/sui/abis/0x1.json +8 -0
- package/src/sui/abis/0x2.json +437 -0
- package/src/sui/abis/0x3.json +116 -5
- package/src/sui/builtin/0x1.ts +28 -13
- package/src/sui/builtin/0x2.ts +631 -119
- package/src/sui/builtin/0x3.ts +450 -116
- package/src/sui/models.ts +2 -0
- package/src/sui/sui-object-processor-template.ts +1 -1
- package/src/sui/sui-object-processor.ts +6 -0
- package/src/sui/sui-plugin.ts +77 -26
- package/src/sui/sui-processor.ts +50 -11
- package/src/testing/eth-facet.ts +2 -1
- package/src/utils/block.ts +15 -0
@@ -3,17 +3,13 @@ import { BaseContract, DeferredTopicFilter, LogDescription, TransactionResponseP
|
|
3
3
|
import { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'
|
4
4
|
import {
|
5
5
|
AddressType,
|
6
|
-
Data_EthBlock,
|
7
|
-
Data_EthLog,
|
8
|
-
Data_EthTrace,
|
9
|
-
Data_EthTransaction,
|
10
6
|
EthFetchConfig,
|
11
7
|
HandleInterval,
|
12
8
|
PreparedData,
|
13
9
|
PreprocessResult,
|
14
10
|
ProcessResult
|
15
11
|
} from '@sentio/protos'
|
16
|
-
import { BindOptions } from './bind-options.js'
|
12
|
+
import { BindOptions, TimeOrBlock } from './bind-options.js'
|
17
13
|
import { PromiseOrVoid } from '../core/promises.js'
|
18
14
|
import { ServerError, Status } from 'nice-grpc'
|
19
15
|
import {
|
@@ -27,9 +23,10 @@ import {
|
|
27
23
|
} from './eth.js'
|
28
24
|
import sha3 from 'js-sha3'
|
29
25
|
import { ListStateStorage } from '@sentio/runtime'
|
26
|
+
import { type Data_EthLog, type Data_EthTrace, type Data_EthTransaction, type Data_EthBlock } from '@sentio/runtime'
|
30
27
|
import { EthChainId } from '@sentio/chain'
|
31
28
|
import { getHandlerName, proxyHandlers, proxyProcessor } from '../utils/metrics.js'
|
32
|
-
import { ALL_ADDRESS } from '../core/index.js'
|
29
|
+
import { ALL_ADDRESS, HandlerOptions } from '../core/index.js'
|
33
30
|
import { parseLog, decodeTrace } from './abi-decoder/index.js'
|
34
31
|
|
35
32
|
export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
@@ -45,6 +42,7 @@ export class EventsHandler {
|
|
45
42
|
handler: (event: Data_EthLog) => Promise<ProcessResult>
|
46
43
|
preprocessHandler?: (event: Data_EthLog, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
47
44
|
fetchConfig: EthFetchConfig
|
45
|
+
partitionHandler?: (event: Data_EthLog) => Promise<string | undefined>
|
48
46
|
}
|
49
47
|
|
50
48
|
export class TraceHandler {
|
@@ -53,6 +51,7 @@ export class TraceHandler {
|
|
53
51
|
handler: (trace: Data_EthTrace) => Promise<ProcessResult>
|
54
52
|
preprocessHandler?: (event: Data_EthTrace, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
55
53
|
fetchConfig: EthFetchConfig
|
54
|
+
partitionHandler?: (trace: Data_EthTrace) => Promise<string | undefined>
|
56
55
|
}
|
57
56
|
|
58
57
|
export class BlockHandler {
|
@@ -62,21 +61,23 @@ export class BlockHandler {
|
|
62
61
|
handler: (block: Data_EthBlock) => Promise<ProcessResult>
|
63
62
|
preprocessHandler?: (event: Data_EthBlock, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
64
63
|
fetchConfig: EthFetchConfig
|
64
|
+
partitionHandler?: (block: Data_EthBlock) => Promise<string | undefined>
|
65
65
|
}
|
66
66
|
|
67
67
|
export class TransactionHandler {
|
68
|
-
handler: (
|
68
|
+
handler: (tx: Data_EthTransaction) => Promise<ProcessResult>
|
69
69
|
handlerName: string
|
70
70
|
preprocessHandler?: (event: Data_EthTransaction, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
71
71
|
fetchConfig: EthFetchConfig
|
72
|
+
partitionHandler?: (tx: Data_EthTransaction) => Promise<string | undefined>
|
72
73
|
}
|
73
74
|
|
74
75
|
class BindInternalOptions {
|
75
76
|
address: string
|
76
77
|
network: EthChainId
|
77
78
|
name: string
|
78
|
-
|
79
|
-
|
79
|
+
start: TimeOrBlock
|
80
|
+
end?: TimeOrBlock
|
80
81
|
baseLabels?: { [key: string]: string }
|
81
82
|
}
|
82
83
|
|
@@ -101,13 +102,20 @@ export class GlobalProcessor {
|
|
101
102
|
address: ALL_ADDRESS,
|
102
103
|
name: config.name || 'Global',
|
103
104
|
network: config.network || EthChainId.ETHEREUM,
|
104
|
-
|
105
|
+
start: config.start || {
|
106
|
+
block: 0
|
107
|
+
},
|
108
|
+
end: config.end
|
105
109
|
}
|
106
110
|
if (config.startBlock) {
|
107
|
-
this.config.
|
111
|
+
this.config.start = {
|
112
|
+
block: config.startBlock
|
113
|
+
}
|
108
114
|
}
|
109
115
|
if (config.endBlock) {
|
110
|
-
this.config.
|
116
|
+
this.config.end = {
|
117
|
+
block: config.endBlock
|
118
|
+
}
|
111
119
|
}
|
112
120
|
|
113
121
|
return proxyProcessor(this)
|
@@ -117,7 +125,7 @@ export class GlobalProcessor {
|
|
117
125
|
handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
|
118
126
|
blockInterval = 250,
|
119
127
|
backfillBlockInterval = 1000,
|
120
|
-
|
128
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
121
129
|
preprocessHandler: (
|
122
130
|
block: RichBlock,
|
123
131
|
ctx: GlobalContext,
|
@@ -133,7 +141,7 @@ export class GlobalProcessor {
|
|
133
141
|
recentInterval: blockInterval,
|
134
142
|
backfillInterval: backfillBlockInterval
|
135
143
|
},
|
136
|
-
|
144
|
+
handlerOptions,
|
137
145
|
preprocessHandler
|
138
146
|
)
|
139
147
|
}
|
@@ -142,7 +150,7 @@ export class GlobalProcessor {
|
|
142
150
|
handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
|
143
151
|
timeIntervalInMinutes = 60,
|
144
152
|
backfillTimeIntervalInMinutes = 240,
|
145
|
-
|
153
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
146
154
|
preprocessHandler: (
|
147
155
|
block: RichBlock,
|
148
156
|
ctx: GlobalContext,
|
@@ -155,7 +163,7 @@ export class GlobalProcessor {
|
|
155
163
|
handler,
|
156
164
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
|
157
165
|
undefined,
|
158
|
-
|
166
|
+
handlerOptions,
|
159
167
|
preprocessHandler
|
160
168
|
)
|
161
169
|
}
|
@@ -168,7 +176,7 @@ export class GlobalProcessor {
|
|
168
176
|
handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
|
169
177
|
timeInterval: HandleInterval | undefined,
|
170
178
|
blockInterval: HandleInterval | undefined,
|
171
|
-
|
179
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
172
180
|
preprocessHandler: (
|
173
181
|
block: RichBlock,
|
174
182
|
ctx: GlobalContext,
|
@@ -230,14 +238,24 @@ export class GlobalProcessor {
|
|
230
238
|
},
|
231
239
|
timeIntervalInMinutes: timeInterval,
|
232
240
|
blockInterval: blockInterval,
|
233
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
241
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
242
|
+
partitionHandler: async (data: Data_EthBlock): Promise<string | undefined> => {
|
243
|
+
const p = handlerOptions?.partitionKey
|
244
|
+
if (!p) return undefined
|
245
|
+
if (typeof p === 'function') {
|
246
|
+
const { block } = formatEthData(data)
|
247
|
+
if (!block) return undefined
|
248
|
+
return p(block)
|
249
|
+
}
|
250
|
+
return p
|
251
|
+
}
|
234
252
|
})
|
235
253
|
return this
|
236
254
|
}
|
237
255
|
|
238
256
|
public onTransaction(
|
239
257
|
handler: (transaction: TransactionResponseParams, ctx: GlobalContext) => PromiseOrVoid,
|
240
|
-
|
258
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TransactionResponseParams>,
|
241
259
|
preprocessHandler: (
|
242
260
|
transaction: TransactionResponseParams,
|
243
261
|
ctx: GlobalContext,
|
@@ -298,7 +316,16 @@ export class GlobalProcessor {
|
|
298
316
|
)
|
299
317
|
return preprocessHandler(transaction, ctx, preprocessStore)
|
300
318
|
},
|
301
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
319
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
320
|
+
partitionHandler: async (data: Data_EthTransaction): Promise<string | undefined> => {
|
321
|
+
const p = handlerOptions?.partitionKey
|
322
|
+
if (!p) return undefined
|
323
|
+
if (typeof p === 'function') {
|
324
|
+
const { transaction } = formatEthData(data)
|
325
|
+
return p(transaction)
|
326
|
+
}
|
327
|
+
return p
|
328
|
+
}
|
302
329
|
})
|
303
330
|
return this
|
304
331
|
}
|
@@ -306,7 +333,7 @@ export class GlobalProcessor {
|
|
306
333
|
public onTrace(
|
307
334
|
signatures: string | string[],
|
308
335
|
handler: (trace: Trace, ctx: GlobalContext) => PromiseOrVoid,
|
309
|
-
|
336
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, Trace>,
|
310
337
|
preprocessHandler: (
|
311
338
|
trace: Trace,
|
312
339
|
ctx: GlobalContext,
|
@@ -329,7 +356,7 @@ export class GlobalProcessor {
|
|
329
356
|
|
330
357
|
this.traceHandlers.push({
|
331
358
|
signatures,
|
332
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
359
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
333
360
|
handlerName: getHandlerName(),
|
334
361
|
handler: async function (data: Data_EthTrace) {
|
335
362
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
@@ -369,6 +396,16 @@ export class GlobalProcessor {
|
|
369
396
|
processor.config.baseLabels
|
370
397
|
)
|
371
398
|
return preprocessHandler(trace, ctx, preprocessStore)
|
399
|
+
},
|
400
|
+
partitionHandler: async (data: Data_EthTrace): Promise<string | undefined> => {
|
401
|
+
const p = handlerOptions?.partitionKey
|
402
|
+
if (!p) return undefined
|
403
|
+
if (typeof p === 'function') {
|
404
|
+
const { trace } = formatEthData(data)
|
405
|
+
if (!trace) return undefined
|
406
|
+
return p(trace)
|
407
|
+
}
|
408
|
+
return p
|
372
409
|
}
|
373
410
|
})
|
374
411
|
return this
|
@@ -390,14 +427,21 @@ export abstract class BaseProcessor<
|
|
390
427
|
address: validateAndNormalizeAddress(config.address),
|
391
428
|
name: config.name || '',
|
392
429
|
network: config.network || EthChainId.ETHEREUM,
|
393
|
-
|
430
|
+
start: config.start || {
|
431
|
+
block: 0
|
432
|
+
},
|
433
|
+
end: config.end,
|
394
434
|
baseLabels: config.baseLabels
|
395
435
|
}
|
396
436
|
if (config.startBlock) {
|
397
|
-
this.config.
|
437
|
+
this.config.start = {
|
438
|
+
block: config.startBlock
|
439
|
+
}
|
398
440
|
}
|
399
441
|
if (config.endBlock) {
|
400
|
-
this.config.
|
442
|
+
this.config.end = {
|
443
|
+
block: config.endBlock
|
444
|
+
}
|
401
445
|
}
|
402
446
|
|
403
447
|
return proxyProcessor(this)
|
@@ -411,7 +455,7 @@ export abstract class BaseProcessor<
|
|
411
455
|
|
412
456
|
public onEvent(
|
413
457
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
414
|
-
|
458
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>,
|
415
459
|
preprocessHandler: (
|
416
460
|
event: TypedEvent,
|
417
461
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -427,13 +471,13 @@ export abstract class BaseProcessor<
|
|
427
471
|
_filters.push(filter())
|
428
472
|
}
|
429
473
|
}
|
430
|
-
return this.onEthEvent(handler, _filters,
|
474
|
+
return this.onEthEvent(handler, _filters, handlerOptions, preprocessHandler)
|
431
475
|
}
|
432
476
|
|
433
477
|
protected onEthEvent(
|
434
478
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
435
479
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
436
|
-
|
480
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>,
|
437
481
|
preprocessHandler: (
|
438
482
|
event: TypedEvent,
|
439
483
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -454,7 +498,7 @@ export abstract class BaseProcessor<
|
|
454
498
|
const processor = this
|
455
499
|
this.eventHandlers.push({
|
456
500
|
filters: _filters,
|
457
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
501
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
458
502
|
handlerName,
|
459
503
|
handler: async function (data: Data_EthLog, preparedData?: PreparedData) {
|
460
504
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
@@ -474,7 +518,7 @@ export abstract class BaseProcessor<
|
|
474
518
|
|
475
519
|
let parsed: LogDescription | null = null
|
476
520
|
try {
|
477
|
-
parsed = await
|
521
|
+
parsed = await getCachedParsedLog(data, processor, log)
|
478
522
|
} catch (e) {
|
479
523
|
// RangeError data out-of-bounds
|
480
524
|
if (e instanceof Error) {
|
@@ -539,7 +583,7 @@ export abstract class BaseProcessor<
|
|
539
583
|
|
540
584
|
let parsed: LogDescription | null = null
|
541
585
|
try {
|
542
|
-
parsed = await
|
586
|
+
parsed = await getCachedParsedLog(data, processor, log)
|
543
587
|
} catch (e) {
|
544
588
|
// RangeError data out-of-bounds
|
545
589
|
if (e instanceof Error) {
|
@@ -555,6 +599,26 @@ export abstract class BaseProcessor<
|
|
555
599
|
return preprocessHandler(event, ctx, preprocessStore)
|
556
600
|
}
|
557
601
|
return PreprocessResult.fromPartial({})
|
602
|
+
},
|
603
|
+
partitionHandler: async (data: Data_EthLog): Promise<string | undefined> => {
|
604
|
+
const p = handlerOptions?.partitionKey
|
605
|
+
if (!p) return undefined
|
606
|
+
if (typeof p === 'function') {
|
607
|
+
const { log } = formatEthData(data)
|
608
|
+
if (!log) return undefined
|
609
|
+
let parsed: LogDescription | null = null
|
610
|
+
try {
|
611
|
+
parsed = await getCachedParsedLog(data, processor, log)
|
612
|
+
} catch (e) {
|
613
|
+
return undefined
|
614
|
+
}
|
615
|
+
if (parsed) {
|
616
|
+
const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }
|
617
|
+
return p(event)
|
618
|
+
}
|
619
|
+
return undefined
|
620
|
+
}
|
621
|
+
return p
|
558
622
|
}
|
559
623
|
})
|
560
624
|
return this
|
@@ -564,7 +628,7 @@ export abstract class BaseProcessor<
|
|
564
628
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
565
629
|
blockInterval = 250,
|
566
630
|
backfillBlockInterval = 1000,
|
567
|
-
|
631
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
568
632
|
preprocessHandler: (
|
569
633
|
block: RichBlock,
|
570
634
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -578,7 +642,7 @@ export abstract class BaseProcessor<
|
|
578
642
|
recentInterval: blockInterval,
|
579
643
|
backfillInterval: backfillBlockInterval
|
580
644
|
},
|
581
|
-
|
645
|
+
handlerOptions,
|
582
646
|
preprocessHandler
|
583
647
|
)
|
584
648
|
}
|
@@ -587,7 +651,7 @@ export abstract class BaseProcessor<
|
|
587
651
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
588
652
|
timeIntervalInMinutes = 60,
|
589
653
|
backfillTimeIntervalInMinutes = 240,
|
590
|
-
|
654
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
591
655
|
preprocessHandler: (
|
592
656
|
block: RichBlock,
|
593
657
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -598,7 +662,7 @@ export abstract class BaseProcessor<
|
|
598
662
|
handler,
|
599
663
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
|
600
664
|
undefined,
|
601
|
-
|
665
|
+
handlerOptions,
|
602
666
|
preprocessHandler
|
603
667
|
)
|
604
668
|
}
|
@@ -607,7 +671,7 @@ export abstract class BaseProcessor<
|
|
607
671
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
608
672
|
timeInterval: HandleInterval | undefined,
|
609
673
|
blockInterval: HandleInterval | undefined,
|
610
|
-
|
674
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
611
675
|
preprocessHandler: (
|
612
676
|
block: RichBlock,
|
613
677
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -671,7 +735,17 @@ export abstract class BaseProcessor<
|
|
671
735
|
},
|
672
736
|
timeIntervalInMinutes: timeInterval,
|
673
737
|
blockInterval: blockInterval,
|
674
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
738
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
739
|
+
partitionHandler: async (data: Data_EthBlock): Promise<string | undefined> => {
|
740
|
+
const p = handlerOptions?.partitionKey
|
741
|
+
if (!p) return undefined
|
742
|
+
if (typeof p === 'function') {
|
743
|
+
const { block } = formatEthData(data)
|
744
|
+
if (!block) return undefined
|
745
|
+
return p(block)
|
746
|
+
}
|
747
|
+
return p
|
748
|
+
}
|
675
749
|
})
|
676
750
|
return this
|
677
751
|
}
|
@@ -679,7 +753,7 @@ export abstract class BaseProcessor<
|
|
679
753
|
protected onEthTrace(
|
680
754
|
signatures: string | string[],
|
681
755
|
handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
682
|
-
|
756
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedCallTrace>,
|
683
757
|
preprocessHandler: (
|
684
758
|
trace: TypedCallTrace,
|
685
759
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -696,7 +770,7 @@ export abstract class BaseProcessor<
|
|
696
770
|
|
697
771
|
this.traceHandlers.push({
|
698
772
|
signatures,
|
699
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
773
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
700
774
|
handlerName,
|
701
775
|
handler: async function (data: Data_EthTrace, preparedData?: PreparedData) {
|
702
776
|
const contractView = processor.CreateBoundContractView()
|
@@ -786,6 +860,35 @@ export abstract class BaseProcessor<
|
|
786
860
|
processor.config.baseLabels
|
787
861
|
)
|
788
862
|
return preprocessHandler(typedTrace, ctx, preprocessStore)
|
863
|
+
},
|
864
|
+
partitionHandler: async (data: Data_EthTrace): Promise<string | undefined> => {
|
865
|
+
const p = handlerOptions?.partitionKey
|
866
|
+
if (!p) return undefined
|
867
|
+
if (typeof p === 'function') {
|
868
|
+
const contractView = processor.CreateBoundContractView()
|
869
|
+
const contractInterface = contractView.rawContract.interface
|
870
|
+
const { trace } = formatEthData(data)
|
871
|
+
if (!trace) return undefined
|
872
|
+
const sighash = trace.action.input?.slice(0, 10)
|
873
|
+
if (!sighash) return undefined
|
874
|
+
const fragment = contractInterface.getFunction(sighash)
|
875
|
+
if (!fragment) return undefined
|
876
|
+
const typedTrace = trace as TypedCallTrace
|
877
|
+
typedTrace.name = fragment.name
|
878
|
+
typedTrace.functionSignature = fragment.format()
|
879
|
+
if (trace.action.input) {
|
880
|
+
const traceData = '0x' + trace.action.input.slice(10)
|
881
|
+
try {
|
882
|
+
typedTrace.args = await decodeTrace(processor, fragment.inputs, traceData)
|
883
|
+
} catch (e) {
|
884
|
+
if (!trace.error) {
|
885
|
+
throw e
|
886
|
+
}
|
887
|
+
}
|
888
|
+
}
|
889
|
+
return p(typedTrace)
|
890
|
+
}
|
891
|
+
return p
|
789
892
|
}
|
790
893
|
})
|
791
894
|
return this
|
@@ -793,7 +896,7 @@ export abstract class BaseProcessor<
|
|
793
896
|
|
794
897
|
public onTrace(
|
795
898
|
handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
796
|
-
|
899
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedCallTrace>,
|
797
900
|
preprocessHandler: (
|
798
901
|
trace: TypedCallTrace,
|
799
902
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -811,6 +914,25 @@ export abstract class BaseProcessor<
|
|
811
914
|
sighashes.push(sighash)
|
812
915
|
}
|
813
916
|
}
|
814
|
-
return this.onEthTrace(sighashes, handler,
|
917
|
+
return this.onEthTrace(sighashes, handler, handlerOptions, preprocessHandler)
|
918
|
+
}
|
919
|
+
}
|
920
|
+
|
921
|
+
// Helper function to get cached or parse log data
|
922
|
+
async function getCachedParsedLog(data: any, processor: any, log: any): Promise<LogDescription | null> {
|
923
|
+
// Check if parsed log is already cached on data object
|
924
|
+
if ((data as any).__parsedLog !== undefined) {
|
925
|
+
return (data as any).__parsedLog
|
926
|
+
}
|
927
|
+
|
928
|
+
try {
|
929
|
+
const parsed = await parseLog(processor, log)
|
930
|
+
// Cache the parsed result on the data object
|
931
|
+
;(data as any).__parsedLog = parsed
|
932
|
+
return parsed
|
933
|
+
} catch (e) {
|
934
|
+
// Cache the null result to avoid retrying
|
935
|
+
;(data as any).__parsedLog = null
|
936
|
+
throw e
|
815
937
|
}
|
816
938
|
}
|
package/src/eth/bind-options.ts
CHANGED
@@ -7,11 +7,18 @@ export class BindOptions {
|
|
7
7
|
network?: EthChainId = EthChainId.ETHEREUM
|
8
8
|
// Optional, override default contract name
|
9
9
|
name?: string
|
10
|
+
start?: TimeOrBlock
|
11
|
+
end?: TimeOrBlock
|
10
12
|
startBlock?: bigint | number
|
11
13
|
endBlock?: bigint | number
|
12
14
|
baseLabels?: { [key: string]: string }
|
13
15
|
}
|
14
16
|
|
17
|
+
export interface TimeOrBlock {
|
18
|
+
block?: bigint | number
|
19
|
+
time?: Date
|
20
|
+
}
|
21
|
+
|
15
22
|
export function getOptionsSignature(opts: BindOptions): string {
|
16
23
|
const sig = [opts.address]
|
17
24
|
if (opts.network) {
|