envio 3.0.0-alpha.21 → 3.0.0-alpha.22
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/bin.mjs +2 -48
- package/evm.schema.json +67 -0
- package/fuel.schema.json +67 -0
- package/index.d.ts +822 -38
- package/index.js +5 -3
- package/package.json +10 -8
- package/rescript.json +5 -9
- package/src/Address.res +4 -5
- package/src/Address.res.mjs +9 -12
- package/src/Api.res +15 -0
- package/src/Api.res.mjs +20 -0
- package/src/Batch.res +32 -34
- package/src/Batch.res.mjs +172 -187
- package/src/Bin.res +89 -0
- package/src/Bin.res.mjs +97 -0
- package/src/ChainFetcher.res +33 -57
- package/src/ChainFetcher.res.mjs +197 -227
- package/src/ChainManager.res +6 -14
- package/src/ChainManager.res.mjs +74 -85
- package/src/ChainMap.res +14 -16
- package/src/ChainMap.res.mjs +38 -38
- package/src/Config.res +193 -135
- package/src/Config.res.mjs +566 -592
- package/src/Core.res +182 -0
- package/src/Core.res.mjs +207 -0
- package/src/Ecosystem.res +25 -4
- package/src/Ecosystem.res.mjs +12 -13
- package/src/Env.res +20 -13
- package/src/Env.res.mjs +124 -113
- package/src/EnvSafe.res +269 -0
- package/src/EnvSafe.res.mjs +296 -0
- package/src/EnvSafe.resi +18 -0
- package/src/Envio.res +37 -26
- package/src/Envio.res.mjs +59 -60
- package/src/ErrorHandling.res +2 -2
- package/src/ErrorHandling.res.mjs +15 -15
- package/src/EventConfigBuilder.res +219 -81
- package/src/EventConfigBuilder.res.mjs +259 -202
- package/src/EventProcessing.res +27 -38
- package/src/EventProcessing.res.mjs +165 -183
- package/src/EventUtils.res +11 -11
- package/src/EventUtils.res.mjs +21 -22
- package/src/EvmTypes.res +0 -1
- package/src/EvmTypes.res.mjs +5 -5
- package/src/FetchState.res +360 -256
- package/src/FetchState.res.mjs +958 -914
- package/src/GlobalState.res +365 -351
- package/src/GlobalState.res.mjs +958 -992
- package/src/GlobalStateManager.res +1 -2
- package/src/GlobalStateManager.res.mjs +36 -44
- package/src/HandlerLoader.res +107 -23
- package/src/HandlerLoader.res.mjs +128 -38
- package/src/HandlerRegister.res +127 -103
- package/src/HandlerRegister.res.mjs +164 -164
- package/src/HandlerRegister.resi +12 -4
- package/src/Hasura.res +35 -22
- package/src/Hasura.res.mjs +158 -167
- package/src/InMemoryStore.res +20 -27
- package/src/InMemoryStore.res.mjs +64 -80
- package/src/InMemoryTable.res +34 -39
- package/src/InMemoryTable.res.mjs +165 -170
- package/src/Internal.res +52 -33
- package/src/Internal.res.mjs +84 -81
- package/src/LazyLoader.res.mjs +55 -61
- package/src/LoadLayer.res +77 -78
- package/src/LoadLayer.res.mjs +160 -189
- package/src/LoadManager.res +16 -21
- package/src/LoadManager.res.mjs +79 -84
- package/src/LogSelection.res +236 -68
- package/src/LogSelection.res.mjs +211 -141
- package/src/Logging.res +13 -9
- package/src/Logging.res.mjs +130 -143
- package/src/Main.res +428 -51
- package/src/Main.res.mjs +528 -271
- package/src/Persistence.res +77 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +291 -167
- package/src/PgStorage.res.mjs +797 -817
- package/src/Prometheus.res +50 -58
- package/src/Prometheus.res.mjs +345 -373
- package/src/ReorgDetection.res +22 -24
- package/src/ReorgDetection.res.mjs +100 -106
- package/src/SafeCheckpointTracking.res +7 -7
- package/src/SafeCheckpointTracking.res.mjs +40 -43
- package/src/SimulateItems.res +41 -49
- package/src/SimulateItems.res.mjs +257 -272
- package/src/Sink.res +2 -2
- package/src/Sink.res.mjs +22 -26
- package/src/TableIndices.res +1 -2
- package/src/TableIndices.res.mjs +42 -48
- package/src/TestIndexer.res +196 -189
- package/src/TestIndexer.res.mjs +536 -536
- package/src/TestIndexerProxyStorage.res +15 -16
- package/src/TestIndexerProxyStorage.res.mjs +98 -122
- package/src/TestIndexerWorker.res +4 -0
- package/src/TestIndexerWorker.res.mjs +7 -0
- package/src/Throttler.res +3 -3
- package/src/Throttler.res.mjs +23 -24
- package/src/Time.res +1 -1
- package/src/Time.res.mjs +18 -21
- package/src/TopicFilter.res +3 -3
- package/src/TopicFilter.res.mjs +29 -30
- package/src/UserContext.res +93 -54
- package/src/UserContext.res.mjs +197 -182
- package/src/Utils.res +141 -86
- package/src/Utils.res.mjs +334 -295
- package/src/bindings/BigDecimal.res +0 -2
- package/src/bindings/BigDecimal.res.mjs +19 -23
- package/src/bindings/ClickHouse.res +28 -27
- package/src/bindings/ClickHouse.res.mjs +243 -240
- package/src/bindings/DateFns.res +11 -11
- package/src/bindings/DateFns.res.mjs +7 -7
- package/src/bindings/EventSource.res.mjs +2 -2
- package/src/bindings/Express.res +2 -5
- package/src/bindings/Hrtime.res +2 -2
- package/src/bindings/Hrtime.res.mjs +30 -32
- package/src/bindings/Lodash.res.mjs +1 -1
- package/src/bindings/NodeJs.res +14 -9
- package/src/bindings/NodeJs.res.mjs +20 -20
- package/src/bindings/Pino.res +8 -10
- package/src/bindings/Pino.res.mjs +40 -43
- package/src/bindings/Postgres.res +2 -5
- package/src/bindings/Postgres.res.mjs +9 -9
- package/src/bindings/PromClient.res +17 -2
- package/src/bindings/PromClient.res.mjs +30 -7
- package/src/bindings/SDSL.res.mjs +2 -2
- package/src/bindings/Viem.res +4 -4
- package/src/bindings/Viem.res.mjs +20 -22
- package/src/bindings/Vitest.res +1 -1
- package/src/bindings/Vitest.res.mjs +2 -2
- package/src/bindings/WebSocket.res +1 -1
- package/src/db/EntityHistory.res +9 -3
- package/src/db/EntityHistory.res.mjs +84 -59
- package/src/db/InternalTable.res +62 -60
- package/src/db/InternalTable.res.mjs +271 -203
- package/src/db/Schema.res +1 -2
- package/src/db/Schema.res.mjs +28 -32
- package/src/db/Table.res +28 -27
- package/src/db/Table.res.mjs +276 -292
- package/src/sources/EventRouter.res +21 -16
- package/src/sources/EventRouter.res.mjs +55 -57
- package/src/sources/Evm.res +17 -1
- package/src/sources/Evm.res.mjs +16 -8
- package/src/sources/EvmChain.res +15 -17
- package/src/sources/EvmChain.res.mjs +40 -42
- package/src/sources/Fuel.res +14 -1
- package/src/sources/Fuel.res.mjs +16 -8
- package/src/sources/FuelSDK.res +1 -1
- package/src/sources/FuelSDK.res.mjs +6 -8
- package/src/sources/HyperFuel.res +8 -10
- package/src/sources/HyperFuel.res.mjs +113 -123
- package/src/sources/HyperFuelClient.res.mjs +6 -7
- package/src/sources/HyperFuelSource.res +19 -20
- package/src/sources/HyperFuelSource.res.mjs +339 -356
- package/src/sources/HyperSync.res +11 -13
- package/src/sources/HyperSync.res.mjs +206 -220
- package/src/sources/HyperSyncClient.res +5 -7
- package/src/sources/HyperSyncClient.res.mjs +70 -75
- package/src/sources/HyperSyncHeightStream.res +8 -9
- package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
- package/src/sources/HyperSyncJsonApi.res +18 -15
- package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
- package/src/sources/HyperSyncSource.res +17 -21
- package/src/sources/HyperSyncSource.res.mjs +268 -290
- package/src/sources/Rpc.res +5 -5
- package/src/sources/Rpc.res.mjs +168 -192
- package/src/sources/RpcSource.res +166 -167
- package/src/sources/RpcSource.res.mjs +972 -1046
- package/src/sources/RpcWebSocketHeightStream.res +10 -11
- package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
- package/src/sources/SimulateSource.res +1 -1
- package/src/sources/SimulateSource.res.mjs +35 -38
- package/src/sources/Source.res +1 -1
- package/src/sources/Source.res.mjs +3 -3
- package/src/sources/SourceManager.res +39 -20
- package/src/sources/SourceManager.res.mjs +340 -371
- package/src/sources/SourceManager.resi +2 -1
- package/src/sources/Svm.res +12 -5
- package/src/sources/Svm.res.mjs +44 -41
- package/src/tui/Tui.res +23 -12
- package/src/tui/Tui.res.mjs +292 -290
- package/src/tui/bindings/Ink.res +2 -4
- package/src/tui/bindings/Ink.res.mjs +35 -41
- package/src/tui/components/BufferedProgressBar.res +7 -7
- package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
- package/src/tui/components/CustomHooks.res +1 -2
- package/src/tui/components/CustomHooks.res.mjs +102 -122
- package/src/tui/components/Messages.res +1 -2
- package/src/tui/components/Messages.res.mjs +38 -42
- package/src/tui/components/SyncETA.res +10 -11
- package/src/tui/components/SyncETA.res.mjs +178 -196
- package/src/tui/components/TuiData.res +1 -1
- package/src/tui/components/TuiData.res.mjs +7 -6
- package/src/vendored/Rest.res +52 -66
- package/src/vendored/Rest.res.mjs +324 -364
- package/svm.schema.json +67 -0
- package/src/Address.gen.ts +0 -8
- package/src/Config.gen.ts +0 -19
- package/src/Envio.gen.ts +0 -55
- package/src/EvmTypes.gen.ts +0 -6
- package/src/InMemoryStore.gen.ts +0 -6
- package/src/Internal.gen.ts +0 -64
- package/src/PgStorage.gen.ts +0 -10
- package/src/PgStorage.res.d.mts +0 -5
- package/src/Types.ts +0 -56
- package/src/bindings/BigDecimal.gen.ts +0 -14
- package/src/bindings/BigDecimal.res.d.mts +0 -5
- package/src/bindings/BigInt.gen.ts +0 -10
- package/src/bindings/BigInt.res +0 -70
- package/src/bindings/BigInt.res.d.mts +0 -5
- package/src/bindings/BigInt.res.mjs +0 -154
- package/src/bindings/Ethers.res.d.mts +0 -5
- package/src/bindings/Pino.gen.ts +0 -17
- package/src/bindings/Postgres.gen.ts +0 -8
- package/src/bindings/Postgres.res.d.mts +0 -5
- package/src/bindings/Promise.res +0 -67
- package/src/bindings/Promise.res.mjs +0 -26
- package/src/db/InternalTable.gen.ts +0 -36
- package/src/sources/HyperSyncClient.gen.ts +0 -19
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Curry from "rescript/lib/es6/curry.js";
|
|
4
3
|
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
4
|
import * as Address from "./Address.res.mjs";
|
|
8
5
|
import * as FuelSDK from "./sources/FuelSDK.res.mjs";
|
|
9
6
|
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
7
|
import * as TopicFilter from "./TopicFilter.res.mjs";
|
|
14
8
|
import * as LogSelection from "./LogSelection.res.mjs";
|
|
9
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
10
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
11
|
+
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
15
12
|
import * as HyperSyncClient from "./sources/HyperSyncClient.res.mjs";
|
|
13
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
16
14
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
let eventParamComponentSchema = S$RescriptSchema.recursive(self => S$RescriptSchema.object(s => ({
|
|
17
|
+
name: s.f("name", S$RescriptSchema.string),
|
|
18
|
+
abiType: s.f("abiType", S$RescriptSchema.string),
|
|
19
|
+
components: s.f("components", S$RescriptSchema.option(S$RescriptSchema.array(self)))
|
|
20
|
+
})));
|
|
21
|
+
|
|
22
|
+
let eventParamSchema = S$RescriptSchema.object(s => ({
|
|
23
|
+
name: s.f("name", S$RescriptSchema.string),
|
|
24
|
+
abiType: s.f("abiType", S$RescriptSchema.string),
|
|
25
|
+
indexed: s.fieldOr("indexed", S$RescriptSchema.bool, false),
|
|
26
|
+
components: s.f("components", S$RescriptSchema.option(S$RescriptSchema.array(eventParamComponentSchema)))
|
|
27
|
+
}));
|
|
25
28
|
|
|
26
29
|
function normalizeOrThrow(value) {
|
|
27
30
|
if (Array.isArray(value)) {
|
|
@@ -32,11 +35,11 @@ function normalizeOrThrow(value) {
|
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
function splitTupleComponents(inner) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
for(
|
|
39
|
-
|
|
38
|
+
let components = [];
|
|
39
|
+
let depth = 0;
|
|
40
|
+
let start = 0;
|
|
41
|
+
for (let i = 0, i_finish = inner.length; i < i_finish; ++i) {
|
|
42
|
+
let ch = inner.charAt(i);
|
|
40
43
|
if (ch === "(") {
|
|
41
44
|
depth = depth + 1 | 0;
|
|
42
45
|
} else if (ch === ")") {
|
|
@@ -45,7 +48,6 @@ function splitTupleComponents(inner) {
|
|
|
45
48
|
components.push(inner.slice(start, i));
|
|
46
49
|
start = i + 1 | 0;
|
|
47
50
|
}
|
|
48
|
-
|
|
49
51
|
}
|
|
50
52
|
if (start < inner.length) {
|
|
51
53
|
components.push(inner.slice(start));
|
|
@@ -55,73 +57,61 @@ function splitTupleComponents(inner) {
|
|
|
55
57
|
|
|
56
58
|
function abiTypeToSchema(abiType) {
|
|
57
59
|
if (abiType.endsWith("]")) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
let bracketIdx = abiType.lastIndexOf("[");
|
|
61
|
+
let baseType = abiType.slice(0, bracketIdx);
|
|
60
62
|
return S$RescriptSchema.array(abiTypeToSchema(baseType));
|
|
61
63
|
}
|
|
62
64
|
if (abiType.startsWith("(") && abiType.endsWith(")")) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
});
|
|
65
|
+
let inner = abiType.slice(1, abiType.length - 1 | 0);
|
|
66
|
+
let components = splitTupleComponents(inner);
|
|
67
|
+
let schemas = components.map(c => abiTypeToSchema(c.trim()));
|
|
68
|
+
return S$RescriptSchema.tuple(s => schemas.map((schema, i) => s.item(i, schema)));
|
|
73
69
|
}
|
|
74
70
|
switch (abiType) {
|
|
75
71
|
case "address" :
|
|
76
|
-
|
|
72
|
+
return Address.schema;
|
|
77
73
|
case "bool" :
|
|
78
|
-
|
|
74
|
+
return S$RescriptSchema.bool;
|
|
79
75
|
case "bytes" :
|
|
80
76
|
case "string" :
|
|
81
|
-
|
|
77
|
+
return S$RescriptSchema.string;
|
|
82
78
|
default:
|
|
83
79
|
if (abiType.startsWith("uint") || abiType.startsWith("int")) {
|
|
84
|
-
return
|
|
80
|
+
return Utils.$$BigInt.schema;
|
|
85
81
|
} else if (abiType.startsWith("bytes")) {
|
|
86
82
|
return S$RescriptSchema.string;
|
|
87
83
|
} else {
|
|
88
|
-
return
|
|
84
|
+
return Stdlib_JsError.throwWithMessage(`Unsupported ABI type: ` + abiType);
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
87
|
}
|
|
92
88
|
|
|
93
89
|
function abiTypeToSimulateSchema(abiType) {
|
|
94
90
|
if (abiType.endsWith("]")) {
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
let bracketIdx = abiType.lastIndexOf("[");
|
|
92
|
+
let baseType = abiType.slice(0, bracketIdx);
|
|
97
93
|
return S$RescriptSchema.array(abiTypeToSimulateSchema(baseType));
|
|
98
94
|
}
|
|
99
95
|
if (abiType.startsWith("(") && abiType.endsWith(")")) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
});
|
|
96
|
+
let inner = abiType.slice(1, abiType.length - 1 | 0);
|
|
97
|
+
let components = splitTupleComponents(inner);
|
|
98
|
+
let schemas = components.map(c => abiTypeToSimulateSchema(c.trim()));
|
|
99
|
+
return S$RescriptSchema.tuple(s => schemas.map((schema, i) => s.item(i, schema)));
|
|
110
100
|
}
|
|
111
101
|
switch (abiType) {
|
|
112
102
|
case "bool" :
|
|
113
|
-
|
|
103
|
+
return S$RescriptSchema.bool;
|
|
114
104
|
case "address" :
|
|
115
105
|
case "bytes" :
|
|
116
106
|
case "string" :
|
|
117
|
-
|
|
107
|
+
return S$RescriptSchema.string;
|
|
118
108
|
default:
|
|
119
109
|
if (abiType.startsWith("uint") || abiType.startsWith("int")) {
|
|
120
110
|
return S$RescriptSchema.bigint;
|
|
121
111
|
} else if (abiType.startsWith("bytes")) {
|
|
122
112
|
return S$RescriptSchema.string;
|
|
123
113
|
} else {
|
|
124
|
-
return
|
|
114
|
+
return Stdlib_JsError.throwWithMessage(`Unsupported ABI type: ` + abiType);
|
|
125
115
|
}
|
|
126
116
|
}
|
|
127
117
|
}
|
|
@@ -131,20 +121,18 @@ function abiTypeToDefaultValue(abiType) {
|
|
|
131
121
|
return [];
|
|
132
122
|
}
|
|
133
123
|
if (abiType.startsWith("(") && abiType.endsWith(")")) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return
|
|
137
|
-
return abiTypeToDefaultValue(c.trim());
|
|
138
|
-
}));
|
|
124
|
+
let inner = abiType.slice(1, abiType.length - 1 | 0);
|
|
125
|
+
let components = splitTupleComponents(inner);
|
|
126
|
+
return components.map(c => abiTypeToDefaultValue(c.trim()));
|
|
139
127
|
}
|
|
140
128
|
switch (abiType) {
|
|
141
129
|
case "address" :
|
|
142
|
-
|
|
130
|
+
return "0x0000000000000000000000000000000000000000";
|
|
143
131
|
case "bool" :
|
|
144
|
-
|
|
132
|
+
return false;
|
|
145
133
|
case "bytes" :
|
|
146
134
|
case "string" :
|
|
147
|
-
|
|
135
|
+
return "";
|
|
148
136
|
default:
|
|
149
137
|
if (abiType.startsWith("uint") || abiType.startsWith("int")) {
|
|
150
138
|
return 0n;
|
|
@@ -156,60 +144,127 @@ function abiTypeToDefaultValue(abiType) {
|
|
|
156
144
|
}
|
|
157
145
|
}
|
|
158
146
|
|
|
147
|
+
function componentsToSimulateSchema(abiType, components) {
|
|
148
|
+
if (!abiType.endsWith("]")) {
|
|
149
|
+
return S$RescriptSchema.object(s => {
|
|
150
|
+
let dict = {};
|
|
151
|
+
components.forEach(c => {
|
|
152
|
+
let sub = c.components;
|
|
153
|
+
let childSchema = sub !== undefined ? componentsToSimulateSchema(c.abiType, sub) : abiTypeToSimulateSchema(c.abiType);
|
|
154
|
+
dict[c.name] = s.f(c.name, childSchema);
|
|
155
|
+
});
|
|
156
|
+
return dict;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
let bracketIdx = abiType.lastIndexOf("[");
|
|
160
|
+
let baseType = abiType.slice(0, bracketIdx);
|
|
161
|
+
return S$RescriptSchema.array(componentsToSimulateSchema(baseType, components));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function componentsToDefaultValue(abiType, components) {
|
|
165
|
+
if (abiType.endsWith("]")) {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
let dict = {};
|
|
169
|
+
components.forEach(c => {
|
|
170
|
+
let sub = c.components;
|
|
171
|
+
let v = sub !== undefined ? componentsToDefaultValue(c.abiType, sub) : abiTypeToDefaultValue(c.abiType);
|
|
172
|
+
dict[c.name] = v;
|
|
173
|
+
});
|
|
174
|
+
return dict;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function componentsToRemapper(abiType, components, value) {
|
|
178
|
+
if (abiType.endsWith("]")) {
|
|
179
|
+
let bracketIdx = abiType.lastIndexOf("[");
|
|
180
|
+
let baseType = abiType.slice(0, bracketIdx);
|
|
181
|
+
return value.map(item => componentsToRemapper(baseType, components, item));
|
|
182
|
+
}
|
|
183
|
+
let dict = {};
|
|
184
|
+
components.forEach((c, i) => {
|
|
185
|
+
let raw = value[i];
|
|
186
|
+
let sub = c.components;
|
|
187
|
+
let mapped = sub !== undefined ? componentsToRemapper(c.abiType, sub, raw) : raw;
|
|
188
|
+
dict[c.name] = mapped;
|
|
189
|
+
});
|
|
190
|
+
return dict;
|
|
191
|
+
}
|
|
192
|
+
|
|
159
193
|
function buildParamsSchema(params) {
|
|
160
194
|
if (params.length === 0) {
|
|
161
|
-
return S$RescriptSchema.shape(S$RescriptSchema.literal(null),
|
|
162
|
-
|
|
163
|
-
}));
|
|
195
|
+
return S$RescriptSchema.shape(S$RescriptSchema.literal(null), param => {});
|
|
164
196
|
} else {
|
|
165
|
-
return S$RescriptSchema.object(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
197
|
+
return S$RescriptSchema.object(s => {
|
|
198
|
+
let dict = {};
|
|
199
|
+
params.forEach(p => {
|
|
200
|
+
dict[p.name] = s.f(p.name, abiTypeToSchema(p.abiType));
|
|
201
|
+
});
|
|
202
|
+
return dict;
|
|
203
|
+
});
|
|
172
204
|
}
|
|
173
205
|
}
|
|
174
206
|
|
|
175
207
|
function buildSimulateParamsSchema(params) {
|
|
176
208
|
if (params.length === 0) {
|
|
177
|
-
return S$RescriptSchema.shape(S$RescriptSchema.unknown,
|
|
178
|
-
|
|
179
|
-
}));
|
|
209
|
+
return S$RescriptSchema.shape(S$RescriptSchema.unknown, param => {});
|
|
180
210
|
} else {
|
|
181
|
-
return S$RescriptSchema.schema(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
211
|
+
return S$RescriptSchema.schema(s => {
|
|
212
|
+
let dict = {};
|
|
213
|
+
params.forEach(p => {
|
|
214
|
+
let components = p.components;
|
|
215
|
+
let match = components !== undefined ? [
|
|
216
|
+
componentsToSimulateSchema(p.abiType, components),
|
|
217
|
+
componentsToDefaultValue(p.abiType, components)
|
|
218
|
+
] : [
|
|
219
|
+
abiTypeToSimulateSchema(p.abiType),
|
|
220
|
+
abiTypeToDefaultValue(p.abiType)
|
|
221
|
+
];
|
|
222
|
+
dict[p.name] = s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(match[0]), match[1]));
|
|
223
|
+
});
|
|
224
|
+
return dict;
|
|
225
|
+
});
|
|
188
226
|
}
|
|
189
227
|
}
|
|
190
228
|
|
|
191
229
|
function buildHyperSyncDecoder(params) {
|
|
192
230
|
if (params.length === 0) {
|
|
193
|
-
return
|
|
194
|
-
|
|
195
|
-
};
|
|
231
|
+
return param => {};
|
|
196
232
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
233
|
+
let indexedParams = params.filter(p => p.indexed);
|
|
234
|
+
let bodyParams = params.filter(p => !p.indexed);
|
|
235
|
+
let fields = [];
|
|
236
|
+
indexedParams.forEach((p, i) => {
|
|
237
|
+
fields.push(`"` + p.name + `": t(d.indexed[` + i.toString() + `])`);
|
|
238
|
+
});
|
|
239
|
+
bodyParams.forEach((p, i) => {
|
|
240
|
+
fields.push(`"` + p.name + `": t(d.body[` + i.toString() + `])`);
|
|
241
|
+
});
|
|
242
|
+
let body = `return function(d) { return {` + fields.join(", ") + `} }`;
|
|
243
|
+
let factory = new Function("t", body);
|
|
244
|
+
let baseDecode = factory(HyperSyncClient.Decoder.toUnderlying);
|
|
245
|
+
let paramsToRemap = params.filter(p => {
|
|
246
|
+
if (p.indexed) {
|
|
247
|
+
return false;
|
|
248
|
+
} else {
|
|
249
|
+
return Stdlib_Option.isSome(p.components);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
if (paramsToRemap.length === 0) {
|
|
253
|
+
return baseDecode;
|
|
254
|
+
} else {
|
|
255
|
+
return decoded => {
|
|
256
|
+
let result = baseDecode(decoded);
|
|
257
|
+
paramsToRemap.forEach(p => {
|
|
258
|
+
let match = p.components;
|
|
259
|
+
let match$1 = result[p.name];
|
|
260
|
+
if (match !== undefined && match$1 !== undefined) {
|
|
261
|
+
result[p.name] = componentsToRemapper(p.abiType, match, Primitive_option.valFromOption(match$1));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
202
264
|
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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);
|
|
265
|
+
return result;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
213
268
|
}
|
|
214
269
|
|
|
215
270
|
function getTopicEncoder(abiType) {
|
|
@@ -218,13 +273,13 @@ function getTopicEncoder(abiType) {
|
|
|
218
273
|
}
|
|
219
274
|
switch (abiType) {
|
|
220
275
|
case "address" :
|
|
221
|
-
|
|
276
|
+
return TopicFilter.fromAddress;
|
|
222
277
|
case "bool" :
|
|
223
|
-
|
|
278
|
+
return TopicFilter.fromBool;
|
|
224
279
|
case "bytes" :
|
|
225
|
-
|
|
280
|
+
return TopicFilter.fromDynamicBytes;
|
|
226
281
|
case "string" :
|
|
227
|
-
|
|
282
|
+
return TopicFilter.fromDynamicString;
|
|
228
283
|
default:
|
|
229
284
|
if (abiType.startsWith("uint")) {
|
|
230
285
|
return TopicFilter.fromBigInt;
|
|
@@ -233,144 +288,146 @@ function getTopicEncoder(abiType) {
|
|
|
233
288
|
} else if (abiType.startsWith("bytes")) {
|
|
234
289
|
return TopicFilter.castToHexUnsafe;
|
|
235
290
|
} else {
|
|
236
|
-
return
|
|
291
|
+
return Stdlib_JsError.throwWithMessage(`Unsupported topic filter ABI type: ` + abiType);
|
|
237
292
|
}
|
|
238
293
|
}
|
|
239
294
|
}
|
|
240
295
|
|
|
241
296
|
function buildTopicGetter(p) {
|
|
242
|
-
|
|
243
|
-
return
|
|
244
|
-
return Belt_Option.mapWithDefault(eventFilter[p.name], [], (function (topicFilters) {
|
|
245
|
-
return normalizeOrThrow(topicFilters).map(Curry.__1(encoder));
|
|
246
|
-
}));
|
|
247
|
-
};
|
|
297
|
+
let encoder = getTopicEncoder(p.abiType);
|
|
298
|
+
return eventFilter => Stdlib_Option.mapOr(eventFilter[p.name], [], topicFilters => normalizeOrThrow(topicFilters).map(encoder));
|
|
248
299
|
}
|
|
249
300
|
|
|
250
|
-
|
|
301
|
+
let alwaysIncludedBlockFields = [
|
|
251
302
|
"number",
|
|
252
303
|
"timestamp",
|
|
253
304
|
"hash"
|
|
254
305
|
];
|
|
255
306
|
|
|
256
307
|
function resolveFieldSelection(blockFields, transactionFields, globalBlockFieldsSet, globalTransactionFieldsSet) {
|
|
257
|
-
|
|
258
|
-
|
|
308
|
+
let selectedBlockFields = blockFields !== undefined ? new Set(alwaysIncludedBlockFields.concat(blockFields)) : globalBlockFieldsSet;
|
|
309
|
+
let selectedTransactionFields = transactionFields !== undefined ? new Set(transactionFields) : globalTransactionFieldsSet;
|
|
259
310
|
return [
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
311
|
+
selectedBlockFields,
|
|
312
|
+
selectedTransactionFields
|
|
313
|
+
];
|
|
263
314
|
}
|
|
264
315
|
|
|
265
|
-
function buildEvmEventConfig(contractName, eventName, sighash, params, isWildcard, handler, contractRegister, eventFilters, blockFields, transactionFields, globalBlockFieldsSetOpt, globalTransactionFieldsSetOpt) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
var filterByAddresses = match.filterByAddresses;
|
|
282
|
-
var match$1 = resolveFieldSelection(blockFields, transactionFields, globalBlockFieldsSet, globalTransactionFieldsSet);
|
|
316
|
+
function buildEvmEventConfig(contractName, eventName, sighash, params, isWildcard, handler, contractRegister, eventFilters, probeChainId, onEventBlockFilterSchema, blockFields, transactionFields, startBlock, globalBlockFieldsSetOpt, globalTransactionFieldsSetOpt) {
|
|
317
|
+
let globalBlockFieldsSet = globalBlockFieldsSetOpt !== undefined ? Primitive_option.valFromOption(globalBlockFieldsSetOpt) : new Set();
|
|
318
|
+
let globalTransactionFieldsSet = globalTransactionFieldsSetOpt !== undefined ? Primitive_option.valFromOption(globalTransactionFieldsSetOpt) : new Set();
|
|
319
|
+
let topicCount = Stdlib_Array.reduce(params, 1, (acc, p) => {
|
|
320
|
+
if (p.indexed) {
|
|
321
|
+
return acc + 1 | 0;
|
|
322
|
+
} else {
|
|
323
|
+
return acc;
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
let indexedParams = params.filter(p => p.indexed);
|
|
327
|
+
let match = LogSelection.parseEventFiltersOrThrow(eventFilters, sighash, indexedParams.map(p => p.name), contractName, probeChainId, onEventBlockFilterSchema, Stdlib_Option.map(indexedParams[0], buildTopicGetter), Stdlib_Option.map(indexedParams[1], buildTopicGetter), Stdlib_Option.map(indexedParams[2], buildTopicGetter));
|
|
328
|
+
let whereStartBlock = match.startBlock;
|
|
329
|
+
let filterByAddresses = match.filterByAddresses;
|
|
330
|
+
let resolvedStartBlock = whereStartBlock !== undefined ? whereStartBlock : startBlock;
|
|
331
|
+
let match$1 = resolveFieldSelection(blockFields, transactionFields, globalBlockFieldsSet, globalTransactionFieldsSet);
|
|
283
332
|
return {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
333
|
+
id: sighash + "_" + topicCount.toString(),
|
|
334
|
+
name: eventName,
|
|
335
|
+
contractName: contractName,
|
|
336
|
+
isWildcard: isWildcard,
|
|
337
|
+
filterByAddresses: filterByAddresses,
|
|
338
|
+
dependsOnAddresses: !isWildcard || filterByAddresses,
|
|
339
|
+
handler: handler,
|
|
340
|
+
contractRegister: contractRegister,
|
|
341
|
+
paramsRawEventSchema: buildParamsSchema(params),
|
|
342
|
+
simulateParamsSchema: buildSimulateParamsSchema(params),
|
|
343
|
+
startBlock: resolvedStartBlock,
|
|
344
|
+
getEventFiltersOrThrow: match.getEventFiltersOrThrow,
|
|
345
|
+
convertHyperSyncEventArgs: buildHyperSyncDecoder(params),
|
|
346
|
+
selectedBlockFields: match$1[0],
|
|
347
|
+
selectedTransactionFields: match$1[1],
|
|
348
|
+
sighash: sighash,
|
|
349
|
+
indexedParams: indexedParams
|
|
350
|
+
};
|
|
299
351
|
}
|
|
300
352
|
|
|
301
|
-
function buildFuelEventConfig(contractName, eventName, kind, sighash, rawAbi, isWildcard, handler, contractRegister) {
|
|
302
|
-
|
|
353
|
+
function buildFuelEventConfig(contractName, eventName, kind, sighash, rawAbi, isWildcard, handler, contractRegister, startBlock) {
|
|
354
|
+
let fuelKind;
|
|
303
355
|
switch (kind) {
|
|
304
356
|
case "burn" :
|
|
305
|
-
|
|
306
|
-
|
|
357
|
+
fuelKind = "Burn";
|
|
358
|
+
break;
|
|
307
359
|
case "call" :
|
|
308
|
-
|
|
309
|
-
|
|
360
|
+
fuelKind = "Call";
|
|
361
|
+
break;
|
|
310
362
|
case "logData" :
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
363
|
+
let abi = FuelSDK.transpileAbi(rawAbi);
|
|
364
|
+
fuelKind = {
|
|
365
|
+
TAG: "LogData",
|
|
366
|
+
logId: sighash,
|
|
367
|
+
decode: FuelSDK.Receipt.getLogDataDecoder(abi, sighash)
|
|
368
|
+
};
|
|
369
|
+
break;
|
|
318
370
|
case "mint" :
|
|
319
|
-
|
|
320
|
-
|
|
371
|
+
fuelKind = "Mint";
|
|
372
|
+
break;
|
|
321
373
|
case "transfer" :
|
|
322
|
-
|
|
323
|
-
|
|
374
|
+
fuelKind = "Transfer";
|
|
375
|
+
break;
|
|
324
376
|
default:
|
|
325
|
-
fuelKind =
|
|
377
|
+
fuelKind = Stdlib_JsError.throwWithMessage(`Unsupported Fuel event kind: ` + kind);
|
|
326
378
|
}
|
|
327
|
-
|
|
379
|
+
let paramsSchema;
|
|
328
380
|
switch (kind) {
|
|
329
381
|
case "logData" :
|
|
330
|
-
|
|
331
|
-
|
|
382
|
+
paramsSchema = Utils.Schema.coerceToJsonPgType(S$RescriptSchema.json(false));
|
|
383
|
+
break;
|
|
332
384
|
case "burn" :
|
|
333
385
|
case "mint" :
|
|
334
|
-
|
|
335
|
-
|
|
386
|
+
paramsSchema = Internal.fuelSupplyParamsSchema;
|
|
387
|
+
break;
|
|
336
388
|
case "call" :
|
|
337
389
|
case "transfer" :
|
|
338
|
-
|
|
339
|
-
|
|
390
|
+
paramsSchema = Internal.fuelTransferParamsSchema;
|
|
391
|
+
break;
|
|
340
392
|
default:
|
|
341
|
-
paramsSchema =
|
|
393
|
+
paramsSchema = Stdlib_JsError.throwWithMessage(`Unsupported Fuel event kind: ` + kind);
|
|
342
394
|
}
|
|
343
|
-
|
|
395
|
+
let tmp = kind === "logData" ? sighash : kind;
|
|
344
396
|
return {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
397
|
+
id: tmp,
|
|
398
|
+
name: eventName,
|
|
399
|
+
contractName: contractName,
|
|
400
|
+
isWildcard: isWildcard,
|
|
401
|
+
filterByAddresses: false,
|
|
402
|
+
dependsOnAddresses: !isWildcard,
|
|
403
|
+
handler: handler,
|
|
404
|
+
contractRegister: contractRegister,
|
|
405
|
+
paramsRawEventSchema: paramsSchema,
|
|
406
|
+
simulateParamsSchema: paramsSchema,
|
|
407
|
+
startBlock: startBlock,
|
|
408
|
+
kind: fuelKind
|
|
409
|
+
};
|
|
357
410
|
}
|
|
358
411
|
|
|
359
412
|
export {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
413
|
+
eventParamComponentSchema,
|
|
414
|
+
eventParamSchema,
|
|
415
|
+
normalizeOrThrow,
|
|
416
|
+
splitTupleComponents,
|
|
417
|
+
abiTypeToSchema,
|
|
418
|
+
abiTypeToSimulateSchema,
|
|
419
|
+
abiTypeToDefaultValue,
|
|
420
|
+
componentsToSimulateSchema,
|
|
421
|
+
componentsToDefaultValue,
|
|
422
|
+
componentsToRemapper,
|
|
423
|
+
buildParamsSchema,
|
|
424
|
+
buildSimulateParamsSchema,
|
|
425
|
+
buildHyperSyncDecoder,
|
|
426
|
+
getTopicEncoder,
|
|
427
|
+
buildTopicGetter,
|
|
428
|
+
alwaysIncludedBlockFields,
|
|
429
|
+
resolveFieldSelection,
|
|
430
|
+
buildEvmEventConfig,
|
|
431
|
+
buildFuelEventConfig,
|
|
375
432
|
}
|
|
376
|
-
/*
|
|
433
|
+
/* eventParamComponentSchema Not a pure module */
|