diff --git a/.eslintignore b/.eslintignore index 2f94aaa1..00684ff6 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,5 @@ /node_modules # artifacts -/tools/marketplace-config-validator/schema.* \ No newline at end of file +/tools/marketplace-config-validator/schema.* +/tools/featured-networks-config-validator/schema.* \ No newline at end of file diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index fd6bb9e3..06857d6e 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -29,3 +29,6 @@ jobs: - name: Validate marketplace config schema run: './tools/marketplace-config-validator/script.sh' + + - name: Validate featured networks config schema + run: './tools/featured-networks-config-validator/script.sh' diff --git a/.gitignore b/.gitignore index 61a6e9b9..9282c3cc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.tsbuildinfo .eslintcache /tools/marketplace-config-validator/schema.* +/tools/featured-networks-config-validator/schema.* # misc .DS_Store \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 206ad7ec..415126fb 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -9,6 +9,9 @@ npx lint-staged --concurrent false echo 🧿 Running marketplace config validator... ./tools/marketplace-config-validator/script.sh +echo 🧿 Running featured networks config validator... +./tools/featured-networks-config-validator/script.sh + # format svg echo 🧿 Running svg formatter... for file in `git diff --diff-filter=ACMRT --cached --name-only | grep ".svg\$"` diff --git a/.prettierignore b/.prettierignore index 088dcc75..080828af 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,3 +3,4 @@ # artifacts /tools/marketplace-config-validator/schema.* +/tools/featured-networks-config-validator/schema.* diff --git a/configs/featured-networks/base-goerli.json b/configs/featured-networks/base-goerli.json new file mode 100644 index 00000000..0225799b --- /dev/null +++ b/configs/featured-networks/base-goerli.json @@ -0,0 +1,15 @@ +[ + { + "title": "Göerli", + "url": "https://eth-goerli.blockscout.com/", + "group": "Testnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/goerli.svg" + }, + { + "title": "Base Göerli", + "url": "https://base-goerli.blockscout.com/", + "group": "Testnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/base.svg", + "isActive": true + } +] diff --git a/configs/featured-networks/eth-goerli.json b/configs/featured-networks/eth-goerli.json new file mode 100644 index 00000000..a866fc75 --- /dev/null +++ b/configs/featured-networks/eth-goerli.json @@ -0,0 +1,98 @@ +[ + { + "title": "Ethereum", + "url": "https://blockscout.com/eth/mainnet", + "group": "Mainnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/ethereum.svg" + }, + { + "title": "Ethereum Classic", + "url": "https://blockscout.com/etc/mainnet", + "group": "Mainnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/ethereum-classic.svg" + }, + { + "title": "Gnosis Chain", + "url": "https://blockscout.com/xdai/mainnet", + "group": "Mainnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/gnosis.svg" + }, + { + "title": "Astar (EVM)", + "url": "https://blockscout.com/astar", + "group": "Mainnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/astar.svg" + }, + { + "title": "Shiden (EVM)", + "url": "https://blockscout.com/shiden", + "group": "Mainnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/shiden.svg" + }, + { + "title": "Goerli", + "url": "https://eth-goerli.blockscout.com/", + "group": "Testnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/goerli.svg", + "isActive": true + }, + { + "title": "Optimism Goerli", + "url": "https://blockscout.com/optimism/mainnet/", + "group": "Mainnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/optimism.svg" + }, + { + "title": "Optimism Goerli", + "url": "https://blockscout.com/optimism/goerli/", + "group": "Testnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/optimism.svg" + }, + { + "title": "Optimism Bedrock Beta", + "url": "https://blockscout.com/optimism/bedrock-beta", + "group": "Testnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/goerli.svg" + }, + { + "title": "Gnosis Chiado", + "url": "https://blockscout.com/gnosis/chiado/", + "group": "Testnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/goerli.svg" + }, + { + "title": "Shibuya (EVM)", + "url": "https://blockscout.com/shibuya", + "group": "Testnets", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/shibuya.svg" + }, + { + "title": "Optimism Opcraft", + "url": "https://blockscout.com/optimism/opcraft", + "group": "Other" + }, + { + "title": "ARTIS-Σ1", + "url": "https://blockscout.com/artis/sigma1", + "group": "Other", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/artis.svg" + }, + { + "title": "LUKSO L14", + "url": "https://blockscout.com/lukso/l14", + "group": "Other", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/lukso.svg" + }, + { + "title": "POA", + "url": "https://blockscout.com/poa/core", + "group": "Other", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/poa.svg" + }, + { + "title": "POA Sokol", + "url": "https://blockscout.com/poa/sokol", + "group": "Other", + "icon": "https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/poa-sokol.svg" + } +] diff --git a/tools/featured-networks-config-validator/index.js b/tools/featured-networks-config-validator/index.js new file mode 100644 index 00000000..8f4eb79a --- /dev/null +++ b/tools/featured-networks-config-validator/index.js @@ -0,0 +1,40 @@ +const { featuredNetworkSchema } = require('./schema.js') + +const fs = require('fs') +const path = require('path') + +function readFiles(dirname, onFileContent, onError) { + fs.readdir(dirname, function (err, filenames) { + if (err) { + onError(err) + return + } + filenames.forEach(function (filename) { + fs.readFile( + path.resolve(dirname, filename), + 'utf-8', + function (err, content) { + if (err) { + onError(err) + return + } + onFileContent(filename, content) + } + ) + }) + }) +} + +console.log() +readFiles( + __dirname + '/../../configs/featured-networks', + function (filename, content) { + console.log(`⏳ Checking ${filename}...`) + featuredNetworkSchema.array().parse(JSON.parse(content)) + console.log('👍 All good!') + console.log() + }, + function (err) { + throw err + } +) diff --git a/tools/featured-networks-config-validator/script.sh b/tools/featured-networks-config-validator/script.sh new file mode 100755 index 00000000..aa695ecf --- /dev/null +++ b/tools/featured-networks-config-validator/script.sh @@ -0,0 +1,3 @@ +yarn ts-to-zod ./tools/featured-networks-config-validator/types.ts ./tools/featured-networks-config-validator/schema.ts +yarn tsc -p ./tools/featured-networks-config-validator/tsconfig.json +node ./tools/featured-networks-config-validator/index.js \ No newline at end of file diff --git a/tools/featured-networks-config-validator/tsconfig.json b/tools/featured-networks-config-validator/tsconfig.json new file mode 100644 index 00000000..a7e70648 --- /dev/null +++ b/tools/featured-networks-config-validator/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es6", + "skipLibCheck": true, + "strict": true, + "esModuleInterop": true, + "module": "CommonJS", + "moduleResolution": "node", + "isolatedModules": true, + "incremental": true, + "baseUrl": "." + }, + "include": ["./schema.ts"], + "exclude": ["node_modules"] +} diff --git a/tools/featured-networks-config-validator/types.ts b/tools/featured-networks-config-validator/types.ts new file mode 100644 index 00000000..f761da18 --- /dev/null +++ b/tools/featured-networks-config-validator/types.ts @@ -0,0 +1,9 @@ +export type NetworkGroup = 'Mainnets' | 'Testnets' | 'Other' + +export interface FeaturedNetwork { + title: string + url: string + group: NetworkGroup + icon?: string + isActive?: boolean +}