From f03eb77170ea66fc9cc19219e3433beb390d47e2 Mon Sep 17 00:00:00 2001 From: Kheops <26880866+0xKheops@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:51:47 +0900 Subject: [PATCH] chore: bump to prettier 3.0.3 --- package.json | 2 +- pnpm-lock.yaml | 16 +- scripts/build/steps/addChains.ts | 2 +- scripts/build/steps/addEvmNetworks.ts | 4 +- scripts/build/steps/addThemeColors.ts | 6 +- scripts/build/steps/fetchChainsExtras.ts | 6 +- scripts/build/steps/writeChaindataIndex.ts | 10 +- scripts/build/util.ts | 4 +- scripts/fetch-external/steps/doSomeThings.ts | 2 +- .../import-from-multi-relay-chain-future.js | 10 +- scripts/import-pjs-config.js | 395 +++++++++--------- 11 files changed, 234 insertions(+), 223 deletions(-) diff --git a/package.json b/package.json index 9d1709411b..cbdec41bae 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@types/tinycolor2": "^1.4.3", "ajv-cli": "^5.0.0", "import-sort-style-module": "^6.0.0", - "prettier": "^2.8.8", + "prettier": "^3.0.3", "prettier-plugin-import-sort": "^0.0.7", "tsx": "^3.13.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ad79df0304..25acad35e3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,11 +62,11 @@ devDependencies: specifier: ^6.0.0 version: 6.0.0 prettier: - specifier: ^2.8.8 - version: 2.8.8 + specifier: ^3.0.3 + version: 3.0.3 prettier-plugin-import-sort: specifier: ^0.0.7 - version: 0.0.7(prettier@2.8.8) + version: 0.0.7(prettier@3.0.3) tsx: specifier: ^3.13.0 version: 3.13.0 @@ -4680,7 +4680,7 @@ packages: tunnel-agent: 0.6.0 dev: false - /prettier-plugin-import-sort@0.0.7(prettier@2.8.8): + /prettier-plugin-import-sort@0.0.7(prettier@3.0.3): resolution: {integrity: sha512-O0KlUSq+lwvh+UiN3wZDT6wWkf7TNxTVv2/XXE5KqpRNbFJq3nRg2ftzBYFFO8QGpdWIrOB0uCTCtFjIxmVKQw==} peerDependencies: prettier: '>= 2.0' @@ -4689,14 +4689,14 @@ packages: import-sort-config: 6.0.0 import-sort-parser-babylon: 6.0.0 import-sort-parser-typescript: 6.0.0 - prettier: 2.8.8 + prettier: 3.0.3 transitivePeerDependencies: - supports-color dev: true - /prettier@2.8.8: - resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} - engines: {node: '>=10.13.0'} + /prettier@3.0.3: + resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==} + engines: {node: '>=14'} hasBin: true dev: true diff --git a/scripts/build/steps/addChains.ts b/scripts/build/steps/addChains.ts index e37a350fb9..6d7d1b5051 100644 --- a/scripts/build/steps/addChains.ts +++ b/scripts/build/steps/addChains.ts @@ -19,7 +19,7 @@ export const addChains = async () => { // only set relay and paraId if both exist on configChain // TODO: Figure out parachains automatically const hasRelay = Boolean( - configChain.relay?.id && sharedData.chainsConfig.some((chain) => chain.id === configChain.relay!.id) + configChain.relay?.id && sharedData.chainsConfig.some((chain) => chain.id === configChain.relay!.id), ) const chain: Chain = { diff --git a/scripts/build/steps/addEvmNetworks.ts b/scripts/build/steps/addEvmNetworks.ts index 41a5629583..56c612501c 100644 --- a/scripts/build/steps/addEvmNetworks.ts +++ b/scripts/build/steps/addEvmNetworks.ts @@ -156,7 +156,7 @@ export const addEvmNetworks = async () => { // for those that reject, we want the chaindata CI requests to also reject Origin: 'chrome-extension://abpofhpcakjhnpklgodncneklaobppdc', }, - } + }, ) // check response status @@ -171,7 +171,7 @@ export const addEvmNetworks = async () => { } catch (error) { return null } - }) ?? [] + }) ?? [], ) // set id diff --git a/scripts/build/steps/addThemeColors.ts b/scripts/build/steps/addThemeColors.ts index 0cdb596e5f..ad432c6e7b 100644 --- a/scripts/build/steps/addThemeColors.ts +++ b/scripts/build/steps/addThemeColors.ts @@ -42,7 +42,7 @@ export const addThemeColors = async () => { if (typeof evmNetwork.logo === 'string') { console.log( - `Extracting theme color from logo for evmNetwork ${index + 1} of ${evmNetworks.length} (${evmNetwork.name})` + `Extracting theme color from logo for evmNetwork ${index + 1} of ${evmNetworks.length} (${evmNetwork.name})`, ) evmNetwork.themeColor = (await extractDominantLogoColor('evmNetwork', evmNetwork.id, evmNetwork.logo)) ?? evmNetwork.themeColor @@ -73,7 +73,7 @@ const extractDominantLogoColor = async (entityType: string, entityId: string, lo .toBuffer((error, data, info) => { if (error) return reject(error) resolve([new Uint8ClampedArray(data.buffer), info]) - }) + }), ) const colors = await extractColors( @@ -85,7 +85,7 @@ const extractDominantLogoColor = async (entityType: string, entityId: string, lo hueDistance: 0.083333333, saturationDistance: 0.2, lightnessDistance: 0.2, - } + }, ) const mostReadable = diff --git a/scripts/build/steps/fetchChainsExtras.ts b/scripts/build/steps/fetchChainsExtras.ts index 36b4ed953e..cf8012ea83 100644 --- a/scripts/build/steps/fetchChainsExtras.ts +++ b/scripts/build/steps/fetchChainsExtras.ts @@ -55,7 +55,7 @@ const attemptToFetchChainExtras = async ( chain: Chain, rpcUrl: string, attempt: number, - maxAttempts: number + maxAttempts: number, ): Promise => { try { // fetch rpc data @@ -70,7 +70,7 @@ const attemptToFetchChainExtras = async ( // // TODO: Get parachainId from storage // ['state_getStorage', ['0x0d715f2646c8f85767b5d2764bb2782604a74d81251e398fd8a0a4d55023bb3f']], ], - RPC_REQUEST_TIMEOUT + RPC_REQUEST_TIMEOUT, ) // deconstruct rpc data @@ -98,7 +98,7 @@ const attemptToFetchChainExtras = async ( console.warn( `Fetching extras for chain ${chain.id}: attempt ${attempt} of ${maxAttempts} failed: ${ (error as Error)?.message ?? error - } (${rpcUrl})` + } (${rpcUrl})`, ) } diff --git a/scripts/build/steps/writeChaindataIndex.ts b/scripts/build/steps/writeChaindataIndex.ts index bbc6f5bbd1..55bb59f475 100644 --- a/scripts/build/steps/writeChaindataIndex.ts +++ b/scripts/build/steps/writeChaindataIndex.ts @@ -29,7 +29,7 @@ ${getFileList() .join('\n')} - ` + `, ) } @@ -54,8 +54,8 @@ const writeChains = async () => { specVersion, })), null, - 2 - ) + 2, + ), ) for (const chain of allChains) { @@ -85,8 +85,8 @@ const writeEvmNetworks = async () => { logo, })), null, - 2 - ) + 2, + ), ) for (const evmNetwork of allEvmNetworks) { diff --git a/scripts/build/util.ts b/scripts/build/util.ts index 82e75a5a2a..41e1bc0830 100644 --- a/scripts/build/util.ts +++ b/scripts/build/util.ts @@ -55,7 +55,7 @@ export const sleep = (ms: number) => new Promise((resolve) => setTimeout(r export const sendWithTimeout = async ( url: string, requests: Array<[string, any?]>, - timeout: number = 10_000 + timeout: number = 10_000, ): Promise => { const autoConnectMs = 0 const ws = new WsProvider( @@ -69,7 +69,7 @@ export const sendWithTimeout = async ( }, // doesn't matter what this is as long as it's a bit larger than `timeout` // if it's not set then `new WsProvider` will throw an uncatchable error after 60s - timeout * 99 + timeout * 99, ) return await (async () => { diff --git a/scripts/fetch-external/steps/doSomeThings.ts b/scripts/fetch-external/steps/doSomeThings.ts index 086b9da792..475d4a2cb8 100644 --- a/scripts/fetch-external/steps/doSomeThings.ts +++ b/scripts/fetch-external/steps/doSomeThings.ts @@ -12,6 +12,6 @@ export const doSomeThings = async () => { fill-rule="evenodd" /> - ` + `, ) } diff --git a/scripts/import-from-multi-relay-chain-future.js b/scripts/import-from-multi-relay-chain-future.js index 9f7a57a54c..6a2145ef16 100644 --- a/scripts/import-from-multi-relay-chain-future.js +++ b/scripts/import-from-multi-relay-chain-future.js @@ -24,7 +24,7 @@ const ss58IdOverrides = { const chaindata = JSON.parse(fs.readFileSync('chaindata.json')) const ss58Registry = JSON.parse( - (await exec('curl -sL https://raw.githubusercontent.com/paritytech/ss58-registry/main/ss58-registry.json')).stdout + (await exec('curl -sL https://raw.githubusercontent.com/paritytech/ss58-registry/main/ss58-registry.json')).stdout, ).registry // @@ -44,8 +44,8 @@ const ss58IdOverrides = { fs.readFileSync( isNaN(paraId) ? `../chaindata/${relayOldId}/manifest.json` - : `../chaindata/${relayOldId}/parathreads/${paraId}/manifest.json` - ) + : `../chaindata/${relayOldId}/parathreads/${paraId}/manifest.json`, + ), ) if (oldChain.name === undefined) oldChain.name = null @@ -90,7 +90,7 @@ const ss58IdOverrides = { rpcs: oldChain.rpcs, paraId, relay: { id: relayId }, - } + }, ) } @@ -121,7 +121,7 @@ const ss58IdOverrides = { if (JSON.stringify(chain.rpcs) !== JSON.stringify(oldChain.rpcs)) { console.log( - `Updating chain rpcs for ${id} from ${JSON.stringify(chain.rpcs)} to ${JSON.stringify(oldChain.rpcs)}` + `Updating chain rpcs for ${id} from ${JSON.stringify(chain.rpcs)} to ${JSON.stringify(oldChain.rpcs)}`, ) chain.rpcs = oldChain.rpcs } diff --git a/scripts/import-pjs-config.js b/scripts/import-pjs-config.js index 01041965c2..700d9f0bd7 100644 --- a/scripts/import-pjs-config.js +++ b/scripts/import-pjs-config.js @@ -1,6 +1,6 @@ // import { allNetworks } from '@polkadot/networks' -import fs from 'fs' -import path from 'path' +import { exists, readFile, writeFile } from 'node:fs/promises' +import path from 'node:path' import { prodChains, @@ -161,202 +161,213 @@ const trimName = (text, id) => // trim leading/trailing spaces .trim() -// import existing chaindata -const chaindataMap = Object.fromEntries(JSON.parse(fs.readFileSync('chaindata.json')).map((chain) => [chain.id, chain])) -// import existing testnets chaindata -const testnetsChaindataMap = Object.fromEntries( - JSON.parse(fs.readFileSync('testnets-chaindata.json')).map((chain) => [chain.id, chain]) -) - -// keep track of updated chain ids -const updatedChainIds = [] - -// keep track of duplicate rpcs -const seenRpcs = {} - -// derive talisman chain from pjs chain and add to chaindata -const addParaToMap = - (relay, idConflictSuffix, isTestnet = false) => - (para) => { - const map = isTestnet ? testnetsChaindataMap : chaindataMap - - let id = isTestnet ? deriveTestnetId(para.info) : deriveId(para.info) - const conflicts = isTestnet ? idConflictsTestnets : idConflicts - const conflictNums = isTestnet ? idConflictNumsTestnets : idConflictNums - if (conflicts[id] > 1) { - id = `${id}-${idConflictSuffix}` - conflictNums[id] = conflictNums[id] ? conflictNums[id] + 1 : 1 - if (conflictNums[id] > 1) id = `${id}-${conflictNums[id]}` +const main = async () => { + // import existing chaindata + const chaindataMap = Object.fromEntries( + JSON.parse(await readFile('chaindata.json')).map((chain) => [chain.id, chain]), + ) + // import existing testnets chaindata + const testnetsChaindataMap = Object.fromEntries( + JSON.parse(await readFile('testnets-chaindata.json')).map((chain) => [chain.id, chain]), + ) + + // keep track of updated chain ids + const updatedChainIds = [] + + // keep track of duplicate rpcs + const seenRpcs = {} + + // derive talisman chain from pjs chain and add to chaindata + const addParaToMap = + (relay, idConflictSuffix, isTestnet = false) => + (para) => { + const map = isTestnet ? testnetsChaindataMap : chaindataMap + + let id = isTestnet ? deriveTestnetId(para.info) : deriveId(para.info) + const conflicts = isTestnet ? idConflictsTestnets : idConflicts + const conflictNums = isTestnet ? idConflictNumsTestnets : idConflictNums + if (conflicts[id] > 1) { + id = `${id}-${idConflictSuffix}` + conflictNums[id] = conflictNums[id] ? conflictNums[id] + 1 : 1 + if (conflictNums[id] > 1) id = `${id}-${conflictNums[id]}` + } + + const chain = map[id] || { id } + + chain.name = trimName(para.text, id) + if (chain.name !== para.text) console.log(`Prettified chain name ${para.text} -> ${chain.name}`) + if (!chain.account) chain.account = '*25519' + chain.rpcs = Object.values(para.providers) + .filter((url) => url.startsWith('wss://')) + .sort(sortGoodFirst) + .filter(filterUnreliable) + .filter((rpc) => (seenRpcs[rpc] ? false : (seenRpcs[rpc] = true))) + if (relay) { + chain.paraId = para.paraId + chain.relay = relay + } else { + delete chain.paraId + delete chain.relay + } + + map[chain.id] = chain + updatedChainIds.push(chain.id) } - const chain = map[id] || { id } - - chain.name = trimName(para.text, id) - if (chain.name !== para.text) console.log(`Prettified chain name ${para.text} -> ${chain.name}`) - if (!chain.account) chain.account = '*25519' - chain.rpcs = Object.values(para.providers) - .filter((url) => url.startsWith('wss://')) - .sort(sortGoodFirst) - .filter(filterUnreliable) - .filter((rpc) => (seenRpcs[rpc] ? false : (seenRpcs[rpc] = true))) - if (relay) { - chain.paraId = para.paraId - chain.relay = relay - } else { - delete chain.paraId - delete chain.relay - } + ;[ + prodRelayPolkadot, + prodRelayKusama, + ...prodParasPolkadot, + ...prodParasPolkadotCommon, + ...prodParasKusama, + ...prodParasKusamaCommon, + ...prodChains, + ].forEach(({ info }) => { + let id = deriveId(info) + idConflicts[id] = idConflicts[id] ? idConflicts[id] + 1 : 1 + }) + ;[ + testRelayWestend, + testRelayRococo, + ...testParasWestend, + ...testParasWestendCommon, + ...testParasRococo, + ...testParasRococoCommon, + ...testChains, + ].forEach(({ info }) => { + let id = deriveTestnetId(info) + idConflictsTestnets[id] = idConflictsTestnets[id] ? idConflictsTestnets[id] + 1 : 1 + }) - map[chain.id] = chain - updatedChainIds.push(chain.id) - } + // derive relay chains + ;[prodRelayPolkadot, prodRelayKusama].forEach(addParaToMap(null, 'relay')) -;[ - prodRelayPolkadot, - prodRelayKusama, - ...prodParasPolkadot, - ...prodParasPolkadotCommon, - ...prodParasKusama, - ...prodParasKusamaCommon, - ...prodChains, -].forEach(({ info }) => { - let id = deriveId(info) - idConflicts[id] = idConflicts[id] ? idConflicts[id] + 1 : 1 -}) -;[ - testRelayWestend, - testRelayRococo, - ...testParasWestend, - ...testParasWestendCommon, - ...testParasRococo, - ...testParasRococoCommon, - ...testChains, -].forEach(({ info }) => { - let id = deriveTestnetId(info) - idConflictsTestnets[id] = idConflictsTestnets[id] ? idConflictsTestnets[id] + 1 : 1 -}) - -// derive relay chains -;[prodRelayPolkadot, prodRelayKusama].forEach(addParaToMap(null, 'relay')) - -// derive polkadot parachains -;[...prodParasPolkadot, ...prodParasPolkadotCommon].forEach(addParaToMap({ id: 'polkadot' }, 'polkadot')) - -// derive kusama parachains -;[...prodParasKusama, ...prodParasKusamaCommon].forEach(addParaToMap({ id: 'kusama' }, 'kusama')) - -// derive solo chains -prodChains.forEach(addParaToMap(null, 'standalone')) - -// derive relay (testnets) chains -;[testRelayWestend, testRelayRococo].forEach(addParaToMap(null, 'relay', true)) - -// derive westend parachains -;[...testParasWestend, ...testParasWestendCommon].forEach(addParaToMap({ id: 'westend-testnet' }, 'westend', true)) - -// derive rococo parachains -;[...testParasRococo, ...testParasRococoCommon].forEach(addParaToMap({ id: 'rococo-testnet' }, 'rococo', true)) - -// derive solo (testnets) chains -testChains.forEach(addParaToMap(null, 'standalone', true)) - -// sort chaindata -const chaindata = Object.values(chaindataMap).sort((a, b) => { - if (a.id === b.id) return 0 - if (a.id === 'polkadot') return -1 - if (b.id === 'polkadot') return 1 - if (a.id === 'kusama') return -1 - if (b.id === 'kusama') return 1 - return a.id.localeCompare(b.id) -}) - -// sort testnets chaindata -const testnetsChaindata = Object.values(testnetsChaindataMap).sort((a, b) => { - if (a.id === b.id) return 0 - if (a.id === 'westend-testnet') return -1 - if (b.id === 'westend-testnet') return 1 - if (a.id === 'rococo-testnet') return -1 - if (b.id === 'rococo-testnet') return 1 - return a.id.localeCompare(b.id) -}) - -// check for testnet <-> mainnet name conflicts and append ` Testnet` to conflicting testnet names -const chaindataNames = Object.fromEntries(chaindata.map(({ name }) => [name, true])) -testnetsChaindata.forEach((chain) => { - if (!chaindataNames[chain.name]) return - chain.name = `${chain.name} Testnet` -}) - -// check for kusama <-> polkadot <-> solochain name conflicts and append to conflicting kusama/solochain names -const [soloNames, polkadotNames] = chaindata.reduce( - ([solo, polka], chain) => { - if (['polkadot', 'kusama'].includes(chain.id)) return [solo, polka] - - if (!chain.relay) return [[...solo, chain.name], polka] - if (chain.relay.id === 'polkadot') return [solo, [...polka, chain.name]] - - return [solo, polka] - }, - [[], []] -) -chaindata.forEach((chain) => { - if (chain.relay?.id === 'kusama') - if ([...polkadotNames, ...soloNames].includes(chain.name)) { - // do nothing - // chain.name = `${chain.name} Kusama` - } + // derive polkadot parachains + ;[...prodParasPolkadot, ...prodParasPolkadotCommon].forEach(addParaToMap({ id: 'polkadot' }, 'polkadot')) - if (!chain.relay) if ([...polkadotNames].includes(chain.name)) chain.name = `${chain.name} Standalone` -}) + // derive kusama parachains + ;[...prodParasKusama, ...prodParasKusamaCommon].forEach(addParaToMap({ id: 'kusama' }, 'kusama')) -// write updated files -fs.writeFileSync('chaindata.json', prettier.format(JSON.stringify(chaindata, null, 2), { parser: 'json' })) -fs.writeFileSync( - 'testnets-chaindata.json', - prettier.format(JSON.stringify(testnetsChaindata, null, 2), { - parser: 'json', + // derive solo chains + prodChains.forEach(addParaToMap(null, 'standalone')) + + // derive relay (testnets) chains + ;[testRelayWestend, testRelayRococo].forEach(addParaToMap(null, 'relay', true)) + + // derive westend parachains + ;[...testParasWestend, ...testParasWestendCommon].forEach(addParaToMap({ id: 'westend-testnet' }, 'westend', true)) + + // derive rococo parachains + ;[...testParasRococo, ...testParasRococoCommon].forEach(addParaToMap({ id: 'rococo-testnet' }, 'rococo', true)) + + // derive solo (testnets) chains + testChains.forEach(addParaToMap(null, 'standalone', true)) + + // sort chaindata + const chaindata = Object.values(chaindataMap).sort((a, b) => { + if (a.id === b.id) return 0 + if (a.id === 'polkadot') return -1 + if (b.id === 'polkadot') return 1 + if (a.id === 'kusama') return -1 + if (b.id === 'kusama') return 1 + return a.id.localeCompare(b.id) + }) + + // sort testnets chaindata + const testnetsChaindata = Object.values(testnetsChaindataMap).sort((a, b) => { + if (a.id === b.id) return 0 + if (a.id === 'westend-testnet') return -1 + if (b.id === 'westend-testnet') return 1 + if (a.id === 'rococo-testnet') return -1 + if (b.id === 'rococo-testnet') return 1 + return a.id.localeCompare(b.id) }) -) - -console.log('Import complete!') - -// check for missing chain logos -;[...chaindata, ...testnetsChaindata].forEach((chain) => { - const hasLogo = fs.existsSync(path.join('assets', 'chains', `${chain.id}.svg`)) - if (hasLogo) return - - console.log(`Missing logo for chain ${chain.id}`) -}) - -// check for paraId conflicts on each relay chain -const relayChainsByParaId = {} -;[...chaindata, ...testnetsChaindata].forEach((chain) => { - if (typeof chain.relay?.id !== 'string') return - relayChainsByParaId[chain.relay?.id] = relayChainsByParaId[chain.relay?.id] || {} - relayChainsByParaId[chain.relay?.id][chain.paraId] = relayChainsByParaId[chain.relay?.id][chain.paraId] || [] - relayChainsByParaId[chain.relay?.id][chain.paraId].push(chain.id) -}) - -Object.entries(relayChainsByParaId).forEach(([relayId, chains]) => { - Object.entries(chains) - .filter(([, chainIds]) => chainIds.length > 1) - .forEach((conflict) => { - console.log(`Conflicting ${relayId} paraId ${conflict[0]}: ${conflict[1].join(', ')}`) - }) -}) - -// check for id conflicts between testnets and production -for (const id of Object.keys(chaindataMap)) { - if (!testnetsChaindataMap[id]) continue - console.log(`Testnet id ${id} conflicts with production`) + + // check for testnet <-> mainnet name conflicts and append ` Testnet` to conflicting testnet names + const chaindataNames = Object.fromEntries(chaindata.map(({ name }) => [name, true])) + testnetsChaindata.forEach((chain) => { + if (!chaindataNames[chain.name]) return + chain.name = `${chain.name} Testnet` + }) + + // check for kusama <-> polkadot <-> solochain name conflicts and append to conflicting kusama/solochain names + const [soloNames, polkadotNames] = chaindata.reduce( + ([solo, polka], chain) => { + if (['polkadot', 'kusama'].includes(chain.id)) return [solo, polka] + + if (!chain.relay) return [[...solo, chain.name], polka] + if (chain.relay.id === 'polkadot') return [solo, [...polka, chain.name]] + + return [solo, polka] + }, + [[], []], + ) + chaindata.forEach((chain) => { + if (chain.relay?.id === 'kusama') + if ([...polkadotNames, ...soloNames].includes(chain.name)) { + // do nothing + // chain.name = `${chain.name} Kusama` + } + + if (!chain.relay) if ([...polkadotNames].includes(chain.name)) chain.name = `${chain.name} Standalone` + }) + + // write updated files + await writeFile('chaindata.json', await prettier.format(JSON.stringify(chaindata, null, 2), { parser: 'json' })) + await writeFile( + 'testnets-chaindata.json', + await prettier.format(JSON.stringify(testnetsChaindata, null, 2), { + parser: 'json', + }), + ) + + console.log('Import complete!') + + // check for missing chain logos + ;[...chaindata, ...testnetsChaindata].forEach((chain) => { + const hasLogo = exists(path.join('assets', 'chains', `${chain.id}.svg`)) + if (hasLogo) return + + console.log(`Missing logo for chain ${chain.id}`) + }) + + // check for paraId conflicts on each relay chain + const relayChainsByParaId = {} + ;[...chaindata, ...testnetsChaindata].forEach((chain) => { + if (typeof chain.relay?.id !== 'string') return + relayChainsByParaId[chain.relay?.id] = relayChainsByParaId[chain.relay?.id] || {} + relayChainsByParaId[chain.relay?.id][chain.paraId] = relayChainsByParaId[chain.relay?.id][chain.paraId] || [] + relayChainsByParaId[chain.relay?.id][chain.paraId].push(chain.id) + }) + + Object.entries(relayChainsByParaId).forEach(([relayId, chains]) => { + Object.entries(chains) + .filter(([, chainIds]) => chainIds.length > 1) + .forEach((conflict) => { + console.log(`Conflicting ${relayId} paraId ${conflict[0]}: ${conflict[1].join(', ')}`) + }) + }) + + // check for id conflicts between testnets and production + for (const id of Object.keys(chaindataMap)) { + if (!testnetsChaindataMap[id]) continue + console.log(`Testnet id ${id} conflicts with production`) + } + + // print existing chains which aren't listed in pjs repo + const chainIds = Object.fromEntries([ + ...chaindata.map(({ id }) => [id, true]), + ...testnetsChaindata.map(({ id }) => [id, true]), + ]) + updatedChainIds.forEach((id) => delete chainIds[id]) + Object.keys(chainIds).forEach((id) => + console.log(`Note: chain ${id} exists in chaindata but not in @polkadot/apps-config`), + ) } -// print existing chains which aren't listed in pjs repo -const chainIds = Object.fromEntries([ - ...chaindata.map(({ id }) => [id, true]), - ...testnetsChaindata.map(({ id }) => [id, true]), -]) -updatedChainIds.forEach((id) => delete chainIds[id]) -Object.keys(chainIds).forEach((id) => - console.log(`Note: chain ${id} exists in chaindata but not in @polkadot/apps-config`) -) +main() + .then(() => process.exit(0)) + .catch((err) => { + console.error(err) + process.exit(1) + })