-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: update docs and readme #62
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# ZKchainHub API | ||
|
||
## Overview | ||
|
||
The `@zkchainhub/api` app is an Express server that exposes an API where you can fetch information about ZKsync ecosystem and their chains. | ||
|
||
## 📋 Prerequisites | ||
|
||
- Ensure you have `node >= 20.0.0` and `pnpm >= 9.5.0` installed. | ||
|
||
## Installation | ||
|
||
```bash | ||
$ pnpm install | ||
``` | ||
|
||
## Building | ||
|
||
To build the monorepo packages, run: | ||
|
||
```bash | ||
$ pnpm build | ||
``` | ||
|
||
## ⚙️ Setting up env variables | ||
|
||
- Create `.env` file and copy paste `.env.example` content in there. | ||
|
||
``` | ||
$ cp .env.example .env | ||
``` | ||
|
||
Available options: | ||
|
||
- (optional) `PORT` on which API is made available. By default is port 3000 | ||
- (optional) `ENVIRONMENT` which environment we are using ( 'mainnet' | 'testnet' | 'local'). By default is 'mainnet' | ||
- `BRIDGE_HUB_ADDRESS` | ||
- `SHARED_BRIDGE_ADDRESS` | ||
- `STATE_MANAGER_ADDRESSES` CSV list of State managers addresses | ||
- `L1_RPC_URLS` as CSV list of RPC URLs. For example, `https://eth.llamarpc.com,https://rpc.flashbots.net/fast`. You can check [Chainlist](https://chainlist.org/) for a list of public RPCs | ||
- (optional) `PRICING_SOURCE` which pricing source to use ('dummy' | 'coingecko'). By default is dummy | ||
- (optional) `DUMMY_PRICE` for dummy pricing source. Default is undefined | ||
- (required if 'coingecko' is selected)`COINGECKO_API_KEY`, `COINGECKO_BASE_URL` and `COINGECKO_API_KEY` depending on your API plan. You can get an API Key creating an account on [Coingecko's site](https://www.coingecko.com/en/api) | ||
- `METADATA_SOURCE` which metadata source to use ('github' | 'local' | 'static') | ||
- (required if METADATA_SOURCE is 'github') `METADATA_TOKEN_URL` Metadata tokens URL | ||
- (required if METADATA_SOURCE is 'github') `METADATA_CHAIN_URL` Metadata chains URL | ||
- (required if METADATA_SOURCE is 'local') `METADATA_TOKEN_JSON_PATH` Metadata tokens JSON file path (see examples on `packages/metadata`) | ||
- (required if METADATA_SOURCE is 'local') `METADATA_CHAIN_JSON_PATH` Metadata chain JSON file path (see examples on `packages/metadata`) | ||
|
||
## Running the app | ||
|
||
```bash | ||
# development watch mode | ||
$ pnpm run dev | ||
|
||
# production mode | ||
$ pnpm run start | ||
|
||
``` | ||
|
||
Verify that ZKchainHub API is running on http://localhost:3000 (or the port specified) | ||
|
||
## Test | ||
|
||
```bash | ||
# unit tests | ||
$ pnpm run test | ||
|
||
# test coverage | ||
$ pnpm run test:cov | ||
``` | ||
|
||
## API | ||
|
||
### Metrics routes | ||
|
||
- `GET /metrics/ecosystem`: Retrieves overall ecosystem metrics | ||
- `GET /metrics/zkchain/:chainId`: Retrieves chain specific metrics | ||
|
||
## Docs | ||
|
||
Locally Swagger docs are available at http://localhost:3000/docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# ZKchainHub Chain Providers package | ||
|
||
## Overview | ||
|
||
The `@zkchainhub/chain-providers` package provides wrappers of the `Viem` library to interact with EVM-based blockchains and ZK chains of the ZKsync ecosystem. | ||
|
||
## 📋 Prerequisites | ||
|
||
- Ensure you have `node >= 20.0.0` and `pnpm >= 9.5.0` installed. | ||
|
||
## Installation | ||
|
||
```bash | ||
$ pnpm install | ||
``` | ||
|
||
## Building | ||
|
||
To build the monorepo packages, run: | ||
|
||
```bash | ||
$ pnpm build | ||
``` | ||
|
||
## Test | ||
|
||
```bash | ||
# unit tests | ||
$ pnpm run test | ||
|
||
# test coverage | ||
$ pnpm run test:cov | ||
``` | ||
|
||
## Usage | ||
|
||
### Importing the Package | ||
|
||
You can import the package in your TypeScript or JavaScript files as follows: | ||
|
||
```typescript | ||
import { EvmProvider } from "@zkchainhub/chain-providers"; | ||
``` | ||
|
||
### Example | ||
|
||
```typescript | ||
// EVM-provider | ||
const rpcUrls = [...]; //non-empty | ||
const chain = mainnet; // from viem/chains | ||
|
||
const evmProvider = new EvmProvider(rpcUrls, chain, logger); | ||
|
||
const gasPrice = await evmProvider.getGasPrice(); | ||
|
||
const result = await evmProvider.readContract(address, abi, "myfunction", [arg1, arg2]); | ||
|
||
// ZK-chain provider | ||
const zkChainProvider = new ZKChainProvider(rpcUrls, chain, logger); | ||
|
||
const l2Tps = await zkChainProvider.tps(); | ||
``` | ||
|
||
## API | ||
|
||
### [EvmProvider](./src/providers/evmProvider.service.ts) | ||
|
||
Available methods | ||
|
||
- `getMulticall3Address()` | ||
- `getBalance(address: Address)` | ||
- `getBlockNumber()` | ||
- `getBlockByNumber(blockNumber: number)` | ||
- `getGasPrice()` | ||
- `estimateGas(args: EstimateGasParameters<typeof this.chain>)` | ||
- `getStorageAt(address: Address, slot: number | Hex)` | ||
- `readContract(contractAddress: Address, abi: TAbi functionName: TFunctionName, args?: TArgs)` | ||
- `batchRequest(abi: AbiWithConstructor,bytecode: Hex, args: ContractConstructorArgs<typeof abi>, constructorReturnParams: ReturnType)` | ||
- `multicall(args: MulticallParameters<contracts, allowFailure>)` | ||
|
||
### [ZKChainProvider](./src/providers/zkChainProvider.service.ts) | ||
|
||
Available methods | ||
|
||
- `getL1BatchDetails(batchNumber: number)` | ||
- `getL1BatchNumber()` | ||
- `avgBlockTime(range: number = 1000)` | ||
- `tps()` | ||
|
||
For more details on both providers, refer to their implementations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# ZKchainHub Metrics package | ||
|
||
## Overview | ||
|
||
The `@zkchainhub/metrics` package exposes services with different aggregated metrics from the ZKsync ecosystem and ZK chains. | ||
|
||
## 📋 Prerequisites | ||
|
||
- Ensure you have `node >= 20.0.0` and `pnpm >= 9.5.0` installed. | ||
|
||
## Installation | ||
|
||
```bash | ||
$ pnpm install | ||
``` | ||
|
||
## Building | ||
|
||
To build the monorepo packages, run: | ||
|
||
```bash | ||
$ pnpm build | ||
``` | ||
|
||
## Test | ||
|
||
```bash | ||
# unit tests | ||
$ pnpm run test | ||
|
||
# test coverage | ||
$ pnpm run test:cov | ||
``` | ||
|
||
## Usage | ||
|
||
### Importing the Package | ||
|
||
You can import the package in your TypeScript or JavaScript files as follows: | ||
|
||
```typescript | ||
import { L1MetricsService } from "@zkchainhub/metrics"; | ||
``` | ||
|
||
### Example | ||
|
||
This packages requires that user injects instances of: | ||
|
||
- EvmProvider | ||
- IPricingProvider | ||
- IMetadataProvider | ||
|
||
```typescript | ||
// ... define needed dependencies | ||
|
||
const l1MetricsService = new L1MetricsService( | ||
bridgeHubAddress, | ||
sharedBridgeAddress, | ||
stateTransitionManagerAddresses, | ||
evmProvider, | ||
pricingProvider, | ||
metadataProvider, | ||
logger, | ||
); | ||
|
||
await l1MetricsService.l1Tvl(); | ||
``` | ||
|
||
## API | ||
|
||
### [L1MetricsService](./src/l1/l1MetricsService.ts) | ||
|
||
Available methods | ||
|
||
- `l1Tvl()` | ||
- `getBatchesInfo(chainId: ChainId)` | ||
- `tvl(chainId: ChainId)` | ||
- `chainType(chainId: ChainId)` | ||
- `ethGasInfo()` | ||
- `getChainIds()` | ||
- `getBaseTokens(chainIds: ChainId[])` | ||
- `feeParams(chainId: ChainId)` | ||
|
||
For more details on services, refer to their implementations. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going the extra extra mile but, what do you think about using a Markdown table for this part? You can use this tool to generate your tables in an easier way
Eg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks 🫶