envio 3.0.0-alpha.21 → 3.0.0-alpha.22
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/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 +428 -51
- package/src/Main.res.mjs +528 -271
- package/src/Persistence.res +77 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +291 -167
- package/src/PgStorage.res.mjs +797 -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 +15 -16
- package/src/TestIndexerProxyStorage.res.mjs +98 -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 +2 -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
package/src/SimulateItems.res
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
open Belt
|
|
2
|
-
|
|
3
1
|
// EVM simulate block schema — all fields present with defaults for non-nullable ones.
|
|
4
2
|
// Nullable fields (from Internal.evmNullableBlockFields) use S.null → option<T>.
|
|
5
3
|
let evmSimulateBlockSchema = S.schema(s =>
|
|
@@ -44,13 +42,13 @@ type evmSimulateBlock = {number: int, timestamp: int}
|
|
|
44
42
|
|
|
45
43
|
let parseEvmSimulateBlock = (
|
|
46
44
|
~defaultBlockNumber: int,
|
|
47
|
-
~blockJson: option<
|
|
45
|
+
~blockJson: option<JSON.t>,
|
|
48
46
|
): Internal.eventBlock => {
|
|
49
47
|
let block = switch blockJson {
|
|
50
48
|
| Some(json) => json->S.convertOrThrow(evmSimulateBlockSchema)
|
|
51
49
|
| None =>
|
|
52
|
-
|
|
53
|
-
->(Utils.magic: dict<unit> =>
|
|
50
|
+
Dict.make()
|
|
51
|
+
->(Utils.magic: dict<unit> => JSON.t)
|
|
54
52
|
->S.convertOrThrow(evmSimulateBlockSchema)
|
|
55
53
|
}
|
|
56
54
|
let block = block->(Utils.magic: _ => Internal.eventBlock)
|
|
@@ -58,8 +56,8 @@ let parseEvmSimulateBlock = (
|
|
|
58
56
|
|
|
59
57
|
// Only set block number when user didn't provide one (schema defaults to 0)
|
|
60
58
|
if blockJson->Option.isNone || blockFields.number === 0 {
|
|
61
|
-
let blockDict = block->(Utils.magic: Internal.eventBlock =>
|
|
62
|
-
blockDict->
|
|
59
|
+
let blockDict = block->(Utils.magic: Internal.eventBlock => dict<unknown>)
|
|
60
|
+
blockDict->Dict.set("number", defaultBlockNumber->(Utils.magic: int => unknown))
|
|
63
61
|
}
|
|
64
62
|
block
|
|
65
63
|
}
|
|
@@ -78,7 +76,7 @@ let evmSimulateTransactionSchema = S.schema(s =>
|
|
|
78
76
|
"effectiveGasPrice": s.matches(S.null(S.bigint)->S.Option.getOr(0n)),
|
|
79
77
|
"gasUsed": s.matches(S.null(S.bigint)->S.Option.getOr(0n)),
|
|
80
78
|
"logsBloom": s.matches(S.null(S.string)->S.Option.getOr("")),
|
|
81
|
-
"accessList": s.matches(S.null(S.json(~validate=false))->S.Option.getOr(
|
|
79
|
+
"accessList": s.matches(S.null(S.json(~validate=false))->S.Option.getOr(JSON.Encode.null)),
|
|
82
80
|
// Signature fields
|
|
83
81
|
"v": s.matches(S.null(S.string)),
|
|
84
82
|
"r": s.matches(S.null(S.string)),
|
|
@@ -107,14 +105,12 @@ let evmSimulateTransactionSchema = S.schema(s =>
|
|
|
107
105
|
}
|
|
108
106
|
)
|
|
109
107
|
|
|
110
|
-
let parseEvmSimulateTransaction = (
|
|
111
|
-
~transactionJson: option<Js.Json.t>,
|
|
112
|
-
): Internal.eventTransaction => {
|
|
108
|
+
let parseEvmSimulateTransaction = (~transactionJson: option<JSON.t>): Internal.eventTransaction => {
|
|
113
109
|
let transaction = switch transactionJson {
|
|
114
110
|
| Some(json) => json->S.convertOrThrow(evmSimulateTransactionSchema)
|
|
115
111
|
| None =>
|
|
116
|
-
|
|
117
|
-
->(Utils.magic: dict<unit> =>
|
|
112
|
+
Dict.make()
|
|
113
|
+
->(Utils.magic: dict<unit> => JSON.t)
|
|
118
114
|
->S.convertOrThrow(evmSimulateTransactionSchema)
|
|
119
115
|
}
|
|
120
116
|
transaction->(Utils.magic: _ => Internal.eventTransaction)
|
|
@@ -133,13 +129,13 @@ type fuelSimulateBlock = {height: int, time: int}
|
|
|
133
129
|
|
|
134
130
|
let parseFuelSimulateBlock = (
|
|
135
131
|
~defaultBlockNumber: int,
|
|
136
|
-
~blockJson: option<
|
|
132
|
+
~blockJson: option<JSON.t>,
|
|
137
133
|
): Internal.eventBlock => {
|
|
138
134
|
let block = switch blockJson {
|
|
139
135
|
| Some(json) => json->S.convertOrThrow(fuelSimulateBlockSchema)
|
|
140
136
|
| None =>
|
|
141
|
-
|
|
142
|
-
->(Utils.magic: dict<unit> =>
|
|
137
|
+
Dict.make()
|
|
138
|
+
->(Utils.magic: dict<unit> => JSON.t)
|
|
143
139
|
->S.convertOrThrow(fuelSimulateBlockSchema)
|
|
144
140
|
}
|
|
145
141
|
let block = block->(Utils.magic: _ => Internal.eventBlock)
|
|
@@ -147,8 +143,8 @@ let parseFuelSimulateBlock = (
|
|
|
147
143
|
|
|
148
144
|
// Only set block height when user didn't provide one (schema defaults to 0)
|
|
149
145
|
if blockJson->Option.isNone || blockFields.height === 0 {
|
|
150
|
-
let blockDict = block->(Utils.magic: Internal.eventBlock =>
|
|
151
|
-
blockDict->
|
|
146
|
+
let blockDict = block->(Utils.magic: Internal.eventBlock => dict<unknown>)
|
|
147
|
+
blockDict->Dict.set("height", defaultBlockNumber->(Utils.magic: int => unknown))
|
|
152
148
|
}
|
|
153
149
|
block
|
|
154
150
|
}
|
|
@@ -161,13 +157,13 @@ let fuelSimulateTransactionSchema = S.schema(s =>
|
|
|
161
157
|
)
|
|
162
158
|
|
|
163
159
|
let parseFuelSimulateTransaction = (
|
|
164
|
-
~transactionJson: option<
|
|
160
|
+
~transactionJson: option<JSON.t>,
|
|
165
161
|
): Internal.eventTransaction => {
|
|
166
162
|
let transaction = switch transactionJson {
|
|
167
163
|
| Some(json) => json->S.convertOrThrow(fuelSimulateTransactionSchema)
|
|
168
164
|
| None =>
|
|
169
|
-
|
|
170
|
-
->(Utils.magic: dict<unit> =>
|
|
165
|
+
Dict.make()
|
|
166
|
+
->(Utils.magic: dict<unit> => JSON.t)
|
|
171
167
|
->S.convertOrThrow(fuelSimulateTransactionSchema)
|
|
172
168
|
}
|
|
173
169
|
transaction->(Utils.magic: _ => Internal.eventTransaction)
|
|
@@ -199,11 +195,9 @@ let findEventConfig = (~config: Config.t, ~contractName: string, ~eventName: str
|
|
|
199
195
|
found.contents
|
|
200
196
|
}
|
|
201
197
|
|
|
202
|
-
let parse = (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
~chainConfig: Config.chain,
|
|
206
|
-
): array<Internal.item> => {
|
|
198
|
+
let parse = (~simulateItems: array<JSON.t>, ~config: Config.t, ~chainConfig: Config.chain): array<
|
|
199
|
+
Internal.item,
|
|
200
|
+
> => {
|
|
207
201
|
let chain = ChainMap.Chain.makeUnsafe(~chainId=chainConfig.id)
|
|
208
202
|
let chainId = chainConfig.id
|
|
209
203
|
let startBlock = chainConfig.startBlock
|
|
@@ -213,7 +207,7 @@ let parse = (
|
|
|
213
207
|
let items = []
|
|
214
208
|
|
|
215
209
|
simulateItems->Array.forEach(rawJson => {
|
|
216
|
-
let raw = rawJson->(Utils.magic:
|
|
210
|
+
let raw = rawJson->(Utils.magic: JSON.t => rawSimulateItem)
|
|
217
211
|
|
|
218
212
|
switch (raw->getContract, raw->getEvent) {
|
|
219
213
|
| (Some(contractName), Some(eventName)) =>
|
|
@@ -221,18 +215,18 @@ let parse = (
|
|
|
221
215
|
let eventConfig = switch findEventConfig(~config, ~contractName, ~eventName) {
|
|
222
216
|
| Some(ec) => ec
|
|
223
217
|
| None =>
|
|
224
|
-
|
|
218
|
+
JsError.throwWithMessage(
|
|
225
219
|
`simulate: Event "${eventName}" not found on contract "${contractName}". ` ++ `Check that the contract and event names match your config.yaml.`,
|
|
226
220
|
)
|
|
227
221
|
}
|
|
228
222
|
|
|
229
223
|
// Parse event item fields
|
|
230
|
-
let item = rawJson->(Utils.magic:
|
|
224
|
+
let item = rawJson->(Utils.magic: JSON.t => Envio.evmSimulateItem)
|
|
231
225
|
|
|
232
226
|
// Parse params using the simulate schema — fills missing fields with defaults
|
|
233
|
-
let paramsJson:
|
|
227
|
+
let paramsJson: JSON.t = switch item.params {
|
|
234
228
|
| Some(json) => json
|
|
235
|
-
| None =>
|
|
229
|
+
| None => Dict.make()->(Utils.magic: dict<unit> => JSON.t)
|
|
236
230
|
}
|
|
237
231
|
let params = paramsJson->S.convertOrThrow(eventConfig.simulateParamsSchema)
|
|
238
232
|
|
|
@@ -260,11 +254,11 @@ let parse = (
|
|
|
260
254
|
addr.contents
|
|
261
255
|
}
|
|
262
256
|
|
|
263
|
-
let rawItem = rawJson->(Utils.magic:
|
|
264
|
-
let blockJson: option<
|
|
265
|
-
rawItem["block"]->(Utils.magic: 'a =>
|
|
266
|
-
let transactionJson: option<
|
|
267
|
-
rawItem["transaction"]->(Utils.magic: 'a =>
|
|
257
|
+
let rawItem = rawJson->(Utils.magic: JSON.t => {..})
|
|
258
|
+
let blockJson: option<JSON.t> =
|
|
259
|
+
rawItem["block"]->(Utils.magic: 'a => Nullable.t<JSON.t>)->Nullable.toOption
|
|
260
|
+
let transactionJson: option<JSON.t> =
|
|
261
|
+
rawItem["transaction"]->(Utils.magic: 'a => Nullable.t<JSON.t>)->Nullable.toOption
|
|
268
262
|
let (block, blockNumber, timestamp) = switch config.ecosystem.name {
|
|
269
263
|
| Fuel =>
|
|
270
264
|
let block = parseFuelSimulateBlock(~defaultBlockNumber=currentBlock.contents, ~blockJson)
|
|
@@ -274,12 +268,12 @@ let parse = (
|
|
|
274
268
|
let block = parseEvmSimulateBlock(~defaultBlockNumber=currentBlock.contents, ~blockJson)
|
|
275
269
|
let blockFields = block->(Utils.magic: Internal.eventBlock => evmSimulateBlock)
|
|
276
270
|
(block, blockFields.number, blockFields.timestamp)
|
|
277
|
-
| Svm =>
|
|
271
|
+
| Svm => JsError.throwWithMessage("simulate is not supported for SVM ecosystem")
|
|
278
272
|
}
|
|
279
273
|
let transaction = switch config.ecosystem.name {
|
|
280
274
|
| Fuel => parseFuelSimulateTransaction(~transactionJson)
|
|
281
275
|
| Evm => parseEvmSimulateTransaction(~transactionJson)
|
|
282
|
-
| Svm =>
|
|
276
|
+
| Svm => JsError.throwWithMessage("simulate is not supported for SVM ecosystem")
|
|
283
277
|
}
|
|
284
278
|
|
|
285
279
|
// Update currentBlock for subsequent items
|
|
@@ -308,7 +302,7 @@ let parse = (
|
|
|
308
302
|
->ignore
|
|
309
303
|
|
|
310
304
|
| _ =>
|
|
311
|
-
|
|
305
|
+
JsError.throwWithMessage(`simulate: Invalid item. Each item must have "contract" and "event" fields.`)
|
|
312
306
|
}
|
|
313
307
|
})
|
|
314
308
|
|
|
@@ -317,29 +311,27 @@ let parse = (
|
|
|
317
311
|
|
|
318
312
|
// Apply simulate source config from processConfig JSON to a Config.t
|
|
319
313
|
// This patches chainMap entries that have simulate items with CustomSources
|
|
320
|
-
let patchConfig = (~config: Config.t, ~processConfig:
|
|
321
|
-
let processChains: option<
|
|
322
|
-
(processConfig->(Utils.magic:
|
|
314
|
+
let patchConfig = (~config: Config.t, ~processConfig: JSON.t): Config.t => {
|
|
315
|
+
let processChains: option<dict<JSON.t>> =
|
|
316
|
+
(processConfig->(Utils.magic: JSON.t => {..}))["chains"]->Nullable.toOption
|
|
323
317
|
switch processChains {
|
|
324
318
|
| Some(chainsDict) =>
|
|
325
319
|
let newChainMap = config.chainMap->ChainMap.mapWithKey((chain, chainConfig) => {
|
|
326
320
|
let chainIdStr = chain->ChainMap.Chain.toChainId->Int.toString
|
|
327
|
-
switch chainsDict->
|
|
321
|
+
switch chainsDict->Dict.get(chainIdStr) {
|
|
328
322
|
| Some(processChainJson) =>
|
|
329
|
-
let simulateRaw: option<array<
|
|
330
|
-
(processChainJson->(Utils.magic:
|
|
323
|
+
let simulateRaw: option<array<JSON.t>> =
|
|
324
|
+
(processChainJson->(Utils.magic: JSON.t => {..}))["simulate"]->Nullable.toOption
|
|
331
325
|
switch simulateRaw {
|
|
332
326
|
| Some(simulateItems) =>
|
|
333
327
|
let items = parse(~simulateItems, ~config, ~chainConfig)
|
|
334
328
|
// Use endBlock from processConfig (the user-specified range)
|
|
335
329
|
let startBlock: int =
|
|
336
|
-
(processChainJson->(Utils.magic:
|
|
330
|
+
(processChainJson->(Utils.magic: JSON.t => {..}))["startBlock"]->(
|
|
337
331
|
Utils.magic: 'a => int
|
|
338
332
|
)
|
|
339
333
|
let endBlock: int =
|
|
340
|
-
(processChainJson->(Utils.magic:
|
|
341
|
-
Utils.magic: 'a => int
|
|
342
|
-
)
|
|
334
|
+
(processChainJson->(Utils.magic: JSON.t => {..}))["endBlock"]->(Utils.magic: 'a => int)
|
|
343
335
|
let source = SimulateSource.make(~items, ~endBlock, ~chain)
|
|
344
336
|
{...chainConfig, startBlock, endBlock, sourceConfig: Config.CustomSources([source])}
|
|
345
337
|
| None => chainConfig
|