@sentio/sdk 2.59.5-rc.1 → 2.60.0-rc.10
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/aptos-plugin.d.ts +5 -11
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +38 -23
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +1 -0
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +11 -3
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +211 -0
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +328 -1
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.js +1 -1
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.js +1 -1
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/btc/btc-plugin.d.ts +5 -8
- package/lib/btc/btc-plugin.d.ts.map +1 -1
- package/lib/btc/btc-plugin.js +22 -14
- package/lib/btc/btc-plugin.js.map +1 -1
- package/lib/core/core-plugin.d.ts +3 -1
- package/lib/core/core-plugin.d.ts.map +1 -1
- package/lib/core/core-plugin.js +13 -0
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/core/handler-options.d.ts +6 -0
- package/lib/core/handler-options.d.ts.map +1 -1
- package/lib/core/handler-options.js.map +1 -1
- package/lib/core/handler-register.d.ts +18 -0
- package/lib/core/handler-register.d.ts.map +1 -0
- package/lib/core/handler-register.js +62 -0
- package/lib/core/handler-register.js.map +1 -0
- package/lib/cosmos/cosmos-plugin.d.ts +5 -7
- package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
- package/lib/cosmos/cosmos-plugin.js +18 -10
- package/lib/cosmos/cosmos-plugin.js.map +1 -1
- package/lib/eth/base-processor.d.ts +3 -1
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +26 -0
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts +5 -40
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +86 -120
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +30 -24
- package/lib/eth/eth.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts +5 -9
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +26 -18
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/iota/builtin/0x1.d.ts +817 -0
- package/lib/iota/builtin/0x1.d.ts.map +1 -0
- package/lib/iota/builtin/0x1.js +4385 -0
- package/lib/iota/builtin/0x1.js.map +1 -0
- package/lib/iota/builtin/0x2.d.ts +4529 -0
- package/lib/iota/builtin/0x2.d.ts.map +1 -0
- package/lib/iota/builtin/0x2.js +17109 -0
- package/lib/iota/builtin/0x2.js.map +1 -0
- package/lib/iota/builtin/0x3.d.ts +2293 -0
- package/lib/iota/builtin/0x3.d.ts.map +1 -0
- package/lib/iota/builtin/0x3.js +6522 -0
- package/lib/iota/builtin/0x3.js.map +1 -0
- package/lib/iota/builtin/index.d.ts +4 -0
- package/lib/iota/builtin/index.d.ts.map +1 -0
- package/lib/iota/builtin/index.js +7 -0
- package/lib/iota/builtin/index.js.map +1 -0
- package/lib/iota/codegen/codegen.d.ts +2 -0
- package/lib/iota/codegen/codegen.d.ts.map +1 -0
- package/lib/iota/codegen/codegen.js +94 -0
- package/lib/iota/codegen/codegen.js.map +1 -0
- package/lib/iota/codegen/index.d.ts +2 -0
- package/lib/iota/codegen/index.d.ts.map +1 -0
- package/lib/iota/codegen/index.js +2 -0
- package/lib/iota/codegen/index.js.map +1 -0
- package/lib/iota/codegen/run.d.ts +2 -0
- package/lib/iota/codegen/run.d.ts.map +1 -0
- package/lib/iota/codegen/run.js +12 -0
- package/lib/iota/codegen/run.js.map +1 -0
- package/lib/iota/context.d.ts +50 -0
- package/lib/iota/context.d.ts.map +1 -0
- package/lib/iota/context.js +134 -0
- package/lib/iota/context.js.map +1 -0
- package/lib/iota/ext/coin.d.ts +17 -0
- package/lib/iota/ext/coin.d.ts.map +1 -0
- package/lib/iota/ext/coin.js +532 -0
- package/lib/iota/ext/coin.js.map +1 -0
- package/lib/iota/ext/index.d.ts +3 -0
- package/lib/iota/ext/index.d.ts.map +1 -0
- package/lib/iota/ext/index.js +3 -0
- package/lib/iota/ext/index.js.map +1 -0
- package/lib/iota/ext/move-dex.d.ts +19 -0
- package/lib/iota/ext/move-dex.d.ts.map +1 -0
- package/lib/iota/ext/move-dex.js +24 -0
- package/lib/iota/ext/move-dex.js.map +1 -0
- package/lib/iota/index.d.ts +11 -0
- package/lib/iota/index.d.ts.map +1 -0
- package/lib/iota/index.js +12 -0
- package/lib/iota/index.js.map +1 -0
- package/lib/iota/iota-object-processor-template.d.ts +44 -0
- package/lib/iota/iota-object-processor-template.d.ts.map +1 -0
- package/lib/iota/iota-object-processor-template.js +171 -0
- package/lib/iota/iota-object-processor-template.js.map +1 -0
- package/lib/iota/iota-object-processor.d.ts +83 -0
- package/lib/iota/iota-object-processor.d.ts.map +1 -0
- package/lib/iota/iota-object-processor.js +193 -0
- package/lib/iota/iota-object-processor.js.map +1 -0
- package/lib/iota/iota-plugin-part.d.ts +12 -0
- package/lib/iota/iota-plugin-part.d.ts.map +1 -0
- package/lib/iota/iota-plugin-part.js +178 -0
- package/lib/iota/iota-plugin-part.js.map +1 -0
- package/lib/iota/iota-plugin.d.ts +3 -0
- package/lib/iota/iota-plugin.d.ts.map +1 -0
- package/lib/iota/iota-plugin.js +4 -0
- package/lib/iota/iota-plugin.js.map +1 -0
- package/lib/iota/iota-processor.d.ts +47 -0
- package/lib/iota/iota-processor.d.ts.map +1 -0
- package/lib/iota/iota-processor.js +223 -0
- package/lib/iota/iota-processor.js.map +1 -0
- package/lib/iota/models.d.ts +12 -0
- package/lib/iota/models.d.ts.map +1 -0
- package/lib/iota/models.js +2 -0
- package/lib/iota/models.js.map +1 -0
- package/lib/iota/move-coder.d.ts +4 -0
- package/lib/iota/move-coder.d.ts.map +1 -0
- package/lib/iota/move-coder.js +12 -0
- package/lib/iota/move-coder.js.map +1 -0
- package/lib/iota/network.d.ts +10 -0
- package/lib/iota/network.d.ts.map +1 -0
- package/lib/iota/network.js +24 -0
- package/lib/iota/network.js.map +1 -0
- package/lib/iota/utils.d.ts +3 -0
- package/lib/iota/utils.d.ts.map +1 -0
- package/lib/iota/utils.js +41 -0
- package/lib/iota/utils.js.map +1 -0
- package/lib/solana/solana-plugin.d.ts +3 -2
- package/lib/solana/solana-plugin.d.ts.map +1 -1
- package/lib/solana/solana-plugin.js +11 -1
- package/lib/solana/solana-plugin.js.map +1 -1
- package/lib/stark/starknet-plugin.d.ts +5 -7
- package/lib/stark/starknet-plugin.d.ts.map +1 -1
- package/lib/stark/starknet-plugin.js +18 -10
- package/lib/stark/starknet-plugin.js.map +1 -1
- package/lib/store/schema.d.ts.map +1 -1
- package/lib/store/schema.js +1 -0
- package/lib/store/schema.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +73 -0
- package/lib/sui/builtin/0x2.d.ts.map +1 -1
- package/lib/sui/builtin/0x2.js +237 -1
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +2 -0
- package/lib/sui/builtin/0x3.d.ts.map +1 -1
- package/lib/sui/builtin/0x3.js +21 -1
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/network.d.ts.map +1 -1
- package/lib/sui/network.js +0 -3
- package/lib/sui/network.js.map +1 -1
- package/lib/sui/sui-plugin-part.d.ts +12 -0
- package/lib/sui/sui-plugin-part.d.ts.map +1 -0
- package/lib/sui/sui-plugin-part.js +178 -0
- package/lib/sui/sui-plugin-part.js.map +1 -0
- package/lib/sui/sui-plugin.d.ts +9 -10
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +30 -164
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/testing/iota-facet.d.ts +14 -0
- package/lib/testing/iota-facet.d.ts.map +1 -0
- package/lib/testing/iota-facet.js +124 -0
- package/lib/testing/iota-facet.js.map +1 -0
- package/lib/testing/test-processor-server.d.ts +2 -0
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +3 -0
- package/lib/testing/test-processor-server.js.map +1 -1
- package/package.json +21 -9
- package/src/aptos/abis/0x1.json +1040 -45
- package/src/aptos/abis/0x3.json +2 -2
- package/src/aptos/abis/0x4.json +17 -17
- package/src/aptos/aptos-plugin.ts +55 -44
- package/src/aptos/aptos-processor.ts +15 -3
- package/src/aptos/builtin/0x1.ts +615 -1
- package/src/aptos/builtin/0x3.ts +1 -1
- package/src/aptos/builtin/0x4.ts +1 -1
- package/src/btc/btc-plugin.ts +33 -32
- package/src/core/core-plugin.ts +16 -2
- package/src/core/handler-options.ts +7 -0
- package/src/core/handler-register.ts +79 -0
- package/src/cosmos/cosmos-plugin.ts +24 -20
- package/src/eth/base-processor.ts +43 -1
- package/src/eth/eth-plugin.ts +111 -185
- package/src/eth/eth.ts +31 -26
- package/src/fuel/fuel-plugin.ts +43 -44
- package/src/iota/abis/0x1.json +4213 -0
- package/src/iota/abis/0x2.json +26692 -0
- package/src/iota/abis/0x3.json +10598 -0
- package/src/iota/builtin/0x1.ts +6292 -0
- package/src/iota/builtin/0x2.ts +26198 -0
- package/src/iota/builtin/0x3.ts +11144 -0
- package/src/iota/builtin/index.ts +6 -0
- package/src/iota/codegen/codegen.ts +118 -0
- package/src/iota/codegen/index.ts +1 -0
- package/src/iota/codegen/run.ts +13 -0
- package/src/iota/context.ts +200 -0
- package/src/iota/ext/coin.ts +565 -0
- package/src/iota/ext/index.ts +2 -0
- package/src/iota/ext/move-dex.ts +52 -0
- package/src/iota/index.ts +29 -0
- package/src/iota/iota-object-processor-template.ts +277 -0
- package/src/iota/iota-object-processor.ts +386 -0
- package/src/iota/iota-plugin-part.ts +211 -0
- package/src/iota/iota-plugin.ts +2 -0
- package/src/iota/iota-processor.ts +339 -0
- package/src/iota/models.ts +14 -0
- package/src/iota/move-coder.ts +15 -0
- package/src/iota/network.ts +27 -0
- package/src/iota/utils.ts +52 -0
- package/src/solana/solana-plugin.ts +20 -2
- package/src/stark/starknet-plugin.ts +24 -20
- package/src/store/schema.ts +1 -0
- package/src/sui/abis/0x2.json +269 -0
- package/src/sui/abis/0x3.json +29 -0
- package/src/sui/builtin/0x2.ts +367 -1
- package/src/sui/builtin/0x3.ts +29 -1
- package/src/sui/network.ts +0 -3
- package/src/sui/sui-plugin-part.ts +211 -0
- package/src/sui/sui-plugin.ts +51 -211
- package/src/testing/iota-facet.ts +143 -0
- package/src/testing/test-processor-server.ts +3 -0
package/src/eth/eth-plugin.ts
CHANGED
@@ -11,12 +11,9 @@ import { PartitionHandlerManager } from '../core/index.js'
|
|
11
11
|
import {
|
12
12
|
AccountConfig,
|
13
13
|
ContractConfig,
|
14
|
-
Data_EthBlock,
|
15
|
-
Data_EthLog,
|
16
|
-
Data_EthTrace,
|
17
|
-
Data_EthTransaction,
|
18
14
|
DataBinding,
|
19
15
|
HandlerType,
|
16
|
+
InitResponse,
|
20
17
|
LogFilter,
|
21
18
|
LogHandlerConfig,
|
22
19
|
PreparedData,
|
@@ -31,67 +28,40 @@ import { ServerError, Status } from 'nice-grpc'
|
|
31
28
|
import { EthProcessorState } from './binds.js'
|
32
29
|
import { AccountProcessorState } from './account-processor-state.js'
|
33
30
|
import { ProcessorTemplateProcessorState } from './base-processor-template.js'
|
34
|
-
import {
|
31
|
+
import { GlobalProcessorState } from './base-processor.js'
|
35
32
|
import { validateAndNormalizeAddress } from './eth.js'
|
36
33
|
import { EthChainId } from '@sentio/chain'
|
37
34
|
import { EthContext } from './context.js'
|
38
35
|
import { TemplateInstanceState } from '../core/template.js'
|
39
36
|
import { timeOrBlockToBlockNumber } from '@sentio/sdk/utils'
|
40
|
-
|
41
|
-
interface Handlers {
|
42
|
-
eventHandlers: ((event: Data_EthLog, preparedData?: PreparedData) => Promise<ProcessResult>)[]
|
43
|
-
traceHandlers: ((trace: Data_EthTrace, preparedData?: PreparedData) => Promise<ProcessResult>)[]
|
44
|
-
blockHandlers: ((block: Data_EthBlock, preparedData?: PreparedData) => Promise<ProcessResult>)[]
|
45
|
-
transactionHandlers: ((trace: Data_EthTransaction, preparedData?: PreparedData) => Promise<ProcessResult>)[]
|
46
|
-
}
|
47
|
-
|
48
|
-
interface PreprocessHandlers {
|
49
|
-
eventHandlers: ((event: Data_EthLog, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>)[]
|
50
|
-
traceHandlers: ((trace: Data_EthTrace, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>)[]
|
51
|
-
blockHandlers: ((block: Data_EthBlock, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>)[]
|
52
|
-
transactionHandlers: ((
|
53
|
-
txn: Data_EthTransaction,
|
54
|
-
preprocessStore: { [k: string]: any }
|
55
|
-
) => Promise<PreprocessResult>)[]
|
56
|
-
}
|
37
|
+
import { HandlerRegister } from '../core/handler-register.js'
|
57
38
|
|
58
39
|
export class EthPlugin extends Plugin {
|
59
40
|
name: string = 'EthPlugin'
|
60
|
-
|
61
|
-
blockHandlers: [],
|
62
|
-
eventHandlers: [],
|
63
|
-
traceHandlers: [],
|
64
|
-
transactionHandlers: []
|
65
|
-
}
|
66
|
-
preprocessHandlers: PreprocessHandlers = {
|
67
|
-
blockHandlers: [],
|
68
|
-
eventHandlers: [],
|
69
|
-
traceHandlers: [],
|
70
|
-
transactionHandlers: []
|
71
|
-
}
|
41
|
+
handlerRegister = new HandlerRegister()
|
72
42
|
|
73
43
|
partitionManager = new PartitionHandlerManager()
|
74
44
|
|
75
|
-
async
|
76
|
-
const
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
82
|
-
const preprocessHandlers: PreprocessHandlers = {
|
83
|
-
blockHandlers: [],
|
84
|
-
eventHandlers: [],
|
85
|
-
traceHandlers: [],
|
86
|
-
transactionHandlers: []
|
45
|
+
async init(config: InitResponse): Promise<void> {
|
46
|
+
for (const state of [EthProcessorState.INSTANCE, GlobalProcessorState.INSTANCE, AccountProcessorState.INSTANCE]) {
|
47
|
+
for (const processor of state.getValues()) {
|
48
|
+
const chainId = processor.getChainId()
|
49
|
+
config.chainIds.push(chainId)
|
50
|
+
}
|
87
51
|
}
|
52
|
+
}
|
53
|
+
|
54
|
+
async configure(config: ProcessConfigResponse, forChainId?: string) {
|
55
|
+
this.handlerRegister.clear(forChainId as EthChainId)
|
88
56
|
|
89
57
|
for (const processor of EthProcessorState.INSTANCE.getValues()) {
|
90
58
|
// If server favor incremental update this need to change
|
91
59
|
// Start basic config for contract
|
92
60
|
const chainId = processor.getChainId()
|
93
61
|
// this.processorsByChainId.set(chainId, processor)
|
94
|
-
|
62
|
+
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
63
|
+
continue
|
64
|
+
}
|
95
65
|
const provider = getProvider(chainId)
|
96
66
|
const startBlock = await timeOrBlockToBlockNumber(provider, processor.config.start)
|
97
67
|
const endBlock = processor.config.end ? await timeOrBlockToBlockNumber(provider, processor.config.end) : undefined
|
@@ -110,8 +80,8 @@ export class EthPlugin extends Plugin {
|
|
110
80
|
|
111
81
|
// Step 1. Prepare all the block handlers
|
112
82
|
for (const blockHandler of processor.blockHandlers) {
|
113
|
-
|
114
|
-
|
83
|
+
const handlerId = this.handlerRegister.register(blockHandler.handler, chainId)
|
84
|
+
|
115
85
|
this.partitionManager.registerPartitionHandler(HandlerType.ETH_BLOCK, handlerId, blockHandler.partitionHandler)
|
116
86
|
// TODO wrap the block handler into one
|
117
87
|
|
@@ -128,8 +98,8 @@ export class EthPlugin extends Plugin {
|
|
128
98
|
|
129
99
|
// Step 2. Prepare all trace handlers
|
130
100
|
for (const traceHandler of processor.traceHandlers) {
|
131
|
-
|
132
|
-
|
101
|
+
const handlerId = this.handlerRegister.register(traceHandler.handler, chainId)
|
102
|
+
|
133
103
|
this.partitionManager.registerPartitionHandler(HandlerType.ETH_TRACE, handlerId, traceHandler.partitionHandler)
|
134
104
|
for (const signature of traceHandler.signatures) {
|
135
105
|
contractConfig.traceConfigs.push({
|
@@ -144,8 +114,7 @@ export class EthPlugin extends Plugin {
|
|
144
114
|
// Step 3. Prepare all the event handlers
|
145
115
|
for (const eventsHandler of processor.eventHandlers) {
|
146
116
|
// associate id with filter
|
147
|
-
|
148
|
-
const handlerId = handlers.eventHandlers.push(eventsHandler.handler) - 1
|
117
|
+
const handlerId = this.handlerRegister.register(eventsHandler.handler, chainId)
|
149
118
|
this.partitionManager.registerPartitionHandler(HandlerType.ETH_LOG, handlerId, eventsHandler.partitionHandler)
|
150
119
|
const logConfig: LogHandlerConfig = {
|
151
120
|
handlerId: handlerId,
|
@@ -186,7 +155,9 @@ export class EthPlugin extends Plugin {
|
|
186
155
|
|
187
156
|
for (const processor of GlobalProcessorState.INSTANCE.getValues()) {
|
188
157
|
const chainId = processor.getChainId()
|
189
|
-
|
158
|
+
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
159
|
+
continue
|
160
|
+
}
|
190
161
|
const provider = getProvider(chainId)
|
191
162
|
const startBlock = await timeOrBlockToBlockNumber(provider, processor.config.start)
|
192
163
|
const endBlock = processor.config.end ? await timeOrBlockToBlockNumber(provider, processor.config.end) : undefined
|
@@ -204,8 +175,7 @@ export class EthPlugin extends Plugin {
|
|
204
175
|
})
|
205
176
|
|
206
177
|
for (const blockHandler of processor.blockHandlers) {
|
207
|
-
|
208
|
-
const handlerId = handlers.blockHandlers.push(blockHandler.handler) - 1
|
178
|
+
const handlerId = this.handlerRegister.register(blockHandler.handler, chainId)
|
209
179
|
contractConfig.intervalConfigs.push({
|
210
180
|
slot: 0,
|
211
181
|
slotInterval: blockHandler.blockInterval,
|
@@ -218,8 +188,7 @@ export class EthPlugin extends Plugin {
|
|
218
188
|
}
|
219
189
|
|
220
190
|
for (const transactionHandler of processor.transactionHandler) {
|
221
|
-
|
222
|
-
const handlerId = handlers.transactionHandlers.push(transactionHandler.handler) - 1
|
191
|
+
const handlerId = this.handlerRegister.register(transactionHandler.handler, chainId)
|
223
192
|
this.partitionManager.registerPartitionHandler(
|
224
193
|
HandlerType.ETH_TRANSACTION,
|
225
194
|
handlerId,
|
@@ -233,8 +202,7 @@ export class EthPlugin extends Plugin {
|
|
233
202
|
}
|
234
203
|
|
235
204
|
for (const traceHandler of processor.traceHandlers) {
|
236
|
-
|
237
|
-
const handlerId = handlers.traceHandlers.push(traceHandler.handler) - 1
|
205
|
+
const handlerId = this.handlerRegister.register(traceHandler.handler, chainId)
|
238
206
|
for (const signature of traceHandler.signatures) {
|
239
207
|
contractConfig.traceConfigs.push({
|
240
208
|
signature: signature,
|
@@ -244,11 +212,61 @@ export class EthPlugin extends Plugin {
|
|
244
212
|
})
|
245
213
|
}
|
246
214
|
}
|
215
|
+
|
216
|
+
for (const eventsHandler of processor.eventHandlers) {
|
217
|
+
// associate id with filter
|
218
|
+
const handlerId = this.handlerRegister.register(eventsHandler.handler, processor.getChainId())
|
219
|
+
const logConfig: LogHandlerConfig = {
|
220
|
+
handlerId: handlerId,
|
221
|
+
handlerName: eventsHandler.handlerName,
|
222
|
+
filters: [],
|
223
|
+
fetchConfig: eventsHandler.fetchConfig
|
224
|
+
}
|
225
|
+
|
226
|
+
if (!eventsHandler.filters || eventsHandler.filters.length === 0) {
|
227
|
+
// if no filter, then we assume all logs
|
228
|
+
logConfig.filters.push({
|
229
|
+
topics: []
|
230
|
+
})
|
231
|
+
} else {
|
232
|
+
for (const filter of eventsHandler.filters) {
|
233
|
+
const topics = await filter.getTopicFilter()
|
234
|
+
// if (!filter.topics) {
|
235
|
+
// throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')
|
236
|
+
// }
|
237
|
+
let address = undefined
|
238
|
+
if (filter.address) {
|
239
|
+
address = filter.address.toString()
|
240
|
+
}
|
241
|
+
const logFilter: LogFilter = {
|
242
|
+
addressType: filter.addressType,
|
243
|
+
address: address && validateAndNormalizeAddress(address),
|
244
|
+
topics: []
|
245
|
+
}
|
246
|
+
|
247
|
+
for (const ts of topics) {
|
248
|
+
let hashes: string[] = []
|
249
|
+
if (Array.isArray(ts)) {
|
250
|
+
hashes = hashes.concat(ts)
|
251
|
+
} else if (ts) {
|
252
|
+
hashes.push(ts)
|
253
|
+
}
|
254
|
+
logFilter.topics.push({ hashes: hashes })
|
255
|
+
}
|
256
|
+
logConfig.filters.push(logFilter)
|
257
|
+
}
|
258
|
+
}
|
259
|
+
contractConfig.logConfigs.push(logConfig)
|
260
|
+
}
|
261
|
+
|
247
262
|
config.contractConfigs.push(contractConfig)
|
248
263
|
}
|
249
264
|
|
250
265
|
// part 1.b prepare EVM account processors
|
251
266
|
for (const processor of AccountProcessorState.INSTANCE.getValues()) {
|
267
|
+
if (forChainId !== undefined && forChainId !== processor.getChainId().toString()) {
|
268
|
+
continue
|
269
|
+
}
|
252
270
|
const accountConfig = AccountConfig.fromPartial({
|
253
271
|
address: validateAndNormalizeAddress(processor.config.address),
|
254
272
|
chainId: processor.getChainId().toString(),
|
@@ -257,8 +275,7 @@ export class EthPlugin extends Plugin {
|
|
257
275
|
// TODO add interval
|
258
276
|
for (const eventsHandler of processor.eventHandlers) {
|
259
277
|
// associate id with filter
|
260
|
-
|
261
|
-
const handlerId = handlers.eventHandlers.push(eventsHandler.handler) - 1
|
278
|
+
const handlerId = this.handlerRegister.register(eventsHandler.handler, processor.getChainId())
|
262
279
|
const logConfig: LogHandlerConfig = {
|
263
280
|
handlerId: handlerId,
|
264
281
|
handlerName: eventsHandler.handlerName,
|
@@ -268,9 +285,7 @@ export class EthPlugin extends Plugin {
|
|
268
285
|
|
269
286
|
for (const filter of eventsHandler.filters) {
|
270
287
|
const topics = await filter.getTopicFilter()
|
271
|
-
|
272
|
-
// throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')
|
273
|
-
// }
|
288
|
+
|
274
289
|
let address = undefined
|
275
290
|
if (filter.address) {
|
276
291
|
address = filter.address.toString()
|
@@ -292,14 +307,15 @@ export class EthPlugin extends Plugin {
|
|
292
307
|
}
|
293
308
|
logConfig.filters.push(logFilter)
|
294
309
|
}
|
310
|
+
|
295
311
|
accountConfig.logConfigs.push(logConfig)
|
296
312
|
}
|
297
313
|
|
298
314
|
config.accountConfigs.push(accountConfig)
|
299
315
|
}
|
300
316
|
|
301
|
-
this.handlers = handlers
|
302
|
-
this.preprocessHandlers = preprocessHandlers
|
317
|
+
// this.handlers = handlers
|
318
|
+
// this.preprocessHandlers = preprocessHandlers
|
303
319
|
}
|
304
320
|
|
305
321
|
supportedHandlers = [HandlerType.ETH_LOG, HandlerType.ETH_BLOCK, HandlerType.ETH_TRACE, HandlerType.ETH_TRANSACTION]
|
@@ -320,21 +336,6 @@ export class EthPlugin extends Plugin {
|
|
320
336
|
}
|
321
337
|
}
|
322
338
|
|
323
|
-
preprocessBinding(request: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
|
324
|
-
switch (request.handlerType) {
|
325
|
-
case HandlerType.ETH_LOG:
|
326
|
-
return this.preprocessLog(request, preprocessStore)
|
327
|
-
case HandlerType.ETH_TRACE:
|
328
|
-
return this.preprocessTrace(request, preprocessStore)
|
329
|
-
case HandlerType.ETH_BLOCK:
|
330
|
-
return this.preprocessBlock(request, preprocessStore)
|
331
|
-
case HandlerType.ETH_TRANSACTION:
|
332
|
-
return this.preprocessTransaction(request, preprocessStore)
|
333
|
-
default:
|
334
|
-
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
335
|
-
}
|
336
|
-
}
|
337
|
-
|
338
339
|
async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {
|
339
340
|
let data: any
|
340
341
|
switch (request.handlerType) {
|
@@ -408,87 +409,6 @@ export class EthPlugin extends Plugin {
|
|
408
409
|
return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length
|
409
410
|
}
|
410
411
|
|
411
|
-
async preprocessLog(request: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
|
412
|
-
if (!request.data?.ethLog?.log) {
|
413
|
-
throw new ServerError(Status.INVALID_ARGUMENT, "Log can't be null")
|
414
|
-
}
|
415
|
-
const ethLog = request.data.ethLog
|
416
|
-
|
417
|
-
const promises: Promise<PreprocessResult>[] = []
|
418
|
-
for (const handlerId of request.handlerIds) {
|
419
|
-
const handler = this.preprocessHandlers.eventHandlers[handlerId]
|
420
|
-
const promise = handler(ethLog, preprocessStore).catch((e) => {
|
421
|
-
throw new ServerError(
|
422
|
-
Status.INTERNAL,
|
423
|
-
'error processing log: ' + JSON.stringify(ethLog.log) + '\n' + errorString(e)
|
424
|
-
)
|
425
|
-
})
|
426
|
-
promises.push(promise)
|
427
|
-
}
|
428
|
-
return mergePreprocessResults(await Promise.all(promises))
|
429
|
-
}
|
430
|
-
|
431
|
-
async preprocessTrace(binding: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
|
432
|
-
if (!binding.data?.ethTrace?.trace) {
|
433
|
-
throw new ServerError(Status.INVALID_ARGUMENT, "Trace can't be null")
|
434
|
-
}
|
435
|
-
const ethTrace = binding.data.ethTrace
|
436
|
-
|
437
|
-
const promises: Promise<PreprocessResult>[] = []
|
438
|
-
|
439
|
-
for (const handlerId of binding.handlerIds) {
|
440
|
-
const promise = this.preprocessHandlers.traceHandlers[handlerId](ethTrace, preprocessStore).catch((e) => {
|
441
|
-
throw new ServerError(
|
442
|
-
Status.INTERNAL,
|
443
|
-
'error processing trace: ' + JSON.stringify(ethTrace.trace) + '\n' + errorString(e)
|
444
|
-
)
|
445
|
-
})
|
446
|
-
promises.push(promise)
|
447
|
-
}
|
448
|
-
return mergePreprocessResults(await Promise.all(promises))
|
449
|
-
}
|
450
|
-
|
451
|
-
async preprocessBlock(binding: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
|
452
|
-
if (!binding.data?.ethBlock?.block) {
|
453
|
-
throw new ServerError(Status.INVALID_ARGUMENT, "Block can't be empty")
|
454
|
-
}
|
455
|
-
const ethBlock = binding.data.ethBlock
|
456
|
-
|
457
|
-
const promises: Promise<PreprocessResult>[] = []
|
458
|
-
for (const handlerId of binding.handlerIds) {
|
459
|
-
const promise = this.preprocessHandlers.blockHandlers[handlerId](ethBlock, preprocessStore).catch((e) => {
|
460
|
-
throw new ServerError(
|
461
|
-
Status.INTERNAL,
|
462
|
-
'error processing block: ' + ethBlock.block?.number + '\n' + errorString(e)
|
463
|
-
)
|
464
|
-
})
|
465
|
-
promises.push(promise)
|
466
|
-
}
|
467
|
-
return mergePreprocessResults(await Promise.all(promises))
|
468
|
-
}
|
469
|
-
|
470
|
-
async preprocessTransaction(binding: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
|
471
|
-
if (!binding.data?.ethTransaction?.transaction) {
|
472
|
-
throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
|
473
|
-
}
|
474
|
-
const ethTransaction = binding.data.ethTransaction
|
475
|
-
|
476
|
-
const promises: Promise<PreprocessResult>[] = []
|
477
|
-
|
478
|
-
for (const handlerId of binding.handlerIds) {
|
479
|
-
const promise = this.preprocessHandlers.transactionHandlers[handlerId](ethTransaction, preprocessStore).catch(
|
480
|
-
(e) => {
|
481
|
-
throw new ServerError(
|
482
|
-
Status.INTERNAL,
|
483
|
-
'error processing transaction: ' + JSON.stringify(ethTransaction.transaction) + '\n' + errorString(e)
|
484
|
-
)
|
485
|
-
}
|
486
|
-
)
|
487
|
-
promises.push(promise)
|
488
|
-
}
|
489
|
-
return mergePreprocessResults(await Promise.all(promises))
|
490
|
-
}
|
491
|
-
|
492
412
|
async processLog(request: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
|
493
413
|
if (!request.data?.ethLog?.log) {
|
494
414
|
throw new ServerError(Status.INVALID_ARGUMENT, "Log can't be null")
|
@@ -497,8 +417,8 @@ export class EthPlugin extends Plugin {
|
|
497
417
|
|
498
418
|
const promises: Promise<ProcessResult>[] = []
|
499
419
|
for (const handlerId of request.handlerIds) {
|
500
|
-
const handler = this.
|
501
|
-
const promise = handler(ethLog, preparedData).catch((e) => {
|
420
|
+
const handler = this.handlerRegister.getHandlerById(handlerId)
|
421
|
+
const promise = handler(ethLog, preparedData).catch((e: any) => {
|
502
422
|
console.error('error processing log: ', e)
|
503
423
|
throw new ServerError(
|
504
424
|
Status.INTERNAL,
|
@@ -522,13 +442,15 @@ export class EthPlugin extends Plugin {
|
|
522
442
|
const promises: Promise<ProcessResult>[] = []
|
523
443
|
|
524
444
|
for (const handlerId of binding.handlerIds) {
|
525
|
-
const promise = this.
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
445
|
+
const promise = this.handlerRegister
|
446
|
+
.getHandlerById(handlerId)(ethTrace, preparedData)
|
447
|
+
.catch((e: any) => {
|
448
|
+
console.error('error processing trace: ', e)
|
449
|
+
throw new ServerError(
|
450
|
+
Status.INTERNAL,
|
451
|
+
'error processing trace: ' + JSON.stringify(ethTrace.trace) + '\n' + errorString(e)
|
452
|
+
)
|
453
|
+
})
|
532
454
|
if (GLOBAL_CONFIG.execution.sequential) {
|
533
455
|
await promise
|
534
456
|
}
|
@@ -545,13 +467,15 @@ export class EthPlugin extends Plugin {
|
|
545
467
|
|
546
468
|
const promises: Promise<ProcessResult>[] = []
|
547
469
|
for (const handlerId of binding.handlerIds) {
|
548
|
-
const promise = this.
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
470
|
+
const promise = this.handlerRegister
|
471
|
+
.getHandlerById(handlerId)(ethBlock, preparedData)
|
472
|
+
.catch((e: any) => {
|
473
|
+
console.error('error processing block: ', e)
|
474
|
+
throw new ServerError(
|
475
|
+
Status.INTERNAL,
|
476
|
+
'error processing block: ' + ethBlock.block?.number + '\n' + errorString(e)
|
477
|
+
)
|
478
|
+
})
|
555
479
|
if (GLOBAL_CONFIG.execution.sequential) {
|
556
480
|
await promise
|
557
481
|
}
|
@@ -569,12 +493,14 @@ export class EthPlugin extends Plugin {
|
|
569
493
|
const promises: Promise<ProcessResult>[] = []
|
570
494
|
|
571
495
|
for (const handlerId of binding.handlerIds) {
|
572
|
-
const promise = this.
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
496
|
+
const promise = this.handlerRegister
|
497
|
+
.getHandlerById(handlerId)(ethTransaction, preparedData)
|
498
|
+
.catch((e: any) => {
|
499
|
+
throw new ServerError(
|
500
|
+
Status.INTERNAL,
|
501
|
+
'error processing transaction: ' + JSON.stringify(ethTransaction.transaction) + '\n' + errorString(e)
|
502
|
+
)
|
503
|
+
})
|
578
504
|
if (GLOBAL_CONFIG.execution.sequential) {
|
579
505
|
await promise
|
580
506
|
}
|
package/src/eth/eth.ts
CHANGED
@@ -150,34 +150,39 @@ export function formatEthData(data: {
|
|
150
150
|
return data.__formattedEthData
|
151
151
|
}
|
152
152
|
|
153
|
-
|
154
|
-
|
155
|
-
data.block.transactions
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
if (
|
162
|
-
data.transaction.v
|
163
|
-
|
164
|
-
|
153
|
+
try {
|
154
|
+
const log = data.log ? formatLog(data.log) : undefined
|
155
|
+
if (data.block && !data.block.transactions) {
|
156
|
+
data.block.transactions = []
|
157
|
+
}
|
158
|
+
const block = data.block ? formatRichBlock(data.block) : undefined
|
159
|
+
const trace = data.trace ? (data.trace as Trace) : undefined
|
160
|
+
let transaction = undefined
|
161
|
+
if (data.transaction) {
|
162
|
+
if (!data.transaction.v) {
|
163
|
+
data.transaction.v = '0x1c'
|
164
|
+
data.transaction.r = '0x88ff6cf0fefd94db46111149ae4bfc179e9b94721fffd821d38d16464b3f71d0'
|
165
|
+
data.transaction.s = '0x45e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33a'
|
166
|
+
}
|
167
|
+
transaction = formatTransactionResponse(data.transaction)
|
168
|
+
}
|
169
|
+
const transactionReceipt = data.transactionReceipt ? formatTransactionReceipt(data.transactionReceipt) : undefined
|
170
|
+
|
171
|
+
const result = {
|
172
|
+
log,
|
173
|
+
block,
|
174
|
+
trace,
|
175
|
+
transaction,
|
176
|
+
transactionReceipt
|
165
177
|
}
|
166
|
-
transaction = formatTransactionResponse(data.transaction)
|
167
|
-
}
|
168
|
-
const transactionReceipt = data.transactionReceipt ? formatTransactionReceipt(data.transactionReceipt) : undefined
|
169
|
-
|
170
|
-
const result = {
|
171
|
-
log,
|
172
|
-
block,
|
173
|
-
trace,
|
174
|
-
transaction,
|
175
|
-
transactionReceipt
|
176
|
-
}
|
177
178
|
|
178
|
-
|
179
|
-
|
180
|
-
|
179
|
+
// Cache the result on the input data object
|
180
|
+
data.__formattedEthData = result
|
181
|
+
return result
|
182
|
+
} catch (e) {
|
183
|
+
console.error('Error formatting eth data', e)
|
184
|
+
return data
|
185
|
+
}
|
181
186
|
}
|
182
187
|
|
183
188
|
export function formatRichBlock(block: RichBlock): RichBlock {
|
package/src/fuel/fuel-plugin.ts
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
import { errorString, GLOBAL_CONFIG, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'
|
2
2
|
import { PartitionHandlerManager } from '../core/index.js'
|
3
|
+
import { HandlerRegister } from '../core/handler-register.js'
|
3
4
|
import {
|
4
5
|
ContractConfig,
|
5
|
-
Data_FuelBlock,
|
6
|
-
Data_FuelReceipt,
|
7
|
-
Data_FuelTransaction,
|
8
6
|
DataBinding,
|
9
7
|
HandlerType,
|
8
|
+
InitResponse,
|
10
9
|
ProcessConfigResponse,
|
11
10
|
ProcessResult,
|
12
11
|
ProcessStreamResponse_Partitions,
|
@@ -20,30 +19,26 @@ import { FuelProcessorState } from './types.js'
|
|
20
19
|
import { FuelProcessor } from './fuel-processor.js'
|
21
20
|
import { FuelGlobalProcessor } from './global-processor.js'
|
22
21
|
|
23
|
-
interface Handlers {
|
24
|
-
transactionHandlers: ((trace: Data_FuelTransaction) => Promise<ProcessResult>)[]
|
25
|
-
blockHandlers: ((block: Data_FuelBlock) => Promise<ProcessResult>)[]
|
26
|
-
receiptHandlers: ((log: Data_FuelReceipt) => Promise<ProcessResult>)[]
|
27
|
-
}
|
28
|
-
|
29
22
|
export class FuelPlugin extends Plugin {
|
30
23
|
name: string = 'FuelPlugin'
|
31
|
-
|
32
|
-
transactionHandlers: [],
|
33
|
-
blockHandlers: [],
|
34
|
-
receiptHandlers: []
|
35
|
-
}
|
36
|
-
|
24
|
+
handlerRegister = new HandlerRegister()
|
37
25
|
partitionManager = new PartitionHandlerManager()
|
38
26
|
|
39
|
-
async
|
40
|
-
const
|
41
|
-
|
42
|
-
|
43
|
-
receiptHandlers: []
|
27
|
+
async init(config: InitResponse) {
|
28
|
+
for (const fuelProcessor of FuelProcessorState.INSTANCE.getValues()) {
|
29
|
+
const chainId = fuelProcessor.config.chainId
|
30
|
+
config.chainIds.push(chainId)
|
44
31
|
}
|
32
|
+
}
|
33
|
+
|
34
|
+
async configure(config: ProcessConfigResponse, forChainId?: string) {
|
35
|
+
this.handlerRegister.clear(forChainId as any)
|
45
36
|
|
46
37
|
for (const processor of FuelProcessorState.INSTANCE.getValues()) {
|
38
|
+
const chainId = processor.config.chainId
|
39
|
+
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
40
|
+
continue
|
41
|
+
}
|
47
42
|
const processorConfig = processor.config
|
48
43
|
const contractConfig = ContractConfig.fromPartial({
|
49
44
|
processorType: USER_PROCESSOR,
|
@@ -57,7 +52,7 @@ export class FuelPlugin extends Plugin {
|
|
57
52
|
endBlock: processorConfig.endBlock
|
58
53
|
})
|
59
54
|
for (const txHandler of processor.txHandlers) {
|
60
|
-
const handlerId =
|
55
|
+
const handlerId = this.handlerRegister.register(txHandler.handler, chainId)
|
61
56
|
this.partitionManager.registerPartitionHandler(
|
62
57
|
HandlerType.FUEL_TRANSACTION,
|
63
58
|
handlerId,
|
@@ -90,7 +85,7 @@ export class FuelPlugin extends Plugin {
|
|
90
85
|
}
|
91
86
|
|
92
87
|
for (const receiptHandler of processor.receiptHandlers ?? []) {
|
93
|
-
const handlerId =
|
88
|
+
const handlerId = this.handlerRegister.register(receiptHandler.handler, chainId)
|
94
89
|
this.partitionManager.registerPartitionHandler(
|
95
90
|
HandlerType.FUEL_RECEIPT,
|
96
91
|
handlerId,
|
@@ -107,7 +102,7 @@ export class FuelPlugin extends Plugin {
|
|
107
102
|
}
|
108
103
|
|
109
104
|
for (const blockHandler of processor.blockHandlers) {
|
110
|
-
const handlerId =
|
105
|
+
const handlerId = this.handlerRegister.register(blockHandler.handler, chainId)
|
111
106
|
this.partitionManager.registerPartitionHandler(HandlerType.FUEL_BLOCK, handlerId, blockHandler.partitionHandler)
|
112
107
|
contractConfig.intervalConfigs.push({
|
113
108
|
slot: 0,
|
@@ -123,8 +118,6 @@ export class FuelPlugin extends Plugin {
|
|
123
118
|
|
124
119
|
config.contractConfigs.push(contractConfig)
|
125
120
|
}
|
126
|
-
|
127
|
-
this.handlers = handlers
|
128
121
|
}
|
129
122
|
|
130
123
|
supportedHandlers = [
|
@@ -212,12 +205,14 @@ export class FuelPlugin extends Plugin {
|
|
212
205
|
const promises: Promise<ProcessResult>[] = []
|
213
206
|
|
214
207
|
for (const handlerId of binding.handlerIds) {
|
215
|
-
const promise = this.
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
208
|
+
const promise = this.handlerRegister
|
209
|
+
.getHandlerById(handlerId)(receipt)
|
210
|
+
.catch((e: any) => {
|
211
|
+
throw new ServerError(
|
212
|
+
Status.INTERNAL,
|
213
|
+
'error processing transaction: ' + JSON.stringify(receipt) + '\n' + errorString(e)
|
214
|
+
)
|
215
|
+
})
|
221
216
|
if (GLOBAL_CONFIG.execution.sequential) {
|
222
217
|
await promise
|
223
218
|
}
|
@@ -235,12 +230,14 @@ export class FuelPlugin extends Plugin {
|
|
235
230
|
const promises: Promise<ProcessResult>[] = []
|
236
231
|
|
237
232
|
for (const handlerId of binding.handlerIds) {
|
238
|
-
const promise = this.
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
233
|
+
const promise = this.handlerRegister
|
234
|
+
.getHandlerById(handlerId)(fuelTransaction)
|
235
|
+
.catch((e: any) => {
|
236
|
+
throw new ServerError(
|
237
|
+
Status.INTERNAL,
|
238
|
+
'error processing transaction: ' + JSON.stringify(fuelTransaction.transaction) + '\n' + errorString(e)
|
239
|
+
)
|
240
|
+
})
|
244
241
|
if (GLOBAL_CONFIG.execution.sequential) {
|
245
242
|
await promise
|
246
243
|
}
|
@@ -257,13 +254,15 @@ export class FuelPlugin extends Plugin {
|
|
257
254
|
|
258
255
|
const promises: Promise<ProcessResult>[] = []
|
259
256
|
for (const handlerId of binding.handlerIds) {
|
260
|
-
const promise = this.
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
257
|
+
const promise = this.handlerRegister
|
258
|
+
.getHandlerById(handlerId)(ethBlock)
|
259
|
+
.catch((e: any) => {
|
260
|
+
console.error('error processing block: ', e)
|
261
|
+
throw new ServerError(
|
262
|
+
Status.INTERNAL,
|
263
|
+
'error processing block: ' + ethBlock.block?.height + '\n' + errorString(e)
|
264
|
+
)
|
265
|
+
})
|
267
266
|
if (GLOBAL_CONFIG.execution.sequential) {
|
268
267
|
await promise
|
269
268
|
}
|