From 676d2e5fa024f16ac4c0dcd4ea7f7774ea99010c Mon Sep 17 00:00:00 2001 From: nigiri <168690269+0xnigir1@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:34:11 -0300 Subject: [PATCH] feat: add websiteUrl to metadata --- apps/api/src/api-docs/swagger.yaml | 4 ++++ .../src/metrics/dto/response/metadata.dto.ts | 8 +++++++ packages/metadata/README.md | 23 ++++++++++--------- packages/metadata/examples/chains.json | 2 ++ packages/metadata/src/schemas/index.ts | 1 + .../test/fixtures/metadata.fixtures.ts | 1 + .../providers/githubMetadata.provider.spec.ts | 3 +++ packages/shared/src/types/zkchain.type.ts | 1 + 8 files changed, 32 insertions(+), 11 deletions(-) diff --git a/apps/api/src/api-docs/swagger.yaml b/apps/api/src/api-docs/swagger.yaml index 7d1ac75..6a7c7e3 100644 --- a/apps/api/src/api-docs/swagger.yaml +++ b/apps/api/src/api-docs/swagger.yaml @@ -200,6 +200,10 @@ components: type: string example: "https://explorer.example.com" description: The URL of the chain's explorer. + websiteUrl: + type: string + example: "https://example.com" + description: The URL of the chain's website. launchDate: type: number example: 1638307200 diff --git a/apps/api/src/metrics/dto/response/metadata.dto.ts b/apps/api/src/metrics/dto/response/metadata.dto.ts index 4ecc90f..c012043 100644 --- a/apps/api/src/metrics/dto/response/metadata.dto.ts +++ b/apps/api/src/metrics/dto/response/metadata.dto.ts @@ -30,6 +30,13 @@ export class ZkChainMetadata { */ explorerUrl?: string; + /** + * The URL of the chain's website. + * @type {string} + * @memberof Metadata + */ + websiteUrl?: string; + /** * The launch date of the chain (timestamp). * @type {number} @@ -42,6 +49,7 @@ export class ZkChainMetadata { this.name = data.name; this.publicRpcs = data.publicRpcs; this.explorerUrl = data.explorerUrl; + this.websiteUrl = data.websiteUrl; this.launchDate = data.launchDate; } } diff --git a/packages/metadata/README.md b/packages/metadata/README.md index c04028b..81ff0e7 100644 --- a/packages/metadata/README.md +++ b/packages/metadata/README.md @@ -10,24 +10,25 @@ This file contains an array of Chain metadata. To add a new one, follow the foll ```json { - "chainId": 324, //mandatory - "name": "ZKsyncERA", //mandatory - "iconUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/24091.png", //optional + "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 + ], // optional, + "explorerUrl": "https://explorer.zksync.io/", // optional + "websiteUrl": "https://zksync.io/", // optional + "launchDate": 1679626800, // mandatory "chainType": "Rollup", // "Rollup" | "Validium" "baseToken": { - "name": "Ether", //mandatory - "symbol": "ETH", //mandatory + "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 + "imageUrl": "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628", // optional + "decimals": 18 // mandatory } } ``` @@ -57,7 +58,7 @@ Inside [examples](./examples/) folder, you'll find json examples. Copy it to you 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 +> https://raw.githubusercontent.com/defi-wonderland/ZKchainHub-metadata/main/chains_mainnet.json ## 📋 Prerequisites diff --git a/packages/metadata/examples/chains.json b/packages/metadata/examples/chains.json index 2e0d8f3..94d1d5c 100644 --- a/packages/metadata/examples/chains.json +++ b/packages/metadata/examples/chains.json @@ -9,6 +9,7 @@ "https://zksync.meowrpc.com" ], "explorerUrl": "https://explorer.zksync.io/", + "websiteUrl": "https://zksync.io/", "launchDate": 1679626800, "chainType": "Rollup", "baseToken": { @@ -27,6 +28,7 @@ "chainType": "Validium", "publicRpcs": ["https://mainnet.zkevm.cronos.org"], "explorerUrl": "https://explorer.zkevm.cronos.org/", + "websiteUrl": "https://cronos.org/zkevm", "baseToken": { "symbol": "zkCRO", "name": "zkCRO", diff --git a/packages/metadata/src/schemas/index.ts b/packages/metadata/src/schemas/index.ts index d5afc01..0c8c0a5 100644 --- a/packages/metadata/src/schemas/index.ts +++ b/packages/metadata/src/schemas/index.ts @@ -21,6 +21,7 @@ export const ChainSchema = z.object({ iconUrl: z.string().url().optional(), publicRpcs: z.array(z.string().url()).default([]), explorerUrl: z.string().url().optional(), + websiteUrl: z.string().url().optional(), launchDate: z.number().positive(), chainType: z.union([z.literal("Rollup"), z.literal("Validium")]), baseToken: TokenSchema, diff --git a/packages/metadata/test/fixtures/metadata.fixtures.ts b/packages/metadata/test/fixtures/metadata.fixtures.ts index ff23fd9..9c74256 100644 --- a/packages/metadata/test/fixtures/metadata.fixtures.ts +++ b/packages/metadata/test/fixtures/metadata.fixtures.ts @@ -32,6 +32,7 @@ export const mockChainData = [ "https://zksync.meowrpc.com", ], explorerUrl: "https://explorer.zksync.io/", + websiteUrl: "https://zksync.io/", launchDate: 1679626800, chainType: "Rollup", baseToken: { diff --git a/packages/metadata/test/unit/providers/githubMetadata.provider.spec.ts b/packages/metadata/test/unit/providers/githubMetadata.provider.spec.ts index 100c67c..5e9f7b8 100644 --- a/packages/metadata/test/unit/providers/githubMetadata.provider.spec.ts +++ b/packages/metadata/test/unit/providers/githubMetadata.provider.spec.ts @@ -98,6 +98,7 @@ describe("GithubMetadataProvider", () => { "https://zksync.meowrpc.com", ], explorerUrl: "https://explorer.zksync.io/", + websiteUrl: "https://zksync.io/", launchDate: 1679626800, chainType: "Rollup", baseToken: { @@ -140,6 +141,7 @@ describe("GithubMetadataProvider", () => { "https://zksync.meowrpc.com", ], explorerUrl: "https://explorer.zksync.io/", + websiteUrl: "https://zksync.io/", launchDate: 1679626800, chainType: "Rollup", baseToken: { @@ -187,6 +189,7 @@ describe("GithubMetadataProvider", () => { "https://zksync.meowrpc.com", ], explorerUrl: "https://explorer.zksync.io/", + websiteUrl: "https://zksync.io/", launchDate: 1679626800, chainType: "Rollup", baseToken: { diff --git a/packages/shared/src/types/zkchain.type.ts b/packages/shared/src/types/zkchain.type.ts index 0e1d3b8..58cf4b1 100644 --- a/packages/shared/src/types/zkchain.type.ts +++ b/packages/shared/src/types/zkchain.type.ts @@ -8,6 +8,7 @@ export type ZKChainMetadataItem = { baseToken: Token<"erc20" | "native">; publicRpcs: string[]; explorerUrl?: string; + websiteUrl?: string; launchDate: number; };