Skip to content

Commit

Permalink
feat: token chain json examples (#59)
Browse files Browse the repository at this point in the history
# 🤖 Linear

Closes ZKS-215

## Description

- Update token list with a more exhaustive one based on L2Beat list
- Remove `coingeckoId` from Token
- Add condition if SharedBridge does not have balance of token, token
it's not returned in TVL
- Update docs and examples
- Metadata uploaded to:
https://github.com/defi-wonderland/ZKchainHub-metadata
  • Loading branch information
0xnigir1 authored Aug 29, 2024
1 parent dd33a59 commit 6a9a61a
Show file tree
Hide file tree
Showing 14 changed files with 3,569 additions and 190 deletions.
96 changes: 96 additions & 0 deletions packages/metadata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# ZKchainHub - Metadata Package

## Overview

This package contains providers for fetching chains and tokens metadata.

### chains.json

This file contains an array of Chain metadata. To add a new one, follow the following interface:

```json
{
"chainId": 324, //mandatory
"name": "ZKsyncERA", //mandatory
"iconUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/24091.png", //optional
"publicRpcs": [
"https://mainnet.era.zksync.io",
"https://zksync.drpc.org",
"https://zksync.meowrpc.com"
], //optional,
"explorerUrl": "https://explorer.zksync.io/", //optional
"launchDate": 1679626800, //mandatory
"chainType": "Rollup", // "Rollup" | "Validium"
"baseToken": {
"name": "Ether", //mandatory
"symbol": "ETH", //mandatory
"type": "native", // "native" | "erc20"
"contractAddress": null, // null if "native", address if "erc20"
"imageUrl": "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628", //optional
"decimals": 18 //mandatory
}
}
```

### tokens.json

This file contains an array of Token metadata. To add a new one, follow the following interface:

```json
{
"name": "0x Protocol Token", //mandatory
"symbol": "ZRX", //mandatory
"contractAddress": "0xE41d2489571d322189246DaFA5ebDe1F4699F498", // null if "native", address if "erc20"
"imageUrl": "https://assets.coingecko.com/coins/images/863/large/0x.png?1696501996", //optional
"type": "erc20", // "native" | "erc20"
"decimals": 18 //mandatory
}
```

Currently, there are three different providers:

- `LocalFileMetadataProvider`
- `GithubMetadataProvider`
- `StaticMetadataProvider`

Inside [examples](./examples/) folder, you'll find json examples. Copy it to your local machine and edit metadata as wanted. Also, you can use it to host your own file on Github (recommended)

At [ZKchainHub-metadata repository](https://github.com/defi-wonderland/ZKchainHub-metadata) you'll find the latest curated list of tokens. To use it, remember to copy file url as raw content.

> https://raw.githubusercontent.com/defi-wonderland/ZKchainHub-metadata/79779a6313ab43af055f59861be012bf67bb908d/chains_mainnet.json
## 📋 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
```

## Contributing

To create a new provider, create it inside [`providers`](./src/providers/) folder and implement the [`IMetadataProvider`](./src/interfaces/metadata.interface.ts) interface.

Then, write the configuration interface inside [`metadataConfig.interface.ts`](./src/interfaces/metadataConfig.interface.ts) and add the provider to the [`MetadataProviderFactory`](./src/factory/index.ts) class.

Finally, export the provider and required files in [`external.ts`](./src/external.ts).
40 changes: 40 additions & 0 deletions packages/metadata/examples/chains.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[
{
"chainId": 324,
"name": "ZKsyncERA",
"iconUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/24091.png",
"publicRpcs": [
"https://mainnet.era.zksync.io",
"https://zksync.drpc.org",
"https://zksync.meowrpc.com"
],
"explorerUrl": "https://explorer.zksync.io/",
"launchDate": 1679626800,
"chainType": "Rollup",
"baseToken": {
"name": "Ether",
"symbol": "ETH",
"contractAddress": null,
"type": "native",
"imageUrl": "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628",
"decimals": 18
}
},
{
"chainId": 388,
"name": "Cronos",
"iconUrl": "https://zkevm.cronos.org/images/chains/zkevm.svg",
"chainType": "Validium",
"publicRpcs": ["https://mainnet.zkevm.cronos.org"],
"explorerUrl": "https://explorer.zkevm.cronos.org/",
"baseToken": {
"symbol": "zkCRO",
"name": "zkCRO",
"contractAddress": "0x28Ff2E4dD1B58efEB0fC138602A28D5aE81e44e2",
"type": "erc20",
"imageUrl": "https://zkevm.cronos.org/images/chains/zkevm.svg",
"decimals": 18
},
"launchDate": 1679626800
}
]
Loading

0 comments on commit 6a9a61a

Please sign in to comment.