envio 2.11.10 → 2.12.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "envio",
3
- "version": "v2.11.10",
3
+ "version": "v2.12.0",
4
4
  "description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
5
5
  "bin": "./bin.js",
6
6
  "repository": {
@@ -23,10 +23,10 @@
23
23
  },
24
24
  "homepage": "https://envio.dev",
25
25
  "optionalDependencies": {
26
- "envio-linux-x64": "v2.11.10",
27
- "envio-linux-arm64": "v2.11.10",
28
- "envio-darwin-x64": "v2.11.10",
29
- "envio-darwin-arm64": "v2.11.10"
26
+ "envio-linux-x64": "v2.12.0",
27
+ "envio-linux-arm64": "v2.12.0",
28
+ "envio-darwin-x64": "v2.12.0",
29
+ "envio-darwin-arm64": "v2.12.0"
30
30
  },
31
31
  "dependencies": {
32
32
  "@envio-dev/hypersync-client": "0.6.3",
package/src/Internal.res CHANGED
@@ -90,6 +90,7 @@ type fuelEventKind =
90
90
  | Call
91
91
  type fuelEventConfig = {
92
92
  name: string,
93
+ contractName: string,
93
94
  kind: fuelEventKind,
94
95
  isWildcard: bool,
95
96
  loader: option<loader>,
@@ -26,7 +26,7 @@ let hasFilters = ({topic1, topic2, topic3}: topicSelection) => {
26
26
  For a group of topic selections, if multiple only use topic0, then they can be compressed into one
27
27
  selection combining the topic0s
28
28
  */
29
- let compressTopicSelectionsOrThrow = (topicSelections: array<topicSelection>) => {
29
+ let compressTopicSelections = (topicSelections: array<topicSelection>) => {
30
30
  let topic0sOfSelectionsWithoutFilters = []
31
31
 
32
32
  let selectionsWithFilters = []
@@ -44,7 +44,12 @@ let compressTopicSelectionsOrThrow = (topicSelections: array<topicSelection>) =>
44
44
  switch topic0sOfSelectionsWithoutFilters {
45
45
  | [] => selectionsWithFilters
46
46
  | topic0 =>
47
- let selectionWithoutFilters = makeTopicSelection(~topic0)->Utils.unwrapResultExn
47
+ let selectionWithoutFilters = {
48
+ topic0,
49
+ topic1: [],
50
+ topic2: [],
51
+ topic3: [],
52
+ }
48
53
  Belt.Array.concat([selectionWithoutFilters], selectionsWithFilters)
49
54
  }
50
55
  }
@@ -54,7 +59,7 @@ type t = {
54
59
  topicSelections: array<topicSelection>,
55
60
  }
56
61
 
57
- let makeOrThrow = (~addresses, ~topicSelections) => {
58
- let topicSelections = compressTopicSelectionsOrThrow(topicSelections)
62
+ let make = (~addresses, ~topicSelections) => {
63
+ let topicSelections = compressTopicSelections(topicSelections)
59
64
  {addresses, topicSelections}
60
65
  }
package/src/Utils.res CHANGED
@@ -354,6 +354,8 @@ module Set = {
354
354
  @send
355
355
  external add: (t<'value>, 'value) => t<'value> = "add"
356
356
 
357
+ let addMany = (set, values) => values->Js.Array2.forEach(value => set->add(value)->ignore)
358
+
357
359
  @ocaml.doc("Removes all elements from the `Set` object.") @send
358
360
  external clear: t<'value> => unit = "clear"
359
361
 
@@ -47,62 +47,20 @@ module Addresses = {
47
47
  mockAddresses[0]
48
48
  }
49
49
 
50
- module BlockTag = {
51
- type t
52
-
53
- type semanticTag = [#latest | #earliest | #pending]
54
- type hexString = string
55
- type blockNumber = int
56
-
57
- type blockTagVariant = Latest | Earliest | Pending | HexString(string) | BlockNumber(int)
58
-
59
- let blockTagFromSemantic = (semanticTag: semanticTag): t => semanticTag->Utils.magic
60
- let blockTagFromBlockNumber = (blockNumber: blockNumber): t => blockNumber->Utils.magic
61
- let blockTagFromHexString = (hexString: hexString): t => hexString->Utils.magic
62
-
63
- let blockTagFromVariant = variant =>
64
- switch variant {
65
- | Latest => #latest->blockTagFromSemantic
66
- | Earliest => #earliest->blockTagFromSemantic
67
- | Pending => #pending->blockTagFromSemantic
68
- | HexString(str) => str->blockTagFromHexString
69
- | BlockNumber(num) => num->blockTagFromBlockNumber
70
- }
71
- }
72
-
73
- module EventFilter = {
74
- type topic = EvmTypes.Hex.t
75
- type t = {
76
- address: Address.t,
77
- topics: array<topic>,
78
- }
79
- }
80
50
  module Filter = {
81
51
  type t
82
-
83
- //This can be used as a filter but should not assume all filters are the same type
84
- //address could be an array of addresses like in combined filter
85
- type filterRecord = {
86
- address: Address.t,
87
- topics: array<EventFilter.topic>,
88
- fromBlock: BlockTag.t,
89
- toBlock: BlockTag.t,
90
- }
91
-
92
- let filterFromRecord = (filterRecord: filterRecord): t => filterRecord->Utils.magic
93
52
  }
94
53
 
95
54
  module CombinedFilter = {
96
55
  type combinedFilterRecord = {
97
- address: array<Address.t>,
56
+ address?: array<Address.t>,
98
57
  //The second element of the tuple is the
99
- topics: array<array<EventFilter.topic>>,
100
- fromBlock: BlockTag.t,
101
- toBlock: BlockTag.t,
58
+ topics: array<array<EvmTypes.Hex.t>>,
59
+ fromBlock: int,
60
+ toBlock: int,
102
61
  }
103
62
 
104
- let combinedFilterToFilter = (combinedFilter: combinedFilterRecord): Filter.t =>
105
- combinedFilter->Utils.magic
63
+ let toFilter = (combinedFilter: combinedFilterRecord): Filter.t => combinedFilter->Utils.magic
106
64
  }
107
65
 
108
66
  type log = {
@@ -112,7 +70,7 @@ type log = {
112
70
  //Note: this is the index of the log in the transaction and should be used whenever we use "logIndex"
113
71
  address: Address.t,
114
72
  data: string,
115
- topics: array<EventFilter.topic>,
73
+ topics: array<EvmTypes.Hex.t>,
116
74
  transactionHash: txHash,
117
75
  transactionIndex: int,
118
76
  //Note: this logIndex is the index of the log in the block, not the transaction
@@ -121,7 +79,7 @@ type log = {
121
79
 
122
80
  type transaction
123
81
 
124
- type minimumParseableLogData = {topics: array<EventFilter.topic>, data: string}
82
+ type minimumParseableLogData = {topics: array<EvmTypes.Hex.t>, data: string}
125
83
 
126
84
  //Can safely convert from log to minimumParseableLogData since it contains
127
85
  //both data points required
@@ -26,3 +26,27 @@ type sizeOptions = {size: int}
26
26
  @module("viem") external boolToHex: (bool, ~options: sizeOptions=?) => hex = "boolToHex"
27
27
  @module("viem") external bytesToHex: (bytes, ~options: sizeOptions=?) => hex = "bytesToHex"
28
28
  @module("viem") external concat: array<hex> => hex = "concat"
29
+
30
+ exception ParseError(exn)
31
+ exception UnknownContractName({contractName: string})
32
+
33
+ let parseLogOrThrow = (
34
+ contractNameAbiMapping: dict<EvmTypes.Abi.t>,
35
+ ~contractName,
36
+ ~topics,
37
+ ~data,
38
+ ) => {
39
+ switch contractNameAbiMapping->Utils.Dict.dangerouslyGetNonOption(contractName) {
40
+ | None => raise(UnknownContractName({contractName: contractName}))
41
+ | Some(abi) =>
42
+ let viemLog: eventLog = {
43
+ abi,
44
+ data,
45
+ topics,
46
+ }
47
+
48
+ try viemLog->decodeEventLogOrThrow catch {
49
+ | exn => raise(ParseError(exn))
50
+ }
51
+ }
52
+ }
@@ -156,7 +156,7 @@ module QueryTypes = {
156
156
 
157
157
  type logParams = {
158
158
  address?: array<Address.t>,
159
- topics: array<array<Ethers.EventFilter.topic>>,
159
+ topics: array<array<EvmTypes.Hex.t>>,
160
160
  }
161
161
 
162
162
  let logParamsSchema = S.object(s => {
@@ -309,10 +309,10 @@ module ResponseTypes = {
309
309
  blockNumber?: int,
310
310
  address?: unchecksummedEthAddress,
311
311
  data?: string,
312
- topic0?: option<Ethers.EventFilter.topic>,
313
- topic1?: option<Ethers.EventFilter.topic>,
314
- topic2?: option<Ethers.EventFilter.topic>,
315
- topic3?: option<Ethers.EventFilter.topic>,
312
+ topic0?: option<EvmTypes.Hex.t>,
313
+ topic1?: option<EvmTypes.Hex.t>,
314
+ topic2?: option<EvmTypes.Hex.t>,
315
+ topic3?: option<EvmTypes.Hex.t>,
316
316
  }
317
317
 
318
318
  let logDataSchema = S.object(s => {
@@ -361,16 +361,12 @@ let queryRoute = Rest.route(() => {
361
361
  path: "/query",
362
362
  method: Post,
363
363
  variables: s => s.body(QueryTypes.postQueryBodySchema),
364
- responses: [
365
- s => s.data(ResponseTypes.queryResponseSchema),
366
- ]
364
+ responses: [s => s.data(ResponseTypes.queryResponseSchema)],
367
365
  })
368
366
 
369
367
  let heightRoute = Rest.route(() => {
370
368
  path: "/height",
371
369
  method: Get,
372
370
  variables: _ => (),
373
- responses: [
374
- s => s.field("height", S.int),
375
- ]
371
+ responses: [s => s.field("height", S.int)],
376
372
  })