envio 3.3.1 → 3.4.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.
- package/package.json +6 -6
- package/src/Api.res +1 -8
- package/src/Api.res.mjs +1 -5
- package/src/ChainState.res +6 -1
- package/src/ChainState.res.mjs +4 -3
- package/src/Config.res +33 -4
- package/src/Config.res.mjs +34 -5
- package/src/Core.res +30 -19
- package/src/Core.res.mjs +5 -5
- package/src/EnvioGlobal.res +0 -2
- package/src/EnvioGlobal.res.mjs +0 -1
- package/src/ExitOnCaughtUp.res +6 -2
- package/src/ExitOnCaughtUp.res.mjs +4 -0
- package/src/FetchState.res +3 -3
- package/src/HandlerRegister.res +357 -434
- package/src/HandlerRegister.res.mjs +202 -242
- package/src/HandlerRegister.resi +7 -15
- package/src/IndexerState.res +10 -0
- package/src/IndexerState.res.mjs +9 -3
- package/src/IndexerState.resi +3 -0
- package/src/Internal.res +10 -1
- package/src/Main.res.mjs +4 -4
- package/src/PgStorage.res +52 -26
- package/src/PgStorage.res.mjs +32 -23
- package/src/SimulateItems.res +61 -40
- package/src/SimulateItems.res.mjs +37 -21
- package/src/TestIndexer.res +446 -453
- package/src/TestIndexer.res.mjs +320 -343
- package/src/bindings/ClickHouse.res +68 -2
- package/src/bindings/ClickHouse.res.mjs +47 -2
- package/src/sources/EvmChain.res +1 -1
- package/src/sources/EvmChain.res.mjs +2 -2
- package/src/sources/FuelHyperSync.res +74 -0
- package/src/sources/FuelHyperSync.res.mjs +80 -0
- package/src/sources/FuelHyperSync.resi +22 -0
- package/src/sources/FuelHyperSyncClient.res +120 -0
- package/src/sources/FuelHyperSyncClient.res.mjs +71 -0
- package/src/sources/FuelHyperSyncSource.res +257 -0
- package/src/sources/FuelHyperSyncSource.res.mjs +252 -0
- package/src/sources/HyperSyncClient.res +2 -2
- package/src/sources/HyperSyncClient.res.mjs +1 -1
- package/src/sources/SvmHyperSyncClient.res +139 -102
- package/src/sources/SvmHyperSyncClient.res.mjs +45 -5
- package/src/sources/SvmHyperSyncSource.res +60 -440
- package/src/sources/SvmHyperSyncSource.res.mjs +42 -363
- package/src/TestIndexerProxyStorage.res +0 -196
- package/src/TestIndexerProxyStorage.res.mjs +0 -121
- package/src/TestIndexerWorker.res +0 -4
- package/src/TestIndexerWorker.res.mjs +0 -7
- package/src/sources/EventRouter.res +0 -165
- package/src/sources/EventRouter.res.mjs +0 -153
- package/src/sources/HyperFuel.res +0 -179
- package/src/sources/HyperFuel.res.mjs +0 -146
- package/src/sources/HyperFuel.resi +0 -36
- package/src/sources/HyperFuelClient.res +0 -127
- package/src/sources/HyperFuelClient.res.mjs +0 -20
- package/src/sources/HyperFuelSource.res +0 -502
- package/src/sources/HyperFuelSource.res.mjs +0 -481
- /package/src/sources/{HyperSyncSource.res → EvmHyperSyncSource.res} +0 -0
- /package/src/sources/{HyperSyncSource.res.mjs → EvmHyperSyncSource.res.mjs} +0 -0
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
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";
|
|
6
|
-
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
7
|
-
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
8
|
-
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
9
|
-
|
|
10
|
-
let $$Error = /* @__PURE__ */Primitive_exceptions.create("HyperFuel.GetLogs.Error");
|
|
11
|
-
|
|
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);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function makeRequestBody(fromBlock, toBlockInclusive, recieptsSelection) {
|
|
34
|
-
return {
|
|
35
|
-
fromBlock: fromBlock,
|
|
36
|
-
toBlock: toBlockInclusive !== undefined ? toBlockInclusive + 1 | 0 : undefined,
|
|
37
|
-
receipts: recieptsSelection,
|
|
38
|
-
fieldSelection: {
|
|
39
|
-
block: [
|
|
40
|
-
"id",
|
|
41
|
-
"height",
|
|
42
|
-
"time"
|
|
43
|
-
],
|
|
44
|
-
receipt: [
|
|
45
|
-
"tx_id",
|
|
46
|
-
"block_height",
|
|
47
|
-
"root_contract_id",
|
|
48
|
-
"data",
|
|
49
|
-
"receipt_index",
|
|
50
|
-
"receipt_type",
|
|
51
|
-
"rb",
|
|
52
|
-
"sub_id",
|
|
53
|
-
"val",
|
|
54
|
-
"amount",
|
|
55
|
-
"to_address",
|
|
56
|
-
"asset_id",
|
|
57
|
-
"to"
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function getParam(param, name) {
|
|
64
|
-
if (param !== undefined) {
|
|
65
|
-
return Primitive_option.valFromOption(param);
|
|
66
|
-
}
|
|
67
|
-
throw {
|
|
68
|
-
RE_EXN_ID: $$Error,
|
|
69
|
-
_1: {
|
|
70
|
-
TAG: "UnexpectedMissingParams",
|
|
71
|
-
missingParams: [name]
|
|
72
|
-
},
|
|
73
|
-
Error: new Error()
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function decodeLogQueryPageItems(response_data) {
|
|
78
|
-
let blocksDict = {};
|
|
79
|
-
response_data.blocks.forEach(block => {
|
|
80
|
-
blocksDict[block.height] = block;
|
|
81
|
-
});
|
|
82
|
-
let items = [];
|
|
83
|
-
response_data.receipts.forEach(receipt => {
|
|
84
|
-
let contractId = receipt.rootContractId;
|
|
85
|
-
if (contractId === undefined) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
let block = getParam(blocksDict[receipt.blockHeight], "Failed to find block associated to receipt");
|
|
89
|
-
items.push({
|
|
90
|
-
transactionId: receipt.txId,
|
|
91
|
-
contractId: Primitive_option.valFromOption(contractId),
|
|
92
|
-
receipt: receipt,
|
|
93
|
-
receiptIndex: receipt.receiptIndex,
|
|
94
|
-
block: {
|
|
95
|
-
id: block.id,
|
|
96
|
-
time: block.time,
|
|
97
|
-
height: block.height
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
return items;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async function query(client, fromBlock, toBlock, recieptsSelection) {
|
|
105
|
-
let query$1 = makeRequestBody(fromBlock, toBlock, recieptsSelection);
|
|
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
|
-
}
|
|
124
|
-
if (res.nextBlock <= fromBlock) {
|
|
125
|
-
throw {
|
|
126
|
-
RE_EXN_ID: $$Error,
|
|
127
|
-
_1: "WrongInstance",
|
|
128
|
-
Error: new Error()
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
items: decodeLogQueryPageItems(res.data),
|
|
133
|
-
nextBlock: res.nextBlock,
|
|
134
|
-
archiveHeight: Stdlib_Option.getOr(res.archiveHeight, 0)
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
let GetLogs = {
|
|
139
|
-
$$Error: $$Error,
|
|
140
|
-
query: query
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export {
|
|
144
|
-
GetLogs,
|
|
145
|
-
}
|
|
146
|
-
/* Stdlib_JsExn Not a pure module */
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
type hyperSyncPage<'item> = {
|
|
2
|
-
items: array<'item>,
|
|
3
|
-
nextBlock: int,
|
|
4
|
-
archiveHeight: int,
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
type block = {
|
|
8
|
-
id: string,
|
|
9
|
-
time: int,
|
|
10
|
-
height: int,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type item = {
|
|
14
|
-
transactionId: string,
|
|
15
|
-
contractId: Address.t,
|
|
16
|
-
receipt: FuelSDK.Receipt.t,
|
|
17
|
-
receiptIndex: int,
|
|
18
|
-
block: block,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type logsQueryPage = hyperSyncPage<item>
|
|
22
|
-
|
|
23
|
-
module GetLogs: {
|
|
24
|
-
type error =
|
|
25
|
-
| UnexpectedMissingParams({missingParams: array<string>})
|
|
26
|
-
| WrongInstance
|
|
27
|
-
|
|
28
|
-
exception Error(error)
|
|
29
|
-
|
|
30
|
-
let query: (
|
|
31
|
-
~client: HyperFuelClient.t,
|
|
32
|
-
~fromBlock: int,
|
|
33
|
-
~toBlock: option<int>,
|
|
34
|
-
~recieptsSelection: array<HyperFuelClient.QueryTypes.receiptSelection>,
|
|
35
|
-
) => promise<logsQueryPage>
|
|
36
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
type t
|
|
2
|
-
|
|
3
|
-
type cfg = {
|
|
4
|
-
url: string,
|
|
5
|
-
apiToken: string,
|
|
6
|
-
}
|
|
7
|
-
module QueryTypes = {
|
|
8
|
-
type blockFieldOptions =
|
|
9
|
-
| @as("id") Id
|
|
10
|
-
| @as("height") Height
|
|
11
|
-
| @as("time") Time
|
|
12
|
-
|
|
13
|
-
type blockFieldSelection = array<blockFieldOptions>
|
|
14
|
-
|
|
15
|
-
type receiptFieldOptions =
|
|
16
|
-
| @as("tx_id") TxId
|
|
17
|
-
| @as("block_height") BlockHeight
|
|
18
|
-
| @as("to_address") ToAddress
|
|
19
|
-
| @as("amount") Amount
|
|
20
|
-
| @as("asset_id") AssetId
|
|
21
|
-
| @as("val") Val
|
|
22
|
-
| @as("rb") Rb
|
|
23
|
-
| @as("receipt_type") ReceiptType
|
|
24
|
-
| @as("receipt_index") ReceiptIndex
|
|
25
|
-
| @as("data") Data
|
|
26
|
-
| @as("root_contract_id") RootContractId
|
|
27
|
-
| @as("sub_id") SubId
|
|
28
|
-
| @as("to") To
|
|
29
|
-
|
|
30
|
-
type receiptFieldSelection = array<receiptFieldOptions>
|
|
31
|
-
|
|
32
|
-
type fieldSelection = {
|
|
33
|
-
block?: blockFieldSelection,
|
|
34
|
-
receipt?: receiptFieldSelection,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type receiptSelection = {
|
|
38
|
-
rootContractId?: array<Address.t>,
|
|
39
|
-
receiptType?: array<FuelSDK.receiptType>,
|
|
40
|
-
rb?: array<bigint>,
|
|
41
|
-
txStatus?: array<int>,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
type query = {
|
|
45
|
-
/** The block to start the query from */
|
|
46
|
-
fromBlock: int,
|
|
47
|
-
/**
|
|
48
|
-
* The block to end the query at. If not specified, the query will go until the
|
|
49
|
-
* end of data. Exclusive, the returned range will be [from_block..to_block).
|
|
50
|
-
*
|
|
51
|
-
* The query will return before it reaches this target block if it hits the time limit
|
|
52
|
-
* configured on the server. The user should continue their query by putting the
|
|
53
|
-
* next_block field in the response into from_block field of their next query. This implements
|
|
54
|
-
* pagination.
|
|
55
|
-
*/
|
|
56
|
-
@as("toBlock")
|
|
57
|
-
toBlockExclusive?: int,
|
|
58
|
-
/**
|
|
59
|
-
* List of receipt selections, the query will return receipts that match any of these selections and
|
|
60
|
-
* it will return receipts that are related to the returned objects.
|
|
61
|
-
*/
|
|
62
|
-
receipts?: array<receiptSelection>,
|
|
63
|
-
/**
|
|
64
|
-
* Field selection. The user can select which fields they are interested in, requesting less fields will improve
|
|
65
|
-
* query execution time and reduce the payload size so the user should always use a minimal number of fields.
|
|
66
|
-
*/
|
|
67
|
-
fieldSelection: fieldSelection,
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module FuelTypes = {
|
|
72
|
-
type receipt = {
|
|
73
|
-
receiptIndex: int,
|
|
74
|
-
rootContractId?: Address.t,
|
|
75
|
-
txId: string,
|
|
76
|
-
blockHeight: int,
|
|
77
|
-
receiptType: FuelSDK.receiptType,
|
|
78
|
-
data?: string,
|
|
79
|
-
rb?: bigint,
|
|
80
|
-
val?: bigint,
|
|
81
|
-
subId?: string,
|
|
82
|
-
amount?: bigint,
|
|
83
|
-
assetId?: string,
|
|
84
|
-
to?: string,
|
|
85
|
-
toAddress?: string,
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
type block = {
|
|
89
|
-
id: string,
|
|
90
|
-
height: int,
|
|
91
|
-
time: int,
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
type queryResponseDataTyped = {
|
|
96
|
-
receipts: array<FuelTypes.receipt>,
|
|
97
|
-
blocks: array<FuelTypes.block>,
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
type queryResponseTyped = {
|
|
101
|
-
/** Current height of the source HyperFuel instance */
|
|
102
|
-
archiveHeight?: int,
|
|
103
|
-
/**
|
|
104
|
-
* Next block to query for, the responses are paginated so
|
|
105
|
-
* the caller should continue the query from this block if they
|
|
106
|
-
* didn't get responses up to the to_block they specified in the Query.
|
|
107
|
-
*/
|
|
108
|
-
nextBlock: int,
|
|
109
|
-
/** Total time it took the HyperFuel instance to execute the query. */
|
|
110
|
-
totalExecutionTime: int,
|
|
111
|
-
/** Response data */
|
|
112
|
-
data: queryResponseDataTyped,
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@send
|
|
116
|
-
external classNew: (Core.hyperfuelClientCtor, cfg, ~userAgent: string) => t = "new"
|
|
117
|
-
|
|
118
|
-
let make = (cfg: cfg) => {
|
|
119
|
-
let envioVersion = Utils.EnvioPackage.value.version
|
|
120
|
-
Core.getAddon().hyperfuelClient->classNew(cfg, ~userAgent=`hyperindex/${envioVersion}`)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@send
|
|
124
|
-
external getSelectedData: (t, QueryTypes.query) => promise<queryResponseTyped> = "getSelectedData"
|
|
125
|
-
|
|
126
|
-
@send
|
|
127
|
-
external getHeight: t => promise<int> = "getHeight"
|
|
@@ -1,20 +0,0 @@
|
|
|
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 FuelTypes = {};
|
|
9
|
-
|
|
10
|
-
function make(cfg) {
|
|
11
|
-
let envioVersion = Utils.EnvioPackage.value.version;
|
|
12
|
-
return Core.getAddon().HyperfuelClient.new(cfg, `hyperindex/` + envioVersion);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
QueryTypes,
|
|
17
|
-
FuelTypes,
|
|
18
|
-
make,
|
|
19
|
-
}
|
|
20
|
-
/* Core Not a pure module */
|