envio 3.0.0-alpha.21 → 3.0.0-alpha.23
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/README.md +3 -3
- package/bin.mjs +2 -48
- package/evm.schema.json +67 -0
- package/fuel.schema.json +67 -0
- package/index.d.ts +822 -38
- package/index.js +5 -3
- package/package.json +10 -8
- package/rescript.json +5 -9
- package/src/Address.res +4 -5
- package/src/Address.res.mjs +9 -12
- package/src/Api.res +15 -0
- package/src/Api.res.mjs +20 -0
- package/src/Batch.res +32 -34
- package/src/Batch.res.mjs +172 -187
- package/src/Bin.res +89 -0
- package/src/Bin.res.mjs +97 -0
- package/src/ChainFetcher.res +33 -57
- package/src/ChainFetcher.res.mjs +197 -227
- package/src/ChainManager.res +6 -14
- package/src/ChainManager.res.mjs +74 -85
- package/src/ChainMap.res +14 -16
- package/src/ChainMap.res.mjs +38 -38
- package/src/Config.res +193 -135
- package/src/Config.res.mjs +566 -592
- package/src/Core.res +182 -0
- package/src/Core.res.mjs +207 -0
- package/src/Ecosystem.res +25 -4
- package/src/Ecosystem.res.mjs +12 -13
- package/src/Env.res +20 -13
- package/src/Env.res.mjs +124 -113
- package/src/EnvSafe.res +269 -0
- package/src/EnvSafe.res.mjs +296 -0
- package/src/EnvSafe.resi +18 -0
- package/src/Envio.res +37 -26
- package/src/Envio.res.mjs +59 -60
- package/src/ErrorHandling.res +2 -2
- package/src/ErrorHandling.res.mjs +15 -15
- package/src/EventConfigBuilder.res +219 -81
- package/src/EventConfigBuilder.res.mjs +259 -202
- package/src/EventProcessing.res +27 -38
- package/src/EventProcessing.res.mjs +165 -183
- package/src/EventUtils.res +11 -11
- package/src/EventUtils.res.mjs +21 -22
- package/src/EvmTypes.res +0 -1
- package/src/EvmTypes.res.mjs +5 -5
- package/src/FetchState.res +360 -256
- package/src/FetchState.res.mjs +958 -914
- package/src/GlobalState.res +365 -351
- package/src/GlobalState.res.mjs +958 -992
- package/src/GlobalStateManager.res +1 -2
- package/src/GlobalStateManager.res.mjs +36 -44
- package/src/HandlerLoader.res +107 -23
- package/src/HandlerLoader.res.mjs +128 -38
- package/src/HandlerRegister.res +127 -103
- package/src/HandlerRegister.res.mjs +164 -164
- package/src/HandlerRegister.resi +12 -4
- package/src/Hasura.res +35 -22
- package/src/Hasura.res.mjs +158 -167
- package/src/InMemoryStore.res +20 -27
- package/src/InMemoryStore.res.mjs +64 -80
- package/src/InMemoryTable.res +34 -39
- package/src/InMemoryTable.res.mjs +165 -170
- package/src/Internal.res +52 -33
- package/src/Internal.res.mjs +84 -81
- package/src/LazyLoader.res.mjs +55 -61
- package/src/LoadLayer.res +77 -78
- package/src/LoadLayer.res.mjs +160 -189
- package/src/LoadManager.res +16 -21
- package/src/LoadManager.res.mjs +79 -84
- package/src/LogSelection.res +236 -68
- package/src/LogSelection.res.mjs +211 -141
- package/src/Logging.res +13 -9
- package/src/Logging.res.mjs +130 -143
- package/src/Main.res +430 -51
- package/src/Main.res.mjs +530 -271
- package/src/Persistence.res +80 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +294 -167
- package/src/PgStorage.res.mjs +799 -817
- package/src/Prometheus.res +50 -58
- package/src/Prometheus.res.mjs +345 -373
- package/src/ReorgDetection.res +22 -24
- package/src/ReorgDetection.res.mjs +100 -106
- package/src/SafeCheckpointTracking.res +7 -7
- package/src/SafeCheckpointTracking.res.mjs +40 -43
- package/src/SimulateItems.res +41 -49
- package/src/SimulateItems.res.mjs +257 -272
- package/src/Sink.res +2 -2
- package/src/Sink.res.mjs +22 -26
- package/src/TableIndices.res +1 -2
- package/src/TableIndices.res.mjs +42 -48
- package/src/TestIndexer.res +196 -189
- package/src/TestIndexer.res.mjs +536 -536
- package/src/TestIndexerProxyStorage.res +16 -16
- package/src/TestIndexerProxyStorage.res.mjs +99 -122
- package/src/TestIndexerWorker.res +4 -0
- package/src/TestIndexerWorker.res.mjs +7 -0
- package/src/Throttler.res +3 -3
- package/src/Throttler.res.mjs +23 -24
- package/src/Time.res +1 -1
- package/src/Time.res.mjs +18 -21
- package/src/TopicFilter.res +3 -3
- package/src/TopicFilter.res.mjs +29 -30
- package/src/UserContext.res +93 -54
- package/src/UserContext.res.mjs +197 -182
- package/src/Utils.res +141 -86
- package/src/Utils.res.mjs +334 -295
- package/src/bindings/BigDecimal.res +0 -2
- package/src/bindings/BigDecimal.res.mjs +19 -23
- package/src/bindings/ClickHouse.res +28 -27
- package/src/bindings/ClickHouse.res.mjs +243 -240
- package/src/bindings/DateFns.res +11 -11
- package/src/bindings/DateFns.res.mjs +7 -7
- package/src/bindings/EventSource.res.mjs +2 -2
- package/src/bindings/Express.res +2 -5
- package/src/bindings/Hrtime.res +2 -2
- package/src/bindings/Hrtime.res.mjs +30 -32
- package/src/bindings/Lodash.res.mjs +1 -1
- package/src/bindings/NodeJs.res +14 -9
- package/src/bindings/NodeJs.res.mjs +20 -20
- package/src/bindings/Pino.res +8 -10
- package/src/bindings/Pino.res.mjs +40 -43
- package/src/bindings/Postgres.res +7 -5
- package/src/bindings/Postgres.res.mjs +9 -9
- package/src/bindings/PromClient.res +17 -2
- package/src/bindings/PromClient.res.mjs +30 -7
- package/src/bindings/SDSL.res.mjs +2 -2
- package/src/bindings/Viem.res +4 -4
- package/src/bindings/Viem.res.mjs +20 -22
- package/src/bindings/Vitest.res +1 -1
- package/src/bindings/Vitest.res.mjs +2 -2
- package/src/bindings/WebSocket.res +1 -1
- package/src/db/EntityHistory.res +9 -3
- package/src/db/EntityHistory.res.mjs +84 -59
- package/src/db/InternalTable.res +62 -60
- package/src/db/InternalTable.res.mjs +271 -203
- package/src/db/Schema.res +1 -2
- package/src/db/Schema.res.mjs +28 -32
- package/src/db/Table.res +28 -27
- package/src/db/Table.res.mjs +276 -292
- package/src/sources/EventRouter.res +21 -16
- package/src/sources/EventRouter.res.mjs +55 -57
- package/src/sources/Evm.res +17 -1
- package/src/sources/Evm.res.mjs +16 -8
- package/src/sources/EvmChain.res +15 -17
- package/src/sources/EvmChain.res.mjs +40 -42
- package/src/sources/Fuel.res +14 -1
- package/src/sources/Fuel.res.mjs +16 -8
- package/src/sources/FuelSDK.res +1 -1
- package/src/sources/FuelSDK.res.mjs +6 -8
- package/src/sources/HyperFuel.res +8 -10
- package/src/sources/HyperFuel.res.mjs +113 -123
- package/src/sources/HyperFuelClient.res.mjs +6 -7
- package/src/sources/HyperFuelSource.res +19 -20
- package/src/sources/HyperFuelSource.res.mjs +339 -356
- package/src/sources/HyperSync.res +11 -13
- package/src/sources/HyperSync.res.mjs +206 -220
- package/src/sources/HyperSyncClient.res +5 -7
- package/src/sources/HyperSyncClient.res.mjs +70 -75
- package/src/sources/HyperSyncHeightStream.res +8 -9
- package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
- package/src/sources/HyperSyncJsonApi.res +18 -15
- package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
- package/src/sources/HyperSyncSource.res +17 -21
- package/src/sources/HyperSyncSource.res.mjs +268 -290
- package/src/sources/Rpc.res +5 -5
- package/src/sources/Rpc.res.mjs +168 -192
- package/src/sources/RpcSource.res +166 -167
- package/src/sources/RpcSource.res.mjs +972 -1046
- package/src/sources/RpcWebSocketHeightStream.res +10 -11
- package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
- package/src/sources/SimulateSource.res +1 -1
- package/src/sources/SimulateSource.res.mjs +35 -38
- package/src/sources/Source.res +1 -1
- package/src/sources/Source.res.mjs +3 -3
- package/src/sources/SourceManager.res +39 -20
- package/src/sources/SourceManager.res.mjs +340 -371
- package/src/sources/SourceManager.resi +2 -1
- package/src/sources/Svm.res +12 -5
- package/src/sources/Svm.res.mjs +44 -41
- package/src/tui/Tui.res +23 -12
- package/src/tui/Tui.res.mjs +292 -290
- package/src/tui/bindings/Ink.res +2 -4
- package/src/tui/bindings/Ink.res.mjs +35 -41
- package/src/tui/components/BufferedProgressBar.res +7 -7
- package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
- package/src/tui/components/CustomHooks.res +1 -2
- package/src/tui/components/CustomHooks.res.mjs +102 -122
- package/src/tui/components/Messages.res +1 -2
- package/src/tui/components/Messages.res.mjs +38 -42
- package/src/tui/components/SyncETA.res +10 -11
- package/src/tui/components/SyncETA.res.mjs +178 -196
- package/src/tui/components/TuiData.res +1 -1
- package/src/tui/components/TuiData.res.mjs +7 -6
- package/src/vendored/Rest.res +52 -66
- package/src/vendored/Rest.res.mjs +324 -364
- package/svm.schema.json +67 -0
- package/src/Address.gen.ts +0 -8
- package/src/Config.gen.ts +0 -19
- package/src/Envio.gen.ts +0 -55
- package/src/EvmTypes.gen.ts +0 -6
- package/src/InMemoryStore.gen.ts +0 -6
- package/src/Internal.gen.ts +0 -64
- package/src/PgStorage.gen.ts +0 -10
- package/src/PgStorage.res.d.mts +0 -5
- package/src/Types.ts +0 -56
- package/src/bindings/BigDecimal.gen.ts +0 -14
- package/src/bindings/BigDecimal.res.d.mts +0 -5
- package/src/bindings/BigInt.gen.ts +0 -10
- package/src/bindings/BigInt.res +0 -70
- package/src/bindings/BigInt.res.d.mts +0 -5
- package/src/bindings/BigInt.res.mjs +0 -154
- package/src/bindings/Ethers.res.d.mts +0 -5
- package/src/bindings/Pino.gen.ts +0 -17
- package/src/bindings/Postgres.gen.ts +0 -8
- package/src/bindings/Postgres.res.d.mts +0 -5
- package/src/bindings/Promise.res +0 -67
- package/src/bindings/Promise.res.mjs +0 -26
- package/src/db/InternalTable.gen.ts +0 -36
- package/src/sources/HyperSyncClient.gen.ts +0 -19
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
open Belt
|
|
2
1
|
open Source
|
|
3
2
|
|
|
4
3
|
exception QueryTimout(string)
|
|
@@ -13,21 +12,22 @@ type blockInfo = {
|
|
|
13
12
|
let getKnownRawBlock = async (~client, ~blockNumber) =>
|
|
14
13
|
switch await Rpc.getRawBlock(~client, ~blockNumber) {
|
|
15
14
|
| Some(json) => json
|
|
16
|
-
| None =>
|
|
15
|
+
| None =>
|
|
16
|
+
JsError.throwWithMessage(`RPC returned null for blockNumber ${blockNumber->Belt.Int.toString}`)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Extract infrastructure fields (number, timestamp, hash) from raw block JSON
|
|
20
|
-
let parseBlockInfo = (json:
|
|
21
|
-
let jsonDict = json->(Utils.magic:
|
|
20
|
+
let parseBlockInfo = (json: JSON.t): blockInfo => {
|
|
21
|
+
let jsonDict = json->(Utils.magic: JSON.t => dict<JSON.t>)
|
|
22
22
|
{
|
|
23
23
|
number: jsonDict
|
|
24
|
-
->
|
|
24
|
+
->Dict.getUnsafe("number")
|
|
25
25
|
->S.parseOrThrow(Rpc.hexIntSchema),
|
|
26
26
|
timestamp: jsonDict
|
|
27
|
-
->
|
|
27
|
+
->Dict.getUnsafe("timestamp")
|
|
28
28
|
->S.parseOrThrow(Rpc.hexIntSchema),
|
|
29
29
|
hash: jsonDict
|
|
30
|
-
->
|
|
30
|
+
->Dict.getUnsafe("hash")
|
|
31
31
|
->S.parseOrThrow(S.string),
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -62,47 +62,47 @@ let getKnownRawBlockWithBackoff = async (
|
|
|
62
62
|
| json => result := Some(json)
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
result.contents->Option.
|
|
65
|
+
result.contents->Option.getOrThrow
|
|
66
66
|
}
|
|
67
67
|
let getSuggestedBlockIntervalFromExn = {
|
|
68
68
|
// Unknown provider: "retry with the range 123-456"
|
|
69
|
-
let suggestedRangeRegExp =
|
|
69
|
+
let suggestedRangeRegExp = /retry with the range (\d+)-(\d+)/
|
|
70
70
|
|
|
71
71
|
// QuickNode, 1RPC, Blast: "limited to a 1000 blocks range"
|
|
72
|
-
let blockRangeLimitRegExp =
|
|
72
|
+
let blockRangeLimitRegExp = /limited to a (\d+) blocks range/
|
|
73
73
|
|
|
74
74
|
// Alchemy: "up to a 500 block range"
|
|
75
|
-
let alchemyRangeRegExp =
|
|
75
|
+
let alchemyRangeRegExp = /up to a (\d+) block range/
|
|
76
76
|
|
|
77
77
|
// Cloudflare: "Max range: 3500"
|
|
78
|
-
let cloudflareRangeRegExp =
|
|
78
|
+
let cloudflareRangeRegExp = /Max range: (\d+)/
|
|
79
79
|
|
|
80
80
|
// Thirdweb: "Maximum allowed number of requested blocks is 3500"
|
|
81
|
-
let thirdwebRangeRegExp =
|
|
81
|
+
let thirdwebRangeRegExp = /Maximum allowed number of requested blocks is (\d+)/
|
|
82
82
|
|
|
83
83
|
// BlockPI: "limited to 2000 block"
|
|
84
|
-
let blockpiRangeRegExp =
|
|
84
|
+
let blockpiRangeRegExp = /limited to (\d+) block/
|
|
85
85
|
|
|
86
86
|
// Base: "block range too large" - fixed 2000 block limit
|
|
87
|
-
let baseRangeRegExp =
|
|
87
|
+
let baseRangeRegExp = /block range too large/
|
|
88
88
|
|
|
89
89
|
// evm-rpc.sei-apis.com: "block range too large (2000), maximum allowed is 1000 blocks"
|
|
90
|
-
let maxAllowedBlocksRegExp =
|
|
90
|
+
let maxAllowedBlocksRegExp = /maximum allowed is (\d+) blocks/
|
|
91
91
|
|
|
92
92
|
// Blast (paid): "exceeds the range allowed for your plan (5000 > 3000)"
|
|
93
|
-
let blastPaidRegExp =
|
|
93
|
+
let blastPaidRegExp = /exceeds the range allowed for your plan \(\d+ > (\d+)\)/
|
|
94
94
|
|
|
95
95
|
// Chainstack: "Block range limit exceeded" - 10000 block limit
|
|
96
|
-
let chainstackRegExp =
|
|
96
|
+
let chainstackRegExp = /Block range limit exceeded./
|
|
97
97
|
|
|
98
98
|
// Coinbase: "please limit the query to at most 1000 blocks"
|
|
99
|
-
let coinbaseRegExp =
|
|
99
|
+
let coinbaseRegExp = /please limit the query to at most (\d+) blocks/
|
|
100
100
|
|
|
101
101
|
// PublicNode: "maximum block range: 2000"
|
|
102
|
-
let publicNodeRegExp =
|
|
102
|
+
let publicNodeRegExp = /maximum block range: (\d+)/
|
|
103
103
|
|
|
104
104
|
// Hyperliquid: "query exceeds max block range 1000"
|
|
105
|
-
let hyperliquidRegExp =
|
|
105
|
+
let hyperliquidRegExp = /query exceeds max block range (\d+)/
|
|
106
106
|
|
|
107
107
|
// TODO: Reproduce how the error message looks like
|
|
108
108
|
// when we send request with numeric block range instead of hex
|
|
@@ -119,8 +119,8 @@ let getSuggestedBlockIntervalFromExn = {
|
|
|
119
119
|
let parseMessageForBlockRange = (message: string) => {
|
|
120
120
|
// Helper to extract block range from regex match
|
|
121
121
|
let extractBlockRange = (execResult, ~isMaxRange) =>
|
|
122
|
-
switch execResult->
|
|
123
|
-
| [
|
|
122
|
+
switch execResult->RegExp.Result.matches {
|
|
123
|
+
| [Some(blockRangeLimit)] =>
|
|
124
124
|
switch blockRangeLimit->Int.fromString {
|
|
125
125
|
| Some(blockRangeLimit) if blockRangeLimit > 0 => Some(blockRangeLimit, isMaxRange)
|
|
126
126
|
| _ => None
|
|
@@ -129,10 +129,10 @@ let getSuggestedBlockIntervalFromExn = {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// Try each regex pattern in order
|
|
132
|
-
switch suggestedRangeRegExp->
|
|
132
|
+
switch suggestedRangeRegExp->RegExp.exec(message) {
|
|
133
133
|
| Some(execResult) =>
|
|
134
|
-
switch execResult->
|
|
135
|
-
| [
|
|
134
|
+
switch execResult->RegExp.Result.matches {
|
|
135
|
+
| [Some(fromBlock), Some(toBlock)] =>
|
|
136
136
|
switch (fromBlock->Int.fromString, toBlock->Int.fromString) {
|
|
137
137
|
| (Some(fromBlock), Some(toBlock)) if toBlock >= fromBlock =>
|
|
138
138
|
Some(toBlock - fromBlock + 1, false)
|
|
@@ -142,40 +142,40 @@ let getSuggestedBlockIntervalFromExn = {
|
|
|
142
142
|
}
|
|
143
143
|
| None =>
|
|
144
144
|
// Try each provider's specific error pattern
|
|
145
|
-
switch blockRangeLimitRegExp->
|
|
145
|
+
switch blockRangeLimitRegExp->RegExp.exec(message) {
|
|
146
146
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
147
147
|
| None =>
|
|
148
|
-
switch alchemyRangeRegExp->
|
|
148
|
+
switch alchemyRangeRegExp->RegExp.exec(message) {
|
|
149
149
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
150
150
|
| None =>
|
|
151
|
-
switch cloudflareRangeRegExp->
|
|
151
|
+
switch cloudflareRangeRegExp->RegExp.exec(message) {
|
|
152
152
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
153
153
|
| None =>
|
|
154
|
-
switch thirdwebRangeRegExp->
|
|
154
|
+
switch thirdwebRangeRegExp->RegExp.exec(message) {
|
|
155
155
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
156
156
|
| None =>
|
|
157
|
-
switch blockpiRangeRegExp->
|
|
157
|
+
switch blockpiRangeRegExp->RegExp.exec(message) {
|
|
158
158
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
159
159
|
| None =>
|
|
160
|
-
switch maxAllowedBlocksRegExp->
|
|
160
|
+
switch maxAllowedBlocksRegExp->RegExp.exec(message) {
|
|
161
161
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
162
162
|
| None =>
|
|
163
|
-
switch baseRangeRegExp->
|
|
163
|
+
switch baseRangeRegExp->RegExp.exec(message) {
|
|
164
164
|
| Some(_) => Some(2000, true)
|
|
165
165
|
| None =>
|
|
166
|
-
switch blastPaidRegExp->
|
|
166
|
+
switch blastPaidRegExp->RegExp.exec(message) {
|
|
167
167
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
168
168
|
| None =>
|
|
169
|
-
switch chainstackRegExp->
|
|
169
|
+
switch chainstackRegExp->RegExp.exec(message) {
|
|
170
170
|
| Some(_) => Some(10000, true)
|
|
171
171
|
| None =>
|
|
172
|
-
switch coinbaseRegExp->
|
|
172
|
+
switch coinbaseRegExp->RegExp.exec(message) {
|
|
173
173
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
174
174
|
| None =>
|
|
175
|
-
switch publicNodeRegExp->
|
|
175
|
+
switch publicNodeRegExp->RegExp.exec(message) {
|
|
176
176
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
177
177
|
| None =>
|
|
178
|
-
switch hyperliquidRegExp->
|
|
178
|
+
switch hyperliquidRegExp->RegExp.exec(message) {
|
|
179
179
|
| Some(execResult) => extractBlockRange(execResult, ~isMaxRange=true)
|
|
180
180
|
| None => None
|
|
181
181
|
}
|
|
@@ -201,7 +201,7 @@ let getSuggestedBlockIntervalFromExn = {
|
|
|
201
201
|
)> =>
|
|
202
202
|
switch exn {
|
|
203
203
|
| Rpc.JsonRpcError({message}) => parseMessageForBlockRange(message)
|
|
204
|
-
|
|
|
204
|
+
| JsExn(error) =>
|
|
205
205
|
try {
|
|
206
206
|
let message: string = (error->Obj.magic)["error"]["message"]
|
|
207
207
|
message->S.assertOrThrow(S.string)
|
|
@@ -265,11 +265,11 @@ let getNextPage = (
|
|
|
265
265
|
->Promise.catch(err => {
|
|
266
266
|
switch getSuggestedBlockIntervalFromExn(err) {
|
|
267
267
|
| Some((nextBlockIntervalTry, isMaxRange)) =>
|
|
268
|
-
mutSuggestedBlockIntervals->
|
|
268
|
+
mutSuggestedBlockIntervals->Dict.set(
|
|
269
269
|
isMaxRange ? maxSuggestedBlockIntervalKey : partitionId,
|
|
270
270
|
nextBlockIntervalTry,
|
|
271
271
|
)
|
|
272
|
-
|
|
272
|
+
throw(
|
|
273
273
|
Source.GetItemsError(
|
|
274
274
|
FailedGettingItems({
|
|
275
275
|
exn: err,
|
|
@@ -284,8 +284,8 @@ let getNextPage = (
|
|
|
284
284
|
let executedBlockInterval = toBlock - fromBlock + 1
|
|
285
285
|
let nextBlockIntervalTry =
|
|
286
286
|
(executedBlockInterval->Belt.Int.toFloat *. sc.backoffMultiplicative)->Belt.Int.fromFloat
|
|
287
|
-
mutSuggestedBlockIntervals->
|
|
288
|
-
|
|
287
|
+
mutSuggestedBlockIntervals->Dict.set(partitionId, nextBlockIntervalTry)
|
|
288
|
+
throw(
|
|
289
289
|
Source.GetItemsError(
|
|
290
290
|
Source.FailedGettingItems({
|
|
291
291
|
exn: err,
|
|
@@ -318,8 +318,8 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
318
318
|
->(Utils.magic: array<Internal.eventConfig> => array<Internal.evmEventConfig>)
|
|
319
319
|
->Belt.Array.forEach(({getEventFiltersOrThrow}) => {
|
|
320
320
|
switch getEventFiltersOrThrow(chain) {
|
|
321
|
-
| Static(s) => staticTopicSelections->
|
|
322
|
-
| Dynamic(fn) => dynamicEventFilters->
|
|
321
|
+
| Static(s) => staticTopicSelections->Array.pushMany(s)->ignore
|
|
322
|
+
| Dynamic(fn) => dynamicEventFilters->Array.push(fn)->ignore
|
|
323
323
|
}
|
|
324
324
|
})
|
|
325
325
|
|
|
@@ -328,7 +328,7 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
328
328
|
dynamicEventFilters,
|
|
329
329
|
) {
|
|
330
330
|
| ([], []) =>
|
|
331
|
-
|
|
331
|
+
throw(
|
|
332
332
|
Source.GetItemsError(
|
|
333
333
|
UnsupportedSelection({
|
|
334
334
|
message: "Invalid events configuration for the partition. Nothing to fetch. Please, report to the Envio team.",
|
|
@@ -345,7 +345,7 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
345
345
|
topicQuery,
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
|
-
| ([], [dynamicEventFilter]) if selection.eventConfigs->
|
|
348
|
+
| ([], [dynamicEventFilter]) if selection.eventConfigs->Array.length === 1 =>
|
|
349
349
|
let eventConfig = selection.eventConfigs->Utils.Array.firstUnsafe
|
|
350
350
|
|
|
351
351
|
(~addressesByContractName) => {
|
|
@@ -355,7 +355,7 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
355
355
|
topicQuery: switch dynamicEventFilter(addresses) {
|
|
356
356
|
| [topicSelection] => topicSelection->Rpc.GetLogs.mapTopicQuery
|
|
357
357
|
| _ =>
|
|
358
|
-
|
|
358
|
+
throw(
|
|
359
359
|
Source.GetItemsError(
|
|
360
360
|
UnsupportedSelection({
|
|
361
361
|
message: "RPC data-source currently doesn't support an array of event filters. Please, create a GitHub issue if it's a blocker for you.",
|
|
@@ -366,7 +366,7 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
| _ =>
|
|
369
|
-
|
|
369
|
+
throw(
|
|
370
370
|
Source.GetItemsError(
|
|
371
371
|
UnsupportedSelection({
|
|
372
372
|
message: "RPC data-source currently supports event filters only when there's a single wildcard event. Please, create a GitHub issue if it's a blocker for you.",
|
|
@@ -384,16 +384,16 @@ let memoGetSelectionConfig = (~chain) =>
|
|
|
384
384
|
Utils.WeakMap.memoize(selection => selection->getSelectionConfig(~chain))
|
|
385
385
|
|
|
386
386
|
// Type-erase a schema for storage in the field registry
|
|
387
|
-
external toFieldSchema: S.t<'a> => S.t<
|
|
387
|
+
external toFieldSchema: S.t<'a> => S.t<JSON.t> = "%identity"
|
|
388
388
|
|
|
389
|
-
let lowercaseAddressSchema: S.t<
|
|
389
|
+
let lowercaseAddressSchema: S.t<JSON.t> =
|
|
390
390
|
S.string
|
|
391
391
|
->S.transform(_ => {
|
|
392
|
-
parser: str => str->
|
|
392
|
+
parser: str => str->String.toLowerCase->Address.unsafeFromString,
|
|
393
393
|
})
|
|
394
394
|
->toFieldSchema
|
|
395
395
|
|
|
396
|
-
let checksumAddressSchema: S.t<
|
|
396
|
+
let checksumAddressSchema: S.t<JSON.t> =
|
|
397
397
|
S.string
|
|
398
398
|
->S.transform(_ => {
|
|
399
399
|
parser: str => str->Address.Evm.fromStringOrThrow,
|
|
@@ -404,11 +404,11 @@ let checksumAddressSchema: S.t<Js.Json.t> =
|
|
|
404
404
|
type blockFieldDef = {
|
|
405
405
|
location: Internal.evmBlockField,
|
|
406
406
|
jsonKey: string,
|
|
407
|
-
schema: S.t<
|
|
407
|
+
schema: S.t<JSON.t>, // Type-erased schema
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
// Block field registry: maps field location (= JS property name) to parsing info.
|
|
411
|
-
let makeBlockFieldRegistry = (addressSchema: S.t<
|
|
411
|
+
let makeBlockFieldRegistry = (addressSchema: S.t<JSON.t>): Utils.Record.t<
|
|
412
412
|
Internal.evmBlockField,
|
|
413
413
|
blockFieldDef,
|
|
414
414
|
> =>
|
|
@@ -464,19 +464,19 @@ let blockFieldRegistryChecksum = makeBlockFieldRegistry(checksumAddressSchema)
|
|
|
464
464
|
|
|
465
465
|
// Parse block fields from raw JSON, similar to parseFieldsFromJson for transactions
|
|
466
466
|
let parseBlockFieldsFromJson = (
|
|
467
|
-
mutBlockAcc:
|
|
467
|
+
mutBlockAcc: dict<JSON.t>,
|
|
468
468
|
fields: array<blockFieldDef>,
|
|
469
|
-
json:
|
|
469
|
+
json: JSON.t,
|
|
470
470
|
) => {
|
|
471
|
-
let jsonDict = json->(Utils.magic:
|
|
471
|
+
let jsonDict = json->(Utils.magic: JSON.t => dict<JSON.t>)
|
|
472
472
|
fields->Array.forEach(def => {
|
|
473
|
-
let raw = jsonDict->
|
|
473
|
+
let raw = jsonDict->Dict.getUnsafe(def.jsonKey)
|
|
474
474
|
try {
|
|
475
475
|
let parsed = raw->S.parseOrThrow(def.schema)
|
|
476
|
-
mutBlockAcc->
|
|
476
|
+
mutBlockAcc->Dict.set((def.location :> string), parsed)
|
|
477
477
|
} catch {
|
|
478
478
|
| S.Raised(error) =>
|
|
479
|
-
|
|
479
|
+
JsError.throwWithMessage(
|
|
480
480
|
`Invalid block field "${(def.location :> string)}" found in the RPC response. Error: ${error->S.Error.reason}`,
|
|
481
481
|
)
|
|
482
482
|
}
|
|
@@ -484,7 +484,7 @@ let parseBlockFieldsFromJson = (
|
|
|
484
484
|
}
|
|
485
485
|
|
|
486
486
|
let makeThrowingGetEventBlock = (
|
|
487
|
-
~getBlockJson: int => promise<
|
|
487
|
+
~getBlockJson: int => promise<JSON.t>,
|
|
488
488
|
~lowercaseAddresses: bool,
|
|
489
489
|
) => {
|
|
490
490
|
let blockFieldRegistry = if lowercaseAddresses {
|
|
@@ -501,7 +501,7 @@ let makeThrowingGetEventBlock = (
|
|
|
501
501
|
| None => {
|
|
502
502
|
let fields: array<blockFieldDef> = []
|
|
503
503
|
selectedBlockFields->Utils.Set.forEach(fieldName => {
|
|
504
|
-
fields->
|
|
504
|
+
fields->Array.push(blockFieldRegistry->Utils.Record.getUnsafe(fieldName))->ignore
|
|
505
505
|
})
|
|
506
506
|
|
|
507
507
|
let fn = if selectedBlockFields->Utils.Set.size == 0 {
|
|
@@ -509,9 +509,9 @@ let makeThrowingGetEventBlock = (
|
|
|
509
509
|
} else {
|
|
510
510
|
(log: Rpc.GetLogs.log) => {
|
|
511
511
|
getBlockJson(log.blockNumber)->Promise.thenResolve(json => {
|
|
512
|
-
let mutBlockAcc =
|
|
512
|
+
let mutBlockAcc = Dict.make()
|
|
513
513
|
parseBlockFieldsFromJson(mutBlockAcc, fields, json)
|
|
514
|
-
mutBlockAcc->(Utils.magic:
|
|
514
|
+
mutBlockAcc->(Utils.magic: dict<JSON.t> => Internal.eventBlock)
|
|
515
515
|
})
|
|
516
516
|
}
|
|
517
517
|
}
|
|
@@ -529,14 +529,14 @@ type fieldSource = TransactionOnly | ReceiptOnly | Both
|
|
|
529
529
|
type fieldDef = {
|
|
530
530
|
location: Internal.evmTransactionField,
|
|
531
531
|
jsonKey: string,
|
|
532
|
-
schema: S.t<
|
|
532
|
+
schema: S.t<JSON.t>, // Type-erased schema (S.nullable for optional fields)
|
|
533
533
|
source: fieldSource,
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
// Field registry: maps field location (= JS property name) to parsing info.
|
|
537
537
|
// Only includes fields that require an RPC call. Log-derived fields (hash, transactionIndex) are special-cased.
|
|
538
538
|
// Nullable fields are wrapped with S.nullable during registry construction based on Internal.evmNullableTransactionFields
|
|
539
|
-
let makeFieldRegistry = (addressSchema: S.t<
|
|
539
|
+
let makeFieldRegistry = (addressSchema: S.t<JSON.t>): Utils.Record.t<
|
|
540
540
|
Internal.evmTransactionField,
|
|
541
541
|
fieldDef,
|
|
542
542
|
> =>
|
|
@@ -691,19 +691,19 @@ type fetchStrategy = NoRpc | TransactionOnly | ReceiptOnly | TransactionAndRecei
|
|
|
691
691
|
// Parse fields from a raw JSON object into a result dict.
|
|
692
692
|
// Uses unsafeGet so nullable schemas (S.nullable) handle both null and undefined.
|
|
693
693
|
let parseFieldsFromJson = (
|
|
694
|
-
mutTransactionAcc:
|
|
694
|
+
mutTransactionAcc: dict<JSON.t>,
|
|
695
695
|
fields: array<fieldDef>,
|
|
696
|
-
json:
|
|
696
|
+
json: JSON.t,
|
|
697
697
|
) => {
|
|
698
|
-
let jsonDict = json->(Utils.magic:
|
|
698
|
+
let jsonDict = json->(Utils.magic: JSON.t => dict<JSON.t>)
|
|
699
699
|
fields->Array.forEach(def => {
|
|
700
|
-
let raw = jsonDict->
|
|
700
|
+
let raw = jsonDict->Dict.getUnsafe(def.jsonKey)
|
|
701
701
|
try {
|
|
702
702
|
let parsed = raw->S.parseOrThrow(def.schema)
|
|
703
|
-
mutTransactionAcc->
|
|
703
|
+
mutTransactionAcc->Dict.set((def.location :> string), parsed)
|
|
704
704
|
} catch {
|
|
705
705
|
| S.Raised(error) =>
|
|
706
|
-
|
|
706
|
+
JsError.throwWithMessage(
|
|
707
707
|
`Invalid transaction field "${(def.location :> string)}" found in the RPC response. Error: ${error->S.Error.reason}`,
|
|
708
708
|
)
|
|
709
709
|
}
|
|
@@ -711,8 +711,8 @@ let parseFieldsFromJson = (
|
|
|
711
711
|
}
|
|
712
712
|
|
|
713
713
|
let makeThrowingGetEventTransaction = (
|
|
714
|
-
~getTransactionJson: string => promise<
|
|
715
|
-
~getReceiptJson: string => promise<
|
|
714
|
+
~getTransactionJson: string => promise<JSON.t>,
|
|
715
|
+
~getReceiptJson: string => promise<JSON.t>,
|
|
716
716
|
~lowercaseAddresses: bool,
|
|
717
717
|
) => {
|
|
718
718
|
let fieldRegistry = if lowercaseAddresses {
|
|
@@ -742,9 +742,9 @@ let makeThrowingGetEventTransaction = (
|
|
|
742
742
|
switch fieldRegistry->Utils.Record.get(fieldName) {
|
|
743
743
|
| Some(def) =>
|
|
744
744
|
switch def.source {
|
|
745
|
-
| TransactionOnly => txFields->
|
|
746
|
-
| ReceiptOnly => receiptFields->
|
|
747
|
-
| Both => bothFields->
|
|
745
|
+
| TransactionOnly => txFields->Array.push(def)->ignore
|
|
746
|
+
| ReceiptOnly => receiptFields->Array.push(def)->ignore
|
|
747
|
+
| Both => bothFields->Array.push(def)->ignore
|
|
748
748
|
}
|
|
749
749
|
| None => () // Unknown field — skip silently
|
|
750
750
|
}
|
|
@@ -762,20 +762,20 @@ let makeThrowingGetEventTransaction = (
|
|
|
762
762
|
|
|
763
763
|
// Assign Both fields to whichever source is already being fetched; default to transaction
|
|
764
764
|
let targetForBoth = strategy == ReceiptOnly ? receiptFields : txFields
|
|
765
|
-
bothFields->Array.forEach(f => targetForBoth->
|
|
765
|
+
bothFields->Array.forEach(f => targetForBoth->Array.push(f)->ignore)
|
|
766
766
|
|
|
767
767
|
// Set log-derived fields on the mutable accumulator
|
|
768
|
-
let setLogFields = (mutTransactionAcc:
|
|
768
|
+
let setLogFields = (mutTransactionAcc: dict<JSON.t>, log: Rpc.GetLogs.log) => {
|
|
769
769
|
if hasTransactionIndex.contents {
|
|
770
|
-
mutTransactionAcc->
|
|
770
|
+
mutTransactionAcc->Dict.set(
|
|
771
771
|
"transactionIndex",
|
|
772
|
-
log.transactionIndex->(Utils.magic: int =>
|
|
772
|
+
log.transactionIndex->(Utils.magic: int => JSON.t),
|
|
773
773
|
)
|
|
774
774
|
}
|
|
775
775
|
if hasHash.contents {
|
|
776
|
-
mutTransactionAcc->
|
|
776
|
+
mutTransactionAcc->Dict.set(
|
|
777
777
|
"hash",
|
|
778
|
-
log.transactionHash->(Utils.magic: string =>
|
|
778
|
+
log.transactionHash->(Utils.magic: string => JSON.t),
|
|
779
779
|
)
|
|
780
780
|
}
|
|
781
781
|
}
|
|
@@ -786,9 +786,9 @@ let makeThrowingGetEventTransaction = (
|
|
|
786
786
|
switch strategy {
|
|
787
787
|
| NoRpc =>
|
|
788
788
|
(log: Rpc.GetLogs.log) => {
|
|
789
|
-
let mutTransactionAcc =
|
|
789
|
+
let mutTransactionAcc = Dict.make()
|
|
790
790
|
setLogFields(mutTransactionAcc, log)
|
|
791
|
-
mutTransactionAcc->(Utils.magic:
|
|
791
|
+
mutTransactionAcc->(Utils.magic: dict<JSON.t> => 'a)->Promise.resolve
|
|
792
792
|
}
|
|
793
793
|
| _ =>
|
|
794
794
|
(log: Rpc.GetLogs.log) => {
|
|
@@ -807,7 +807,7 @@ let makeThrowingGetEventTransaction = (
|
|
|
807
807
|
txJson,
|
|
808
808
|
receiptJson,
|
|
809
809
|
)) => {
|
|
810
|
-
let mutTransactionAcc =
|
|
810
|
+
let mutTransactionAcc = Dict.make()
|
|
811
811
|
setLogFields(mutTransactionAcc, log)
|
|
812
812
|
|
|
813
813
|
switch txJson {
|
|
@@ -819,7 +819,7 @@ let makeThrowingGetEventTransaction = (
|
|
|
819
819
|
| None => ()
|
|
820
820
|
}
|
|
821
821
|
|
|
822
|
-
mutTransactionAcc->(Utils.magic:
|
|
822
|
+
mutTransactionAcc->(Utils.magic: dict<JSON.t> => 'a)
|
|
823
823
|
})
|
|
824
824
|
}
|
|
825
825
|
}
|
|
@@ -858,7 +858,7 @@ let make = (
|
|
|
858
858
|
let chainId = chain->ChainMap.Chain.toChainId
|
|
859
859
|
let urlHost = switch Utils.Url.getHostFromUrl(url) {
|
|
860
860
|
| None =>
|
|
861
|
-
|
|
861
|
+
JsError.throwWithMessage(
|
|
862
862
|
`The RPC url for chain ${chainId->Belt.Int.toString} is in incorrect format. The RPC url needs to start with either http:// or https://`,
|
|
863
863
|
)
|
|
864
864
|
| Some(host) => host
|
|
@@ -867,7 +867,7 @@ let make = (
|
|
|
867
867
|
|
|
868
868
|
let getSelectionConfig = memoGetSelectionConfig(~chain)
|
|
869
869
|
|
|
870
|
-
let mutSuggestedBlockIntervals =
|
|
870
|
+
let mutSuggestedBlockIntervals = Dict.make()
|
|
871
871
|
|
|
872
872
|
let client = Rpc.makeClient(url)
|
|
873
873
|
|
|
@@ -965,13 +965,14 @@ let make = (
|
|
|
965
965
|
~getTransactionJson=async transactionHash => {
|
|
966
966
|
switch await transactionLoader.contents->LazyLoader.get(transactionHash) {
|
|
967
967
|
| Some(json) => json
|
|
968
|
-
| None =>
|
|
968
|
+
| None => JsError.throwWithMessage(`Transaction not found for hash: ${transactionHash}`)
|
|
969
969
|
}
|
|
970
970
|
},
|
|
971
971
|
~getReceiptJson=async transactionHash => {
|
|
972
972
|
switch await receiptLoader.contents->LazyLoader.get(transactionHash) {
|
|
973
973
|
| Some(json) => json
|
|
974
|
-
| None =>
|
|
974
|
+
| None =>
|
|
975
|
+
JsError.throwWithMessage(`Transaction receipt not found for hash: ${transactionHash}`)
|
|
975
976
|
}
|
|
976
977
|
},
|
|
977
978
|
~lowercaseAddresses,
|
|
@@ -987,7 +988,7 @@ let make = (
|
|
|
987
988
|
blockNumber: log.blockNumber,
|
|
988
989
|
address: log.address,
|
|
989
990
|
data: log.data,
|
|
990
|
-
topics: log.topics->(Utils.magic: array<string> => array<
|
|
991
|
+
topics: log.topics->(Utils.magic: array<string> => array<Nullable.t<EvmTypes.Hex.t>>),
|
|
991
992
|
}
|
|
992
993
|
{log: hyperSyncLog}
|
|
993
994
|
}
|
|
@@ -1007,7 +1008,7 @@ let make = (
|
|
|
1007
1008
|
~fromBlock,
|
|
1008
1009
|
~toBlock,
|
|
1009
1010
|
~addressesByContractName,
|
|
1010
|
-
~
|
|
1011
|
+
~indexingAddresses,
|
|
1011
1012
|
~knownHeight,
|
|
1012
1013
|
~partitionId,
|
|
1013
1014
|
~selection: FetchState.selection,
|
|
@@ -1074,7 +1075,7 @@ let make = (
|
|
|
1074
1075
|
) {
|
|
1075
1076
|
// Increase batch size going forward, but do not increase past a configured maximum
|
|
1076
1077
|
// See: https://en.wikipedia.org/wiki/Additive_increase/multiplicative_decrease
|
|
1077
|
-
mutSuggestedBlockIntervals->
|
|
1078
|
+
mutSuggestedBlockIntervals->Dict.set(
|
|
1078
1079
|
partitionId,
|
|
1079
1080
|
Pervasives.min(
|
|
1080
1081
|
executedBlockInterval + syncConfig.accelerationAdditive,
|
|
@@ -1089,7 +1090,7 @@ let make = (
|
|
|
1089
1090
|
// Decode using HyperSyncClient decoder
|
|
1090
1091
|
let parsedEvents = try await getHscDecoder().decodeEvents(hyperSyncEvents) catch {
|
|
1091
1092
|
| exn =>
|
|
1092
|
-
|
|
1093
|
+
throw(
|
|
1093
1094
|
Source.GetItemsError(
|
|
1094
1095
|
FailedGettingItems({
|
|
1095
1096
|
exn,
|
|
@@ -1102,79 +1103,76 @@ let make = (
|
|
|
1102
1103
|
)
|
|
1103
1104
|
}
|
|
1104
1105
|
|
|
1105
|
-
let parsedQueueItems =
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
}
|
|
1106
|
+
let parsedQueueItems = await logs
|
|
1107
|
+
->Array.zip(parsedEvents)
|
|
1108
|
+
->Array.filterMap(((
|
|
1109
|
+
log: Rpc.GetLogs.log,
|
|
1110
|
+
maybeDecodedEvent: Nullable.t<HyperSyncClient.Decoder.decodedEvent>,
|
|
1111
|
+
)) => {
|
|
1112
|
+
let topic0 = log.topics[0]->Option.getOr("0x0")
|
|
1113
|
+
let routedAddress = if lowercaseAddresses {
|
|
1114
|
+
log.address->Address.Evm.fromAddressLowercaseOrThrow
|
|
1115
|
+
} else {
|
|
1116
|
+
log.address->Address.Evm.fromAddressOrThrow
|
|
1117
|
+
}
|
|
1118
1118
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1119
|
+
switch eventRouter->EventRouter.get(
|
|
1120
|
+
~tag=EventRouter.getEvmEventId(~sighash=topic0, ~topicCount=log.topics->Array.length),
|
|
1121
|
+
~indexingAddresses,
|
|
1122
|
+
~contractAddress=routedAddress,
|
|
1123
|
+
~blockNumber=log.blockNumber,
|
|
1124
|
+
) {
|
|
1125
|
+
| None => None
|
|
1126
|
+
| Some(eventConfig) =>
|
|
1127
|
+
switch maybeDecodedEvent {
|
|
1128
|
+
| Value(decoded) =>
|
|
1129
|
+
Some(
|
|
1130
|
+
(
|
|
1131
|
+
async () => {
|
|
1132
|
+
let (block, transaction) = try await Promise.all2((
|
|
1133
|
+
log->getEventBlockOrThrow(~selectedBlockFields=eventConfig.selectedBlockFields),
|
|
1134
|
+
log->getEventTransactionOrThrow(
|
|
1135
|
+
~selectedTransactionFields=eventConfig.selectedTransactionFields,
|
|
1136
|
+
),
|
|
1137
|
+
)) catch {
|
|
1138
|
+
| exn =>
|
|
1139
|
+
throw(
|
|
1140
|
+
Source.GetItemsError(
|
|
1141
|
+
FailedGettingFieldSelection({
|
|
1142
|
+
message: "Failed getting selected fields. Please double-check your RPC provider returns correct data.",
|
|
1143
|
+
exn,
|
|
1144
|
+
blockNumber: log.blockNumber,
|
|
1145
|
+
logIndex: log.logIndex,
|
|
1146
|
+
}),
|
|
1136
1147
|
),
|
|
1137
|
-
)
|
|
1138
|
-
|
|
1139
|
-
raise(
|
|
1140
|
-
Source.GetItemsError(
|
|
1141
|
-
FailedGettingFieldSelection({
|
|
1142
|
-
message: "Failed getting selected fields. Please double-check your RPC provider returns correct data.",
|
|
1143
|
-
exn,
|
|
1144
|
-
blockNumber: log.blockNumber,
|
|
1145
|
-
logIndex: log.logIndex,
|
|
1146
|
-
}),
|
|
1147
|
-
),
|
|
1148
|
-
)
|
|
1149
|
-
}
|
|
1148
|
+
)
|
|
1149
|
+
}
|
|
1150
1150
|
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1151
|
+
Internal.Event({
|
|
1152
|
+
eventConfig: (eventConfig :> Internal.eventConfig),
|
|
1153
|
+
timestamp: block->Evm.getTimestamp,
|
|
1154
|
+
blockNumber: block->Evm.getNumber,
|
|
1155
|
+
chain,
|
|
1156
|
+
logIndex: log.logIndex,
|
|
1157
|
+
event: {
|
|
1158
|
+
contractName: eventConfig.contractName,
|
|
1159
|
+
eventName: eventConfig.name,
|
|
1160
|
+
chainId: chain->ChainMap.Chain.toChainId,
|
|
1161
|
+
params: decoded->eventConfig.convertHyperSyncEventArgs,
|
|
1162
|
+
transaction,
|
|
1163
|
+
block,
|
|
1164
|
+
srcAddress: routedAddress,
|
|
1156
1165
|
logIndex: log.logIndex,
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
block,
|
|
1164
|
-
srcAddress: routedAddress,
|
|
1165
|
-
logIndex: log.logIndex,
|
|
1166
|
-
}->Internal.fromGenericEvent,
|
|
1167
|
-
})
|
|
1168
|
-
}
|
|
1169
|
-
)(),
|
|
1170
|
-
)
|
|
1171
|
-
| Js.Nullable.Null
|
|
1172
|
-
| Js.Nullable.Undefined =>
|
|
1173
|
-
None
|
|
1174
|
-
}
|
|
1166
|
+
}->Internal.fromGenericEvent,
|
|
1167
|
+
})
|
|
1168
|
+
}
|
|
1169
|
+
)(),
|
|
1170
|
+
)
|
|
1171
|
+
| Null | Undefined => None
|
|
1175
1172
|
}
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1173
|
+
}
|
|
1174
|
+
})
|
|
1175
|
+
->Promise.all
|
|
1178
1176
|
|
|
1179
1177
|
let optFirstBlockParent = await firstBlockParentPromise
|
|
1180
1178
|
|
|
@@ -1234,8 +1232,9 @@ let make = (
|
|
|
1234
1232
|
}
|
|
1235
1233
|
|
|
1236
1234
|
let createHeightSubscription =
|
|
1237
|
-
ws->Belt.Option.map(wsUrl =>
|
|
1238
|
-
RpcWebSocketHeightStream.subscribe(~wsUrl, ~chainId, ~onHeight)
|
|
1235
|
+
ws->Belt.Option.map(wsUrl =>
|
|
1236
|
+
(~onHeight) => RpcWebSocketHeightStream.subscribe(~wsUrl, ~chainId, ~onHeight)
|
|
1237
|
+
)
|
|
1239
1238
|
|
|
1240
1239
|
{
|
|
1241
1240
|
name,
|
|
@@ -1262,7 +1261,7 @@ let make = (
|
|
|
1262
1261
|
~method="eth_blockNumber",
|
|
1263
1262
|
~seconds,
|
|
1264
1263
|
)
|
|
1265
|
-
exn->
|
|
1264
|
+
exn->throw
|
|
1266
1265
|
}
|
|
1267
1266
|
let seconds = timerRef->Hrtime.timeSince->Hrtime.toSecondsFloat
|
|
1268
1267
|
Prometheus.SourceRequestCount.increment(
|