2019-07-02 10:00:13 +00:00
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
2019-07-02 10:17:25 +00:00
|
|
|
const {
|
|
|
|
CHAINS_DIRECTORY,
|
|
|
|
startSpinner,
|
|
|
|
stopSpinner,
|
|
|
|
stat,
|
|
|
|
tableLog,
|
|
|
|
toNumber
|
|
|
|
} = require('./shared')
|
2019-07-02 10:00:13 +00:00
|
|
|
|
|
|
|
fs.readdir(CHAINS_DIRECTORY, async function (err, files) {
|
|
|
|
if (err) {
|
|
|
|
console.error('Could not list the directory.', err)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
let matches = []
|
|
|
|
|
2019-07-02 10:17:25 +00:00
|
|
|
startSpinner(`Counting ${CHAINS_DIRECTORY}`)
|
|
|
|
|
2019-07-02 10:00:13 +00:00
|
|
|
await Promise.all(
|
|
|
|
files.map(async function (file, index) {
|
|
|
|
const filePath = path.join(CHAINS_DIRECTORY, file)
|
|
|
|
const fileStat = await stat(filePath)
|
|
|
|
const ext = path.extname(file)
|
|
|
|
if (fileStat.isFile() && ext === '.json') {
|
|
|
|
let json = require(filePath)
|
|
|
|
if (toNumber(json.chainId) !== toNumber(json.networkId)) {
|
|
|
|
matches.push(json)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fileStat
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
2019-07-02 10:17:25 +00:00
|
|
|
stopSpinner()
|
|
|
|
|
2019-07-02 10:00:13 +00:00
|
|
|
console.log(
|
|
|
|
`There are ${files.length} known EVM chains from which ${
|
|
|
|
matches.length
|
|
|
|
} have unmatched ids, here are the list of those chains: `
|
|
|
|
)
|
|
|
|
tableLog(matches)
|
|
|
|
})
|