@sentio/sdk 2.59.0-rc.8 → 2.59.0
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 +40 -3
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +20 -19
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +101 -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 +333 -332
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +664 -664
- 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 +130 -130
- 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 +56 -56
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +27 -0
- 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/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 +10 -5
- 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 +21 -16
- 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 +4 -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 +7 -6
- package/lib/sui/builtin/0x1.d.ts.map +1 -1
- package/lib/sui/builtin/0x1.js +12 -12
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +61 -60
- package/lib/sui/builtin/0x2.d.ts.map +1 -1
- package/lib/sui/builtin/0x2.js +120 -120
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +49 -48
- package/lib/sui/builtin/0x3.d.ts.map +1 -1
- package/lib/sui/builtin/0x3.js +96 -96
- 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-plugin.d.ts +6 -3
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +59 -20
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +5 -4
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +47 -11
- package/lib/sui/sui-processor.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 +4 -4
- package/src/aptos/api.ts +13 -1
- package/src/aptos/aptos-plugin.ts +51 -8
- package/src/aptos/aptos-processor.ts +112 -74
- package/src/aptos/aptos-resource-processor-template.ts +9 -8
- package/src/aptos/builtin/0x1.ts +1565 -664
- package/src/aptos/builtin/0x3.ts +302 -130
- package/src/aptos/builtin/0x4.ts +123 -56
- package/src/aptos/codegen/codegen.ts +34 -1
- 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/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 +10 -5
- 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 +162 -37
- 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 +74 -5
- 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/builtin/0x1.ts +22 -12
- package/src/sui/builtin/0x2.ts +220 -120
- package/src/sui/builtin/0x3.ts +241 -96
- package/src/sui/models.ts +2 -0
- package/src/sui/sui-plugin.ts +68 -22
- package/src/sui/sui-processor.ts +48 -11
- package/src/utils/block.ts +15 -0
@@ -13,7 +13,7 @@ import {
|
|
13
13
|
PreprocessResult,
|
14
14
|
ProcessResult
|
15
15
|
} from '@sentio/protos'
|
16
|
-
import { BindOptions } from './bind-options.js'
|
16
|
+
import { BindOptions, TimeOrBlock } from './bind-options.js'
|
17
17
|
import { PromiseOrVoid } from '../core/promises.js'
|
18
18
|
import { ServerError, Status } from 'nice-grpc'
|
19
19
|
import {
|
@@ -29,7 +29,7 @@ import sha3 from 'js-sha3'
|
|
29
29
|
import { ListStateStorage } from '@sentio/runtime'
|
30
30
|
import { EthChainId } from '@sentio/chain'
|
31
31
|
import { getHandlerName, proxyHandlers, proxyProcessor } from '../utils/metrics.js'
|
32
|
-
import { ALL_ADDRESS } from '../core/index.js'
|
32
|
+
import { ALL_ADDRESS, HandlerOptions } from '../core/index.js'
|
33
33
|
import { parseLog, decodeTrace } from './abi-decoder/index.js'
|
34
34
|
|
35
35
|
export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
@@ -45,6 +45,7 @@ export class EventsHandler {
|
|
45
45
|
handler: (event: Data_EthLog) => Promise<ProcessResult>
|
46
46
|
preprocessHandler?: (event: Data_EthLog, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
47
47
|
fetchConfig: EthFetchConfig
|
48
|
+
partitionHandler?: (event: Data_EthLog) => Promise<string | undefined>
|
48
49
|
}
|
49
50
|
|
50
51
|
export class TraceHandler {
|
@@ -53,6 +54,7 @@ export class TraceHandler {
|
|
53
54
|
handler: (trace: Data_EthTrace) => Promise<ProcessResult>
|
54
55
|
preprocessHandler?: (event: Data_EthTrace, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
55
56
|
fetchConfig: EthFetchConfig
|
57
|
+
partitionHandler?: (trace: Data_EthTrace) => Promise<string | undefined>
|
56
58
|
}
|
57
59
|
|
58
60
|
export class BlockHandler {
|
@@ -62,21 +64,23 @@ export class BlockHandler {
|
|
62
64
|
handler: (block: Data_EthBlock) => Promise<ProcessResult>
|
63
65
|
preprocessHandler?: (event: Data_EthBlock, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
64
66
|
fetchConfig: EthFetchConfig
|
67
|
+
partitionHandler?: (block: Data_EthBlock) => Promise<string | undefined>
|
65
68
|
}
|
66
69
|
|
67
70
|
export class TransactionHandler {
|
68
|
-
handler: (
|
71
|
+
handler: (tx: Data_EthTransaction) => Promise<ProcessResult>
|
69
72
|
handlerName: string
|
70
73
|
preprocessHandler?: (event: Data_EthTransaction, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
71
74
|
fetchConfig: EthFetchConfig
|
75
|
+
partitionHandler?: (tx: Data_EthTransaction) => Promise<string | undefined>
|
72
76
|
}
|
73
77
|
|
74
78
|
class BindInternalOptions {
|
75
79
|
address: string
|
76
80
|
network: EthChainId
|
77
81
|
name: string
|
78
|
-
|
79
|
-
|
82
|
+
start: TimeOrBlock
|
83
|
+
end?: TimeOrBlock
|
80
84
|
baseLabels?: { [key: string]: string }
|
81
85
|
}
|
82
86
|
|
@@ -101,13 +105,20 @@ export class GlobalProcessor {
|
|
101
105
|
address: ALL_ADDRESS,
|
102
106
|
name: config.name || 'Global',
|
103
107
|
network: config.network || EthChainId.ETHEREUM,
|
104
|
-
|
108
|
+
start: config.start || {
|
109
|
+
block: 0
|
110
|
+
},
|
111
|
+
end: config.end
|
105
112
|
}
|
106
113
|
if (config.startBlock) {
|
107
|
-
this.config.
|
114
|
+
this.config.start = {
|
115
|
+
block: config.startBlock
|
116
|
+
}
|
108
117
|
}
|
109
118
|
if (config.endBlock) {
|
110
|
-
this.config.
|
119
|
+
this.config.end = {
|
120
|
+
block: config.endBlock
|
121
|
+
}
|
111
122
|
}
|
112
123
|
|
113
124
|
return proxyProcessor(this)
|
@@ -117,7 +128,7 @@ export class GlobalProcessor {
|
|
117
128
|
handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
|
118
129
|
blockInterval = 250,
|
119
130
|
backfillBlockInterval = 1000,
|
120
|
-
|
131
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
121
132
|
preprocessHandler: (
|
122
133
|
block: RichBlock,
|
123
134
|
ctx: GlobalContext,
|
@@ -133,7 +144,7 @@ export class GlobalProcessor {
|
|
133
144
|
recentInterval: blockInterval,
|
134
145
|
backfillInterval: backfillBlockInterval
|
135
146
|
},
|
136
|
-
|
147
|
+
handlerOptions,
|
137
148
|
preprocessHandler
|
138
149
|
)
|
139
150
|
}
|
@@ -142,7 +153,7 @@ export class GlobalProcessor {
|
|
142
153
|
handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
|
143
154
|
timeIntervalInMinutes = 60,
|
144
155
|
backfillTimeIntervalInMinutes = 240,
|
145
|
-
|
156
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
146
157
|
preprocessHandler: (
|
147
158
|
block: RichBlock,
|
148
159
|
ctx: GlobalContext,
|
@@ -155,7 +166,7 @@ export class GlobalProcessor {
|
|
155
166
|
handler,
|
156
167
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
|
157
168
|
undefined,
|
158
|
-
|
169
|
+
handlerOptions,
|
159
170
|
preprocessHandler
|
160
171
|
)
|
161
172
|
}
|
@@ -168,7 +179,7 @@ export class GlobalProcessor {
|
|
168
179
|
handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
|
169
180
|
timeInterval: HandleInterval | undefined,
|
170
181
|
blockInterval: HandleInterval | undefined,
|
171
|
-
|
182
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
172
183
|
preprocessHandler: (
|
173
184
|
block: RichBlock,
|
174
185
|
ctx: GlobalContext,
|
@@ -230,14 +241,24 @@ export class GlobalProcessor {
|
|
230
241
|
},
|
231
242
|
timeIntervalInMinutes: timeInterval,
|
232
243
|
blockInterval: blockInterval,
|
233
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
244
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
245
|
+
partitionHandler: async (data: Data_EthBlock): Promise<string | undefined> => {
|
246
|
+
const p = handlerOptions?.partitionKey
|
247
|
+
if (!p) return undefined
|
248
|
+
if (typeof p === 'function') {
|
249
|
+
const { block } = formatEthData(data)
|
250
|
+
if (!block) return undefined
|
251
|
+
return p(block)
|
252
|
+
}
|
253
|
+
return p
|
254
|
+
}
|
234
255
|
})
|
235
256
|
return this
|
236
257
|
}
|
237
258
|
|
238
259
|
public onTransaction(
|
239
260
|
handler: (transaction: TransactionResponseParams, ctx: GlobalContext) => PromiseOrVoid,
|
240
|
-
|
261
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TransactionResponseParams>,
|
241
262
|
preprocessHandler: (
|
242
263
|
transaction: TransactionResponseParams,
|
243
264
|
ctx: GlobalContext,
|
@@ -298,7 +319,16 @@ export class GlobalProcessor {
|
|
298
319
|
)
|
299
320
|
return preprocessHandler(transaction, ctx, preprocessStore)
|
300
321
|
},
|
301
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
322
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
323
|
+
partitionHandler: async (data: Data_EthTransaction): Promise<string | undefined> => {
|
324
|
+
const p = handlerOptions?.partitionKey
|
325
|
+
if (!p) return undefined
|
326
|
+
if (typeof p === 'function') {
|
327
|
+
const { transaction } = formatEthData(data)
|
328
|
+
return p(transaction)
|
329
|
+
}
|
330
|
+
return p
|
331
|
+
}
|
302
332
|
})
|
303
333
|
return this
|
304
334
|
}
|
@@ -306,7 +336,7 @@ export class GlobalProcessor {
|
|
306
336
|
public onTrace(
|
307
337
|
signatures: string | string[],
|
308
338
|
handler: (trace: Trace, ctx: GlobalContext) => PromiseOrVoid,
|
309
|
-
|
339
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, Trace>,
|
310
340
|
preprocessHandler: (
|
311
341
|
trace: Trace,
|
312
342
|
ctx: GlobalContext,
|
@@ -329,7 +359,7 @@ export class GlobalProcessor {
|
|
329
359
|
|
330
360
|
this.traceHandlers.push({
|
331
361
|
signatures,
|
332
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
362
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
333
363
|
handlerName: getHandlerName(),
|
334
364
|
handler: async function (data: Data_EthTrace) {
|
335
365
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
@@ -369,6 +399,16 @@ export class GlobalProcessor {
|
|
369
399
|
processor.config.baseLabels
|
370
400
|
)
|
371
401
|
return preprocessHandler(trace, ctx, preprocessStore)
|
402
|
+
},
|
403
|
+
partitionHandler: async (data: Data_EthTrace): Promise<string | undefined> => {
|
404
|
+
const p = handlerOptions?.partitionKey
|
405
|
+
if (!p) return undefined
|
406
|
+
if (typeof p === 'function') {
|
407
|
+
const { trace } = formatEthData(data)
|
408
|
+
if (!trace) return undefined
|
409
|
+
return p(trace)
|
410
|
+
}
|
411
|
+
return p
|
372
412
|
}
|
373
413
|
})
|
374
414
|
return this
|
@@ -390,14 +430,21 @@ export abstract class BaseProcessor<
|
|
390
430
|
address: validateAndNormalizeAddress(config.address),
|
391
431
|
name: config.name || '',
|
392
432
|
network: config.network || EthChainId.ETHEREUM,
|
393
|
-
|
433
|
+
start: config.start || {
|
434
|
+
block: 0
|
435
|
+
},
|
436
|
+
end: config.end,
|
394
437
|
baseLabels: config.baseLabels
|
395
438
|
}
|
396
439
|
if (config.startBlock) {
|
397
|
-
this.config.
|
440
|
+
this.config.start = {
|
441
|
+
block: config.startBlock
|
442
|
+
}
|
398
443
|
}
|
399
444
|
if (config.endBlock) {
|
400
|
-
this.config.
|
445
|
+
this.config.end = {
|
446
|
+
block: config.endBlock
|
447
|
+
}
|
401
448
|
}
|
402
449
|
|
403
450
|
return proxyProcessor(this)
|
@@ -411,7 +458,7 @@ export abstract class BaseProcessor<
|
|
411
458
|
|
412
459
|
public onEvent(
|
413
460
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
414
|
-
|
461
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>,
|
415
462
|
preprocessHandler: (
|
416
463
|
event: TypedEvent,
|
417
464
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -427,13 +474,13 @@ export abstract class BaseProcessor<
|
|
427
474
|
_filters.push(filter())
|
428
475
|
}
|
429
476
|
}
|
430
|
-
return this.onEthEvent(handler, _filters,
|
477
|
+
return this.onEthEvent(handler, _filters, handlerOptions, preprocessHandler)
|
431
478
|
}
|
432
479
|
|
433
480
|
protected onEthEvent(
|
434
481
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
435
482
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
436
|
-
|
483
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>,
|
437
484
|
preprocessHandler: (
|
438
485
|
event: TypedEvent,
|
439
486
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -454,7 +501,7 @@ export abstract class BaseProcessor<
|
|
454
501
|
const processor = this
|
455
502
|
this.eventHandlers.push({
|
456
503
|
filters: _filters,
|
457
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
504
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
458
505
|
handlerName,
|
459
506
|
handler: async function (data: Data_EthLog, preparedData?: PreparedData) {
|
460
507
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
@@ -474,7 +521,7 @@ export abstract class BaseProcessor<
|
|
474
521
|
|
475
522
|
let parsed: LogDescription | null = null
|
476
523
|
try {
|
477
|
-
parsed = await
|
524
|
+
parsed = await getCachedParsedLog(data, processor, log)
|
478
525
|
} catch (e) {
|
479
526
|
// RangeError data out-of-bounds
|
480
527
|
if (e instanceof Error) {
|
@@ -539,7 +586,7 @@ export abstract class BaseProcessor<
|
|
539
586
|
|
540
587
|
let parsed: LogDescription | null = null
|
541
588
|
try {
|
542
|
-
parsed = await
|
589
|
+
parsed = await getCachedParsedLog(data, processor, log)
|
543
590
|
} catch (e) {
|
544
591
|
// RangeError data out-of-bounds
|
545
592
|
if (e instanceof Error) {
|
@@ -555,6 +602,26 @@ export abstract class BaseProcessor<
|
|
555
602
|
return preprocessHandler(event, ctx, preprocessStore)
|
556
603
|
}
|
557
604
|
return PreprocessResult.fromPartial({})
|
605
|
+
},
|
606
|
+
partitionHandler: async (data: Data_EthLog): Promise<string | undefined> => {
|
607
|
+
const p = handlerOptions?.partitionKey
|
608
|
+
if (!p) return undefined
|
609
|
+
if (typeof p === 'function') {
|
610
|
+
const { log } = formatEthData(data)
|
611
|
+
if (!log) return undefined
|
612
|
+
let parsed: LogDescription | null = null
|
613
|
+
try {
|
614
|
+
parsed = await getCachedParsedLog(data, processor, log)
|
615
|
+
} catch (e) {
|
616
|
+
return undefined
|
617
|
+
}
|
618
|
+
if (parsed) {
|
619
|
+
const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }
|
620
|
+
return p(event)
|
621
|
+
}
|
622
|
+
return undefined
|
623
|
+
}
|
624
|
+
return p
|
558
625
|
}
|
559
626
|
})
|
560
627
|
return this
|
@@ -564,7 +631,7 @@ export abstract class BaseProcessor<
|
|
564
631
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
565
632
|
blockInterval = 250,
|
566
633
|
backfillBlockInterval = 1000,
|
567
|
-
|
634
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
568
635
|
preprocessHandler: (
|
569
636
|
block: RichBlock,
|
570
637
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -578,7 +645,7 @@ export abstract class BaseProcessor<
|
|
578
645
|
recentInterval: blockInterval,
|
579
646
|
backfillInterval: backfillBlockInterval
|
580
647
|
},
|
581
|
-
|
648
|
+
handlerOptions,
|
582
649
|
preprocessHandler
|
583
650
|
)
|
584
651
|
}
|
@@ -587,7 +654,7 @@ export abstract class BaseProcessor<
|
|
587
654
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
588
655
|
timeIntervalInMinutes = 60,
|
589
656
|
backfillTimeIntervalInMinutes = 240,
|
590
|
-
|
657
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
591
658
|
preprocessHandler: (
|
592
659
|
block: RichBlock,
|
593
660
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -598,7 +665,7 @@ export abstract class BaseProcessor<
|
|
598
665
|
handler,
|
599
666
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
|
600
667
|
undefined,
|
601
|
-
|
668
|
+
handlerOptions,
|
602
669
|
preprocessHandler
|
603
670
|
)
|
604
671
|
}
|
@@ -607,7 +674,7 @@ export abstract class BaseProcessor<
|
|
607
674
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
608
675
|
timeInterval: HandleInterval | undefined,
|
609
676
|
blockInterval: HandleInterval | undefined,
|
610
|
-
|
677
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
611
678
|
preprocessHandler: (
|
612
679
|
block: RichBlock,
|
613
680
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -671,7 +738,17 @@ export abstract class BaseProcessor<
|
|
671
738
|
},
|
672
739
|
timeIntervalInMinutes: timeInterval,
|
673
740
|
blockInterval: blockInterval,
|
674
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
741
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
742
|
+
partitionHandler: async (data: Data_EthBlock): Promise<string | undefined> => {
|
743
|
+
const p = handlerOptions?.partitionKey
|
744
|
+
if (!p) return undefined
|
745
|
+
if (typeof p === 'function') {
|
746
|
+
const { block } = formatEthData(data)
|
747
|
+
if (!block) return undefined
|
748
|
+
return p(block)
|
749
|
+
}
|
750
|
+
return p
|
751
|
+
}
|
675
752
|
})
|
676
753
|
return this
|
677
754
|
}
|
@@ -679,7 +756,7 @@ export abstract class BaseProcessor<
|
|
679
756
|
protected onEthTrace(
|
680
757
|
signatures: string | string[],
|
681
758
|
handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
682
|
-
|
759
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedCallTrace>,
|
683
760
|
preprocessHandler: (
|
684
761
|
trace: TypedCallTrace,
|
685
762
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -696,7 +773,7 @@ export abstract class BaseProcessor<
|
|
696
773
|
|
697
774
|
this.traceHandlers.push({
|
698
775
|
signatures,
|
699
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
776
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
700
777
|
handlerName,
|
701
778
|
handler: async function (data: Data_EthTrace, preparedData?: PreparedData) {
|
702
779
|
const contractView = processor.CreateBoundContractView()
|
@@ -786,6 +863,35 @@ export abstract class BaseProcessor<
|
|
786
863
|
processor.config.baseLabels
|
787
864
|
)
|
788
865
|
return preprocessHandler(typedTrace, ctx, preprocessStore)
|
866
|
+
},
|
867
|
+
partitionHandler: async (data: Data_EthTrace): Promise<string | undefined> => {
|
868
|
+
const p = handlerOptions?.partitionKey
|
869
|
+
if (!p) return undefined
|
870
|
+
if (typeof p === 'function') {
|
871
|
+
const contractView = processor.CreateBoundContractView()
|
872
|
+
const contractInterface = contractView.rawContract.interface
|
873
|
+
const { trace } = formatEthData(data)
|
874
|
+
if (!trace) return undefined
|
875
|
+
const sighash = trace.action.input?.slice(0, 10)
|
876
|
+
if (!sighash) return undefined
|
877
|
+
const fragment = contractInterface.getFunction(sighash)
|
878
|
+
if (!fragment) return undefined
|
879
|
+
const typedTrace = trace as TypedCallTrace
|
880
|
+
typedTrace.name = fragment.name
|
881
|
+
typedTrace.functionSignature = fragment.format()
|
882
|
+
if (trace.action.input) {
|
883
|
+
const traceData = '0x' + trace.action.input.slice(10)
|
884
|
+
try {
|
885
|
+
typedTrace.args = await decodeTrace(processor, fragment.inputs, traceData)
|
886
|
+
} catch (e) {
|
887
|
+
if (!trace.error) {
|
888
|
+
throw e
|
889
|
+
}
|
890
|
+
}
|
891
|
+
}
|
892
|
+
return p(typedTrace)
|
893
|
+
}
|
894
|
+
return p
|
789
895
|
}
|
790
896
|
})
|
791
897
|
return this
|
@@ -793,7 +899,7 @@ export abstract class BaseProcessor<
|
|
793
899
|
|
794
900
|
public onTrace(
|
795
901
|
handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
796
|
-
|
902
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedCallTrace>,
|
797
903
|
preprocessHandler: (
|
798
904
|
trace: TypedCallTrace,
|
799
905
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -811,6 +917,25 @@ export abstract class BaseProcessor<
|
|
811
917
|
sighashes.push(sighash)
|
812
918
|
}
|
813
919
|
}
|
814
|
-
return this.onEthTrace(sighashes, handler,
|
920
|
+
return this.onEthTrace(sighashes, handler, handlerOptions, preprocessHandler)
|
921
|
+
}
|
922
|
+
}
|
923
|
+
|
924
|
+
// Helper function to get cached or parse log data
|
925
|
+
async function getCachedParsedLog(data: any, processor: any, log: any): Promise<LogDescription | null> {
|
926
|
+
// Check if parsed log is already cached on data object
|
927
|
+
if ((data as any).__parsedLog !== undefined) {
|
928
|
+
return (data as any).__parsedLog
|
929
|
+
}
|
930
|
+
|
931
|
+
try {
|
932
|
+
const parsed = await parseLog(processor, log)
|
933
|
+
// Cache the parsed result on the data object
|
934
|
+
;(data as any).__parsedLog = parsed
|
935
|
+
return parsed
|
936
|
+
} catch (e) {
|
937
|
+
// Cache the null result to avoid retrying
|
938
|
+
;(data as any).__parsedLog = null
|
939
|
+
throw e
|
815
940
|
}
|
816
941
|
}
|
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) {
|