diff --git a/blockchains/smartchain/assets/0x4B0F1812e5Df2A09796481Ff14017e6005508003/info.json b/blockchains/smartchain/assets/0x4B0F1812e5Df2A09796481Ff14017e6005508003/info.json index 68897fed4..b4ee4c566 100644 --- a/blockchains/smartchain/assets/0x4B0F1812e5Df2A09796481Ff14017e6005508003/info.json +++ b/blockchains/smartchain/assets/0x4B0F1812e5Df2A09796481Ff14017e6005508003/info.json @@ -4,23 +4,14 @@ "source_code": "https://github.com/trustwallet/", "white_paper": "", "description": "Utility token to increase adoption of cryptocurrency.", - "socials": [ - { - "name": "Twitter", - "url": "https://twitter.com/trustwalletapp", - "handle": "TrustWalletApp" - }, - { - "name": "Reddit", - "url": "https://reddit.com/r/trustapp", - "handle": "TrustApp" - } - ], "explorer": "https://bscscan.com/token/0x4B0F1812e5Df2A09796481Ff14017e6005508003", "research": "https://research.binance.com/en/projects/trustwallet", "type": "BEP20", "symbol": "TWT", "decimals": 18, "status": "active", - "id": "0x4B0F1812e5Df2A09796481Ff14017e6005508003" + "id": "0x4B0F1812e5Df2A09796481Ff14017e6005508003", + "tags": [ + "dao" + ] } \ No newline at end of file diff --git a/script/generic/asset-infos.ts b/script/generic/asset-infos.ts index 0e8c588b5..7d4fcce94 100644 --- a/script/generic/asset-infos.ts +++ b/script/generic/asset-infos.ts @@ -10,6 +10,7 @@ import { isValidJSON, readJsonFile, writeJsonFile } from "../generic/json"; import { ActionInterface, CheckStepInterface } from "../generic/interface"; import { CoinType } from "@trustwallet/wallet-core"; import { isValidStatusValue } from "../generic/status-values"; +import { isValidTagValues } from "../generic/tag-values"; import * as bluebird from "bluebird"; const requiredKeys = ["name", "type", "symbol", "decimals", "description", "website", "explorer", "status", "id"]; @@ -67,7 +68,14 @@ function isAssetInfoValid(info: unknown, path: string, address: string, chain: s // status if (!isValidStatusValue(info['status'])) { - return [`Invalid value for status field, '${info['status']}'`, "", fixedInfo] + return [`Invalid value for status field, '${info['status']}'`, "", fixedInfo]; + } + + // tags + if (info['tags']) { + if (!isValidTagValues(info['tags'])) { + return [`Invalid tags, '${info['tags']}'`, "", fixedInfo]; + } } const isKeys2CorrectType = diff --git a/script/generic/tag-values.ts b/script/generic/tag-values.ts new file mode 100644 index 000000000..e06cfa246 --- /dev/null +++ b/script/generic/tag-values.ts @@ -0,0 +1,19 @@ +import { readJsonFile } from "../generic/json"; + +const tags: any = readJsonFile("script/tags.json") as any; + +export function isValidTagValue(value: string): boolean { + //console.log(`isValidTagValue ${value}`); + if (!value) { + return false; + } + if (!(value in tags)) { + return false; + } + //console.log(`TAG ${tags[value]['name']}`); + return true; +} + +export function isValidTagValues(values: string[]): boolean { + return values.reduce((accum: boolean, value: string) => accum && isValidTagValue(value), true); +} diff --git a/script/tags.json b/script/tags.json new file mode 100644 index 000000000..36000fc0b --- /dev/null +++ b/script/tags.json @@ -0,0 +1,34 @@ +{ + "stablecoin": { + "name": "Stablecoin", + "description": "Tokens that are fixed to an external asset, e.g. the US dollar." + }, + "wrapped": { + "name": "Wrapped", + "description": "Tokens that are wrapped or peg representation of digital assets. Excluded stablecoins" + }, + "synthetics": { + "name": "Synthetics", + "description": "Synthetic assets created to track the value of another asset" + }, + "nft": { + "name": "NFT", + "description": "Non-fungible tokens or tokens associated with the NFT ecosystem." + }, + "dao": { + "name": "DAO", + "description": "Tokens that govern decentralized autonomous organizations (DAOs)." + }, + "defi": { + "name": "DeFi", + "description": null + }, + "creator": { + "name": "Creator", + "description": "Tokens by creators." + }, + "staking": { + "name": "Staking", + "description": "Tokens that are used for staking to receive rewards." + } +} \ No newline at end of file diff --git a/test/index.test.ts b/test/index.test.ts index e4afa6cb9..c8a242c2e 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -22,6 +22,7 @@ import { } from "../script/generic/types"; import { findImagesToFetch } from "../script/blockchain/binance"; import { isValidStatusValue } from "../script/generic/status-values"; +import { isValidTagValue, isValidTagValues } from "../script/generic/tag-values"; describe("Test eth-address helpers", () => { test(`Test isChecksum`, () => { @@ -136,7 +137,7 @@ describe("Test blockchain binance", () => { }); }); -describe("Test status-values", () => { +describe("Test status, tag values", () => { test(`Test status-values`, () => { expect(isValidStatusValue("active")).toEqual(true); expect(isValidStatusValue("abandoned")).toEqual(true); @@ -144,4 +145,17 @@ describe("Test status-values", () => { expect(isValidStatusValue("ACTIVE")).toEqual(false); expect(isValidStatusValue("")).toEqual(false); }); + test(`Test tag-values`, () => { + expect(isValidTagValue("defi")).toEqual(true); + expect(isValidTagValue("dao")).toEqual(true); + expect(isValidStatusValue("invalidvalue")).toEqual(false); + expect(isValidStatusValue("DAO")).toEqual(false); + expect(isValidStatusValue("")).toEqual(false); + + expect(isValidTagValues(["defi"])).toEqual(true); + expect(isValidTagValues(["dao"])).toEqual(true); + expect(isValidTagValues(["defi", "dao"])).toEqual(true); + expect(isValidTagValues(["invalid"])).toEqual(false); + expect(isValidTagValues(["defi", "invalid"])).toEqual(false); + }); });