envio 3.1.2 → 3.2.1

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 (134) hide show
  1. package/evm.schema.json +83 -11
  2. package/fuel.schema.json +83 -11
  3. package/index.d.ts +184 -3
  4. package/package.json +6 -6
  5. package/src/Batch.res +2 -2
  6. package/src/ChainFetcher.res +27 -3
  7. package/src/ChainFetcher.res.mjs +17 -3
  8. package/src/ChainManager.res +163 -0
  9. package/src/ChainManager.res.mjs +136 -0
  10. package/src/Config.res +213 -30
  11. package/src/Config.res.mjs +102 -41
  12. package/src/Core.res +16 -10
  13. package/src/Ecosystem.res +0 -3
  14. package/src/Env.res +2 -2
  15. package/src/Env.res.mjs +2 -2
  16. package/src/Envio.res +101 -2
  17. package/src/Envio.res.mjs +2 -3
  18. package/src/EventConfigBuilder.res +87 -0
  19. package/src/EventConfigBuilder.res.mjs +53 -0
  20. package/src/EventUtils.res +2 -2
  21. package/src/FetchState.res +63 -67
  22. package/src/FetchState.res.mjs +44 -42
  23. package/src/GlobalState.res +219 -363
  24. package/src/GlobalState.res.mjs +314 -491
  25. package/src/GlobalStateManager.res +49 -59
  26. package/src/GlobalStateManager.res.mjs +5 -4
  27. package/src/GlobalStateManager.resi +1 -1
  28. package/src/HandlerLoader.res +18 -2
  29. package/src/HandlerLoader.res.mjs +16 -34
  30. package/src/HandlerRegister.res +9 -9
  31. package/src/HandlerRegister.res.mjs +9 -9
  32. package/src/Hasura.res +102 -32
  33. package/src/Hasura.res.mjs +88 -34
  34. package/src/InMemoryStore.res +10 -1
  35. package/src/InMemoryStore.res.mjs +4 -1
  36. package/src/InMemoryTable.res +83 -136
  37. package/src/InMemoryTable.res.mjs +57 -86
  38. package/src/Internal.res +70 -5
  39. package/src/Internal.res.mjs +2 -8
  40. package/src/LazyLoader.res +2 -2
  41. package/src/LazyLoader.res.mjs +3 -3
  42. package/src/LoadLayer.res +47 -60
  43. package/src/LoadLayer.res.mjs +28 -50
  44. package/src/LoadLayer.resi +2 -5
  45. package/src/LogSelection.res +90 -21
  46. package/src/LogSelection.res.mjs +72 -21
  47. package/src/Logging.res +1 -1
  48. package/src/Main.res +61 -2
  49. package/src/Main.res.mjs +37 -1
  50. package/src/Persistence.res +3 -16
  51. package/src/PgStorage.res +125 -114
  52. package/src/PgStorage.res.mjs +112 -95
  53. package/src/Ports.res +5 -0
  54. package/src/Ports.res.mjs +9 -0
  55. package/src/Prometheus.res +3 -3
  56. package/src/Prometheus.res.mjs +4 -4
  57. package/src/ReorgDetection.res +4 -4
  58. package/src/ReorgDetection.res.mjs +4 -5
  59. package/src/SafeCheckpointTracking.res +16 -16
  60. package/src/SafeCheckpointTracking.res.mjs +2 -2
  61. package/src/SimulateItems.res +10 -14
  62. package/src/SimulateItems.res.mjs +5 -2
  63. package/src/Sink.res +1 -1
  64. package/src/Sink.res.mjs +1 -2
  65. package/src/SvmTypes.res +9 -0
  66. package/src/SvmTypes.res.mjs +14 -0
  67. package/src/TestIndexer.res +35 -68
  68. package/src/TestIndexer.res.mjs +17 -48
  69. package/src/TestIndexerProxyStorage.res +23 -23
  70. package/src/TestIndexerProxyStorage.res.mjs +12 -15
  71. package/src/Throttler.res +2 -2
  72. package/src/Time.res +2 -2
  73. package/src/Time.res.mjs +2 -2
  74. package/src/UserContext.res +19 -118
  75. package/src/UserContext.res.mjs +10 -66
  76. package/src/Utils.res +15 -15
  77. package/src/Utils.res.mjs +7 -8
  78. package/src/adapters/MarkBatchProcessedAdapter.res +5 -0
  79. package/src/adapters/MarkBatchProcessedAdapter.res.mjs +14 -0
  80. package/src/bindings/BigDecimal.res +1 -1
  81. package/src/bindings/BigDecimal.res.mjs +2 -2
  82. package/src/bindings/ClickHouse.res +8 -6
  83. package/src/bindings/ClickHouse.res.mjs +5 -5
  84. package/src/bindings/Hrtime.res +1 -1
  85. package/src/bindings/Pino.res +2 -2
  86. package/src/bindings/Pino.res.mjs +3 -4
  87. package/src/db/EntityFilter.res +410 -0
  88. package/src/db/EntityFilter.res.mjs +424 -0
  89. package/src/db/EntityHistory.res +1 -1
  90. package/src/db/EntityHistory.res.mjs +1 -1
  91. package/src/db/InternalTable.res +10 -10
  92. package/src/db/InternalTable.res.mjs +41 -45
  93. package/src/db/Schema.res +2 -2
  94. package/src/db/Schema.res.mjs +3 -3
  95. package/src/db/Table.res +106 -22
  96. package/src/db/Table.res.mjs +84 -35
  97. package/src/sources/EventRouter.res +67 -2
  98. package/src/sources/EventRouter.res.mjs +45 -3
  99. package/src/sources/Evm.res +0 -7
  100. package/src/sources/Evm.res.mjs +0 -15
  101. package/src/sources/EvmChain.res +1 -1
  102. package/src/sources/EvmChain.res.mjs +1 -2
  103. package/src/sources/EvmRpcClient.res +42 -0
  104. package/src/sources/EvmRpcClient.res.mjs +64 -0
  105. package/src/sources/Fuel.res +0 -7
  106. package/src/sources/Fuel.res.mjs +0 -15
  107. package/src/sources/HyperFuelSource.res +5 -4
  108. package/src/sources/HyperFuelSource.res.mjs +2 -2
  109. package/src/sources/HyperSyncClient.res +9 -5
  110. package/src/sources/HyperSyncClient.res.mjs +2 -2
  111. package/src/sources/HyperSyncHeightStream.res +2 -2
  112. package/src/sources/HyperSyncHeightStream.res.mjs +2 -2
  113. package/src/sources/HyperSyncSource.res +12 -11
  114. package/src/sources/HyperSyncSource.res.mjs +6 -6
  115. package/src/sources/Rpc.res +1 -5
  116. package/src/sources/Rpc.res.mjs +1 -9
  117. package/src/sources/RpcSource.res +57 -21
  118. package/src/sources/RpcSource.res.mjs +47 -20
  119. package/src/sources/RpcWebSocketHeightStream.res +1 -1
  120. package/src/sources/SourceManager.res +3 -2
  121. package/src/sources/SourceManager.res.mjs +1 -1
  122. package/src/sources/Svm.res +3 -10
  123. package/src/sources/Svm.res.mjs +4 -18
  124. package/src/sources/SvmHyperSyncClient.res +265 -0
  125. package/src/sources/SvmHyperSyncClient.res.mjs +28 -0
  126. package/src/sources/SvmHyperSyncSource.res +638 -0
  127. package/src/sources/SvmHyperSyncSource.res.mjs +557 -0
  128. package/src/tui/Tui.res +9 -2
  129. package/src/tui/Tui.res.mjs +18 -3
  130. package/src/tui/components/BufferedProgressBar.res +2 -2
  131. package/src/tui/components/TuiData.res +3 -0
  132. package/svm.schema.json +523 -14
  133. package/src/TableIndices.res +0 -115
  134. package/src/TableIndices.res.mjs +0 -144
@@ -0,0 +1,265 @@
1
+ type cfg = {
2
+ /** HyperSync server URL. */
3
+ url: string,
4
+ /** Optional bearer token for the HyperSync server. */
5
+ apiToken?: string,
6
+ httpReqTimeoutMillis?: int,
7
+ maxNumRetries?: int,
8
+ retryBaseMs?: int,
9
+ retryCeilingMs?: int,
10
+ /// Per-program Borsh schema descriptors (JSON, one per program). The Rust
11
+ /// client builds these into decoders at creation and decodes matching
12
+ /// instructions inline on `get`.
13
+ programSchemas?: array<string>,
14
+ }
15
+
16
+ module QueryTypes = {
17
+ type blockField =
18
+ | @as("slot") Slot
19
+ | @as("blockhash") Blockhash
20
+ | @as("parent_slot") ParentSlot
21
+ | @as("parent_blockhash") ParentBlockhash
22
+ | @as("block_time") BlockTime
23
+ | @as("block_height") BlockHeight
24
+
25
+ type transactionField =
26
+ | @as("slot") Slot
27
+ | @as("transaction_index") TransactionIndex
28
+ | @as("signatures") Signatures
29
+ | @as("fee_payer") FeePayer
30
+ | @as("success") Success
31
+ | @as("err") Err
32
+ | @as("fee") Fee
33
+ | @as("compute_units_consumed") ComputeUnitsConsumed
34
+ | @as("account_keys") AccountKeys
35
+ | @as("recent_blockhash") RecentBlockhash
36
+ | @as("version") Version
37
+ | @as("loaded_addresses_writable") LoadedAddressesWritable
38
+ | @as("loaded_addresses_readonly") LoadedAddressesReadonly
39
+
40
+ type instructionField =
41
+ | @as("slot") Slot
42
+ | @as("transaction_index") TransactionIndex
43
+ | @as("instruction_address") InstructionAddress
44
+ | @as("program_id") ProgramId
45
+ | @as("accounts") Accounts
46
+ | @as("data") Data
47
+ | @as("d1") D1
48
+ | @as("d2") D2
49
+ | @as("d4") D4
50
+ | @as("d8") D8
51
+ | @as("a0") A0
52
+ | @as("a1") A1
53
+ | @as("a2") A2
54
+ | @as("a3") A3
55
+ | @as("a4") A4
56
+ | @as("a5") A5
57
+ | @as("a6") A6
58
+ | @as("a7") A7
59
+ | @as("a8") A8
60
+ | @as("a9") A9
61
+ | @as("is_inner") IsInner
62
+ | @as("is_committed") IsCommitted
63
+
64
+ type logField =
65
+ | @as("slot") Slot
66
+ | @as("transaction_index") TransactionIndex
67
+ | @as("instruction_address") InstructionAddress
68
+ | @as("program_id") ProgramId
69
+ | @as("kind") Kind
70
+ | @as("message") Message
71
+
72
+ type tokenBalanceField =
73
+ | @as("slot") Slot
74
+ | @as("transaction_index") TransactionIndex
75
+ | @as("account") Account
76
+ | @as("mint") Mint
77
+ | @as("owner") Owner
78
+ | @as("pre_amount") PreAmount
79
+ | @as("post_amount") PostAmount
80
+
81
+ type fieldSelection = {
82
+ block?: array<blockField>,
83
+ transaction?: array<transactionField>,
84
+ instruction?: array<instructionField>,
85
+ log?: array<logField>,
86
+ tokenBalance?: array<tokenBalanceField>,
87
+ }
88
+
89
+ /** Filter for selecting instructions. All non-empty fields are AND-ed: an
90
+ instruction must match at least one value in every non-empty field.
91
+
92
+ Discriminator filters (d1..d8) take hex-encoded byte prefixes ("0x" optional).
93
+ Account filters (a0..a9) take base58 pubkey strings. */
94
+ type instructionSelection = {
95
+ programId?: array<string>,
96
+ d1?: array<string>,
97
+ d2?: array<string>,
98
+ d4?: array<string>,
99
+ d8?: array<string>,
100
+ a0?: array<string>,
101
+ a1?: array<string>,
102
+ a2?: array<string>,
103
+ a3?: array<string>,
104
+ a4?: array<string>,
105
+ a5?: array<string>,
106
+ a6?: array<string>,
107
+ a7?: array<string>,
108
+ a8?: array<string>,
109
+ a9?: array<string>,
110
+ isInner?: bool,
111
+ }
112
+
113
+ type transactionSelection = {
114
+ feePayer?: array<string>,
115
+ success?: bool,
116
+ }
117
+
118
+ type logSelection = {
119
+ programId?: array<string>,
120
+ kind?: array<string>,
121
+ }
122
+
123
+ type query = {
124
+ fromSlot: int,
125
+ toSlot?: int,
126
+ instructions?: array<instructionSelection>,
127
+ transactions?: array<transactionSelection>,
128
+ logs?: array<logSelection>,
129
+ includeAllBlocks?: bool,
130
+ includeTokenBalances?: bool,
131
+ fields?: fieldSelection,
132
+ maxNumBlocks?: int,
133
+ maxNumTransactions?: int,
134
+ maxNumInstructions?: int,
135
+ maxNumLogs?: int,
136
+ maxNumTokenBalances?: int,
137
+ }
138
+ }
139
+
140
+ module ResponseTypes = {
141
+ type block = {
142
+ slot: int,
143
+ blockhash: string,
144
+ parentSlot?: int,
145
+ parentBlockhash?: string,
146
+ blockTime?: int,
147
+ blockHeight?: int,
148
+ }
149
+
150
+ type transaction = {
151
+ slot: int,
152
+ transactionIndex: int,
153
+ signatures: array<string>,
154
+ feePayer?: string,
155
+ success?: bool,
156
+ err?: string,
157
+ fee?: int,
158
+ computeUnitsConsumed?: int,
159
+ accountKeys: array<string>,
160
+ recentBlockhash?: string,
161
+ version?: string,
162
+ loadedAddressesWritable: array<string>,
163
+ loadedAddressesReadonly: array<string>,
164
+ }
165
+
166
+ /// Borsh-decoded view attached by the Rust client. `argsJson`/`accountsJson`
167
+ /// are stringified to side-step napi-rs's lack of native JSON passthrough.
168
+ /** Solana instruction record.
169
+
170
+ `data` is the raw instruction byte buffer, hex-encoded with a `0x` prefix.
171
+ `d1`..`d8` are the same byte prefix as `data` but truncated to N bytes
172
+ (only `Some` when the instruction is at least that long), exposed for
173
+ handler-dispatch convenience.
174
+ `accounts` is the full positional account list in base58. */
175
+ type decodedInstruction = {
176
+ name: string,
177
+ argsJson: string,
178
+ accountsJson: string,
179
+ extraAccounts: array<string>,
180
+ }
181
+
182
+ type instruction = {
183
+ slot: int,
184
+ transactionIndex: int,
185
+ instructionAddress: array<int>,
186
+ programId: string,
187
+ accounts: array<string>,
188
+ data: string,
189
+ d1?: string,
190
+ d2?: string,
191
+ d4?: string,
192
+ d8?: string,
193
+ isInner: bool,
194
+ isCommitted: bool,
195
+ decoded?: decodedInstruction,
196
+ }
197
+
198
+ type log = {
199
+ slot: int,
200
+ transactionIndex?: int,
201
+ instructionAddress?: array<int>,
202
+ programId?: string,
203
+ kind?: string,
204
+ message?: string,
205
+ }
206
+
207
+ type tokenBalance = {
208
+ slot: int,
209
+ transactionIndex?: int,
210
+ account?: string,
211
+ mint?: string,
212
+ owner?: string,
213
+ preAmount?: string,
214
+ postAmount?: string,
215
+ }
216
+
217
+ type queryResponseData = {
218
+ blocks: array<block>,
219
+ transactions: array<transaction>,
220
+ instructions: array<instruction>,
221
+ logs: array<log>,
222
+ tokenBalances: array<tokenBalance>,
223
+ }
224
+
225
+ type queryResponse = {
226
+ nextSlot: int,
227
+ responseBytes: int,
228
+ data: queryResponseData,
229
+ }
230
+ }
231
+
232
+ type query = QueryTypes.query
233
+ type queryResponse = ResponseTypes.queryResponse
234
+
235
+ type t = {
236
+ getHeight: unit => promise<int>,
237
+ get: (~query: query) => promise<queryResponse>,
238
+ }
239
+
240
+ @send
241
+ external classFromConfig: (Core.svmHypersyncClientCtor, cfg, string) => t = "fromConfig"
242
+
243
+ let make = (
244
+ ~url,
245
+ ~apiToken=?,
246
+ ~httpReqTimeoutMillis=?,
247
+ ~maxNumRetries=?,
248
+ ~retryBaseMs=?,
249
+ ~retryCeilingMs=?,
250
+ ~programSchemas=?,
251
+ ) => {
252
+ let envioVersion = Utils.EnvioPackage.value.version
253
+ Core.getAddon().svmHypersyncClient->classFromConfig(
254
+ {
255
+ url,
256
+ ?apiToken,
257
+ ?httpReqTimeoutMillis,
258
+ ?maxNumRetries,
259
+ ?retryBaseMs,
260
+ ?retryCeilingMs,
261
+ ?programSchemas,
262
+ },
263
+ `hyperindex/${envioVersion}`,
264
+ )
265
+ }
@@ -0,0 +1,28 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Core from "../Core.res.mjs";
4
+ import * as Utils from "../Utils.res.mjs";
5
+
6
+ let QueryTypes = {};
7
+
8
+ let ResponseTypes = {};
9
+
10
+ function make(url, apiToken, httpReqTimeoutMillis, maxNumRetries, retryBaseMs, retryCeilingMs, programSchemas) {
11
+ let envioVersion = Utils.EnvioPackage.value.version;
12
+ return Core.getAddon().SvmHypersyncClient.fromConfig({
13
+ url: url,
14
+ apiToken: apiToken,
15
+ httpReqTimeoutMillis: httpReqTimeoutMillis,
16
+ maxNumRetries: maxNumRetries,
17
+ retryBaseMs: retryBaseMs,
18
+ retryCeilingMs: retryCeilingMs,
19
+ programSchemas: programSchemas
20
+ }, `hyperindex/` + envioVersion);
21
+ }
22
+
23
+ export {
24
+ QueryTypes,
25
+ ResponseTypes,
26
+ make,
27
+ }
28
+ /* Core Not a pure module */