envio 3.0.0-alpha.2 → 3.0.0-alpha.21
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 +578 -1
- package/index.js +4 -0
- package/package.json +47 -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 +725 -25
- package/src/Config.res.mjs +692 -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 +33 -73
- package/src/Env.res.mjs +29 -85
- package/src/Envio.gen.ts +3 -1
- package/src/Envio.res +77 -9
- package/src/Envio.res.mjs +39 -1
- package/src/EventConfigBuilder.res +408 -0
- package/src/EventConfigBuilder.res.mjs +376 -0
- 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 +1224 -0
- package/src/GlobalState.res.mjs +1291 -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/HandlerRegister.resi +30 -0
- 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 +6 -0
- package/src/Internal.res +265 -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 +390 -0
- package/src/Main.res.mjs +341 -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/SimulateItems.res +353 -0
- package/src/SimulateItems.res.mjs +335 -0
- package/src/Sink.res +4 -2
- package/src/Sink.res.mjs +2 -1
- package/src/TableIndices.res +0 -1
- package/src/TestIndexer.res +913 -0
- package/src/TestIndexer.res.mjs +698 -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 +11 -2
- 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 +144 -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 +35 -13
- package/src/sources/HyperFuelSource.res.mjs +26 -16
- package/src/sources/HyperSync.res +61 -60
- package/src/sources/HyperSync.res.mjs +53 -67
- package/src/sources/HyperSync.resi +6 -4
- package/src/sources/HyperSyncClient.res +29 -2
- package/src/sources/HyperSyncClient.res.mjs +9 -0
- package/src/sources/HyperSyncHeightStream.res +76 -118
- package/src/sources/HyperSyncHeightStream.res.mjs +68 -75
- package/src/sources/HyperSyncSource.res +122 -143
- package/src/sources/HyperSyncSource.res.mjs +106 -121
- package/src/sources/Rpc.res +86 -14
- package/src/sources/Rpc.res.mjs +101 -9
- package/src/sources/RpcSource.res +731 -364
- package/src/sources/RpcSource.res.mjs +845 -410
- package/src/sources/RpcWebSocketHeightStream.res +181 -0
- package/src/sources/RpcWebSocketHeightStream.res.mjs +196 -0
- package/src/sources/SimulateSource.res +59 -0
- package/src/sources/SimulateSource.res.mjs +50 -0
- package/src/sources/Source.res +7 -5
- package/src/sources/SourceManager.res +358 -221
- package/src/sources/SourceManager.res.mjs +346 -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/EventRegister.resi +0 -30
- 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
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Curry from "rescript/lib/es6/curry.js";
|
|
4
|
+
import * as Utils from "./Utils.res.mjs";
|
|
5
|
+
import * as $$BigInt from "./bindings/BigInt.res.mjs";
|
|
6
|
+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
7
|
+
import * as Address from "./Address.res.mjs";
|
|
8
|
+
import * as FuelSDK from "./sources/FuelSDK.res.mjs";
|
|
9
|
+
import * as Internal from "./Internal.res.mjs";
|
|
10
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
11
|
+
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
12
|
+
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
13
|
+
import * as TopicFilter from "./TopicFilter.res.mjs";
|
|
14
|
+
import * as LogSelection from "./LogSelection.res.mjs";
|
|
15
|
+
import * as HyperSyncClient from "./sources/HyperSyncClient.res.mjs";
|
|
16
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
17
|
+
|
|
18
|
+
var eventParamSchema = S$RescriptSchema.object(function (s) {
|
|
19
|
+
return {
|
|
20
|
+
name: s.f("name", S$RescriptSchema.string),
|
|
21
|
+
abiType: s.f("abiType", S$RescriptSchema.string),
|
|
22
|
+
indexed: s.fieldOr("indexed", S$RescriptSchema.bool, false)
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
function normalizeOrThrow(value) {
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
return value;
|
|
29
|
+
} else {
|
|
30
|
+
return [value];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function splitTupleComponents(inner) {
|
|
35
|
+
var components = [];
|
|
36
|
+
var depth = 0;
|
|
37
|
+
var start = 0;
|
|
38
|
+
for(var i = 0 ,i_finish = inner.length; i < i_finish; ++i){
|
|
39
|
+
var ch = inner.charAt(i);
|
|
40
|
+
if (ch === "(") {
|
|
41
|
+
depth = depth + 1 | 0;
|
|
42
|
+
} else if (ch === ")") {
|
|
43
|
+
depth = depth - 1 | 0;
|
|
44
|
+
} else if (ch === "," && depth === 0) {
|
|
45
|
+
components.push(inner.slice(start, i));
|
|
46
|
+
start = i + 1 | 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
if (start < inner.length) {
|
|
51
|
+
components.push(inner.slice(start));
|
|
52
|
+
}
|
|
53
|
+
return components;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function abiTypeToSchema(abiType) {
|
|
57
|
+
if (abiType.endsWith("]")) {
|
|
58
|
+
var bracketIdx = abiType.lastIndexOf("[");
|
|
59
|
+
var baseType = abiType.slice(0, bracketIdx);
|
|
60
|
+
return S$RescriptSchema.array(abiTypeToSchema(baseType));
|
|
61
|
+
}
|
|
62
|
+
if (abiType.startsWith("(") && abiType.endsWith(")")) {
|
|
63
|
+
var inner = abiType.slice(1, abiType.length - 1 | 0);
|
|
64
|
+
var components = splitTupleComponents(inner);
|
|
65
|
+
var schemas = Belt_Array.map(components, (function (c) {
|
|
66
|
+
return abiTypeToSchema(c.trim());
|
|
67
|
+
}));
|
|
68
|
+
return S$RescriptSchema.tuple(function (s) {
|
|
69
|
+
return Belt_Array.mapWithIndex(schemas, (function (i, schema) {
|
|
70
|
+
return s.item(i, schema);
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
switch (abiType) {
|
|
75
|
+
case "address" :
|
|
76
|
+
return Address.schema;
|
|
77
|
+
case "bool" :
|
|
78
|
+
return S$RescriptSchema.bool;
|
|
79
|
+
case "bytes" :
|
|
80
|
+
case "string" :
|
|
81
|
+
return S$RescriptSchema.string;
|
|
82
|
+
default:
|
|
83
|
+
if (abiType.startsWith("uint") || abiType.startsWith("int")) {
|
|
84
|
+
return $$BigInt.schema;
|
|
85
|
+
} else if (abiType.startsWith("bytes")) {
|
|
86
|
+
return S$RescriptSchema.string;
|
|
87
|
+
} else {
|
|
88
|
+
return Js_exn.raiseError("Unsupported ABI type: " + abiType);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function abiTypeToSimulateSchema(abiType) {
|
|
94
|
+
if (abiType.endsWith("]")) {
|
|
95
|
+
var bracketIdx = abiType.lastIndexOf("[");
|
|
96
|
+
var baseType = abiType.slice(0, bracketIdx);
|
|
97
|
+
return S$RescriptSchema.array(abiTypeToSimulateSchema(baseType));
|
|
98
|
+
}
|
|
99
|
+
if (abiType.startsWith("(") && abiType.endsWith(")")) {
|
|
100
|
+
var inner = abiType.slice(1, abiType.length - 1 | 0);
|
|
101
|
+
var components = splitTupleComponents(inner);
|
|
102
|
+
var schemas = Belt_Array.map(components, (function (c) {
|
|
103
|
+
return abiTypeToSimulateSchema(c.trim());
|
|
104
|
+
}));
|
|
105
|
+
return S$RescriptSchema.tuple(function (s) {
|
|
106
|
+
return Belt_Array.mapWithIndex(schemas, (function (i, schema) {
|
|
107
|
+
return s.item(i, schema);
|
|
108
|
+
}));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
switch (abiType) {
|
|
112
|
+
case "bool" :
|
|
113
|
+
return S$RescriptSchema.bool;
|
|
114
|
+
case "address" :
|
|
115
|
+
case "bytes" :
|
|
116
|
+
case "string" :
|
|
117
|
+
return S$RescriptSchema.string;
|
|
118
|
+
default:
|
|
119
|
+
if (abiType.startsWith("uint") || abiType.startsWith("int")) {
|
|
120
|
+
return S$RescriptSchema.bigint;
|
|
121
|
+
} else if (abiType.startsWith("bytes")) {
|
|
122
|
+
return S$RescriptSchema.string;
|
|
123
|
+
} else {
|
|
124
|
+
return Js_exn.raiseError("Unsupported ABI type: " + abiType);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function abiTypeToDefaultValue(abiType) {
|
|
130
|
+
if (abiType.endsWith("]")) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
if (abiType.startsWith("(") && abiType.endsWith(")")) {
|
|
134
|
+
var inner = abiType.slice(1, abiType.length - 1 | 0);
|
|
135
|
+
var components = splitTupleComponents(inner);
|
|
136
|
+
return Belt_Array.map(components, (function (c) {
|
|
137
|
+
return abiTypeToDefaultValue(c.trim());
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
switch (abiType) {
|
|
141
|
+
case "address" :
|
|
142
|
+
return "0x0000000000000000000000000000000000000000";
|
|
143
|
+
case "bool" :
|
|
144
|
+
return false;
|
|
145
|
+
case "bytes" :
|
|
146
|
+
case "string" :
|
|
147
|
+
return "";
|
|
148
|
+
default:
|
|
149
|
+
if (abiType.startsWith("uint") || abiType.startsWith("int")) {
|
|
150
|
+
return 0n;
|
|
151
|
+
} else if (abiType.startsWith("bytes")) {
|
|
152
|
+
return "";
|
|
153
|
+
} else {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function buildParamsSchema(params) {
|
|
160
|
+
if (params.length === 0) {
|
|
161
|
+
return S$RescriptSchema.shape(S$RescriptSchema.literal(null), (function (param) {
|
|
162
|
+
|
|
163
|
+
}));
|
|
164
|
+
} else {
|
|
165
|
+
return S$RescriptSchema.object(function (s) {
|
|
166
|
+
var dict = {};
|
|
167
|
+
Belt_Array.forEach(params, (function (p) {
|
|
168
|
+
dict[p.name] = s.f(p.name, abiTypeToSchema(p.abiType));
|
|
169
|
+
}));
|
|
170
|
+
return dict;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function buildSimulateParamsSchema(params) {
|
|
176
|
+
if (params.length === 0) {
|
|
177
|
+
return S$RescriptSchema.shape(S$RescriptSchema.unknown, (function (param) {
|
|
178
|
+
|
|
179
|
+
}));
|
|
180
|
+
} else {
|
|
181
|
+
return S$RescriptSchema.schema(function (s) {
|
|
182
|
+
var dict = {};
|
|
183
|
+
Belt_Array.forEach(params, (function (p) {
|
|
184
|
+
dict[p.name] = s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(abiTypeToSimulateSchema(p.abiType)), abiTypeToDefaultValue(p.abiType)));
|
|
185
|
+
}));
|
|
186
|
+
return dict;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function buildHyperSyncDecoder(params) {
|
|
192
|
+
if (params.length === 0) {
|
|
193
|
+
return function (param) {
|
|
194
|
+
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
var indexedParams = params.filter(function (p) {
|
|
198
|
+
return p.indexed;
|
|
199
|
+
});
|
|
200
|
+
var bodyParams = params.filter(function (p) {
|
|
201
|
+
return !p.indexed;
|
|
202
|
+
});
|
|
203
|
+
var fields = [];
|
|
204
|
+
Belt_Array.forEachWithIndex(indexedParams, (function (i, p) {
|
|
205
|
+
fields.push("\"" + p.name + "\": t(d.indexed[" + String(i) + "])");
|
|
206
|
+
}));
|
|
207
|
+
Belt_Array.forEachWithIndex(bodyParams, (function (i, p) {
|
|
208
|
+
fields.push("\"" + p.name + "\": t(d.body[" + String(i) + "])");
|
|
209
|
+
}));
|
|
210
|
+
var body = "return function(d) { return {" + fields.join(", ") + "} }";
|
|
211
|
+
var factory = new Function("t", body);
|
|
212
|
+
return factory(HyperSyncClient.Decoder.toUnderlying);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function getTopicEncoder(abiType) {
|
|
216
|
+
if (abiType.endsWith("]") || abiType.startsWith("(")) {
|
|
217
|
+
return TopicFilter.castToHexUnsafe;
|
|
218
|
+
}
|
|
219
|
+
switch (abiType) {
|
|
220
|
+
case "address" :
|
|
221
|
+
return TopicFilter.fromAddress;
|
|
222
|
+
case "bool" :
|
|
223
|
+
return TopicFilter.fromBool;
|
|
224
|
+
case "bytes" :
|
|
225
|
+
return TopicFilter.fromDynamicBytes;
|
|
226
|
+
case "string" :
|
|
227
|
+
return TopicFilter.fromDynamicString;
|
|
228
|
+
default:
|
|
229
|
+
if (abiType.startsWith("uint")) {
|
|
230
|
+
return TopicFilter.fromBigInt;
|
|
231
|
+
} else if (abiType.startsWith("int")) {
|
|
232
|
+
return TopicFilter.fromSignedBigInt;
|
|
233
|
+
} else if (abiType.startsWith("bytes")) {
|
|
234
|
+
return TopicFilter.castToHexUnsafe;
|
|
235
|
+
} else {
|
|
236
|
+
return Js_exn.raiseError("Unsupported topic filter ABI type: " + abiType);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function buildTopicGetter(p) {
|
|
242
|
+
var encoder = getTopicEncoder(p.abiType);
|
|
243
|
+
return function (eventFilter) {
|
|
244
|
+
return Belt_Option.mapWithDefault(eventFilter[p.name], [], (function (topicFilters) {
|
|
245
|
+
return normalizeOrThrow(topicFilters).map(Curry.__1(encoder));
|
|
246
|
+
}));
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
var alwaysIncludedBlockFields = [
|
|
251
|
+
"number",
|
|
252
|
+
"timestamp",
|
|
253
|
+
"hash"
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
function resolveFieldSelection(blockFields, transactionFields, globalBlockFieldsSet, globalTransactionFieldsSet) {
|
|
257
|
+
var selectedBlockFields = blockFields !== undefined ? new Set(Belt_Array.concat(alwaysIncludedBlockFields, blockFields)) : globalBlockFieldsSet;
|
|
258
|
+
var selectedTransactionFields = transactionFields !== undefined ? new Set(transactionFields) : globalTransactionFieldsSet;
|
|
259
|
+
return [
|
|
260
|
+
selectedBlockFields,
|
|
261
|
+
selectedTransactionFields
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function buildEvmEventConfig(contractName, eventName, sighash, params, isWildcard, handler, contractRegister, eventFilters, blockFields, transactionFields, globalBlockFieldsSetOpt, globalTransactionFieldsSetOpt) {
|
|
266
|
+
var globalBlockFieldsSet = globalBlockFieldsSetOpt !== undefined ? Caml_option.valFromOption(globalBlockFieldsSetOpt) : new Set();
|
|
267
|
+
var globalTransactionFieldsSet = globalTransactionFieldsSetOpt !== undefined ? Caml_option.valFromOption(globalTransactionFieldsSetOpt) : new Set();
|
|
268
|
+
var topicCount = Belt_Array.reduce(params, 1, (function (acc, p) {
|
|
269
|
+
if (p.indexed) {
|
|
270
|
+
return acc + 1 | 0;
|
|
271
|
+
} else {
|
|
272
|
+
return acc;
|
|
273
|
+
}
|
|
274
|
+
}));
|
|
275
|
+
var indexedParams = params.filter(function (p) {
|
|
276
|
+
return p.indexed;
|
|
277
|
+
});
|
|
278
|
+
var match = LogSelection.parseEventFiltersOrThrow(eventFilters, sighash, Belt_Array.map(indexedParams, (function (p) {
|
|
279
|
+
return p.name;
|
|
280
|
+
})), Belt_Option.map(Belt_Array.get(indexedParams, 0), buildTopicGetter), Belt_Option.map(Belt_Array.get(indexedParams, 1), buildTopicGetter), Belt_Option.map(Belt_Array.get(indexedParams, 2), buildTopicGetter));
|
|
281
|
+
var filterByAddresses = match.filterByAddresses;
|
|
282
|
+
var match$1 = resolveFieldSelection(blockFields, transactionFields, globalBlockFieldsSet, globalTransactionFieldsSet);
|
|
283
|
+
return {
|
|
284
|
+
id: sighash + "_" + String(topicCount),
|
|
285
|
+
name: eventName,
|
|
286
|
+
contractName: contractName,
|
|
287
|
+
isWildcard: isWildcard,
|
|
288
|
+
filterByAddresses: filterByAddresses,
|
|
289
|
+
dependsOnAddresses: !isWildcard || filterByAddresses,
|
|
290
|
+
handler: handler,
|
|
291
|
+
contractRegister: contractRegister,
|
|
292
|
+
paramsRawEventSchema: buildParamsSchema(params),
|
|
293
|
+
simulateParamsSchema: buildSimulateParamsSchema(params),
|
|
294
|
+
getEventFiltersOrThrow: match.getEventFiltersOrThrow,
|
|
295
|
+
convertHyperSyncEventArgs: buildHyperSyncDecoder(params),
|
|
296
|
+
selectedBlockFields: match$1[0],
|
|
297
|
+
selectedTransactionFields: match$1[1]
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function buildFuelEventConfig(contractName, eventName, kind, sighash, rawAbi, isWildcard, handler, contractRegister) {
|
|
302
|
+
var fuelKind;
|
|
303
|
+
switch (kind) {
|
|
304
|
+
case "burn" :
|
|
305
|
+
fuelKind = "Burn";
|
|
306
|
+
break;
|
|
307
|
+
case "call" :
|
|
308
|
+
fuelKind = "Call";
|
|
309
|
+
break;
|
|
310
|
+
case "logData" :
|
|
311
|
+
var abi = FuelSDK.transpileAbi(rawAbi);
|
|
312
|
+
fuelKind = {
|
|
313
|
+
TAG: "LogData",
|
|
314
|
+
logId: sighash,
|
|
315
|
+
decode: FuelSDK.Receipt.getLogDataDecoder(abi, sighash)
|
|
316
|
+
};
|
|
317
|
+
break;
|
|
318
|
+
case "mint" :
|
|
319
|
+
fuelKind = "Mint";
|
|
320
|
+
break;
|
|
321
|
+
case "transfer" :
|
|
322
|
+
fuelKind = "Transfer";
|
|
323
|
+
break;
|
|
324
|
+
default:
|
|
325
|
+
fuelKind = Js_exn.raiseError("Unsupported Fuel event kind: " + kind);
|
|
326
|
+
}
|
|
327
|
+
var paramsSchema;
|
|
328
|
+
switch (kind) {
|
|
329
|
+
case "logData" :
|
|
330
|
+
paramsSchema = Utils.Schema.coerceToJsonPgType(S$RescriptSchema.json(false));
|
|
331
|
+
break;
|
|
332
|
+
case "burn" :
|
|
333
|
+
case "mint" :
|
|
334
|
+
paramsSchema = Internal.fuelSupplyParamsSchema;
|
|
335
|
+
break;
|
|
336
|
+
case "call" :
|
|
337
|
+
case "transfer" :
|
|
338
|
+
paramsSchema = Internal.fuelTransferParamsSchema;
|
|
339
|
+
break;
|
|
340
|
+
default:
|
|
341
|
+
paramsSchema = Js_exn.raiseError("Unsupported Fuel event kind: " + kind);
|
|
342
|
+
}
|
|
343
|
+
var tmp = kind === "logData" ? sighash : kind;
|
|
344
|
+
return {
|
|
345
|
+
id: tmp,
|
|
346
|
+
name: eventName,
|
|
347
|
+
contractName: contractName,
|
|
348
|
+
isWildcard: isWildcard,
|
|
349
|
+
filterByAddresses: false,
|
|
350
|
+
dependsOnAddresses: !isWildcard,
|
|
351
|
+
handler: handler,
|
|
352
|
+
contractRegister: contractRegister,
|
|
353
|
+
paramsRawEventSchema: paramsSchema,
|
|
354
|
+
simulateParamsSchema: paramsSchema,
|
|
355
|
+
kind: fuelKind
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export {
|
|
360
|
+
eventParamSchema ,
|
|
361
|
+
normalizeOrThrow ,
|
|
362
|
+
splitTupleComponents ,
|
|
363
|
+
abiTypeToSchema ,
|
|
364
|
+
abiTypeToSimulateSchema ,
|
|
365
|
+
abiTypeToDefaultValue ,
|
|
366
|
+
buildParamsSchema ,
|
|
367
|
+
buildSimulateParamsSchema ,
|
|
368
|
+
buildHyperSyncDecoder ,
|
|
369
|
+
getTopicEncoder ,
|
|
370
|
+
buildTopicGetter ,
|
|
371
|
+
alwaysIncludedBlockFields ,
|
|
372
|
+
resolveFieldSelection ,
|
|
373
|
+
buildEvmEventConfig ,
|
|
374
|
+
buildFuelEventConfig ,
|
|
375
|
+
}
|
|
376
|
+
/* eventParamSchema Not a pure module */
|