From 0eced92a89916fddc1500c2243024680b8bf5a59 Mon Sep 17 00:00:00 2001 From: nigiri <168690269+0xnigir1@users.noreply.github.com> Date: Wed, 28 Aug 2024 21:28:48 -0300 Subject: [PATCH] docs: add metadata readme --- packages/metadata/README.md | 96 +++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 packages/metadata/README.md diff --git a/packages/metadata/README.md b/packages/metadata/README.md new file mode 100644 index 0000000..47369c9 --- /dev/null +++ b/packages/metadata/README.md @@ -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).