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.
Files changed (92) hide show
  1. package/index.d.ts +10 -6
  2. package/package.json +6 -6
  3. package/src/BatchProcessing.res +13 -0
  4. package/src/BatchProcessing.res.mjs +4 -0
  5. package/src/Bin.res +2 -2
  6. package/src/ChainFetching.res +5 -5
  7. package/src/ChainFetching.res.mjs +3 -4
  8. package/src/ChainState.res +44 -36
  9. package/src/ChainState.res.mjs +36 -31
  10. package/src/ChainState.resi +2 -12
  11. package/src/Change.res +3 -3
  12. package/src/Config.res +4 -4
  13. package/src/Config.res.mjs +1 -10
  14. package/src/Core.res +4 -35
  15. package/src/Core.res.mjs +1 -31
  16. package/src/CrossChainState.res +2 -20
  17. package/src/CrossChainState.res.mjs +2 -6
  18. package/src/EntityId.res +15 -0
  19. package/src/EntityId.res.mjs +9 -0
  20. package/src/Env.res +16 -0
  21. package/src/Env.res.mjs +6 -0
  22. package/src/EventConfigBuilder.res +1 -58
  23. package/src/EventConfigBuilder.res.mjs +1 -33
  24. package/src/FetchState.res +663 -484
  25. package/src/FetchState.res.mjs +491 -440
  26. package/src/HandlerRegister.res +45 -0
  27. package/src/HandlerRegister.res.mjs +43 -0
  28. package/src/InMemoryStore.res +11 -4
  29. package/src/InMemoryTable.res +12 -10
  30. package/src/InMemoryTable.res.mjs +6 -5
  31. package/src/IndexerState.res +59 -2
  32. package/src/IndexerState.res.mjs +48 -3
  33. package/src/IndexerState.resi +2 -0
  34. package/src/Internal.res +17 -8
  35. package/src/LogSelection.res +2 -1
  36. package/src/Metrics.res +37 -6
  37. package/src/Metrics.res.mjs +5 -1
  38. package/src/Persistence.res +1 -1
  39. package/src/PgStorage.res +55 -22
  40. package/src/PgStorage.res.mjs +25 -17
  41. package/src/SimulateItems.res +2 -2
  42. package/src/TestIndexer.res +6 -5
  43. package/src/TestIndexer.res.mjs +3 -2
  44. package/src/UserContext.res +3 -3
  45. package/src/Writing.res +12 -2
  46. package/src/Writing.res.mjs +13 -2
  47. package/src/bindings/ClickHouse.res +5 -3
  48. package/src/bindings/ClickHouse.res.mjs +2 -5
  49. package/src/bindings/Vitest.res +22 -1
  50. package/src/bindings/Vitest.res.mjs +15 -0
  51. package/src/db/EntityHistory.res +16 -7
  52. package/src/db/EntityHistory.res.mjs +7 -6
  53. package/src/db/Table.res +40 -9
  54. package/src/db/Table.res.mjs +44 -6
  55. package/src/sources/AddressSet.res +48 -0
  56. package/src/sources/AddressSet.res.mjs +11 -0
  57. package/src/sources/AddressStore.res +152 -0
  58. package/src/sources/AddressStore.res.mjs +97 -0
  59. package/src/sources/EvmChain.res +3 -0
  60. package/src/sources/EvmChain.res.mjs +4 -2
  61. package/src/sources/EvmHyperSyncSource.res +9 -9
  62. package/src/sources/EvmHyperSyncSource.res.mjs +3 -3
  63. package/src/sources/EvmRpcClient.res +10 -3
  64. package/src/sources/EvmRpcClient.res.mjs +3 -3
  65. package/src/sources/FuelHyperSync.res +4 -3
  66. package/src/sources/FuelHyperSync.res.mjs +3 -3
  67. package/src/sources/FuelHyperSync.resi +2 -1
  68. package/src/sources/FuelHyperSyncClient.res +12 -6
  69. package/src/sources/FuelHyperSyncClient.res.mjs +2 -2
  70. package/src/sources/FuelHyperSyncSource.res +7 -4
  71. package/src/sources/FuelHyperSyncSource.res.mjs +3 -3
  72. package/src/sources/HyperSync.res +9 -5
  73. package/src/sources/HyperSync.res.mjs +3 -3
  74. package/src/sources/HyperSync.resi +3 -2
  75. package/src/sources/HyperSyncClient.res +24 -10
  76. package/src/sources/HyperSyncClient.res.mjs +4 -4
  77. package/src/sources/RpcSource.res +71 -67
  78. package/src/sources/RpcSource.res.mjs +4 -4
  79. package/src/sources/SimulateSource.res +26 -11
  80. package/src/sources/SimulateSource.res.mjs +13 -5
  81. package/src/sources/Source.res +8 -4
  82. package/src/sources/SourceManager.res +2 -3
  83. package/src/sources/SourceManager.res.mjs +2 -3
  84. package/src/sources/Svm.res +1 -2
  85. package/src/sources/Svm.res.mjs +1 -1
  86. package/src/sources/SvmHyperSyncClient.res +14 -4
  87. package/src/sources/SvmHyperSyncClient.res.mjs +2 -2
  88. package/src/sources/SvmHyperSyncSource.res +11 -6
  89. package/src/sources/SvmHyperSyncSource.res.mjs +5 -4
  90. package/src/IndexingAddresses.res +0 -108
  91. package/src/IndexingAddresses.res.mjs +0 -101
  92. package/src/IndexingAddresses.resi +0 -34
@@ -1,6 +1,5 @@
1
1
  open Source
2
2
 
3
-
4
3
  // Surfaced by HyperSyncClient.getHeight (Rust) when HyperSync rejects the API
5
4
  // token. The corrupted-token test feeds the real server error through this
6
5
  // check so it can't silently drift away from what getHeightOrThrow guards on.
@@ -17,6 +16,8 @@ type options = {
17
16
  serializationFormat: HyperSyncClient.serializationFormat,
18
17
  enableQueryCaching: bool,
19
18
  logLevel: HyperSyncClient.logLevel,
19
+ // The chain's address index; the client reads it while routing.
20
+ addressStore: AddressStore.t,
20
21
  }
21
22
 
22
23
  let make = (
@@ -30,6 +31,7 @@ let make = (
30
31
  serializationFormat,
31
32
  enableQueryCaching,
32
33
  logLevel,
34
+ addressStore,
33
35
  }: options,
34
36
  ): t => {
35
37
  let name = "HyperSync"
@@ -46,13 +48,12 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
46
48
  ~url=endpointUrl,
47
49
  ~apiToken,
48
50
  ~httpReqTimeoutMillis=clientTimeoutMillis,
49
- ~eventRegistrations=HyperSyncClient.Registration.fromOnEventRegistrations(
50
- onEventRegistrations,
51
- ),
51
+ ~eventRegistrations=HyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations),
52
52
  ~enableChecksumAddresses=!lowercaseAddresses,
53
53
  ~serializationFormat,
54
54
  ~enableQueryCaching,
55
55
  ~logLevel,
56
+ ~addressStore,
56
57
  ) {
57
58
  | client => client
58
59
  | exception exn =>
@@ -89,8 +90,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
89
90
  let getItemsOrThrow = async (
90
91
  ~fromBlock,
91
92
  ~toBlock,
92
- ~addressesByContractName,
93
- ~contractNameByAddress as _,
93
+ ~addressSet,
94
94
  ~knownHeight,
95
95
  ~partitionId as _,
96
96
  ~selection: FetchState.selection,
@@ -109,7 +109,8 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
109
109
  ~toBlock,
110
110
  ~maxNumLogs=itemsTarget,
111
111
  ~registrationIndexes=selection.onEventRegistrations->Array.map(reg => reg.index),
112
- ~addressesByContractName,
112
+ ~addressSet,
113
+ ~clientFilteredContracts=selection.clientFilteredContracts,
113
114
  ) catch {
114
115
  | HyperSync.GetLogs.Error(error) =>
115
116
  throw(
@@ -180,8 +181,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
180
181
  let getBlock = blockNumber => blocksByNumber->Utils.Map.unsafeGet(blockNumber)
181
182
 
182
183
  pageUnsafe.items->Array.forEach(item => {
183
- let onEventRegistration =
184
- onEventRegistrations->Array.getUnsafe(item.onEventRegistrationIndex)
184
+ let onEventRegistration = onEventRegistrations->Array.getUnsafe(item.onEventRegistrationIndex)
185
185
  parsedQueueItems
186
186
  ->Array.push(makeEventBatchQueueItem(item, ~onEventRegistration))
187
187
  ->ignore
@@ -28,7 +28,7 @@ Set the ENVIO_API_TOKEN environment variable in your .env file.
28
28
  Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
29
29
  let client;
30
30
  try {
31
- client = HyperSyncClient.make(endpointUrl, apiToken$1, param.clientTimeoutMillis, HyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations), !param.lowercaseAddresses, param.serializationFormat, param.enableQueryCaching, undefined, undefined, undefined, param.logLevel);
31
+ client = HyperSyncClient.make(endpointUrl, apiToken$1, param.clientTimeoutMillis, HyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations), !param.lowercaseAddresses, param.serializationFormat, param.enableQueryCaching, undefined, undefined, undefined, param.logLevel, param.addressStore);
32
32
  } catch (raw_exn) {
33
33
  let exn = Primitive_exceptions.internalToException(raw_exn);
34
34
  client = ErrorHandling.mkLogAndRaise(undefined, "Failed to instantiate the hypersync client, please double check your ABI", exn);
@@ -52,12 +52,12 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
52
52
  }
53
53
  };
54
54
  };
55
- let getItemsOrThrow = async (fromBlock, toBlock, addressesByContractName, param, knownHeight, param$1, selection, itemsTarget, retry, param$2) => {
55
+ let getItemsOrThrow = async (fromBlock, toBlock, addressSet, knownHeight, param, selection, itemsTarget, retry, param$1) => {
56
56
  let totalTimeRef = Performance.now();
57
57
  let startFetchingBatchTimeRef = Performance.now();
58
58
  let pageUnsafe;
59
59
  try {
60
- pageUnsafe = await HyperSync.GetLogs.query(client, fromBlock, toBlock, itemsTarget, selection.onEventRegistrations.map(reg => reg.index), addressesByContractName);
60
+ pageUnsafe = await HyperSync.GetLogs.query(client, fromBlock, toBlock, itemsTarget, selection.onEventRegistrations.map(reg => reg.index), addressSet, selection.clientFilteredContracts);
61
61
  } catch (raw_error) {
62
62
  let error = Primitive_exceptions.internalToException(raw_error);
63
63
  if (error.RE_EXN_ID === HyperSync.GetLogs.$$Error) {
@@ -26,7 +26,10 @@ type nextPageParams = {
26
26
  // selections and the routing index are derived on the Rust side from the
27
27
  // registrations passed at construction.
28
28
  registrationIndexes: array<int>,
29
- addressesByContractName: dict<array<Address.t>>,
29
+ // Contract names to fetch address-free even though their registrations
30
+ // depend on addresses (client-side filtering). None/empty means
31
+ // every address-dependent contract is filtered server-side.
32
+ clientFilteredContracts: option<array<string>>,
30
33
  }
31
34
 
32
35
  type nextPageResponse = {
@@ -38,7 +41,7 @@ type nextPageResponse = {
38
41
  // The caller provides a range; Rust decides the actual `toBlock` and returns it.
39
42
  type t = {
40
43
  getHeight: unit => promise<int>,
41
- getNextPage: nextPageParams => promise<nextPageResponse>,
44
+ getNextPage: (nextPageParams, AddressSet.t) => promise<nextPageResponse>,
42
45
  }
43
46
 
44
47
  @send
@@ -47,6 +50,7 @@ external classNew: (
47
50
  cfg,
48
51
  array<HyperSyncClient.Registration.input>,
49
52
  ~checksumAddresses: bool,
53
+ ~addressStore: AddressStore.t,
50
54
  ) => t = "new"
51
55
 
52
56
  // Rust encodes JSON-RPC errors as a JSON payload in the napi error's
@@ -85,6 +89,7 @@ let make = (
85
89
  ~httpReqTimeoutMillis=?,
86
90
  ~headers=?,
87
91
  ~eventRegistrations=[],
92
+ ~addressStore,
88
93
  ) => {
89
94
  let client = Core.getAddon().evmRpcClient->classNew(
90
95
  {
@@ -100,9 +105,11 @@ let make = (
100
105
  },
101
106
  eventRegistrations,
102
107
  ~checksumAddresses,
108
+ ~addressStore,
103
109
  )
104
110
  {
105
111
  getHeight: () => client.getHeight()->Promise.catch(coerceErrorOrThrow),
106
- getNextPage: params => client.getNextPage(params)->Promise.catch(coerceErrorOrThrow),
112
+ getNextPage: (params, addressSet) =>
113
+ client.getNextPage(params, addressSet)->Promise.catch(coerceErrorOrThrow),
107
114
  }
108
115
  }
@@ -46,7 +46,7 @@ function coerceErrorOrThrow(exn) {
46
46
  throw exn;
47
47
  }
48
48
 
49
- function make(url, checksumAddresses, syncConfig, httpReqTimeoutMillis, headers, eventRegistrationsOpt) {
49
+ function make(url, checksumAddresses, syncConfig, httpReqTimeoutMillis, headers, eventRegistrationsOpt, addressStore) {
50
50
  let eventRegistrations = eventRegistrationsOpt !== undefined ? eventRegistrationsOpt : [];
51
51
  let client = Core.getAddon().EvmRpcClient.new({
52
52
  url: url,
@@ -58,10 +58,10 @@ function make(url, checksumAddresses, syncConfig, httpReqTimeoutMillis, headers,
58
58
  intervalCeiling: syncConfig.intervalCeiling,
59
59
  backoffMillis: syncConfig.backoffMillis,
60
60
  queryTimeoutMillis: syncConfig.queryTimeoutMillis
61
- }, eventRegistrations, checksumAddresses);
61
+ }, eventRegistrations, checksumAddresses, addressStore);
62
62
  return {
63
63
  getHeight: () => Stdlib_Promise.$$catch(client.getHeight(), coerceErrorOrThrow),
64
- getNextPage: params => Stdlib_Promise.$$catch(client.getNextPage(params), coerceErrorOrThrow)
64
+ getNextPage: (params, addressSet) => Stdlib_Promise.$$catch(client.getNextPage(params, addressSet), coerceErrorOrThrow)
65
65
  };
66
66
  }
67
67
 
@@ -43,16 +43,17 @@ module GetLogs = {
43
43
  ~fromBlock,
44
44
  ~toBlock,
45
45
  ~registrationIndexes,
46
- ~addressesByContractName,
46
+ ~addressSet,
47
+ ~clientFilteredContracts,
47
48
  ): logsQueryPage => {
48
49
  let query: FuelHyperSyncClient.EventItems.query = {
49
50
  fromBlock,
50
51
  toBlock,
51
52
  registrationIndexes,
52
- addressesByContractName,
53
+ clientFilteredContracts,
53
54
  }
54
55
 
55
- let res = switch await client->FuelHyperSyncClient.getEventItems(query) {
56
+ let res = switch await client->FuelHyperSyncClient.getEventItems(query, addressSet) {
56
57
  | res => res
57
58
  | exception exn =>
58
59
  switch exn->extractMissingParams {
@@ -29,16 +29,16 @@ function extractMissingParams(exn) {
29
29
  }
30
30
  }
31
31
 
32
- async function query(client, fromBlock, toBlock, registrationIndexes, addressesByContractName) {
32
+ async function query(client, fromBlock, toBlock, registrationIndexes, addressSet, clientFilteredContracts) {
33
33
  let query$1 = {
34
34
  fromBlock: fromBlock,
35
35
  toBlock: toBlock,
36
36
  registrationIndexes: registrationIndexes,
37
- addressesByContractName: addressesByContractName
37
+ clientFilteredContracts: clientFilteredContracts
38
38
  };
39
39
  let res;
40
40
  try {
41
- res = await client.getEventItems(query$1);
41
+ res = await client.getEventItems(query$1, addressSet);
42
42
  } catch (raw_exn) {
43
43
  let exn = Primitive_exceptions.internalToException(raw_exn);
44
44
  let missingParams = extractMissingParams(exn);
@@ -17,6 +17,7 @@ module GetLogs: {
17
17
  ~fromBlock: int,
18
18
  ~toBlock: option<int>,
19
19
  ~registrationIndexes: array<int>,
20
- ~addressesByContractName: dict<array<Address.t>>,
20
+ ~addressSet: AddressSet.t,
21
+ ~clientFilteredContracts: option<array<string>>,
21
22
  ) => promise<logsQueryPage>
22
23
  }
@@ -52,15 +52,18 @@ module Registration = {
52
52
  }
53
53
 
54
54
  module EventItems = {
55
- // The whole per-query input: block range, the partition's registration
56
- // selection (by index), and its current addresses. Receipt selections,
57
- // field selection, and routing are derived on the Rust side.
55
+ // The whole per-query input beside the partition's address set: block range
56
+ // and the registration selection (by index). Receipt selections, field
57
+ // selection, and routing are derived on the Rust side.
58
58
  type query = {
59
59
  fromBlock: int,
60
60
  // Inclusive; None queries to the end of available data.
61
61
  toBlock: option<int>,
62
62
  registrationIndexes: array<int>,
63
- addressesByContractName: dict<array<Address.t>>,
63
+ // Contract names to fetch address-free even though their registrations
64
+ // depend on addresses (client-side filtering). None/empty means every
65
+ // address-dependent contract is filtered server-side.
66
+ clientFilteredContracts: option<array<string>>,
64
67
  }
65
68
 
66
69
  // One routed receipt with its kind-specific columns flattened: LogData
@@ -102,19 +105,22 @@ external classNew: (
102
105
  cfg,
103
106
  ~userAgent: string,
104
107
  array<Registration.input>,
108
+ AddressStore.t,
105
109
  ) => t = "new"
106
110
 
107
- let make = (cfg: cfg, ~eventRegistrations) => {
111
+ let make = (cfg: cfg, ~eventRegistrations, ~addressStore) => {
108
112
  let envioVersion = Utils.EnvioPackage.value.version
109
113
  Core.getAddon().fuelHyperSyncClient->classNew(
110
114
  cfg,
111
115
  ~userAgent=`hyperindex/${envioVersion}`,
112
116
  eventRegistrations,
117
+ addressStore,
113
118
  )
114
119
  }
115
120
 
116
121
  @send
117
- external getEventItems: (t, EventItems.query) => promise<EventItems.response> = "getEventItems"
122
+ external getEventItems: (t, EventItems.query, AddressSet.t) => promise<EventItems.response> =
123
+ "getEventItems"
118
124
 
119
125
  @send
120
126
  external getHeight: t => promise<int> = "getHeight"
@@ -58,9 +58,9 @@ let Registration = {
58
58
 
59
59
  let EventItems = {};
60
60
 
61
- function make(cfg, eventRegistrations) {
61
+ function make(cfg, eventRegistrations, addressStore) {
62
62
  let envioVersion = Utils.EnvioPackage.value.version;
63
- return Core.getAddon().FuelHyperSyncClient.new(cfg, `hyperindex/` + envioVersion, eventRegistrations);
63
+ return Core.getAddon().FuelHyperSyncClient.new(cfg, `hyperindex/` + envioVersion, eventRegistrations, addressStore);
64
64
  }
65
65
 
66
66
  export {
@@ -8,9 +8,11 @@ type options = {
8
8
  apiToken: option<string>,
9
9
  // The chain's registrations, indexed by their sequential `index`.
10
10
  onEventRegistrations: array<Internal.fuelOnEventRegistration>,
11
+ // The chain's address index; the client reads it while routing.
12
+ addressStore: AddressStore.t,
11
13
  }
12
14
 
13
- let make = ({chain, endpointUrl, apiToken, onEventRegistrations}: options): t => {
15
+ let make = ({chain, endpointUrl, apiToken, onEventRegistrations, addressStore}: options): t => {
14
16
  let name = "HyperFuel"
15
17
 
16
18
  let apiToken = switch apiToken {
@@ -24,6 +26,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
24
26
  let client = switch FuelHyperSyncClient.make(
25
27
  {url: endpointUrl, apiToken},
26
28
  ~eventRegistrations=FuelHyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations),
29
+ ~addressStore,
27
30
  ) {
28
31
  | client => client
29
32
  | exception exn =>
@@ -33,8 +36,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
33
36
  let getItemsOrThrow = async (
34
37
  ~fromBlock,
35
38
  ~toBlock,
36
- ~addressesByContractName,
37
- ~contractNameByAddress as _,
39
+ ~addressSet,
38
40
  ~knownHeight,
39
41
  ~partitionId as _,
40
42
  ~selection: FetchState.selection,
@@ -52,7 +54,8 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
52
54
  ~fromBlock,
53
55
  ~toBlock,
54
56
  ~registrationIndexes=selection.onEventRegistrations->Array.map(reg => reg.index),
55
- ~addressesByContractName,
57
+ ~addressSet,
58
+ ~clientFilteredContracts=selection.clientFilteredContracts,
56
59
  ) catch {
57
60
  | FuelHyperSync.GetLogs.Error(error) =>
58
61
  throw(
@@ -27,17 +27,17 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
27
27
  client = FuelHyperSyncClient.make({
28
28
  url: param.endpointUrl,
29
29
  apiToken: apiToken$1
30
- }, FuelHyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations));
30
+ }, FuelHyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations), param.addressStore);
31
31
  } catch (raw_exn) {
32
32
  let exn = Primitive_exceptions.internalToException(raw_exn);
33
33
  client = ErrorHandling.mkLogAndRaise(undefined, "Failed to instantiate the HyperFuel client", exn);
34
34
  }
35
- let getItemsOrThrow = async (fromBlock, toBlock, addressesByContractName, param, knownHeight, param$1, selection, param$2, retry, logger) => {
35
+ let getItemsOrThrow = async (fromBlock, toBlock, addressSet, knownHeight, param, selection, param$1, retry, logger) => {
36
36
  let totalTimeRef = Performance.now();
37
37
  let startFetchingBatchTimeRef = Performance.now();
38
38
  let pageUnsafe;
39
39
  try {
40
- pageUnsafe = await FuelHyperSync.GetLogs.query(client, fromBlock, toBlock, selection.onEventRegistrations.map(reg => reg.index), addressesByContractName);
40
+ pageUnsafe = await FuelHyperSync.GetLogs.query(client, fromBlock, toBlock, selection.onEventRegistrations.map(reg => reg.index), addressSet, selection.clientFilteredContracts);
41
41
  } catch (raw_error) {
42
42
  let error = Primitive_exceptions.internalToException(raw_error);
43
43
  if (error.RE_EXN_ID === FuelHyperSync.GetLogs.$$Error) {
@@ -16,7 +16,7 @@ let reraisIfRateLimited = exn =>
16
16
 
17
17
  type logsQueryPage = {
18
18
  items: array<HyperSyncClient.EventItems.item>,
19
- // Block headers referenced by `items`, deduplicated by block number.
19
+ // Headers for every returned block, deduplicated by block number.
20
20
  blocks: array<HyperSyncClient.EventItems.blockHeader>,
21
21
  nextBlock: int,
22
22
  archiveHeight: int,
@@ -92,17 +92,21 @@ module GetLogs = {
92
92
  ~toBlock,
93
93
  ~maxNumLogs,
94
94
  ~registrationIndexes,
95
- ~addressesByContractName,
95
+ ~addressSet,
96
+ ~clientFilteredContracts,
96
97
  ): logsQueryPage => {
97
98
  let query: HyperSyncClient.EventItems.query = {
98
99
  fromBlock,
99
100
  toBlock,
100
- maxNumLogs,
101
+ ?maxNumLogs,
101
102
  registrationIndexes,
102
- addressesByContractName,
103
+ clientFilteredContracts,
103
104
  }
104
105
 
105
- let (res, transactionStore, blockStore) = switch await client.getEventItems(~query) {
106
+ let (res, transactionStore, blockStore) = switch await client.getEventItems(
107
+ ~query,
108
+ ~addressSet,
109
+ ) {
106
110
  | res => res
107
111
  | exception exn =>
108
112
  reraisIfRateLimited(exn)
@@ -82,17 +82,17 @@ function extractMissingParams(exn) {
82
82
  }
83
83
  }
84
84
 
85
- async function query(client, fromBlock, toBlock, maxNumLogs, registrationIndexes, addressesByContractName) {
85
+ async function query(client, fromBlock, toBlock, maxNumLogs, registrationIndexes, addressSet, clientFilteredContracts) {
86
86
  let query$1 = {
87
87
  fromBlock: fromBlock,
88
88
  toBlock: toBlock,
89
89
  maxNumLogs: maxNumLogs,
90
90
  registrationIndexes: registrationIndexes,
91
- addressesByContractName: addressesByContractName
91
+ clientFilteredContracts: clientFilteredContracts
92
92
  };
93
93
  let match;
94
94
  try {
95
- match = await client.getEventItems(query$1);
95
+ match = await client.getEventItems(query$1, addressSet);
96
96
  } catch (raw_exn) {
97
97
  let exn = Primitive_exceptions.internalToException(raw_exn);
98
98
  reraisIfRateLimited(exn);
@@ -32,9 +32,10 @@ module GetLogs: {
32
32
  ~client: HyperSyncClient.t,
33
33
  ~fromBlock: int,
34
34
  ~toBlock: option<int>,
35
- ~maxNumLogs: int,
35
+ ~maxNumLogs: option<int>,
36
36
  ~registrationIndexes: array<int>,
37
- ~addressesByContractName: dict<array<Address.t>>,
37
+ ~addressSet: AddressSet.t,
38
+ ~clientFilteredContracts: option<array<string>>,
38
39
  ) => promise<logsQueryPage>
39
40
  }
40
41
 
@@ -302,16 +302,20 @@ module Registration = {
302
302
  }
303
303
 
304
304
  module EventItems = {
305
- // The whole per-query input: block range, the partition's registration
306
- // selection (by id), and its current addresses. Log selections, field
307
- // selection, and the routing index are derived on the Rust side.
305
+ // The whole per-query input beside the partition's address set: block range
306
+ // and the registration selection (by id). Log selections, field selection,
307
+ // and the routing index are derived on the Rust side.
308
308
  type query = {
309
309
  fromBlock: int,
310
310
  // Inclusive; None queries to the end of available data.
311
311
  toBlock: option<int>,
312
- maxNumLogs: int,
312
+ // Absent means no server-side cap on the number of logs returned.
313
+ maxNumLogs?: int,
313
314
  registrationIndexes: array<int>,
314
- addressesByContractName: dict<array<Address.t>>,
315
+ // Contract names to fetch address-free even though their registrations
316
+ // depend on addresses (client-side filtering). None/empty means
317
+ // every address-dependent contract is filtered server-side.
318
+ clientFilteredContracts: option<array<string>>,
315
319
  }
316
320
 
317
321
  type item = {
@@ -340,7 +344,9 @@ module EventItems = {
340
344
  type response = {
341
345
  archiveHeight: option<int>,
342
346
  nextBlock: int,
343
- // One header per block number referenced by `items`.
347
+ // One header per returned block number, including blocks no item
348
+ // references — reorg detection reads them all. The block store keeps only
349
+ // the ones items reference.
344
350
  blocks: array<blockHeader>,
345
351
  items: array<item>,
346
352
  rollbackGuard: option<ResponseTypes.rollbackGuard>,
@@ -353,16 +359,22 @@ type t = {
353
359
  // and blocks.
354
360
  getEventItems: (
355
361
  ~query: EventItems.query,
362
+ ~addressSet: AddressSet.t,
356
363
  ) => promise<(EventItems.response, TransactionStore.t, BlockStore.t)>,
357
364
  getHeight: unit => promise<int>,
358
365
  }
359
366
 
360
367
  @send
361
- external classNew: (Core.evmHyperSyncClientCtor, cfg, string, array<Registration.input>) => t =
362
- "new"
368
+ external classNew: (
369
+ Core.evmHyperSyncClientCtor,
370
+ cfg,
371
+ string,
372
+ array<Registration.input>,
373
+ AddressStore.t,
374
+ ) => t = "new"
363
375
 
364
- let makeWithAgent = (cfg, ~userAgent, ~eventRegistrations) =>
365
- Core.getAddon().evmHyperSyncClient->classNew(cfg, userAgent, eventRegistrations)
376
+ let makeWithAgent = (cfg, ~userAgent, ~eventRegistrations, ~addressStore) =>
377
+ Core.getAddon().evmHyperSyncClient->classNew(cfg, userAgent, eventRegistrations, addressStore)
366
378
 
367
379
  type logLevel = [#trace | #debug | #info | #warn | #error]
368
380
  let logLevelSchema: S.t<logLevel> = S.enum([#trace, #debug, #info, #warn, #error])
@@ -388,6 +400,7 @@ let make = (
388
400
  ~retryBackoffMs=?,
389
401
  ~retryCeilingMs=?,
390
402
  ~logLevel=#info,
403
+ ~addressStore,
391
404
  ) => {
392
405
  let envioVersion = Utils.EnvioPackage.value.version
393
406
  makeWithAgent(
@@ -407,5 +420,6 @@ let make = (
407
420
  },
408
421
  ~userAgent=`hyperindex/${envioVersion}`,
409
422
  ~eventRegistrations,
423
+ ~addressStore,
410
424
  )
411
425
  }
@@ -73,8 +73,8 @@ let Registration = {
73
73
 
74
74
  let EventItems = {};
75
75
 
76
- function makeWithAgent(cfg, userAgent, eventRegistrations) {
77
- return Core.getAddon().EvmHyperSyncClient.new(cfg, userAgent, eventRegistrations);
76
+ function makeWithAgent(cfg, userAgent, eventRegistrations, addressStore) {
77
+ return Core.getAddon().EvmHyperSyncClient.new(cfg, userAgent, eventRegistrations, addressStore);
78
78
  }
79
79
 
80
80
  let logLevelSchema = S$RescriptSchema.$$enum([
@@ -99,7 +99,7 @@ function logLevelToString(level) {
99
99
  }
100
100
  }
101
101
 
102
- function make(url, apiToken, httpReqTimeoutMillis, eventRegistrations, enableChecksumAddressesOpt, serializationFormat, enableQueryCaching, retryBaseMs, retryBackoffMs, retryCeilingMs, logLevelOpt) {
102
+ function make(url, apiToken, httpReqTimeoutMillis, eventRegistrations, enableChecksumAddressesOpt, serializationFormat, enableQueryCaching, retryBaseMs, retryBackoffMs, retryCeilingMs, logLevelOpt, addressStore) {
103
103
  let enableChecksumAddresses = enableChecksumAddressesOpt !== undefined ? enableChecksumAddressesOpt : true;
104
104
  let logLevel = logLevelOpt !== undefined ? logLevelOpt : "info";
105
105
  let envioVersion = Utils.EnvioPackage.value.version;
@@ -115,7 +115,7 @@ function make(url, apiToken, httpReqTimeoutMillis, eventRegistrations, enableChe
115
115
  serializationFormat: serializationFormat,
116
116
  enableQueryCaching: enableQueryCaching,
117
117
  logLevel: logLevelToString(logLevel)
118
- }, `hyperindex/` + envioVersion, eventRegistrations);
118
+ }, `hyperindex/` + envioVersion, eventRegistrations, addressStore);
119
119
  }
120
120
 
121
121
  export {