@lodestar/utils 1.14.0-dev.f705b1e9e3 → 1.14.0-dev.fbc5a78fc2

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.
@@ -0,0 +1,10 @@
1
+ export declare const ETH_TO_GWEI: bigint;
2
+ export declare const GWEI_TO_WEI: bigint;
3
+ export declare const ETH_TO_WEI: bigint;
4
+ type EthNumeric = bigint;
5
+ /**
6
+ * Convert gwei to wei.
7
+ */
8
+ export declare function gweiToWei(gwei: EthNumeric): EthNumeric;
9
+ export {};
10
+ //# sourceMappingURL=ethConversion.d.ts.map
@@ -0,0 +1,10 @@
1
+ export const ETH_TO_GWEI = BigInt(10 ** 9);
2
+ export const GWEI_TO_WEI = BigInt(10 ** 9);
3
+ export const ETH_TO_WEI = ETH_TO_GWEI * GWEI_TO_WEI;
4
+ /**
5
+ * Convert gwei to wei.
6
+ */
7
+ export function gweiToWei(gwei) {
8
+ return gwei * GWEI_TO_WEI;
9
+ }
10
+ //# sourceMappingURL=ethConversion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ethConversion.js","sourceRoot":"","sources":["../src/ethConversion.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAIpD;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,OAAO,IAAI,GAAG,WAAW,CAAC;AAC5B,CAAC"}
package/lib/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./format.js";
8
8
  export * from "./logger.js";
9
9
  export * from "./map.js";
10
10
  export * from "./math.js";
11
+ export * from "./metrics.js";
11
12
  export * from "./objects.js";
12
13
  export { retry, type RetryOptions } from "./retry.js";
13
14
  export * from "./notNullish.js";
@@ -19,4 +20,5 @@ export * from "./url.js";
19
20
  export * from "./verifyMerkleBranch.js";
20
21
  export * from "./promise.js";
21
22
  export * from "./waitFor.js";
23
+ export * from "./ethConversion.js";
22
24
  //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -8,6 +8,7 @@ export * from "./format.js";
8
8
  export * from "./logger.js";
9
9
  export * from "./map.js";
10
10
  export * from "./math.js";
11
+ export * from "./metrics.js";
11
12
  export * from "./objects.js";
12
13
  export { retry } from "./retry.js";
13
14
  export * from "./notNullish.js";
@@ -19,4 +20,5 @@ export * from "./url.js";
19
20
  export * from "./verifyMerkleBranch.js";
20
21
  export * from "./promise.js";
21
22
  export * from "./waitFor.js";
23
+ export * from "./ethConversion.js";
22
24
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAC,KAAK,EAAoB,MAAM,YAAY,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAwB,OAAO,EAAC,MAAM,YAAY,CAAC;AAC1D,cAAc,UAAU,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAC,KAAK,EAAoB,MAAM,YAAY,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAwB,OAAO,EAAC,MAAM,YAAY,CAAC;AAC1D,cAAc,UAAU,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,57 @@
1
+ export type NoLabels = Record<string, never>;
2
+ export type LabelsGeneric = Record<string, string | number>;
3
+ export type LabelKeys<Labels extends LabelsGeneric> = Extract<keyof Labels, string>;
4
+ export type CollectFn<Labels extends LabelsGeneric> = (metric: Gauge<Labels>) => void;
5
+ export interface Gauge<Labels extends LabelsGeneric = NoLabels> {
6
+ inc: NoLabels extends Labels ? (value?: number) => void : (labels: Labels, value?: number) => void;
7
+ dec: NoLabels extends Labels ? (value?: number) => void : (labels: Labels, value?: number) => void;
8
+ set: NoLabels extends Labels ? (value: number) => void : (labels: Labels, value: number) => void;
9
+ collect?(): void;
10
+ }
11
+ export interface GaugeExtra<Labels extends LabelsGeneric = NoLabels> extends Omit<Gauge<Labels>, "collect"> {
12
+ addCollect(collectFn: CollectFn<Labels>): void;
13
+ }
14
+ export interface Histogram<Labels extends LabelsGeneric = NoLabels> {
15
+ startTimer(): NoLabels extends Labels ? () => number : (labels: Labels) => number;
16
+ startTimer<L extends Partial<Labels>>(labels?: NoLabels extends Labels ? never : L): keyof Omit<Labels, keyof L> extends never ? () => number : (labels: Omit<Labels, keyof L>) => number;
17
+ observe: NoLabels extends Labels ? (value: number) => void : (labels: Labels, value: number) => void;
18
+ reset(): void;
19
+ }
20
+ export interface AvgMinMax<Labels extends LabelsGeneric = NoLabels> {
21
+ addGetValuesFn(getValuesFn: () => number[]): void;
22
+ set: NoLabels extends Labels ? (values: number[]) => void : (labels: Labels, values: number[]) => void;
23
+ }
24
+ export interface Counter<Labels extends LabelsGeneric = NoLabels> {
25
+ inc: NoLabels extends Labels ? (value?: number) => void : (labels: Labels, value?: number) => void;
26
+ }
27
+ export type GaugeConfig<Labels extends LabelsGeneric> = {
28
+ name: string;
29
+ help: string;
30
+ } & (NoLabels extends Labels ? {
31
+ labelNames?: never;
32
+ } : {
33
+ labelNames: [LabelKeys<Labels>, ...LabelKeys<Labels>[]];
34
+ });
35
+ export type HistogramConfig<Labels extends LabelsGeneric> = GaugeConfig<Labels> & {
36
+ buckets?: number[];
37
+ };
38
+ export type AvgMinMaxConfig<Labels extends LabelsGeneric> = GaugeConfig<Labels>;
39
+ export type CounterConfig<Labels extends LabelsGeneric> = GaugeConfig<Labels>;
40
+ export type StaticConfig<Labels extends LabelsGeneric> = {
41
+ name: GaugeConfig<Labels>["name"];
42
+ help: GaugeConfig<Labels>["help"];
43
+ value: Record<LabelKeys<Labels>, string>;
44
+ };
45
+ export interface MetricsRegister {
46
+ gauge<Labels extends LabelsGeneric = NoLabels>(config: GaugeConfig<Labels>): Gauge<Labels>;
47
+ histogram<Labels extends LabelsGeneric = NoLabels>(config: HistogramConfig<Labels>): Histogram<Labels>;
48
+ counter<Labels extends LabelsGeneric = NoLabels>(config: CounterConfig<Labels>): Counter<Labels>;
49
+ }
50
+ export interface MetricsRegisterExtra extends MetricsRegister {
51
+ gauge<Labels extends LabelsGeneric = NoLabels>(config: GaugeConfig<Labels>): GaugeExtra<Labels>;
52
+ }
53
+ export interface MetricsRegisterCustom extends MetricsRegisterExtra {
54
+ avgMinMax<Labels extends LabelsGeneric = NoLabels>(config: AvgMinMaxConfig<Labels>): AvgMinMax<Labels>;
55
+ static<Labels extends LabelsGeneric = NoLabels>(config: StaticConfig<Labels>): void;
56
+ }
57
+ //# sourceMappingURL=metrics.d.ts.map
package/lib/metrics.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/ChainSafe/lodestar/issues"
13
13
  },
14
- "version": "1.14.0-dev.f705b1e9e3",
14
+ "version": "1.14.0-dev.fbc5a78fc2",
15
15
  "type": "module",
16
16
  "exports": "./lib/index.js",
17
17
  "files": [
@@ -27,12 +27,15 @@
27
27
  "build:watch": "yarn run build --watch",
28
28
  "build:release": "yarn clean && yarn build",
29
29
  "check-build": "node -e \"(async function() { await import('./lib/index.js') })()\"",
30
- "check-types": "tsc",
30
+ "check-types": "tsc && vitest --run --typecheck --dir test/types/",
31
31
  "lint": "eslint --color --ext .ts src/ test/",
32
32
  "lint:fix": "yarn run lint --fix",
33
33
  "pretest": "yarn run check-types",
34
- "test:unit": "mocha 'test/**/*.test.ts'",
35
- "test:browsers": "yarn karma start karma.config.cjs",
34
+ "test:unit": "vitest --run --dir test/unit/ --coverage",
35
+ "test:browsers": "yarn test:browsers:chrome && yarn test:browsers:firefox && yarn test:browsers:electron",
36
+ "test:browsers:chrome": "vitest --run --browser chrome --config ./vitest.browser.config.ts --dir test/unit",
37
+ "test:browsers:firefox": "vitest --run --browser firefox --config ./vitest.browser.config.ts --dir test/unit",
38
+ "test:browsers:electron": "echo 'Electron tests will be introduced back in the future as soon vitest supports electron.'",
36
39
  "check-readme": "typescript-docs-verifier"
37
40
  },
38
41
  "types": "lib/index.d.ts",
@@ -47,6 +50,7 @@
47
50
  "devDependencies": {
48
51
  "@types/js-yaml": "^4.0.5",
49
52
  "@types/triple-beam": "^1.3.2",
53
+ "prom-client": "^15.1.0",
50
54
  "triple-beam": "^1.3.0"
51
55
  },
52
56
  "keywords": [
@@ -55,5 +59,5 @@
55
59
  "beacon",
56
60
  "blockchain"
57
61
  ],
58
- "gitHead": "f99a8dfcec41d3d8c61c39e71e8257fc67cfc43e"
62
+ "gitHead": "716ea97e8c7f9895ce98c9ab9895830826d0f9c9"
59
63
  }