@sentio/sdk 3.9.0-rc.9 → 4.0.0-rc.2
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 +4 -4
- 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 +14 -8
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +3 -3
- 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 +12 -10
- 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 +22 -14
- 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 +9 -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 +3 -3
- package/lib/iota/iota-processor.d.ts.map +1 -1
- package/lib/iota/iota-processor.js +20 -19
- 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/codegen/codegen.d.ts +1 -1
- package/lib/solana/codegen/codegen.d.ts.map +1 -1
- package/lib/solana/codegen/codegen.js +2 -2
- package/lib/solana/codegen/codegen.js.map +1 -1
- 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 +2 -2
- 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/codegen.js +2 -2
- package/lib/store/codegen.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 +3 -3
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +20 -19
- 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 +1 -1
- package/lib/testing/memory-database.d.ts.map +1 -1
- package/lib/testing/memory-database.js +82 -69
- 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 +19 -13
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +22 -20
- 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 +10 -12
- package/src/aptos/aptos-plugin.ts +105 -91
- package/src/aptos/aptos-processor.ts +42 -34
- 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 +27 -11
- package/src/eth/base-processor.ts +77 -65
- 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 +18 -11
- package/src/eth/eth-plugin.ts +135 -118
- package/src/eth/eth.ts +29 -20
- 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 +10 -7
- 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 +35 -27
- package/src/iota/network.ts +2 -2
- package/src/move/filter.ts +1 -1
- package/src/move/index.ts +1 -1
- package/src/solana/codegen/codegen.ts +2 -2
- package/src/solana/solana-context.ts +4 -3
- package/src/solana/solana-plugin.ts +27 -24
- package/src/solana/solana-processor.ts +23 -11
- package/src/store/cache.ts +22 -18
- package/src/store/codegen.ts +2 -2
- package/src/store/convert.ts +68 -104
- package/src/store/decorators.ts +3 -2
- package/src/store/store.ts +31 -23
- 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 +35 -27
- 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 +109 -82
- 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 +64 -58
- package/src/utils/price.ts +20 -13
|
@@ -3,19 +3,25 @@ import { BaseContract, DeferredTopicFilter, LogDescription, LogParams, Transacti
|
|
|
3
3
|
import { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'
|
|
4
4
|
import {
|
|
5
5
|
AddressType,
|
|
6
|
-
Data_EthBlock,
|
|
7
|
-
Data_EthLog,
|
|
8
|
-
Data_EthTrace,
|
|
9
|
-
Data_EthTransaction,
|
|
10
|
-
EthFetchConfig,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
type Data_EthBlock,
|
|
7
|
+
type Data_EthLog,
|
|
8
|
+
type Data_EthTrace,
|
|
9
|
+
type Data_EthTransaction,
|
|
10
|
+
type EthFetchConfig,
|
|
11
|
+
EthFetchConfigSchema,
|
|
12
|
+
type HandleInterval,
|
|
13
|
+
HandleIntervalSchema,
|
|
14
|
+
type PreparedData,
|
|
15
|
+
type PreprocessResult,
|
|
16
|
+
PreprocessResultSchema,
|
|
17
|
+
type ProcessResult,
|
|
18
|
+
ProcessResultSchema,
|
|
19
|
+
timestampDate
|
|
15
20
|
} from '@sentio/protos'
|
|
21
|
+
import { create } from '@bufbuild/protobuf'
|
|
22
|
+
import { ConnectError, Code } from '@connectrpc/connect'
|
|
16
23
|
import { BindOptions, TimeOrBlock } from './bind-options.js'
|
|
17
24
|
import { PromiseOrVoid } from '../core/promises.js'
|
|
18
|
-
import { ServerError, Status } from 'nice-grpc'
|
|
19
25
|
import {
|
|
20
26
|
fixEmptyKey,
|
|
21
27
|
formatEthData,
|
|
@@ -38,7 +44,7 @@ export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
|
|
38
44
|
address?: string
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
export const defaultPreprocessHandler = () => (
|
|
47
|
+
export const defaultPreprocessHandler = () => create(PreprocessResultSchema, { ethCallParams: [] }) as any
|
|
42
48
|
|
|
43
49
|
export class EventsHandler {
|
|
44
50
|
filters: AddressOrTypeEventFilter[]
|
|
@@ -142,10 +148,10 @@ export class GlobalProcessor {
|
|
|
142
148
|
return this.onInterval(
|
|
143
149
|
handler,
|
|
144
150
|
undefined,
|
|
145
|
-
{
|
|
151
|
+
create(HandleIntervalSchema, {
|
|
146
152
|
recentInterval: blockInterval,
|
|
147
153
|
backfillInterval: backfillBlockInterval
|
|
148
|
-
},
|
|
154
|
+
}),
|
|
149
155
|
handlerOptions,
|
|
150
156
|
preprocessHandler
|
|
151
157
|
)
|
|
@@ -166,7 +172,10 @@ export class GlobalProcessor {
|
|
|
166
172
|
): this {
|
|
167
173
|
return this.onInterval(
|
|
168
174
|
handler,
|
|
169
|
-
|
|
175
|
+
create(HandleIntervalSchema, {
|
|
176
|
+
recentInterval: timeIntervalInMinutes,
|
|
177
|
+
backfillInterval: backfillTimeIntervalInMinutes
|
|
178
|
+
}),
|
|
170
179
|
undefined,
|
|
171
180
|
handlerOptions,
|
|
172
181
|
preprocessHandler
|
|
@@ -204,7 +213,7 @@ export class GlobalProcessor {
|
|
|
204
213
|
const { block } = formatEthData(data)
|
|
205
214
|
|
|
206
215
|
if (!block) {
|
|
207
|
-
throw new
|
|
216
|
+
throw new ConnectError('Block is empty', Code.InvalidArgument)
|
|
208
217
|
}
|
|
209
218
|
|
|
210
219
|
const ctx = new GlobalContext(
|
|
@@ -225,7 +234,7 @@ export class GlobalProcessor {
|
|
|
225
234
|
const { block } = formatEthData(data)
|
|
226
235
|
|
|
227
236
|
if (!block) {
|
|
228
|
-
throw new
|
|
237
|
+
throw new ConnectError('Block is empty', Code.InvalidArgument)
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
const ctx = new GlobalContext(
|
|
@@ -243,7 +252,7 @@ export class GlobalProcessor {
|
|
|
243
252
|
},
|
|
244
253
|
timeIntervalInMinutes: timeInterval,
|
|
245
254
|
blockInterval: blockInterval,
|
|
246
|
-
fetchConfig:
|
|
255
|
+
fetchConfig: create(EthFetchConfigSchema, handlerOptions || {}),
|
|
247
256
|
partitionHandler: async (data: Data_EthBlock): Promise<string | undefined> => {
|
|
248
257
|
const p = handlerOptions?.partitionKey
|
|
249
258
|
if (!p) return undefined
|
|
@@ -278,7 +287,7 @@ export class GlobalProcessor {
|
|
|
278
287
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
|
279
288
|
|
|
280
289
|
if (!transaction) {
|
|
281
|
-
throw new
|
|
290
|
+
throw new ConnectError('transaction is empty', Code.InvalidArgument)
|
|
282
291
|
}
|
|
283
292
|
let to = transaction.to
|
|
284
293
|
if (to === trace?.action.from) {
|
|
@@ -287,7 +296,7 @@ export class GlobalProcessor {
|
|
|
287
296
|
const ctx = new GlobalContext(
|
|
288
297
|
chainId,
|
|
289
298
|
to || '*',
|
|
290
|
-
data.timestamp,
|
|
299
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
291
300
|
block,
|
|
292
301
|
undefined,
|
|
293
302
|
trace,
|
|
@@ -302,7 +311,7 @@ export class GlobalProcessor {
|
|
|
302
311
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
|
303
312
|
|
|
304
313
|
if (!transaction) {
|
|
305
|
-
throw new
|
|
314
|
+
throw new ConnectError('transaction is empty', Code.InvalidArgument)
|
|
306
315
|
}
|
|
307
316
|
let to = transaction.to
|
|
308
317
|
if (to === trace?.action.from) {
|
|
@@ -311,7 +320,7 @@ export class GlobalProcessor {
|
|
|
311
320
|
const ctx = new GlobalContext(
|
|
312
321
|
chainId,
|
|
313
322
|
to || '*',
|
|
314
|
-
data.timestamp,
|
|
323
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
315
324
|
block,
|
|
316
325
|
undefined,
|
|
317
326
|
trace,
|
|
@@ -321,7 +330,7 @@ export class GlobalProcessor {
|
|
|
321
330
|
)
|
|
322
331
|
return preprocessHandler(transaction, ctx, preprocessStore)
|
|
323
332
|
},
|
|
324
|
-
fetchConfig:
|
|
333
|
+
fetchConfig: create(EthFetchConfigSchema, handlerOptions || {}),
|
|
325
334
|
partitionHandler: async (data: Data_EthTransaction): Promise<string | undefined> => {
|
|
326
335
|
const p = handlerOptions?.partitionKey
|
|
327
336
|
if (!p) return undefined
|
|
@@ -351,17 +360,17 @@ export class GlobalProcessor {
|
|
|
351
360
|
|
|
352
361
|
this.eventHandlers.push({
|
|
353
362
|
filters: _filters,
|
|
354
|
-
fetchConfig:
|
|
363
|
+
fetchConfig: create(EthFetchConfigSchema, handlerOptions || {}),
|
|
355
364
|
handlerName: getHandlerName(),
|
|
356
365
|
handler: async function (data) {
|
|
357
366
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
|
358
367
|
if (!log) {
|
|
359
|
-
throw new
|
|
368
|
+
throw new ConnectError('Log is empty', Code.InvalidArgument)
|
|
360
369
|
}
|
|
361
370
|
const ctx = new GlobalContext(
|
|
362
371
|
chainId,
|
|
363
372
|
transaction?.to || '*',
|
|
364
|
-
data.timestamp,
|
|
373
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
365
374
|
block,
|
|
366
375
|
log,
|
|
367
376
|
undefined,
|
|
@@ -402,18 +411,18 @@ export class GlobalProcessor {
|
|
|
402
411
|
|
|
403
412
|
this.traceHandlers.push({
|
|
404
413
|
signatures,
|
|
405
|
-
fetchConfig:
|
|
414
|
+
fetchConfig: create(EthFetchConfigSchema, handlerOptions || {}),
|
|
406
415
|
handlerName: getHandlerName(),
|
|
407
416
|
handler: async function (data: Data_EthTrace) {
|
|
408
417
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
|
409
418
|
|
|
410
419
|
if (!trace) {
|
|
411
|
-
throw new
|
|
420
|
+
throw new ConnectError('trace is null', Code.InvalidArgument)
|
|
412
421
|
}
|
|
413
422
|
const ctx = new GlobalContext(
|
|
414
423
|
chainId,
|
|
415
424
|
trace.action.to || '*',
|
|
416
|
-
data.timestamp,
|
|
425
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
417
426
|
block,
|
|
418
427
|
undefined,
|
|
419
428
|
trace,
|
|
@@ -428,12 +437,12 @@ export class GlobalProcessor {
|
|
|
428
437
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
|
429
438
|
|
|
430
439
|
if (!trace) {
|
|
431
|
-
throw new
|
|
440
|
+
throw new ConnectError('trace is null', Code.InvalidArgument)
|
|
432
441
|
}
|
|
433
442
|
const ctx = new GlobalContext(
|
|
434
443
|
chainId,
|
|
435
444
|
trace.action.to || '*',
|
|
436
|
-
data.timestamp,
|
|
445
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
437
446
|
block,
|
|
438
447
|
undefined,
|
|
439
448
|
trace,
|
|
@@ -499,11 +508,11 @@ export abstract class BaseProcessor<
|
|
|
499
508
|
return this.config.network
|
|
500
509
|
}
|
|
501
510
|
|
|
502
|
-
public onEvent(
|
|
503
|
-
handler: (event:
|
|
504
|
-
handlerOptions?: HandlerOptions<EthFetchConfig,
|
|
511
|
+
public onEvent<T extends TypedEvent = TypedEvent>(
|
|
512
|
+
handler: (event: T, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
513
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, T>,
|
|
505
514
|
preprocessHandler: (
|
|
506
|
-
event:
|
|
515
|
+
event: T,
|
|
507
516
|
ctx: ContractContext<TContract, TBoundContractView>,
|
|
508
517
|
preprocessStore: { [k: string]: any }
|
|
509
518
|
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
|
@@ -520,12 +529,12 @@ export abstract class BaseProcessor<
|
|
|
520
529
|
return this.onEthEvent(handler, _filters, handlerOptions, preprocessHandler)
|
|
521
530
|
}
|
|
522
531
|
|
|
523
|
-
protected onEthEvent(
|
|
524
|
-
handler: (event:
|
|
532
|
+
protected onEthEvent<T extends TypedEvent | RawEvent = TypedEvent | RawEvent>(
|
|
533
|
+
handler: (event: T, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
|
525
534
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
|
526
|
-
handlerOptions?: HandlerOptions<EthFetchConfig,
|
|
535
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, T>,
|
|
527
536
|
preprocessHandler: (
|
|
528
|
-
event:
|
|
537
|
+
event: T,
|
|
529
538
|
ctx: ContractContext<TContract, TBoundContractView>,
|
|
530
539
|
preprocessStore: { [k: string]: any }
|
|
531
540
|
) => Promise<PreprocessResult> = defaultPreprocessHandler,
|
|
@@ -544,12 +553,12 @@ export abstract class BaseProcessor<
|
|
|
544
553
|
const processor = this
|
|
545
554
|
this.eventHandlers.push({
|
|
546
555
|
filters: _filters,
|
|
547
|
-
fetchConfig:
|
|
556
|
+
fetchConfig: create(EthFetchConfigSchema, handlerOptions || {}),
|
|
548
557
|
handlerName,
|
|
549
558
|
handler: async function (data: Data_EthLog, preparedData?: PreparedData) {
|
|
550
559
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
|
551
560
|
if (!log) {
|
|
552
|
-
throw new
|
|
561
|
+
throw new ConnectError('Log is empty', Code.InvalidArgument)
|
|
553
562
|
}
|
|
554
563
|
let contractView
|
|
555
564
|
try {
|
|
@@ -565,7 +574,7 @@ export abstract class BaseProcessor<
|
|
|
565
574
|
contractName,
|
|
566
575
|
contractView,
|
|
567
576
|
chainId,
|
|
568
|
-
data.timestamp,
|
|
577
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
569
578
|
block,
|
|
570
579
|
log,
|
|
571
580
|
undefined,
|
|
@@ -586,17 +595,17 @@ export abstract class BaseProcessor<
|
|
|
586
595
|
if (e instanceof Error) {
|
|
587
596
|
if (e.message.includes('data out-of-bounds')) {
|
|
588
597
|
console.error("Can't decode", log, 'may because of incompatible ABIs, e.g. string vs indexed string', e)
|
|
589
|
-
return
|
|
598
|
+
return create(ProcessResultSchema)
|
|
590
599
|
}
|
|
591
600
|
}
|
|
592
601
|
throw e
|
|
593
602
|
}
|
|
594
603
|
if (parsed) {
|
|
595
604
|
const event: TypedEvent = new TypedEvent(log, parsed.name, fixEmptyKey(parsed))
|
|
596
|
-
await handler(event, ctx)
|
|
605
|
+
await handler(event as T, ctx)
|
|
597
606
|
return ctx.stopAndGetResult()
|
|
598
607
|
}
|
|
599
|
-
return
|
|
608
|
+
return create(ProcessResultSchema)
|
|
600
609
|
},
|
|
601
610
|
preprocessHandler: async function (
|
|
602
611
|
data: Data_EthLog,
|
|
@@ -604,7 +613,7 @@ export abstract class BaseProcessor<
|
|
|
604
613
|
): Promise<PreprocessResult> {
|
|
605
614
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
|
606
615
|
if (!log) {
|
|
607
|
-
throw new
|
|
616
|
+
throw new ConnectError('Log is empty', Code.InvalidArgument)
|
|
608
617
|
}
|
|
609
618
|
let contractView
|
|
610
619
|
try {
|
|
@@ -621,7 +630,7 @@ export abstract class BaseProcessor<
|
|
|
621
630
|
contractName,
|
|
622
631
|
contractView,
|
|
623
632
|
chainId,
|
|
624
|
-
data.timestamp,
|
|
633
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
625
634
|
block,
|
|
626
635
|
log,
|
|
627
636
|
undefined,
|
|
@@ -638,16 +647,16 @@ export abstract class BaseProcessor<
|
|
|
638
647
|
if (e instanceof Error) {
|
|
639
648
|
if (e.message.includes('data out-of-bounds')) {
|
|
640
649
|
console.error("Can't decode", log, 'may because of incompatible ABIs, e.g. string vs indexed string', e)
|
|
641
|
-
return
|
|
650
|
+
return create(PreprocessResultSchema)
|
|
642
651
|
}
|
|
643
652
|
}
|
|
644
653
|
throw e
|
|
645
654
|
}
|
|
646
655
|
if (parsed) {
|
|
647
656
|
const event: TypedEvent = new TypedEvent(log, parsed.name, fixEmptyKey(parsed))
|
|
648
|
-
return preprocessHandler(event, ctx, preprocessStore)
|
|
657
|
+
return preprocessHandler(event as T, ctx, preprocessStore)
|
|
649
658
|
}
|
|
650
|
-
return
|
|
659
|
+
return create(PreprocessResultSchema)
|
|
651
660
|
},
|
|
652
661
|
partitionHandler: async (data: Data_EthLog): Promise<string | undefined> => {
|
|
653
662
|
const p = handlerOptions?.partitionKey
|
|
@@ -663,7 +672,7 @@ export abstract class BaseProcessor<
|
|
|
663
672
|
}
|
|
664
673
|
if (parsed) {
|
|
665
674
|
const event: TypedEvent = new TypedEvent(log, parsed.name, fixEmptyKey(parsed))
|
|
666
|
-
return p(event)
|
|
675
|
+
return p(event as T)
|
|
667
676
|
}
|
|
668
677
|
return undefined
|
|
669
678
|
}
|
|
@@ -687,10 +696,10 @@ export abstract class BaseProcessor<
|
|
|
687
696
|
return this.onInterval(
|
|
688
697
|
handler,
|
|
689
698
|
undefined,
|
|
690
|
-
{
|
|
699
|
+
create(HandleIntervalSchema, {
|
|
691
700
|
recentInterval: blockInterval,
|
|
692
701
|
backfillInterval: backfillBlockInterval
|
|
693
|
-
},
|
|
702
|
+
}),
|
|
694
703
|
handlerOptions,
|
|
695
704
|
preprocessHandler
|
|
696
705
|
)
|
|
@@ -709,7 +718,10 @@ export abstract class BaseProcessor<
|
|
|
709
718
|
): this {
|
|
710
719
|
return this.onInterval(
|
|
711
720
|
handler,
|
|
712
|
-
|
|
721
|
+
create(HandleIntervalSchema, {
|
|
722
|
+
recentInterval: timeIntervalInMinutes,
|
|
723
|
+
backfillInterval: backfillTimeIntervalInMinutes
|
|
724
|
+
}),
|
|
713
725
|
undefined,
|
|
714
726
|
handlerOptions,
|
|
715
727
|
preprocessHandler
|
|
@@ -738,7 +750,7 @@ export abstract class BaseProcessor<
|
|
|
738
750
|
const { block } = formatEthData(data)
|
|
739
751
|
|
|
740
752
|
if (!block) {
|
|
741
|
-
throw new
|
|
753
|
+
throw new ConnectError('Block is empty', Code.InvalidArgument)
|
|
742
754
|
}
|
|
743
755
|
|
|
744
756
|
const contractView = processor.CreateBoundContractView()
|
|
@@ -763,7 +775,7 @@ export abstract class BaseProcessor<
|
|
|
763
775
|
const { block } = formatEthData(data)
|
|
764
776
|
|
|
765
777
|
if (!block) {
|
|
766
|
-
throw new
|
|
778
|
+
throw new ConnectError('Block is empty', Code.InvalidArgument)
|
|
767
779
|
}
|
|
768
780
|
|
|
769
781
|
const contractView = processor.CreateBoundContractView()
|
|
@@ -784,7 +796,7 @@ export abstract class BaseProcessor<
|
|
|
784
796
|
},
|
|
785
797
|
timeIntervalInMinutes: timeInterval,
|
|
786
798
|
blockInterval: blockInterval,
|
|
787
|
-
fetchConfig:
|
|
799
|
+
fetchConfig: create(EthFetchConfigSchema, handlerOptions || {}),
|
|
788
800
|
partitionHandler: async (data: Data_EthBlock): Promise<string | undefined> => {
|
|
789
801
|
const p = handlerOptions?.partitionKey
|
|
790
802
|
if (!p) return undefined
|
|
@@ -819,7 +831,7 @@ export abstract class BaseProcessor<
|
|
|
819
831
|
|
|
820
832
|
this.traceHandlers.push({
|
|
821
833
|
signatures,
|
|
822
|
-
fetchConfig:
|
|
834
|
+
fetchConfig: create(EthFetchConfigSchema, handlerOptions || {}),
|
|
823
835
|
handlerName,
|
|
824
836
|
handler: async function (data: Data_EthTrace, preparedData?: PreparedData) {
|
|
825
837
|
const contractView = processor.CreateBoundContractView()
|
|
@@ -827,19 +839,19 @@ export abstract class BaseProcessor<
|
|
|
827
839
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
|
828
840
|
const sighash = trace?.action.input?.slice(0, 10)
|
|
829
841
|
if (!sighash) {
|
|
830
|
-
throw new
|
|
842
|
+
throw new ConnectError('trace has no sighash', Code.InvalidArgument)
|
|
831
843
|
}
|
|
832
844
|
const fragment = contractInterface.getFunction(sighash)
|
|
833
845
|
|
|
834
846
|
if (!trace || !fragment) {
|
|
835
|
-
throw new
|
|
847
|
+
throw new ConnectError('trace is null', Code.InvalidArgument)
|
|
836
848
|
}
|
|
837
849
|
const typedTrace = trace as TypedCallTrace
|
|
838
850
|
typedTrace.name = fragment.name
|
|
839
851
|
typedTrace.functionSignature = fragment.format()
|
|
840
852
|
// const trace = data.trace as Trace
|
|
841
853
|
if (!trace?.action.input) {
|
|
842
|
-
return
|
|
854
|
+
return create(ProcessResultSchema)
|
|
843
855
|
}
|
|
844
856
|
const traceData = '0x' + trace.action.input.slice(10)
|
|
845
857
|
try {
|
|
@@ -855,7 +867,7 @@ export abstract class BaseProcessor<
|
|
|
855
867
|
contractName,
|
|
856
868
|
contractView,
|
|
857
869
|
chainId,
|
|
858
|
-
data.timestamp,
|
|
870
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
859
871
|
block,
|
|
860
872
|
undefined,
|
|
861
873
|
trace,
|
|
@@ -873,19 +885,19 @@ export abstract class BaseProcessor<
|
|
|
873
885
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
|
874
886
|
const sighash = trace?.action.input?.slice(0, 10)
|
|
875
887
|
if (!sighash) {
|
|
876
|
-
throw new
|
|
888
|
+
throw new ConnectError('trace has no sighash', Code.InvalidArgument)
|
|
877
889
|
}
|
|
878
890
|
const fragment = contractInterface.getFunction(sighash)
|
|
879
891
|
|
|
880
892
|
if (!trace || !fragment) {
|
|
881
|
-
throw new
|
|
893
|
+
throw new ConnectError('trace is null', Code.InvalidArgument)
|
|
882
894
|
}
|
|
883
895
|
const typedTrace = trace as TypedCallTrace
|
|
884
896
|
typedTrace.name = fragment.name
|
|
885
897
|
typedTrace.functionSignature = fragment.format()
|
|
886
898
|
// const trace = data.trace as Trace
|
|
887
899
|
if (!trace?.action.input) {
|
|
888
|
-
return
|
|
900
|
+
return create(PreprocessResultSchema)
|
|
889
901
|
}
|
|
890
902
|
const traceData = '0x' + trace.action.input.slice(10)
|
|
891
903
|
try {
|
|
@@ -900,7 +912,7 @@ export abstract class BaseProcessor<
|
|
|
900
912
|
contractName,
|
|
901
913
|
contractView,
|
|
902
914
|
chainId,
|
|
903
|
-
data.timestamp,
|
|
915
|
+
data.timestamp ? timestampDate(data.timestamp) : undefined,
|
|
904
916
|
block,
|
|
905
917
|
undefined,
|
|
906
918
|
trace,
|