envio 3.0.0-alpha.21 → 3.0.0-alpha.22

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 (219) hide show
  1. package/bin.mjs +2 -48
  2. package/evm.schema.json +67 -0
  3. package/fuel.schema.json +67 -0
  4. package/index.d.ts +822 -38
  5. package/index.js +5 -3
  6. package/package.json +10 -8
  7. package/rescript.json +5 -9
  8. package/src/Address.res +4 -5
  9. package/src/Address.res.mjs +9 -12
  10. package/src/Api.res +15 -0
  11. package/src/Api.res.mjs +20 -0
  12. package/src/Batch.res +32 -34
  13. package/src/Batch.res.mjs +172 -187
  14. package/src/Bin.res +89 -0
  15. package/src/Bin.res.mjs +97 -0
  16. package/src/ChainFetcher.res +33 -57
  17. package/src/ChainFetcher.res.mjs +197 -227
  18. package/src/ChainManager.res +6 -14
  19. package/src/ChainManager.res.mjs +74 -85
  20. package/src/ChainMap.res +14 -16
  21. package/src/ChainMap.res.mjs +38 -38
  22. package/src/Config.res +193 -135
  23. package/src/Config.res.mjs +566 -592
  24. package/src/Core.res +182 -0
  25. package/src/Core.res.mjs +207 -0
  26. package/src/Ecosystem.res +25 -4
  27. package/src/Ecosystem.res.mjs +12 -13
  28. package/src/Env.res +20 -13
  29. package/src/Env.res.mjs +124 -113
  30. package/src/EnvSafe.res +269 -0
  31. package/src/EnvSafe.res.mjs +296 -0
  32. package/src/EnvSafe.resi +18 -0
  33. package/src/Envio.res +37 -26
  34. package/src/Envio.res.mjs +59 -60
  35. package/src/ErrorHandling.res +2 -2
  36. package/src/ErrorHandling.res.mjs +15 -15
  37. package/src/EventConfigBuilder.res +219 -81
  38. package/src/EventConfigBuilder.res.mjs +259 -202
  39. package/src/EventProcessing.res +27 -38
  40. package/src/EventProcessing.res.mjs +165 -183
  41. package/src/EventUtils.res +11 -11
  42. package/src/EventUtils.res.mjs +21 -22
  43. package/src/EvmTypes.res +0 -1
  44. package/src/EvmTypes.res.mjs +5 -5
  45. package/src/FetchState.res +360 -256
  46. package/src/FetchState.res.mjs +958 -914
  47. package/src/GlobalState.res +365 -351
  48. package/src/GlobalState.res.mjs +958 -992
  49. package/src/GlobalStateManager.res +1 -2
  50. package/src/GlobalStateManager.res.mjs +36 -44
  51. package/src/HandlerLoader.res +107 -23
  52. package/src/HandlerLoader.res.mjs +128 -38
  53. package/src/HandlerRegister.res +127 -103
  54. package/src/HandlerRegister.res.mjs +164 -164
  55. package/src/HandlerRegister.resi +12 -4
  56. package/src/Hasura.res +35 -22
  57. package/src/Hasura.res.mjs +158 -167
  58. package/src/InMemoryStore.res +20 -27
  59. package/src/InMemoryStore.res.mjs +64 -80
  60. package/src/InMemoryTable.res +34 -39
  61. package/src/InMemoryTable.res.mjs +165 -170
  62. package/src/Internal.res +52 -33
  63. package/src/Internal.res.mjs +84 -81
  64. package/src/LazyLoader.res.mjs +55 -61
  65. package/src/LoadLayer.res +77 -78
  66. package/src/LoadLayer.res.mjs +160 -189
  67. package/src/LoadManager.res +16 -21
  68. package/src/LoadManager.res.mjs +79 -84
  69. package/src/LogSelection.res +236 -68
  70. package/src/LogSelection.res.mjs +211 -141
  71. package/src/Logging.res +13 -9
  72. package/src/Logging.res.mjs +130 -143
  73. package/src/Main.res +428 -51
  74. package/src/Main.res.mjs +528 -271
  75. package/src/Persistence.res +77 -84
  76. package/src/Persistence.res.mjs +131 -132
  77. package/src/PgStorage.res +291 -167
  78. package/src/PgStorage.res.mjs +797 -817
  79. package/src/Prometheus.res +50 -58
  80. package/src/Prometheus.res.mjs +345 -373
  81. package/src/ReorgDetection.res +22 -24
  82. package/src/ReorgDetection.res.mjs +100 -106
  83. package/src/SafeCheckpointTracking.res +7 -7
  84. package/src/SafeCheckpointTracking.res.mjs +40 -43
  85. package/src/SimulateItems.res +41 -49
  86. package/src/SimulateItems.res.mjs +257 -272
  87. package/src/Sink.res +2 -2
  88. package/src/Sink.res.mjs +22 -26
  89. package/src/TableIndices.res +1 -2
  90. package/src/TableIndices.res.mjs +42 -48
  91. package/src/TestIndexer.res +196 -189
  92. package/src/TestIndexer.res.mjs +536 -536
  93. package/src/TestIndexerProxyStorage.res +15 -16
  94. package/src/TestIndexerProxyStorage.res.mjs +98 -122
  95. package/src/TestIndexerWorker.res +4 -0
  96. package/src/TestIndexerWorker.res.mjs +7 -0
  97. package/src/Throttler.res +3 -3
  98. package/src/Throttler.res.mjs +23 -24
  99. package/src/Time.res +1 -1
  100. package/src/Time.res.mjs +18 -21
  101. package/src/TopicFilter.res +3 -3
  102. package/src/TopicFilter.res.mjs +29 -30
  103. package/src/UserContext.res +93 -54
  104. package/src/UserContext.res.mjs +197 -182
  105. package/src/Utils.res +141 -86
  106. package/src/Utils.res.mjs +334 -295
  107. package/src/bindings/BigDecimal.res +0 -2
  108. package/src/bindings/BigDecimal.res.mjs +19 -23
  109. package/src/bindings/ClickHouse.res +28 -27
  110. package/src/bindings/ClickHouse.res.mjs +243 -240
  111. package/src/bindings/DateFns.res +11 -11
  112. package/src/bindings/DateFns.res.mjs +7 -7
  113. package/src/bindings/EventSource.res.mjs +2 -2
  114. package/src/bindings/Express.res +2 -5
  115. package/src/bindings/Hrtime.res +2 -2
  116. package/src/bindings/Hrtime.res.mjs +30 -32
  117. package/src/bindings/Lodash.res.mjs +1 -1
  118. package/src/bindings/NodeJs.res +14 -9
  119. package/src/bindings/NodeJs.res.mjs +20 -20
  120. package/src/bindings/Pino.res +8 -10
  121. package/src/bindings/Pino.res.mjs +40 -43
  122. package/src/bindings/Postgres.res +2 -5
  123. package/src/bindings/Postgres.res.mjs +9 -9
  124. package/src/bindings/PromClient.res +17 -2
  125. package/src/bindings/PromClient.res.mjs +30 -7
  126. package/src/bindings/SDSL.res.mjs +2 -2
  127. package/src/bindings/Viem.res +4 -4
  128. package/src/bindings/Viem.res.mjs +20 -22
  129. package/src/bindings/Vitest.res +1 -1
  130. package/src/bindings/Vitest.res.mjs +2 -2
  131. package/src/bindings/WebSocket.res +1 -1
  132. package/src/db/EntityHistory.res +9 -3
  133. package/src/db/EntityHistory.res.mjs +84 -59
  134. package/src/db/InternalTable.res +62 -60
  135. package/src/db/InternalTable.res.mjs +271 -203
  136. package/src/db/Schema.res +1 -2
  137. package/src/db/Schema.res.mjs +28 -32
  138. package/src/db/Table.res +28 -27
  139. package/src/db/Table.res.mjs +276 -292
  140. package/src/sources/EventRouter.res +21 -16
  141. package/src/sources/EventRouter.res.mjs +55 -57
  142. package/src/sources/Evm.res +17 -1
  143. package/src/sources/Evm.res.mjs +16 -8
  144. package/src/sources/EvmChain.res +15 -17
  145. package/src/sources/EvmChain.res.mjs +40 -42
  146. package/src/sources/Fuel.res +14 -1
  147. package/src/sources/Fuel.res.mjs +16 -8
  148. package/src/sources/FuelSDK.res +1 -1
  149. package/src/sources/FuelSDK.res.mjs +6 -8
  150. package/src/sources/HyperFuel.res +8 -10
  151. package/src/sources/HyperFuel.res.mjs +113 -123
  152. package/src/sources/HyperFuelClient.res.mjs +6 -7
  153. package/src/sources/HyperFuelSource.res +19 -20
  154. package/src/sources/HyperFuelSource.res.mjs +339 -356
  155. package/src/sources/HyperSync.res +11 -13
  156. package/src/sources/HyperSync.res.mjs +206 -220
  157. package/src/sources/HyperSyncClient.res +5 -7
  158. package/src/sources/HyperSyncClient.res.mjs +70 -75
  159. package/src/sources/HyperSyncHeightStream.res +8 -9
  160. package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
  161. package/src/sources/HyperSyncJsonApi.res +18 -15
  162. package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
  163. package/src/sources/HyperSyncSource.res +17 -21
  164. package/src/sources/HyperSyncSource.res.mjs +268 -290
  165. package/src/sources/Rpc.res +5 -5
  166. package/src/sources/Rpc.res.mjs +168 -192
  167. package/src/sources/RpcSource.res +166 -167
  168. package/src/sources/RpcSource.res.mjs +972 -1046
  169. package/src/sources/RpcWebSocketHeightStream.res +10 -11
  170. package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
  171. package/src/sources/SimulateSource.res +1 -1
  172. package/src/sources/SimulateSource.res.mjs +35 -38
  173. package/src/sources/Source.res +1 -1
  174. package/src/sources/Source.res.mjs +3 -3
  175. package/src/sources/SourceManager.res +39 -20
  176. package/src/sources/SourceManager.res.mjs +340 -371
  177. package/src/sources/SourceManager.resi +2 -1
  178. package/src/sources/Svm.res +12 -5
  179. package/src/sources/Svm.res.mjs +44 -41
  180. package/src/tui/Tui.res +23 -12
  181. package/src/tui/Tui.res.mjs +292 -290
  182. package/src/tui/bindings/Ink.res +2 -4
  183. package/src/tui/bindings/Ink.res.mjs +35 -41
  184. package/src/tui/components/BufferedProgressBar.res +7 -7
  185. package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
  186. package/src/tui/components/CustomHooks.res +1 -2
  187. package/src/tui/components/CustomHooks.res.mjs +102 -122
  188. package/src/tui/components/Messages.res +1 -2
  189. package/src/tui/components/Messages.res.mjs +38 -42
  190. package/src/tui/components/SyncETA.res +10 -11
  191. package/src/tui/components/SyncETA.res.mjs +178 -196
  192. package/src/tui/components/TuiData.res +1 -1
  193. package/src/tui/components/TuiData.res.mjs +7 -6
  194. package/src/vendored/Rest.res +52 -66
  195. package/src/vendored/Rest.res.mjs +324 -364
  196. package/svm.schema.json +67 -0
  197. package/src/Address.gen.ts +0 -8
  198. package/src/Config.gen.ts +0 -19
  199. package/src/Envio.gen.ts +0 -55
  200. package/src/EvmTypes.gen.ts +0 -6
  201. package/src/InMemoryStore.gen.ts +0 -6
  202. package/src/Internal.gen.ts +0 -64
  203. package/src/PgStorage.gen.ts +0 -10
  204. package/src/PgStorage.res.d.mts +0 -5
  205. package/src/Types.ts +0 -56
  206. package/src/bindings/BigDecimal.gen.ts +0 -14
  207. package/src/bindings/BigDecimal.res.d.mts +0 -5
  208. package/src/bindings/BigInt.gen.ts +0 -10
  209. package/src/bindings/BigInt.res +0 -70
  210. package/src/bindings/BigInt.res.d.mts +0 -5
  211. package/src/bindings/BigInt.res.mjs +0 -154
  212. package/src/bindings/Ethers.res.d.mts +0 -5
  213. package/src/bindings/Pino.gen.ts +0 -17
  214. package/src/bindings/Postgres.gen.ts +0 -8
  215. package/src/bindings/Postgres.res.d.mts +0 -5
  216. package/src/bindings/Promise.res +0 -67
  217. package/src/bindings/Promise.res.mjs +0 -26
  218. package/src/db/InternalTable.gen.ts +0 -36
  219. 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: Js.Dict.empty(),
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(_) => raise(EventDuplicate)
18
+ | Some(_) => throw(EventDuplicate)
21
19
  | None =>
22
20
  if isWildcard && wildcard->Option.isSome {
23
- raise(WildcardCollision)
21
+ throw(WildcardCollision)
24
22
  } else {
25
23
  if isWildcard {
26
24
  group.wildcard = Some(event)
27
25
  }
28
- byContractName->Js.Dict.set(contractName, event)
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
- ~indexingContracts: dict<Internal.indexingContract>,
35
+ ~indexingAddresses: dict<FetchState.indexingAddress>,
38
36
  ) =>
39
37
  switch group {
40
38
  | {wildcard, byContractName} =>
41
- switch indexingContracts->Utils.Dict.dangerouslyGetNonOption(
39
+ switch indexingAddresses->Utils.Dict.dangerouslyGetNonOption(
42
40
  contractAddress->Address.toString,
43
41
  ) {
44
42
  | Some(indexingContract) =>
45
- if indexingContract.startBlock <= blockNumber {
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 = () => Js.Dict.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->Js.Dict.set(eventId, group)
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
- Js.Exn.raiseError(
82
+ JsError.throwWithMessage(
78
83
  `Duplicate event detected: ${eventName} for contract ${contractName} on chain ${chain->ChainMap.Chain.toString}`,
79
84
  )
80
85
  | WildcardCollision =>
81
- Js.Exn.raiseError(
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, ~indexingContracts) => {
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, ~indexingContracts)
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/belt_Array.js";
6
- import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
7
- import * as Caml_option from "rescript/lib/es6/caml_option.js";
8
- import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
9
- import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
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
- var EventDuplicate = /* @__PURE__ */Caml_exceptions.create("EventRouter.EventDuplicate");
10
+ let EventDuplicate = /* @__PURE__ */Primitive_exceptions.create("EventRouter.EventDuplicate");
12
11
 
13
- var WildcardCollision = /* @__PURE__ */Caml_exceptions.create("EventRouter.WildcardCollision");
12
+ let WildcardCollision = /* @__PURE__ */Primitive_exceptions.create("EventRouter.WildcardCollision");
14
13
 
15
14
  function empty() {
16
15
  return {
17
- wildcard: undefined,
18
- byContractName: {}
19
- };
16
+ wildcard: undefined,
17
+ byContractName: {}
18
+ };
20
19
  }
21
20
 
22
- function addOrThrow(group, $$event, contractName, isWildcard) {
23
- var wildcard = group.wildcard;
24
- var byContractName = group.byContractName;
25
- var match = byContractName[contractName];
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
- RE_EXN_ID: EventDuplicate,
29
- Error: new Error()
30
- };
27
+ RE_EXN_ID: EventDuplicate,
28
+ Error: new Error()
29
+ };
31
30
  }
32
- if (isWildcard && Belt_Option.isSome(wildcard)) {
31
+ if (isWildcard && Stdlib_Option.isSome(wildcard)) {
33
32
  throw {
34
- RE_EXN_ID: WildcardCollision,
35
- Error: new Error()
36
- };
33
+ RE_EXN_ID: WildcardCollision,
34
+ Error: new Error()
35
+ };
37
36
  }
38
37
  if (isWildcard) {
39
- group.wildcard = Caml_option.some($$event);
38
+ group.wildcard = Primitive_option.some(event);
40
39
  }
41
- byContractName[contractName] = $$event;
40
+ byContractName[contractName] = event;
42
41
  }
43
42
 
44
- function get(group, contractAddress, blockNumber, indexingContracts) {
45
- var wildcard = group.wildcard;
46
- var indexingContract = indexingContracts[contractAddress];
47
- if (indexingContract !== undefined) {
48
- if (indexingContract.startBlock <= blockNumber) {
49
- return group.byContractName[indexingContract.contractName];
50
- } else {
51
- return ;
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
- var Group = {
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, $$event, contractName, isWildcard, eventName, chain) {
69
- var group = router[eventId];
70
- var group$1;
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
- var group$2 = {
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, $$event, contractName, isWildcard);
83
- }
84
- catch (raw_exn){
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 Js_exn.raiseError("Duplicate event detected: " + eventName + " for contract " + contractName + " on chain " + ChainMap.Chain.toString(chain));
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 Js_exn.raiseError("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
+ 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, indexingContracts) {
97
- var group = router[tag];
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, indexingContracts);
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
- var router = {};
110
- Belt_Array.forEach(events, (function (config) {
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 */
@@ -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: Js.Json.t => unit = %raw(`fields => {
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
  }
@@ -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
- var cleanUpRawEventFieldsInPlace = (fields => {
5
+ let cleanUpRawEventFieldsInPlace = (fields => {
5
6
  delete fields.hash
6
7
  delete fields.number
7
8
  delete fields.timestamp
8
9
  });
9
10
 
10
- var ecosystem_blockFields = [
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
- var ecosystem_transactionFields = [
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
- var ecosystem = {
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
- /* No side effect */
113
+ /* ecosystem Not a pure module */
@@ -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.getWithDefault(20_000)
20
+ let queryTimeoutMillis = queryTimeoutMillis->Option.getOr(20_000)
23
21
  {
24
- initialBlockInterval: Env.Configurable.SyncConfig.initialBlockInterval->Option.getWithDefault(
25
- initialBlockInterval->Option.getWithDefault(10_000),
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.getWithDefault(
29
- backoffMultiplicative->Option.getWithDefault(0.8),
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.getWithDefault(
33
- accelerationAdditive->Option.getWithDefault(500),
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.getWithDefault(
37
- intervalCeiling->Option.getWithDefault(10_000),
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.getWithDefault(5000),
38
+ backoffMillis: backoffMillis->Option.getOr(5000),
41
39
  // How long to wait before cancelling an RPC request
42
40
  queryTimeoutMillis,
43
- fallbackStallTimeout: fallbackStallTimeout->Option.getWithDefault(queryTimeoutMillis / 2),
41
+ fallbackStallTimeout: fallbackStallTimeout->Option.getOr(queryTimeoutMillis / 2),
44
42
  // How frequently to check for new blocks in realtime (default: 1000ms)
45
- pollingInterval: pollingInterval->Option.getWithDefault(1000),
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->Js.Array2.forEach(({?syncConfig, url, sourceFor, ?ws}) => {
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.getWithDefault({})),
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->Js.Array2.push(source)
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/belt_Array.js";
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
- var queryTimeoutMillis = Belt_Option.getWithDefault(param.queryTimeoutMillis, 20000);
11
+ let queryTimeoutMillis = Stdlib_Option.getOr(param.queryTimeoutMillis, 20000);
12
12
  return {
13
- initialBlockInterval: Belt_Option.getWithDefault(Env.Configurable.SyncConfig.initialBlockInterval, Belt_Option.getWithDefault(param.initialBlockInterval, 10000)),
14
- backoffMultiplicative: Belt_Option.getWithDefault(Env.Configurable.SyncConfig.backoffMultiplicative, Belt_Option.getWithDefault(param.backoffMultiplicative, 0.8)),
15
- accelerationAdditive: Belt_Option.getWithDefault(Env.Configurable.SyncConfig.accelerationAdditive, Belt_Option.getWithDefault(param.accelerationAdditive, 500)),
16
- intervalCeiling: Belt_Option.getWithDefault(Env.Configurable.SyncConfig.intervalCeiling, Belt_Option.getWithDefault(param.intervalCeiling, 10000)),
17
- backoffMillis: Belt_Option.getWithDefault(param.backoffMillis, 5000),
18
- queryTimeoutMillis: queryTimeoutMillis,
19
- fallbackStallTimeout: Belt_Option.getWithDefault(param.fallbackStallTimeout, queryTimeoutMillis / 2 | 0),
20
- pollingInterval: Belt_Option.getWithDefault(param.pollingInterval, 1000)
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
- var eventRouter = EventRouter.fromEvmEventModsOrThrow(Belt_Array.flatMap(contracts, (function (contract) {
26
- return contract.events;
27
- })), chain);
28
- var sources = hyperSync !== undefined ? [HyperSyncSource.make({
29
- chain: chain,
30
- endpointUrl: hyperSync,
31
- allEventSignatures: allEventSignatures,
32
- eventRouter: eventRouter,
33
- apiToken: Env.envioApiToken,
34
- clientMaxRetries: Env.hyperSyncClientMaxRetries,
35
- clientTimeoutMillis: Env.hyperSyncClientTimeoutMillis,
36
- lowercaseAddresses: lowercaseAddresses,
37
- serializationFormat: Env.hypersyncClientSerializationFormat,
38
- enableQueryCaching: Env.hypersyncClientEnableQueryCaching
39
- })] : [];
40
- rpcs.forEach(function (param) {
41
- var source = RpcSource.make({
42
- sourceFor: param.sourceFor,
43
- syncConfig: getSyncConfig(Belt_Option.getWithDefault(param.syncConfig, {})),
44
- url: param.url,
45
- chain: chain,
46
- eventRouter: eventRouter,
47
- allEventSignatures: allEventSignatures,
48
- lowercaseAddresses: lowercaseAddresses,
49
- ws: param.ws
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 */
@@ -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: Js.Json.t => unit = %raw(`fields => {
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
  }
@@ -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
- var cleanUpRawEventFieldsInPlace = (fields => {
5
+ let cleanUpRawEventFieldsInPlace = (fields => {
5
6
  delete fields.id
6
7
  delete fields.height
7
8
  delete fields.time
8
9
  });
9
10
 
10
- var ecosystem_blockFields = [
11
+ let ecosystem_blockFields = [
11
12
  "id",
12
13
  "height",
13
14
  "time"
14
15
  ];
15
16
 
16
- var ecosystem_transactionFields = ["id"];
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
- var ecosystem = {
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
- /* No side effect */
55
+ /* ecosystem Not a pure module */
@@ -15,7 +15,7 @@ type receiptType =
15
15
  | @as(12) Burn
16
16
 
17
17
  @module("./vendored-fuel-abi-coder.js")
18
- external transpileAbi: Js.Json.t => EvmTypes.Abi.t = "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
- var decode = VendoredFuelAbiCoderJs.AbiCoder.getLogDecoder(abi, logId);
15
- return function (data) {
16
- return decode(data);
17
- };
14
+ let decode = VendoredFuelAbiCoderJs.AbiCoder.getLogDecoder(abi, logId);
15
+ return data => decode(data);
18
16
  }
19
17
 
20
- var Receipt = {
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 */