envio 2.20.0 → 2.21.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/evm.schema.json +4 -2
- package/fuel.schema.json +1 -1
- package/package.json +6 -6
- package/src/Internal.gen.ts +3 -1
- package/src/Internal.res +2 -2
- package/src/Logging.res +13 -14
- package/src/Types.ts +4 -0
- package/src/Utils.res +6 -0
- package/src/bindings/Promise.res +2 -0
- package/src/db/EntityHistory.res +16 -12
- package/src/sources/HyperSyncClient.gen.ts +19 -0
- package/src/sources/HyperSyncClient.res +27 -0
package/evm.schema.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
]
|
|
28
28
|
},
|
|
29
29
|
"schema": {
|
|
30
|
-
"description": "Custom path to schema.
|
|
30
|
+
"description": "Custom path to schema.graphql file",
|
|
31
31
|
"type": [
|
|
32
32
|
"string",
|
|
33
33
|
"null"
|
|
@@ -229,6 +229,7 @@
|
|
|
229
229
|
"status",
|
|
230
230
|
"yParity",
|
|
231
231
|
"chainId",
|
|
232
|
+
"accessList",
|
|
232
233
|
"maxFeePerBlobGas",
|
|
233
234
|
"blobVersionedHashes",
|
|
234
235
|
"kind",
|
|
@@ -236,7 +237,8 @@
|
|
|
236
237
|
"l1GasPrice",
|
|
237
238
|
"l1GasUsed",
|
|
238
239
|
"l1FeeScalar",
|
|
239
|
-
"gasUsedForL1"
|
|
240
|
+
"gasUsedForL1",
|
|
241
|
+
"authorizationList"
|
|
240
242
|
]
|
|
241
243
|
},
|
|
242
244
|
"BlockField": {
|
package/fuel.schema.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envio",
|
|
3
|
-
"version": "v2.
|
|
3
|
+
"version": "v2.21.0",
|
|
4
4
|
"description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
|
|
5
5
|
"bin": "./bin.js",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://envio.dev",
|
|
27
27
|
"optionalDependencies": {
|
|
28
|
-
"envio-linux-x64": "v2.
|
|
29
|
-
"envio-linux-arm64": "v2.
|
|
30
|
-
"envio-darwin-x64": "v2.
|
|
31
|
-
"envio-darwin-arm64": "v2.
|
|
28
|
+
"envio-linux-x64": "v2.21.0",
|
|
29
|
+
"envio-linux-arm64": "v2.21.0",
|
|
30
|
+
"envio-darwin-x64": "v2.21.0",
|
|
31
|
+
"envio-darwin-arm64": "v2.21.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@envio-dev/hypersync-client": "0.6.
|
|
34
|
+
"@envio-dev/hypersync-client": "0.6.5",
|
|
35
35
|
"rescript": "11.1.3",
|
|
36
36
|
"rescript-schema": "9.3.0",
|
|
37
37
|
"viem": "2.21.0"
|
package/src/Internal.gen.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
/* tslint:disable */
|
|
5
5
|
|
|
6
|
+
import type {GenericContractRegister as $$genericContractRegister} from './Types.ts';
|
|
7
|
+
|
|
6
8
|
import type {Invalid as $$noEventFilters} from './Types.ts';
|
|
7
9
|
|
|
8
10
|
import type {t as Address_t} from './Address.gen';
|
|
@@ -22,7 +24,7 @@ export type genericLoader<args,loaderReturn> = (_1:args) => Promise<loaderReturn
|
|
|
22
24
|
|
|
23
25
|
export type genericContractRegisterArgs<event,context> = { readonly event: event; readonly context: context };
|
|
24
26
|
|
|
25
|
-
export type genericContractRegister<args> =
|
|
27
|
+
export type genericContractRegister<args> = $$genericContractRegister<args>;
|
|
26
28
|
|
|
27
29
|
export type genericHandlerArgs<event,context,loaderReturn> = {
|
|
28
30
|
readonly event: event;
|
package/src/Internal.res
CHANGED
|
@@ -35,8 +35,8 @@ type genericContractRegisterArgs<'event, 'context> = {
|
|
|
35
35
|
event: 'event,
|
|
36
36
|
context: 'context,
|
|
37
37
|
}
|
|
38
|
-
@genType
|
|
39
|
-
type genericContractRegister<'args> = 'args => unit
|
|
38
|
+
@genType.import(("./Types.ts", "GenericContractRegister"))
|
|
39
|
+
type genericContractRegister<'args> = 'args => promise<unit>
|
|
40
40
|
|
|
41
41
|
type contractRegisterContext
|
|
42
42
|
type contractRegisterArgs = genericContractRegisterArgs<event, contractRegisterContext>
|
package/src/Logging.res
CHANGED
|
@@ -150,7 +150,8 @@ let getEventLogger = (eventItem: Internal.eventItem) => {
|
|
|
150
150
|
| None => {
|
|
151
151
|
let l = getLogger()->child(
|
|
152
152
|
{
|
|
153
|
-
"
|
|
153
|
+
"contractName": eventItem.eventConfig.contractName,
|
|
154
|
+
"eventName": eventItem.eventConfig.name,
|
|
154
155
|
"chainId": eventItem.chain->ChainMap.Chain.toChainId,
|
|
155
156
|
"block": eventItem.blockNumber,
|
|
156
157
|
"logIndex": eventItem.logIndex,
|
|
@@ -162,18 +163,16 @@ let getEventLogger = (eventItem: Internal.eventItem) => {
|
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
166
|
+
@inline
|
|
167
|
+
let logForItem = (eventItem, level: Pino.logLevel, message: string, ~params=?) => {
|
|
168
|
+
(eventItem->getEventLogger->Utils.magic->Js.Dict.unsafeGet((level :> string)))(params, message)
|
|
169
|
+
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
171
|
+
let getUserLogger = (eventItem): Envio.logger => {
|
|
172
|
+
info: (message: string, ~params=?) => eventItem->logForItem(#uinfo, message, ~params?),
|
|
173
|
+
debug: (message: string, ~params=?) => eventItem->logForItem(#udebug, message, ~params?),
|
|
174
|
+
warn: (message: string, ~params=?) => eventItem->logForItem(#uwarn, message, ~params?),
|
|
175
|
+
error: (message: string, ~params=?) => eventItem->logForItem(#uerror, message, ~params?),
|
|
176
|
+
errorWithExn: (message: string, exn) =>
|
|
177
|
+
eventItem->logForItem(#uerror, message, ~params={"err": exn->Internal.prettifyExn}),
|
|
179
178
|
}
|
package/src/Types.ts
CHANGED
package/src/Utils.res
CHANGED
|
@@ -328,6 +328,8 @@ let unwrapResultExn = res =>
|
|
|
328
328
|
external queueMicrotask: (unit => unit) => unit = "queueMicrotask"
|
|
329
329
|
|
|
330
330
|
module Schema = {
|
|
331
|
+
let variantTag = S.union([S.string, S.object(s => s.field("TAG", S.string))])
|
|
332
|
+
|
|
331
333
|
let getNonOptionalFieldNames = schema => {
|
|
332
334
|
let acc = []
|
|
333
335
|
switch schema->S.classify {
|
|
@@ -385,6 +387,10 @@ module Schema = {
|
|
|
385
387
|
}
|
|
386
388
|
}
|
|
387
389
|
|
|
390
|
+
let getVariantsTags = variants => {
|
|
391
|
+
variants->Js.Array2.map(variant => variant->S.parseOrThrow(Schema.variantTag))
|
|
392
|
+
}
|
|
393
|
+
|
|
388
394
|
module Set = {
|
|
389
395
|
type t<'value>
|
|
390
396
|
|
package/src/bindings/Promise.res
CHANGED
package/src/db/EntityHistory.res
CHANGED
|
@@ -24,6 +24,15 @@ type historyRow<'entity> = {
|
|
|
24
24
|
current: historyFields,
|
|
25
25
|
previous: option<historyFields>,
|
|
26
26
|
entityData: entityData<'entity>,
|
|
27
|
+
// In the event of a rollback, some entity updates may have been
|
|
28
|
+
// been affected by a rollback diff. If there was no rollback diff
|
|
29
|
+
// this will always be false.
|
|
30
|
+
// If there was a rollback diff, this will be false in the case of a
|
|
31
|
+
// new entity update (where entity affected is not present in the diff) b
|
|
32
|
+
// but true if the update is related to an entity that is
|
|
33
|
+
// currently present in the diff
|
|
34
|
+
// Optional since it's discarded during parsing/serialization
|
|
35
|
+
containsRollbackDiffChange?: bool,
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
type previousHistoryFields = historyFieldsGeneral<option<int>>
|
|
@@ -134,6 +143,7 @@ type t<'entity> = {
|
|
|
134
143
|
table: table,
|
|
135
144
|
createInsertFnQuery: string,
|
|
136
145
|
schema: S.t<historyRow<'entity>>,
|
|
146
|
+
// Used for parsing
|
|
137
147
|
schemaRows: S.t<array<historyRow<'entity>>>,
|
|
138
148
|
insertFn: (Postgres.sql, Js.Json.t, ~shouldCopyCurrentEntity: bool) => promise<unit>,
|
|
139
149
|
}
|
|
@@ -148,19 +158,13 @@ let insertRow = (
|
|
|
148
158
|
self.insertFn(sql, row, ~shouldCopyCurrentEntity)
|
|
149
159
|
}
|
|
150
160
|
|
|
151
|
-
let batchInsertRows = (
|
|
152
|
-
self: t<'entity>,
|
|
153
|
-
~sql,
|
|
154
|
-
~rows: array<historyRow<'entity>>,
|
|
155
|
-
~shouldCopyCurrentEntity,
|
|
156
|
-
) => {
|
|
157
|
-
let rows =
|
|
158
|
-
rows
|
|
159
|
-
->S.reverseConvertToJsonOrThrow(self.schemaRows)
|
|
160
|
-
->(Utils.magic: Js.Json.t => array<Js.Json.t>)
|
|
161
|
+
let batchInsertRows = (self: t<'entity>, ~sql, ~rows: array<historyRow<'entity>>) => {
|
|
161
162
|
rows
|
|
162
|
-
->Belt.Array.map(
|
|
163
|
-
|
|
163
|
+
->Belt.Array.map(historyRow => {
|
|
164
|
+
let containsRollbackDiffChange =
|
|
165
|
+
historyRow.containsRollbackDiffChange->Belt.Option.getWithDefault(false)
|
|
166
|
+
let shouldCopyCurrentEntity = !containsRollbackDiffChange
|
|
167
|
+
self->insertRow(~sql, ~historyRow, ~shouldCopyCurrentEntity)
|
|
164
168
|
})
|
|
165
169
|
->Promise.all
|
|
166
170
|
->Promise.thenResolve(_ => ())
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* TypeScript file generated from HyperSyncClient.res by genType. */
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/* tslint:disable */
|
|
5
|
+
|
|
6
|
+
import type {t as Address_t} from '../../src/Address.gen';
|
|
7
|
+
|
|
8
|
+
export type ResponseTypes_accessList = { readonly address?: Address_t; readonly storageKeys?: string[] };
|
|
9
|
+
|
|
10
|
+
export type ResponseTypes_authorizationList = {
|
|
11
|
+
readonly chainId: bigint;
|
|
12
|
+
readonly address: Address_t;
|
|
13
|
+
readonly nonce: number;
|
|
14
|
+
readonly yParity:
|
|
15
|
+
1
|
|
16
|
+
| 0;
|
|
17
|
+
readonly r: string;
|
|
18
|
+
readonly s: string
|
|
19
|
+
};
|
|
@@ -75,6 +75,7 @@ module QueryTypes = {
|
|
|
75
75
|
| L1GasUsed
|
|
76
76
|
| L1FeeScalar
|
|
77
77
|
| GasUsedForL1
|
|
78
|
+
| AuthorizationList
|
|
78
79
|
|
|
79
80
|
type logField =
|
|
80
81
|
| Removed
|
|
@@ -302,11 +303,36 @@ module ResponseTypes = {
|
|
|
302
303
|
mixHash?: string,
|
|
303
304
|
}
|
|
304
305
|
|
|
306
|
+
@genType
|
|
305
307
|
type accessList = {
|
|
306
308
|
address?: Address.t,
|
|
307
309
|
storageKeys?: array<string>,
|
|
308
310
|
}
|
|
309
311
|
|
|
312
|
+
let accessListSchema = S.object(s => {
|
|
313
|
+
address: ?s.field("address", S.option(Address.schema)),
|
|
314
|
+
storageKeys: ?s.field("storageKeys", S.option(S.array(S.string))),
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
@genType
|
|
318
|
+
type authorizationList = {
|
|
319
|
+
chainId: bigint,
|
|
320
|
+
address: Address.t,
|
|
321
|
+
nonce: int,
|
|
322
|
+
yParity: [#0 | #1],
|
|
323
|
+
r: string,
|
|
324
|
+
s: string,
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
let authorizationListSchema = S.object(s => {
|
|
328
|
+
chainId: s.field("chainId", S.bigint),
|
|
329
|
+
address: s.field("address", Address.schema),
|
|
330
|
+
nonce: s.field("nonce", S.int),
|
|
331
|
+
yParity: s.field("yParity", S.enum([#0, #1])),
|
|
332
|
+
r: s.field("r", S.string),
|
|
333
|
+
s: s.field("s", S.string),
|
|
334
|
+
})
|
|
335
|
+
|
|
310
336
|
type transaction = {
|
|
311
337
|
blockHash?: string,
|
|
312
338
|
blockNumber?: int,
|
|
@@ -342,6 +368,7 @@ module ResponseTypes = {
|
|
|
342
368
|
l1GasUsed?: bigint,
|
|
343
369
|
l1FeeScalar?: int,
|
|
344
370
|
gasUsedForL1?: bigint,
|
|
371
|
+
authorizationList?: array<authorizationList>,
|
|
345
372
|
}
|
|
346
373
|
|
|
347
374
|
type log = {
|