envio 2.17.0 → 2.18.0

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.
@@ -0,0 +1,408 @@
1
+ type unchecksummedEthAddress = string
2
+
3
+ type t
4
+
5
+ type cfg = {
6
+ url: string,
7
+ bearerToken?: string,
8
+ http_req_timeout_millis?: int,
9
+ }
10
+ module QueryTypes = {
11
+ type blockFieldOptions =
12
+ | @as("id") Id
13
+ | @as("da_height") DaHeight
14
+ | @as("transactions_count") TransactionsCount
15
+ | @as("message_receipt_count") MessageReceiptCount
16
+ | @as("transactions_root") TransactionsRoot
17
+ | @as("message_receipt_root") MessageReceiptRoot
18
+ | @as("height") Height
19
+ | @as("prev_root") PrevRoot
20
+ | @as("time") Time
21
+ | @as("application_hash") ApplicationHash
22
+
23
+ type blockFieldSelection = array<blockFieldOptions>
24
+
25
+ type transactionFieldOptions =
26
+ | @as("id") Id
27
+ | @as("block_height") BlockHeight
28
+ | @as("input_asset_ids") InputAssetIds
29
+ | @as("input_contracts") InputContracts
30
+ | @as("input_contract_utxo_id") InputContractUtxoId
31
+ | @as("input_contract_balance_root") InputContractBalanceRoot
32
+ | @as("input_contract_state_root") InputContractStateRoot
33
+ | @as("input_contract_tx_pointer_block_height") InputContractTxPointerBlockHeight
34
+ | @as("input_contract_tx_pointer_tx_index") InputContractTxPointerTxIndex
35
+ | @as("input_contract") InputContract
36
+ | @as("gas_price") GasPrice
37
+ | @as("gas_limit") GasLimit
38
+ | @as("maturity") Maturity
39
+ | @as("mint_amount") MintAmount
40
+ | @as("mint_asset_id") MintAssetId
41
+ | @as("tx_pointer_block_height") TxPointerBlockHeight
42
+ | @as("tx_pointer_tx_index") TxPointerTxIndex
43
+ | @as("tx_type") TxType
44
+ | @as("output_contract_input_index") OutputContractInputIndex
45
+ | @as("output_contract_balance_root") OutputContractBalanceRoot
46
+ | @as("output_contract_state_root") OutputContractStateRoot
47
+ | @as("witnesses") Witnesses
48
+ | @as("receipts_root") ReceiptsRoot
49
+ | @as("status") Status
50
+ | @as("time") Time
51
+ | @as("reason") Reason
52
+ | @as("script") Script
53
+ | @as("script_data") ScriptData
54
+ | @as("bytecode_witness_index") BytecodeWitnessIndex
55
+ | @as("bytecode_length") BytecodeLength
56
+ | @as("salt") Salt
57
+
58
+ type transactionFieldSelection = array<transactionFieldOptions>
59
+
60
+ type receiptFieldOptions =
61
+ | @as("tx_id") TxId
62
+ | @as("tx_status") TxStatus
63
+ | @as("block_height") BlockHeight
64
+ | @as("pc") Pc
65
+ | @as("is") Is
66
+ | @as("to") To
67
+ | @as("to_address") ToAddress
68
+ | @as("amount") Amount
69
+ | @as("asset_id") AssetId
70
+ | @as("gas") Gas
71
+ | @as("param1") Param1
72
+ | @as("param2") Param2
73
+ | @as("val") Val
74
+ | @as("ptr") Ptr
75
+ | @as("digest") Digest
76
+ | @as("reason") Reason
77
+ | @as("ra") Ra
78
+ | @as("rb") Rb
79
+ | @as("rc") Rc
80
+ | @as("rd") Rd
81
+ | @as("len") Len
82
+ | @as("receipt_type") ReceiptType
83
+ | @as("receipt_index") ReceiptIndex
84
+ | @as("result") Result
85
+ | @as("gas_used") GasUsed
86
+ | @as("data") Data
87
+ | @as("sender") Sender
88
+ | @as("recipient") Recipient
89
+ | @as("nonce") Nonce
90
+ | @as("contract_id") ContractId
91
+ | @as("root_contract_id") RootContractId
92
+ | @as("sub_id") SubId
93
+
94
+ type receiptFieldSelection = array<receiptFieldOptions>
95
+
96
+ type fieldSelection = {
97
+ block?: blockFieldSelection,
98
+ transaction?: transactionFieldSelection,
99
+ receipt?: receiptFieldSelection,
100
+ }
101
+
102
+ type inputSelection
103
+ type outputSelection
104
+
105
+ type receiptSelection = {
106
+ rootContractId?: array<Address.t>,
107
+ toAddress?: array<string>,
108
+ assetId?: array<string>,
109
+ receiptType?: array<Fuel.receiptType>,
110
+ sender?: array<string>,
111
+ recipient?: array<string>,
112
+ contractId?: array<Address.t>,
113
+ ra?: array<bigint>,
114
+ rb?: array<bigint>,
115
+ rc?: array<bigint>,
116
+ rd?: array<bigint>,
117
+ txStatus?: array<int>,
118
+ }
119
+
120
+ type query = {
121
+ /** The block to start the query from */
122
+ fromBlock: int,
123
+ /**
124
+ * The block to end the query at. If not specified, the query will go until the
125
+ * end of data. Exclusive, the returned range will be [from_block..to_block).
126
+ *
127
+ * The query will return before it reaches this target block if it hits the time limit
128
+ * configured on the server. The user should continue their query by putting the
129
+ * next_block field in the response into from_block field of their next query. This implements
130
+ * pagination.
131
+ */
132
+ @as("toBlock")
133
+ toBlockExclusive?: int,
134
+ /**
135
+ * List of receipt selections, the query will return receipts that match any of these selections and
136
+ * it will return receipts that are related to the returned objects.
137
+ */
138
+ receipts?: array<receiptSelection>,
139
+ /**
140
+ * List of input selections, the query will return inputs that match any of these selections and
141
+ * it will return inputs that are related to the returned objects.
142
+ */
143
+ inputs?: array<inputSelection>,
144
+ /**
145
+ * List of output selections, the query will return outputs that match any of these selections and
146
+ * it will return outputs that are related to the returned objects.
147
+ */
148
+ outputs?: array<outputSelection>,
149
+ /**
150
+ * Whether to include all blocks regardless of if they are related to a returned transaction or log. Normally
151
+ * the server will return only the blocks that are related to the transaction or logs in the response. But if this
152
+ * is set to true, the server will return data for all blocks in the requested range [from_block, to_block).
153
+ */
154
+ includeAllBlocks?: bool,
155
+ /**
156
+ * Field selection. The user can select which fields they are interested in, requesting less fields will improve
157
+ * query execution time and reduce the payload size so the user should always use a minimal number of fields.
158
+ */
159
+ fieldSelection: fieldSelection,
160
+ /**
161
+ * Maximum number of blocks that should be returned, the server might return more blocks than this number but
162
+ * it won't overshoot by too much.
163
+ */
164
+ maxNumBlocks?: int,
165
+ /**
166
+ * Maximum number of transactions that should be returned, the server might return more transactions than this number but
167
+ * it won't overshoot by too much.
168
+ */
169
+ maxNumTransactions?: int,
170
+ }
171
+ }
172
+
173
+ module FuelTypes = {
174
+ /** An object containing information about a transaction. */
175
+ type transaction = {
176
+ /** block the transaction is in. */
177
+ blockHeight: int,
178
+ /** A unique transaction id. */
179
+ id: string,
180
+ /** An array of asset ids used for the transaction inputs. */
181
+ inputAssetIds?: array<string>,
182
+ /** An array of contracts used for the transaction inputs. */
183
+ inputContracts?: array<string>,
184
+ /**
185
+ * A contract used for the transaction input.
186
+ * A unique 32 byte identifier for the UTXO for a contract used for the transaction input.
187
+ */
188
+ inputContractUtxoId?: string,
189
+ /** The root of amount of coins owned by contract before transaction execution for a contract used for the transaction input. */
190
+ inputContractBalanceRoot?: string,
191
+ /** The state root of contract before transaction execution for a contract used for the transaction input. */
192
+ inputContractStateRoot?: string,
193
+ /** A pointer to the TX whose output is being spent for a contract used for the transaction input. */
194
+ inputContractTxPointerBlockHeight?: int,
195
+ /** A pointer to the TX whose output is being spent for a contract used for the transaction input. */
196
+ inputContractTxPointerTxIndex?: int,
197
+ /** The contract id for a contract used for the transaction input. */
198
+ inputContract?: string,
199
+ /** The gas price for the transaction. */
200
+ gasPrice?: bigint,
201
+ /** The gas limit for the transaction. */
202
+ gasLimit?: bigint,
203
+ /** The minimum block height that the transaction can be included at. */
204
+ maturity?: int,
205
+ /** The amount minted in the transaction. */
206
+ mintAmount?: bigint,
207
+ /** The asset ID for coins minted in the transaction. */
208
+ mintAssetId?: string,
209
+ /** The location of the transaction in the block. */
210
+ txPointerBlockHeight?: int,
211
+ txPointerTxIndex?: int,
212
+ /** Script, creating a new contract, or minting new coins */
213
+ txType: int,
214
+ /** The index of the input from a transaction that changed the state of a contract. */
215
+ outputContractInputIndex?: int,
216
+ /** The root of amount of coins owned by contract after transaction execution from a transaction that changed the state of a contract. */
217
+ outputContractBalanceRoot?: string,
218
+ /** The state root of contract after transaction execution from a transaction that changed the state of a contract. */
219
+ outputContractStateRoot?: string,
220
+ /** An array of witnesses. */
221
+ witnesses?: string,
222
+ /** The root of the receipts. */
223
+ receiptsRoot?: string,
224
+ /** The status type of the transaction. */
225
+ status: int,
226
+ /** for SubmittedStatus, SuccessStatus, and FailureStatus, the time a transaction was submitted, successful, or failed */
227
+ time: int,
228
+ /**
229
+ * for SuccessStatus, the state of the program execution
230
+ * for SqueezedOutStatus & FailureStatus, the reason the transaction was squeezed out or failed
231
+ */
232
+ reason?: string,
233
+ /** The script to execute. */
234
+ script?: string,
235
+ /** The script input parameters. */
236
+ scriptData?: string,
237
+ /** The witness index of contract bytecode. */
238
+ bytecodeWitnessIndex?: int,
239
+ /** The length of the transaction bytecode. */
240
+ bytecodeLength?: int,
241
+ /** The salt value for the transaction. */
242
+ salt?: string,
243
+ }
244
+ /** An object representing all possible types of receipts. */
245
+ type receipt = {
246
+ /** Index of the receipt in the block */
247
+ receiptIndex: int,
248
+ /** Contract that produced the receipt */
249
+ rootContractId?: Address.t,
250
+ /** transaction that this receipt originated from */
251
+ txId: string,
252
+ /** The status type of the transaction this receipt originated from */
253
+ txStatus: int,
254
+ /** block that the receipt originated in */
255
+ blockHeight: int,
256
+ /** The value of the program counter register $pc, which is the memory address of the current instruction. */
257
+ pc?: int,
258
+ /** The value of register $is, which is the pointer to the start of the currently-executing code. */
259
+ is?: int,
260
+ /** The recipient contract */
261
+ to?: string,
262
+ /** The recipient address */
263
+ toAddress?: string,
264
+ /** The amount of coins transferred. */
265
+ amount?: bigint,
266
+ /** The asset id of the coins transferred. */
267
+ assetId?: string,
268
+ /** The gas used for the transaction. */
269
+ gas?: int,
270
+ /** The first parameter for a CALL receipt type, holds the function selector. */
271
+ param1?: bigint,
272
+ /** The second parameter for a CALL receipt type, typically used for the user-specified input to the ABI function being selected. */
273
+ param2?: bigint,
274
+ /** The value of registers at the end of execution, used for debugging. */
275
+ val?: bigint,
276
+ /** The value of the pointer register, used for debugging. */
277
+ ptr?: bigint,
278
+ /** A 32-byte String of MEM[$rC, $rD]. The syntax MEM[x, y] means the memory range starting at byte x, of length y bytes. */
279
+ digest?: string,
280
+ /** The decimal string representation of an 8-bit unsigned integer for the panic reason. Only returned if the receipt type is PANIC. */
281
+ reason?: int,
282
+ /** The value of register $rA. */
283
+ ra?: bigint,
284
+ /** The value of register $rB. */
285
+ rb?: bigint,
286
+ /** The value of register $rC. */
287
+ rc?: bigint,
288
+ /** The value of register $rD. */
289
+ rd?: bigint,
290
+ /** The length of the receipt. */
291
+ len?: bigint,
292
+ /** The type of receipt. */
293
+ receiptType: Fuel.receiptType,
294
+ /** 0 if script exited successfully, any otherwise. */
295
+ result?: int,
296
+ /** The amount of gas consumed by the script. */
297
+ gasUsed?: int,
298
+ /** The receipt data. */
299
+ data?: string,
300
+ /** The address of the message sender. */
301
+ sender?: string,
302
+ /** The address of the message recipient. */
303
+ recipient?: string,
304
+ /** The nonce value for a message. */
305
+ nonce?: string,
306
+ /** Current context if in an internal context. null otherwise */
307
+ contractId?: Address.t,
308
+ /** The sub id. */
309
+ subId?: string,
310
+ }
311
+
312
+ // Unused - in indexer currently
313
+ type input = {
314
+ txId: string,
315
+ blockHeight: int,
316
+ inputType: int,
317
+ utxoId?: string,
318
+ owner?: string,
319
+ amount?: bigint,
320
+ assetId?: string,
321
+ txPointerBlockHeight?: int,
322
+ txPointerTxIndex?: int,
323
+ witnessIndex?: int,
324
+ predicateGasUsed?: int,
325
+ predicate?: string,
326
+ predicateData?: string,
327
+ balanceRoot?: string,
328
+ stateRoot?: string,
329
+ contract?: string,
330
+ sender?: string,
331
+ recipient?: string,
332
+ nonce?: string,
333
+ data?: string,
334
+ }
335
+
336
+ // Unused in indexer currently
337
+ type output = {
338
+ txId: string,
339
+ blockHeight: int,
340
+ outputType: int,
341
+ to?: string,
342
+ amount?: bigint,
343
+ assetId?: string,
344
+ inputIndex?: int,
345
+ balanceRoot?: string,
346
+ stateRoot?: string,
347
+ contract?: string,
348
+ }
349
+
350
+ // Unused in indexer currently
351
+ /** The block header contains metadata about a certain block. */
352
+ type block = {
353
+ /** String of the header */
354
+ id: string,
355
+ /** The block height for the data availability layer up to which (inclusive) input messages are processed. */
356
+ daHeight: int,
357
+ consensusParametersVersion: int,
358
+ stateTransitionBytecodeVersion: int,
359
+ /** The number of transactions in the block. */
360
+ transactionsCount: string,
361
+ /** The number of receipt messages in the block. */
362
+ messageReceiptCount: string,
363
+ /** The merkle root of the transactions in the block. */
364
+ transactionsRoot: string,
365
+ messageOutboxRoot: string,
366
+ eventInboxRoot: string,
367
+ /** The block height. */
368
+ height: int,
369
+ /** The merkle root of all previous consensus header Stringes (not including this block). */
370
+ prevRoot: string,
371
+ /** The timestamp for the block. */
372
+ time: int,
373
+ /** The String of the serialized application header for this block. */
374
+ applicationHash: string,
375
+ }
376
+ }
377
+
378
+ type queryResponseDataTyped = {
379
+ transactions: array<FuelTypes.transaction>,
380
+ receipts: array<FuelTypes.receipt>,
381
+ blocks: option<array<FuelTypes.block>>,
382
+ inputs: array<FuelTypes.input>,
383
+ outputs: array<FuelTypes.output>,
384
+ }
385
+
386
+ type queryResponseTyped = {
387
+ /** Current height of the source hypersync instance */
388
+ archiveHeight?: int,
389
+ /**
390
+ * Next block to query for, the responses are paginated so
391
+ * the caller should continue the query from this block if they
392
+ * didn't get responses up to the to_block they specified in the Query.
393
+ */
394
+ nextBlock: int,
395
+ /** Total time it took the hypersync instance to execute the query. */
396
+ totalExecutionTime: int,
397
+ /** Response data */
398
+ data: queryResponseDataTyped,
399
+ }
400
+
401
+ @module("@envio-dev/hyperfuel-client") @scope("HyperfuelClient")
402
+ external make: cfg => t = "new"
403
+ let make = (cfg: cfg) => {
404
+ make({...cfg, bearerToken: "3dc856dd-b0ea-494f-b27e-017b8b6b7e07"})
405
+ }
406
+
407
+ @send
408
+ external getSelectedData: (t, QueryTypes.query) => promise<queryResponseTyped> = "getSelectedData"