envio 3.0.0-alpha.2 → 3.0.0-alpha.20
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 +164 -30
- package/bin.mjs +49 -0
- package/evm.schema.json +79 -169
- package/fuel.schema.json +50 -21
- package/index.d.ts +497 -1
- package/index.js +4 -0
- package/package.json +42 -31
- package/rescript.json +4 -1
- package/src/Batch.res +11 -8
- package/src/Batch.res.mjs +11 -9
- package/src/ChainFetcher.res +531 -0
- package/src/ChainFetcher.res.mjs +339 -0
- package/src/ChainManager.res +190 -0
- package/src/ChainManager.res.mjs +166 -0
- package/src/Change.res +3 -3
- package/src/Config.gen.ts +19 -0
- package/src/Config.res +737 -22
- package/src/Config.res.mjs +703 -26
- package/src/{Indexer.res → Ctx.res} +1 -1
- package/src/Ecosystem.res +9 -124
- package/src/Ecosystem.res.mjs +19 -160
- package/src/Env.res +30 -74
- package/src/Env.res.mjs +25 -87
- package/src/Envio.gen.ts +3 -1
- package/src/Envio.res +20 -9
- package/src/EventProcessing.res +469 -0
- package/src/EventProcessing.res.mjs +337 -0
- package/src/EvmTypes.gen.ts +6 -0
- package/src/EvmTypes.res +1 -0
- package/src/FetchState.res +1256 -639
- package/src/FetchState.res.mjs +1135 -612
- package/src/GlobalState.res +1190 -0
- package/src/GlobalState.res.mjs +1183 -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/HandlerRegister.res +357 -0
- package/src/HandlerRegister.res.mjs +299 -0
- package/src/{EventRegister.resi → HandlerRegister.resi} +13 -13
- package/src/Hasura.res +111 -175
- package/src/Hasura.res.mjs +88 -150
- package/src/InMemoryStore.res +1 -1
- package/src/InMemoryStore.res.mjs +3 -3
- package/src/InMemoryTable.res +1 -1
- package/src/InMemoryTable.res.mjs +1 -1
- package/src/Internal.gen.ts +4 -0
- package/src/Internal.res +230 -12
- package/src/Internal.res.mjs +115 -1
- 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 +21 -7
- package/src/Logging.res.mjs +16 -8
- package/src/Main.res +377 -0
- package/src/Main.res.mjs +339 -0
- package/src/Persistence.res +7 -21
- package/src/Persistence.res.mjs +3 -3
- package/src/PgStorage.gen.ts +10 -0
- package/src/PgStorage.res +116 -69
- package/src/PgStorage.res.d.mts +5 -0
- package/src/PgStorage.res.mjs +93 -50
- package/src/Prometheus.res +294 -224
- package/src/Prometheus.res.mjs +353 -340
- package/src/ReorgDetection.res +6 -10
- package/src/ReorgDetection.res.mjs +6 -6
- package/src/SafeCheckpointTracking.res +4 -4
- package/src/SafeCheckpointTracking.res.mjs +2 -2
- package/src/Sink.res +4 -2
- package/src/Sink.res.mjs +2 -1
- package/src/TableIndices.res +0 -1
- package/src/TestIndexer.res +692 -0
- package/src/TestIndexer.res.mjs +527 -0
- package/src/TestIndexerProxyStorage.res +205 -0
- package/src/TestIndexerProxyStorage.res.mjs +151 -0
- package/src/TopicFilter.res +1 -1
- package/src/Types.ts +1 -1
- package/src/UserContext.res +424 -0
- package/src/UserContext.res.mjs +279 -0
- package/src/Utils.res +97 -26
- package/src/Utils.res.mjs +91 -44
- package/src/bindings/BigInt.res +10 -0
- package/src/bindings/BigInt.res.mjs +15 -0
- package/src/bindings/ClickHouse.res +120 -23
- package/src/bindings/ClickHouse.res.mjs +118 -28
- package/src/bindings/DateFns.res +74 -0
- package/src/bindings/DateFns.res.mjs +22 -0
- package/src/bindings/EventSource.res +8 -1
- package/src/bindings/EventSource.res.mjs +8 -1
- package/src/bindings/Express.res +1 -0
- package/src/bindings/Hrtime.res +14 -1
- package/src/bindings/Hrtime.res.mjs +22 -2
- package/src/bindings/Hrtime.resi +4 -0
- package/src/bindings/Lodash.res +0 -1
- package/src/bindings/NodeJs.res +49 -3
- package/src/bindings/NodeJs.res.mjs +11 -3
- package/src/bindings/Pino.res +24 -10
- package/src/bindings/Pino.res.mjs +14 -8
- package/src/bindings/Postgres.gen.ts +8 -0
- package/src/bindings/Postgres.res +5 -1
- package/src/bindings/Postgres.res.d.mts +5 -0
- package/src/bindings/PromClient.res +0 -10
- package/src/bindings/PromClient.res.mjs +0 -3
- package/src/bindings/Vitest.res +142 -0
- package/src/bindings/Vitest.res.mjs +9 -0
- package/src/bindings/WebSocket.res +27 -0
- package/src/bindings/WebSocket.res.mjs +2 -0
- package/src/bindings/Yargs.res +8 -0
- package/src/bindings/Yargs.res.mjs +2 -0
- package/src/db/EntityHistory.res +7 -7
- package/src/db/EntityHistory.res.mjs +9 -9
- package/src/db/InternalTable.res +59 -111
- package/src/db/InternalTable.res.mjs +73 -104
- package/src/db/Table.res +27 -8
- package/src/db/Table.res.mjs +25 -14
- package/src/sources/Evm.res +84 -0
- package/src/sources/Evm.res.mjs +105 -0
- package/src/sources/EvmChain.res +94 -0
- package/src/sources/EvmChain.res.mjs +60 -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 +33 -13
- package/src/sources/HyperFuelSource.res.mjs +24 -16
- package/src/sources/HyperSync.res +36 -6
- package/src/sources/HyperSync.res.mjs +9 -7
- package/src/sources/HyperSync.resi +4 -0
- package/src/sources/HyperSyncClient.res +1 -1
- package/src/sources/HyperSyncHeightStream.res +47 -116
- package/src/sources/HyperSyncHeightStream.res.mjs +46 -73
- package/src/sources/HyperSyncSource.res +118 -139
- package/src/sources/HyperSyncSource.res.mjs +104 -121
- package/src/sources/Rpc.res +86 -14
- package/src/sources/Rpc.res.mjs +101 -9
- package/src/sources/RpcSource.res +621 -364
- package/src/sources/RpcSource.res.mjs +843 -410
- package/src/sources/RpcWebSocketHeightStream.res +181 -0
- package/src/sources/RpcWebSocketHeightStream.res.mjs +196 -0
- package/src/sources/Source.res +7 -5
- package/src/sources/SourceManager.res +325 -225
- package/src/sources/SourceManager.res.mjs +314 -171
- package/src/sources/SourceManager.resi +17 -6
- package/src/sources/Svm.res +81 -0
- package/src/sources/Svm.res.mjs +90 -0
- package/src/tui/Tui.res +247 -0
- package/src/tui/Tui.res.mjs +337 -0
- package/src/tui/bindings/Ink.res +371 -0
- package/src/tui/bindings/Ink.res.mjs +72 -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 +174 -0
- package/src/tui/components/SyncETA.res.mjs +263 -0
- package/src/tui/components/TuiData.res +47 -0
- package/src/tui/components/TuiData.res.mjs +34 -0
- package/svm.schema.json +112 -0
- package/bin.js +0 -48
- package/src/EventRegister.res +0 -241
- package/src/EventRegister.res.mjs +0 -240
- package/src/bindings/Ethers.gen.ts +0 -14
- package/src/bindings/Ethers.res +0 -204
- package/src/bindings/Ethers.res.mjs +0 -130
- /package/src/{Indexer.res.mjs → Ctx.res.mjs} +0 -0
package/src/Config.res.mjs
CHANGED
|
@@ -1,29 +1,646 @@
|
|
|
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";
|
|
6
|
+
import * as Table from "./db/Table.res.mjs";
|
|
3
7
|
import * as Utils from "./Utils.res.mjs";
|
|
8
|
+
import * as $$BigInt from "./bindings/BigInt.res.mjs";
|
|
4
9
|
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
10
|
+
import * as Address from "./Address.res.mjs";
|
|
11
|
+
import * as Js_dict from "rescript/lib/es6/js_dict.js";
|
|
5
12
|
import * as ChainMap from "./ChainMap.res.mjs";
|
|
6
|
-
import * as
|
|
13
|
+
import * as Internal from "./Internal.res.mjs";
|
|
7
14
|
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
15
|
+
import * as BigDecimal from "./bindings/BigDecimal.res.mjs";
|
|
16
|
+
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
17
|
+
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
18
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
19
|
+
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
8
20
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
var name = "dynamic_contract_registry";
|
|
22
|
+
|
|
23
|
+
function makeId(chainId, contractAddress) {
|
|
24
|
+
return String(chainId) + "-" + contractAddress;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var schema = S$RescriptSchema.schema(function (s) {
|
|
28
|
+
return {
|
|
29
|
+
id: s.m(S$RescriptSchema.string),
|
|
30
|
+
chain_id: s.m(S$RescriptSchema.$$int),
|
|
31
|
+
registering_event_block_number: s.m(S$RescriptSchema.$$int),
|
|
32
|
+
registering_event_log_index: s.m(S$RescriptSchema.$$int),
|
|
33
|
+
registering_event_block_timestamp: s.m(S$RescriptSchema.$$int),
|
|
34
|
+
registering_event_contract_name: s.m(S$RescriptSchema.string),
|
|
35
|
+
registering_event_name: s.m(S$RescriptSchema.string),
|
|
36
|
+
registering_event_src_address: s.m(Address.schema),
|
|
37
|
+
contract_address: s.m(Address.schema),
|
|
38
|
+
contract_name: s.m(S$RescriptSchema.string)
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
var rowsSchema = S$RescriptSchema.array(schema);
|
|
43
|
+
|
|
44
|
+
var table = Table.mkTable(name, undefined, [
|
|
45
|
+
Table.mkField("id", "String", S$RescriptSchema.string, undefined, undefined, undefined, true, undefined, undefined),
|
|
46
|
+
Table.mkField("chain_id", "Int32", S$RescriptSchema.$$int, undefined, undefined, undefined, undefined, undefined, undefined),
|
|
47
|
+
Table.mkField("registering_event_block_number", "Int32", S$RescriptSchema.$$int, undefined, undefined, undefined, undefined, undefined, undefined),
|
|
48
|
+
Table.mkField("registering_event_log_index", "Int32", S$RescriptSchema.$$int, undefined, undefined, undefined, undefined, undefined, undefined),
|
|
49
|
+
Table.mkField("registering_event_block_timestamp", "Int32", S$RescriptSchema.$$int, undefined, undefined, undefined, undefined, undefined, undefined),
|
|
50
|
+
Table.mkField("registering_event_contract_name", "String", S$RescriptSchema.string, undefined, undefined, undefined, undefined, undefined, undefined),
|
|
51
|
+
Table.mkField("registering_event_name", "String", S$RescriptSchema.string, undefined, undefined, undefined, undefined, undefined, undefined),
|
|
52
|
+
Table.mkField("registering_event_src_address", "String", Address.schema, undefined, undefined, undefined, undefined, undefined, undefined),
|
|
53
|
+
Table.mkField("contract_address", "String", Address.schema, undefined, undefined, undefined, undefined, undefined, undefined),
|
|
54
|
+
Table.mkField("contract_name", "String", S$RescriptSchema.string, undefined, undefined, undefined, undefined, undefined, undefined)
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
var entityConfig = {
|
|
58
|
+
name: name,
|
|
59
|
+
index: -1,
|
|
60
|
+
schema: schema,
|
|
61
|
+
rowsSchema: rowsSchema,
|
|
62
|
+
table: table
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var DynamicContractRegistry = {
|
|
66
|
+
name: name,
|
|
67
|
+
index: -1,
|
|
68
|
+
makeId: makeId,
|
|
69
|
+
schema: schema,
|
|
70
|
+
rowsSchema: rowsSchema,
|
|
71
|
+
table: table,
|
|
72
|
+
entityConfig: entityConfig
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
var rpcSourceForSchema = S$RescriptSchema.$$enum([
|
|
76
|
+
"sync",
|
|
77
|
+
"fallback",
|
|
78
|
+
"live"
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
var rpcConfigSchema = S$RescriptSchema.schema(function (s) {
|
|
82
|
+
return {
|
|
83
|
+
url: s.m(S$RescriptSchema.string),
|
|
84
|
+
for: s.m(rpcSourceForSchema),
|
|
85
|
+
ws: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
86
|
+
initialBlockInterval: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
87
|
+
backoffMultiplicative: s.m(S$RescriptSchema.option(S$RescriptSchema.$$float)),
|
|
88
|
+
accelerationAdditive: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
89
|
+
intervalCeiling: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
90
|
+
backoffMillis: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
91
|
+
fallbackStallTimeout: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
92
|
+
queryTimeoutMillis: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
93
|
+
pollingInterval: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int))
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
var publicConfigChainSchema = S$RescriptSchema.schema(function (s) {
|
|
98
|
+
return {
|
|
99
|
+
id: s.m(S$RescriptSchema.$$int),
|
|
100
|
+
startBlock: s.m(S$RescriptSchema.$$int),
|
|
101
|
+
endBlock: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
102
|
+
maxReorgDepth: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
103
|
+
blockLag: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
104
|
+
hypersync: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
105
|
+
rpcs: s.m(S$RescriptSchema.option(S$RescriptSchema.array(rpcConfigSchema))),
|
|
106
|
+
rpc: s.m(S$RescriptSchema.option(S$RescriptSchema.string))
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
var contractEventItemSchema = S$RescriptSchema.schema(function (s) {
|
|
111
|
+
return {
|
|
112
|
+
event: s.m(S$RescriptSchema.string),
|
|
113
|
+
name: s.m(S$RescriptSchema.string),
|
|
114
|
+
blockFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.string))),
|
|
115
|
+
transactionFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.string)))
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
var contractConfigSchema = S$RescriptSchema.schema(function (s) {
|
|
120
|
+
return {
|
|
121
|
+
abi: s.m(S$RescriptSchema.json(false)),
|
|
122
|
+
handler: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
123
|
+
events: s.m(S$RescriptSchema.option(S$RescriptSchema.array(contractEventItemSchema)))
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
var publicConfigEcosystemSchema = S$RescriptSchema.schema(function (s) {
|
|
128
|
+
return {
|
|
129
|
+
chains: s.m(S$RescriptSchema.dict(publicConfigChainSchema)),
|
|
130
|
+
contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(contractConfigSchema)))
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
var publicConfigEvmSchema = S$RescriptSchema.schema(function (s) {
|
|
135
|
+
return {
|
|
136
|
+
chains: s.m(S$RescriptSchema.dict(publicConfigChainSchema)),
|
|
137
|
+
contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(contractConfigSchema))),
|
|
138
|
+
addressFormat: s.m(S$RescriptSchema.option(S$RescriptSchema.$$enum([
|
|
139
|
+
"lowercase",
|
|
140
|
+
"checksum"
|
|
141
|
+
]))),
|
|
142
|
+
globalBlockFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmBlockFieldSchema))),
|
|
143
|
+
globalTransactionFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmTransactionFieldSchema)))
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
var multichainSchema = S$RescriptSchema.$$enum([
|
|
148
|
+
"ordered",
|
|
149
|
+
"unordered"
|
|
150
|
+
]);
|
|
151
|
+
|
|
152
|
+
var compositeIndexFieldSchema = S$RescriptSchema.schema(function (s) {
|
|
153
|
+
return {
|
|
154
|
+
fieldName: s.m(S$RescriptSchema.string),
|
|
155
|
+
direction: s.m(S$RescriptSchema.string)
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
var derivedFieldSchema = S$RescriptSchema.schema(function (s) {
|
|
160
|
+
return {
|
|
161
|
+
fieldName: s.m(S$RescriptSchema.string),
|
|
162
|
+
derivedFromEntity: s.m(S$RescriptSchema.string),
|
|
163
|
+
derivedFromField: s.m(S$RescriptSchema.string)
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
var propertySchema = S$RescriptSchema.schema(function (s) {
|
|
168
|
+
return {
|
|
169
|
+
name: s.m(S$RescriptSchema.string),
|
|
170
|
+
type: s.m(S$RescriptSchema.string),
|
|
171
|
+
isNullable: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
|
|
172
|
+
isArray: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
|
|
173
|
+
isIndex: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
|
|
174
|
+
linkedEntity: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
175
|
+
enum: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
176
|
+
entity: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
177
|
+
precision: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
178
|
+
scale: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int))
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
var entityJsonSchema = S$RescriptSchema.schema(function (s) {
|
|
183
|
+
return {
|
|
184
|
+
name: s.m(S$RescriptSchema.string),
|
|
185
|
+
properties: s.m(S$RescriptSchema.array(propertySchema)),
|
|
186
|
+
derivedFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(derivedFieldSchema))),
|
|
187
|
+
compositeIndices: s.m(S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.array(compositeIndexFieldSchema))))
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
function getFieldTypeAndSchema(prop, enumConfigsByName) {
|
|
192
|
+
var typ = prop.type;
|
|
193
|
+
var isNullable = Belt_Option.getWithDefault(prop.isNullable, false);
|
|
194
|
+
var isArray = Belt_Option.getWithDefault(prop.isArray, false);
|
|
195
|
+
var isIndex = Belt_Option.getWithDefault(prop.isIndex, false);
|
|
196
|
+
var match;
|
|
197
|
+
switch (typ) {
|
|
198
|
+
case "bigdecimal" :
|
|
199
|
+
match = [
|
|
200
|
+
{
|
|
201
|
+
type: "BigDecimal",
|
|
202
|
+
config: Belt_Option.map(prop.precision, (function (p) {
|
|
203
|
+
return [
|
|
204
|
+
p,
|
|
205
|
+
Belt_Option.getWithDefault(prop.scale, 0)
|
|
206
|
+
];
|
|
207
|
+
}))
|
|
208
|
+
},
|
|
209
|
+
BigDecimal.schema
|
|
210
|
+
];
|
|
211
|
+
break;
|
|
212
|
+
case "bigint" :
|
|
213
|
+
match = [
|
|
214
|
+
{
|
|
215
|
+
type: "BigInt",
|
|
216
|
+
precision: prop.precision
|
|
217
|
+
},
|
|
218
|
+
$$BigInt.schema
|
|
219
|
+
];
|
|
220
|
+
break;
|
|
221
|
+
case "boolean" :
|
|
222
|
+
match = [
|
|
223
|
+
"Boolean",
|
|
224
|
+
S$RescriptSchema.bool
|
|
225
|
+
];
|
|
226
|
+
break;
|
|
227
|
+
case "date" :
|
|
228
|
+
match = [
|
|
229
|
+
"Date",
|
|
230
|
+
Utils.Schema.dbDate
|
|
231
|
+
];
|
|
232
|
+
break;
|
|
233
|
+
case "entity" :
|
|
234
|
+
var entityName = Belt_Option.getExn(prop.entity);
|
|
235
|
+
match = [
|
|
236
|
+
{
|
|
237
|
+
type: "Entity",
|
|
238
|
+
name: entityName
|
|
239
|
+
},
|
|
240
|
+
S$RescriptSchema.string
|
|
241
|
+
];
|
|
242
|
+
break;
|
|
243
|
+
case "enum" :
|
|
244
|
+
var enumName = Belt_Option.getExn(prop.enum);
|
|
245
|
+
var enumConfig = Belt_Option.getExn(Js_dict.get(enumConfigsByName, enumName));
|
|
246
|
+
match = [
|
|
247
|
+
{
|
|
248
|
+
type: "Enum",
|
|
249
|
+
config: enumConfig
|
|
250
|
+
},
|
|
251
|
+
enumConfig.schema
|
|
252
|
+
];
|
|
253
|
+
break;
|
|
254
|
+
case "float" :
|
|
255
|
+
match = [
|
|
256
|
+
"Number",
|
|
257
|
+
S$RescriptSchema.$$float
|
|
258
|
+
];
|
|
259
|
+
break;
|
|
260
|
+
case "int" :
|
|
261
|
+
match = [
|
|
262
|
+
"Int32",
|
|
263
|
+
S$RescriptSchema.$$int
|
|
264
|
+
];
|
|
265
|
+
break;
|
|
266
|
+
case "json" :
|
|
267
|
+
match = [
|
|
268
|
+
"Json",
|
|
269
|
+
S$RescriptSchema.json(false)
|
|
270
|
+
];
|
|
271
|
+
break;
|
|
272
|
+
case "serial" :
|
|
273
|
+
match = [
|
|
274
|
+
"Serial",
|
|
275
|
+
S$RescriptSchema.$$int
|
|
276
|
+
];
|
|
277
|
+
break;
|
|
278
|
+
case "string" :
|
|
279
|
+
match = [
|
|
280
|
+
"String",
|
|
281
|
+
S$RescriptSchema.string
|
|
282
|
+
];
|
|
283
|
+
break;
|
|
284
|
+
default:
|
|
285
|
+
match = Js_exn.raiseError("Unknown field type in entity config: " + typ);
|
|
286
|
+
}
|
|
287
|
+
var baseSchema = match[1];
|
|
288
|
+
var fieldSchema = isArray ? S$RescriptSchema.array(baseSchema) : baseSchema;
|
|
289
|
+
var fieldSchema$1 = isNullable ? S$RescriptSchema.$$null(fieldSchema) : fieldSchema;
|
|
290
|
+
return [
|
|
291
|
+
match[0],
|
|
292
|
+
fieldSchema$1,
|
|
293
|
+
isNullable,
|
|
294
|
+
isArray,
|
|
295
|
+
isIndex
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function parseEnumsFromJson(enumsJson) {
|
|
300
|
+
return Belt_Array.map(Js_dict.entries(enumsJson), (function (param) {
|
|
301
|
+
return Table.makeEnumConfig(param[0], param[1]);
|
|
302
|
+
}));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function parseEntitiesFromJson(entitiesJson, enumConfigsByName) {
|
|
306
|
+
return Belt_Array.mapWithIndex(entitiesJson, (function (index, entityJson) {
|
|
307
|
+
var entityName = entityJson.name;
|
|
308
|
+
var fields = Belt_Array.map(entityJson.properties, (function (prop) {
|
|
309
|
+
var match = getFieldTypeAndSchema(prop, enumConfigsByName);
|
|
310
|
+
return Table.mkField(prop.name, match[0], match[1], undefined, match[3], match[2], prop.name === "id", match[4], prop.linkedEntity);
|
|
311
|
+
}));
|
|
312
|
+
var derivedFields = Belt_Array.map(Belt_Option.getWithDefault(entityJson.derivedFields, []), (function (df) {
|
|
313
|
+
return Table.mkDerivedFromField(df.fieldName, df.derivedFromEntity, df.derivedFromField);
|
|
314
|
+
}));
|
|
315
|
+
var compositeIndices = Belt_Array.map(Belt_Option.getWithDefault(entityJson.compositeIndices, []), (function (ci) {
|
|
316
|
+
return Belt_Array.map(ci, (function (f) {
|
|
317
|
+
return {
|
|
318
|
+
fieldName: f.fieldName,
|
|
319
|
+
direction: f.direction === "Asc" ? "Asc" : "Desc"
|
|
320
|
+
};
|
|
321
|
+
}));
|
|
322
|
+
}));
|
|
323
|
+
var table = Table.mkTable(entityName, compositeIndices, Belt_Array.concat(fields, derivedFields));
|
|
324
|
+
var schema = S$RescriptSchema.schema(function (s) {
|
|
325
|
+
var dict = {};
|
|
326
|
+
Belt_Array.forEach(entityJson.properties, (function (prop) {
|
|
327
|
+
var match = getFieldTypeAndSchema(prop, enumConfigsByName);
|
|
328
|
+
var match$1 = prop.linkedEntity;
|
|
329
|
+
var dbFieldName = match$1 !== undefined ? prop.name + "_id" : prop.name;
|
|
330
|
+
dict[dbFieldName] = s.m(match[1]);
|
|
331
|
+
}));
|
|
332
|
+
return dict;
|
|
333
|
+
});
|
|
334
|
+
return {
|
|
335
|
+
name: entityName,
|
|
336
|
+
index: index,
|
|
337
|
+
schema: schema,
|
|
338
|
+
rowsSchema: S$RescriptSchema.array(schema),
|
|
339
|
+
table: table
|
|
340
|
+
};
|
|
341
|
+
}));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
var publicConfigSchema = S$RescriptSchema.schema(function (s) {
|
|
345
|
+
return {
|
|
346
|
+
name: s.m(S$RescriptSchema.string),
|
|
347
|
+
description: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
348
|
+
handlers: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
349
|
+
multichain: s.m(S$RescriptSchema.option(multichainSchema)),
|
|
350
|
+
fullBatchSize: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
|
|
351
|
+
rollbackOnReorg: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
|
|
352
|
+
saveFullHistory: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
|
|
353
|
+
rawEvents: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
|
|
354
|
+
evm: s.m(S$RescriptSchema.option(publicConfigEvmSchema)),
|
|
355
|
+
fuel: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema)),
|
|
356
|
+
svm: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema)),
|
|
357
|
+
enums: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(S$RescriptSchema.array(S$RescriptSchema.string)))),
|
|
358
|
+
entities: s.m(S$RescriptSchema.option(S$RescriptSchema.array(entityJsonSchema)))
|
|
359
|
+
};
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
var alwaysIncludedBlockFields = [
|
|
363
|
+
"number",
|
|
364
|
+
"timestamp",
|
|
365
|
+
"hash"
|
|
366
|
+
];
|
|
367
|
+
|
|
368
|
+
function enrichEvmFieldSelections(events, jsonEvents, globalBlockFieldsSet, globalTransactionFieldsSet) {
|
|
369
|
+
var fieldsByName = {};
|
|
370
|
+
if (jsonEvents !== undefined) {
|
|
371
|
+
Belt_Array.forEach(jsonEvents, (function (je) {
|
|
372
|
+
var name = je.name;
|
|
373
|
+
if (je.blockFields !== undefined || je.transactionFields !== undefined) {
|
|
374
|
+
fieldsByName[name] = je;
|
|
375
|
+
return ;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
events.forEach(function ($$event, i) {
|
|
381
|
+
var je = Js_dict.get(fieldsByName, $$event.name);
|
|
382
|
+
var match;
|
|
383
|
+
if (je !== undefined) {
|
|
384
|
+
var je$1 = Caml_option.valFromOption(je);
|
|
385
|
+
var fields = je$1.blockFields;
|
|
386
|
+
var fields$1 = je$1.transactionFields;
|
|
387
|
+
match = [
|
|
388
|
+
fields !== undefined ? new Set(Belt_Array.concat(alwaysIncludedBlockFields, fields)) : globalBlockFieldsSet,
|
|
389
|
+
fields$1 !== undefined ? new Set(fields$1) : globalTransactionFieldsSet
|
|
390
|
+
];
|
|
391
|
+
} else {
|
|
392
|
+
match = [
|
|
393
|
+
globalBlockFieldsSet,
|
|
394
|
+
globalTransactionFieldsSet
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
events[i] = {
|
|
398
|
+
id: $$event.id,
|
|
399
|
+
name: $$event.name,
|
|
400
|
+
contractName: $$event.contractName,
|
|
401
|
+
isWildcard: $$event.isWildcard,
|
|
402
|
+
filterByAddresses: $$event.filterByAddresses,
|
|
403
|
+
dependsOnAddresses: $$event.dependsOnAddresses,
|
|
404
|
+
handler: $$event.handler,
|
|
405
|
+
contractRegister: $$event.contractRegister,
|
|
406
|
+
paramsRawEventSchema: $$event.paramsRawEventSchema,
|
|
407
|
+
getEventFiltersOrThrow: $$event.getEventFiltersOrThrow,
|
|
408
|
+
convertHyperSyncEventArgs: $$event.convertHyperSyncEventArgs,
|
|
409
|
+
selectedBlockFields: match[0],
|
|
410
|
+
selectedTransactionFields: match[1]
|
|
411
|
+
};
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function fromPublic(publicConfigJson, codegenChainsOpt, maxAddrInPartitionOpt) {
|
|
416
|
+
var codegenChains = codegenChainsOpt !== undefined ? codegenChainsOpt : [];
|
|
19
417
|
var maxAddrInPartition = maxAddrInPartitionOpt !== undefined ? maxAddrInPartitionOpt : 5000;
|
|
20
|
-
|
|
21
|
-
|
|
418
|
+
var publicConfig;
|
|
419
|
+
try {
|
|
420
|
+
publicConfig = S$RescriptSchema.parseOrThrow(publicConfigJson, publicConfigSchema);
|
|
421
|
+
}
|
|
422
|
+
catch (raw_exn){
|
|
423
|
+
var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
|
|
424
|
+
if (exn.RE_EXN_ID === S$RescriptSchema.Raised) {
|
|
425
|
+
publicConfig = Js_exn.raiseError("Invalid internal.config.ts: " + Utils.prettifyExn(exn._1));
|
|
426
|
+
} else {
|
|
427
|
+
throw exn;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
var match = publicConfig.evm;
|
|
431
|
+
var match$1 = publicConfig.fuel;
|
|
432
|
+
var match$2 = publicConfig.svm;
|
|
433
|
+
var match$3 = match !== undefined ? (
|
|
434
|
+
match$1 !== undefined || match$2 !== undefined ? Js_exn.raiseError("Invalid indexer config: Multiple ecosystems are not supported for a single indexer") : [
|
|
435
|
+
Caml_option.valFromOption(match).chains,
|
|
436
|
+
"evm"
|
|
437
|
+
]
|
|
438
|
+
) : (
|
|
439
|
+
match$1 !== undefined ? (
|
|
440
|
+
match$2 !== undefined ? Js_exn.raiseError("Invalid indexer config: Multiple ecosystems are not supported for a single indexer") : [
|
|
441
|
+
Caml_option.valFromOption(match$1).chains,
|
|
442
|
+
"fuel"
|
|
443
|
+
]
|
|
444
|
+
) : (
|
|
445
|
+
match$2 !== undefined ? [
|
|
446
|
+
Caml_option.valFromOption(match$2).chains,
|
|
447
|
+
"svm"
|
|
448
|
+
] : Js_exn.raiseError("Invalid indexer config: No ecosystem configured (evm, fuel, or svm)")
|
|
449
|
+
)
|
|
450
|
+
);
|
|
451
|
+
var ecosystemName = match$3[1];
|
|
452
|
+
var publicChainsConfig = match$3[0];
|
|
453
|
+
var evm = publicConfig.evm;
|
|
454
|
+
var lowercaseAddresses = evm !== undefined ? Belt_Option.getWithDefault(Caml_option.valFromOption(evm).addressFormat, "checksum") === "lowercase" : false;
|
|
455
|
+
var match$4 = publicConfig.evm;
|
|
456
|
+
var match$5 = publicConfig.fuel;
|
|
457
|
+
var publicContractsConfig;
|
|
458
|
+
switch (ecosystemName) {
|
|
459
|
+
case "evm" :
|
|
460
|
+
publicContractsConfig = match$4 !== undefined ? Caml_option.valFromOption(match$4).contracts : undefined;
|
|
461
|
+
break;
|
|
462
|
+
case "fuel" :
|
|
463
|
+
publicContractsConfig = match$5 !== undefined ? Caml_option.valFromOption(match$5).contracts : undefined;
|
|
464
|
+
break;
|
|
465
|
+
case "svm" :
|
|
466
|
+
publicContractsConfig = undefined;
|
|
467
|
+
break;
|
|
468
|
+
|
|
469
|
+
}
|
|
470
|
+
var evm$1 = publicConfig.evm;
|
|
471
|
+
var match$6;
|
|
472
|
+
if (evm$1 !== undefined) {
|
|
473
|
+
var evm$2 = Caml_option.valFromOption(evm$1);
|
|
474
|
+
match$6 = [
|
|
475
|
+
new Set(Belt_Array.concat(alwaysIncludedBlockFields, Belt_Option.getWithDefault(evm$2.globalBlockFields, []))),
|
|
476
|
+
new Set(Belt_Option.getWithDefault(evm$2.globalTransactionFields, []))
|
|
477
|
+
];
|
|
478
|
+
} else {
|
|
479
|
+
match$6 = [
|
|
480
|
+
new Set(alwaysIncludedBlockFields),
|
|
481
|
+
new Set()
|
|
482
|
+
];
|
|
22
483
|
}
|
|
23
|
-
var
|
|
484
|
+
var globalTransactionFieldsSet = match$6[1];
|
|
485
|
+
var globalBlockFieldsSet = match$6[0];
|
|
486
|
+
var contractsWithAbis = {};
|
|
487
|
+
var jsonEventsByContract = {};
|
|
488
|
+
if (publicContractsConfig !== undefined) {
|
|
489
|
+
Belt_Array.forEach(Js_dict.entries(publicContractsConfig), (function (param) {
|
|
490
|
+
var contractConfig = param[1];
|
|
491
|
+
var capitalizedName = Utils.$$String.capitalize(param[0]);
|
|
492
|
+
var abi = contractConfig.abi;
|
|
493
|
+
var events = contractConfig.events;
|
|
494
|
+
var eventSignatures = events !== undefined ? Belt_Array.map(events, (function (eventItem) {
|
|
495
|
+
return eventItem.event;
|
|
496
|
+
})) : [];
|
|
497
|
+
contractsWithAbis[capitalizedName] = [
|
|
498
|
+
abi,
|
|
499
|
+
eventSignatures
|
|
500
|
+
];
|
|
501
|
+
var events$1 = contractConfig.events;
|
|
502
|
+
if (events$1 !== undefined) {
|
|
503
|
+
jsonEventsByContract[capitalizedName] = events$1;
|
|
504
|
+
return ;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
var codegenChainById = {};
|
|
510
|
+
Belt_Array.forEach(codegenChains, (function (codegenChain) {
|
|
511
|
+
codegenChainById[String(codegenChain.id)] = codegenChain;
|
|
512
|
+
}));
|
|
513
|
+
var contractsByChainId = {};
|
|
514
|
+
Belt_Array.forEach(codegenChains, (function (codegenChain) {
|
|
515
|
+
var mergedContracts = Belt_Array.map(codegenChain.contracts, (function (codegenContract) {
|
|
516
|
+
var match = Js_dict.get(contractsWithAbis, codegenContract.name);
|
|
517
|
+
if (match === undefined) {
|
|
518
|
+
return Js_exn.raiseError("Contract \"" + codegenContract.name + "\" is missing ABI in public config (internal.config.ts)");
|
|
519
|
+
}
|
|
520
|
+
var parsedAddresses = Belt_Array.map(codegenContract.addresses, (function (addressString) {
|
|
521
|
+
switch (ecosystemName) {
|
|
522
|
+
case "evm" :
|
|
523
|
+
if (lowercaseAddresses) {
|
|
524
|
+
return Address.Evm.fromStringLowercaseOrThrow(addressString);
|
|
525
|
+
} else {
|
|
526
|
+
return Address.Evm.fromStringOrThrow(addressString);
|
|
527
|
+
}
|
|
528
|
+
case "fuel" :
|
|
529
|
+
case "svm" :
|
|
530
|
+
return addressString;
|
|
531
|
+
|
|
532
|
+
}
|
|
533
|
+
}));
|
|
534
|
+
if (ecosystemName === "evm") {
|
|
535
|
+
enrichEvmFieldSelections(codegenContract.events, Js_dict.get(jsonEventsByContract, codegenContract.name), globalBlockFieldsSet, globalTransactionFieldsSet);
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
name: codegenContract.name,
|
|
539
|
+
abi: match[0],
|
|
540
|
+
addresses: parsedAddresses,
|
|
541
|
+
events: codegenContract.events,
|
|
542
|
+
startBlock: codegenContract.startBlock,
|
|
543
|
+
eventSignatures: match[1]
|
|
544
|
+
};
|
|
545
|
+
}));
|
|
546
|
+
contractsByChainId[String(codegenChain.id)] = mergedContracts;
|
|
547
|
+
}));
|
|
548
|
+
var parseRpcSourceFor = function (sourceFor) {
|
|
549
|
+
switch (sourceFor) {
|
|
550
|
+
case "sync" :
|
|
551
|
+
return "Sync";
|
|
552
|
+
case "fallback" :
|
|
553
|
+
return "Fallback";
|
|
554
|
+
case "live" :
|
|
555
|
+
return "Live";
|
|
556
|
+
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
var chains = Object.keys(publicChainsConfig).map(function (chainName) {
|
|
560
|
+
var publicChainConfig = publicChainsConfig[chainName];
|
|
561
|
+
var chainId = publicChainConfig.id;
|
|
562
|
+
var c = Js_dict.get(codegenChainById, String(chainId));
|
|
563
|
+
var codegenChain = c !== undefined ? c : Js_exn.raiseError("Chain with id " + String(chainId) + " not found in codegen chains");
|
|
564
|
+
var contracts = Js_dict.get(contractsByChainId, String(chainId));
|
|
565
|
+
var mergedContracts = contracts !== undefined ? contracts : Js_exn.raiseError("Contracts for chain with id " + String(chainId) + " not found in merged contracts");
|
|
566
|
+
var sourceConfig;
|
|
567
|
+
switch (ecosystemName) {
|
|
568
|
+
case "evm" :
|
|
569
|
+
var rpcs = Belt_Array.map(Belt_Option.getWithDefault(publicChainConfig.rpcs, []), (function (rpcConfig) {
|
|
570
|
+
var initialBlockInterval = rpcConfig.initialBlockInterval;
|
|
571
|
+
var backoffMultiplicative = rpcConfig.backoffMultiplicative;
|
|
572
|
+
var accelerationAdditive = rpcConfig.accelerationAdditive;
|
|
573
|
+
var intervalCeiling = rpcConfig.intervalCeiling;
|
|
574
|
+
var backoffMillis = rpcConfig.backoffMillis;
|
|
575
|
+
var queryTimeoutMillis = rpcConfig.queryTimeoutMillis;
|
|
576
|
+
var fallbackStallTimeout = rpcConfig.fallbackStallTimeout;
|
|
577
|
+
var pollingInterval = rpcConfig.pollingInterval;
|
|
578
|
+
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) || Belt_Option.isSome(pollingInterval);
|
|
579
|
+
var syncConfig = hasSyncConfig ? ({
|
|
580
|
+
initialBlockInterval: initialBlockInterval,
|
|
581
|
+
backoffMultiplicative: backoffMultiplicative,
|
|
582
|
+
accelerationAdditive: accelerationAdditive,
|
|
583
|
+
intervalCeiling: intervalCeiling,
|
|
584
|
+
backoffMillis: backoffMillis,
|
|
585
|
+
queryTimeoutMillis: queryTimeoutMillis,
|
|
586
|
+
fallbackStallTimeout: fallbackStallTimeout,
|
|
587
|
+
pollingInterval: pollingInterval
|
|
588
|
+
}) : undefined;
|
|
589
|
+
return {
|
|
590
|
+
url: rpcConfig.url,
|
|
591
|
+
sourceFor: parseRpcSourceFor(rpcConfig.for),
|
|
592
|
+
syncConfig: syncConfig,
|
|
593
|
+
ws: rpcConfig.ws
|
|
594
|
+
};
|
|
595
|
+
}));
|
|
596
|
+
sourceConfig = {
|
|
597
|
+
TAG: "EvmSourceConfig",
|
|
598
|
+
hypersync: publicChainConfig.hypersync,
|
|
599
|
+
rpcs: rpcs
|
|
600
|
+
};
|
|
601
|
+
break;
|
|
602
|
+
case "fuel" :
|
|
603
|
+
var hypersync = publicChainConfig.hypersync;
|
|
604
|
+
sourceConfig = hypersync !== undefined ? ({
|
|
605
|
+
TAG: "FuelSourceConfig",
|
|
606
|
+
hypersync: hypersync
|
|
607
|
+
}) : Js_exn.raiseError("Chain " + chainName + " is missing hypersync endpoint in config");
|
|
608
|
+
break;
|
|
609
|
+
case "svm" :
|
|
610
|
+
var rpc = publicChainConfig.rpc;
|
|
611
|
+
sourceConfig = rpc !== undefined ? ({
|
|
612
|
+
TAG: "SvmSourceConfig",
|
|
613
|
+
rpc: rpc
|
|
614
|
+
}) : Js_exn.raiseError("Chain " + chainName + " is missing rpc endpoint in config");
|
|
615
|
+
break;
|
|
616
|
+
|
|
617
|
+
}
|
|
618
|
+
var tmp;
|
|
619
|
+
switch (ecosystemName) {
|
|
620
|
+
case "evm" :
|
|
621
|
+
tmp = Belt_Option.getWithDefault(publicChainConfig.maxReorgDepth, 200);
|
|
622
|
+
break;
|
|
623
|
+
case "fuel" :
|
|
624
|
+
case "svm" :
|
|
625
|
+
tmp = 0;
|
|
626
|
+
break;
|
|
627
|
+
|
|
628
|
+
}
|
|
629
|
+
return {
|
|
630
|
+
name: chainName,
|
|
631
|
+
id: codegenChain.id,
|
|
632
|
+
startBlock: publicChainConfig.startBlock,
|
|
633
|
+
endBlock: publicChainConfig.endBlock,
|
|
634
|
+
maxReorgDepth: tmp,
|
|
635
|
+
blockLag: Belt_Option.getWithDefault(publicChainConfig.blockLag, 0),
|
|
636
|
+
contracts: mergedContracts,
|
|
637
|
+
sourceConfig: sourceConfig
|
|
638
|
+
};
|
|
639
|
+
});
|
|
640
|
+
var chainMap = ChainMap.fromArrayUnsafe(chains.map(function (chain) {
|
|
24
641
|
return [
|
|
25
|
-
ChainMap.Chain.makeUnsafe(
|
|
26
|
-
|
|
642
|
+
ChainMap.Chain.makeUnsafe(chain.id),
|
|
643
|
+
chain
|
|
27
644
|
];
|
|
28
645
|
}));
|
|
29
646
|
var addContractNameToContractNameMapping = {};
|
|
@@ -33,19 +650,60 @@ function make(shouldRollbackOnReorgOpt, shouldSaveFullHistoryOpt, chainsOpt, ena
|
|
|
33
650
|
addContractNameToContractNameMapping[addKey] = contract.name;
|
|
34
651
|
}));
|
|
35
652
|
}));
|
|
36
|
-
var ecosystem
|
|
653
|
+
var ecosystem;
|
|
654
|
+
switch (ecosystemName) {
|
|
655
|
+
case "evm" :
|
|
656
|
+
ecosystem = Evm.ecosystem;
|
|
657
|
+
break;
|
|
658
|
+
case "fuel" :
|
|
659
|
+
ecosystem = Fuel.ecosystem;
|
|
660
|
+
break;
|
|
661
|
+
case "svm" :
|
|
662
|
+
ecosystem = Svm.ecosystem;
|
|
663
|
+
break;
|
|
664
|
+
|
|
665
|
+
}
|
|
666
|
+
var allEnums = parseEnumsFromJson(Belt_Option.getWithDefault(publicConfig.enums, {}));
|
|
667
|
+
var enumConfigsByName = Js_dict.fromArray(allEnums.map(function (enumConfig) {
|
|
668
|
+
return [
|
|
669
|
+
enumConfig.name,
|
|
670
|
+
enumConfig
|
|
671
|
+
];
|
|
672
|
+
}));
|
|
673
|
+
var userEntities = parseEntitiesFromJson(Belt_Option.getWithDefault(publicConfig.entities, []), enumConfigsByName);
|
|
674
|
+
var allEntities = userEntities.concat([entityConfig]);
|
|
675
|
+
var userEntitiesByName = Js_dict.fromArray(userEntities.map(function (entityConfig) {
|
|
676
|
+
return [
|
|
677
|
+
entityConfig.name,
|
|
678
|
+
entityConfig
|
|
679
|
+
];
|
|
680
|
+
}));
|
|
681
|
+
var contractHandlers = publicContractsConfig !== undefined ? Js_dict.entries(publicContractsConfig).map(function (param) {
|
|
682
|
+
return {
|
|
683
|
+
name: Utils.$$String.capitalize(param[0]),
|
|
684
|
+
handler: param[1].handler
|
|
685
|
+
};
|
|
686
|
+
}) : [];
|
|
37
687
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
688
|
+
name: publicConfig.name,
|
|
689
|
+
description: publicConfig.description,
|
|
690
|
+
handlers: Belt_Option.getWithDefault(publicConfig.handlers, "src/handlers"),
|
|
691
|
+
contractHandlers: contractHandlers,
|
|
692
|
+
shouldRollbackOnReorg: Belt_Option.getWithDefault(publicConfig.rollbackOnReorg, true),
|
|
693
|
+
shouldSaveFullHistory: Belt_Option.getWithDefault(publicConfig.saveFullHistory, false),
|
|
694
|
+
multichain: Belt_Option.getWithDefault(publicConfig.multichain, "unordered"),
|
|
41
695
|
chainMap: chainMap,
|
|
42
696
|
defaultChain: Belt_Array.get(chains, 0),
|
|
43
|
-
ecosystem: ecosystem
|
|
44
|
-
enableRawEvents:
|
|
697
|
+
ecosystem: ecosystem,
|
|
698
|
+
enableRawEvents: Belt_Option.getWithDefault(publicConfig.rawEvents, false),
|
|
45
699
|
maxAddrInPartition: maxAddrInPartition,
|
|
46
|
-
batchSize:
|
|
700
|
+
batchSize: Belt_Option.getWithDefault(publicConfig.fullBatchSize, 5000),
|
|
47
701
|
lowercaseAddresses: lowercaseAddresses,
|
|
48
|
-
addContractNameToContractNameMapping: addContractNameToContractNameMapping
|
|
702
|
+
addContractNameToContractNameMapping: addContractNameToContractNameMapping,
|
|
703
|
+
userEntitiesByName: userEntitiesByName,
|
|
704
|
+
userEntities: userEntities,
|
|
705
|
+
allEntities: allEntities,
|
|
706
|
+
allEnums: allEnums
|
|
49
707
|
};
|
|
50
708
|
}
|
|
51
709
|
|
|
@@ -77,9 +735,28 @@ function getChain(config, chainId) {
|
|
|
77
735
|
}
|
|
78
736
|
|
|
79
737
|
export {
|
|
80
|
-
|
|
738
|
+
DynamicContractRegistry ,
|
|
739
|
+
rpcSourceForSchema ,
|
|
740
|
+
rpcConfigSchema ,
|
|
741
|
+
publicConfigChainSchema ,
|
|
742
|
+
contractEventItemSchema ,
|
|
743
|
+
contractConfigSchema ,
|
|
744
|
+
publicConfigEcosystemSchema ,
|
|
745
|
+
publicConfigEvmSchema ,
|
|
746
|
+
multichainSchema ,
|
|
747
|
+
compositeIndexFieldSchema ,
|
|
748
|
+
derivedFieldSchema ,
|
|
749
|
+
propertySchema ,
|
|
750
|
+
entityJsonSchema ,
|
|
751
|
+
getFieldTypeAndSchema ,
|
|
752
|
+
parseEnumsFromJson ,
|
|
753
|
+
parseEntitiesFromJson ,
|
|
754
|
+
publicConfigSchema ,
|
|
755
|
+
alwaysIncludedBlockFields ,
|
|
756
|
+
enrichEvmFieldSelections ,
|
|
757
|
+
fromPublic ,
|
|
81
758
|
shouldSaveHistory ,
|
|
82
759
|
shouldPruneHistory ,
|
|
83
760
|
getChain ,
|
|
84
761
|
}
|
|
85
|
-
/*
|
|
762
|
+
/* schema Not a pure module */
|