Skip to content

Commit

Permalink
feat: metrics package refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnigir1 committed Aug 19, 2024
1 parent 1fd0604 commit 3caa270
Show file tree
Hide file tree
Showing 27 changed files with 5,972 additions and 6 deletions.
12 changes: 9 additions & 3 deletions packages/metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
"lint": "eslint \"{src,test}/**/*.{js,ts,json}\"",
"lint:fix": "pnpm lint --fix",
"format": "prettier --check \"{src,test}/**/*.{js,ts,json}\"",
"format:fix": "prettier --write \"{src,test}/**/*.{js,ts,json}\""
"format:fix": "prettier --write \"{src,test}/**/*.{js,ts,json}\"",
"test": "vitest run --config vitest.config.ts --passWithNoTests",
"test:cov": "vitest run --config vitest.config.ts --coverage"
},
"dependencies": {},
"devDependencies": {}
"dependencies": {
"@zkchainhub/shared": "workspace:*",
"@zkchainhub/pricing": "workspace:*",
"@zkchainhub/providers": "workspace:*",
"viem": "2.19.6"
}
}
3 changes: 3 additions & 0 deletions packages/metrics/src/exceptions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./invalidChainId.exception.js";
export * from "./l1MetricsService.exception.js";
export * from "./invalidChainType.exception.js";
6 changes: 6 additions & 0 deletions packages/metrics/src/exceptions/invalidChainId.exception.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class InvalidChainId extends Error {
constructor(message: string) {
super(message);
this.name = "InvalidChainId";
}
}
11 changes: 11 additions & 0 deletions packages/metrics/src/exceptions/invalidChainType.exception.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Chains } from "@zkchainhub/shared";

export class InvalidChainType extends Error {
constructor(index: number) {
super(`Current supported types are [${Chains.join(
", ",
)}], but received index ${index}. Verify if supported chains are consistent with https://github.com/matter-labs/era-contracts/blob/8a70bbbc48125f5bde6189b4e3c6a3ee79631678/l1-contracts/contracts/state-transition/chain-deps/ZkSyncHyperchainStorage.sol#L39
`);
this.name = "InvalidChainType";
}
}
6 changes: 6 additions & 0 deletions packages/metrics/src/exceptions/l1MetricsService.exception.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class L1MetricsServiceException extends Error {
constructor(message: string) {
super(message);
this.name = "L1MetricsServiceException";
}
}
5 changes: 5 additions & 0 deletions packages/metrics/src/external.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type { FeeParams, GasInfo, AssetTvl } from "./internal.js";

export { InvalidChainId, InvalidChainType, L1MetricsServiceException } from "./internal.js";

export { L1MetricsService } from "./internal.js";
1 change: 1 addition & 0 deletions packages/metrics/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./external.js";
4 changes: 4 additions & 0 deletions packages/metrics/src/internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./types/index.js";
export * from "./exceptions/index.js";
export * from "./l1/abis/index.js";
export * from "./l1/index.js";
Loading

0 comments on commit 3caa270

Please sign in to comment.