@sentio/sdk 2.39.7-rc.8 → 2.40.0-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/codegen/types.test.js.map +1 -1
- package/lib/aptos/ext/coin-event.test.js.map +1 -1
- package/lib/aptos/ext/coin.test.js.map +1 -1
- package/lib/core/event-logger.test.js.map +1 -1
- package/lib/core/normalization.test.js.map +1 -1
- package/lib/core/numberish.test.js.map +1 -1
- package/lib/eth/account-processor.d.ts +14 -8
- package/lib/eth/account-processor.d.ts.map +1 -1
- package/lib/eth/account-processor.js +43 -21
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +9 -6
- package/lib/eth/base-processor-template.d.ts.map +1 -1
- package/lib/eth/base-processor-template.js +25 -12
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +13 -8
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +109 -28
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +32 -32
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +62 -62
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts +17 -17
- package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +32 -32
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts +25 -25
- package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +48 -48
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +14 -14
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +26 -26
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts +21 -21
- package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +40 -40
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts +20 -20
- package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +38 -38
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/event-handler.d.ts.map +1 -1
- package/lib/eth/codegen/event-handler.js +3 -2
- package/lib/eth/codegen/event-handler.js.map +1 -1
- package/lib/eth/codegen/file.d.ts.map +1 -1
- package/lib/eth/codegen/file.js +6 -4
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/codegen/functions-handler.js +4 -3
- package/lib/eth/codegen/functions-handler.js.map +1 -1
- package/lib/eth/context.d.ts +6 -5
- package/lib/eth/context.d.ts.map +1 -1
- package/lib/eth/context.js +7 -5
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts +22 -10
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +105 -10
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.js +1 -1
- package/lib/eth/eth.js.map +1 -1
- package/lib/eth/eth.test.js.map +1 -1
- package/lib/eth/generic-processor.test.js.map +1 -1
- package/lib/eth/index.d.ts +2 -2
- package/lib/eth/index.d.ts.map +1 -1
- package/lib/eth/index.js +2 -2
- package/lib/eth/index.js.map +1 -1
- package/lib/eth/provider.d.ts.map +1 -1
- package/lib/eth/provider.js +12 -18
- package/lib/eth/provider.js.map +1 -1
- package/lib/eth/provider.test.js.map +1 -1
- package/lib/store/convert.test.js.map +1 -1
- package/lib/store/schema.js +1 -1
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +2 -1
- package/lib/store/store.js.map +1 -1
- package/lib/utils/dex-price.test.js.map +1 -1
- package/lib/utils/erc20.test.js.map +1 -1
- package/lib/utils/price.test.js.map +1 -1
- package/package.json +6 -7
- package/src/eth/account-processor.ts +93 -22
- package/src/eth/base-processor-template.ts +60 -14
- package/src/eth/base-processor.ts +181 -37
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +302 -62
- package/src/eth/builtin/internal/erc1155-processor.ts +137 -32
- package/src/eth/builtin/internal/erc20-processor.ts +235 -48
- package/src/eth/builtin/internal/erc20bytes-processor.ts +124 -26
- package/src/eth/builtin/internal/erc721-processor.ts +191 -40
- package/src/eth/builtin/internal/weth9-processor.ts +170 -38
- package/src/eth/codegen/event-handler.ts +3 -2
- package/src/eth/codegen/file.ts +6 -4
- package/src/eth/codegen/functions-handler.ts +4 -3
- package/src/eth/context.ts +23 -7
- package/src/eth/eth-plugin.ts +142 -14
- package/src/eth/eth.ts +1 -1
- package/src/eth/index.ts +2 -2
- package/src/eth/provider.ts +15 -19
- package/src/store/schema.ts +1 -1
- package/src/store/store.ts +22 -13
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ERC20__factory, ERC721__factory } from './builtin/internal/index.js'
|
2
|
-
import { AddressType, EthFetchConfig, ProcessResult } from '@sentio/protos'
|
2
|
+
import { AddressType, EthFetchConfig, PreprocessResult, ProcessResult } from '@sentio/protos'
|
3
3
|
|
4
4
|
import { PartiallyOptional, PromiseOrVoid } from '../core/index.js'
|
5
5
|
|
@@ -7,7 +7,7 @@ import { AccountBindOptions } from './bind-options.js'
|
|
7
7
|
import { ERC20Processor, TransferEvent as ERC20TransferEvent } from './builtin/erc20.js'
|
8
8
|
import { ERC721Processor, TransferEvent as ERC721TransferEvent } from './builtin/erc721.js'
|
9
9
|
import { AccountContext } from './context.js'
|
10
|
-
import { AddressOrTypeEventFilter, EventsHandler } from './base-processor.js'
|
10
|
+
import { AddressOrTypeEventFilter, defaultPreprocessHandler, EventsHandler } from './base-processor.js'
|
11
11
|
import { Block } from 'ethers'
|
12
12
|
import { AccountProcessorState } from './account-processor-state.js'
|
13
13
|
import { fixEmptyKey, formatEthData, TypedEvent } from './eth.js'
|
@@ -30,7 +30,7 @@ export class AccountProcessor {
|
|
30
30
|
protected constructor(config: PartiallyOptional<AccountBindOptions, 'network'>) {
|
31
31
|
this.config = {
|
32
32
|
...config,
|
33
|
-
network: config.network || EthChainId.ETHEREUM
|
33
|
+
network: config.network || EthChainId.ETHEREUM
|
34
34
|
}
|
35
35
|
}
|
36
36
|
|
@@ -43,17 +43,23 @@ export class AccountProcessor {
|
|
43
43
|
* @param handler custom handler function
|
44
44
|
* @param tokensAddresses all the erc20 token address to watch
|
45
45
|
* @param fetchConfig
|
46
|
+
* @param preprocessHandler
|
46
47
|
*/
|
47
48
|
onERC20TransferIn(
|
48
49
|
handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,
|
49
50
|
tokensAddresses: string[] = [],
|
50
|
-
fetchConfig?: Partial<EthFetchConfig
|
51
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
52
|
+
preprocessHandler: (
|
53
|
+
event: ERC20TransferEvent,
|
54
|
+
ctx: AccountContext
|
55
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
51
56
|
) {
|
52
57
|
return this.onERC20(
|
53
58
|
handler,
|
54
59
|
tokensAddresses,
|
55
60
|
(address: string) => ERC721Processor.filters.Transfer(null, this.config.address),
|
56
|
-
fetchConfig
|
61
|
+
fetchConfig,
|
62
|
+
preprocessHandler
|
57
63
|
)
|
58
64
|
}
|
59
65
|
|
@@ -62,17 +68,23 @@ export class AccountProcessor {
|
|
62
68
|
* @param handler custom handler function
|
63
69
|
* @param tokensAddresses all the erc20 token address to watch
|
64
70
|
* @param fetchConfig
|
71
|
+
* @param preprocessHandler
|
65
72
|
*/
|
66
73
|
onERC20TransferOut(
|
67
74
|
handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,
|
68
75
|
tokensAddresses: string[] = [],
|
69
|
-
fetchConfig?: Partial<EthFetchConfig
|
76
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
77
|
+
preprocessHandler: (
|
78
|
+
event: ERC20TransferEvent,
|
79
|
+
ctx: AccountContext
|
80
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
70
81
|
) {
|
71
82
|
return this.onERC20(
|
72
83
|
handler,
|
73
84
|
tokensAddresses,
|
74
85
|
(address: string) => ERC20Processor.filters.Transfer(this.config.address),
|
75
|
-
fetchConfig
|
86
|
+
fetchConfig,
|
87
|
+
preprocessHandler
|
76
88
|
)
|
77
89
|
}
|
78
90
|
|
@@ -81,18 +93,24 @@ export class AccountProcessor {
|
|
81
93
|
* @param handler custom handler function
|
82
94
|
* @param tokensAddresses all the erc20 token address to watch
|
83
95
|
* @param fetchConfig
|
96
|
+
* @param preprocessHandler
|
84
97
|
*/
|
85
98
|
onERC20Minted(
|
86
99
|
handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,
|
87
100
|
tokensAddresses: string[] = [],
|
88
|
-
fetchConfig?: Partial<EthFetchConfig
|
101
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
102
|
+
preprocessHandler: (
|
103
|
+
event: ERC20TransferEvent,
|
104
|
+
ctx: AccountContext
|
105
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
89
106
|
) {
|
90
107
|
return this.onERC20(
|
91
108
|
handler,
|
92
109
|
tokensAddresses,
|
93
110
|
(address: string) =>
|
94
111
|
ERC20Processor.filters.Transfer('0x0000000000000000000000000000000000000000', this.config.address),
|
95
|
-
fetchConfig
|
112
|
+
fetchConfig,
|
113
|
+
preprocessHandler
|
96
114
|
)
|
97
115
|
}
|
98
116
|
|
@@ -100,9 +118,13 @@ export class AccountProcessor {
|
|
100
118
|
handler: (event: ERC20TransferEvent, ctx: AccountContext) => PromiseOrVoid,
|
101
119
|
tokensAddresses: string[] = [],
|
102
120
|
defaultFilter: (address: string) => AddressOrTypeEventFilter,
|
103
|
-
fetchConfig?: Partial<EthFetchConfig
|
121
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
122
|
+
preprocessHandler: (
|
123
|
+
event: ERC20TransferEvent,
|
124
|
+
ctx: AccountContext
|
125
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
104
126
|
) {
|
105
|
-
return this.onERC(handler, tokensAddresses, defaultFilter, AddressType.ERC20, fetchConfig)
|
127
|
+
return this.onERC(handler, tokensAddresses, defaultFilter, AddressType.ERC20, fetchConfig, preprocessHandler)
|
106
128
|
}
|
107
129
|
|
108
130
|
/**
|
@@ -110,17 +132,23 @@ export class AccountProcessor {
|
|
110
132
|
* @param handler custom handler function
|
111
133
|
* @param collections all the ERC721 token address to watch, if not provided then watch all ERC721
|
112
134
|
* @param fetchConfig
|
135
|
+
* @param preprocessHandler
|
113
136
|
*/
|
114
137
|
onERC721TransferIn(
|
115
138
|
handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,
|
116
139
|
collections: string[],
|
117
|
-
fetchConfig?: Partial<EthFetchConfig
|
140
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
141
|
+
preprocessHandler: (
|
142
|
+
event: ERC721TransferEvent,
|
143
|
+
ctx: AccountContext
|
144
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
118
145
|
) {
|
119
146
|
return this.onERC721(
|
120
147
|
handler,
|
121
148
|
collections,
|
122
149
|
(address: string) => ERC721Processor.filters.Transfer(null, this.config.address),
|
123
|
-
fetchConfig
|
150
|
+
fetchConfig,
|
151
|
+
preprocessHandler
|
124
152
|
)
|
125
153
|
}
|
126
154
|
|
@@ -129,17 +157,23 @@ export class AccountProcessor {
|
|
129
157
|
* @param handler custom handler function
|
130
158
|
* @param collections all the ERC721 token address to watch, if not provided then watch all ERC721
|
131
159
|
* @param fetchConfig
|
160
|
+
* @param preprocessHandler
|
132
161
|
*/
|
133
162
|
onERC721TransferOut(
|
134
163
|
handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,
|
135
164
|
collections: string[],
|
136
|
-
fetchConfig?: Partial<EthFetchConfig
|
165
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
166
|
+
preprocessHandler: (
|
167
|
+
event: ERC721TransferEvent,
|
168
|
+
ctx: AccountContext
|
169
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
137
170
|
) {
|
138
171
|
return this.onERC721(
|
139
172
|
handler,
|
140
173
|
collections,
|
141
174
|
(address: string) => ERC721Processor.filters.Transfer(this.config.address),
|
142
|
-
fetchConfig
|
175
|
+
fetchConfig,
|
176
|
+
preprocessHandler
|
143
177
|
)
|
144
178
|
}
|
145
179
|
|
@@ -148,18 +182,24 @@ export class AccountProcessor {
|
|
148
182
|
* @param handler custom handler function
|
149
183
|
* @param collections all the ERC721 token address to watch, if not provided then watch all ERC721
|
150
184
|
* @param fetchConfig
|
185
|
+
* @param preprocessHandler
|
151
186
|
*/
|
152
187
|
onERC721Minted(
|
153
188
|
handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,
|
154
189
|
collections: string[] = [],
|
155
|
-
fetchConfig?: Partial<EthFetchConfig
|
190
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
191
|
+
preprocessHandler: (
|
192
|
+
event: ERC721TransferEvent,
|
193
|
+
ctx: AccountContext
|
194
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
156
195
|
) {
|
157
196
|
return this.onERC721(
|
158
197
|
handler,
|
159
198
|
collections,
|
160
199
|
(address: string) =>
|
161
200
|
ERC721Processor.filters.Transfer('0x0000000000000000000000000000000000000000', this.config.address),
|
162
|
-
fetchConfig
|
201
|
+
fetchConfig,
|
202
|
+
preprocessHandler
|
163
203
|
)
|
164
204
|
}
|
165
205
|
|
@@ -167,9 +207,13 @@ export class AccountProcessor {
|
|
167
207
|
handler: (event: ERC721TransferEvent, ctx: AccountContext) => PromiseOrVoid,
|
168
208
|
collections: string[],
|
169
209
|
defaultFilter: (address: string) => AddressOrTypeEventFilter,
|
170
|
-
fetchConfig?: Partial<EthFetchConfig
|
210
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
211
|
+
preprocessHandler: (
|
212
|
+
event: ERC721TransferEvent,
|
213
|
+
ctx: AccountContext
|
214
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
171
215
|
) {
|
172
|
-
return this.onERC(handler, collections, defaultFilter, AddressType.ERC721, fetchConfig)
|
216
|
+
return this.onERC(handler, collections, defaultFilter, AddressType.ERC721, fetchConfig, preprocessHandler)
|
173
217
|
}
|
174
218
|
|
175
219
|
private onERC(
|
@@ -177,7 +221,8 @@ export class AccountProcessor {
|
|
177
221
|
contractAddresses: string[],
|
178
222
|
defaultFilter: (address: string) => AddressOrTypeEventFilter,
|
179
223
|
addressType: AddressType,
|
180
|
-
fetchConfig?: Partial<EthFetchConfig
|
224
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
225
|
+
preprocessHandler: (event: any, ctx: AccountContext) => Promise<PreprocessResult> = defaultPreprocessHandler
|
181
226
|
) {
|
182
227
|
const filters = []
|
183
228
|
for (const token of contractAddresses) {
|
@@ -191,13 +236,14 @@ export class AccountProcessor {
|
|
191
236
|
filter.addressType = addressType
|
192
237
|
filters.push(filter)
|
193
238
|
}
|
194
|
-
return this.onEvent(handler, filters, fetchConfig)
|
239
|
+
return this.onEvent(handler, filters, fetchConfig, preprocessHandler)
|
195
240
|
}
|
196
241
|
|
197
242
|
protected onEvent(
|
198
243
|
handler: (event: TypedEvent, ctx: AccountContext) => PromiseOrVoid,
|
199
244
|
filter: AddressOrTypeEventFilter | AddressOrTypeEventFilter[],
|
200
|
-
fetchConfig?: Partial<EthFetchConfig
|
245
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
246
|
+
preprocessHandler: (event: TypedEvent, ctx: AccountContext) => Promise<PreprocessResult> = defaultPreprocessHandler
|
201
247
|
) {
|
202
248
|
const chainId = this.getChainId()
|
203
249
|
|
@@ -256,6 +302,31 @@ export class AccountProcessor {
|
|
256
302
|
}
|
257
303
|
return ProcessResult.fromPartial({})
|
258
304
|
},
|
305
|
+
preprocessHandler: async function (data) {
|
306
|
+
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
307
|
+
if (!log) {
|
308
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')
|
309
|
+
}
|
310
|
+
// const log = data.log as { topics: Array<string>; data: string }
|
311
|
+
const ctx = new AccountContext(
|
312
|
+
chainId,
|
313
|
+
config.address,
|
314
|
+
data.timestamp,
|
315
|
+
data.block as Block,
|
316
|
+
log,
|
317
|
+
undefined,
|
318
|
+
transaction,
|
319
|
+
transactionReceipt
|
320
|
+
)
|
321
|
+
|
322
|
+
const logParam = log as any as { topics: Array<string>; data: string }
|
323
|
+
const parsed = ERC20_INTERFACE.parseLog(logParam)
|
324
|
+
if (parsed) {
|
325
|
+
const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }
|
326
|
+
return preprocessHandler(event, ctx)
|
327
|
+
}
|
328
|
+
return PreprocessResult.fromPartial({})
|
329
|
+
}
|
259
330
|
})
|
260
331
|
|
261
332
|
return this
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { BoundContractView, ContractContext, ContractView, EthContext } from './context.js'
|
2
2
|
import { BaseContract } from 'ethers'
|
3
|
-
import { BaseProcessor } from './base-processor.js'
|
3
|
+
import { BaseProcessor, defaultPreprocessHandler } from './base-processor.js'
|
4
4
|
import { BindOptions, getOptionsSignature } from './bind-options.js'
|
5
|
-
import { EthFetchConfig, HandleInterval, TemplateInstance } from '@sentio/protos'
|
5
|
+
import { EthFetchConfig, HandleInterval, TemplateInstance, PreprocessResult } from '@sentio/protos'
|
6
6
|
import { PromiseOrVoid } from '../core/promises.js'
|
7
7
|
import { ListStateStorage } from '@sentio/runtime'
|
8
8
|
import { BlockParams } from 'ethers/providers'
|
@@ -24,6 +24,10 @@ export abstract class BaseProcessorTemplate<
|
|
24
24
|
binds = new Set<string>()
|
25
25
|
blockHandlers: {
|
26
26
|
handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
27
|
+
preprocessHandler: (
|
28
|
+
block: BlockParams,
|
29
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
30
|
+
) => Promise<PreprocessResult>
|
27
31
|
blockInterval?: HandleInterval
|
28
32
|
timeIntervalInMinutes?: HandleInterval
|
29
33
|
fetchConfig?: EthFetchConfig
|
@@ -31,10 +35,18 @@ export abstract class BaseProcessorTemplate<
|
|
31
35
|
traceHandlers: {
|
32
36
|
signature: string
|
33
37
|
handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
38
|
+
preprocessHandler: (
|
39
|
+
trace: TypedCallTrace,
|
40
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
41
|
+
) => Promise<PreprocessResult>
|
34
42
|
fetchConfig?: EthFetchConfig
|
35
43
|
}[] = []
|
36
44
|
eventHandlers: {
|
37
45
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
46
|
+
preprocessHandler: (
|
47
|
+
event: TypedEvent,
|
48
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
49
|
+
) => Promise<PreprocessResult>
|
38
50
|
filter: DeferredTopicFilter | DeferredTopicFilter[]
|
39
51
|
fetchConfig?: EthFetchConfig
|
40
52
|
}[] = []
|
@@ -64,14 +76,14 @@ export abstract class BaseProcessorTemplate<
|
|
64
76
|
|
65
77
|
for (const eh of this.eventHandlers) {
|
66
78
|
// @ts-ignore friendly
|
67
|
-
processor.onEthEvent(eh.handler, eh.filter, eh.fetchConfig)
|
79
|
+
processor.onEthEvent(eh.handler, eh.filter, eh.fetchConfig, eh.preprocessHandler)
|
68
80
|
}
|
69
81
|
for (const th of this.traceHandlers) {
|
70
82
|
// @ts-ignore friendly
|
71
|
-
processor.onEthTrace(th.signature, th.handler, th.fetchConfig)
|
83
|
+
processor.onEthTrace(th.signature, th.handler, th.fetchConfig, th.preprocessHandler)
|
72
84
|
}
|
73
85
|
for (const bh of this.blockHandlers) {
|
74
|
-
processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval, bh.fetchConfig)
|
86
|
+
processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval, bh.fetchConfig, bh.preprocessHandler)
|
75
87
|
}
|
76
88
|
|
77
89
|
const instance: TemplateInstance = {
|
@@ -97,10 +109,15 @@ export abstract class BaseProcessorTemplate<
|
|
97
109
|
protected onEthEvent(
|
98
110
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
99
111
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
100
|
-
fetchConfig?: Partial<EthFetchConfig
|
112
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
113
|
+
preprocessHandler: (
|
114
|
+
event: TypedEvent,
|
115
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
116
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
101
117
|
) {
|
102
118
|
this.eventHandlers.push({
|
103
119
|
handler: handler,
|
120
|
+
preprocessHandler,
|
104
121
|
filter: filter,
|
105
122
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
106
123
|
})
|
@@ -111,7 +128,11 @@ export abstract class BaseProcessorTemplate<
|
|
111
128
|
handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
112
129
|
blockInterval = 1000,
|
113
130
|
backfillBlockInterval = 4000,
|
114
|
-
fetchConfig?: EthFetchConfig
|
131
|
+
fetchConfig?: EthFetchConfig,
|
132
|
+
preprocessHandler: (
|
133
|
+
block: BlockParams,
|
134
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
135
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
115
136
|
) {
|
116
137
|
return this.onInterval(
|
117
138
|
handler,
|
@@ -120,7 +141,8 @@ export abstract class BaseProcessorTemplate<
|
|
120
141
|
recentInterval: blockInterval,
|
121
142
|
backfillInterval: backfillBlockInterval
|
122
143
|
},
|
123
|
-
fetchConfig
|
144
|
+
fetchConfig,
|
145
|
+
preprocessHandler
|
124
146
|
)
|
125
147
|
}
|
126
148
|
|
@@ -128,13 +150,18 @@ export abstract class BaseProcessorTemplate<
|
|
128
150
|
handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
129
151
|
timeIntervalInMinutes = 60,
|
130
152
|
backfillBlockInterval = 240,
|
131
|
-
fetchConfig?: EthFetchConfig
|
153
|
+
fetchConfig?: EthFetchConfig,
|
154
|
+
preprocessHandler: (
|
155
|
+
block: BlockParams,
|
156
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
157
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
132
158
|
) {
|
133
159
|
return this.onInterval(
|
134
160
|
handler,
|
135
161
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillBlockInterval },
|
136
162
|
undefined,
|
137
|
-
fetchConfig
|
163
|
+
fetchConfig,
|
164
|
+
preprocessHandler
|
138
165
|
)
|
139
166
|
}
|
140
167
|
|
@@ -142,18 +169,37 @@ export abstract class BaseProcessorTemplate<
|
|
142
169
|
handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
143
170
|
timeInterval: HandleInterval | undefined,
|
144
171
|
blockInterval: HandleInterval | undefined,
|
145
|
-
fetchConfig: EthFetchConfig | undefined
|
172
|
+
fetchConfig: EthFetchConfig | undefined,
|
173
|
+
preprocessHandler: (
|
174
|
+
block: BlockParams,
|
175
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
176
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
146
177
|
) {
|
147
|
-
this.blockHandlers.push({
|
178
|
+
this.blockHandlers.push({
|
179
|
+
handler,
|
180
|
+
preprocessHandler,
|
181
|
+
timeIntervalInMinutes: timeInterval,
|
182
|
+
blockInterval,
|
183
|
+
fetchConfig
|
184
|
+
})
|
148
185
|
return this
|
149
186
|
}
|
150
187
|
|
151
188
|
public onTrace(
|
152
189
|
signature: string,
|
153
190
|
handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
154
|
-
fetchConfig?: Partial<EthFetchConfig
|
191
|
+
fetchConfig?: Partial<EthFetchConfig>,
|
192
|
+
preprocessHandler: (
|
193
|
+
trace: TypedCallTrace,
|
194
|
+
ctx: ContractContext<TContract, TBoundContractView>
|
195
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
155
196
|
) {
|
156
|
-
this.traceHandlers.push({
|
197
|
+
this.traceHandlers.push({
|
198
|
+
signature,
|
199
|
+
handler,
|
200
|
+
preprocessHandler,
|
201
|
+
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
202
|
+
})
|
157
203
|
return this
|
158
204
|
}
|
159
205
|
|