envio 3.0.0-alpha.0 → 3.0.0-alpha.10
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/README.md +2 -2
- package/evm.schema.json +53 -57
- package/fuel.schema.json +35 -31
- package/index.d.ts +446 -1
- package/index.js +4 -0
- package/package.json +23 -11
- package/rescript.json +4 -1
- package/src/Batch.res.mjs +1 -1
- package/src/Benchmark.res +394 -0
- package/src/Benchmark.res.mjs +398 -0
- package/src/ChainFetcher.res +526 -0
- package/src/ChainFetcher.res.mjs +343 -0
- package/src/ChainManager.res +182 -0
- package/src/ChainManager.res.mjs +150 -0
- package/src/Config.res +367 -27
- package/src/Config.res.mjs +338 -28
- package/src/{Indexer.res → Ctx.res} +1 -1
- package/src/Ecosystem.res +25 -0
- package/src/Ecosystem.res.mjs +29 -0
- package/src/Env.res +252 -0
- package/src/Env.res.mjs +271 -0
- package/src/Envio.gen.ts +9 -1
- package/src/Envio.res +12 -9
- package/src/EventProcessing.res +476 -0
- package/src/EventProcessing.res.mjs +341 -0
- package/src/EventRegister.res +4 -15
- package/src/EventRegister.res.mjs +3 -9
- package/src/EventRegister.resi +2 -8
- package/src/FetchState.res +54 -29
- package/src/FetchState.res.mjs +62 -35
- package/src/GlobalState.res +1163 -0
- package/src/GlobalState.res.mjs +1196 -0
- package/src/GlobalStateManager.res +68 -0
- package/src/GlobalStateManager.res.mjs +75 -0
- package/src/GlobalStateManager.resi +7 -0
- package/src/HandlerLoader.res +89 -0
- package/src/HandlerLoader.res.mjs +79 -0
- package/src/Internal.gen.ts +3 -14
- package/src/Internal.res +45 -13
- package/src/LoadLayer.res +444 -0
- package/src/LoadLayer.res.mjs +296 -0
- package/src/LoadLayer.resi +32 -0
- package/src/LogSelection.res +33 -27
- package/src/LogSelection.res.mjs +6 -0
- package/src/Logging.res +11 -4
- package/src/Logging.res.mjs +14 -6
- package/src/Main.res +351 -0
- package/src/Main.res.mjs +312 -0
- package/src/Persistence.res +1 -2
- package/src/PgStorage.gen.ts +10 -0
- package/src/PgStorage.res +28 -34
- package/src/PgStorage.res.d.mts +5 -0
- package/src/PgStorage.res.mjs +27 -27
- package/src/Prometheus.res +8 -8
- package/src/Prometheus.res.mjs +10 -10
- package/src/ReorgDetection.res +6 -10
- package/src/ReorgDetection.res.mjs +6 -6
- package/src/TestIndexer.res +536 -0
- package/src/TestIndexer.res.mjs +412 -0
- package/src/TestIndexerProxyStorage.res +210 -0
- package/src/TestIndexerProxyStorage.res.mjs +157 -0
- package/src/Types.ts +1 -1
- package/src/UserContext.res +355 -0
- package/src/UserContext.res.mjs +236 -0
- package/src/Utils.res +28 -0
- package/src/Utils.res.mjs +18 -0
- package/src/bindings/ClickHouse.res +31 -1
- package/src/bindings/ClickHouse.res.mjs +27 -1
- package/src/bindings/DateFns.res +71 -0
- package/src/bindings/DateFns.res.mjs +22 -0
- package/src/bindings/Ethers.res +27 -67
- package/src/bindings/Ethers.res.mjs +18 -70
- package/src/bindings/EventSource.res +13 -0
- package/src/bindings/EventSource.res.mjs +2 -0
- package/src/bindings/NodeJs.res +44 -3
- package/src/bindings/NodeJs.res.mjs +11 -3
- package/src/bindings/Pino.res +21 -7
- package/src/bindings/Pino.res.mjs +11 -5
- package/src/bindings/Postgres.gen.ts +8 -0
- package/src/bindings/Postgres.res +3 -0
- package/src/bindings/Postgres.res.d.mts +5 -0
- package/src/bindings/RescriptMocha.res +123 -0
- package/src/bindings/RescriptMocha.res.mjs +18 -0
- package/src/bindings/Vitest.res +134 -0
- package/src/bindings/Vitest.res.mjs +9 -0
- package/src/bindings/Yargs.res +8 -0
- package/src/bindings/Yargs.res.mjs +2 -0
- package/src/db/InternalTable.res +2 -0
- package/src/db/InternalTable.res.mjs +1 -1
- package/src/sources/Evm.res +87 -0
- package/src/sources/Evm.res.mjs +105 -0
- package/src/sources/EvmChain.res +90 -0
- package/src/sources/EvmChain.res.mjs +57 -0
- package/src/sources/Fuel.res +19 -34
- package/src/sources/Fuel.res.mjs +34 -16
- package/src/sources/FuelSDK.res +38 -0
- package/src/sources/FuelSDK.res.mjs +29 -0
- package/src/sources/HyperFuel.res +2 -2
- package/src/sources/HyperFuel.resi +1 -1
- package/src/sources/HyperFuelClient.res +2 -2
- package/src/sources/HyperFuelSource.res +8 -8
- package/src/sources/HyperFuelSource.res.mjs +5 -5
- package/src/sources/HyperSyncHeightStream.res +97 -0
- package/src/sources/HyperSyncHeightStream.res.mjs +94 -0
- package/src/sources/HyperSyncSource.res +64 -172
- package/src/sources/HyperSyncSource.res.mjs +73 -155
- package/src/sources/Rpc.res +43 -0
- package/src/sources/Rpc.res.mjs +31 -0
- package/src/sources/RpcSource.res +32 -130
- package/src/sources/RpcSource.res.mjs +47 -121
- package/src/sources/Source.res +3 -2
- package/src/sources/SourceManager.res +183 -108
- package/src/sources/SourceManager.res.mjs +162 -99
- package/src/sources/SourceManager.resi +4 -5
- package/src/sources/Svm.res +59 -0
- package/src/sources/Svm.res.mjs +79 -0
- package/src/tui/Tui.res +266 -0
- package/src/tui/Tui.res.mjs +342 -0
- package/src/tui/bindings/Ink.res +376 -0
- package/src/tui/bindings/Ink.res.mjs +75 -0
- package/src/tui/bindings/Style.res +123 -0
- package/src/tui/bindings/Style.res.mjs +2 -0
- package/src/tui/components/BufferedProgressBar.res +40 -0
- package/src/tui/components/BufferedProgressBar.res.mjs +57 -0
- package/src/tui/components/CustomHooks.res +122 -0
- package/src/tui/components/CustomHooks.res.mjs +179 -0
- package/src/tui/components/Messages.res +41 -0
- package/src/tui/components/Messages.res.mjs +75 -0
- package/src/tui/components/SyncETA.res +193 -0
- package/src/tui/components/SyncETA.res.mjs +269 -0
- package/src/tui/components/TuiData.res +46 -0
- package/src/tui/components/TuiData.res.mjs +29 -0
- package/src/Platform.res +0 -140
- package/src/Platform.res.mjs +0 -170
- package/src/bindings/Ethers.gen.ts +0 -14
- /package/src/{Indexer.res.mjs → Ctx.res.mjs} +0 -0
package/src/Config.res.mjs
CHANGED
|
@@ -1,30 +1,303 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as Evm from "./sources/Evm.res.mjs";
|
|
4
|
+
import * as Svm from "./sources/Svm.res.mjs";
|
|
5
|
+
import * as Fuel from "./sources/Fuel.res.mjs";
|
|
3
6
|
import * as Utils from "./Utils.res.mjs";
|
|
4
7
|
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
8
|
+
import * as Address from "./Address.res.mjs";
|
|
9
|
+
import * as Js_dict from "rescript/lib/es6/js_dict.js";
|
|
5
10
|
import * as ChainMap from "./ChainMap.res.mjs";
|
|
6
|
-
import * as Platform from "./Platform.res.mjs";
|
|
7
11
|
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
12
|
+
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
13
|
+
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
14
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
15
|
+
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
8
16
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
var rpcSourceForSchema = S$RescriptSchema.$$enum([
|
|
18
|
+
"sync",
|
|
19
|
+
"fallback",
|
|
20
|
+
"live"
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
var rpcConfigSchema = S$RescriptSchema.schema(function (s) {
|
|
24
|
+
return {
|
|
25
|
+
url: s.m(S$RescriptSchema.string),
|
|
26
|
+
for: s.m(rpcSourceForSchema),
|
|
27
|
+
initialBlockInterval: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
28
|
+
backoffMultiplicative: s.m(S$RescriptSchema.option(S$RescriptSchema.$$float)),
|
|
29
|
+
accelerationAdditive: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
30
|
+
intervalCeiling: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
31
|
+
backoffMillis: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
32
|
+
fallbackStallTimeout: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
33
|
+
queryTimeoutMillis: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int))
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
var publicConfigChainSchema = S$RescriptSchema.schema(function (s) {
|
|
38
|
+
return {
|
|
39
|
+
id: s.m(S$RescriptSchema.$$int),
|
|
40
|
+
startBlock: s.m(S$RescriptSchema.$$int),
|
|
41
|
+
endBlock: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
42
|
+
maxReorgDepth: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
43
|
+
hypersync: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
44
|
+
rpcs: s.m(S$RescriptSchema.option(S$RescriptSchema.array(rpcConfigSchema))),
|
|
45
|
+
rpc: s.m(S$RescriptSchema.option(S$RescriptSchema.string))
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
var contractEventItemSchema = S$RescriptSchema.schema(function (s) {
|
|
50
|
+
return {
|
|
51
|
+
event: s.m(S$RescriptSchema.string)
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
var contractConfigSchema = S$RescriptSchema.schema(function (s) {
|
|
56
|
+
return {
|
|
57
|
+
abi: s.m(S$RescriptSchema.json(false)),
|
|
58
|
+
handler: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
59
|
+
events: s.m(S$RescriptSchema.option(S$RescriptSchema.array(contractEventItemSchema)))
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
var publicConfigEcosystemSchema = S$RescriptSchema.schema(function (s) {
|
|
64
|
+
return {
|
|
65
|
+
chains: s.m(S$RescriptSchema.dict(publicConfigChainSchema)),
|
|
66
|
+
contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(contractConfigSchema)))
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var publicConfigEvmSchema = S$RescriptSchema.schema(function (s) {
|
|
71
|
+
return {
|
|
72
|
+
chains: s.m(S$RescriptSchema.dict(publicConfigChainSchema)),
|
|
73
|
+
contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(contractConfigSchema))),
|
|
74
|
+
addressFormat: s.m(S$RescriptSchema.option(S$RescriptSchema.$$enum([
|
|
75
|
+
"lowercase",
|
|
76
|
+
"checksum"
|
|
77
|
+
])))
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
var multichainSchema = S$RescriptSchema.$$enum([
|
|
82
|
+
"ordered",
|
|
83
|
+
"unordered"
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
var publicConfigSchema = S$RescriptSchema.schema(function (s) {
|
|
87
|
+
return {
|
|
88
|
+
name: s.m(S$RescriptSchema.string),
|
|
89
|
+
description: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
90
|
+
handlers: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
91
|
+
multichain: s.m(S$RescriptSchema.option(multichainSchema)),
|
|
92
|
+
fullBatchSize: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
93
|
+
rollbackOnReorg: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
|
|
94
|
+
saveFullHistory: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
|
|
95
|
+
rawEvents: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
|
|
96
|
+
evm: s.m(S$RescriptSchema.option(publicConfigEvmSchema)),
|
|
97
|
+
fuel: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema)),
|
|
98
|
+
svm: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema))
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
function fromPublic(publicConfigJson, codegenChainsOpt, maxAddrInPartitionOpt, userEntitiesOpt) {
|
|
103
|
+
var codegenChains = codegenChainsOpt !== undefined ? codegenChainsOpt : [];
|
|
20
104
|
var maxAddrInPartition = maxAddrInPartitionOpt !== undefined ? maxAddrInPartitionOpt : 5000;
|
|
21
|
-
|
|
22
|
-
|
|
105
|
+
var userEntities = userEntitiesOpt !== undefined ? userEntitiesOpt : [];
|
|
106
|
+
var publicConfig;
|
|
107
|
+
try {
|
|
108
|
+
publicConfig = S$RescriptSchema.parseOrThrow(publicConfigJson, publicConfigSchema);
|
|
23
109
|
}
|
|
24
|
-
|
|
110
|
+
catch (raw_exn){
|
|
111
|
+
var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
|
|
112
|
+
if (exn.RE_EXN_ID === S$RescriptSchema.Raised) {
|
|
113
|
+
publicConfig = Js_exn.raiseError("Invalid internal.config.ts: " + Utils.prettifyExn(exn._1));
|
|
114
|
+
} else {
|
|
115
|
+
throw exn;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var match = publicConfig.evm;
|
|
119
|
+
var match$1 = publicConfig.fuel;
|
|
120
|
+
var match$2 = publicConfig.svm;
|
|
121
|
+
var match$3 = match !== undefined ? (
|
|
122
|
+
match$1 !== undefined || match$2 !== undefined ? Js_exn.raiseError("Invalid indexer config: Multiple ecosystems are not supported for a single indexer") : [
|
|
123
|
+
Caml_option.valFromOption(match).chains,
|
|
124
|
+
"evm"
|
|
125
|
+
]
|
|
126
|
+
) : (
|
|
127
|
+
match$1 !== undefined ? (
|
|
128
|
+
match$2 !== undefined ? Js_exn.raiseError("Invalid indexer config: Multiple ecosystems are not supported for a single indexer") : [
|
|
129
|
+
Caml_option.valFromOption(match$1).chains,
|
|
130
|
+
"fuel"
|
|
131
|
+
]
|
|
132
|
+
) : (
|
|
133
|
+
match$2 !== undefined ? [
|
|
134
|
+
Caml_option.valFromOption(match$2).chains,
|
|
135
|
+
"svm"
|
|
136
|
+
] : Js_exn.raiseError("Invalid indexer config: No ecosystem configured (evm, fuel, or svm)")
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
var ecosystemName = match$3[1];
|
|
140
|
+
var publicChainsConfig = match$3[0];
|
|
141
|
+
var evm = publicConfig.evm;
|
|
142
|
+
var lowercaseAddresses = evm !== undefined ? Belt_Option.getWithDefault(Caml_option.valFromOption(evm).addressFormat, "checksum") === "lowercase" : false;
|
|
143
|
+
var match$4 = publicConfig.evm;
|
|
144
|
+
var match$5 = publicConfig.fuel;
|
|
145
|
+
var publicContractsConfig;
|
|
146
|
+
switch (ecosystemName) {
|
|
147
|
+
case "evm" :
|
|
148
|
+
publicContractsConfig = match$4 !== undefined ? Caml_option.valFromOption(match$4).contracts : undefined;
|
|
149
|
+
break;
|
|
150
|
+
case "fuel" :
|
|
151
|
+
publicContractsConfig = match$5 !== undefined ? Caml_option.valFromOption(match$5).contracts : undefined;
|
|
152
|
+
break;
|
|
153
|
+
case "svm" :
|
|
154
|
+
publicContractsConfig = undefined;
|
|
155
|
+
break;
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
var contractsWithAbis = publicContractsConfig !== undefined ? Js_dict.fromArray(Js_dict.entries(publicContractsConfig).map(function (param) {
|
|
159
|
+
var contractConfig = param[1];
|
|
160
|
+
var abi = contractConfig.abi;
|
|
161
|
+
var events = contractConfig.events;
|
|
162
|
+
var eventSignatures = events !== undefined ? Belt_Array.map(events, (function (eventItem) {
|
|
163
|
+
return eventItem.event;
|
|
164
|
+
})) : [];
|
|
165
|
+
return [
|
|
166
|
+
param[0],
|
|
167
|
+
[
|
|
168
|
+
abi,
|
|
169
|
+
eventSignatures
|
|
170
|
+
]
|
|
171
|
+
];
|
|
172
|
+
})) : ({});
|
|
173
|
+
var codegenChainById = {};
|
|
174
|
+
Belt_Array.forEach(codegenChains, (function (codegenChain) {
|
|
175
|
+
codegenChainById[String(codegenChain.id)] = codegenChain;
|
|
176
|
+
}));
|
|
177
|
+
var contractsByChainId = {};
|
|
178
|
+
Belt_Array.forEach(codegenChains, (function (codegenChain) {
|
|
179
|
+
var mergedContracts = Belt_Array.map(codegenChain.contracts, (function (codegenContract) {
|
|
180
|
+
var match = Js_dict.get(contractsWithAbis, codegenContract.name);
|
|
181
|
+
if (match === undefined) {
|
|
182
|
+
return Js_exn.raiseError("Contract \"" + codegenContract.name + "\" is missing ABI in public config (internal.config.ts)");
|
|
183
|
+
}
|
|
184
|
+
var parsedAddresses = Belt_Array.map(codegenContract.addresses, (function (addressString) {
|
|
185
|
+
switch (ecosystemName) {
|
|
186
|
+
case "evm" :
|
|
187
|
+
if (lowercaseAddresses) {
|
|
188
|
+
return Address.Evm.fromStringLowercaseOrThrow(addressString);
|
|
189
|
+
} else {
|
|
190
|
+
return Address.Evm.fromStringOrThrow(addressString);
|
|
191
|
+
}
|
|
192
|
+
case "fuel" :
|
|
193
|
+
case "svm" :
|
|
194
|
+
return addressString;
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
}));
|
|
198
|
+
return {
|
|
199
|
+
name: codegenContract.name,
|
|
200
|
+
abi: match[0],
|
|
201
|
+
addresses: parsedAddresses,
|
|
202
|
+
events: codegenContract.events,
|
|
203
|
+
startBlock: codegenContract.startBlock,
|
|
204
|
+
eventSignatures: match[1]
|
|
205
|
+
};
|
|
206
|
+
}));
|
|
207
|
+
contractsByChainId[String(codegenChain.id)] = mergedContracts;
|
|
208
|
+
}));
|
|
209
|
+
var parseRpcSourceFor = function (sourceFor) {
|
|
210
|
+
switch (sourceFor) {
|
|
211
|
+
case "sync" :
|
|
212
|
+
return "Sync";
|
|
213
|
+
case "fallback" :
|
|
214
|
+
return "Fallback";
|
|
215
|
+
case "live" :
|
|
216
|
+
return "Live";
|
|
217
|
+
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
var chains = Object.keys(publicChainsConfig).map(function (chainName) {
|
|
221
|
+
var publicChainConfig = publicChainsConfig[chainName];
|
|
222
|
+
var chainId = publicChainConfig.id;
|
|
223
|
+
var c = Js_dict.get(codegenChainById, String(chainId));
|
|
224
|
+
var codegenChain = c !== undefined ? c : Js_exn.raiseError("Chain with id " + String(chainId) + " not found in codegen chains");
|
|
225
|
+
var contracts = Js_dict.get(contractsByChainId, String(chainId));
|
|
226
|
+
var mergedContracts = contracts !== undefined ? contracts : Js_exn.raiseError("Contracts for chain with id " + String(chainId) + " not found in merged contracts");
|
|
227
|
+
var sourceConfig;
|
|
228
|
+
switch (ecosystemName) {
|
|
229
|
+
case "evm" :
|
|
230
|
+
var rpcs = Belt_Array.map(Belt_Option.getWithDefault(publicChainConfig.rpcs, []), (function (rpcConfig) {
|
|
231
|
+
var initialBlockInterval = rpcConfig.initialBlockInterval;
|
|
232
|
+
var backoffMultiplicative = rpcConfig.backoffMultiplicative;
|
|
233
|
+
var accelerationAdditive = rpcConfig.accelerationAdditive;
|
|
234
|
+
var intervalCeiling = rpcConfig.intervalCeiling;
|
|
235
|
+
var backoffMillis = rpcConfig.backoffMillis;
|
|
236
|
+
var queryTimeoutMillis = rpcConfig.queryTimeoutMillis;
|
|
237
|
+
var fallbackStallTimeout = rpcConfig.fallbackStallTimeout;
|
|
238
|
+
var hasSyncConfig = Belt_Option.isSome(initialBlockInterval) || Belt_Option.isSome(backoffMultiplicative) || Belt_Option.isSome(accelerationAdditive) || Belt_Option.isSome(intervalCeiling) || Belt_Option.isSome(backoffMillis) || Belt_Option.isSome(queryTimeoutMillis) || Belt_Option.isSome(fallbackStallTimeout);
|
|
239
|
+
var syncConfig = hasSyncConfig ? ({
|
|
240
|
+
initialBlockInterval: initialBlockInterval,
|
|
241
|
+
backoffMultiplicative: backoffMultiplicative,
|
|
242
|
+
accelerationAdditive: accelerationAdditive,
|
|
243
|
+
intervalCeiling: intervalCeiling,
|
|
244
|
+
backoffMillis: backoffMillis,
|
|
245
|
+
queryTimeoutMillis: queryTimeoutMillis,
|
|
246
|
+
fallbackStallTimeout: fallbackStallTimeout
|
|
247
|
+
}) : undefined;
|
|
248
|
+
return {
|
|
249
|
+
url: rpcConfig.url,
|
|
250
|
+
sourceFor: parseRpcSourceFor(rpcConfig.for),
|
|
251
|
+
syncConfig: syncConfig
|
|
252
|
+
};
|
|
253
|
+
}));
|
|
254
|
+
sourceConfig = {
|
|
255
|
+
TAG: "EvmSourceConfig",
|
|
256
|
+
hypersync: publicChainConfig.hypersync,
|
|
257
|
+
rpcs: rpcs
|
|
258
|
+
};
|
|
259
|
+
break;
|
|
260
|
+
case "fuel" :
|
|
261
|
+
var hypersync = publicChainConfig.hypersync;
|
|
262
|
+
sourceConfig = hypersync !== undefined ? ({
|
|
263
|
+
TAG: "FuelSourceConfig",
|
|
264
|
+
hypersync: hypersync
|
|
265
|
+
}) : Js_exn.raiseError("Chain " + chainName + " is missing hypersync endpoint in config");
|
|
266
|
+
break;
|
|
267
|
+
case "svm" :
|
|
268
|
+
var rpc = publicChainConfig.rpc;
|
|
269
|
+
sourceConfig = rpc !== undefined ? ({
|
|
270
|
+
TAG: "SvmSourceConfig",
|
|
271
|
+
rpc: rpc
|
|
272
|
+
}) : Js_exn.raiseError("Chain " + chainName + " is missing rpc endpoint in config");
|
|
273
|
+
break;
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
var tmp;
|
|
277
|
+
switch (ecosystemName) {
|
|
278
|
+
case "evm" :
|
|
279
|
+
tmp = Belt_Option.getWithDefault(publicChainConfig.maxReorgDepth, 200);
|
|
280
|
+
break;
|
|
281
|
+
case "fuel" :
|
|
282
|
+
case "svm" :
|
|
283
|
+
tmp = 0;
|
|
284
|
+
break;
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
name: chainName,
|
|
289
|
+
id: codegenChain.id,
|
|
290
|
+
startBlock: publicChainConfig.startBlock,
|
|
291
|
+
endBlock: publicChainConfig.endBlock,
|
|
292
|
+
maxReorgDepth: tmp,
|
|
293
|
+
contracts: mergedContracts,
|
|
294
|
+
sourceConfig: sourceConfig
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
var chainMap = ChainMap.fromArrayUnsafe(chains.map(function (chain) {
|
|
25
298
|
return [
|
|
26
|
-
ChainMap.Chain.makeUnsafe(
|
|
27
|
-
|
|
299
|
+
ChainMap.Chain.makeUnsafe(chain.id),
|
|
300
|
+
chain
|
|
28
301
|
];
|
|
29
302
|
}));
|
|
30
303
|
var addContractNameToContractNameMapping = {};
|
|
@@ -34,20 +307,48 @@ function make(shouldRollbackOnReorgOpt, shouldSaveFullHistoryOpt, chainsOpt, ena
|
|
|
34
307
|
addContractNameToContractNameMapping[addKey] = contract.name;
|
|
35
308
|
}));
|
|
36
309
|
}));
|
|
37
|
-
var
|
|
310
|
+
var ecosystem;
|
|
311
|
+
switch (ecosystemName) {
|
|
312
|
+
case "evm" :
|
|
313
|
+
ecosystem = Evm.ecosystem;
|
|
314
|
+
break;
|
|
315
|
+
case "fuel" :
|
|
316
|
+
ecosystem = Fuel.ecosystem;
|
|
317
|
+
break;
|
|
318
|
+
case "svm" :
|
|
319
|
+
ecosystem = Svm.ecosystem;
|
|
320
|
+
break;
|
|
321
|
+
|
|
322
|
+
}
|
|
323
|
+
var userEntitiesByName = Js_dict.fromArray(userEntities.map(function (entityConfig) {
|
|
324
|
+
return [
|
|
325
|
+
entityConfig.name,
|
|
326
|
+
entityConfig
|
|
327
|
+
];
|
|
328
|
+
}));
|
|
329
|
+
var contractHandlers = publicContractsConfig !== undefined ? Js_dict.entries(publicContractsConfig).map(function (param) {
|
|
330
|
+
return {
|
|
331
|
+
name: param[0],
|
|
332
|
+
handler: param[1].handler
|
|
333
|
+
};
|
|
334
|
+
}) : [];
|
|
38
335
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
336
|
+
name: publicConfig.name,
|
|
337
|
+
description: publicConfig.description,
|
|
338
|
+
handlers: Belt_Option.getWithDefault(publicConfig.handlers, "src/handlers"),
|
|
339
|
+
contractHandlers: contractHandlers,
|
|
340
|
+
shouldRollbackOnReorg: Belt_Option.getWithDefault(publicConfig.rollbackOnReorg, true),
|
|
341
|
+
shouldSaveFullHistory: Belt_Option.getWithDefault(publicConfig.saveFullHistory, false),
|
|
342
|
+
multichain: Belt_Option.getWithDefault(publicConfig.multichain, "unordered"),
|
|
42
343
|
chainMap: chainMap,
|
|
43
344
|
defaultChain: Belt_Array.get(chains, 0),
|
|
44
|
-
|
|
45
|
-
enableRawEvents:
|
|
46
|
-
preloadHandlers: preloadHandlers,
|
|
345
|
+
ecosystem: ecosystem,
|
|
346
|
+
enableRawEvents: Belt_Option.getWithDefault(publicConfig.rawEvents, false),
|
|
47
347
|
maxAddrInPartition: maxAddrInPartition,
|
|
48
|
-
batchSize:
|
|
348
|
+
batchSize: Belt_Option.getWithDefault(publicConfig.fullBatchSize, 5000),
|
|
49
349
|
lowercaseAddresses: lowercaseAddresses,
|
|
50
|
-
addContractNameToContractNameMapping: addContractNameToContractNameMapping
|
|
350
|
+
addContractNameToContractNameMapping: addContractNameToContractNameMapping,
|
|
351
|
+
userEntitiesByName: userEntitiesByName
|
|
51
352
|
};
|
|
52
353
|
}
|
|
53
354
|
|
|
@@ -79,9 +380,18 @@ function getChain(config, chainId) {
|
|
|
79
380
|
}
|
|
80
381
|
|
|
81
382
|
export {
|
|
82
|
-
|
|
383
|
+
rpcSourceForSchema ,
|
|
384
|
+
rpcConfigSchema ,
|
|
385
|
+
publicConfigChainSchema ,
|
|
386
|
+
contractEventItemSchema ,
|
|
387
|
+
contractConfigSchema ,
|
|
388
|
+
publicConfigEcosystemSchema ,
|
|
389
|
+
publicConfigEvmSchema ,
|
|
390
|
+
multichainSchema ,
|
|
391
|
+
publicConfigSchema ,
|
|
392
|
+
fromPublic ,
|
|
83
393
|
shouldSaveHistory ,
|
|
84
394
|
shouldPruneHistory ,
|
|
85
395
|
getChain ,
|
|
86
396
|
}
|
|
87
|
-
/*
|
|
397
|
+
/* rpcSourceForSchema Not a pure module */
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type name = | @as("evm") Evm | @as("fuel") Fuel | @as("svm") Svm
|
|
2
|
+
|
|
3
|
+
type t = {
|
|
4
|
+
name: name,
|
|
5
|
+
blockFields: array<string>,
|
|
6
|
+
transactionFields: array<string>,
|
|
7
|
+
blockNumberName: string,
|
|
8
|
+
blockTimestampName: string,
|
|
9
|
+
blockHashName: string,
|
|
10
|
+
getNumber: Internal.eventBlock => int,
|
|
11
|
+
getTimestamp: Internal.eventBlock => int,
|
|
12
|
+
getId: Internal.eventBlock => string,
|
|
13
|
+
cleanUpRawEventFieldsInPlace: Js.Json.t => unit,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let makeOnBlockArgs = (~blockNumber: int, ~ecosystem: t, ~context): Internal.onBlockArgs => {
|
|
17
|
+
switch ecosystem.name {
|
|
18
|
+
| Svm => {slot: blockNumber, context}
|
|
19
|
+
| _ => {
|
|
20
|
+
let blockEvent = Js.Dict.empty()
|
|
21
|
+
blockEvent->Js.Dict.set(ecosystem.blockNumberName, blockNumber->Utils.magic)
|
|
22
|
+
{block: blockEvent->Utils.magic, context}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
4
|
+
|
|
5
|
+
function makeOnBlockArgs(blockNumber, ecosystem, context) {
|
|
6
|
+
var match = ecosystem.name;
|
|
7
|
+
switch (match) {
|
|
8
|
+
case "evm" :
|
|
9
|
+
case "fuel" :
|
|
10
|
+
break;
|
|
11
|
+
case "svm" :
|
|
12
|
+
return {
|
|
13
|
+
slot: blockNumber,
|
|
14
|
+
context: context
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
var blockEvent = {};
|
|
19
|
+
blockEvent[ecosystem.blockNumberName] = blockNumber;
|
|
20
|
+
return {
|
|
21
|
+
block: Caml_option.some(blockEvent),
|
|
22
|
+
context: context
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
makeOnBlockArgs ,
|
|
28
|
+
}
|
|
29
|
+
/* No side effect */
|