envio 3.0.0-alpha.0 → 3.0.0-alpha.10
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/README.md +2 -2
- package/evm.schema.json +53 -57
- package/fuel.schema.json +35 -31
- package/index.d.ts +446 -1
- package/index.js +4 -0
- package/package.json +23 -11
- package/rescript.json +4 -1
- package/src/Batch.res.mjs +1 -1
- package/src/Benchmark.res +394 -0
- package/src/Benchmark.res.mjs +398 -0
- package/src/ChainFetcher.res +526 -0
- package/src/ChainFetcher.res.mjs +343 -0
- package/src/ChainManager.res +182 -0
- package/src/ChainManager.res.mjs +150 -0
- package/src/Config.res +367 -27
- package/src/Config.res.mjs +338 -28
- package/src/{Indexer.res → Ctx.res} +1 -1
- package/src/Ecosystem.res +25 -0
- package/src/Ecosystem.res.mjs +29 -0
- package/src/Env.res +252 -0
- package/src/Env.res.mjs +271 -0
- package/src/Envio.gen.ts +9 -1
- package/src/Envio.res +12 -9
- package/src/EventProcessing.res +476 -0
- package/src/EventProcessing.res.mjs +341 -0
- package/src/EventRegister.res +4 -15
- package/src/EventRegister.res.mjs +3 -9
- package/src/EventRegister.resi +2 -8
- package/src/FetchState.res +54 -29
- package/src/FetchState.res.mjs +62 -35
- package/src/GlobalState.res +1163 -0
- package/src/GlobalState.res.mjs +1196 -0
- package/src/GlobalStateManager.res +68 -0
- package/src/GlobalStateManager.res.mjs +75 -0
- package/src/GlobalStateManager.resi +7 -0
- package/src/HandlerLoader.res +89 -0
- package/src/HandlerLoader.res.mjs +79 -0
- package/src/Internal.gen.ts +3 -14
- package/src/Internal.res +45 -13
- package/src/LoadLayer.res +444 -0
- package/src/LoadLayer.res.mjs +296 -0
- package/src/LoadLayer.resi +32 -0
- package/src/LogSelection.res +33 -27
- package/src/LogSelection.res.mjs +6 -0
- package/src/Logging.res +11 -4
- package/src/Logging.res.mjs +14 -6
- package/src/Main.res +351 -0
- package/src/Main.res.mjs +312 -0
- package/src/Persistence.res +1 -2
- package/src/PgStorage.gen.ts +10 -0
- package/src/PgStorage.res +28 -34
- package/src/PgStorage.res.d.mts +5 -0
- package/src/PgStorage.res.mjs +27 -27
- package/src/Prometheus.res +8 -8
- package/src/Prometheus.res.mjs +10 -10
- package/src/ReorgDetection.res +6 -10
- package/src/ReorgDetection.res.mjs +6 -6
- package/src/TestIndexer.res +536 -0
- package/src/TestIndexer.res.mjs +412 -0
- package/src/TestIndexerProxyStorage.res +210 -0
- package/src/TestIndexerProxyStorage.res.mjs +157 -0
- package/src/Types.ts +1 -1
- package/src/UserContext.res +355 -0
- package/src/UserContext.res.mjs +236 -0
- package/src/Utils.res +28 -0
- package/src/Utils.res.mjs +18 -0
- package/src/bindings/ClickHouse.res +31 -1
- package/src/bindings/ClickHouse.res.mjs +27 -1
- package/src/bindings/DateFns.res +71 -0
- package/src/bindings/DateFns.res.mjs +22 -0
- package/src/bindings/Ethers.res +27 -67
- package/src/bindings/Ethers.res.mjs +18 -70
- package/src/bindings/EventSource.res +13 -0
- package/src/bindings/EventSource.res.mjs +2 -0
- package/src/bindings/NodeJs.res +44 -3
- package/src/bindings/NodeJs.res.mjs +11 -3
- package/src/bindings/Pino.res +21 -7
- package/src/bindings/Pino.res.mjs +11 -5
- package/src/bindings/Postgres.gen.ts +8 -0
- package/src/bindings/Postgres.res +3 -0
- package/src/bindings/Postgres.res.d.mts +5 -0
- package/src/bindings/RescriptMocha.res +123 -0
- package/src/bindings/RescriptMocha.res.mjs +18 -0
- package/src/bindings/Vitest.res +134 -0
- package/src/bindings/Vitest.res.mjs +9 -0
- package/src/bindings/Yargs.res +8 -0
- package/src/bindings/Yargs.res.mjs +2 -0
- package/src/db/InternalTable.res +2 -0
- package/src/db/InternalTable.res.mjs +1 -1
- package/src/sources/Evm.res +87 -0
- package/src/sources/Evm.res.mjs +105 -0
- package/src/sources/EvmChain.res +90 -0
- package/src/sources/EvmChain.res.mjs +57 -0
- package/src/sources/Fuel.res +19 -34
- package/src/sources/Fuel.res.mjs +34 -16
- package/src/sources/FuelSDK.res +38 -0
- package/src/sources/FuelSDK.res.mjs +29 -0
- package/src/sources/HyperFuel.res +2 -2
- package/src/sources/HyperFuel.resi +1 -1
- package/src/sources/HyperFuelClient.res +2 -2
- package/src/sources/HyperFuelSource.res +8 -8
- package/src/sources/HyperFuelSource.res.mjs +5 -5
- package/src/sources/HyperSyncHeightStream.res +97 -0
- package/src/sources/HyperSyncHeightStream.res.mjs +94 -0
- package/src/sources/HyperSyncSource.res +64 -172
- package/src/sources/HyperSyncSource.res.mjs +73 -155
- package/src/sources/Rpc.res +43 -0
- package/src/sources/Rpc.res.mjs +31 -0
- package/src/sources/RpcSource.res +32 -130
- package/src/sources/RpcSource.res.mjs +47 -121
- package/src/sources/Source.res +3 -2
- package/src/sources/SourceManager.res +183 -108
- package/src/sources/SourceManager.res.mjs +162 -99
- package/src/sources/SourceManager.resi +4 -5
- package/src/sources/Svm.res +59 -0
- package/src/sources/Svm.res.mjs +79 -0
- package/src/tui/Tui.res +266 -0
- package/src/tui/Tui.res.mjs +342 -0
- package/src/tui/bindings/Ink.res +376 -0
- package/src/tui/bindings/Ink.res.mjs +75 -0
- package/src/tui/bindings/Style.res +123 -0
- package/src/tui/bindings/Style.res.mjs +2 -0
- package/src/tui/components/BufferedProgressBar.res +40 -0
- package/src/tui/components/BufferedProgressBar.res.mjs +57 -0
- package/src/tui/components/CustomHooks.res +122 -0
- package/src/tui/components/CustomHooks.res.mjs +179 -0
- package/src/tui/components/Messages.res +41 -0
- package/src/tui/components/Messages.res.mjs +75 -0
- package/src/tui/components/SyncETA.res +193 -0
- package/src/tui/components/SyncETA.res.mjs +269 -0
- package/src/tui/components/TuiData.res +46 -0
- package/src/tui/components/TuiData.res.mjs +29 -0
- package/src/Platform.res +0 -140
- package/src/Platform.res.mjs +0 -170
- package/src/bindings/Ethers.gen.ts +0 -14
- /package/src/{Indexer.res.mjs → Ctx.res.mjs} +0 -0
|
@@ -2,52 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Ethers from "ethers";
|
|
4
4
|
import * as Address from "../Address.res.mjs";
|
|
5
|
-
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
6
|
-
import * as Caml_array from "rescript/lib/es6/caml_array.js";
|
|
7
5
|
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
8
6
|
|
|
9
|
-
function makeAbi(abi) {
|
|
10
|
-
return abi;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
var getAddressFromStringUnsafe = Address.Evm.fromStringOrThrow;
|
|
14
|
-
|
|
15
|
-
function ethAddressToString(prim) {
|
|
16
|
-
return prim;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
7
|
var Constants = {};
|
|
20
8
|
|
|
21
|
-
var mockAddresses = Belt_Array.map([
|
|
22
|
-
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
23
|
-
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
|
24
|
-
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
|
25
|
-
"0x90F79bf6EB2c4f870365E785982E1f101E93b906",
|
|
26
|
-
"0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
|
|
27
|
-
"0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
|
|
28
|
-
"0x976EA74026E726554dB657fA54763abd0C3a0aa9",
|
|
29
|
-
"0x14dC79964da2C08b23698B3D3cc7Ca32193d9955",
|
|
30
|
-
"0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f",
|
|
31
|
-
"0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
|
|
32
|
-
"0xBcd4042DE499D14e55001CcbB24a551F3b954096",
|
|
33
|
-
"0x71bE63f3384f5fb98995898A86B02Fb2426c5788",
|
|
34
|
-
"0xFABB0ac9d68B0B445fB7357272Ff202C5651694a",
|
|
35
|
-
"0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec",
|
|
36
|
-
"0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097",
|
|
37
|
-
"0xcd3B766CCDd6AE721141F452C550Ca635964ce71",
|
|
38
|
-
"0x2546BcD3c84621e976D8185a91A922aE77ECEc30",
|
|
39
|
-
"0xbDA5747bFD65F08deb54cb465eB87D40e51B197E",
|
|
40
|
-
"0xdD2FD4581271e230360230F9337D5c0430Bf44C0",
|
|
41
|
-
"0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199"
|
|
42
|
-
], getAddressFromStringUnsafe);
|
|
43
|
-
|
|
44
|
-
var defaultAddress = Caml_array.get(mockAddresses, 0);
|
|
45
|
-
|
|
46
|
-
var Addresses = {
|
|
47
|
-
mockAddresses: mockAddresses,
|
|
48
|
-
defaultAddress: defaultAddress
|
|
49
|
-
};
|
|
50
|
-
|
|
51
9
|
var Filter = {};
|
|
52
10
|
|
|
53
11
|
function toFilter(combinedFilter) {
|
|
@@ -81,26 +39,23 @@ function makeGetTransactionFields(getTransactionByHash, lowercaseAddresses) {
|
|
|
81
39
|
return async function (log) {
|
|
82
40
|
var transaction = await getTransactionByHash(log.transactionHash);
|
|
83
41
|
transaction.transactionIndex = log.transactionIndex;
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} else {
|
|
102
|
-
transaction.contractAddress = contractAddress.toLowerCase();
|
|
103
|
-
}
|
|
42
|
+
var from = transaction.from;
|
|
43
|
+
if (from === null || from === undefined) {
|
|
44
|
+
from === null;
|
|
45
|
+
} else {
|
|
46
|
+
transaction.from = lowercaseAddresses ? from.toLowerCase() : Address.Evm.fromStringOrThrow(from);
|
|
47
|
+
}
|
|
48
|
+
var to = transaction.to;
|
|
49
|
+
if (to === null || to === undefined) {
|
|
50
|
+
to === null;
|
|
51
|
+
} else {
|
|
52
|
+
transaction.to = lowercaseAddresses ? to.toLowerCase() : Address.Evm.fromStringOrThrow(to);
|
|
53
|
+
}
|
|
54
|
+
var contractAddress = transaction.contractAddress;
|
|
55
|
+
if (contractAddress === null || contractAddress === undefined) {
|
|
56
|
+
contractAddress === null;
|
|
57
|
+
} else {
|
|
58
|
+
transaction.contractAddress = lowercaseAddresses ? contractAddress.toLowerCase() : Address.Evm.fromStringOrThrow(contractAddress);
|
|
104
59
|
}
|
|
105
60
|
return transaction;
|
|
106
61
|
};
|
|
@@ -112,19 +67,12 @@ var JsonRpcProvider = {
|
|
|
112
67
|
makeGetTransactionFields: makeGetTransactionFields
|
|
113
68
|
};
|
|
114
69
|
|
|
115
|
-
var ethAddressSchema = Address.schema;
|
|
116
|
-
|
|
117
70
|
export {
|
|
118
|
-
makeAbi ,
|
|
119
|
-
getAddressFromStringUnsafe ,
|
|
120
|
-
ethAddressToString ,
|
|
121
|
-
ethAddressSchema ,
|
|
122
71
|
Constants ,
|
|
123
|
-
Addresses ,
|
|
124
72
|
Filter ,
|
|
125
73
|
CombinedFilter ,
|
|
126
74
|
logToMinimumParseableLogData ,
|
|
127
75
|
Network ,
|
|
128
76
|
JsonRpcProvider ,
|
|
129
77
|
}
|
|
130
|
-
/*
|
|
78
|
+
/* ethers Not a pure module */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type t
|
|
2
|
+
|
|
3
|
+
type options = {headers?: Js.Dict.t<string>}
|
|
4
|
+
|
|
5
|
+
@module("eventsource") @new
|
|
6
|
+
external create: (~url: string, ~options: options=?) => t = "EventSource"
|
|
7
|
+
|
|
8
|
+
@set external onopen: (t, unit => unit) => unit = "onopen"
|
|
9
|
+
@set external onerror: (t, Js.Exn.t => unit) => unit = "onerror"
|
|
10
|
+
|
|
11
|
+
type event = {data: string}
|
|
12
|
+
@send external addEventListener: (t, string, event => unit) => unit = "addEventListener"
|
|
13
|
+
@send external close: t => unit = "close"
|
package/src/bindings/NodeJs.res
CHANGED
|
@@ -36,8 +36,9 @@ module Util = {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
module Process = {
|
|
39
|
-
type t = {env: Js.Dict.t<string>}
|
|
39
|
+
type t = {env: Js.Dict.t<string>, execArgv: array<string>}
|
|
40
40
|
@module external process: t = "process"
|
|
41
|
+
@module("process") external cwd: unit => string = "cwd"
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
module ChildProcess = {
|
|
@@ -59,11 +60,24 @@ module ChildProcess = {
|
|
|
59
60
|
module Url = {
|
|
60
61
|
type t
|
|
61
62
|
@module("url") external fileURLToPath: t => string = "fileURLToPath"
|
|
63
|
+
@module("url") external fileURLToPathFromString: string => string = "fileURLToPath"
|
|
64
|
+
// Convert a file path to a file:// URL string (for dynamic imports)
|
|
65
|
+
@module("url") external pathToFileURL: string => t = "pathToFileURL"
|
|
66
|
+
@send external toString: t => string = "toString"
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
module ImportMeta = {
|
|
65
70
|
type t = {url: Url.t}
|
|
66
71
|
@val external importMeta: t = "import.meta"
|
|
72
|
+
// Get import.meta.url as string for module registration
|
|
73
|
+
@val external url: string = "import.meta.url"
|
|
74
|
+
// Resolve module specifier to file:// URL
|
|
75
|
+
@val external resolve: string => string = "import.meta.resolve"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module Module = {
|
|
79
|
+
// Register ESM loader hooks (e.g., for TypeScript support via tsx)
|
|
80
|
+
@module("node:module") external register: (string, string) => unit = "register"
|
|
67
81
|
}
|
|
68
82
|
|
|
69
83
|
module Path = {
|
|
@@ -77,8 +91,35 @@ module Path = {
|
|
|
77
91
|
|
|
78
92
|
external toString: t => string = "%identity"
|
|
79
93
|
|
|
80
|
-
// ESM-compatible __dirname replacement
|
|
81
|
-
let
|
|
94
|
+
// ESM-compatible __dirname replacement - accepts importMeta from calling file
|
|
95
|
+
let getDirname = (importMeta: ImportMeta.t) => dirname(Url.fileURLToPath(importMeta.url))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module WorkerThreads = {
|
|
99
|
+
// Check if we're in the main thread or a worker
|
|
100
|
+
@module("worker_threads") external isMainThread: bool = "isMainThread"
|
|
101
|
+
|
|
102
|
+
// Worker data passed from main thread
|
|
103
|
+
@module("worker_threads") external workerData: Js.Nullable.t<'a> = "workerData"
|
|
104
|
+
|
|
105
|
+
// MessagePort for communication with parent
|
|
106
|
+
type messagePort
|
|
107
|
+
@module("worker_threads") external parentPort: Js.Nullable.t<messagePort> = "parentPort"
|
|
108
|
+
@send external postMessage: (messagePort, 'a) => unit = "postMessage"
|
|
109
|
+
@send external onPortMessage: (messagePort, @as("message") _, 'a => unit) => unit = "on"
|
|
110
|
+
|
|
111
|
+
// Worker class for spawning workers
|
|
112
|
+
type worker
|
|
113
|
+
type workerOptions = {workerData?: Js.Json.t, execArgv?: array<string>}
|
|
114
|
+
|
|
115
|
+
@new @module("worker_threads")
|
|
116
|
+
external makeWorker: (string, workerOptions) => worker = "Worker"
|
|
117
|
+
|
|
118
|
+
@send external onMessage: (worker, @as("message") _, 'a => unit) => unit = "on"
|
|
119
|
+
@send external onError: (worker, @as("error") _, exn => unit) => unit = "on"
|
|
120
|
+
@send external onExit: (worker, @as("exit") _, int => unit) => unit = "on"
|
|
121
|
+
@send external terminate: worker => promise<int> = "terminate"
|
|
122
|
+
@send external workerPostMessage: (worker, 'a) => unit = "postMessage"
|
|
82
123
|
}
|
|
83
124
|
|
|
84
125
|
module Fs = {
|
|
@@ -24,12 +24,18 @@ var Url$1 = {};
|
|
|
24
24
|
|
|
25
25
|
var ImportMeta = {};
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var Module = {};
|
|
28
|
+
|
|
29
|
+
function getDirname(importMeta) {
|
|
30
|
+
return Path.dirname(Url.fileURLToPath(importMeta.url));
|
|
31
|
+
}
|
|
28
32
|
|
|
29
33
|
var Path$1 = {
|
|
30
|
-
|
|
34
|
+
getDirname: getDirname
|
|
31
35
|
};
|
|
32
36
|
|
|
37
|
+
var WorkerThreads = {};
|
|
38
|
+
|
|
33
39
|
var Promises = {};
|
|
34
40
|
|
|
35
41
|
var Fs = {
|
|
@@ -42,7 +48,9 @@ export {
|
|
|
42
48
|
ChildProcess ,
|
|
43
49
|
Url$1 as Url,
|
|
44
50
|
ImportMeta ,
|
|
51
|
+
Module ,
|
|
45
52
|
Path$1 as Path,
|
|
53
|
+
WorkerThreads ,
|
|
46
54
|
Fs ,
|
|
47
55
|
}
|
|
48
|
-
/*
|
|
56
|
+
/* url Not a pure module */
|
package/src/bindings/Pino.res
CHANGED
|
@@ -5,6 +5,7 @@ type logLevelBuiltin = [
|
|
|
5
5
|
| #warn
|
|
6
6
|
| #error
|
|
7
7
|
| #fatal
|
|
8
|
+
| #silent
|
|
8
9
|
]
|
|
9
10
|
@genType
|
|
10
11
|
type logLevelUser = [
|
|
@@ -108,8 +109,8 @@ let createChildParams: 'a => childParams = Utils.magic
|
|
|
108
109
|
@send external child: (t, childParams) => t = "child"
|
|
109
110
|
|
|
110
111
|
module ECS = {
|
|
111
|
-
@module
|
|
112
|
-
external make: 'a => options = "
|
|
112
|
+
@module("@elastic/ecs-pino-format")
|
|
113
|
+
external make: 'a => options = "default"
|
|
113
114
|
let make = make
|
|
114
115
|
}
|
|
115
116
|
|
|
@@ -132,15 +133,28 @@ module MultiStreamLogger = {
|
|
|
132
133
|
}
|
|
133
134
|
@module("pino") external destination: destinationOpts => stream = "destination"
|
|
134
135
|
|
|
135
|
-
type prettyFactoryOpts = {...options, customColors?: string}
|
|
136
|
+
type prettyFactoryOpts = {...options, customColors?: string, colorize?: bool}
|
|
136
137
|
@module("pino-pretty")
|
|
137
138
|
external prettyFactory: prettyFactoryOpts => string => string = "prettyFactory"
|
|
138
139
|
|
|
139
140
|
let makeFormatter = logLevels => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
let customColors = "fatal:bgRed,error:red,warn:yellow,info:green,udebug:bgBlue,uinfo:bgGreen,uwarn:bgYellow,uerror:bgRed,debug:blue,trace:gray"
|
|
142
|
+
// Force colors when running for logs format test
|
|
143
|
+
let options = switch %raw(`"ENVIO_TEST_LOGGING_FORMAT" in process.env`) {
|
|
144
|
+
| Some(_) => {
|
|
145
|
+
customLevels: logLevels,
|
|
146
|
+
customColors,
|
|
147
|
+
colorize: true,
|
|
148
|
+
}
|
|
149
|
+
// For some reason setting colorize as undefined,
|
|
150
|
+
// makes it behave as false.
|
|
151
|
+
| None => {
|
|
152
|
+
customLevels: logLevels,
|
|
153
|
+
customColors,
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
prettyFactory(options)
|
|
144
158
|
}
|
|
145
159
|
|
|
146
160
|
let makeStreams = (~userLogLevel, ~formatter, ~logFile, ~defaultFileLogLevel) => {
|
|
@@ -6,7 +6,7 @@ import * as Caml_obj from "rescript/lib/es6/caml_obj.js";
|
|
|
6
6
|
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
7
7
|
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
8
8
|
import * as PinoPretty from "pino-pretty";
|
|
9
|
-
import
|
|
9
|
+
import EcsPinoFormat from "@elastic/ecs-pino-format";
|
|
10
10
|
|
|
11
11
|
function createPinoMessage(message) {
|
|
12
12
|
return message;
|
|
@@ -40,10 +40,16 @@ var ECS = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
function makeFormatter(logLevels) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
var customColors = "fatal:bgRed,error:red,warn:yellow,info:green,udebug:bgBlue,uinfo:bgGreen,uwarn:bgYellow,uerror:bgRed,debug:blue,trace:gray";
|
|
44
|
+
var match = ("ENVIO_TEST_LOGGING_FORMAT" in process.env);
|
|
45
|
+
return PinoPretty.prettyFactory(match !== undefined ? ({
|
|
46
|
+
customLevels: logLevels,
|
|
47
|
+
customColors: customColors,
|
|
48
|
+
colorize: true
|
|
49
|
+
}) : ({
|
|
50
|
+
customLevels: logLevels,
|
|
51
|
+
customColors: customColors
|
|
52
|
+
}));
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
function makeStreams(userLogLevel, formatter, logFile, defaultFileLogLevel) {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
module Assert = {
|
|
2
|
+
type assertion<'a> = ('a, 'a, ~message: string=?) => unit
|
|
3
|
+
|
|
4
|
+
@module("assert") external equal: assertion<'a> = "equal"
|
|
5
|
+
@module("assert") external notEqual: assertion<'a> = "notEqual"
|
|
6
|
+
|
|
7
|
+
@module("assert") external deepEqual: assertion<'a> = "deepEqual"
|
|
8
|
+
@module("assert")
|
|
9
|
+
external notDeepEqual: assertion<'a> = "notDeepEqual"
|
|
10
|
+
|
|
11
|
+
@module("assert") external strictEqual: assertion<'a> = "strictEqual"
|
|
12
|
+
@module("assert")
|
|
13
|
+
external notStrictEqual: assertion<'a> = "notStrictEqual"
|
|
14
|
+
|
|
15
|
+
@module("assert")
|
|
16
|
+
external deepStrictEqual: assertion<'a> = "deepStrictEqual"
|
|
17
|
+
@module("assert")
|
|
18
|
+
external notDeepStrictEqual: assertion<'a> = "notDeepStrictEqual"
|
|
19
|
+
|
|
20
|
+
@module("assert") external ifError: 'a => unit = "ifError"
|
|
21
|
+
|
|
22
|
+
@module("assert")
|
|
23
|
+
external throws: (unit => 'a, ~error: 'error=?, ~message: string=?) => unit = "throws"
|
|
24
|
+
@module("assert")
|
|
25
|
+
external doesNotThrow: (unit => 'a, ~error: 'error=?, ~message: string=?) => unit = "doesNotThrow"
|
|
26
|
+
|
|
27
|
+
@module("assert")
|
|
28
|
+
external rejects: (unit => promise<'a>, ~error: 'error=?, ~message: string=?) => promise<unit> =
|
|
29
|
+
"rejects"
|
|
30
|
+
|
|
31
|
+
@module("assert") external ok: (bool, ~message: string=?) => unit = "ok"
|
|
32
|
+
@module("assert") external fail: string => 'a = "fail"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Mocha bindings on `this` for `describe` and `it` functions */
|
|
36
|
+
module This = {
|
|
37
|
+
@val external timeout: int => unit = "this.timeout"
|
|
38
|
+
@val external retries: int => unit = "this.retries"
|
|
39
|
+
@val external slow: int => unit = "this.slow"
|
|
40
|
+
@val external skip: unit => unit = "this.skip"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@val
|
|
44
|
+
external describe: (string, unit => unit) => unit = "describe"
|
|
45
|
+
@val
|
|
46
|
+
external describe_only: (string, unit => unit) => unit = "describe.only"
|
|
47
|
+
@val
|
|
48
|
+
external describe_skip: (string, unit => unit) => unit = "describe.skip"
|
|
49
|
+
|
|
50
|
+
@val
|
|
51
|
+
external it: (string, unit => unit) => unit = "it"
|
|
52
|
+
@val
|
|
53
|
+
external it_only: (string, unit => unit) => unit = "it.only"
|
|
54
|
+
@val
|
|
55
|
+
external it_skip: (string, unit => unit) => unit = "it.skip"
|
|
56
|
+
@val
|
|
57
|
+
external before: (unit => unit) => unit = "before"
|
|
58
|
+
@val
|
|
59
|
+
external after: (unit => unit) => unit = "after"
|
|
60
|
+
@val
|
|
61
|
+
external beforeEach: (unit => unit) => unit = "beforeEach"
|
|
62
|
+
@val
|
|
63
|
+
external afterEach: (unit => unit) => unit = "afterEach"
|
|
64
|
+
@val
|
|
65
|
+
external beforeWithTitle: (string, unit => unit) => unit = "before"
|
|
66
|
+
@val
|
|
67
|
+
external afterWithTitle: (string, unit => unit) => unit = "after"
|
|
68
|
+
@val
|
|
69
|
+
external beforeEachWithTitle: (string, unit => unit) => unit = "beforeEach"
|
|
70
|
+
@val
|
|
71
|
+
external afterEachWithTitle: (string, unit => unit) => unit = "afterEach"
|
|
72
|
+
|
|
73
|
+
module Async = {
|
|
74
|
+
@val
|
|
75
|
+
external it: (string, unit => promise<unit>) => unit = "it"
|
|
76
|
+
@val
|
|
77
|
+
external it_only: (string, unit => promise<unit>) => unit = "it.only"
|
|
78
|
+
@val
|
|
79
|
+
external it_skip: (string, unit => promise<unit>) => unit = "it.skip"
|
|
80
|
+
@val
|
|
81
|
+
external before: (unit => promise<unit>) => unit = "before"
|
|
82
|
+
@val
|
|
83
|
+
external after: (unit => promise<unit>) => unit = "after"
|
|
84
|
+
@val
|
|
85
|
+
external beforeEach: (unit => promise<unit>) => unit = "beforeEach"
|
|
86
|
+
@val
|
|
87
|
+
external afterEach: (unit => promise<unit>) => unit = "afterEach"
|
|
88
|
+
@val
|
|
89
|
+
external beforeWithTitle: (string, unit => promise<unit>) => unit = "before"
|
|
90
|
+
@val
|
|
91
|
+
external afterWithTitle: (string, unit => promise<unit>) => unit = "after"
|
|
92
|
+
@val
|
|
93
|
+
external beforeEachWithTitle: (string, unit => promise<unit>) => unit = "beforeEach"
|
|
94
|
+
@val
|
|
95
|
+
external afterEachWithTitle: (string, unit => promise<unit>) => unit = "afterEach"
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module DoneCallback = {
|
|
99
|
+
type doneCallback = Js.Nullable.t<Js.Exn.t> => unit
|
|
100
|
+
|
|
101
|
+
@val
|
|
102
|
+
external it: (string, doneCallback => unit) => unit = "it"
|
|
103
|
+
@val
|
|
104
|
+
external it_only: (string, doneCallback => unit) => unit = "it.only"
|
|
105
|
+
@val
|
|
106
|
+
external it_skip: (string, doneCallback => unit) => unit = "it.skip"
|
|
107
|
+
@val
|
|
108
|
+
external before: (doneCallback => unit) => unit = "before"
|
|
109
|
+
@val
|
|
110
|
+
external after: (doneCallback => unit) => unit = "after"
|
|
111
|
+
@val
|
|
112
|
+
external beforeEach: (doneCallback => unit) => unit = "beforeEach"
|
|
113
|
+
@val
|
|
114
|
+
external afterEach: (doneCallback => unit) => unit = "afterEach"
|
|
115
|
+
@val
|
|
116
|
+
external beforeWithTitle: (string, doneCallback => unit) => unit = "before"
|
|
117
|
+
@val
|
|
118
|
+
external afterWithTitle: (string, doneCallback => unit) => unit = "after"
|
|
119
|
+
@val
|
|
120
|
+
external beforeEachWithTitle: (string, doneCallback => unit) => unit = "beforeEach"
|
|
121
|
+
@val
|
|
122
|
+
external afterEachWithTitle: (string, doneCallback => unit) => unit = "afterEach"
|
|
123
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Minimal Vitest bindings for ReScript
|
|
2
|
+
|
|
3
|
+
// Expectation object returned by expect()
|
|
4
|
+
type rec expectation<'a> = {
|
|
5
|
+
// Equality matchers
|
|
6
|
+
toBe: 'a => unit,
|
|
7
|
+
toEqual: 'a => unit,
|
|
8
|
+
toStrictEqual: 'a => unit,
|
|
9
|
+
// Truthiness matchers
|
|
10
|
+
toBeTruthy: unit => unit,
|
|
11
|
+
toBeFalsy: unit => unit,
|
|
12
|
+
toBeNull: unit => unit,
|
|
13
|
+
toBeUndefined: unit => unit,
|
|
14
|
+
toBeDefined: unit => unit,
|
|
15
|
+
// Number matchers
|
|
16
|
+
toBeGreaterThan: 'a => unit,
|
|
17
|
+
toBeGreaterThanOrEqual: 'a => unit,
|
|
18
|
+
toBeLessThan: 'a => unit,
|
|
19
|
+
toBeLessThanOrEqual: 'a => unit,
|
|
20
|
+
toBeCloseTo: (float, ~numDigits: int=?) => unit,
|
|
21
|
+
toBeNaN: unit => unit,
|
|
22
|
+
// String matchers
|
|
23
|
+
toContain: string => unit,
|
|
24
|
+
toMatch: Js.Re.t => unit,
|
|
25
|
+
toMatchString: string => unit,
|
|
26
|
+
// Array matchers
|
|
27
|
+
toContainItem: 'a => unit,
|
|
28
|
+
toHaveLength: int => unit,
|
|
29
|
+
// Object matchers
|
|
30
|
+
toHaveProperty: string => unit,
|
|
31
|
+
toHavePropertyValue: 'b. (string, 'b) => unit,
|
|
32
|
+
// Exception matchers
|
|
33
|
+
toThrow: unit => unit,
|
|
34
|
+
toThrowError: string => unit,
|
|
35
|
+
// Negation
|
|
36
|
+
not: expectation<'a>,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Test context passed to test callbacks
|
|
40
|
+
type testContext = {expect: 'a. ('a, ~message: string=?) => expectation<'a>}
|
|
41
|
+
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// Test Suite Functions
|
|
44
|
+
// ============================================================================
|
|
45
|
+
|
|
46
|
+
@module("vitest")
|
|
47
|
+
external describe: (string, unit => unit) => unit = "describe"
|
|
48
|
+
|
|
49
|
+
@module("vitest") @scope("describe")
|
|
50
|
+
external describe_only: (string, unit => unit) => unit = "only"
|
|
51
|
+
|
|
52
|
+
@module("vitest") @scope("describe")
|
|
53
|
+
external describe_skip: (string, unit => unit) => unit = "skip"
|
|
54
|
+
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Test Functions (sync)
|
|
57
|
+
// ============================================================================
|
|
58
|
+
|
|
59
|
+
@module("vitest")
|
|
60
|
+
external it: (string, unit => unit) => unit = "it"
|
|
61
|
+
|
|
62
|
+
@module("vitest") @scope("it")
|
|
63
|
+
external it_only: (string, unit => unit) => unit = "only"
|
|
64
|
+
|
|
65
|
+
@module("vitest") @scope("it")
|
|
66
|
+
external it_skip: (string, unit => unit) => unit = "skip"
|
|
67
|
+
|
|
68
|
+
@module("vitest")
|
|
69
|
+
external test: (string, unit => unit) => unit = "test"
|
|
70
|
+
|
|
71
|
+
@module("vitest") @scope("test")
|
|
72
|
+
external test_only: (string, unit => unit) => unit = "only"
|
|
73
|
+
|
|
74
|
+
@module("vitest") @scope("test")
|
|
75
|
+
external test_skip: (string, unit => unit) => unit = "skip"
|
|
76
|
+
|
|
77
|
+
// ============================================================================
|
|
78
|
+
// Setup and Teardown
|
|
79
|
+
// ============================================================================
|
|
80
|
+
|
|
81
|
+
@module("vitest")
|
|
82
|
+
external beforeAll: (unit => unit) => unit = "beforeAll"
|
|
83
|
+
|
|
84
|
+
@module("vitest")
|
|
85
|
+
external afterAll: (unit => unit) => unit = "afterAll"
|
|
86
|
+
|
|
87
|
+
@module("vitest")
|
|
88
|
+
external beforeEach: (unit => unit) => unit = "beforeEach"
|
|
89
|
+
|
|
90
|
+
@module("vitest")
|
|
91
|
+
external afterEach: (unit => unit) => unit = "afterEach"
|
|
92
|
+
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// Async Module
|
|
95
|
+
// ============================================================================
|
|
96
|
+
|
|
97
|
+
module Async = {
|
|
98
|
+
@module("vitest")
|
|
99
|
+
external it: (string, testContext => promise<unit>) => unit = "it"
|
|
100
|
+
|
|
101
|
+
@module("vitest") @scope("it")
|
|
102
|
+
external it_only: (string, testContext => promise<unit>) => unit = "only"
|
|
103
|
+
|
|
104
|
+
@module("vitest") @scope("it")
|
|
105
|
+
external it_skip: (string, testContext => promise<unit>) => unit = "skip"
|
|
106
|
+
|
|
107
|
+
@module("vitest")
|
|
108
|
+
external test: (string, testContext => promise<unit>) => unit = "test"
|
|
109
|
+
|
|
110
|
+
@module("vitest") @scope("test")
|
|
111
|
+
external test_only: (string, testContext => promise<unit>) => unit = "only"
|
|
112
|
+
|
|
113
|
+
@module("vitest") @scope("test")
|
|
114
|
+
external test_skip: (string, testContext => promise<unit>) => unit = "skip"
|
|
115
|
+
|
|
116
|
+
@module("vitest")
|
|
117
|
+
external beforeAll: (unit => promise<unit>) => unit = "beforeAll"
|
|
118
|
+
|
|
119
|
+
@module("vitest")
|
|
120
|
+
external afterAll: (unit => promise<unit>) => unit = "afterAll"
|
|
121
|
+
|
|
122
|
+
@module("vitest")
|
|
123
|
+
external beforeEach: (unit => promise<unit>) => unit = "beforeEach"
|
|
124
|
+
|
|
125
|
+
@module("vitest")
|
|
126
|
+
external afterEach: (unit => promise<unit>) => unit = "afterEach"
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ============================================================================
|
|
130
|
+
// Expect
|
|
131
|
+
// ============================================================================
|
|
132
|
+
|
|
133
|
+
@module("vitest")
|
|
134
|
+
external expect: ('a, ~message: string=?) => expectation<'a> = "expect"
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type arg = string
|
|
2
|
+
|
|
3
|
+
type parsedArgs<'a> = 'a
|
|
4
|
+
|
|
5
|
+
@module("yargs/yargs") external yargs: array<arg> => parsedArgs<'a> = "default"
|
|
6
|
+
@module("yargs/helpers") external hideBin: array<arg> => array<arg> = "hideBin"
|
|
7
|
+
|
|
8
|
+
@get external argv: parsedArgs<'a> => 'a = "argv"
|
package/src/db/InternalTable.res
CHANGED
|
@@ -243,6 +243,7 @@ WHERE "${(#id: field :> string)}" = $1;`
|
|
|
243
243
|
numEventsProcessed: int,
|
|
244
244
|
progressBlockNumber: int,
|
|
245
245
|
dynamicContracts: array<Internal.indexingContract>,
|
|
246
|
+
sourceBlockNumber: int,
|
|
246
247
|
}
|
|
247
248
|
|
|
248
249
|
// FIXME: Using registering_event_block_number for startBlock
|
|
@@ -258,6 +259,7 @@ WHERE "${(#id: field :> string)}" = $1;`
|
|
|
258
259
|
"${(#ready_at: field :> string)}" as "timestampCaughtUpToHeadOrEndblock",
|
|
259
260
|
"${(#events_processed: field :> string)}" as "numEventsProcessed",
|
|
260
261
|
"${(#progress_block: field :> string)}" as "progressBlockNumber",
|
|
262
|
+
"${(#source_block: field :> string)}" as "sourceBlockNumber",
|
|
261
263
|
(
|
|
262
264
|
SELECT COALESCE(json_agg(json_build_object(
|
|
263
265
|
'address', "contract_address",
|