envio 3.3.0-alpha.4 → 3.3.0-alpha.5
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/evm.schema.json +10 -0
- package/package.json +7 -7
- package/src/Batch.res.mjs +1 -1
- package/src/ChainState.res +41 -7
- package/src/ChainState.res.mjs +22 -18
- package/src/ChainState.resi +3 -1
- package/src/Config.res +3 -0
- package/src/Config.res.mjs +3 -1
- package/src/Core.res +0 -3
- package/src/FetchState.res +63 -133
- package/src/FetchState.res.mjs +107 -166
- package/src/IndexingAddresses.res +105 -0
- package/src/IndexingAddresses.res.mjs +100 -0
- package/src/IndexingAddresses.resi +32 -0
- package/src/Main.res +4 -15
- package/src/Main.res.mjs +6 -14
- package/src/Metrics.res +33 -0
- package/src/Metrics.res.mjs +39 -0
- package/src/Prometheus.res +2 -20
- package/src/Prometheus.res.mjs +83 -95
- package/src/bindings/Viem.res +0 -41
- package/src/bindings/Viem.res.mjs +1 -43
- package/src/sources/Evm.res +7 -36
- package/src/sources/Evm.res.mjs +4 -36
- package/src/sources/EvmChain.res +3 -1
- package/src/sources/EvmChain.res.mjs +2 -1
- package/src/sources/EvmRpcClient.res +36 -5
- package/src/sources/EvmRpcClient.res.mjs +7 -4
- package/src/sources/HyperSyncClient.res +0 -35
- package/src/sources/HyperSyncClient.res.mjs +1 -8
- package/src/sources/Rpc.res +15 -47
- package/src/sources/Rpc.res.mjs +25 -56
- package/src/sources/RpcSource.res +30 -73
- package/src/sources/RpcSource.res.mjs +24 -73
- package/src/sources/Svm.res +7 -15
- package/src/sources/Svm.res.mjs +4 -15
- package/src/sources/TransactionStore.res +14 -2
- package/src/sources/TransactionStore.res.mjs +10 -2
|
@@ -224,7 +224,7 @@ let getSuggestedBlockIntervalFromExn = {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
type eventBatchQuery = {
|
|
227
|
-
|
|
227
|
+
items: array<EvmRpcClient.rpcEventItem>,
|
|
228
228
|
latestFetchedBlockInfo: blockInfo,
|
|
229
229
|
}
|
|
230
230
|
|
|
@@ -234,10 +234,10 @@ let getNextPage = (
|
|
|
234
234
|
~fromBlock,
|
|
235
235
|
~toBlock,
|
|
236
236
|
~addresses,
|
|
237
|
-
~topicQuery,
|
|
237
|
+
~topicQuery: Rpc.GetLogs.topicQuery,
|
|
238
238
|
~loadBlock,
|
|
239
239
|
~syncConfig as sc: Config.sourceSync,
|
|
240
|
-
~
|
|
240
|
+
~rpcClient: EvmRpcClient.t,
|
|
241
241
|
~mutSuggestedBlockIntervals,
|
|
242
242
|
~partitionId,
|
|
243
243
|
~sourceName,
|
|
@@ -253,17 +253,20 @@ let getNextPage = (
|
|
|
253
253
|
|
|
254
254
|
let latestFetchedBlockPromise = loadBlock(toBlock)
|
|
255
255
|
Prometheus.SourceRequestCount.increment(~sourceName, ~chainId, ~method="eth_getLogs")
|
|
256
|
-
let logsPromise =
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
256
|
+
let logsPromise = rpcClient.getLogs({
|
|
257
|
+
fromBlock,
|
|
258
|
+
toBlock,
|
|
259
|
+
?addresses,
|
|
260
|
+
topics: topicQuery->Array.map(filter =>
|
|
261
|
+
switch filter {
|
|
262
|
+
| Rpc.GetLogs.Null => Nullable.null
|
|
263
|
+
| Single(topic) => Nullable.make([topic])
|
|
264
|
+
| Multiple(topics) => Nullable.make(topics)
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
})->Promise.then(async items => {
|
|
265
268
|
{
|
|
266
|
-
|
|
269
|
+
items,
|
|
267
270
|
latestFetchedBlockInfo: await latestFetchedBlockPromise,
|
|
268
271
|
}
|
|
269
272
|
})
|
|
@@ -855,6 +858,7 @@ type options = {
|
|
|
855
858
|
allEventParams: array<HyperSyncClient.Decoder.eventParamsInput>,
|
|
856
859
|
lowercaseAddresses: bool,
|
|
857
860
|
ws?: string,
|
|
861
|
+
headers?: dict<string>,
|
|
858
862
|
}
|
|
859
863
|
|
|
860
864
|
let make = (
|
|
@@ -867,6 +871,7 @@ let make = (
|
|
|
867
871
|
allEventParams,
|
|
868
872
|
lowercaseAddresses,
|
|
869
873
|
?ws,
|
|
874
|
+
?headers,
|
|
870
875
|
}: options,
|
|
871
876
|
): t => {
|
|
872
877
|
let chainId = chain->ChainMap.Chain.toChainId
|
|
@@ -883,8 +888,13 @@ let make = (
|
|
|
883
888
|
|
|
884
889
|
let mutSuggestedBlockIntervals = Dict.make()
|
|
885
890
|
|
|
886
|
-
let client = Rpc.makeClient(url)
|
|
887
|
-
let rpcClient = EvmRpcClient.make(
|
|
891
|
+
let client = Rpc.makeClient(url, ~headers?)
|
|
892
|
+
let rpcClient = EvmRpcClient.make(
|
|
893
|
+
~url,
|
|
894
|
+
~allEventParams,
|
|
895
|
+
~checksumAddresses=!lowercaseAddresses,
|
|
896
|
+
~headers?,
|
|
897
|
+
)
|
|
888
898
|
|
|
889
899
|
let makeTransactionLoader = () =>
|
|
890
900
|
LazyLoader.make(
|
|
@@ -1000,36 +1010,6 @@ let make = (
|
|
|
1000
1010
|
~lowercaseAddresses,
|
|
1001
1011
|
)
|
|
1002
1012
|
|
|
1003
|
-
let convertLogToHyperSyncEvent = (log: Rpc.GetLogs.log): HyperSyncClient.ResponseTypes.event => {
|
|
1004
|
-
let hyperSyncLog: HyperSyncClient.ResponseTypes.log = {
|
|
1005
|
-
removed: log.removed,
|
|
1006
|
-
index: log.logIndex,
|
|
1007
|
-
transactionIndex: log.transactionIndex,
|
|
1008
|
-
transactionHash: log.transactionHash,
|
|
1009
|
-
blockHash: log.blockHash,
|
|
1010
|
-
blockNumber: log.blockNumber,
|
|
1011
|
-
address: log.address,
|
|
1012
|
-
data: log.data,
|
|
1013
|
-
topics: log.topics->(Utils.magic: array<string> => array<Nullable.t<EvmTypes.Hex.t>>),
|
|
1014
|
-
}
|
|
1015
|
-
{log: hyperSyncLog}
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
let hscDecoder: ref<option<HyperSyncClient.Decoder.tWithParams>> = ref(None)
|
|
1019
|
-
let getHscDecoder = () => {
|
|
1020
|
-
switch hscDecoder.contents {
|
|
1021
|
-
| Some(decoder) => decoder
|
|
1022
|
-
| None => {
|
|
1023
|
-
let decoder = HyperSyncClient.Decoder.fromParams(
|
|
1024
|
-
allEventParams,
|
|
1025
|
-
~checksumAddresses=!lowercaseAddresses,
|
|
1026
|
-
)
|
|
1027
|
-
hscDecoder := Some(decoder)
|
|
1028
|
-
decoder
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
1013
|
let getItemsOrThrow = async (
|
|
1034
1014
|
~fromBlock,
|
|
1035
1015
|
~toBlock,
|
|
@@ -1073,7 +1053,7 @@ let make = (
|
|
|
1073
1053
|
let {getLogSelectionOrThrow} = getSelectionConfig(selection)
|
|
1074
1054
|
let {addresses, topicQuery} = getLogSelectionOrThrow(~addressesByContractName)
|
|
1075
1055
|
|
|
1076
|
-
let {
|
|
1056
|
+
let {items, latestFetchedBlockInfo} = await getNextPage(
|
|
1077
1057
|
~fromBlock,
|
|
1078
1058
|
~toBlock=suggestedToBlock,
|
|
1079
1059
|
~addresses,
|
|
@@ -1083,7 +1063,7 @@ let make = (
|
|
|
1083
1063
|
->LazyLoader.get(blockNumber)
|
|
1084
1064
|
->Promise.thenResolve(parseBlockInfo),
|
|
1085
1065
|
~syncConfig,
|
|
1086
|
-
~
|
|
1066
|
+
~rpcClient,
|
|
1087
1067
|
~mutSuggestedBlockIntervals,
|
|
1088
1068
|
~partitionId,
|
|
1089
1069
|
~sourceName=name,
|
|
@@ -1110,31 +1090,8 @@ let make = (
|
|
|
1110
1090
|
)
|
|
1111
1091
|
}
|
|
1112
1092
|
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
// Decode using HyperSyncClient decoder
|
|
1117
|
-
let parsedEvents = try await getHscDecoder().decodeLogs(hyperSyncEvents) catch {
|
|
1118
|
-
| exn =>
|
|
1119
|
-
throw(
|
|
1120
|
-
Source.GetItemsError(
|
|
1121
|
-
FailedGettingItems({
|
|
1122
|
-
exn,
|
|
1123
|
-
attemptedToBlock: toBlock,
|
|
1124
|
-
retry: ImpossibleForTheQuery({
|
|
1125
|
-
message: "Failed to parse events using hypersync client decoder. Please double-check your ABI.",
|
|
1126
|
-
}),
|
|
1127
|
-
}),
|
|
1128
|
-
),
|
|
1129
|
-
)
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
let parsedQueueItems = await logs
|
|
1133
|
-
->Array.zip(parsedEvents)
|
|
1134
|
-
->Array.filterMap(((
|
|
1135
|
-
log: Rpc.GetLogs.log,
|
|
1136
|
-
maybeDecodedEvent: Nullable.t<dict<Internal.eventParams>>,
|
|
1137
|
-
)) => {
|
|
1093
|
+
let parsedQueueItems = await items
|
|
1094
|
+
->Array.filterMap(({log, params: maybeDecodedEvent}: EvmRpcClient.rpcEventItem) => {
|
|
1138
1095
|
let topic0 = log.topics[0]->Option.getOr("0x0")
|
|
1139
1096
|
let routedAddress = if lowercaseAddresses {
|
|
1140
1097
|
log.address->Address.Evm.fromAddressLowercaseOrThrow
|
|
@@ -1242,7 +1199,7 @@ let make = (
|
|
|
1242
1199
|
| Some(b) => pushBlockInfo(b)
|
|
1243
1200
|
| None => ()
|
|
1244
1201
|
}
|
|
1245
|
-
|
|
1202
|
+
items->Array.forEach(({log}) =>
|
|
1246
1203
|
blockHashes
|
|
1247
1204
|
->Array.push({ReorgDetection.blockNumber: log.blockNumber, blockHash: log.blockHash})
|
|
1248
1205
|
->ignore
|
|
@@ -21,7 +21,6 @@ import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
|
|
|
21
21
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
22
22
|
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
23
23
|
import * as Stdlib_Promise from "@rescript/runtime/lib/es6/Stdlib_Promise.js";
|
|
24
|
-
import * as HyperSyncClient from "./HyperSyncClient.res.mjs";
|
|
25
24
|
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
26
25
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
27
26
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
@@ -221,20 +220,28 @@ function getSuggestedBlockIntervalFromExn(exn) {
|
|
|
221
220
|
|
|
222
221
|
let maxSuggestedBlockIntervalKey = "max";
|
|
223
222
|
|
|
224
|
-
function getNextPage(fromBlock, toBlock, addresses, topicQuery, loadBlock, sc,
|
|
223
|
+
function getNextPage(fromBlock, toBlock, addresses, topicQuery, loadBlock, sc, rpcClient, mutSuggestedBlockIntervals, partitionId, sourceName, chainId) {
|
|
225
224
|
let queryTimoutPromise = Time.resolvePromiseAfterDelay(sc.queryTimeoutMillis).then(() => Promise.reject({
|
|
226
225
|
RE_EXN_ID: QueryTimout,
|
|
227
226
|
_1: `Query took longer than ` + (sc.queryTimeoutMillis / 1000 | 0).toString() + ` seconds`
|
|
228
227
|
}));
|
|
229
228
|
let latestFetchedBlockPromise = loadBlock(toBlock);
|
|
230
229
|
Prometheus.SourceRequestCount.increment(sourceName, chainId, "eth_getLogs");
|
|
231
|
-
let logsPromise =
|
|
230
|
+
let logsPromise = rpcClient.getLogs({
|
|
232
231
|
fromBlock: fromBlock,
|
|
233
232
|
toBlock: toBlock,
|
|
234
|
-
|
|
235
|
-
topics: topicQuery
|
|
236
|
-
|
|
237
|
-
|
|
233
|
+
addresses: addresses,
|
|
234
|
+
topics: topicQuery.map(filter => {
|
|
235
|
+
if (filter === null) {
|
|
236
|
+
return null;
|
|
237
|
+
} else if (typeof filter === "string") {
|
|
238
|
+
return [filter];
|
|
239
|
+
} else {
|
|
240
|
+
return filter;
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
}).then(async items => ({
|
|
244
|
+
items: items,
|
|
238
245
|
latestFetchedBlockInfo: await latestFetchedBlockPromise
|
|
239
246
|
}));
|
|
240
247
|
return Stdlib_Promise.$$catch(Promise.race([
|
|
@@ -918,8 +925,8 @@ function makeThrowingGetEventTransaction(getTransactionJson, getReceiptJson, low
|
|
|
918
925
|
}
|
|
919
926
|
|
|
920
927
|
function make(param) {
|
|
928
|
+
let headers = param.headers;
|
|
921
929
|
let lowercaseAddresses = param.lowercaseAddresses;
|
|
922
|
-
let allEventParams = param.allEventParams;
|
|
923
930
|
let eventRouter = param.eventRouter;
|
|
924
931
|
let chain = param.chain;
|
|
925
932
|
let url = param.url;
|
|
@@ -929,8 +936,8 @@ function make(param) {
|
|
|
929
936
|
let name = `RPC (` + urlHost + `)`;
|
|
930
937
|
let getSelectionConfig = memoGetSelectionConfig(chain);
|
|
931
938
|
let mutSuggestedBlockIntervals = {};
|
|
932
|
-
let client = Rpc.makeClient(url);
|
|
933
|
-
let rpcClient = EvmRpcClient.make(url, undefined);
|
|
939
|
+
let client = Rpc.makeClient(url, headers);
|
|
940
|
+
let rpcClient = EvmRpcClient.make(url, !lowercaseAddresses, undefined, headers, param.allEventParams);
|
|
934
941
|
let makeTransactionLoader = () => LazyLoader.make(transactionHash => {
|
|
935
942
|
Prometheus.SourceRequestCount.increment(name, chain, "eth_getTransactionByHash");
|
|
936
943
|
return Rest.fetch(Rpc.GetTransactionByHash.rawRoute, transactionHash, client);
|
|
@@ -998,43 +1005,6 @@ function make(param) {
|
|
|
998
1005
|
Error: new Error()
|
|
999
1006
|
};
|
|
1000
1007
|
}, lowercaseAddresses);
|
|
1001
|
-
let convertLogToHyperSyncEvent = log => {
|
|
1002
|
-
let hyperSyncLog_removed = log.removed;
|
|
1003
|
-
let hyperSyncLog_logIndex = log.logIndex;
|
|
1004
|
-
let hyperSyncLog_transactionIndex = log.transactionIndex;
|
|
1005
|
-
let hyperSyncLog_transactionHash = log.transactionHash;
|
|
1006
|
-
let hyperSyncLog_blockHash = log.blockHash;
|
|
1007
|
-
let hyperSyncLog_blockNumber = log.blockNumber;
|
|
1008
|
-
let hyperSyncLog_address = Primitive_option.some(log.address);
|
|
1009
|
-
let hyperSyncLog_data = log.data;
|
|
1010
|
-
let hyperSyncLog_topics = log.topics;
|
|
1011
|
-
let hyperSyncLog = {
|
|
1012
|
-
removed: hyperSyncLog_removed,
|
|
1013
|
-
logIndex: hyperSyncLog_logIndex,
|
|
1014
|
-
transactionIndex: hyperSyncLog_transactionIndex,
|
|
1015
|
-
transactionHash: hyperSyncLog_transactionHash,
|
|
1016
|
-
blockHash: hyperSyncLog_blockHash,
|
|
1017
|
-
blockNumber: hyperSyncLog_blockNumber,
|
|
1018
|
-
address: hyperSyncLog_address,
|
|
1019
|
-
data: hyperSyncLog_data,
|
|
1020
|
-
topics: hyperSyncLog_topics
|
|
1021
|
-
};
|
|
1022
|
-
return {
|
|
1023
|
-
log: hyperSyncLog
|
|
1024
|
-
};
|
|
1025
|
-
};
|
|
1026
|
-
let hscDecoder = {
|
|
1027
|
-
contents: undefined
|
|
1028
|
-
};
|
|
1029
|
-
let getHscDecoder = () => {
|
|
1030
|
-
let decoder = hscDecoder.contents;
|
|
1031
|
-
if (decoder !== undefined) {
|
|
1032
|
-
return decoder;
|
|
1033
|
-
}
|
|
1034
|
-
let decoder$1 = HyperSyncClient.Decoder.fromParams(allEventParams, !lowercaseAddresses);
|
|
1035
|
-
hscDecoder.contents = decoder$1;
|
|
1036
|
-
return decoder$1;
|
|
1037
|
-
};
|
|
1038
1008
|
let getItemsOrThrow = async (fromBlock, toBlock, addressesByContractName, contractNameByAddress, knownHeight, partitionId, selection, retry, param) => {
|
|
1039
1009
|
let startFetchingBatchTimeRef = Performance.now();
|
|
1040
1010
|
let maxSuggestedBlockInterval = mutSuggestedBlockIntervals[maxSuggestedBlockIntervalKey];
|
|
@@ -1044,42 +1014,22 @@ function make(param) {
|
|
|
1044
1014
|
let firstBlockParentPromise = fromBlock > 0 ? LazyLoader.get(blockLoader.contents, fromBlock - 1 | 0).then(json => parseBlockInfo(json)) : Promise.resolve(undefined);
|
|
1045
1015
|
let match = getSelectionConfig(selection);
|
|
1046
1016
|
let match$1 = match.getLogSelectionOrThrow(addressesByContractName);
|
|
1047
|
-
let match$2 = await getNextPage(fromBlock, suggestedToBlock, match$1.addresses, match$1.topicQuery, blockNumber => LazyLoader.get(blockLoader.contents, blockNumber).then(parseBlockInfo), syncConfig,
|
|
1017
|
+
let match$2 = await getNextPage(fromBlock, suggestedToBlock, match$1.addresses, match$1.topicQuery, blockNumber => LazyLoader.get(blockLoader.contents, blockNumber).then(parseBlockInfo), syncConfig, rpcClient, mutSuggestedBlockIntervals, partitionId, name, chain);
|
|
1048
1018
|
let latestFetchedBlockInfo = match$2.latestFetchedBlockInfo;
|
|
1049
|
-
let
|
|
1019
|
+
let items = match$2.items;
|
|
1050
1020
|
let executedBlockInterval = (suggestedToBlock - fromBlock | 0) + 1 | 0;
|
|
1051
1021
|
if (executedBlockInterval >= suggestedBlockInterval && !(maxSuggestedBlockIntervalKey in mutSuggestedBlockIntervals)) {
|
|
1052
1022
|
mutSuggestedBlockIntervals[partitionId] = Primitive_int.min(executedBlockInterval + syncConfig.accelerationAdditive | 0, syncConfig.intervalCeiling);
|
|
1053
1023
|
}
|
|
1054
|
-
let
|
|
1055
|
-
|
|
1056
|
-
try {
|
|
1057
|
-
parsedEvents = await getHscDecoder().decodeLogs(hyperSyncEvents);
|
|
1058
|
-
} catch (raw_exn) {
|
|
1059
|
-
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
1060
|
-
throw {
|
|
1061
|
-
RE_EXN_ID: Source.GetItemsError,
|
|
1062
|
-
_1: {
|
|
1063
|
-
TAG: "FailedGettingItems",
|
|
1064
|
-
exn: exn,
|
|
1065
|
-
attemptedToBlock: toBlock$1,
|
|
1066
|
-
retry: {
|
|
1067
|
-
TAG: "ImpossibleForTheQuery",
|
|
1068
|
-
message: "Failed to parse events using hypersync client decoder. Please double-check your ABI."
|
|
1069
|
-
}
|
|
1070
|
-
},
|
|
1071
|
-
Error: new Error()
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
let parsedQueueItems = await Promise.all(Stdlib_Array.filterMap(Stdlib_Array.zip(logs, parsedEvents), param => {
|
|
1075
|
-
let log = param[0];
|
|
1024
|
+
let parsedQueueItems = await Promise.all(Stdlib_Array.filterMap(items, param => {
|
|
1025
|
+
let log = param.log;
|
|
1076
1026
|
let topic0 = Stdlib_Option.getOr(log.topics[0], "0x0");
|
|
1077
1027
|
let routedAddress = lowercaseAddresses ? Address.Evm.fromAddressLowercaseOrThrow(log.address) : Address.Evm.fromAddressOrThrow(log.address);
|
|
1078
1028
|
let eventConfig = EventRouter.get(eventRouter, EventRouter.getEvmEventId(topic0, log.topics.length), routedAddress, contractNameByAddress);
|
|
1079
1029
|
if (eventConfig === undefined) {
|
|
1080
1030
|
return;
|
|
1081
1031
|
}
|
|
1082
|
-
let decoded = Stdlib_Option.flatMap(Primitive_option.fromNullable(param
|
|
1032
|
+
let decoded = Stdlib_Option.flatMap(Primitive_option.fromNullable(param.params), __x => __x[eventConfig.contractName]);
|
|
1083
1033
|
if (decoded === undefined) {
|
|
1084
1034
|
return;
|
|
1085
1035
|
}
|
|
@@ -1165,7 +1115,8 @@ function make(param) {
|
|
|
1165
1115
|
if (optFirstBlockParent !== undefined) {
|
|
1166
1116
|
pushBlockInfo(optFirstBlockParent);
|
|
1167
1117
|
}
|
|
1168
|
-
|
|
1118
|
+
items.forEach(param => {
|
|
1119
|
+
let log = param.log;
|
|
1169
1120
|
blockHashes.push({
|
|
1170
1121
|
blockHash: log.blockHash,
|
|
1171
1122
|
blockNumber: log.blockNumber
|
package/src/sources/Svm.res
CHANGED
|
@@ -4,21 +4,13 @@ let cleanUpRawEventFieldsInPlace: JSON.t => unit = %raw(`fields => {
|
|
|
4
4
|
delete fields.time
|
|
5
5
|
}`)
|
|
6
6
|
|
|
7
|
-
// Ordered transaction field names
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"err",
|
|
15
|
-
"fee",
|
|
16
|
-
"computeUnitsConsumed",
|
|
17
|
-
"accountKeys",
|
|
18
|
-
"recentBlockhash",
|
|
19
|
-
"version",
|
|
20
|
-
"tokenBalances",
|
|
21
|
-
]
|
|
7
|
+
// Ordered transaction field names, the field codes shared with the Rust store
|
|
8
|
+
// (`SvmTxField`). Derived from the typed field list so the two can't drift;
|
|
9
|
+
// `Internal.allSvmTransactionFields` is pinned to the Rust ordinal order by a test.
|
|
10
|
+
let transactionFields =
|
|
11
|
+
Internal.allSvmTransactionFields->(
|
|
12
|
+
Utils.magic: array<Internal.svmTransactionField> => array<string>
|
|
13
|
+
)
|
|
22
14
|
|
|
23
15
|
// One instruction's selected transaction fields → store selection bitmask.
|
|
24
16
|
// Computed per event at config build and cached on the event config.
|
package/src/sources/Svm.res.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import * as Rpc from "./Rpc.res.mjs";
|
|
|
4
4
|
import * as Rest from "../vendored/Rest.res.mjs";
|
|
5
5
|
import * as Utils from "../Utils.res.mjs";
|
|
6
6
|
import * as Logging from "../Logging.res.mjs";
|
|
7
|
+
import * as Internal from "../Internal.res.mjs";
|
|
7
8
|
import * as Prometheus from "../Prometheus.res.mjs";
|
|
8
9
|
import * as Performance from "../bindings/Performance.res.mjs";
|
|
9
10
|
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
@@ -16,21 +17,7 @@ let cleanUpRawEventFieldsInPlace = (fields => {
|
|
|
16
17
|
delete fields.time
|
|
17
18
|
});
|
|
18
19
|
|
|
19
|
-
let
|
|
20
|
-
"transactionIndex",
|
|
21
|
-
"signatures",
|
|
22
|
-
"feePayer",
|
|
23
|
-
"success",
|
|
24
|
-
"err",
|
|
25
|
-
"fee",
|
|
26
|
-
"computeUnitsConsumed",
|
|
27
|
-
"accountKeys",
|
|
28
|
-
"recentBlockhash",
|
|
29
|
-
"version",
|
|
30
|
-
"tokenBalances"
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
let eventTransactionFieldMask = TransactionStore.makeMaskFn(transactionFields);
|
|
20
|
+
let eventTransactionFieldMask = TransactionStore.makeMaskFn(Internal.allSvmTransactionFields);
|
|
34
21
|
|
|
35
22
|
function make(logger) {
|
|
36
23
|
return {
|
|
@@ -93,6 +80,8 @@ function makeRPCSource(chain, rpc, sourceForOpt) {
|
|
|
93
80
|
};
|
|
94
81
|
}
|
|
95
82
|
|
|
83
|
+
let transactionFields = Internal.allSvmTransactionFields;
|
|
84
|
+
|
|
96
85
|
export {
|
|
97
86
|
cleanUpRawEventFieldsInPlace,
|
|
98
87
|
transactionFields,
|
|
@@ -6,8 +6,20 @@
|
|
|
6
6
|
// in columnar form and zipped into plain JS objects on the main thread.
|
|
7
7
|
type t
|
|
8
8
|
|
|
9
|
-
@send external
|
|
10
|
-
|
|
9
|
+
@send external newEvm: (Core.transactionStoreCtor, ~shouldChecksum: bool) => t = "newEvm"
|
|
10
|
+
@send external newSvm: Core.transactionStoreCtor => t = "newSvm"
|
|
11
|
+
@send external newFuel: Core.transactionStoreCtor => t = "newFuel"
|
|
12
|
+
|
|
13
|
+
// The store's ecosystem is fixed here, from the chain's config. EVM carries the
|
|
14
|
+
// chain's address-checksumming setting; SVM/Fuel need no extra data.
|
|
15
|
+
let make = (~ecosystem: Ecosystem.name, ~shouldChecksum: bool): t => {
|
|
16
|
+
let ctor = Core.getAddon().transactionStore
|
|
17
|
+
switch ecosystem {
|
|
18
|
+
| Evm => ctor->newEvm(~shouldChecksum)
|
|
19
|
+
| Svm => ctor->newSvm
|
|
20
|
+
| Fuel => ctor->newFuel
|
|
21
|
+
}
|
|
22
|
+
}
|
|
11
23
|
|
|
12
24
|
// Field-name → bit-index map from an ordered field-name array. The index is the
|
|
13
25
|
// field code shared with the Rust store (`EvmTxField`/`SvmTxField`).
|
|
@@ -3,8 +3,16 @@
|
|
|
3
3
|
import * as Core from "../Core.res.mjs";
|
|
4
4
|
import * as Utils from "../Utils.res.mjs";
|
|
5
5
|
|
|
6
|
-
function make() {
|
|
7
|
-
|
|
6
|
+
function make(ecosystem, shouldChecksum) {
|
|
7
|
+
let ctor = Core.getAddon().TransactionStore;
|
|
8
|
+
switch (ecosystem) {
|
|
9
|
+
case "evm" :
|
|
10
|
+
return ctor.newEvm(shouldChecksum);
|
|
11
|
+
case "fuel" :
|
|
12
|
+
return ctor.newFuel();
|
|
13
|
+
case "svm" :
|
|
14
|
+
return ctor.newSvm();
|
|
15
|
+
}
|
|
8
16
|
}
|
|
9
17
|
|
|
10
18
|
function fieldCodes(fields) {
|