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.
Files changed (220) hide show
  1. package/README.md +3 -3
  2. package/bin.mjs +2 -48
  3. package/evm.schema.json +67 -0
  4. package/fuel.schema.json +67 -0
  5. package/index.d.ts +822 -38
  6. package/index.js +5 -3
  7. package/package.json +10 -8
  8. package/rescript.json +5 -9
  9. package/src/Address.res +4 -5
  10. package/src/Address.res.mjs +9 -12
  11. package/src/Api.res +15 -0
  12. package/src/Api.res.mjs +20 -0
  13. package/src/Batch.res +32 -34
  14. package/src/Batch.res.mjs +172 -187
  15. package/src/Bin.res +89 -0
  16. package/src/Bin.res.mjs +97 -0
  17. package/src/ChainFetcher.res +33 -57
  18. package/src/ChainFetcher.res.mjs +197 -227
  19. package/src/ChainManager.res +6 -14
  20. package/src/ChainManager.res.mjs +74 -85
  21. package/src/ChainMap.res +14 -16
  22. package/src/ChainMap.res.mjs +38 -38
  23. package/src/Config.res +193 -135
  24. package/src/Config.res.mjs +566 -592
  25. package/src/Core.res +182 -0
  26. package/src/Core.res.mjs +207 -0
  27. package/src/Ecosystem.res +25 -4
  28. package/src/Ecosystem.res.mjs +12 -13
  29. package/src/Env.res +20 -13
  30. package/src/Env.res.mjs +124 -113
  31. package/src/EnvSafe.res +269 -0
  32. package/src/EnvSafe.res.mjs +296 -0
  33. package/src/EnvSafe.resi +18 -0
  34. package/src/Envio.res +37 -26
  35. package/src/Envio.res.mjs +59 -60
  36. package/src/ErrorHandling.res +2 -2
  37. package/src/ErrorHandling.res.mjs +15 -15
  38. package/src/EventConfigBuilder.res +219 -81
  39. package/src/EventConfigBuilder.res.mjs +259 -202
  40. package/src/EventProcessing.res +27 -38
  41. package/src/EventProcessing.res.mjs +165 -183
  42. package/src/EventUtils.res +11 -11
  43. package/src/EventUtils.res.mjs +21 -22
  44. package/src/EvmTypes.res +0 -1
  45. package/src/EvmTypes.res.mjs +5 -5
  46. package/src/FetchState.res +360 -256
  47. package/src/FetchState.res.mjs +958 -914
  48. package/src/GlobalState.res +365 -351
  49. package/src/GlobalState.res.mjs +958 -992
  50. package/src/GlobalStateManager.res +1 -2
  51. package/src/GlobalStateManager.res.mjs +36 -44
  52. package/src/HandlerLoader.res +107 -23
  53. package/src/HandlerLoader.res.mjs +128 -38
  54. package/src/HandlerRegister.res +127 -103
  55. package/src/HandlerRegister.res.mjs +164 -164
  56. package/src/HandlerRegister.resi +12 -4
  57. package/src/Hasura.res +35 -22
  58. package/src/Hasura.res.mjs +158 -167
  59. package/src/InMemoryStore.res +20 -27
  60. package/src/InMemoryStore.res.mjs +64 -80
  61. package/src/InMemoryTable.res +34 -39
  62. package/src/InMemoryTable.res.mjs +165 -170
  63. package/src/Internal.res +52 -33
  64. package/src/Internal.res.mjs +84 -81
  65. package/src/LazyLoader.res.mjs +55 -61
  66. package/src/LoadLayer.res +77 -78
  67. package/src/LoadLayer.res.mjs +160 -189
  68. package/src/LoadManager.res +16 -21
  69. package/src/LoadManager.res.mjs +79 -84
  70. package/src/LogSelection.res +236 -68
  71. package/src/LogSelection.res.mjs +211 -141
  72. package/src/Logging.res +13 -9
  73. package/src/Logging.res.mjs +130 -143
  74. package/src/Main.res +430 -51
  75. package/src/Main.res.mjs +530 -271
  76. package/src/Persistence.res +80 -84
  77. package/src/Persistence.res.mjs +131 -132
  78. package/src/PgStorage.res +294 -167
  79. package/src/PgStorage.res.mjs +799 -817
  80. package/src/Prometheus.res +50 -58
  81. package/src/Prometheus.res.mjs +345 -373
  82. package/src/ReorgDetection.res +22 -24
  83. package/src/ReorgDetection.res.mjs +100 -106
  84. package/src/SafeCheckpointTracking.res +7 -7
  85. package/src/SafeCheckpointTracking.res.mjs +40 -43
  86. package/src/SimulateItems.res +41 -49
  87. package/src/SimulateItems.res.mjs +257 -272
  88. package/src/Sink.res +2 -2
  89. package/src/Sink.res.mjs +22 -26
  90. package/src/TableIndices.res +1 -2
  91. package/src/TableIndices.res.mjs +42 -48
  92. package/src/TestIndexer.res +196 -189
  93. package/src/TestIndexer.res.mjs +536 -536
  94. package/src/TestIndexerProxyStorage.res +16 -16
  95. package/src/TestIndexerProxyStorage.res.mjs +99 -122
  96. package/src/TestIndexerWorker.res +4 -0
  97. package/src/TestIndexerWorker.res.mjs +7 -0
  98. package/src/Throttler.res +3 -3
  99. package/src/Throttler.res.mjs +23 -24
  100. package/src/Time.res +1 -1
  101. package/src/Time.res.mjs +18 -21
  102. package/src/TopicFilter.res +3 -3
  103. package/src/TopicFilter.res.mjs +29 -30
  104. package/src/UserContext.res +93 -54
  105. package/src/UserContext.res.mjs +197 -182
  106. package/src/Utils.res +141 -86
  107. package/src/Utils.res.mjs +334 -295
  108. package/src/bindings/BigDecimal.res +0 -2
  109. package/src/bindings/BigDecimal.res.mjs +19 -23
  110. package/src/bindings/ClickHouse.res +28 -27
  111. package/src/bindings/ClickHouse.res.mjs +243 -240
  112. package/src/bindings/DateFns.res +11 -11
  113. package/src/bindings/DateFns.res.mjs +7 -7
  114. package/src/bindings/EventSource.res.mjs +2 -2
  115. package/src/bindings/Express.res +2 -5
  116. package/src/bindings/Hrtime.res +2 -2
  117. package/src/bindings/Hrtime.res.mjs +30 -32
  118. package/src/bindings/Lodash.res.mjs +1 -1
  119. package/src/bindings/NodeJs.res +14 -9
  120. package/src/bindings/NodeJs.res.mjs +20 -20
  121. package/src/bindings/Pino.res +8 -10
  122. package/src/bindings/Pino.res.mjs +40 -43
  123. package/src/bindings/Postgres.res +7 -5
  124. package/src/bindings/Postgres.res.mjs +9 -9
  125. package/src/bindings/PromClient.res +17 -2
  126. package/src/bindings/PromClient.res.mjs +30 -7
  127. package/src/bindings/SDSL.res.mjs +2 -2
  128. package/src/bindings/Viem.res +4 -4
  129. package/src/bindings/Viem.res.mjs +20 -22
  130. package/src/bindings/Vitest.res +1 -1
  131. package/src/bindings/Vitest.res.mjs +2 -2
  132. package/src/bindings/WebSocket.res +1 -1
  133. package/src/db/EntityHistory.res +9 -3
  134. package/src/db/EntityHistory.res.mjs +84 -59
  135. package/src/db/InternalTable.res +62 -60
  136. package/src/db/InternalTable.res.mjs +271 -203
  137. package/src/db/Schema.res +1 -2
  138. package/src/db/Schema.res.mjs +28 -32
  139. package/src/db/Table.res +28 -27
  140. package/src/db/Table.res.mjs +276 -292
  141. package/src/sources/EventRouter.res +21 -16
  142. package/src/sources/EventRouter.res.mjs +55 -57
  143. package/src/sources/Evm.res +17 -1
  144. package/src/sources/Evm.res.mjs +16 -8
  145. package/src/sources/EvmChain.res +15 -17
  146. package/src/sources/EvmChain.res.mjs +40 -42
  147. package/src/sources/Fuel.res +14 -1
  148. package/src/sources/Fuel.res.mjs +16 -8
  149. package/src/sources/FuelSDK.res +1 -1
  150. package/src/sources/FuelSDK.res.mjs +6 -8
  151. package/src/sources/HyperFuel.res +8 -10
  152. package/src/sources/HyperFuel.res.mjs +113 -123
  153. package/src/sources/HyperFuelClient.res.mjs +6 -7
  154. package/src/sources/HyperFuelSource.res +19 -20
  155. package/src/sources/HyperFuelSource.res.mjs +339 -356
  156. package/src/sources/HyperSync.res +11 -13
  157. package/src/sources/HyperSync.res.mjs +206 -220
  158. package/src/sources/HyperSyncClient.res +5 -7
  159. package/src/sources/HyperSyncClient.res.mjs +70 -75
  160. package/src/sources/HyperSyncHeightStream.res +8 -9
  161. package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
  162. package/src/sources/HyperSyncJsonApi.res +18 -15
  163. package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
  164. package/src/sources/HyperSyncSource.res +17 -21
  165. package/src/sources/HyperSyncSource.res.mjs +268 -290
  166. package/src/sources/Rpc.res +5 -5
  167. package/src/sources/Rpc.res.mjs +168 -192
  168. package/src/sources/RpcSource.res +166 -167
  169. package/src/sources/RpcSource.res.mjs +972 -1046
  170. package/src/sources/RpcWebSocketHeightStream.res +10 -11
  171. package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
  172. package/src/sources/SimulateSource.res +1 -1
  173. package/src/sources/SimulateSource.res.mjs +35 -38
  174. package/src/sources/Source.res +1 -1
  175. package/src/sources/Source.res.mjs +3 -3
  176. package/src/sources/SourceManager.res +39 -20
  177. package/src/sources/SourceManager.res.mjs +340 -371
  178. package/src/sources/SourceManager.resi +2 -1
  179. package/src/sources/Svm.res +12 -5
  180. package/src/sources/Svm.res.mjs +44 -41
  181. package/src/tui/Tui.res +23 -12
  182. package/src/tui/Tui.res.mjs +292 -290
  183. package/src/tui/bindings/Ink.res +2 -4
  184. package/src/tui/bindings/Ink.res.mjs +35 -41
  185. package/src/tui/components/BufferedProgressBar.res +7 -7
  186. package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
  187. package/src/tui/components/CustomHooks.res +1 -2
  188. package/src/tui/components/CustomHooks.res.mjs +102 -122
  189. package/src/tui/components/Messages.res +1 -2
  190. package/src/tui/components/Messages.res.mjs +38 -42
  191. package/src/tui/components/SyncETA.res +10 -11
  192. package/src/tui/components/SyncETA.res.mjs +178 -196
  193. package/src/tui/components/TuiData.res +1 -1
  194. package/src/tui/components/TuiData.res.mjs +7 -6
  195. package/src/vendored/Rest.res +52 -66
  196. package/src/vendored/Rest.res.mjs +324 -364
  197. package/svm.schema.json +67 -0
  198. package/src/Address.gen.ts +0 -8
  199. package/src/Config.gen.ts +0 -19
  200. package/src/Envio.gen.ts +0 -55
  201. package/src/EvmTypes.gen.ts +0 -6
  202. package/src/InMemoryStore.gen.ts +0 -6
  203. package/src/Internal.gen.ts +0 -64
  204. package/src/PgStorage.gen.ts +0 -10
  205. package/src/PgStorage.res.d.mts +0 -5
  206. package/src/Types.ts +0 -56
  207. package/src/bindings/BigDecimal.gen.ts +0 -14
  208. package/src/bindings/BigDecimal.res.d.mts +0 -5
  209. package/src/bindings/BigInt.gen.ts +0 -10
  210. package/src/bindings/BigInt.res +0 -70
  211. package/src/bindings/BigInt.res.d.mts +0 -5
  212. package/src/bindings/BigInt.res.mjs +0 -154
  213. package/src/bindings/Ethers.res.d.mts +0 -5
  214. package/src/bindings/Pino.gen.ts +0 -17
  215. package/src/bindings/Postgres.gen.ts +0 -8
  216. package/src/bindings/Postgres.res.d.mts +0 -5
  217. package/src/bindings/Promise.res +0 -67
  218. package/src/bindings/Promise.res.mjs +0 -26
  219. package/src/db/InternalTable.gen.ts +0 -36
  220. 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 $$BigInt from "../bindings/BigInt.res.mjs";
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
- var 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
- var blockFieldSelectionSchema = S$RescriptSchema.array(blockFieldOptionsSchema);
31
-
32
- var 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
- var transactionFieldSelectionSchema = S$RescriptSchema.array(transactionFieldOptionsSchema);
62
-
63
- var 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
- var logFieldSelectionSchema = S$RescriptSchema.array(logFieldOptionsSchema);
79
-
80
- var fieldSelectionSchema = S$RescriptSchema.object(function (s) {
81
- return {
82
- block: s.f("block", S$RescriptSchema.option(blockFieldSelectionSchema)),
83
- transaction: s.f("transaction", S$RescriptSchema.option(transactionFieldSelectionSchema)),
84
- log: s.f("log", S$RescriptSchema.option(logFieldSelectionSchema))
85
- };
86
- });
87
-
88
- var logParamsSchema = S$RescriptSchema.object(function (s) {
89
- return {
90
- address: s.f("address", S$RescriptSchema.option(S$RescriptSchema.array(Address.schema))),
91
- topics: s.f("topics", S$RescriptSchema.array(S$RescriptSchema.array(EvmTypes.Hex.schema)))
92
- };
93
- });
94
-
95
- var transactionParamsSchema = S$RescriptSchema.object(function (s) {
96
- return {
97
- from: s.f("from", S$RescriptSchema.option(S$RescriptSchema.array(Address.schema))),
98
- to: s.f("to", S$RescriptSchema.option(S$RescriptSchema.array(Address.schema))),
99
- sighash: s.f("sighash", S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.string)))
100
- };
101
- });
102
-
103
- var postQueryBodySchema = S$RescriptSchema.object(function (s) {
104
- return {
105
- fromBlock: s.f("from_block", S$RescriptSchema.$$int),
106
- toBlockExclusive: s.f("to_block", S$RescriptSchema.option(S$RescriptSchema.$$int)),
107
- logs: s.f("logs", S$RescriptSchema.option(S$RescriptSchema.array(logParamsSchema))),
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
- var blockDataSchema = S$RescriptSchema.object(function (s) {
129
- return {
130
- number: s.f("number", S$RescriptSchema.option(S$RescriptSchema.$$int)),
131
- hash: s.f("hash", S$RescriptSchema.option(S$RescriptSchema.string)),
132
- parentHash: s.f("parent_hash", S$RescriptSchema.option(S$RescriptSchema.string)),
133
- nonce: s.f("nonce", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.$$int))),
134
- sha3Uncles: s.f("sha3_uncles", S$RescriptSchema.option(S$RescriptSchema.string)),
135
- logsBloom: s.f("logs_bloom", S$RescriptSchema.option(S$RescriptSchema.string)),
136
- transactionsRoot: s.f("transactions_root", S$RescriptSchema.option(S$RescriptSchema.string)),
137
- stateRoot: s.f("state_root", S$RescriptSchema.option(S$RescriptSchema.string)),
138
- receiptsRoot: s.f("receipts_root", S$RescriptSchema.option(S$RescriptSchema.string)),
139
- miner: s.f("miner", S$RescriptSchema.option(S$RescriptSchema.string)),
140
- difficulty: s.f("difficulty", S$RescriptSchema.option(S$RescriptSchema.$$null($$BigInt.schema))),
141
- totalDifficulty: s.f("total_difficulty", S$RescriptSchema.option(S$RescriptSchema.$$null($$BigInt.schema))),
142
- extraData: s.f("extra_data", S$RescriptSchema.option(S$RescriptSchema.string)),
143
- size: s.f("size", S$RescriptSchema.option($$BigInt.schema)),
144
- gasLimit: s.f("gas_limit", S$RescriptSchema.option($$BigInt.schema)),
145
- gasUsed: s.f("gas_used", S$RescriptSchema.option($$BigInt.schema)),
146
- timestamp: s.f("timestamp", S$RescriptSchema.option($$BigInt.schema)),
147
- uncles: s.f("unclus", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
148
- baseFeePerGas: s.f("base_fee_per_gas", S$RescriptSchema.option(S$RescriptSchema.$$null($$BigInt.schema)))
149
- };
150
- });
151
-
152
- var transactionDataSchema = S$RescriptSchema.object(function (s) {
153
- return {
154
- blockHash: s.f("block_hash", S$RescriptSchema.option(S$RescriptSchema.string)),
155
- blockNumber: s.f("block_number", S$RescriptSchema.option(S$RescriptSchema.$$int)),
156
- from: s.f("from", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
157
- gas: s.f("gas", S$RescriptSchema.option($$BigInt.schema)),
158
- gasPrice: s.f("gas_price", S$RescriptSchema.option(S$RescriptSchema.$$null($$BigInt.schema))),
159
- hash: s.f("hash", S$RescriptSchema.option(S$RescriptSchema.string)),
160
- input: s.f("input", S$RescriptSchema.option(S$RescriptSchema.string)),
161
- nonce: s.f("nonce", S$RescriptSchema.option(S$RescriptSchema.$$int)),
162
- to: s.f("to", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
163
- transactionIndex: s.f("transaction_index", S$RescriptSchema.option(S$RescriptSchema.$$int)),
164
- value: s.f("value", S$RescriptSchema.option($$BigInt.schema)),
165
- v: s.f("v", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
166
- r: s.f("r", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
167
- s: s.f("s", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
168
- maxPriorityFeePerGas: s.f("max_priority_fee_per_gas", S$RescriptSchema.option(S$RescriptSchema.$$null($$BigInt.schema))),
169
- maxFeePerGas: s.f("max_fee_per_gas", S$RescriptSchema.option(S$RescriptSchema.$$null($$BigInt.schema))),
170
- chainId: s.f("chain_id", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.$$int))),
171
- cumulativeGasUsed: s.f("cumulative_gas_used", S$RescriptSchema.option($$BigInt.schema)),
172
- effectiveGasPrice: s.f("effective_gas_price", S$RescriptSchema.option($$BigInt.schema)),
173
- gasUsed: s.f("gas_used", S$RescriptSchema.option($$BigInt.schema)),
174
- contractAddress: s.f("contract_address", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
175
- logsBoom: s.f("logs_bloom", S$RescriptSchema.option(S$RescriptSchema.string)),
176
- type_: s.f("type", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.$$int))),
177
- root: s.f("root", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string))),
178
- status: s.f("status", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.$$int))),
179
- sighash: s.f("sighash", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.string)))
180
- };
181
- });
182
-
183
- var logDataSchema = S$RescriptSchema.object(function (s) {
184
- return {
185
- removed: s.f("removed", S$RescriptSchema.option(S$RescriptSchema.$$null(S$RescriptSchema.bool))),
186
- index: s.f("log_index", S$RescriptSchema.option(S$RescriptSchema.$$int)),
187
- transactionIndex: s.f("transaction_index", S$RescriptSchema.option(S$RescriptSchema.$$int)),
188
- transactionHash: s.f("transaction_hash", S$RescriptSchema.option(S$RescriptSchema.string)),
189
- blockHash: s.f("block_hash", S$RescriptSchema.option(S$RescriptSchema.string)),
190
- blockNumber: s.f("block_number", S$RescriptSchema.option(S$RescriptSchema.$$int)),
191
- address: s.f("address", S$RescriptSchema.option(S$RescriptSchema.string)),
192
- data: s.f("data", S$RescriptSchema.option(S$RescriptSchema.string)),
193
- topic0: s.f("topic0", S$RescriptSchema.option(S$RescriptSchema.$$null(EvmTypes.Hex.schema))),
194
- topic1: s.f("topic1", S$RescriptSchema.option(S$RescriptSchema.$$null(EvmTypes.Hex.schema))),
195
- topic2: s.f("topic2", S$RescriptSchema.option(S$RescriptSchema.$$null(EvmTypes.Hex.schema))),
196
- topic3: s.f("topic3", S$RescriptSchema.option(S$RescriptSchema.$$null(EvmTypes.Hex.schema)))
197
- };
198
- });
199
-
200
- var dataSchema = S$RescriptSchema.object(function (s) {
201
- return {
202
- blocks: s.f("blocks", S$RescriptSchema.option(S$RescriptSchema.array(blockDataSchema))),
203
- transactions: s.f("transactions", S$RescriptSchema.option(S$RescriptSchema.array(transactionDataSchema))),
204
- logs: s.f("logs", S$RescriptSchema.option(S$RescriptSchema.array(logDataSchema)))
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
- method: "POST",
228
- path: "/query",
229
- input: (function (s) {
230
- return {
231
- query: s.body(postQueryBodySchema),
232
- token: s.auth("Bearer")
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
- method: "GET",
244
- path: "/height",
245
- input: (function (s) {
246
- return s.auth("Bearer");
247
- }),
248
- responses: [(function (s) {
249
- return s.data(S$RescriptSchema.union([
250
- S$RescriptSchema.object(function (s) {
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 = Js.Dict.empty()
20
- let dynamicEventFiltersByContract = Js.Dict.empty()
21
- let dynamicWildcardEventFiltersByContract = Js.Dict.empty()
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
- ->Js.Array2.pushMany(
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.flatMapU(fn => fn(addresses)),
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
- Js.Exn.raiseError(`An API token is required for using HyperSync as a data-source.
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
- ~indexingContracts,
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
- raise(
279
+ throw(
284
280
  Source.GetItemsError(
285
281
  Source.FailedGettingItems({
286
282
  exn: %raw(`null`),
287
- attemptedToBlock: toBlock->Option.getWithDefault(knownHeight),
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->Js.Array2.joinWith(
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
- raise(
305
+ throw(
310
306
  Source.GetItemsError(
311
307
  Source.FailedGettingItems({
312
308
  exn,
313
- attemptedToBlock: toBlock->Option.getWithDefault(knownHeight),
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
- ~indexingContracts,
439
+ ~indexingAddresses,
444
440
  ~contractAddress=log.address,
445
441
  ~blockNumber=block.number->Belt.Option.getUnsafe,
446
442
  )
447
- let maybeDecodedEvent = parsedEvents->Js.Array2.unsafe_get(index)
443
+ let maybeDecodedEvent = parsedEvents->Array.getUnsafe(index)
448
444
 
449
445
  switch (maybeEventConfig, maybeDecodedEvent) {
450
446
  | (Some(eventConfig), Value(decoded)) =>
451
447
  parsedQueueItems
452
- ->Js.Array2.push(
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) => Js.Exn.raiseError(m)
532
+ | ErrorMessage(m) => JsError.throwWithMessage(m)
537
533
  }
538
534
  let seconds = timerRef->Hrtime.timeSince->Hrtime.toSecondsFloat
539
535
  Prometheus.SourceRequestCount.increment(