@sentio/sdk 2.59.0-rc.9 → 2.59.1-rc.1
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 +18 -13
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +151 -26
- package/lib/eth/base-processor.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 +42 -1
- 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/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 +139 -28
- 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 +55 -3
- 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
@@ -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,13 +64,15 @@ 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 {
|
@@ -124,7 +128,7 @@ export class GlobalProcessor {
|
|
124
128
|
handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
|
125
129
|
blockInterval = 250,
|
126
130
|
backfillBlockInterval = 1000,
|
127
|
-
|
131
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
128
132
|
preprocessHandler: (
|
129
133
|
block: RichBlock,
|
130
134
|
ctx: GlobalContext,
|
@@ -140,7 +144,7 @@ export class GlobalProcessor {
|
|
140
144
|
recentInterval: blockInterval,
|
141
145
|
backfillInterval: backfillBlockInterval
|
142
146
|
},
|
143
|
-
|
147
|
+
handlerOptions,
|
144
148
|
preprocessHandler
|
145
149
|
)
|
146
150
|
}
|
@@ -149,7 +153,7 @@ export class GlobalProcessor {
|
|
149
153
|
handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
|
150
154
|
timeIntervalInMinutes = 60,
|
151
155
|
backfillTimeIntervalInMinutes = 240,
|
152
|
-
|
156
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
153
157
|
preprocessHandler: (
|
154
158
|
block: RichBlock,
|
155
159
|
ctx: GlobalContext,
|
@@ -162,7 +166,7 @@ export class GlobalProcessor {
|
|
162
166
|
handler,
|
163
167
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
|
164
168
|
undefined,
|
165
|
-
|
169
|
+
handlerOptions,
|
166
170
|
preprocessHandler
|
167
171
|
)
|
168
172
|
}
|
@@ -175,7 +179,7 @@ export class GlobalProcessor {
|
|
175
179
|
handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
|
176
180
|
timeInterval: HandleInterval | undefined,
|
177
181
|
blockInterval: HandleInterval | undefined,
|
178
|
-
|
182
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
179
183
|
preprocessHandler: (
|
180
184
|
block: RichBlock,
|
181
185
|
ctx: GlobalContext,
|
@@ -237,14 +241,24 @@ export class GlobalProcessor {
|
|
237
241
|
},
|
238
242
|
timeIntervalInMinutes: timeInterval,
|
239
243
|
blockInterval: blockInterval,
|
240
|
-
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
|
+
}
|
241
255
|
})
|
242
256
|
return this
|
243
257
|
}
|
244
258
|
|
245
259
|
public onTransaction(
|
246
260
|
handler: (transaction: TransactionResponseParams, ctx: GlobalContext) => PromiseOrVoid,
|
247
|
-
|
261
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TransactionResponseParams>,
|
248
262
|
preprocessHandler: (
|
249
263
|
transaction: TransactionResponseParams,
|
250
264
|
ctx: GlobalContext,
|
@@ -305,7 +319,16 @@ export class GlobalProcessor {
|
|
305
319
|
)
|
306
320
|
return preprocessHandler(transaction, ctx, preprocessStore)
|
307
321
|
},
|
308
|
-
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
|
+
}
|
309
332
|
})
|
310
333
|
return this
|
311
334
|
}
|
@@ -313,7 +336,7 @@ export class GlobalProcessor {
|
|
313
336
|
public onTrace(
|
314
337
|
signatures: string | string[],
|
315
338
|
handler: (trace: Trace, ctx: GlobalContext) => PromiseOrVoid,
|
316
|
-
|
339
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, Trace>,
|
317
340
|
preprocessHandler: (
|
318
341
|
trace: Trace,
|
319
342
|
ctx: GlobalContext,
|
@@ -336,7 +359,7 @@ export class GlobalProcessor {
|
|
336
359
|
|
337
360
|
this.traceHandlers.push({
|
338
361
|
signatures,
|
339
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
362
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
340
363
|
handlerName: getHandlerName(),
|
341
364
|
handler: async function (data: Data_EthTrace) {
|
342
365
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
@@ -376,6 +399,16 @@ export class GlobalProcessor {
|
|
376
399
|
processor.config.baseLabels
|
377
400
|
)
|
378
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
|
379
412
|
}
|
380
413
|
})
|
381
414
|
return this
|
@@ -425,7 +458,7 @@ export abstract class BaseProcessor<
|
|
425
458
|
|
426
459
|
public onEvent(
|
427
460
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
428
|
-
|
461
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>,
|
429
462
|
preprocessHandler: (
|
430
463
|
event: TypedEvent,
|
431
464
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -441,13 +474,13 @@ export abstract class BaseProcessor<
|
|
441
474
|
_filters.push(filter())
|
442
475
|
}
|
443
476
|
}
|
444
|
-
return this.onEthEvent(handler, _filters,
|
477
|
+
return this.onEthEvent(handler, _filters, handlerOptions, preprocessHandler)
|
445
478
|
}
|
446
479
|
|
447
480
|
protected onEthEvent(
|
448
481
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
449
482
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
450
|
-
|
483
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>,
|
451
484
|
preprocessHandler: (
|
452
485
|
event: TypedEvent,
|
453
486
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -468,7 +501,7 @@ export abstract class BaseProcessor<
|
|
468
501
|
const processor = this
|
469
502
|
this.eventHandlers.push({
|
470
503
|
filters: _filters,
|
471
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
504
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
472
505
|
handlerName,
|
473
506
|
handler: async function (data: Data_EthLog, preparedData?: PreparedData) {
|
474
507
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
@@ -488,7 +521,7 @@ export abstract class BaseProcessor<
|
|
488
521
|
|
489
522
|
let parsed: LogDescription | null = null
|
490
523
|
try {
|
491
|
-
parsed = await
|
524
|
+
parsed = await getCachedParsedLog(data, processor, log)
|
492
525
|
} catch (e) {
|
493
526
|
// RangeError data out-of-bounds
|
494
527
|
if (e instanceof Error) {
|
@@ -553,7 +586,7 @@ export abstract class BaseProcessor<
|
|
553
586
|
|
554
587
|
let parsed: LogDescription | null = null
|
555
588
|
try {
|
556
|
-
parsed = await
|
589
|
+
parsed = await getCachedParsedLog(data, processor, log)
|
557
590
|
} catch (e) {
|
558
591
|
// RangeError data out-of-bounds
|
559
592
|
if (e instanceof Error) {
|
@@ -569,6 +602,26 @@ export abstract class BaseProcessor<
|
|
569
602
|
return preprocessHandler(event, ctx, preprocessStore)
|
570
603
|
}
|
571
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
|
572
625
|
}
|
573
626
|
})
|
574
627
|
return this
|
@@ -578,7 +631,7 @@ export abstract class BaseProcessor<
|
|
578
631
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
579
632
|
blockInterval = 250,
|
580
633
|
backfillBlockInterval = 1000,
|
581
|
-
|
634
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
582
635
|
preprocessHandler: (
|
583
636
|
block: RichBlock,
|
584
637
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -592,7 +645,7 @@ export abstract class BaseProcessor<
|
|
592
645
|
recentInterval: blockInterval,
|
593
646
|
backfillInterval: backfillBlockInterval
|
594
647
|
},
|
595
|
-
|
648
|
+
handlerOptions,
|
596
649
|
preprocessHandler
|
597
650
|
)
|
598
651
|
}
|
@@ -601,7 +654,7 @@ export abstract class BaseProcessor<
|
|
601
654
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
602
655
|
timeIntervalInMinutes = 60,
|
603
656
|
backfillTimeIntervalInMinutes = 240,
|
604
|
-
|
657
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
605
658
|
preprocessHandler: (
|
606
659
|
block: RichBlock,
|
607
660
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -612,7 +665,7 @@ export abstract class BaseProcessor<
|
|
612
665
|
handler,
|
613
666
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
|
614
667
|
undefined,
|
615
|
-
|
668
|
+
handlerOptions,
|
616
669
|
preprocessHandler
|
617
670
|
)
|
618
671
|
}
|
@@ -621,7 +674,7 @@ export abstract class BaseProcessor<
|
|
621
674
|
handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
622
675
|
timeInterval: HandleInterval | undefined,
|
623
676
|
blockInterval: HandleInterval | undefined,
|
624
|
-
|
677
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
|
625
678
|
preprocessHandler: (
|
626
679
|
block: RichBlock,
|
627
680
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -685,7 +738,17 @@ export abstract class BaseProcessor<
|
|
685
738
|
},
|
686
739
|
timeIntervalInMinutes: timeInterval,
|
687
740
|
blockInterval: blockInterval,
|
688
|
-
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
|
+
}
|
689
752
|
})
|
690
753
|
return this
|
691
754
|
}
|
@@ -693,7 +756,7 @@ export abstract class BaseProcessor<
|
|
693
756
|
protected onEthTrace(
|
694
757
|
signatures: string | string[],
|
695
758
|
handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
696
|
-
|
759
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedCallTrace>,
|
697
760
|
preprocessHandler: (
|
698
761
|
trace: TypedCallTrace,
|
699
762
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -710,7 +773,7 @@ export abstract class BaseProcessor<
|
|
710
773
|
|
711
774
|
this.traceHandlers.push({
|
712
775
|
signatures,
|
713
|
-
fetchConfig: EthFetchConfig.fromPartial(
|
776
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
714
777
|
handlerName,
|
715
778
|
handler: async function (data: Data_EthTrace, preparedData?: PreparedData) {
|
716
779
|
const contractView = processor.CreateBoundContractView()
|
@@ -800,6 +863,35 @@ export abstract class BaseProcessor<
|
|
800
863
|
processor.config.baseLabels
|
801
864
|
)
|
802
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
|
803
895
|
}
|
804
896
|
})
|
805
897
|
return this
|
@@ -807,7 +899,7 @@ export abstract class BaseProcessor<
|
|
807
899
|
|
808
900
|
public onTrace(
|
809
901
|
handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
810
|
-
|
902
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedCallTrace>,
|
811
903
|
preprocessHandler: (
|
812
904
|
trace: TypedCallTrace,
|
813
905
|
ctx: ContractContext<TContract, TBoundContractView>,
|
@@ -825,6 +917,25 @@ export abstract class BaseProcessor<
|
|
825
917
|
sighashes.push(sighash)
|
826
918
|
}
|
827
919
|
}
|
828
|
-
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
|
829
940
|
}
|
830
941
|
}
|