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
|
@@ -1,118 +1,110 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as
|
|
3
|
+
import * as Utils from "../Utils.res.mjs";
|
|
4
4
|
import * as Address from "../Address.res.mjs";
|
|
5
5
|
import * as EvmTypes from "../EvmTypes.res.mjs";
|
|
6
6
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
transactions: s.f("transactions", S$RescriptSchema.option(S$RescriptSchema.array(transactionParamsSchema))),
|
|
109
|
-
fieldSelection: s.f("field_selection", fieldSelectionSchema),
|
|
110
|
-
maxNumLogs: s.f("max_num_logs", S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
111
|
-
includeAllBlocks: s.f("include_all_blocks", S$RescriptSchema.option(S$RescriptSchema.bool))
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
var QueryTypes = {
|
|
8
|
+
let blockFieldOptionsSchema = S$RescriptSchema.$$enum([
|
|
9
|
+
"number",
|
|
10
|
+
"hash",
|
|
11
|
+
"parent_hash",
|
|
12
|
+
"nonce",
|
|
13
|
+
"sha3_uncles",
|
|
14
|
+
"logs_bloom",
|
|
15
|
+
"transactions_root",
|
|
16
|
+
"state_root",
|
|
17
|
+
"receipts_root",
|
|
18
|
+
"miner",
|
|
19
|
+
"difficulty",
|
|
20
|
+
"total_difficulty",
|
|
21
|
+
"extra_data",
|
|
22
|
+
"size",
|
|
23
|
+
"gas_limit",
|
|
24
|
+
"gas_used",
|
|
25
|
+
"timestamp",
|
|
26
|
+
"uncles",
|
|
27
|
+
"base_fee_per_gas"
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
let blockFieldSelectionSchema = S$RescriptSchema.array(blockFieldOptionsSchema);
|
|
31
|
+
|
|
32
|
+
let transactionFieldOptionsSchema = S$RescriptSchema.$$enum([
|
|
33
|
+
"block_hash",
|
|
34
|
+
"block_number",
|
|
35
|
+
"from",
|
|
36
|
+
"gas",
|
|
37
|
+
"gas_price",
|
|
38
|
+
"hash",
|
|
39
|
+
"input",
|
|
40
|
+
"nonce",
|
|
41
|
+
"to",
|
|
42
|
+
"transaction_index",
|
|
43
|
+
"value",
|
|
44
|
+
"v",
|
|
45
|
+
"r",
|
|
46
|
+
"s",
|
|
47
|
+
"max_priority_fee_per_gas",
|
|
48
|
+
"max_fee_per_gas",
|
|
49
|
+
"chain_id",
|
|
50
|
+
"cumulative_gas_used",
|
|
51
|
+
"effective_gas_price",
|
|
52
|
+
"gas_used",
|
|
53
|
+
"contract_address",
|
|
54
|
+
"logs_bloom",
|
|
55
|
+
"type",
|
|
56
|
+
"root",
|
|
57
|
+
"status",
|
|
58
|
+
"sighash"
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
let transactionFieldSelectionSchema = S$RescriptSchema.array(transactionFieldOptionsSchema);
|
|
62
|
+
|
|
63
|
+
let logFieldOptionsSchema = S$RescriptSchema.$$enum([
|
|
64
|
+
"removed",
|
|
65
|
+
"log_index",
|
|
66
|
+
"transaction_index",
|
|
67
|
+
"transaction_hash",
|
|
68
|
+
"block_hash",
|
|
69
|
+
"block_number",
|
|
70
|
+
"address",
|
|
71
|
+
"data",
|
|
72
|
+
"topic0",
|
|
73
|
+
"topic1",
|
|
74
|
+
"topic2",
|
|
75
|
+
"topic3"
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
let logFieldSelectionSchema = S$RescriptSchema.array(logFieldOptionsSchema);
|
|
79
|
+
|
|
80
|
+
let fieldSelectionSchema = S$RescriptSchema.object(s => ({
|
|
81
|
+
block: s.f("block", S$RescriptSchema.option(blockFieldSelectionSchema)),
|
|
82
|
+
transaction: s.f("transaction", S$RescriptSchema.option(transactionFieldSelectionSchema)),
|
|
83
|
+
log: s.f("log", S$RescriptSchema.option(logFieldSelectionSchema))
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
let logParamsSchema = S$RescriptSchema.object(s => ({
|
|
87
|
+
address: s.f("address", S$RescriptSchema.option(S$RescriptSchema.array(Address.schema))),
|
|
88
|
+
topics: s.f("topics", S$RescriptSchema.array(S$RescriptSchema.array(EvmTypes.Hex.schema)))
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
let transactionParamsSchema = S$RescriptSchema.object(s => ({
|
|
92
|
+
from: s.f("from", S$RescriptSchema.option(S$RescriptSchema.array(Address.schema))),
|
|
93
|
+
to: s.f("to", S$RescriptSchema.option(S$RescriptSchema.array(Address.schema))),
|
|
94
|
+
sighash: s.f("sighash", S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.string)))
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
let postQueryBodySchema = S$RescriptSchema.object(s => ({
|
|
98
|
+
fromBlock: s.f("from_block", S$RescriptSchema.int),
|
|
99
|
+
toBlockExclusive: s.f("to_block", S$RescriptSchema.option(S$RescriptSchema.int)),
|
|
100
|
+
logs: s.f("logs", S$RescriptSchema.option(S$RescriptSchema.array(logParamsSchema))),
|
|
101
|
+
transactions: s.f("transactions", S$RescriptSchema.option(S$RescriptSchema.array(transactionParamsSchema))),
|
|
102
|
+
fieldSelection: s.f("field_selection", fieldSelectionSchema),
|
|
103
|
+
maxNumLogs: s.f("max_num_logs", S$RescriptSchema.option(S$RescriptSchema.int)),
|
|
104
|
+
includeAllBlocks: s.f("include_all_blocks", S$RescriptSchema.option(S$RescriptSchema.bool))
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
let QueryTypes = {
|
|
116
108
|
blockFieldOptionsSchema: blockFieldOptionsSchema,
|
|
117
109
|
blockFieldSelectionSchema: blockFieldSelectionSchema,
|
|
118
110
|
transactionFieldOptionsSchema: transactionFieldOptionsSchema,
|
|
@@ -125,96 +117,86 @@ var QueryTypes = {
|
|
|
125
117
|
postQueryBodySchema: postQueryBodySchema
|
|
126
118
|
};
|
|
127
119
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
var queryResponseSchema = S$RescriptSchema.object(function (s) {
|
|
209
|
-
return {
|
|
210
|
-
data: s.f("data", S$RescriptSchema.array(dataSchema)),
|
|
211
|
-
archiveHeight: s.f("archive_height", S$RescriptSchema.$$int),
|
|
212
|
-
nextBlock: s.f("next_block", S$RescriptSchema.$$int),
|
|
213
|
-
totalTime: s.f("total_execution_time", S$RescriptSchema.$$int)
|
|
214
|
-
};
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
var ResponseTypes = {
|
|
120
|
+
let blockDataSchema = S$RescriptSchema.object(s => ({
|
|
121
|
+
number: s.f("number", S$RescriptSchema.option(S$RescriptSchema.int)),
|
|
122
|
+
hash: s.f("hash", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
123
|
+
parentHash: s.f("parent_hash", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
124
|
+
nonce: s.f("nonce", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.int))),
|
|
125
|
+
sha3Uncles: s.f("sha3_uncles", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
126
|
+
logsBloom: s.f("logs_bloom", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
127
|
+
transactionsRoot: s.f("transactions_root", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
128
|
+
stateRoot: s.f("state_root", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
129
|
+
receiptsRoot: s.f("receipts_root", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
130
|
+
miner: s.f("miner", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
131
|
+
difficulty: s.f("difficulty", S$RescriptSchema.option(S$RescriptSchema.$$null(Utils.$$BigInt.schema))),
|
|
132
|
+
totalDifficulty: s.f("total_difficulty", S$RescriptSchema.option(S$RescriptSchema.$$null(Utils.$$BigInt.schema))),
|
|
133
|
+
extraData: s.f("extra_data", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
134
|
+
size: s.f("size", S$RescriptSchema.option(Utils.$$BigInt.schema)),
|
|
135
|
+
gasLimit: s.f("gas_limit", S$RescriptSchema.option(Utils.$$BigInt.schema)),
|
|
136
|
+
gasUsed: s.f("gas_used", S$RescriptSchema.option(Utils.$$BigInt.schema)),
|
|
137
|
+
timestamp: s.f("timestamp", S$RescriptSchema.option(Utils.$$BigInt.schema)),
|
|
138
|
+
uncles: s.f("unclus", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
|
|
139
|
+
baseFeePerGas: s.f("base_fee_per_gas", S$RescriptSchema.option(S$RescriptSchema.$$null(Utils.$$BigInt.schema)))
|
|
140
|
+
}));
|
|
141
|
+
|
|
142
|
+
let transactionDataSchema = S$RescriptSchema.object(s => ({
|
|
143
|
+
blockHash: s.f("block_hash", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
144
|
+
blockNumber: s.f("block_number", S$RescriptSchema.option(S$RescriptSchema.int)),
|
|
145
|
+
from: s.f("from", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
|
|
146
|
+
gas: s.f("gas", S$RescriptSchema.option(Utils.$$BigInt.schema)),
|
|
147
|
+
gasPrice: s.f("gas_price", S$RescriptSchema.option(S$RescriptSchema.$$null(Utils.$$BigInt.schema))),
|
|
148
|
+
hash: s.f("hash", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
149
|
+
input: s.f("input", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
150
|
+
nonce: s.f("nonce", S$RescriptSchema.option(S$RescriptSchema.int)),
|
|
151
|
+
to: s.f("to", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
|
|
152
|
+
transactionIndex: s.f("transaction_index", S$RescriptSchema.option(S$RescriptSchema.int)),
|
|
153
|
+
value: s.f("value", S$RescriptSchema.option(Utils.$$BigInt.schema)),
|
|
154
|
+
v: s.f("v", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
|
|
155
|
+
r: s.f("r", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
|
|
156
|
+
s: s.f("s", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
|
|
157
|
+
maxPriorityFeePerGas: s.f("max_priority_fee_per_gas", S$RescriptSchema.option(S$RescriptSchema.$$null(Utils.$$BigInt.schema))),
|
|
158
|
+
maxFeePerGas: s.f("max_fee_per_gas", S$RescriptSchema.option(S$RescriptSchema.$$null(Utils.$$BigInt.schema))),
|
|
159
|
+
chainId: s.f("chain_id", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.int))),
|
|
160
|
+
cumulativeGasUsed: s.f("cumulative_gas_used", S$RescriptSchema.option(Utils.$$BigInt.schema)),
|
|
161
|
+
effectiveGasPrice: s.f("effective_gas_price", S$RescriptSchema.option(Utils.$$BigInt.schema)),
|
|
162
|
+
gasUsed: s.f("gas_used", S$RescriptSchema.option(Utils.$$BigInt.schema)),
|
|
163
|
+
contractAddress: s.f("contract_address", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
|
|
164
|
+
logsBoom: s.f("logs_bloom", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
165
|
+
type_: s.f("type", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.int))),
|
|
166
|
+
root: s.f("root", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
|
|
167
|
+
status: s.f("status", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.int))),
|
|
168
|
+
sighash: s.f("sighash", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string)))
|
|
169
|
+
}));
|
|
170
|
+
|
|
171
|
+
let logDataSchema = S$RescriptSchema.object(s => ({
|
|
172
|
+
removed: s.f("removed", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.bool))),
|
|
173
|
+
index: s.f("log_index", S$RescriptSchema.option(S$RescriptSchema.int)),
|
|
174
|
+
transactionIndex: s.f("transaction_index", S$RescriptSchema.option(S$RescriptSchema.int)),
|
|
175
|
+
transactionHash: s.f("transaction_hash", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
176
|
+
blockHash: s.f("block_hash", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
177
|
+
blockNumber: s.f("block_number", S$RescriptSchema.option(S$RescriptSchema.int)),
|
|
178
|
+
address: s.f("address", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
179
|
+
data: s.f("data", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
180
|
+
topic0: s.f("topic0", S$RescriptSchema.option(S$RescriptSchema.$$null(EvmTypes.Hex.schema))),
|
|
181
|
+
topic1: s.f("topic1", S$RescriptSchema.option(S$RescriptSchema.$$null(EvmTypes.Hex.schema))),
|
|
182
|
+
topic2: s.f("topic2", S$RescriptSchema.option(S$RescriptSchema.$$null(EvmTypes.Hex.schema))),
|
|
183
|
+
topic3: s.f("topic3", S$RescriptSchema.option(S$RescriptSchema.$$null(EvmTypes.Hex.schema)))
|
|
184
|
+
}));
|
|
185
|
+
|
|
186
|
+
let dataSchema = S$RescriptSchema.object(s => ({
|
|
187
|
+
blocks: s.f("blocks", S$RescriptSchema.option(S$RescriptSchema.array(blockDataSchema))),
|
|
188
|
+
transactions: s.f("transactions", S$RescriptSchema.option(S$RescriptSchema.array(transactionDataSchema))),
|
|
189
|
+
logs: s.f("logs", S$RescriptSchema.option(S$RescriptSchema.array(logDataSchema)))
|
|
190
|
+
}));
|
|
191
|
+
|
|
192
|
+
let queryResponseSchema = S$RescriptSchema.object(s => ({
|
|
193
|
+
data: s.f("data", S$RescriptSchema.array(dataSchema)),
|
|
194
|
+
archiveHeight: s.f("archive_height", S$RescriptSchema.int),
|
|
195
|
+
nextBlock: s.f("next_block", S$RescriptSchema.int),
|
|
196
|
+
totalTime: s.f("total_execution_time", S$RescriptSchema.int)
|
|
197
|
+
}));
|
|
198
|
+
|
|
199
|
+
let ResponseTypes = {
|
|
218
200
|
blockDataSchema: blockDataSchema,
|
|
219
201
|
transactionDataSchema: transactionDataSchema,
|
|
220
202
|
logDataSchema: logDataSchema,
|
|
@@ -224,44 +206,32 @@ var ResponseTypes = {
|
|
|
224
206
|
|
|
225
207
|
function queryRoute() {
|
|
226
208
|
return {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
responses: [(function (s) {
|
|
236
|
-
return s.data(queryResponseSchema);
|
|
237
|
-
})]
|
|
238
|
-
};
|
|
209
|
+
method: "POST",
|
|
210
|
+
path: "/query",
|
|
211
|
+
input: s => ({
|
|
212
|
+
query: s.body(postQueryBodySchema),
|
|
213
|
+
token: s.auth("Bearer")
|
|
214
|
+
}),
|
|
215
|
+
responses: [s => s.data(queryResponseSchema)]
|
|
216
|
+
};
|
|
239
217
|
}
|
|
240
218
|
|
|
241
219
|
function heightRoute() {
|
|
242
220
|
return {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return s.f("height", S$RescriptSchema.$$int);
|
|
252
|
-
}),
|
|
253
|
-
S$RescriptSchema.shape(S$RescriptSchema.string, (function (s) {
|
|
254
|
-
return s;
|
|
255
|
-
}))
|
|
256
|
-
]));
|
|
257
|
-
})]
|
|
258
|
-
};
|
|
221
|
+
method: "GET",
|
|
222
|
+
path: "/height",
|
|
223
|
+
input: s => s.auth("Bearer"),
|
|
224
|
+
responses: [s => s.data(S$RescriptSchema.union([
|
|
225
|
+
S$RescriptSchema.object(s => (s.f("height", S$RescriptSchema.int))),
|
|
226
|
+
S$RescriptSchema.shape(S$RescriptSchema.string, s => (s))
|
|
227
|
+
]))]
|
|
228
|
+
};
|
|
259
229
|
}
|
|
260
230
|
|
|
261
231
|
export {
|
|
262
|
-
QueryTypes
|
|
263
|
-
ResponseTypes
|
|
264
|
-
queryRoute
|
|
265
|
-
heightRoute
|
|
232
|
+
QueryTypes,
|
|
233
|
+
ResponseTypes,
|
|
234
|
+
queryRoute,
|
|
235
|
+
heightRoute,
|
|
266
236
|
}
|
|
267
237
|
/* blockFieldOptionsSchema Not a pure module */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
open Source
|
|
2
|
-
open Belt
|
|
3
2
|
|
|
4
3
|
type selectionConfig = {
|
|
5
4
|
getLogSelectionOrThrow: (
|
|
@@ -16,9 +15,9 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
16
15
|
let capitalizedBlockFields = Utils.Set.make()
|
|
17
16
|
let capitalizedTransactionFields = Utils.Set.make()
|
|
18
17
|
|
|
19
|
-
let staticTopicSelectionsByContract =
|
|
20
|
-
let dynamicEventFiltersByContract =
|
|
21
|
-
let dynamicWildcardEventFiltersByContract =
|
|
18
|
+
let staticTopicSelectionsByContract = Dict.make()
|
|
19
|
+
let dynamicEventFiltersByContract = Dict.make()
|
|
20
|
+
let dynamicWildcardEventFiltersByContract = Dict.make()
|
|
22
21
|
let noAddressesTopicSelections = []
|
|
23
22
|
let contractNames = Utils.Set.make()
|
|
24
23
|
|
|
@@ -64,7 +63,7 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
64
63
|
}
|
|
65
64
|
} else {
|
|
66
65
|
noAddressesTopicSelections
|
|
67
|
-
->
|
|
66
|
+
->Array.pushMany(
|
|
68
67
|
switch eventFilters {
|
|
69
68
|
| Static(s) => s
|
|
70
69
|
| Dynamic(fn) => fn([])
|
|
@@ -108,10 +107,7 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
108
107
|
| None => ()
|
|
109
108
|
| Some(fns) =>
|
|
110
109
|
logSelections->Array.push(
|
|
111
|
-
LogSelection.make(
|
|
112
|
-
~addresses,
|
|
113
|
-
~topicSelections=fns->Array.flatMapU(fn => fn(addresses)),
|
|
114
|
-
),
|
|
110
|
+
LogSelection.make(~addresses, ~topicSelections=fns->Array.flatMap(fn => fn(addresses))),
|
|
115
111
|
)
|
|
116
112
|
}
|
|
117
113
|
switch dynamicWildcardEventFiltersByContract->Utils.Dict.dangerouslyGetNonOption(
|
|
@@ -122,7 +118,7 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
122
118
|
logSelections->Array.push(
|
|
123
119
|
LogSelection.make(
|
|
124
120
|
~addresses=[],
|
|
125
|
-
~topicSelections=fns->Array.
|
|
121
|
+
~topicSelections=fns->Array.flatMap(fn => fn(addresses)),
|
|
126
122
|
),
|
|
127
123
|
)
|
|
128
124
|
}
|
|
@@ -176,7 +172,7 @@ let make = (
|
|
|
176
172
|
let apiToken = switch apiToken {
|
|
177
173
|
| Some(token) => token
|
|
178
174
|
| None =>
|
|
179
|
-
|
|
175
|
+
JsError.throwWithMessage(`An API token is required for using HyperSync as a data-source.
|
|
180
176
|
Set the ENVIO_API_TOKEN environment variable in your .env file.
|
|
181
177
|
Learn more or get a free API token at: https://envio.dev/app/api-tokens`)
|
|
182
178
|
}
|
|
@@ -245,7 +241,7 @@ Learn more or get a free API token at: https://envio.dev/app/api-tokens`)
|
|
|
245
241
|
~fromBlock,
|
|
246
242
|
~toBlock,
|
|
247
243
|
~addressesByContractName,
|
|
248
|
-
~
|
|
244
|
+
~indexingAddresses,
|
|
249
245
|
~knownHeight,
|
|
250
246
|
~partitionId as _,
|
|
251
247
|
~selection,
|
|
@@ -280,11 +276,11 @@ Learn more or get a free API token at: https://envio.dev/app/api-tokens`)
|
|
|
280
276
|
~nonOptionalTransactionFieldNames=selectionConfig.nonOptionalTransactionFieldNames,
|
|
281
277
|
) catch {
|
|
282
278
|
| HyperSync.GetLogs.Error(error) =>
|
|
283
|
-
|
|
279
|
+
throw(
|
|
284
280
|
Source.GetItemsError(
|
|
285
281
|
Source.FailedGettingItems({
|
|
286
282
|
exn: %raw(`null`),
|
|
287
|
-
attemptedToBlock: toBlock->Option.
|
|
283
|
+
attemptedToBlock: toBlock->Option.getOr(knownHeight),
|
|
288
284
|
retry: switch error {
|
|
289
285
|
| WrongInstance =>
|
|
290
286
|
let backoffMillis = switch retry {
|
|
@@ -297,7 +293,7 @@ Learn more or get a free API token at: https://envio.dev/app/api-tokens`)
|
|
|
297
293
|
})
|
|
298
294
|
| UnexpectedMissingParams({missingParams}) =>
|
|
299
295
|
ImpossibleForTheQuery({
|
|
300
|
-
message: `Source returned invalid data with missing required fields: ${missingParams->
|
|
296
|
+
message: `Source returned invalid data with missing required fields: ${missingParams->Array.joinUnsafe(
|
|
301
297
|
", ",
|
|
302
298
|
)}`,
|
|
303
299
|
})
|
|
@@ -306,11 +302,11 @@ Learn more or get a free API token at: https://envio.dev/app/api-tokens`)
|
|
|
306
302
|
),
|
|
307
303
|
)
|
|
308
304
|
| exn =>
|
|
309
|
-
|
|
305
|
+
throw(
|
|
310
306
|
Source.GetItemsError(
|
|
311
307
|
Source.FailedGettingItems({
|
|
312
308
|
exn,
|
|
313
|
-
attemptedToBlock: toBlock->Option.
|
|
309
|
+
attemptedToBlock: toBlock->Option.getOr(knownHeight),
|
|
314
310
|
retry: WithBackoff({
|
|
315
311
|
message: `Unexpected issue while fetching events from HyperSync client. Attempt a retry.`,
|
|
316
312
|
backoffMillis: switch retry {
|
|
@@ -440,16 +436,16 @@ Learn more or get a free API token at: https://envio.dev/app/api-tokens`)
|
|
|
440
436
|
~sighash=topic0->EvmTypes.Hex.toString,
|
|
441
437
|
~topicCount=log.topics->Array.length,
|
|
442
438
|
),
|
|
443
|
-
~
|
|
439
|
+
~indexingAddresses,
|
|
444
440
|
~contractAddress=log.address,
|
|
445
441
|
~blockNumber=block.number->Belt.Option.getUnsafe,
|
|
446
442
|
)
|
|
447
|
-
let maybeDecodedEvent = parsedEvents->
|
|
443
|
+
let maybeDecodedEvent = parsedEvents->Array.getUnsafe(index)
|
|
448
444
|
|
|
449
445
|
switch (maybeEventConfig, maybeDecodedEvent) {
|
|
450
446
|
| (Some(eventConfig), Value(decoded)) =>
|
|
451
447
|
parsedQueueItems
|
|
452
|
-
->
|
|
448
|
+
->Array.push(
|
|
453
449
|
makeEventBatchQueueItem(
|
|
454
450
|
item,
|
|
455
451
|
~params=decoded->eventConfig.convertHyperSyncEventArgs,
|
|
@@ -533,7 +529,7 @@ Learn more or get a free API token at: https://envio.dev/app/api-tokens`)
|
|
|
533
529
|
// So just block forever
|
|
534
530
|
let _ = await Promise.make((_, _) => ())
|
|
535
531
|
0
|
|
536
|
-
| ErrorMessage(m) =>
|
|
532
|
+
| ErrorMessage(m) => JsError.throwWithMessage(m)
|
|
537
533
|
}
|
|
538
534
|
let seconds = timerRef->Hrtime.timeSince->Hrtime.toSecondsFloat
|
|
539
535
|
Prometheus.SourceRequestCount.increment(
|