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
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
open Belt
|
|
2
|
+
|
|
3
|
+
// Message types for communication between worker and main thread
|
|
4
|
+
type requestId = int
|
|
5
|
+
|
|
6
|
+
// Serializable change with entity as JSON (for worker thread messaging)
|
|
7
|
+
@tag("type")
|
|
8
|
+
type serializableChange =
|
|
9
|
+
| @as("SET") Set({entityId: string, entity: Js.Json.t, checkpointId: bigint})
|
|
10
|
+
| @as("DELETE") Delete({entityId: string, checkpointId: bigint})
|
|
11
|
+
|
|
12
|
+
type serializableEntityUpdate = {
|
|
13
|
+
latestChange: serializableChange,
|
|
14
|
+
history: array<serializableChange>,
|
|
15
|
+
containsRollbackDiffChange: bool,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type serializableUpdatedEntity = {
|
|
19
|
+
entityName: string,
|
|
20
|
+
updates: array<serializableEntityUpdate>,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Worker -> Main thread payloads
|
|
24
|
+
@tag("type")
|
|
25
|
+
type workerPayload =
|
|
26
|
+
| @as("loadByIds") LoadByIds({tableName: string, ids: array<string>})
|
|
27
|
+
| @as("loadByField")
|
|
28
|
+
LoadByField({
|
|
29
|
+
tableName: string,
|
|
30
|
+
fieldName: string,
|
|
31
|
+
fieldValue: Js.Json.t,
|
|
32
|
+
operator: Persistence.operator,
|
|
33
|
+
})
|
|
34
|
+
| @as("writeBatch")
|
|
35
|
+
WriteBatch({
|
|
36
|
+
updatedEntities: array<serializableUpdatedEntity>,
|
|
37
|
+
checkpointIds: array<bigint>,
|
|
38
|
+
checkpointChainIds: array<int>,
|
|
39
|
+
checkpointBlockNumbers: array<int>,
|
|
40
|
+
checkpointBlockHashes: array<Js.Null.t<string>>,
|
|
41
|
+
checkpointEventsProcessed: array<int>,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
// Main thread -> Worker payloads
|
|
45
|
+
@tag("type")
|
|
46
|
+
type mainPayload =
|
|
47
|
+
| @as("response") Response({data: Js.Json.t})
|
|
48
|
+
| @as("error") Error({message: string})
|
|
49
|
+
|
|
50
|
+
// Message wrapper with id
|
|
51
|
+
type message<'payload> = {id: requestId, payload: 'payload}
|
|
52
|
+
type workerMessage = message<workerPayload>
|
|
53
|
+
type mainMessage = message<mainPayload>
|
|
54
|
+
|
|
55
|
+
// Pending request tracker
|
|
56
|
+
type pendingRequest = {
|
|
57
|
+
resolve: Js.Json.t => unit,
|
|
58
|
+
reject: exn => unit,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type t = {
|
|
62
|
+
parentPort: NodeJs.WorkerThreads.messagePort,
|
|
63
|
+
initialState: Persistence.initialState,
|
|
64
|
+
pendingRequests: dict<pendingRequest>,
|
|
65
|
+
mutable requestCounter: int,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let make = (~parentPort, ~initialState): t => {
|
|
69
|
+
let proxy = {
|
|
70
|
+
parentPort,
|
|
71
|
+
initialState,
|
|
72
|
+
pendingRequests: Js.Dict.empty(),
|
|
73
|
+
requestCounter: 0,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Set up message listener for responses from main thread
|
|
77
|
+
parentPort->NodeJs.WorkerThreads.onPortMessage((msg: mainMessage) => {
|
|
78
|
+
let idStr = msg.id->Int.toString
|
|
79
|
+
let {resolve, reject} = switch proxy.pendingRequests->Utils.Dict.dangerouslyGetNonOption(
|
|
80
|
+
idStr,
|
|
81
|
+
) {
|
|
82
|
+
| Some(pending) => pending
|
|
83
|
+
| None => Js.Exn.raiseError(`TestIndexer: No pending request found for id ${idStr}`)
|
|
84
|
+
}
|
|
85
|
+
Js.Dict.unsafeDeleteKey(proxy.pendingRequests->Obj.magic, idStr)
|
|
86
|
+
|
|
87
|
+
switch msg.payload {
|
|
88
|
+
| Response({data}) => resolve(data)
|
|
89
|
+
| Error({message}) => reject(Utils.Error.make(message))
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
proxy
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let nextRequestId = (proxy: t): requestId => {
|
|
97
|
+
proxy.requestCounter = proxy.requestCounter + 1
|
|
98
|
+
proxy.requestCounter
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let sendRequest = (proxy: t, ~payload: workerPayload): promise<Js.Json.t> => {
|
|
102
|
+
Promise.make((resolve, reject) => {
|
|
103
|
+
let id = proxy->nextRequestId
|
|
104
|
+
proxy.pendingRequests->Js.Dict.set(id->Int.toString, {resolve, reject})
|
|
105
|
+
proxy.parentPort->NodeJs.WorkerThreads.postMessage({id, payload})
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let makeStorage = (proxy: t): Persistence.storage => {
|
|
110
|
+
isInitialized: async () => true,
|
|
111
|
+
initialize: async (~chainConfigs as _=?, ~entities as _=?, ~enums as _=?) => {
|
|
112
|
+
Js.Exn.raiseError(
|
|
113
|
+
"TestIndexer: initialize should not be called. Use resumeInitialState instead.",
|
|
114
|
+
)
|
|
115
|
+
},
|
|
116
|
+
resumeInitialState: async () => proxy.initialState,
|
|
117
|
+
loadByIdsOrThrow: async (~ids, ~table: Table.table, ~rowsSchema) => {
|
|
118
|
+
let response = await proxy->sendRequest(~payload=LoadByIds({tableName: table.tableName, ids}))
|
|
119
|
+
response->S.parseOrThrow(rowsSchema)
|
|
120
|
+
},
|
|
121
|
+
loadByFieldOrThrow: async (
|
|
122
|
+
~fieldName,
|
|
123
|
+
~fieldSchema,
|
|
124
|
+
~fieldValue,
|
|
125
|
+
~operator,
|
|
126
|
+
~table: Table.table,
|
|
127
|
+
~rowsSchema,
|
|
128
|
+
) => {
|
|
129
|
+
let response = await proxy->sendRequest(
|
|
130
|
+
~payload=LoadByField({
|
|
131
|
+
tableName: table.tableName,
|
|
132
|
+
fieldName,
|
|
133
|
+
fieldValue: fieldValue->S.reverseConvertToJsonOrThrow(fieldSchema),
|
|
134
|
+
operator,
|
|
135
|
+
}),
|
|
136
|
+
)
|
|
137
|
+
response->S.parseOrThrow(rowsSchema)
|
|
138
|
+
},
|
|
139
|
+
writeBatch: async (
|
|
140
|
+
~batch,
|
|
141
|
+
~rawEvents as _,
|
|
142
|
+
~rollbackTargetCheckpointId as _,
|
|
143
|
+
~isInReorgThreshold as _,
|
|
144
|
+
~config as _,
|
|
145
|
+
~allEntities as _,
|
|
146
|
+
~updatedEffectsCache as _,
|
|
147
|
+
~updatedEntities,
|
|
148
|
+
) => {
|
|
149
|
+
// Encode entities to JSON for serialization across worker boundary
|
|
150
|
+
let serializableEntities = updatedEntities->Array.map((
|
|
151
|
+
{entityConfig, updates}: Persistence.updatedEntity,
|
|
152
|
+
) => {
|
|
153
|
+
let encodeChange = (change: Change.t<Internal.entity>): serializableChange => {
|
|
154
|
+
switch change {
|
|
155
|
+
| Set({entityId, entity, checkpointId}) =>
|
|
156
|
+
Set({
|
|
157
|
+
entityId,
|
|
158
|
+
entity: entity->S.reverseConvertToJsonOrThrow(entityConfig.schema),
|
|
159
|
+
checkpointId,
|
|
160
|
+
})
|
|
161
|
+
| Delete({entityId, checkpointId}) => Delete({entityId, checkpointId})
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
{
|
|
165
|
+
entityName: entityConfig.name,
|
|
166
|
+
updates: updates->Array.map(update => {
|
|
167
|
+
latestChange: encodeChange(update.latestChange),
|
|
168
|
+
history: update.history->Array.map(encodeChange),
|
|
169
|
+
containsRollbackDiffChange: update.containsRollbackDiffChange,
|
|
170
|
+
}),
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
let _ = await proxy->sendRequest(
|
|
174
|
+
~payload=WriteBatch({
|
|
175
|
+
updatedEntities: serializableEntities,
|
|
176
|
+
checkpointIds: batch.checkpointIds,
|
|
177
|
+
checkpointChainIds: batch.checkpointChainIds,
|
|
178
|
+
checkpointBlockNumbers: batch.checkpointBlockNumbers,
|
|
179
|
+
checkpointBlockHashes: batch.checkpointBlockHashes,
|
|
180
|
+
checkpointEventsProcessed: batch.checkpointEventsProcessed,
|
|
181
|
+
}),
|
|
182
|
+
)
|
|
183
|
+
},
|
|
184
|
+
dumpEffectCache: async () => (),
|
|
185
|
+
reset: async () => (),
|
|
186
|
+
setChainMeta: async _ => Obj.magic(),
|
|
187
|
+
pruneStaleCheckpoints: async (~safeCheckpointId as _) => (),
|
|
188
|
+
pruneStaleEntityHistory: async (~entityName as _, ~entityIndex as _, ~safeCheckpointId as _) =>
|
|
189
|
+
(),
|
|
190
|
+
getRollbackTargetCheckpoint: async (~reorgChainId as _, ~lastKnownValidBlockNumber as _) => {
|
|
191
|
+
Js.Exn.raiseError(
|
|
192
|
+
"TestIndexer: Rollback is not supported. Set rollbackOnReorg to false in config.",
|
|
193
|
+
)
|
|
194
|
+
},
|
|
195
|
+
getRollbackProgressDiff: async (~rollbackTargetCheckpointId as _) => {
|
|
196
|
+
Js.Exn.raiseError(
|
|
197
|
+
"TestIndexer: Rollback is not supported. Set rollbackOnReorg to false in config.",
|
|
198
|
+
)
|
|
199
|
+
},
|
|
200
|
+
getRollbackData: async (~entityConfig as _, ~rollbackTargetCheckpointId as _) => {
|
|
201
|
+
Js.Exn.raiseError(
|
|
202
|
+
"TestIndexer: Rollback is not supported. Set rollbackOnReorg to false in config.",
|
|
203
|
+
)
|
|
204
|
+
},
|
|
205
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
4
|
+
import * as Js_dict from "rescript/lib/es6/js_dict.js";
|
|
5
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
6
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
7
|
+
|
|
8
|
+
function make(parentPort, initialState) {
|
|
9
|
+
var proxy = {
|
|
10
|
+
parentPort: parentPort,
|
|
11
|
+
initialState: initialState,
|
|
12
|
+
pendingRequests: {},
|
|
13
|
+
requestCounter: 0
|
|
14
|
+
};
|
|
15
|
+
parentPort.on("message", (function (msg) {
|
|
16
|
+
var idStr = String(msg.id);
|
|
17
|
+
var pending = proxy.pendingRequests[idStr];
|
|
18
|
+
var match = pending !== undefined ? pending : Js_exn.raiseError("TestIndexer: No pending request found for id " + idStr);
|
|
19
|
+
Js_dict.unsafeDeleteKey(proxy.pendingRequests, idStr);
|
|
20
|
+
var match$1 = msg.payload;
|
|
21
|
+
if (match$1.type === "response") {
|
|
22
|
+
return match.resolve(match$1.data);
|
|
23
|
+
} else {
|
|
24
|
+
return match.reject(new Error(match$1.message));
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
return proxy;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function nextRequestId(proxy) {
|
|
31
|
+
proxy.requestCounter = proxy.requestCounter + 1 | 0;
|
|
32
|
+
return proxy.requestCounter;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function sendRequest(proxy, payload) {
|
|
36
|
+
return new Promise((function (resolve, reject) {
|
|
37
|
+
var id = nextRequestId(proxy);
|
|
38
|
+
proxy.pendingRequests[String(id)] = {
|
|
39
|
+
resolve: resolve,
|
|
40
|
+
reject: reject
|
|
41
|
+
};
|
|
42
|
+
proxy.parentPort.postMessage({
|
|
43
|
+
id: id,
|
|
44
|
+
payload: payload
|
|
45
|
+
});
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function makeStorage(proxy) {
|
|
50
|
+
return {
|
|
51
|
+
isInitialized: (async function () {
|
|
52
|
+
return true;
|
|
53
|
+
}),
|
|
54
|
+
initialize: (async function (param, param$1, param$2) {
|
|
55
|
+
return Js_exn.raiseError("TestIndexer: initialize should not be called. Use resumeInitialState instead.");
|
|
56
|
+
}),
|
|
57
|
+
resumeInitialState: (async function () {
|
|
58
|
+
return proxy.initialState;
|
|
59
|
+
}),
|
|
60
|
+
loadByIdsOrThrow: (async function (ids, table, rowsSchema) {
|
|
61
|
+
var response = await sendRequest(proxy, {
|
|
62
|
+
type: "loadByIds",
|
|
63
|
+
tableName: table.tableName,
|
|
64
|
+
ids: ids
|
|
65
|
+
});
|
|
66
|
+
return S$RescriptSchema.parseOrThrow(response, rowsSchema);
|
|
67
|
+
}),
|
|
68
|
+
loadByFieldOrThrow: (async function (fieldName, fieldSchema, fieldValue, operator, table, rowsSchema) {
|
|
69
|
+
var response = await sendRequest(proxy, {
|
|
70
|
+
type: "loadByField",
|
|
71
|
+
tableName: table.tableName,
|
|
72
|
+
fieldName: fieldName,
|
|
73
|
+
fieldValue: S$RescriptSchema.reverseConvertToJsonOrThrow(fieldValue, fieldSchema),
|
|
74
|
+
operator: operator
|
|
75
|
+
});
|
|
76
|
+
return S$RescriptSchema.parseOrThrow(response, rowsSchema);
|
|
77
|
+
}),
|
|
78
|
+
dumpEffectCache: (async function () {
|
|
79
|
+
|
|
80
|
+
}),
|
|
81
|
+
reset: (async function () {
|
|
82
|
+
|
|
83
|
+
}),
|
|
84
|
+
setChainMeta: (async function (param) {
|
|
85
|
+
|
|
86
|
+
}),
|
|
87
|
+
pruneStaleCheckpoints: (async function (param) {
|
|
88
|
+
|
|
89
|
+
}),
|
|
90
|
+
pruneStaleEntityHistory: (async function (param, param$1, param$2) {
|
|
91
|
+
|
|
92
|
+
}),
|
|
93
|
+
getRollbackTargetCheckpoint: (async function (param, param$1) {
|
|
94
|
+
return Js_exn.raiseError("TestIndexer: Rollback is not supported. Set rollbackOnReorg to false in config.");
|
|
95
|
+
}),
|
|
96
|
+
getRollbackProgressDiff: (async function (param) {
|
|
97
|
+
return Js_exn.raiseError("TestIndexer: Rollback is not supported. Set rollbackOnReorg to false in config.");
|
|
98
|
+
}),
|
|
99
|
+
getRollbackData: (async function (param, param$1) {
|
|
100
|
+
return Js_exn.raiseError("TestIndexer: Rollback is not supported. Set rollbackOnReorg to false in config.");
|
|
101
|
+
}),
|
|
102
|
+
writeBatch: (async function (batch, param, param$1, param$2, param$3, param$4, param$5, updatedEntities) {
|
|
103
|
+
var serializableEntities = Belt_Array.map(updatedEntities, (function (param) {
|
|
104
|
+
var entityConfig = param.entityConfig;
|
|
105
|
+
var encodeChange = function (change) {
|
|
106
|
+
if (change.type === "SET") {
|
|
107
|
+
return {
|
|
108
|
+
type: "SET",
|
|
109
|
+
entityId: change.entityId,
|
|
110
|
+
entity: S$RescriptSchema.reverseConvertToJsonOrThrow(change.entity, entityConfig.schema),
|
|
111
|
+
checkpointId: change.checkpointId
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
return {
|
|
115
|
+
type: "DELETE",
|
|
116
|
+
entityId: change.entityId,
|
|
117
|
+
checkpointId: change.checkpointId
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
entityName: entityConfig.name,
|
|
123
|
+
updates: Belt_Array.map(param.updates, (function (update) {
|
|
124
|
+
return {
|
|
125
|
+
latestChange: encodeChange(update.latestChange),
|
|
126
|
+
history: Belt_Array.map(update.history, encodeChange),
|
|
127
|
+
containsRollbackDiffChange: update.containsRollbackDiffChange
|
|
128
|
+
};
|
|
129
|
+
}))
|
|
130
|
+
};
|
|
131
|
+
}));
|
|
132
|
+
await sendRequest(proxy, {
|
|
133
|
+
type: "writeBatch",
|
|
134
|
+
updatedEntities: serializableEntities,
|
|
135
|
+
checkpointIds: batch.checkpointIds,
|
|
136
|
+
checkpointChainIds: batch.checkpointChainIds,
|
|
137
|
+
checkpointBlockNumbers: batch.checkpointBlockNumbers,
|
|
138
|
+
checkpointBlockHashes: batch.checkpointBlockHashes,
|
|
139
|
+
checkpointEventsProcessed: batch.checkpointEventsProcessed
|
|
140
|
+
});
|
|
141
|
+
})
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
make ,
|
|
147
|
+
nextRequestId ,
|
|
148
|
+
sendRequest ,
|
|
149
|
+
makeStorage ,
|
|
150
|
+
}
|
|
151
|
+
/* S-RescriptSchema Not a pure module */
|
package/src/TopicFilter.res
CHANGED
|
@@ -16,7 +16,7 @@ type bytesHex = string
|
|
|
16
16
|
let keccak256 = Viem.keccak256
|
|
17
17
|
let bytesToHex = Viem.bytesToHex
|
|
18
18
|
let concat = Viem.concat
|
|
19
|
-
let castToHexUnsafe: 'a => hex = val => val->Utils.magic
|
|
19
|
+
let castToHexUnsafe: 'a => hex = val => val->(Utils.magic: 'a => hex)
|
|
20
20
|
let fromBigInt: bigint => hex = val => val->Viem.bigintToHex(~options={size: 32})
|
|
21
21
|
let fromDynamicString: string => hex = val => val->(Utils.magic: string => hex)->keccak256
|
|
22
22
|
let fromString: string => hex = val => val->Viem.stringToHex(~options={size: 32})
|