envio 3.0.0-alpha.21 → 3.0.0-alpha.23
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 +3 -3
- 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 +430 -51
- package/src/Main.res.mjs +530 -271
- package/src/Persistence.res +80 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +294 -167
- package/src/PgStorage.res.mjs +799 -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 +16 -16
- package/src/TestIndexerProxyStorage.res.mjs +99 -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 +7 -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,5 +1,3 @@
|
|
|
1
|
-
open Belt
|
|
2
|
-
|
|
3
1
|
exception EventDuplicate
|
|
4
2
|
exception WildcardCollision
|
|
5
3
|
|
|
@@ -11,21 +9,21 @@ module Group = {
|
|
|
11
9
|
|
|
12
10
|
let empty = () => {
|
|
13
11
|
wildcard: None,
|
|
14
|
-
byContractName:
|
|
12
|
+
byContractName: Dict.make(),
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
let addOrThrow = (group: t<'a>, event, ~contractName, ~isWildcard) => {
|
|
18
16
|
let {byContractName, wildcard} = group
|
|
19
17
|
switch byContractName->Utils.Dict.dangerouslyGetNonOption(contractName) {
|
|
20
|
-
| Some(_) =>
|
|
18
|
+
| Some(_) => throw(EventDuplicate)
|
|
21
19
|
| None =>
|
|
22
20
|
if isWildcard && wildcard->Option.isSome {
|
|
23
|
-
|
|
21
|
+
throw(WildcardCollision)
|
|
24
22
|
} else {
|
|
25
23
|
if isWildcard {
|
|
26
24
|
group.wildcard = Some(event)
|
|
27
25
|
}
|
|
28
|
-
byContractName->
|
|
26
|
+
byContractName->Dict.set(contractName, event)
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
}
|
|
@@ -34,16 +32,23 @@ module Group = {
|
|
|
34
32
|
group: t<'a>,
|
|
35
33
|
~contractAddress,
|
|
36
34
|
~blockNumber,
|
|
37
|
-
~
|
|
35
|
+
~indexingAddresses: dict<FetchState.indexingAddress>,
|
|
38
36
|
) =>
|
|
39
37
|
switch group {
|
|
40
38
|
| {wildcard, byContractName} =>
|
|
41
|
-
switch
|
|
39
|
+
switch indexingAddresses->Utils.Dict.dangerouslyGetNonOption(
|
|
42
40
|
contractAddress->Address.toString,
|
|
43
41
|
) {
|
|
44
42
|
| Some(indexingContract) =>
|
|
45
|
-
if indexingContract.
|
|
46
|
-
byContractName->Utils.Dict.dangerouslyGetNonOption(indexingContract.contractName)
|
|
43
|
+
if indexingContract.effectiveStartBlock <= blockNumber {
|
|
44
|
+
switch byContractName->Utils.Dict.dangerouslyGetNonOption(indexingContract.contractName) {
|
|
45
|
+
// Fall back to the wildcard handler when the indexed contract has no
|
|
46
|
+
// matching event for this tag. This covers addresses registered for
|
|
47
|
+
// contracts without events (persisted for future config changes) as
|
|
48
|
+
// well as addresses whose contract has other events but not this one.
|
|
49
|
+
| None => wildcard
|
|
50
|
+
| Some(_) as event => event
|
|
51
|
+
}
|
|
47
52
|
} else {
|
|
48
53
|
None
|
|
49
54
|
}
|
|
@@ -54,7 +59,7 @@ module Group = {
|
|
|
54
59
|
|
|
55
60
|
type t<'a> = dict<Group.t<'a>>
|
|
56
61
|
|
|
57
|
-
let empty = () =>
|
|
62
|
+
let empty = () => Dict.make()
|
|
58
63
|
|
|
59
64
|
let addOrThrow = (
|
|
60
65
|
router: t<'a>,
|
|
@@ -68,26 +73,26 @@ let addOrThrow = (
|
|
|
68
73
|
let group = switch router->Utils.Dict.dangerouslyGetNonOption(eventId) {
|
|
69
74
|
| None =>
|
|
70
75
|
let group = Group.empty()
|
|
71
|
-
router->
|
|
76
|
+
router->Dict.set(eventId, group)
|
|
72
77
|
group
|
|
73
78
|
| Some(group) => group
|
|
74
79
|
}
|
|
75
80
|
try group->Group.addOrThrow(event, ~contractName, ~isWildcard) catch {
|
|
76
81
|
| EventDuplicate =>
|
|
77
|
-
|
|
82
|
+
JsError.throwWithMessage(
|
|
78
83
|
`Duplicate event detected: ${eventName} for contract ${contractName} on chain ${chain->ChainMap.Chain.toString}`,
|
|
79
84
|
)
|
|
80
85
|
| WildcardCollision =>
|
|
81
|
-
|
|
86
|
+
JsError.throwWithMessage(
|
|
82
87
|
`Another event is already registered with the same signature that would interfer with wildcard filtering: ${eventName} for contract ${contractName} on chain ${chain->ChainMap.Chain.toString}`,
|
|
83
88
|
)
|
|
84
89
|
}
|
|
85
90
|
}
|
|
86
91
|
|
|
87
|
-
let get = (router: t<'a>, ~tag, ~contractAddress, ~blockNumber, ~
|
|
92
|
+
let get = (router: t<'a>, ~tag, ~contractAddress, ~blockNumber, ~indexingAddresses) => {
|
|
88
93
|
switch router->Utils.Dict.dangerouslyGetNonOption(tag) {
|
|
89
94
|
| None => None
|
|
90
|
-
| Some(group) => group->Group.get(~contractAddress, ~blockNumber, ~
|
|
95
|
+
| Some(group) => group->Group.get(~contractAddress, ~blockNumber, ~indexingAddresses)
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
98
|
|
|
@@ -1,61 +1,63 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
4
3
|
import * as ChainMap from "../ChainMap.res.mjs";
|
|
5
|
-
import * as Belt_Array from "rescript/lib/es6/
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
9
|
-
import * as
|
|
4
|
+
import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.js";
|
|
5
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
|
+
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
7
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
8
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
let EventDuplicate = /* @__PURE__ */Primitive_exceptions.create("EventRouter.EventDuplicate");
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
let WildcardCollision = /* @__PURE__ */Primitive_exceptions.create("EventRouter.WildcardCollision");
|
|
14
13
|
|
|
15
14
|
function empty() {
|
|
16
15
|
return {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
wildcard: undefined,
|
|
17
|
+
byContractName: {}
|
|
18
|
+
};
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
function addOrThrow(group,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
function addOrThrow(group, event, contractName, isWildcard) {
|
|
22
|
+
let wildcard = group.wildcard;
|
|
23
|
+
let byContractName = group.byContractName;
|
|
24
|
+
let match = byContractName[contractName];
|
|
26
25
|
if (match !== undefined) {
|
|
27
26
|
throw {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
RE_EXN_ID: EventDuplicate,
|
|
28
|
+
Error: new Error()
|
|
29
|
+
};
|
|
31
30
|
}
|
|
32
|
-
if (isWildcard &&
|
|
31
|
+
if (isWildcard && Stdlib_Option.isSome(wildcard)) {
|
|
33
32
|
throw {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
RE_EXN_ID: WildcardCollision,
|
|
34
|
+
Error: new Error()
|
|
35
|
+
};
|
|
37
36
|
}
|
|
38
37
|
if (isWildcard) {
|
|
39
|
-
group.wildcard =
|
|
38
|
+
group.wildcard = Primitive_option.some(event);
|
|
40
39
|
}
|
|
41
|
-
byContractName[contractName] =
|
|
40
|
+
byContractName[contractName] = event;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
function get(group, contractAddress, blockNumber,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (indexingContract
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
function get(group, contractAddress, blockNumber, indexingAddresses) {
|
|
44
|
+
let wildcard = group.wildcard;
|
|
45
|
+
let indexingContract = indexingAddresses[contractAddress];
|
|
46
|
+
if (indexingContract === undefined) {
|
|
47
|
+
return wildcard;
|
|
48
|
+
}
|
|
49
|
+
if (indexingContract.effectiveStartBlock > blockNumber) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
let event = group.byContractName[indexingContract.contractName];
|
|
53
|
+
if (event !== undefined) {
|
|
54
|
+
return event;
|
|
53
55
|
} else {
|
|
54
56
|
return wildcard;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
let Group = {
|
|
59
61
|
empty: empty,
|
|
60
62
|
addOrThrow: addOrThrow,
|
|
61
63
|
get: get
|
|
@@ -65,13 +67,13 @@ function empty$1() {
|
|
|
65
67
|
return {};
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
function addOrThrow$1(router, eventId,
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
function addOrThrow$1(router, eventId, event, contractName, isWildcard, eventName, chain) {
|
|
71
|
+
let group = router[eventId];
|
|
72
|
+
let group$1;
|
|
71
73
|
if (group !== undefined) {
|
|
72
74
|
group$1 = group;
|
|
73
75
|
} else {
|
|
74
|
-
|
|
76
|
+
let group$2 = {
|
|
75
77
|
wildcard: undefined,
|
|
76
78
|
byContractName: {}
|
|
77
79
|
};
|
|
@@ -79,26 +81,24 @@ function addOrThrow$1(router, eventId, $$event, contractName, isWildcard, eventN
|
|
|
79
81
|
group$1 = group$2;
|
|
80
82
|
}
|
|
81
83
|
try {
|
|
82
|
-
return addOrThrow(group$1,
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
|
|
84
|
+
return addOrThrow(group$1, event, contractName, isWildcard);
|
|
85
|
+
} catch (raw_exn) {
|
|
86
|
+
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
86
87
|
if (exn.RE_EXN_ID === EventDuplicate) {
|
|
87
|
-
return
|
|
88
|
+
return Stdlib_JsError.throwWithMessage(`Duplicate event detected: ` + eventName + ` for contract ` + contractName + ` on chain ` + ChainMap.Chain.toString(chain));
|
|
88
89
|
}
|
|
89
90
|
if (exn.RE_EXN_ID === WildcardCollision) {
|
|
90
|
-
return
|
|
91
|
+
return Stdlib_JsError.throwWithMessage(`Another event is already registered with the same signature that would interfer with wildcard filtering: ` + eventName + ` for contract ` + contractName + ` on chain ` + ChainMap.Chain.toString(chain));
|
|
91
92
|
}
|
|
92
93
|
throw exn;
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
function get$1(router, tag, contractAddress, blockNumber,
|
|
97
|
-
|
|
97
|
+
function get$1(router, tag, contractAddress, blockNumber, indexingAddresses) {
|
|
98
|
+
let group = router[tag];
|
|
98
99
|
if (group !== undefined) {
|
|
99
|
-
return get(group, contractAddress, blockNumber,
|
|
100
|
+
return get(group, contractAddress, blockNumber, indexingAddresses);
|
|
100
101
|
}
|
|
101
|
-
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
function getEvmEventId(sighash, topicCount) {
|
|
@@ -106,21 +106,19 @@ function getEvmEventId(sighash, topicCount) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
function fromEvmEventModsOrThrow(events, chain) {
|
|
109
|
-
|
|
110
|
-
Belt_Array.forEach(events, (
|
|
111
|
-
addOrThrow$1(router, config.id, config, config.contractName, config.isWildcard, config.name, chain);
|
|
112
|
-
}));
|
|
109
|
+
let router = {};
|
|
110
|
+
Belt_Array.forEach(events, config => addOrThrow$1(router, config.id, config, config.contractName, config.isWildcard, config.name, chain));
|
|
113
111
|
return router;
|
|
114
112
|
}
|
|
115
113
|
|
|
116
114
|
export {
|
|
117
|
-
EventDuplicate
|
|
118
|
-
WildcardCollision
|
|
119
|
-
Group
|
|
115
|
+
EventDuplicate,
|
|
116
|
+
WildcardCollision,
|
|
117
|
+
Group,
|
|
120
118
|
empty$1 as empty,
|
|
121
119
|
addOrThrow$1 as addOrThrow,
|
|
122
120
|
get$1 as get,
|
|
123
|
-
getEvmEventId
|
|
124
|
-
fromEvmEventModsOrThrow
|
|
121
|
+
getEvmEventId,
|
|
122
|
+
fromEvmEventModsOrThrow,
|
|
125
123
|
}
|
|
126
124
|
/* ChainMap Not a pure module */
|
package/src/sources/Evm.res
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@get external getTimestamp: Internal.eventBlock => int = "timestamp"
|
|
3
3
|
@get external getId: Internal.eventBlock => string = "hash"
|
|
4
4
|
|
|
5
|
-
let cleanUpRawEventFieldsInPlace:
|
|
5
|
+
let cleanUpRawEventFieldsInPlace: JSON.t => unit = %raw(`fields => {
|
|
6
6
|
delete fields.hash
|
|
7
7
|
delete fields.number
|
|
8
8
|
delete fields.timestamp
|
|
@@ -81,4 +81,20 @@ let ecosystem: Ecosystem.t = {
|
|
|
81
81
|
getTimestamp,
|
|
82
82
|
getId,
|
|
83
83
|
cleanUpRawEventFieldsInPlace,
|
|
84
|
+
onBlockMethodName: "onBlock",
|
|
85
|
+
// EVM filter shape: `{block: {number: {_gte?, _lte?, _every?}}}`.
|
|
86
|
+
// The inner range chunk is returned as raw `S.unknown` and parsed a
|
|
87
|
+
// second time in `Main.res` by the shared `blockRangeSchema`.
|
|
88
|
+
onBlockFilterSchema: S.object(s =>
|
|
89
|
+
s.field("block", S.option(S.object(s2 => s2.field("number", S.unknown))))
|
|
90
|
+
),
|
|
91
|
+
// EVM event filter shape: `{block: {number: {_gte?}}, params?, ...}`.
|
|
92
|
+
// Only the `block.number` wrapper is unwrapped here; sibling fields
|
|
93
|
+
// like `params` are left for `LogSelection` to consume. The inner
|
|
94
|
+
// range chunk is validated by `eventBlockRangeSchema` in
|
|
95
|
+
// `LogSelection.res` which rejects `_lte`/`_every` (use `onBlock` for
|
|
96
|
+
// stride- and endBlock-based block handlers).
|
|
97
|
+
onEventBlockFilterSchema: S.object(s =>
|
|
98
|
+
s.field("block", S.option(S.object(s2 => s2.field("number", S.unknown))))
|
|
99
|
+
),
|
|
84
100
|
}
|
package/src/sources/Evm.res.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
let cleanUpRawEventFieldsInPlace = (fields => {
|
|
5
6
|
delete fields.hash
|
|
6
7
|
delete fields.number
|
|
7
8
|
delete fields.timestamp
|
|
8
9
|
});
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
let ecosystem_blockFields = [
|
|
11
12
|
"number",
|
|
12
13
|
"timestamp",
|
|
13
14
|
"hash",
|
|
@@ -37,7 +38,7 @@ var ecosystem_blockFields = [
|
|
|
37
38
|
"mixHash"
|
|
38
39
|
];
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
let ecosystem_transactionFields = [
|
|
41
42
|
"transactionIndex",
|
|
42
43
|
"hash",
|
|
43
44
|
"from",
|
|
@@ -85,7 +86,11 @@ function ecosystem_getId(prim) {
|
|
|
85
86
|
return prim.hash;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
let ecosystem_onBlockFilterSchema = S$RescriptSchema.object(s => s.f("block", S$RescriptSchema.option(S$RescriptSchema.object(s2 => s2.f("number", S$RescriptSchema.unknown)))));
|
|
90
|
+
|
|
91
|
+
let ecosystem_onEventBlockFilterSchema = S$RescriptSchema.object(s => s.f("block", S$RescriptSchema.option(S$RescriptSchema.object(s2 => s2.f("number", S$RescriptSchema.unknown)))));
|
|
92
|
+
|
|
93
|
+
let ecosystem = {
|
|
89
94
|
name: "evm",
|
|
90
95
|
blockFields: ecosystem_blockFields,
|
|
91
96
|
transactionFields: ecosystem_transactionFields,
|
|
@@ -95,11 +100,14 @@ var ecosystem = {
|
|
|
95
100
|
getNumber: ecosystem_getNumber,
|
|
96
101
|
getTimestamp: ecosystem_getTimestamp,
|
|
97
102
|
getId: ecosystem_getId,
|
|
98
|
-
cleanUpRawEventFieldsInPlace: cleanUpRawEventFieldsInPlace
|
|
103
|
+
cleanUpRawEventFieldsInPlace: cleanUpRawEventFieldsInPlace,
|
|
104
|
+
onBlockMethodName: "onBlock",
|
|
105
|
+
onBlockFilterSchema: ecosystem_onBlockFilterSchema,
|
|
106
|
+
onEventBlockFilterSchema: ecosystem_onEventBlockFilterSchema
|
|
99
107
|
};
|
|
100
108
|
|
|
101
109
|
export {
|
|
102
|
-
cleanUpRawEventFieldsInPlace
|
|
103
|
-
ecosystem
|
|
110
|
+
cleanUpRawEventFieldsInPlace,
|
|
111
|
+
ecosystem,
|
|
104
112
|
}
|
|
105
|
-
/*
|
|
113
|
+
/* ecosystem Not a pure module */
|
package/src/sources/EvmChain.res
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
open Belt
|
|
2
|
-
|
|
3
1
|
type rpc = {
|
|
4
2
|
url: string,
|
|
5
3
|
sourceFor: Source.sourceFor,
|
|
@@ -19,30 +17,30 @@ let getSyncConfig = (
|
|
|
19
17
|
?pollingInterval,
|
|
20
18
|
}: Config.sourceSyncOptions,
|
|
21
19
|
): Config.sourceSync => {
|
|
22
|
-
let queryTimeoutMillis = queryTimeoutMillis->Option.
|
|
20
|
+
let queryTimeoutMillis = queryTimeoutMillis->Option.getOr(20_000)
|
|
23
21
|
{
|
|
24
|
-
initialBlockInterval: Env.Configurable.SyncConfig.initialBlockInterval->Option.
|
|
25
|
-
initialBlockInterval->Option.
|
|
22
|
+
initialBlockInterval: Env.Configurable.SyncConfig.initialBlockInterval->Option.getOr(
|
|
23
|
+
initialBlockInterval->Option.getOr(10_000),
|
|
26
24
|
),
|
|
27
25
|
// After an RPC error, how much to scale back the number of blocks requested at once
|
|
28
|
-
backoffMultiplicative: Env.Configurable.SyncConfig.backoffMultiplicative->Option.
|
|
29
|
-
backoffMultiplicative->Option.
|
|
26
|
+
backoffMultiplicative: Env.Configurable.SyncConfig.backoffMultiplicative->Option.getOr(
|
|
27
|
+
backoffMultiplicative->Option.getOr(0.8),
|
|
30
28
|
),
|
|
31
29
|
// Without RPC errors or timeouts, how much to increase the number of blocks requested by for the next batch
|
|
32
|
-
accelerationAdditive: Env.Configurable.SyncConfig.accelerationAdditive->Option.
|
|
33
|
-
accelerationAdditive->Option.
|
|
30
|
+
accelerationAdditive: Env.Configurable.SyncConfig.accelerationAdditive->Option.getOr(
|
|
31
|
+
accelerationAdditive->Option.getOr(500),
|
|
34
32
|
),
|
|
35
33
|
// Do not further increase the block interval past this limit
|
|
36
|
-
intervalCeiling: Env.Configurable.SyncConfig.intervalCeiling->Option.
|
|
37
|
-
intervalCeiling->Option.
|
|
34
|
+
intervalCeiling: Env.Configurable.SyncConfig.intervalCeiling->Option.getOr(
|
|
35
|
+
intervalCeiling->Option.getOr(10_000),
|
|
38
36
|
),
|
|
39
37
|
// After an error, how long to wait before retrying
|
|
40
|
-
backoffMillis: backoffMillis->Option.
|
|
38
|
+
backoffMillis: backoffMillis->Option.getOr(5000),
|
|
41
39
|
// How long to wait before cancelling an RPC request
|
|
42
40
|
queryTimeoutMillis,
|
|
43
|
-
fallbackStallTimeout: fallbackStallTimeout->Option.
|
|
41
|
+
fallbackStallTimeout: fallbackStallTimeout->Option.getOr(queryTimeoutMillis / 2),
|
|
44
42
|
// How frequently to check for new blocks in realtime (default: 1000ms)
|
|
45
|
-
pollingInterval: pollingInterval->Option.
|
|
43
|
+
pollingInterval: pollingInterval->Option.getOr(1000),
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -76,18 +74,18 @@ let makeSources = (
|
|
|
76
74
|
]
|
|
77
75
|
| _ => []
|
|
78
76
|
}
|
|
79
|
-
rpcs->
|
|
77
|
+
rpcs->Array.forEach(({?syncConfig, url, sourceFor, ?ws}) => {
|
|
80
78
|
let source = RpcSource.make({
|
|
81
79
|
chain,
|
|
82
80
|
sourceFor,
|
|
83
|
-
syncConfig: getSyncConfig(syncConfig->Option.
|
|
81
|
+
syncConfig: getSyncConfig(syncConfig->Option.getOr({})),
|
|
84
82
|
url,
|
|
85
83
|
eventRouter,
|
|
86
84
|
allEventSignatures,
|
|
87
85
|
lowercaseAddresses,
|
|
88
86
|
?ws,
|
|
89
87
|
})
|
|
90
|
-
let _ = sources->
|
|
88
|
+
let _ = sources->Array.push(source)
|
|
91
89
|
})
|
|
92
90
|
|
|
93
91
|
sources
|
|
@@ -2,59 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Env from "../Env.res.mjs";
|
|
4
4
|
import * as RpcSource from "./RpcSource.res.mjs";
|
|
5
|
-
import * as Belt_Array from "rescript/lib/es6/
|
|
6
|
-
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
5
|
+
import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.js";
|
|
7
6
|
import * as EventRouter from "./EventRouter.res.mjs";
|
|
7
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
8
8
|
import * as HyperSyncSource from "./HyperSyncSource.res.mjs";
|
|
9
9
|
|
|
10
10
|
function getSyncConfig(param) {
|
|
11
|
-
|
|
11
|
+
let queryTimeoutMillis = Stdlib_Option.getOr(param.queryTimeoutMillis, 20000);
|
|
12
12
|
return {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
initialBlockInterval: Stdlib_Option.getOr(Env.Configurable.SyncConfig.initialBlockInterval, Stdlib_Option.getOr(param.initialBlockInterval, 10000)),
|
|
14
|
+
backoffMultiplicative: Stdlib_Option.getOr(Env.Configurable.SyncConfig.backoffMultiplicative, Stdlib_Option.getOr(param.backoffMultiplicative, 0.8)),
|
|
15
|
+
accelerationAdditive: Stdlib_Option.getOr(Env.Configurable.SyncConfig.accelerationAdditive, Stdlib_Option.getOr(param.accelerationAdditive, 500)),
|
|
16
|
+
intervalCeiling: Stdlib_Option.getOr(Env.Configurable.SyncConfig.intervalCeiling, Stdlib_Option.getOr(param.intervalCeiling, 10000)),
|
|
17
|
+
backoffMillis: Stdlib_Option.getOr(param.backoffMillis, 5000),
|
|
18
|
+
queryTimeoutMillis: queryTimeoutMillis,
|
|
19
|
+
fallbackStallTimeout: Stdlib_Option.getOr(param.fallbackStallTimeout, queryTimeoutMillis / 2 | 0),
|
|
20
|
+
pollingInterval: Stdlib_Option.getOr(param.pollingInterval, 1000)
|
|
21
|
+
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function makeSources(chain, contracts, hyperSync, allEventSignatures, rpcs, lowercaseAddresses) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
sources.push(source);
|
|
52
|
-
});
|
|
25
|
+
let eventRouter = EventRouter.fromEvmEventModsOrThrow(Belt_Array.flatMap(contracts, contract => contract.events), chain);
|
|
26
|
+
let sources = hyperSync !== undefined ? [HyperSyncSource.make({
|
|
27
|
+
chain: chain,
|
|
28
|
+
endpointUrl: hyperSync,
|
|
29
|
+
allEventSignatures: allEventSignatures,
|
|
30
|
+
eventRouter: eventRouter,
|
|
31
|
+
apiToken: Env.envioApiToken,
|
|
32
|
+
clientMaxRetries: Env.hyperSyncClientMaxRetries,
|
|
33
|
+
clientTimeoutMillis: Env.hyperSyncClientTimeoutMillis,
|
|
34
|
+
lowercaseAddresses: lowercaseAddresses,
|
|
35
|
+
serializationFormat: Env.hypersyncClientSerializationFormat,
|
|
36
|
+
enableQueryCaching: Env.hypersyncClientEnableQueryCaching
|
|
37
|
+
})] : [];
|
|
38
|
+
rpcs.forEach(param => {
|
|
39
|
+
let source = RpcSource.make({
|
|
40
|
+
sourceFor: param.sourceFor,
|
|
41
|
+
syncConfig: getSyncConfig(Stdlib_Option.getOr(param.syncConfig, {})),
|
|
42
|
+
url: param.url,
|
|
43
|
+
chain: chain,
|
|
44
|
+
eventRouter: eventRouter,
|
|
45
|
+
allEventSignatures: allEventSignatures,
|
|
46
|
+
lowercaseAddresses: lowercaseAddresses,
|
|
47
|
+
ws: param.ws
|
|
48
|
+
});
|
|
49
|
+
sources.push(source);
|
|
50
|
+
});
|
|
53
51
|
return sources;
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
export {
|
|
57
|
-
getSyncConfig
|
|
58
|
-
makeSources
|
|
55
|
+
getSyncConfig,
|
|
56
|
+
makeSources,
|
|
59
57
|
}
|
|
60
58
|
/* Env Not a pure module */
|
package/src/sources/Fuel.res
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@get external getTimestamp: Internal.eventBlock => int = "time"
|
|
3
3
|
@get external getId: Internal.eventBlock => string = "id"
|
|
4
4
|
|
|
5
|
-
let cleanUpRawEventFieldsInPlace:
|
|
5
|
+
let cleanUpRawEventFieldsInPlace: JSON.t => unit = %raw(`fields => {
|
|
6
6
|
delete fields.id
|
|
7
7
|
delete fields.height
|
|
8
8
|
delete fields.time
|
|
@@ -19,4 +19,17 @@ let ecosystem: Ecosystem.t = {
|
|
|
19
19
|
getTimestamp,
|
|
20
20
|
getId,
|
|
21
21
|
cleanUpRawEventFieldsInPlace,
|
|
22
|
+
onBlockMethodName: "onBlock",
|
|
23
|
+
// Fuel filter shape: `{block: {height: {_gte?, _lte?, _every?}}}`.
|
|
24
|
+
// Inner range chunk parsed by `blockRangeSchema` in `Main.res`.
|
|
25
|
+
onBlockFilterSchema: S.object(s =>
|
|
26
|
+
s.field("block", S.option(S.object(s2 => s2.field("height", S.unknown))))
|
|
27
|
+
),
|
|
28
|
+
// Fuel event filter shape: `{block: {height: {_gte?}}, params?, ...}`.
|
|
29
|
+
// Analogous to EVM, but keyed by `block.height` instead of
|
|
30
|
+
// `block.number`. See `Evm.res` for the rationale on the two-stage
|
|
31
|
+
// parse and the `_lte`/`_every` rejection.
|
|
32
|
+
onEventBlockFilterSchema: S.object(s =>
|
|
33
|
+
s.field("block", S.option(S.object(s2 => s2.field("height", S.unknown))))
|
|
34
|
+
),
|
|
22
35
|
}
|
package/src/sources/Fuel.res.mjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
let cleanUpRawEventFieldsInPlace = (fields => {
|
|
5
6
|
delete fields.id
|
|
6
7
|
delete fields.height
|
|
7
8
|
delete fields.time
|
|
8
9
|
});
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
let ecosystem_blockFields = [
|
|
11
12
|
"id",
|
|
12
13
|
"height",
|
|
13
14
|
"time"
|
|
14
15
|
];
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
let ecosystem_transactionFields = ["id"];
|
|
17
18
|
|
|
18
19
|
function ecosystem_getNumber(prim) {
|
|
19
20
|
return prim.height;
|
|
@@ -27,7 +28,11 @@ function ecosystem_getId(prim) {
|
|
|
27
28
|
return prim.id;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
let ecosystem_onBlockFilterSchema = S$RescriptSchema.object(s => s.f("block", S$RescriptSchema.option(S$RescriptSchema.object(s2 => s2.f("height", S$RescriptSchema.unknown)))));
|
|
32
|
+
|
|
33
|
+
let ecosystem_onEventBlockFilterSchema = S$RescriptSchema.object(s => s.f("block", S$RescriptSchema.option(S$RescriptSchema.object(s2 => s2.f("height", S$RescriptSchema.unknown)))));
|
|
34
|
+
|
|
35
|
+
let ecosystem = {
|
|
31
36
|
name: "fuel",
|
|
32
37
|
blockFields: ecosystem_blockFields,
|
|
33
38
|
transactionFields: ecosystem_transactionFields,
|
|
@@ -37,11 +42,14 @@ var ecosystem = {
|
|
|
37
42
|
getNumber: ecosystem_getNumber,
|
|
38
43
|
getTimestamp: ecosystem_getTimestamp,
|
|
39
44
|
getId: ecosystem_getId,
|
|
40
|
-
cleanUpRawEventFieldsInPlace: cleanUpRawEventFieldsInPlace
|
|
45
|
+
cleanUpRawEventFieldsInPlace: cleanUpRawEventFieldsInPlace,
|
|
46
|
+
onBlockMethodName: "onBlock",
|
|
47
|
+
onBlockFilterSchema: ecosystem_onBlockFilterSchema,
|
|
48
|
+
onEventBlockFilterSchema: ecosystem_onEventBlockFilterSchema
|
|
41
49
|
};
|
|
42
50
|
|
|
43
51
|
export {
|
|
44
|
-
cleanUpRawEventFieldsInPlace
|
|
45
|
-
ecosystem
|
|
52
|
+
cleanUpRawEventFieldsInPlace,
|
|
53
|
+
ecosystem,
|
|
46
54
|
}
|
|
47
|
-
/*
|
|
55
|
+
/* ecosystem Not a pure module */
|
package/src/sources/FuelSDK.res
CHANGED
|
@@ -15,7 +15,7 @@ type receiptType =
|
|
|
15
15
|
| @as(12) Burn
|
|
16
16
|
|
|
17
17
|
@module("./vendored-fuel-abi-coder.js")
|
|
18
|
-
external transpileAbi:
|
|
18
|
+
external transpileAbi: JSON.t => EvmTypes.Abi.t = "transpileAbi"
|
|
19
19
|
|
|
20
20
|
@module("./vendored-fuel-abi-coder.js") @scope("AbiCoder")
|
|
21
21
|
external getLogDecoder: (~abi: EvmTypes.Abi.t, ~logId: string) => string => unknown =
|
|
@@ -11,19 +11,17 @@ function getLogDecoder(prim0, prim1) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function getLogDataDecoder(abi, logId) {
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
return decode(data);
|
|
17
|
-
};
|
|
14
|
+
let decode = VendoredFuelAbiCoderJs.AbiCoder.getLogDecoder(abi, logId);
|
|
15
|
+
return data => decode(data);
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
let Receipt = {
|
|
21
19
|
getLogDataDecoder: getLogDataDecoder
|
|
22
20
|
};
|
|
23
21
|
|
|
24
22
|
export {
|
|
25
|
-
transpileAbi
|
|
26
|
-
getLogDecoder
|
|
27
|
-
Receipt
|
|
23
|
+
transpileAbi,
|
|
24
|
+
getLogDecoder,
|
|
25
|
+
Receipt,
|
|
28
26
|
}
|
|
29
27
|
/* ./vendored-fuel-abi-coder.js Not a pure module */
|