@sentio/sdk 4.0.0-rc.1 → 4.0.0-rc.3
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 +1 -1
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +43 -42
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +1 -1
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +25 -25
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.js +10 -5
- package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
- package/lib/aptos/context.d.ts +1 -1
- package/lib/aptos/context.d.ts.map +1 -1
- package/lib/aptos/context.js +8 -6
- package/lib/aptos/context.js.map +1 -1
- package/lib/aptos/data.d.ts +4 -4
- package/lib/aptos/data.d.ts.map +1 -1
- package/lib/core/base-context.d.ts +3 -2
- package/lib/core/base-context.d.ts.map +1 -1
- package/lib/core/base-context.js +12 -11
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/core-plugin.d.ts.map +1 -1
- package/lib/core/core-plugin.js +6 -4
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/core/event-logger.d.ts +10 -2
- package/lib/core/event-logger.d.ts.map +1 -1
- package/lib/core/event-logger.js +42 -26
- package/lib/core/event-logger.js.map +1 -1
- package/lib/core/exporter.d.ts.map +1 -1
- package/lib/core/exporter.js +5 -3
- package/lib/core/exporter.js.map +1 -1
- package/lib/core/handler-options.d.ts +1 -1
- package/lib/core/handler-options.d.ts.map +1 -1
- package/lib/core/handler-register.d.ts +1 -1
- package/lib/core/handler-register.d.ts.map +1 -1
- package/lib/core/handler-register.js +2 -2
- package/lib/core/handler-register.js.map +1 -1
- package/lib/core/meter.d.ts +4 -3
- package/lib/core/meter.d.ts.map +1 -1
- package/lib/core/meter.js +5 -4
- package/lib/core/meter.js.map +1 -1
- package/lib/core/normalization.d.ts +1 -1
- package/lib/core/normalization.d.ts.map +1 -1
- package/lib/core/normalization.js +41 -31
- package/lib/core/normalization.js.map +1 -1
- package/lib/core/numberish.d.ts +1 -1
- package/lib/core/numberish.d.ts.map +1 -1
- package/lib/core/numberish.js +35 -30
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/partition-handler-manager.d.ts +1 -1
- package/lib/core/partition-handler-manager.d.ts.map +1 -1
- package/lib/core/partition-handler-manager.js +10 -9
- package/lib/core/partition-handler-manager.js.map +1 -1
- package/lib/cosmos/context.d.ts.map +1 -1
- package/lib/cosmos/context.js +4 -2
- package/lib/cosmos/context.js.map +1 -1
- package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
- package/lib/cosmos/cosmos-plugin.js +11 -10
- package/lib/cosmos/cosmos-plugin.js.map +1 -1
- package/lib/cosmos/cosmos-processor.js.map +1 -1
- package/lib/eth/abi-decoder/decode-worker.js +2 -2
- package/lib/eth/abi-decoder/decode-worker.js.map +1 -1
- package/lib/eth/account-processor.d.ts +2 -2
- package/lib/eth/account-processor.d.ts.map +1 -1
- package/lib/eth/account-processor.js +10 -9
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +3 -3
- package/lib/eth/base-processor-template.d.ts.map +1 -1
- package/lib/eth/base-processor-template.js +12 -8
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +1 -1
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +53 -46
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +48 -46
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +18 -16
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +38 -36
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +20 -18
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +30 -28
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +24 -22
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/file.d.ts.map +1 -1
- package/lib/eth/codegen/file.js +2 -1
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/codegen/function-calls.js +1 -1
- package/lib/eth/context.d.ts +1 -1
- package/lib/eth/context.d.ts.map +1 -1
- package/lib/eth/context.js +17 -11
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +83 -75
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts +6 -6
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +39 -26
- package/lib/eth/eth.js.map +1 -1
- package/lib/eth/index.d.ts +1 -1
- package/lib/eth/index.d.ts.map +1 -1
- package/lib/eth/index.js +0 -1
- package/lib/eth/index.js.map +1 -1
- package/lib/fuel/asset-processor.d.ts +2 -2
- package/lib/fuel/asset-processor.d.ts.map +1 -1
- package/lib/fuel/asset-processor.js +5 -3
- package/lib/fuel/asset-processor.js.map +1 -1
- package/lib/fuel/context.d.ts.map +1 -1
- package/lib/fuel/context.js +4 -2
- package/lib/fuel/context.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +41 -53
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
- package/lib/fuel/fuel-processor-template.js +7 -5
- package/lib/fuel/fuel-processor-template.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +30 -20
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/fuel/global-processor.d.ts.map +1 -1
- package/lib/fuel/global-processor.js +2 -1
- package/lib/fuel/global-processor.js.map +1 -1
- package/lib/fuel/types.d.ts +10 -4
- package/lib/fuel/types.d.ts.map +1 -1
- package/lib/fuel/types.js.map +1 -1
- package/lib/iota/context.d.ts +1 -1
- package/lib/iota/context.d.ts.map +1 -1
- package/lib/iota/context.js +8 -6
- package/lib/iota/context.js.map +1 -1
- package/lib/iota/iota-object-processor-template.d.ts +1 -1
- package/lib/iota/iota-object-processor-template.d.ts.map +1 -1
- package/lib/iota/iota-object-processor-template.js +17 -12
- package/lib/iota/iota-object-processor-template.js.map +1 -1
- package/lib/iota/iota-object-processor.d.ts +1 -1
- package/lib/iota/iota-object-processor.d.ts.map +1 -1
- package/lib/iota/iota-object-processor.js +23 -16
- package/lib/iota/iota-object-processor.js.map +1 -1
- package/lib/iota/iota-plugin-part.d.ts +1 -1
- package/lib/iota/iota-plugin-part.d.ts.map +1 -1
- package/lib/iota/iota-plugin-part.js +16 -15
- package/lib/iota/iota-plugin-part.js.map +1 -1
- package/lib/iota/iota-processor.d.ts +1 -1
- package/lib/iota/iota-processor.d.ts.map +1 -1
- package/lib/iota/iota-processor.js +18 -17
- package/lib/iota/iota-processor.js.map +1 -1
- package/lib/iota/network.js +2 -2
- package/lib/iota/network.js.map +1 -1
- package/lib/move/filter.d.ts +1 -1
- package/lib/move/filter.d.ts.map +1 -1
- package/lib/move/index.d.ts +1 -1
- package/lib/move/index.d.ts.map +1 -1
- package/lib/move/index.js +0 -1
- package/lib/move/index.js.map +1 -1
- package/lib/solana/builtin/types.d.ts +4 -4
- package/lib/solana/solana-context.d.ts.map +1 -1
- package/lib/solana/solana-context.js +4 -3
- package/lib/solana/solana-context.js.map +1 -1
- package/lib/solana/solana-plugin.d.ts.map +1 -1
- package/lib/solana/solana-plugin.js +19 -18
- package/lib/solana/solana-plugin.js.map +1 -1
- package/lib/solana/solana-processor.d.ts.map +1 -1
- package/lib/solana/solana-processor.js +8 -3
- package/lib/solana/solana-processor.js.map +1 -1
- package/lib/store/cache.d.ts.map +1 -1
- package/lib/store/cache.js +22 -17
- package/lib/store/cache.js.map +1 -1
- package/lib/store/convert.d.ts +1 -1
- package/lib/store/convert.d.ts.map +1 -1
- package/lib/store/convert.js +67 -104
- package/lib/store/convert.js.map +1 -1
- package/lib/store/decorators.d.ts +1 -1
- package/lib/store/decorators.d.ts.map +1 -1
- package/lib/store/decorators.js +3 -1
- package/lib/store/decorators.js.map +1 -1
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +24 -16
- package/lib/store/store.js.map +1 -1
- package/lib/store/types.js +24 -32
- package/lib/store/types.js.map +1 -1
- package/lib/store/util.d.ts +1 -1
- package/lib/store/util.d.ts.map +1 -1
- package/lib/store/util.js +13 -17
- package/lib/store/util.js.map +1 -1
- package/lib/sui/context.d.ts +1 -1
- package/lib/sui/context.d.ts.map +1 -1
- package/lib/sui/context.js +8 -6
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/sui-object-processor-template.d.ts +1 -1
- package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
- package/lib/sui/sui-object-processor-template.js +17 -12
- package/lib/sui/sui-object-processor-template.js.map +1 -1
- package/lib/sui/sui-object-processor.d.ts +1 -1
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +23 -16
- package/lib/sui/sui-object-processor.js.map +1 -1
- package/lib/sui/sui-plugin-part.d.ts +1 -1
- package/lib/sui/sui-plugin-part.d.ts.map +1 -1
- package/lib/sui/sui-plugin-part.js +16 -15
- package/lib/sui/sui-plugin-part.js.map +1 -1
- package/lib/sui/sui-plugin.d.ts +1 -1
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +35 -34
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +1 -1
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +18 -17
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/aptos-facet.d.ts.map +1 -1
- package/lib/testing/aptos-facet.js +18 -11
- package/lib/testing/aptos-facet.js.map +1 -1
- package/lib/testing/cosmos-facet.d.ts.map +1 -1
- package/lib/testing/cosmos-facet.js +10 -6
- package/lib/testing/cosmos-facet.js.map +1 -1
- package/lib/testing/eth-facet.d.ts +1 -1
- package/lib/testing/eth-facet.d.ts.map +1 -1
- package/lib/testing/eth-facet.js +34 -18
- package/lib/testing/eth-facet.js.map +1 -1
- package/lib/testing/fuel-facet.d.ts.map +1 -1
- package/lib/testing/fuel-facet.js +28 -18
- package/lib/testing/fuel-facet.js.map +1 -1
- package/lib/testing/iota-facet.d.ts.map +1 -1
- package/lib/testing/iota-facet.js +32 -20
- package/lib/testing/iota-facet.js.map +1 -1
- package/lib/testing/memory-database.d.ts +11 -3
- package/lib/testing/memory-database.d.ts.map +1 -1
- package/lib/testing/memory-database.js +84 -71
- package/lib/testing/memory-database.js.map +1 -1
- package/lib/testing/metric-utils.d.ts +2 -2
- package/lib/testing/metric-utils.d.ts.map +1 -1
- package/lib/testing/metric-utils.js +13 -12
- package/lib/testing/metric-utils.js.map +1 -1
- package/lib/testing/solana-facet.d.ts +3 -2
- package/lib/testing/solana-facet.d.ts.map +1 -1
- package/lib/testing/solana-facet.js +8 -5
- package/lib/testing/solana-facet.js.map +1 -1
- package/lib/testing/sui-facet.d.ts.map +1 -1
- package/lib/testing/sui-facet.js +30 -20
- package/lib/testing/sui-facet.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +1453 -16
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +108 -45
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/utils/price.d.ts +1 -1
- package/lib/utils/price.d.ts.map +1 -1
- package/lib/utils/price.js +19 -12
- package/lib/utils/price.js.map +1 -1
- package/package.json +5 -7
- package/src/aptos/aptos-plugin.ts +105 -91
- package/src/aptos/aptos-processor.ts +33 -25
- package/src/aptos/aptos-resource-processor-template.ts +15 -6
- package/src/aptos/context.ts +8 -7
- package/src/aptos/data.ts +4 -4
- package/src/core/base-context.ts +19 -12
- package/src/core/core-plugin.ts +10 -7
- package/src/core/event-logger.ts +63 -34
- package/src/core/exporter.ts +5 -4
- package/src/core/handler-options.ts +1 -1
- package/src/core/handler-register.ts +3 -3
- package/src/core/meter.ts +9 -7
- package/src/core/normalization.ts +53 -31
- package/src/core/numberish.ts +46 -30
- package/src/core/partition-handler-manager.ts +13 -11
- package/src/cosmos/context.ts +4 -3
- package/src/cosmos/cosmos-plugin.ts +19 -15
- package/src/cosmos/cosmos-processor.ts +2 -2
- package/src/eth/abi-decoder/decode-worker.ts +2 -2
- package/src/eth/account-processor.ts +21 -12
- package/src/eth/base-processor-template.ts +22 -10
- package/src/eth/base-processor.ts +66 -54
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +177 -116
- package/src/eth/builtin/internal/erc1155-processor.ts +73 -38
- package/src/eth/builtin/internal/erc20-processor.ts +152 -91
- package/src/eth/builtin/internal/erc20bytes-processor.ts +80 -46
- package/src/eth/builtin/internal/erc721-processor.ts +109 -65
- package/src/eth/builtin/internal/weth9-processor.ts +95 -56
- package/src/eth/codegen/file.ts +2 -1
- package/src/eth/codegen/function-calls.ts +1 -1
- package/src/eth/context.ts +29 -13
- package/src/eth/eth-plugin.ts +135 -118
- package/src/eth/eth.ts +46 -32
- package/src/eth/index.ts +1 -1
- package/src/fuel/asset-processor.ts +16 -8
- package/src/fuel/context.ts +4 -3
- package/src/fuel/fuel-plugin.ts +71 -73
- package/src/fuel/fuel-processor-template.ts +7 -6
- package/src/fuel/fuel-processor.ts +35 -23
- package/src/fuel/global-processor.ts +3 -3
- package/src/fuel/types.ts +10 -4
- package/src/iota/context.ts +8 -7
- package/src/iota/iota-object-processor-template.ts +25 -15
- package/src/iota/iota-object-processor.ts +33 -22
- package/src/iota/iota-plugin-part.ts +41 -34
- package/src/iota/iota-processor.ts +25 -17
- package/src/iota/network.ts +2 -2
- package/src/move/filter.ts +1 -1
- package/src/move/index.ts +1 -1
- package/src/solana/solana-context.ts +4 -3
- package/src/solana/solana-plugin.ts +27 -24
- package/src/solana/solana-processor.ts +14 -6
- package/src/store/cache.ts +22 -18
- package/src/store/convert.ts +68 -104
- package/src/store/decorators.ts +3 -2
- package/src/store/store.ts +30 -22
- package/src/store/types.ts +24 -33
- package/src/store/util.ts +13 -18
- package/src/sui/context.ts +8 -7
- package/src/sui/sui-object-processor-template.ts +25 -15
- package/src/sui/sui-object-processor.ts +33 -22
- package/src/sui/sui-plugin-part.ts +41 -34
- package/src/sui/sui-plugin.ts +49 -47
- package/src/sui/sui-processor.ts +25 -17
- package/src/testing/aptos-facet.ts +18 -11
- package/src/testing/cosmos-facet.ts +10 -6
- package/src/testing/eth-facet.ts +40 -18
- package/src/testing/fuel-facet.ts +28 -18
- package/src/testing/iota-facet.ts +32 -20
- package/src/testing/memory-database.ts +126 -88
- package/src/testing/metric-utils.ts +15 -14
- package/src/testing/solana-facet.ts +11 -6
- package/src/testing/sui-facet.ts +30 -20
- package/src/testing/test-processor-server.ts +169 -79
- package/src/utils/price.ts +20 -13
package/src/eth/eth-plugin.ts
CHANGED
|
@@ -9,22 +9,28 @@ import {
|
|
|
9
9
|
} from '@sentio/runtime'
|
|
10
10
|
import { PartitionHandlerManager } from '../core/index.js'
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
AccountConfigSchema,
|
|
13
|
+
ContractConfigSchema,
|
|
14
14
|
DataBinding,
|
|
15
15
|
HandlerType,
|
|
16
16
|
InitResponse,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
LogFilterSchema,
|
|
18
|
+
LogHandlerConfigSchema,
|
|
19
|
+
OnIntervalConfigSchema,
|
|
19
20
|
PreparedData,
|
|
20
21
|
PreprocessResult,
|
|
22
|
+
PreprocessResultSchema,
|
|
21
23
|
ProcessConfigResponse,
|
|
22
24
|
ProcessResult,
|
|
23
25
|
ProcessStreamResponse_Partitions,
|
|
24
|
-
|
|
26
|
+
ProcessStreamResponse_PartitionsSchema,
|
|
27
|
+
StartRequest,
|
|
28
|
+
TopicSchema,
|
|
29
|
+
TraceHandlerConfigSchema,
|
|
30
|
+
TransactionHandlerConfigSchema
|
|
25
31
|
} from '@sentio/protos'
|
|
26
|
-
|
|
27
|
-
import {
|
|
32
|
+
import { create } from '@bufbuild/protobuf'
|
|
33
|
+
import { ConnectError, Code } from '@connectrpc/connect'
|
|
28
34
|
import { EthProcessorState } from './binds.js'
|
|
29
35
|
import { AccountProcessorState } from './account-processor-state.js'
|
|
30
36
|
import { ProcessorTemplateProcessorState } from './base-processor-template.js'
|
|
@@ -65,7 +71,7 @@ export class EthPlugin extends Plugin {
|
|
|
65
71
|
const startBlock = await timeOrBlockToBlockNumber(provider, processor.config.start)
|
|
66
72
|
const endBlock = processor.config.end ? await timeOrBlockToBlockNumber(provider, processor.config.end) : undefined
|
|
67
73
|
|
|
68
|
-
const contractConfig =
|
|
74
|
+
const contractConfig = create(ContractConfigSchema, {
|
|
69
75
|
processorType: USER_PROCESSOR,
|
|
70
76
|
contract: {
|
|
71
77
|
name: processor.config.name,
|
|
@@ -84,15 +90,17 @@ export class EthPlugin extends Plugin {
|
|
|
84
90
|
this.partitionManager.registerPartitionHandler(HandlerType.ETH_BLOCK, handlerId, blockHandler.partitionHandler)
|
|
85
91
|
// TODO wrap the block handler into one
|
|
86
92
|
|
|
87
|
-
contractConfig.intervalConfigs.push(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
contractConfig.intervalConfigs.push(
|
|
94
|
+
create(OnIntervalConfigSchema, {
|
|
95
|
+
slot: 0,
|
|
96
|
+
slotInterval: blockHandler.blockInterval,
|
|
97
|
+
minutes: 0,
|
|
98
|
+
minutesInterval: blockHandler.timeIntervalInMinutes,
|
|
99
|
+
handlerId: handlerId,
|
|
100
|
+
handlerName: blockHandler.handlerName,
|
|
101
|
+
fetchConfig: blockHandler.fetchConfig
|
|
102
|
+
})
|
|
103
|
+
)
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
// Step 2. Prepare all trace handlers
|
|
@@ -101,12 +109,14 @@ export class EthPlugin extends Plugin {
|
|
|
101
109
|
|
|
102
110
|
this.partitionManager.registerPartitionHandler(HandlerType.ETH_TRACE, handlerId, traceHandler.partitionHandler)
|
|
103
111
|
for (const signature of traceHandler.signatures) {
|
|
104
|
-
contractConfig.traceConfigs.push(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
contractConfig.traceConfigs.push(
|
|
113
|
+
create(TraceHandlerConfigSchema, {
|
|
114
|
+
signature: signature,
|
|
115
|
+
handlerId: handlerId,
|
|
116
|
+
handlerName: traceHandler.handlerName,
|
|
117
|
+
fetchConfig: traceHandler.fetchConfig
|
|
118
|
+
})
|
|
119
|
+
)
|
|
110
120
|
}
|
|
111
121
|
}
|
|
112
122
|
|
|
@@ -115,24 +125,25 @@ export class EthPlugin extends Plugin {
|
|
|
115
125
|
// associate id with filter
|
|
116
126
|
const handlerId = this.handlerRegister.register(eventsHandler.handler, chainId)
|
|
117
127
|
this.partitionManager.registerPartitionHandler(HandlerType.ETH_LOG, handlerId, eventsHandler.partitionHandler)
|
|
118
|
-
const logConfig
|
|
128
|
+
const logConfig = create(LogHandlerConfigSchema, {
|
|
119
129
|
handlerId: handlerId,
|
|
120
130
|
handlerName: eventsHandler.handlerName,
|
|
121
131
|
filters: [],
|
|
122
132
|
fetchConfig: eventsHandler.fetchConfig
|
|
123
|
-
}
|
|
133
|
+
})
|
|
124
134
|
|
|
125
135
|
for (const filter of eventsHandler.filters) {
|
|
126
136
|
const topics = await filter.getTopicFilter()
|
|
127
137
|
|
|
128
138
|
// if (!filter.topics) {
|
|
129
|
-
// throw new
|
|
139
|
+
// throw new ConnectError('Topic should not be null', Code.InvalidArgument)
|
|
130
140
|
// }
|
|
131
|
-
const logFilter
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
const logFilter = create(LogFilterSchema, {
|
|
142
|
+
addressOrType: contractConfig.contract?.address
|
|
143
|
+
? { case: 'address', value: validateAndNormalizeAddress(contractConfig.contract.address) }
|
|
144
|
+
: undefined,
|
|
134
145
|
topics: []
|
|
135
|
-
}
|
|
146
|
+
})
|
|
136
147
|
|
|
137
148
|
for (const ts of topics) {
|
|
138
149
|
let hashes: string[] = []
|
|
@@ -141,7 +152,7 @@ export class EthPlugin extends Plugin {
|
|
|
141
152
|
} else if (ts) {
|
|
142
153
|
hashes.push(ts)
|
|
143
154
|
}
|
|
144
|
-
logFilter.topics.push({ hashes: hashes })
|
|
155
|
+
logFilter.topics.push(create(TopicSchema, { hashes: hashes }))
|
|
145
156
|
}
|
|
146
157
|
logConfig.filters.push(logFilter)
|
|
147
158
|
}
|
|
@@ -168,7 +179,7 @@ export class EthPlugin extends Plugin {
|
|
|
168
179
|
endBlock = processor.config.end?.block != undefined ? BigInt(processor.config.end.block) : undefined
|
|
169
180
|
}
|
|
170
181
|
|
|
171
|
-
const contractConfig =
|
|
182
|
+
const contractConfig = create(ContractConfigSchema, {
|
|
172
183
|
processorType: USER_PROCESSOR,
|
|
173
184
|
contract: {
|
|
174
185
|
name: processor.config.name,
|
|
@@ -182,15 +193,17 @@ export class EthPlugin extends Plugin {
|
|
|
182
193
|
|
|
183
194
|
for (const blockHandler of processor.blockHandlers) {
|
|
184
195
|
const handlerId = this.handlerRegister.register(blockHandler.handler, chainId)
|
|
185
|
-
contractConfig.intervalConfigs.push(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
196
|
+
contractConfig.intervalConfigs.push(
|
|
197
|
+
create(OnIntervalConfigSchema, {
|
|
198
|
+
slot: 0,
|
|
199
|
+
slotInterval: blockHandler.blockInterval,
|
|
200
|
+
minutes: 0,
|
|
201
|
+
minutesInterval: blockHandler.timeIntervalInMinutes,
|
|
202
|
+
handlerId: handlerId,
|
|
203
|
+
handlerName: blockHandler.handlerName,
|
|
204
|
+
fetchConfig: blockHandler.fetchConfig
|
|
205
|
+
})
|
|
206
|
+
)
|
|
194
207
|
}
|
|
195
208
|
|
|
196
209
|
for (const transactionHandler of processor.transactionHandler) {
|
|
@@ -200,55 +213,65 @@ export class EthPlugin extends Plugin {
|
|
|
200
213
|
handlerId,
|
|
201
214
|
transactionHandler.partitionHandler
|
|
202
215
|
)
|
|
203
|
-
contractConfig.transactionConfig.push(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
contractConfig.transactionConfig.push(
|
|
217
|
+
create(TransactionHandlerConfigSchema, {
|
|
218
|
+
handlerId: handlerId,
|
|
219
|
+
handlerName: transactionHandler.handlerName,
|
|
220
|
+
fetchConfig: transactionHandler.fetchConfig
|
|
221
|
+
})
|
|
222
|
+
)
|
|
208
223
|
}
|
|
209
224
|
|
|
210
225
|
for (const traceHandler of processor.traceHandlers) {
|
|
211
226
|
const handlerId = this.handlerRegister.register(traceHandler.handler, chainId)
|
|
212
227
|
for (const signature of traceHandler.signatures) {
|
|
213
|
-
contractConfig.traceConfigs.push(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
228
|
+
contractConfig.traceConfigs.push(
|
|
229
|
+
create(TraceHandlerConfigSchema, {
|
|
230
|
+
signature: signature,
|
|
231
|
+
handlerId: handlerId,
|
|
232
|
+
handlerName: traceHandler.handlerName,
|
|
233
|
+
fetchConfig: traceHandler.fetchConfig
|
|
234
|
+
})
|
|
235
|
+
)
|
|
219
236
|
}
|
|
220
237
|
}
|
|
221
238
|
|
|
222
239
|
for (const eventsHandler of processor.eventHandlers) {
|
|
223
240
|
// associate id with filter
|
|
224
241
|
const handlerId = this.handlerRegister.register(eventsHandler.handler, processor.getChainId())
|
|
225
|
-
const logConfig
|
|
242
|
+
const logConfig = create(LogHandlerConfigSchema, {
|
|
226
243
|
handlerId: handlerId,
|
|
227
244
|
handlerName: eventsHandler.handlerName,
|
|
228
245
|
filters: [],
|
|
229
246
|
fetchConfig: eventsHandler.fetchConfig
|
|
230
|
-
}
|
|
247
|
+
})
|
|
231
248
|
|
|
232
249
|
if (!eventsHandler.filters || eventsHandler.filters.length === 0) {
|
|
233
250
|
// if no filter, then we assume all logs
|
|
234
|
-
logConfig.filters.push(
|
|
235
|
-
|
|
236
|
-
|
|
251
|
+
logConfig.filters.push(
|
|
252
|
+
create(LogFilterSchema, {
|
|
253
|
+
topics: []
|
|
254
|
+
})
|
|
255
|
+
)
|
|
237
256
|
} else {
|
|
238
257
|
for (const filter of eventsHandler.filters) {
|
|
239
258
|
const topics = await filter.getTopicFilter()
|
|
240
259
|
// if (!filter.topics) {
|
|
241
|
-
// throw new
|
|
260
|
+
// throw new ConnectError('Topic should not be null', Code.InvalidArgument)
|
|
242
261
|
// }
|
|
243
262
|
let address = undefined
|
|
244
263
|
if (filter.address) {
|
|
245
264
|
address = filter.address.toString()
|
|
246
265
|
}
|
|
247
|
-
const logFilter
|
|
248
|
-
|
|
249
|
-
|
|
266
|
+
const logFilter = create(LogFilterSchema, {
|
|
267
|
+
addressOrType:
|
|
268
|
+
filter.addressType != undefined
|
|
269
|
+
? { case: 'addressType', value: filter.addressType }
|
|
270
|
+
: address
|
|
271
|
+
? { case: 'address', value: validateAndNormalizeAddress(address) }
|
|
272
|
+
: undefined,
|
|
250
273
|
topics: []
|
|
251
|
-
}
|
|
274
|
+
})
|
|
252
275
|
|
|
253
276
|
for (const ts of topics) {
|
|
254
277
|
let hashes: string[] = []
|
|
@@ -257,7 +280,7 @@ export class EthPlugin extends Plugin {
|
|
|
257
280
|
} else if (ts) {
|
|
258
281
|
hashes.push(ts)
|
|
259
282
|
}
|
|
260
|
-
logFilter.topics.push({ hashes: hashes })
|
|
283
|
+
logFilter.topics.push(create(TopicSchema, { hashes: hashes }))
|
|
261
284
|
}
|
|
262
285
|
logConfig.filters.push(logFilter)
|
|
263
286
|
}
|
|
@@ -273,7 +296,7 @@ export class EthPlugin extends Plugin {
|
|
|
273
296
|
if (forChainId !== undefined && forChainId !== processor.getChainId().toString()) {
|
|
274
297
|
continue
|
|
275
298
|
}
|
|
276
|
-
const accountConfig =
|
|
299
|
+
const accountConfig = create(AccountConfigSchema, {
|
|
277
300
|
address: validateAndNormalizeAddress(processor.config.address),
|
|
278
301
|
chainId: processor.getChainId().toString(),
|
|
279
302
|
startBlock: processor.config.startBlock ? BigInt(processor.config.startBlock) : 0n
|
|
@@ -282,12 +305,12 @@ export class EthPlugin extends Plugin {
|
|
|
282
305
|
for (const eventsHandler of processor.eventHandlers) {
|
|
283
306
|
// associate id with filter
|
|
284
307
|
const handlerId = this.handlerRegister.register(eventsHandler.handler, processor.getChainId())
|
|
285
|
-
const logConfig
|
|
308
|
+
const logConfig = create(LogHandlerConfigSchema, {
|
|
286
309
|
handlerId: handlerId,
|
|
287
310
|
handlerName: eventsHandler.handlerName,
|
|
288
311
|
filters: [],
|
|
289
312
|
fetchConfig: eventsHandler.fetchConfig
|
|
290
|
-
}
|
|
313
|
+
})
|
|
291
314
|
|
|
292
315
|
for (const filter of eventsHandler.filters) {
|
|
293
316
|
const topics = await filter.getTopicFilter()
|
|
@@ -296,11 +319,14 @@ export class EthPlugin extends Plugin {
|
|
|
296
319
|
if (filter.address) {
|
|
297
320
|
address = filter.address.toString()
|
|
298
321
|
}
|
|
299
|
-
const logFilter
|
|
300
|
-
|
|
301
|
-
|
|
322
|
+
const logFilter = create(LogFilterSchema, {
|
|
323
|
+
addressOrType: filter.addressType
|
|
324
|
+
? { case: 'addressType', value: filter.addressType }
|
|
325
|
+
: address
|
|
326
|
+
? { case: 'address', value: validateAndNormalizeAddress(address) }
|
|
327
|
+
: undefined,
|
|
302
328
|
topics: []
|
|
303
|
-
}
|
|
329
|
+
})
|
|
304
330
|
|
|
305
331
|
for (const ts of topics) {
|
|
306
332
|
let hashes: string[] = []
|
|
@@ -309,7 +335,7 @@ export class EthPlugin extends Plugin {
|
|
|
309
335
|
} else if (ts) {
|
|
310
336
|
hashes.push(ts)
|
|
311
337
|
}
|
|
312
|
-
logFilter.topics.push({ hashes: hashes })
|
|
338
|
+
logFilter.topics.push(create(TopicSchema, { hashes: hashes }))
|
|
313
339
|
}
|
|
314
340
|
logConfig.filters.push(logFilter)
|
|
315
341
|
}
|
|
@@ -338,7 +364,7 @@ export class EthPlugin extends Plugin {
|
|
|
338
364
|
case HandlerType.ETH_TRANSACTION:
|
|
339
365
|
return this.processTransaction(request, preparedData)
|
|
340
366
|
default:
|
|
341
|
-
throw new
|
|
367
|
+
throw new ConnectError('No handle type registered ' + request.handlerType, Code.InvalidArgument)
|
|
342
368
|
}
|
|
343
369
|
}
|
|
344
370
|
|
|
@@ -346,40 +372,40 @@ export class EthPlugin extends Plugin {
|
|
|
346
372
|
let data: any
|
|
347
373
|
switch (request.handlerType) {
|
|
348
374
|
case HandlerType.ETH_LOG:
|
|
349
|
-
if (
|
|
350
|
-
throw new
|
|
375
|
+
if (request.data?.value.case !== 'ethLog' || !request.data.value.value) {
|
|
376
|
+
throw new ConnectError("ethLog can't be empty", Code.InvalidArgument)
|
|
351
377
|
}
|
|
352
|
-
data = request.data.
|
|
378
|
+
data = request.data.value.value
|
|
353
379
|
break
|
|
354
380
|
case HandlerType.ETH_TRACE:
|
|
355
|
-
if (
|
|
356
|
-
throw new
|
|
381
|
+
if (request.data?.value.case !== 'ethTrace' || !request.data.value.value) {
|
|
382
|
+
throw new ConnectError("ethTrace can't be empty", Code.InvalidArgument)
|
|
357
383
|
}
|
|
358
|
-
data = request.data.
|
|
384
|
+
data = request.data.value.value
|
|
359
385
|
break
|
|
360
386
|
case HandlerType.ETH_BLOCK:
|
|
361
|
-
if (
|
|
362
|
-
throw new
|
|
387
|
+
if (request.data?.value.case !== 'ethBlock' || !request.data.value.value) {
|
|
388
|
+
throw new ConnectError("ethBlock can't be empty", Code.InvalidArgument)
|
|
363
389
|
}
|
|
364
|
-
data = request.data.
|
|
390
|
+
data = request.data.value.value
|
|
365
391
|
break
|
|
366
392
|
case HandlerType.ETH_TRANSACTION:
|
|
367
|
-
if (
|
|
368
|
-
throw new
|
|
393
|
+
if (request.data?.value.case !== 'ethTransaction' || !request.data.value.value) {
|
|
394
|
+
throw new ConnectError("ethTransaction can't be empty", Code.InvalidArgument)
|
|
369
395
|
}
|
|
370
|
-
data = request.data.
|
|
396
|
+
data = request.data.value.value
|
|
371
397
|
break
|
|
372
398
|
default:
|
|
373
|
-
throw new
|
|
399
|
+
throw new ConnectError('No handle type registered ' + request.handlerType, Code.InvalidArgument)
|
|
374
400
|
}
|
|
375
401
|
const partitions = await this.partitionManager.processPartitionForHandlerType(
|
|
376
402
|
request.handlerType,
|
|
377
403
|
request.handlerIds,
|
|
378
404
|
data
|
|
379
405
|
)
|
|
380
|
-
return {
|
|
406
|
+
return create(ProcessStreamResponse_PartitionsSchema, {
|
|
381
407
|
partitions
|
|
382
|
-
}
|
|
408
|
+
})
|
|
383
409
|
}
|
|
384
410
|
|
|
385
411
|
async start(request: StartRequest) {
|
|
@@ -392,10 +418,10 @@ export class EthPlugin extends Plugin {
|
|
|
392
418
|
|
|
393
419
|
const template = ProcessorTemplateProcessorState.INSTANCE.getValues()[instance.templateId]
|
|
394
420
|
if (!template) {
|
|
395
|
-
throw new
|
|
421
|
+
throw new ConnectError('Invalid template contract:' + instance, Code.InvalidArgument)
|
|
396
422
|
}
|
|
397
423
|
if (!instance.contract) {
|
|
398
|
-
throw new
|
|
424
|
+
throw new ConnectError('Contract Empty from:' + instance, Code.InvalidArgument)
|
|
399
425
|
}
|
|
400
426
|
const ctx = new NoopContext(instance.contract.chainId as EthChainId)
|
|
401
427
|
template.startInstance(
|
|
@@ -404,7 +430,7 @@ export class EthPlugin extends Plugin {
|
|
|
404
430
|
address: validateAndNormalizeAddress(instance.contract.address),
|
|
405
431
|
startBlock: instance.startBlock,
|
|
406
432
|
endBlock: instance.endBlock,
|
|
407
|
-
baseLabels: instance.baseLabels
|
|
433
|
+
baseLabels: instance.baseLabels as { [key: string]: string } | undefined
|
|
408
434
|
},
|
|
409
435
|
ctx
|
|
410
436
|
)
|
|
@@ -412,20 +438,17 @@ export class EthPlugin extends Plugin {
|
|
|
412
438
|
}
|
|
413
439
|
|
|
414
440
|
async processLog(request: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
|
|
415
|
-
if (
|
|
416
|
-
throw new
|
|
441
|
+
if (request.data?.value.case !== 'ethLog' || !request.data.value.value.rawLog) {
|
|
442
|
+
throw new ConnectError("Log can't be null", Code.InvalidArgument)
|
|
417
443
|
}
|
|
418
|
-
const ethLog = request.data.
|
|
444
|
+
const ethLog = request.data.value.value
|
|
419
445
|
|
|
420
446
|
const promises: Promise<ProcessResult>[] = []
|
|
421
447
|
for (const handlerId of request.handlerIds) {
|
|
422
448
|
const handler = this.handlerRegister.getHandlerById(request.chainId, handlerId)
|
|
423
449
|
const promise = handler(ethLog, preparedData).catch((e: any) => {
|
|
424
450
|
console.error('error processing log: ', e)
|
|
425
|
-
throw new
|
|
426
|
-
Status.INTERNAL,
|
|
427
|
-
'error processing log: ' + JSON.stringify(ethLog.log) + '\n' + errorString(e)
|
|
428
|
-
)
|
|
451
|
+
throw new ConnectError('error processing log: ' + ethLog.rawLog + '\n' + errorString(e), Code.Internal)
|
|
429
452
|
})
|
|
430
453
|
if (GLOBAL_CONFIG.execution.sequential) {
|
|
431
454
|
await promise
|
|
@@ -436,10 +459,10 @@ export class EthPlugin extends Plugin {
|
|
|
436
459
|
}
|
|
437
460
|
|
|
438
461
|
async processTrace(binding: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
|
|
439
|
-
if (
|
|
440
|
-
throw new
|
|
462
|
+
if (binding.data?.value.case !== 'ethTrace' || !binding.data.value.value.rawTrace) {
|
|
463
|
+
throw new ConnectError("Trace can't be null", Code.InvalidArgument)
|
|
441
464
|
}
|
|
442
|
-
const ethTrace = binding.data.
|
|
465
|
+
const ethTrace = binding.data.value.value
|
|
443
466
|
|
|
444
467
|
const promises: Promise<ProcessResult>[] = []
|
|
445
468
|
|
|
@@ -448,10 +471,7 @@ export class EthPlugin extends Plugin {
|
|
|
448
471
|
.getHandlerById(binding.chainId, handlerId)(ethTrace, preparedData)
|
|
449
472
|
.catch((e: any) => {
|
|
450
473
|
console.error('error processing trace: ', e)
|
|
451
|
-
throw new
|
|
452
|
-
Status.INTERNAL,
|
|
453
|
-
'error processing trace: ' + JSON.stringify(ethTrace.trace) + '\n' + errorString(e)
|
|
454
|
-
)
|
|
474
|
+
throw new ConnectError('error processing trace: ' + ethTrace.rawTrace + '\n' + errorString(e), Code.Internal)
|
|
455
475
|
})
|
|
456
476
|
if (GLOBAL_CONFIG.execution.sequential) {
|
|
457
477
|
await promise
|
|
@@ -462,10 +482,10 @@ export class EthPlugin extends Plugin {
|
|
|
462
482
|
}
|
|
463
483
|
|
|
464
484
|
async processBlock(binding: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
|
|
465
|
-
if (
|
|
466
|
-
throw new
|
|
485
|
+
if (binding.data?.value.case !== 'ethBlock' || !binding.data.value.value.rawBlock) {
|
|
486
|
+
throw new ConnectError("Block can't be empty", Code.InvalidArgument)
|
|
467
487
|
}
|
|
468
|
-
const ethBlock = binding.data.
|
|
488
|
+
const ethBlock = binding.data.value.value
|
|
469
489
|
|
|
470
490
|
const promises: Promise<ProcessResult>[] = []
|
|
471
491
|
for (const handlerId of binding.handlerIds) {
|
|
@@ -473,10 +493,7 @@ export class EthPlugin extends Plugin {
|
|
|
473
493
|
.getHandlerById(binding.chainId, handlerId)(ethBlock, preparedData)
|
|
474
494
|
.catch((e: any) => {
|
|
475
495
|
console.error('error processing block: ', e)
|
|
476
|
-
throw new
|
|
477
|
-
Status.INTERNAL,
|
|
478
|
-
'error processing block: ' + ethBlock.block?.number + '\n' + errorString(e)
|
|
479
|
-
)
|
|
496
|
+
throw new ConnectError('error processing block: ' + errorString(e), Code.Internal)
|
|
480
497
|
})
|
|
481
498
|
if (GLOBAL_CONFIG.execution.sequential) {
|
|
482
499
|
await promise
|
|
@@ -487,10 +504,10 @@ export class EthPlugin extends Plugin {
|
|
|
487
504
|
}
|
|
488
505
|
|
|
489
506
|
async processTransaction(binding: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
|
|
490
|
-
if (
|
|
491
|
-
throw new
|
|
507
|
+
if (binding.data?.value.case !== 'ethTransaction' || !binding.data.value.value.rawTransaction) {
|
|
508
|
+
throw new ConnectError("transaction can't be null", Code.InvalidArgument)
|
|
492
509
|
}
|
|
493
|
-
const ethTransaction = binding.data.
|
|
510
|
+
const ethTransaction = binding.data.value.value
|
|
494
511
|
|
|
495
512
|
const promises: Promise<ProcessResult>[] = []
|
|
496
513
|
|
|
@@ -498,9 +515,9 @@ export class EthPlugin extends Plugin {
|
|
|
498
515
|
const promise = this.handlerRegister
|
|
499
516
|
.getHandlerById(binding.chainId, handlerId)(ethTransaction, preparedData)
|
|
500
517
|
.catch((e: any) => {
|
|
501
|
-
throw new
|
|
502
|
-
|
|
503
|
-
|
|
518
|
+
throw new ConnectError(
|
|
519
|
+
'error processing transaction: ' + ethTransaction.rawTransaction + '\n' + errorString(e),
|
|
520
|
+
Code.Internal
|
|
504
521
|
)
|
|
505
522
|
})
|
|
506
523
|
if (GLOBAL_CONFIG.execution.sequential) {
|
|
@@ -525,7 +542,7 @@ class NoopContext extends EthContext {
|
|
|
525
542
|
}
|
|
526
543
|
|
|
527
544
|
function mergePreprocessResults(results: PreprocessResult[]): PreprocessResult {
|
|
528
|
-
const res
|
|
545
|
+
const res = create(PreprocessResultSchema, { ethCallParams: [] })
|
|
529
546
|
for (const r of results) {
|
|
530
547
|
res.ethCallParams = res.ethCallParams.concat(r.ethCallParams)
|
|
531
548
|
}
|