envio 3.5.0-alpha.0 → 3.5.0-alpha.2
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/index.d.ts +10 -6
- package/package.json +6 -6
- package/src/BatchProcessing.res +13 -0
- package/src/BatchProcessing.res.mjs +4 -0
- package/src/Bin.res +2 -2
- package/src/ChainFetching.res +5 -5
- package/src/ChainFetching.res.mjs +3 -4
- package/src/ChainState.res +44 -36
- package/src/ChainState.res.mjs +36 -31
- package/src/ChainState.resi +2 -12
- package/src/Change.res +3 -3
- package/src/Config.res +4 -4
- package/src/Config.res.mjs +1 -10
- package/src/Core.res +4 -35
- package/src/Core.res.mjs +1 -31
- package/src/CrossChainState.res +2 -20
- package/src/CrossChainState.res.mjs +2 -6
- package/src/EntityId.res +15 -0
- package/src/EntityId.res.mjs +9 -0
- package/src/Env.res +16 -0
- package/src/Env.res.mjs +6 -0
- package/src/EventConfigBuilder.res +1 -58
- package/src/EventConfigBuilder.res.mjs +1 -33
- package/src/FetchState.res +663 -484
- package/src/FetchState.res.mjs +491 -440
- package/src/HandlerRegister.res +45 -0
- package/src/HandlerRegister.res.mjs +43 -0
- package/src/InMemoryStore.res +11 -4
- package/src/InMemoryTable.res +12 -10
- package/src/InMemoryTable.res.mjs +6 -5
- package/src/IndexerState.res +59 -2
- package/src/IndexerState.res.mjs +48 -3
- package/src/IndexerState.resi +2 -0
- package/src/Internal.res +17 -8
- package/src/LogSelection.res +2 -1
- package/src/Metrics.res +37 -6
- package/src/Metrics.res.mjs +5 -1
- package/src/Persistence.res +1 -1
- package/src/PgStorage.res +55 -22
- package/src/PgStorage.res.mjs +25 -17
- package/src/SimulateItems.res +2 -2
- package/src/TestIndexer.res +6 -5
- package/src/TestIndexer.res.mjs +3 -2
- package/src/UserContext.res +3 -3
- package/src/Writing.res +12 -2
- package/src/Writing.res.mjs +13 -2
- package/src/bindings/ClickHouse.res +5 -3
- package/src/bindings/ClickHouse.res.mjs +2 -5
- package/src/bindings/Vitest.res +22 -1
- package/src/bindings/Vitest.res.mjs +15 -0
- package/src/db/EntityHistory.res +16 -7
- package/src/db/EntityHistory.res.mjs +7 -6
- package/src/db/Table.res +40 -9
- package/src/db/Table.res.mjs +44 -6
- package/src/sources/AddressSet.res +48 -0
- package/src/sources/AddressSet.res.mjs +11 -0
- package/src/sources/AddressStore.res +152 -0
- package/src/sources/AddressStore.res.mjs +97 -0
- package/src/sources/EvmChain.res +3 -0
- package/src/sources/EvmChain.res.mjs +4 -2
- package/src/sources/EvmHyperSyncSource.res +9 -9
- package/src/sources/EvmHyperSyncSource.res.mjs +3 -3
- package/src/sources/EvmRpcClient.res +10 -3
- package/src/sources/EvmRpcClient.res.mjs +3 -3
- package/src/sources/FuelHyperSync.res +4 -3
- package/src/sources/FuelHyperSync.res.mjs +3 -3
- package/src/sources/FuelHyperSync.resi +2 -1
- package/src/sources/FuelHyperSyncClient.res +12 -6
- package/src/sources/FuelHyperSyncClient.res.mjs +2 -2
- package/src/sources/FuelHyperSyncSource.res +7 -4
- package/src/sources/FuelHyperSyncSource.res.mjs +3 -3
- package/src/sources/HyperSync.res +9 -5
- package/src/sources/HyperSync.res.mjs +3 -3
- package/src/sources/HyperSync.resi +3 -2
- package/src/sources/HyperSyncClient.res +24 -10
- package/src/sources/HyperSyncClient.res.mjs +4 -4
- package/src/sources/RpcSource.res +71 -67
- package/src/sources/RpcSource.res.mjs +4 -4
- package/src/sources/SimulateSource.res +26 -11
- package/src/sources/SimulateSource.res.mjs +13 -5
- package/src/sources/Source.res +8 -4
- package/src/sources/SourceManager.res +2 -3
- package/src/sources/SourceManager.res.mjs +2 -3
- package/src/sources/Svm.res +1 -2
- package/src/sources/Svm.res.mjs +1 -1
- package/src/sources/SvmHyperSyncClient.res +14 -4
- package/src/sources/SvmHyperSyncClient.res.mjs +2 -2
- package/src/sources/SvmHyperSyncSource.res +11 -6
- package/src/sources/SvmHyperSyncSource.res.mjs +5 -4
- package/src/IndexingAddresses.res +0 -108
- package/src/IndexingAddresses.res.mjs +0 -101
- package/src/IndexingAddresses.resi +0 -34
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
type indexingAddress = Internal.indexingContract
|
|
2
|
-
|
|
3
|
-
type contractConfig = {startBlock: option<int>}
|
|
4
|
-
|
|
5
|
-
type t = dict<indexingAddress>
|
|
6
|
-
|
|
7
|
-
let deriveEffectiveStartBlock = (~registrationBlock: int, ~contractStartBlock: option<int>) => {
|
|
8
|
-
Pervasives.max(Pervasives.max(registrationBlock, 0), contractStartBlock->Option.getOr(0))
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let makeContractConfigs = (~onEventRegistrations: array<Internal.onEventRegistration>): dict<
|
|
12
|
-
contractConfig,
|
|
13
|
-
> => {
|
|
14
|
-
let contractConfigs: dict<contractConfig> = Dict.make()
|
|
15
|
-
onEventRegistrations->Array.forEach(reg => {
|
|
16
|
-
let contractName = reg.eventConfig.contractName
|
|
17
|
-
switch contractConfigs->Utils.Dict.dangerouslyGetNonOption(contractName) {
|
|
18
|
-
| Some({startBlock}) =>
|
|
19
|
-
contractConfigs->Dict.set(
|
|
20
|
-
contractName,
|
|
21
|
-
{
|
|
22
|
-
startBlock: switch (startBlock, reg.startBlock) {
|
|
23
|
-
| (Some(a), Some(b)) => Some(Pervasives.min(a, b))
|
|
24
|
-
| (Some(_) as s, None) | (None, Some(_) as s) => s
|
|
25
|
-
| (None, None) => None
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
)
|
|
29
|
-
| None =>
|
|
30
|
-
contractConfigs->Dict.set(
|
|
31
|
-
contractName,
|
|
32
|
-
{
|
|
33
|
-
startBlock: reg.startBlock,
|
|
34
|
-
},
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
contractConfigs
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let makeIndexingAddress = (
|
|
42
|
-
~contract: Internal.indexingAddress,
|
|
43
|
-
~contractConfigs: dict<contractConfig>,
|
|
44
|
-
): indexingAddress => {
|
|
45
|
-
let contractStartBlock = switch contractConfigs->Utils.Dict.dangerouslyGetNonOption(
|
|
46
|
-
contract.contractName,
|
|
47
|
-
) {
|
|
48
|
-
| Some({startBlock}) => startBlock
|
|
49
|
-
| None => None
|
|
50
|
-
}
|
|
51
|
-
{
|
|
52
|
-
address: contract.address,
|
|
53
|
-
contractName: contract.contractName,
|
|
54
|
-
registrationBlock: contract.registrationBlock,
|
|
55
|
-
effectiveStartBlock: deriveEffectiveStartBlock(
|
|
56
|
-
~registrationBlock=contract.registrationBlock,
|
|
57
|
-
~contractStartBlock,
|
|
58
|
-
),
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let make = (
|
|
63
|
-
~contractConfigs: dict<contractConfig>,
|
|
64
|
-
~addresses: array<Internal.indexingAddress>,
|
|
65
|
-
): t => {
|
|
66
|
-
let indexingAddresses = Dict.make()
|
|
67
|
-
addresses->Array.forEach(contract => {
|
|
68
|
-
indexingAddresses->Dict.set(
|
|
69
|
-
contract.address->Address.toString,
|
|
70
|
-
makeIndexingAddress(~contract, ~contractConfigs),
|
|
71
|
-
)
|
|
72
|
-
})
|
|
73
|
-
indexingAddresses
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let get = (indexingAddresses: t, address) =>
|
|
77
|
-
indexingAddresses->Utils.Dict.dangerouslyGetNonOption(address)
|
|
78
|
-
|
|
79
|
-
let size = (indexingAddresses: t) => indexingAddresses->Utils.Dict.size
|
|
80
|
-
|
|
81
|
-
let getContractAddresses = (indexingAddresses: t, ~contractName): array<Address.t> => {
|
|
82
|
-
let addresses = []
|
|
83
|
-
indexingAddresses->Utils.Dict.forEach(ia => {
|
|
84
|
-
if ia.contractName === contractName {
|
|
85
|
-
addresses->Array.push(ia.address)
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
addresses
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Underlying dict for the precompiled `clientAddressFilter` only — it does raw
|
|
92
|
-
// `indexingAddresses[srcAddress]` access in generated JS and can't take the opaque
|
|
93
|
-
// type. Don't reach for this elsewhere; use the domain accessors above.
|
|
94
|
-
let rawForFilter = (indexingAddresses: t): dict<indexingAddress> => indexingAddresses
|
|
95
|
-
|
|
96
|
-
let register = (indexingAddresses: t, additions: dict<indexingAddress>) => {
|
|
97
|
-
let _ = Utils.Dict.mergeInPlace(indexingAddresses, additions)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let rollbackInPlace = (indexingAddresses: t, ~targetBlockNumber: int): unit => {
|
|
101
|
-
// forEachWithKey is a `for..in`, so deleting the key currently being visited is
|
|
102
|
-
// safe — it doesn't affect enumeration of the remaining keys.
|
|
103
|
-
indexingAddresses->Utils.Dict.forEachWithKey((indexingContract, address) => {
|
|
104
|
-
if indexingContract.registrationBlock > targetBlockNumber {
|
|
105
|
-
indexingAddresses->Utils.Dict.deleteInPlace(address)
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as Utils from "./Utils.res.mjs";
|
|
4
|
-
import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
|
|
5
|
-
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
|
-
|
|
7
|
-
function deriveEffectiveStartBlock(registrationBlock, contractStartBlock) {
|
|
8
|
-
return Primitive_int.max(Primitive_int.max(registrationBlock, 0), Stdlib_Option.getOr(contractStartBlock, 0));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function makeContractConfigs(onEventRegistrations) {
|
|
12
|
-
let contractConfigs = {};
|
|
13
|
-
onEventRegistrations.forEach(reg => {
|
|
14
|
-
let contractName = reg.eventConfig.contractName;
|
|
15
|
-
let match = contractConfigs[contractName];
|
|
16
|
-
if (match !== undefined) {
|
|
17
|
-
let startBlock = match.startBlock;
|
|
18
|
-
let match$1 = reg.startBlock;
|
|
19
|
-
contractConfigs[contractName] = {
|
|
20
|
-
startBlock: startBlock !== undefined ? (
|
|
21
|
-
match$1 !== undefined ? Primitive_int.min(startBlock, match$1) : startBlock
|
|
22
|
-
) : (
|
|
23
|
-
match$1 !== undefined ? match$1 : undefined
|
|
24
|
-
)
|
|
25
|
-
};
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
contractConfigs[contractName] = {
|
|
29
|
-
startBlock: reg.startBlock
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
return contractConfigs;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function makeIndexingAddress(contract, contractConfigs) {
|
|
36
|
-
let match = contractConfigs[contract.contractName];
|
|
37
|
-
let contractStartBlock = match !== undefined ? match.startBlock : undefined;
|
|
38
|
-
return {
|
|
39
|
-
address: contract.address,
|
|
40
|
-
contractName: contract.contractName,
|
|
41
|
-
registrationBlock: contract.registrationBlock,
|
|
42
|
-
effectiveStartBlock: deriveEffectiveStartBlock(contract.registrationBlock, contractStartBlock)
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function make(contractConfigs, addresses) {
|
|
47
|
-
let indexingAddresses = {};
|
|
48
|
-
addresses.forEach(contract => {
|
|
49
|
-
indexingAddresses[contract.address] = makeIndexingAddress(contract, contractConfigs);
|
|
50
|
-
});
|
|
51
|
-
return indexingAddresses;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function get(indexingAddresses, address) {
|
|
55
|
-
return indexingAddresses[address];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function size(indexingAddresses) {
|
|
59
|
-
return Utils.Dict.size(indexingAddresses);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function getContractAddresses(indexingAddresses, contractName) {
|
|
63
|
-
let addresses = [];
|
|
64
|
-
Utils.Dict.forEach(indexingAddresses, ia => {
|
|
65
|
-
if (ia.contractName === contractName) {
|
|
66
|
-
addresses.push(ia.address);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
return addresses;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function rawForFilter(indexingAddresses) {
|
|
74
|
-
return indexingAddresses;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function register(indexingAddresses, additions) {
|
|
78
|
-
Object.assign(indexingAddresses, additions);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function rollbackInPlace(indexingAddresses, targetBlockNumber) {
|
|
82
|
-
Utils.Dict.forEachWithKey(indexingAddresses, (indexingContract, address) => {
|
|
83
|
-
if (indexingContract.registrationBlock > targetBlockNumber) {
|
|
84
|
-
return Utils.Dict.deleteInPlace(indexingAddresses, address);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export {
|
|
90
|
-
deriveEffectiveStartBlock,
|
|
91
|
-
makeContractConfigs,
|
|
92
|
-
makeIndexingAddress,
|
|
93
|
-
make,
|
|
94
|
-
get,
|
|
95
|
-
size,
|
|
96
|
-
getContractAddresses,
|
|
97
|
-
rawForFilter,
|
|
98
|
-
register,
|
|
99
|
-
rollbackInPlace,
|
|
100
|
-
}
|
|
101
|
-
/* Utils Not a pure module */
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
type indexingAddress = Internal.indexingContract
|
|
2
|
-
|
|
3
|
-
type contractConfig = {startBlock: option<int>}
|
|
4
|
-
|
|
5
|
-
type t
|
|
6
|
-
|
|
7
|
-
let deriveEffectiveStartBlock: (~registrationBlock: int, ~contractStartBlock: option<int>) => int
|
|
8
|
-
|
|
9
|
-
let makeContractConfigs: (
|
|
10
|
-
~onEventRegistrations: array<Internal.onEventRegistration>,
|
|
11
|
-
) => dict<contractConfig>
|
|
12
|
-
|
|
13
|
-
let makeIndexingAddress: (
|
|
14
|
-
~contract: Internal.indexingAddress,
|
|
15
|
-
~contractConfigs: dict<contractConfig>,
|
|
16
|
-
) => indexingAddress
|
|
17
|
-
|
|
18
|
-
let make: (~contractConfigs: dict<contractConfig>, ~addresses: array<Internal.indexingAddress>) => t
|
|
19
|
-
|
|
20
|
-
let get: (t, string) => option<indexingAddress>
|
|
21
|
-
|
|
22
|
-
let size: t => int
|
|
23
|
-
|
|
24
|
-
let getContractAddresses: (t, ~contractName: string) => array<Address.t>
|
|
25
|
-
|
|
26
|
-
// Underlying dict for the precompiled `clientAddressFilter` only, which does raw
|
|
27
|
-
// `indexingAddresses[srcAddress]` access in generated JS. Don't use elsewhere —
|
|
28
|
-
// prefer the domain accessors so the opaque type stays enforced.
|
|
29
|
-
let rawForFilter: t => dict<indexingAddress>
|
|
30
|
-
|
|
31
|
-
let register: (t, dict<indexingAddress>) => unit
|
|
32
|
-
|
|
33
|
-
// Deletes addresses registered after `targetBlockNumber` from the index in place.
|
|
34
|
-
let rollbackInPlace: (t, ~targetBlockNumber: int) => unit
|