envio 3.2.1 → 3.3.0-alpha.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 (106) hide show
  1. package/package.json +6 -7
  2. package/src/Batch.res +12 -15
  3. package/src/Batch.res.mjs +4 -5
  4. package/src/BatchProcessing.res +199 -0
  5. package/src/BatchProcessing.res.mjs +125 -0
  6. package/src/ChainFetching.res +373 -0
  7. package/src/ChainFetching.res.mjs +206 -0
  8. package/src/ChainMetadata.res +27 -0
  9. package/src/ChainMetadata.res.mjs +27 -0
  10. package/src/ChainState.res +643 -0
  11. package/src/ChainState.res.mjs +476 -0
  12. package/src/ChainState.resi +87 -0
  13. package/src/Config.res +13 -4
  14. package/src/Config.res.mjs +8 -3
  15. package/src/ContractRegisterContext.res +106 -0
  16. package/src/ContractRegisterContext.res.mjs +76 -0
  17. package/src/Core.res +3 -0
  18. package/src/CrossChainState.res +294 -0
  19. package/src/CrossChainState.res.mjs +221 -0
  20. package/src/CrossChainState.resi +39 -0
  21. package/src/Ecosystem.res +58 -0
  22. package/src/Ecosystem.res.mjs +43 -1
  23. package/src/Env.res +0 -2
  24. package/src/Env.res.mjs +0 -3
  25. package/src/EventConfigBuilder.res +2 -2
  26. package/src/EventProcessing.res +60 -46
  27. package/src/EventProcessing.res.mjs +33 -32
  28. package/src/EventUtils.res +0 -4
  29. package/src/EventUtils.res.mjs +0 -4
  30. package/src/ExitOnCaughtUp.res +10 -0
  31. package/src/ExitOnCaughtUp.res.mjs +22 -0
  32. package/src/FetchState.res +205 -73
  33. package/src/FetchState.res.mjs +242 -103
  34. package/src/InMemoryStore.res +36 -451
  35. package/src/InMemoryStore.res.mjs +20 -369
  36. package/src/IndexerLoop.res +43 -0
  37. package/src/IndexerLoop.res.mjs +46 -0
  38. package/src/IndexerState.res +536 -0
  39. package/src/IndexerState.res.mjs +543 -0
  40. package/src/IndexerState.resi +128 -0
  41. package/src/Internal.res +29 -8
  42. package/src/LoadLayer.res +20 -18
  43. package/src/LoadLayer.res.mjs +14 -12
  44. package/src/LoadLayer.resi +6 -3
  45. package/src/Logging.res +11 -44
  46. package/src/Logging.res.mjs +10 -42
  47. package/src/Main.res +54 -79
  48. package/src/Main.res.mjs +44 -56
  49. package/src/PgStorage.res +8 -71
  50. package/src/PgStorage.res.mjs +3 -47
  51. package/src/Prometheus.res +1 -13
  52. package/src/Prometheus.res.mjs +84 -96
  53. package/src/PruneStaleHistory.res +45 -0
  54. package/src/PruneStaleHistory.res.mjs +46 -0
  55. package/src/RawEvent.res +73 -0
  56. package/src/RawEvent.res.mjs +51 -0
  57. package/src/Rollback.res +204 -0
  58. package/src/Rollback.res.mjs +118 -0
  59. package/src/SimulateItems.res +12 -10
  60. package/src/SimulateItems.res.mjs +1 -1
  61. package/src/UserContext.res +26 -114
  62. package/src/UserContext.res.mjs +15 -78
  63. package/src/Writing.res +242 -0
  64. package/src/Writing.res.mjs +215 -0
  65. package/src/db/InternalTable.res +14 -27
  66. package/src/sources/Evm.res +40 -1
  67. package/src/sources/Evm.res.mjs +94 -84
  68. package/src/sources/Fuel.res +40 -1
  69. package/src/sources/Fuel.res.mjs +36 -26
  70. package/src/sources/HyperFuel.res +41 -120
  71. package/src/sources/HyperFuel.res.mjs +42 -80
  72. package/src/sources/HyperFuel.resi +1 -24
  73. package/src/sources/HyperFuelClient.res +16 -297
  74. package/src/sources/HyperFuelClient.res.mjs +5 -4
  75. package/src/sources/HyperFuelSource.res +33 -8
  76. package/src/sources/HyperFuelSource.res.mjs +56 -10
  77. package/src/sources/HyperSyncSource.res +5 -3
  78. package/src/sources/HyperSyncSource.res.mjs +1 -1
  79. package/src/sources/RpcSource.res +2 -2
  80. package/src/sources/RpcSource.res.mjs +1 -1
  81. package/src/sources/SourceManager.res +14 -23
  82. package/src/sources/SourceManager.res.mjs +27 -29
  83. package/src/sources/SourceManager.resi +4 -2
  84. package/src/sources/Svm.res +18 -1
  85. package/src/sources/Svm.res.mjs +30 -22
  86. package/src/sources/SvmHyperSyncSource.res +1 -1
  87. package/src/sources/SvmHyperSyncSource.res.mjs +1 -1
  88. package/src/tui/Tui.res +38 -36
  89. package/src/tui/Tui.res.mjs +51 -51
  90. package/src/ChainFetcher.res +0 -519
  91. package/src/ChainFetcher.res.mjs +0 -314
  92. package/src/ChainManager.res +0 -358
  93. package/src/ChainManager.res.mjs +0 -291
  94. package/src/Ctx.res +0 -6
  95. package/src/Ctx.res.mjs +0 -2
  96. package/src/GlobalState.res +0 -1056
  97. package/src/GlobalState.res.mjs +0 -1086
  98. package/src/GlobalStateManager.res +0 -57
  99. package/src/GlobalStateManager.res.mjs +0 -68
  100. package/src/GlobalStateManager.resi +0 -7
  101. package/src/Ports.res +0 -5
  102. package/src/Ports.res.mjs +0 -9
  103. package/src/adapters/MarkBatchProcessedAdapter.res +0 -5
  104. package/src/adapters/MarkBatchProcessedAdapter.res.mjs +0 -14
  105. package/src/sources/EnvioApiClient.res +0 -15
  106. package/src/sources/EnvioApiClient.res.mjs +0 -24
@@ -1,35 +1,35 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
- import * as Time from "../Time.res.mjs";
4
- import * as Logging from "../Logging.res.mjs";
3
+ import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
4
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
5
+ import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
5
6
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
- import * as HyperFuelClient from "./HyperFuelClient.res.mjs";
7
7
  import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
8
- import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
9
8
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
10
9
 
11
- let cache = {};
10
+ let $$Error = /* @__PURE__ */Primitive_exceptions.create("HyperFuel.GetLogs.Error");
12
11
 
13
- function getClient(url) {
14
- let client = cache[url];
15
- if (client !== undefined) {
16
- return Primitive_option.valFromOption(client);
12
+ function extractMissingParams(exn) {
13
+ let message = exn.RE_EXN_ID === "JsExn" ? Stdlib_JsExn.message(exn._1) : undefined;
14
+ if (message === undefined) {
15
+ return;
16
+ }
17
+ let obj;
18
+ try {
19
+ obj = Stdlib_JSON.Decode.object(JSON.parse(message));
20
+ } catch (exn$1) {
21
+ return;
22
+ }
23
+ if (obj === undefined) {
24
+ return;
25
+ }
26
+ let match = obj["kind"];
27
+ let match$1 = obj["fields"];
28
+ if (match === "MissingFields" && Array.isArray(match$1)) {
29
+ return Stdlib_Array.filterMap(match$1, Stdlib_JSON.Decode.string);
17
30
  }
18
- let newClient = HyperFuelClient.make({
19
- url: url
20
- });
21
- cache[url] = newClient;
22
- return newClient;
23
- }
24
-
25
- function queryErrorToMsq(e) {
26
- let match = e._0;
27
- return match.queryName + ` query failed due to unexpected missing params on response:
28
- ` + match.missingParams.join(", ");
29
31
  }
30
32
 
31
- let $$Error = /* @__PURE__ */Primitive_exceptions.create("HyperFuel.GetLogs.Error");
32
-
33
33
  function makeRequestBody(fromBlock, toBlockInclusive, recieptsSelection) {
34
34
  return {
35
35
  fromBlock: fromBlock,
@@ -101,10 +101,26 @@ function decodeLogQueryPageItems(response_data) {
101
101
  return items;
102
102
  }
103
103
 
104
- async function query(serverUrl, fromBlock, toBlock, recieptsSelection) {
104
+ async function query(client, fromBlock, toBlock, recieptsSelection) {
105
105
  let query$1 = makeRequestBody(fromBlock, toBlock, recieptsSelection);
106
- let hyperFuelClient = getClient(serverUrl);
107
- let res = await hyperFuelClient.getSelectedData(query$1);
106
+ let res;
107
+ try {
108
+ res = await client.getSelectedData(query$1);
109
+ } catch (raw_exn) {
110
+ let exn = Primitive_exceptions.internalToException(raw_exn);
111
+ let missingParams = extractMissingParams(exn);
112
+ if (missingParams !== undefined) {
113
+ throw {
114
+ RE_EXN_ID: $$Error,
115
+ _1: {
116
+ TAG: "UnexpectedMissingParams",
117
+ missingParams: missingParams
118
+ },
119
+ Error: new Error()
120
+ };
121
+ }
122
+ throw exn;
123
+ }
108
124
  if (res.nextBlock <= fromBlock) {
109
125
  throw {
110
126
  RE_EXN_ID: $$Error,
@@ -119,66 +135,12 @@ async function query(serverUrl, fromBlock, toBlock, recieptsSelection) {
119
135
  };
120
136
  }
121
137
 
122
- async function queryBlockData(serverUrl, blockNumber, logger) {
123
- let query_toBlock = blockNumber + 1 | 0;
124
- let query_inputs = [{}];
125
- let query_outputs = [{}];
126
- let query_includeAllBlocks = true;
127
- let query_fieldSelection = {
128
- block: [
129
- "height",
130
- "id",
131
- "time"
132
- ]
133
- };
134
- let query = {
135
- fromBlock: blockNumber,
136
- toBlock: query_toBlock,
137
- inputs: query_inputs,
138
- outputs: query_outputs,
139
- includeAllBlocks: query_includeAllBlocks,
140
- fieldSelection: query_fieldSelection
141
- };
142
- let hyperFuelClient = getClient(serverUrl);
143
- let logger$1 = Logging.createChildFrom(logger, {
144
- logType: "hypersync get blockhash query",
145
- blockNumber: blockNumber
146
- });
147
- let executeQuery = () => hyperFuelClient.getSelectedData(query);
148
- let res = await Time.retryAsyncWithExponentialBackOff(undefined, undefined, undefined, undefined, logger$1, executeQuery);
149
- if (res.nextBlock > blockNumber) {
150
- return Stdlib_Option.flatMap(res.data.blocks, blocks => Stdlib_Option.map(blocks[0], block => ({
151
- blockHash: block.id,
152
- blockNumber: block.height,
153
- blockTimestamp: block.time
154
- })));
155
- }
156
- let logger$2 = Logging.createChild({
157
- url: serverUrl
158
- });
159
- Logging.childInfo(logger$2, `Block #` + blockNumber.toString() + ` not found in HyperFuel. HyperFuel has multiple instances and it's possible that they drift independently slightly from the head. Indexing should continue correctly after retrying the query in ` + (100).toString() + `ms.`);
160
- await Time.resolvePromiseAfterDelay(100);
161
- return await queryBlockData(serverUrl, blockNumber, logger$2);
162
- }
163
-
164
- function heightRoute() {
165
- return {
166
- method: "GET",
167
- path: "/height",
168
- input: param => {},
169
- responses: [s => s.field("height", S$RescriptSchema.int)]
170
- };
171
- }
172
-
173
138
  let GetLogs = {
174
139
  $$Error: $$Error,
175
140
  query: query
176
141
  };
177
142
 
178
143
  export {
179
- queryErrorToMsq,
180
144
  GetLogs,
181
- queryBlockData,
182
- heightRoute,
183
145
  }
184
- /* Time Not a pure module */
146
+ /* Stdlib_JsExn Not a pure module */
@@ -18,23 +18,8 @@ type item = {
18
18
  block: block,
19
19
  }
20
20
 
21
- type blockNumberAndHash = {
22
- blockNumber: int,
23
- hash: string,
24
- }
25
-
26
21
  type logsQueryPage = hyperSyncPage<item>
27
22
 
28
- type missingParams = {
29
- queryName: string,
30
- missingParams: array<string>,
31
- }
32
- type queryError = UnexpectedMissingParams(missingParams)
33
-
34
- let queryErrorToMsq: queryError => string
35
-
36
- type queryResponse<'a> = result<'a, queryError>
37
-
38
23
  module GetLogs: {
39
24
  type error =
40
25
  | UnexpectedMissingParams({missingParams: array<string>})
@@ -43,17 +28,9 @@ module GetLogs: {
43
28
  exception Error(error)
44
29
 
45
30
  let query: (
46
- ~serverUrl: string,
31
+ ~client: HyperFuelClient.t,
47
32
  ~fromBlock: int,
48
33
  ~toBlock: option<int>,
49
34
  ~recieptsSelection: array<HyperFuelClient.QueryTypes.receiptSelection>,
50
35
  ) => promise<logsQueryPage>
51
36
  }
52
-
53
- let queryBlockData: (
54
- ~serverUrl: string,
55
- ~blockNumber: int,
56
- ~logger: Pino.t,
57
- ) => promise<option<ReorgDetection.blockDataWithTimestamp>>
58
-
59
- let heightRoute: Rest.route<unit, int>
@@ -1,119 +1,43 @@
1
- type unchecksummedEthAddress = string
2
-
3
1
  type t
4
2
 
5
3
  type cfg = {
6
4
  url: string,
7
- bearerToken?: string,
8
- http_req_timeout_millis?: int,
5
+ apiToken: string,
9
6
  }
10
7
  module QueryTypes = {
11
8
  type blockFieldOptions =
12
9
  | @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
10
  | @as("height") Height
19
- | @as("prev_root") PrevRoot
20
11
  | @as("time") Time
21
- | @as("application_hash") ApplicationHash
22
12
 
23
13
  type blockFieldSelection = array<blockFieldOptions>
24
14
 
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
15
  type receiptFieldOptions =
61
16
  | @as("tx_id") TxId
62
- | @as("tx_status") TxStatus
63
17
  | @as("block_height") BlockHeight
64
- | @as("pc") Pc
65
- | @as("is") Is
66
- | @as("to") To
67
18
  | @as("to_address") ToAddress
68
19
  | @as("amount") Amount
69
20
  | @as("asset_id") AssetId
70
- | @as("gas") Gas
71
- | @as("param1") Param1
72
- | @as("param2") Param2
73
21
  | @as("val") Val
74
- | @as("ptr") Ptr
75
- | @as("digest") Digest
76
- | @as("reason") Reason
77
- | @as("ra") Ra
78
22
  | @as("rb") Rb
79
- | @as("rc") Rc
80
- | @as("rd") Rd
81
- | @as("len") Len
82
23
  | @as("receipt_type") ReceiptType
83
24
  | @as("receipt_index") ReceiptIndex
84
- | @as("result") Result
85
- | @as("gas_used") GasUsed
86
25
  | @as("data") Data
87
- | @as("sender") Sender
88
- | @as("recipient") Recipient
89
- | @as("nonce") Nonce
90
- | @as("contract_id") ContractId
91
26
  | @as("root_contract_id") RootContractId
92
27
  | @as("sub_id") SubId
28
+ | @as("to") To
93
29
 
94
30
  type receiptFieldSelection = array<receiptFieldOptions>
95
31
 
96
32
  type fieldSelection = {
97
33
  block?: blockFieldSelection,
98
- transaction?: transactionFieldSelection,
99
34
  receipt?: receiptFieldSelection,
100
35
  }
101
36
 
102
- type inputSelection
103
- type outputSelection
104
-
105
37
  type receiptSelection = {
106
38
  rootContractId?: array<Address.t>,
107
- toAddress?: array<string>,
108
- assetId?: array<string>,
109
39
  receiptType?: array<FuelSDK.receiptType>,
110
- sender?: array<string>,
111
- recipient?: array<string>,
112
- contractId?: array<Address.t>,
113
- ra?: array<bigint>,
114
40
  rb?: array<bigint>,
115
- rc?: array<bigint>,
116
- rd?: array<bigint>,
117
41
  txStatus?: array<int>,
118
42
  }
119
43
 
@@ -137,254 +61,44 @@ module QueryTypes = {
137
61
  */
138
62
  receipts?: array<receiptSelection>,
139
63
  /**
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
64
  * Field selection. The user can select which fields they are interested in, requesting less fields will improve
157
65
  * query execution time and reduce the payload size so the user should always use a minimal number of fields.
158
66
  */
159
67
  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
68
  }
171
69
  }
172
70
 
173
71
  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
72
  type receipt = {
246
- /** Index of the receipt in the block */
247
73
  receiptIndex: int,
248
- /** Contract that produced the receipt */
249
74
  rootContractId?: Address.t,
250
- /** transaction that this receipt originated from */
251
75
  txId: string,
252
- /** The status type of the transaction this receipt originated from */
253
- txStatus: int,
254
- /** block that the receipt originated in */
255
76
  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
77
  receiptType: FuelSDK.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
78
  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. */
79
+ rb?: bigint,
80
+ val?: bigint,
309
81
  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
82
  amount?: bigint,
320
83
  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
84
  to?: string,
342
- amount?: bigint,
343
- assetId?: string,
344
- inputIndex?: int,
345
- balanceRoot?: string,
346
- stateRoot?: string,
347
- contract?: string,
85
+ toAddress?: string,
348
86
  }
349
87
 
350
- // Unused in indexer currently
351
- /** The block header contains metadata about a certain block. */
352
88
  type block = {
353
- /** String of the header */
354
89
  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
90
  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
91
  time: int,
373
- /** The String of the serialized application header for this block. */
374
- applicationHash: string,
375
92
  }
376
93
  }
377
94
 
378
95
  type queryResponseDataTyped = {
379
- transactions: array<FuelTypes.transaction>,
380
96
  receipts: array<FuelTypes.receipt>,
381
- blocks: option<array<FuelTypes.block>>,
382
- inputs: array<FuelTypes.input>,
383
- outputs: array<FuelTypes.output>,
97
+ blocks: array<FuelTypes.block>,
384
98
  }
385
99
 
386
100
  type queryResponseTyped = {
387
- /** Current height of the source hypersync instance */
101
+ /** Current height of the source HyperFuel instance */
388
102
  archiveHeight?: int,
389
103
  /**
390
104
  * Next block to query for, the responses are paginated so
@@ -392,17 +106,22 @@ type queryResponseTyped = {
392
106
  * didn't get responses up to the to_block they specified in the Query.
393
107
  */
394
108
  nextBlock: int,
395
- /** Total time it took the hypersync instance to execute the query. */
109
+ /** Total time it took the HyperFuel instance to execute the query. */
396
110
  totalExecutionTime: int,
397
111
  /** Response data */
398
112
  data: queryResponseDataTyped,
399
113
  }
400
114
 
401
- @module("@envio-dev/hyperfuel-client") @scope("HyperfuelClient")
402
- external make: cfg => t = "new"
115
+ @send
116
+ external classNew: (Core.hyperfuelClientCtor, cfg, ~userAgent: string) => t = "new"
117
+
403
118
  let make = (cfg: cfg) => {
404
- make({...cfg, bearerToken: "3dc856dd-b0ea-494f-b27e-017b8b6b7e07"})
119
+ let envioVersion = Utils.EnvioPackage.value.version
120
+ Core.getAddon().hyperfuelClient->classNew(cfg, ~userAgent=`hyperindex/${envioVersion}`)
405
121
  }
406
122
 
407
123
  @send
408
124
  external getSelectedData: (t, QueryTypes.query) => promise<queryResponseTyped> = "getSelectedData"
125
+
126
+ @send
127
+ external getHeight: t => promise<int> = "getHeight"
@@ -1,14 +1,15 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
- import * as HyperfuelClient from "@envio-dev/hyperfuel-client";
3
+ import * as Core from "../Core.res.mjs";
4
+ import * as Utils from "../Utils.res.mjs";
4
5
 
5
6
  let QueryTypes = {};
6
7
 
7
8
  let FuelTypes = {};
8
9
 
9
10
  function make(cfg) {
10
- let newrecord = {...cfg};
11
- return HyperfuelClient.HyperfuelClient.new((newrecord.bearerToken = "3dc856dd-b0ea-494f-b27e-017b8b6b7e07", newrecord));
11
+ let envioVersion = Utils.EnvioPackage.value.version;
12
+ return Core.getAddon().HyperfuelClient.new(cfg, `hyperindex/` + envioVersion);
12
13
  }
13
14
 
14
15
  export {
@@ -16,4 +17,4 @@ export {
16
17
  FuelTypes,
17
18
  make,
18
19
  }
19
- /* @envio-dev/hyperfuel-client Not a pure module */
20
+ /* Core Not a pure module */