Sort chains by chainID in json files - closes #61 (#333)

This commit is contained in:
ligi 2021-07-11 19:17:46 +02:00 committed by GitHub
parent 4fe1b852e2
commit 4ea7eef329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,23 +38,25 @@ private fun createOutputFiles() {
val chainJSONArray = JsonArray<JsonObject>()
val miniChainJSONArray = JsonArray<JsonObject>()
allChainFiles.forEach {
val jsonObject = Klaxon().parseJsonObject(it.reader())
chainJSONArray.add(jsonObject)
fullJSONFile.writeText(chainJSONArray.toJsonString())
prettyJSONFile.writeText(chainJSONArray.toJsonString(prettyPrint = true))
allChainFiles
.map { Klaxon().parseJsonObject(it.reader()) }
.sortedBy { (it["chainId"] as Number).toLong() }
.forEach { jsonObject ->
chainJSONArray.add(jsonObject)
fullJSONFile.writeText(chainJSONArray.toJsonString())
prettyJSONFile.writeText(chainJSONArray.toJsonString(prettyPrint = true))
val miniJSON = JsonObject()
listOf("name", "chainId", "shortName", "networkId", "nativeCurrency", "rpc", "faucets", "infoURL").forEach { field ->
jsonObject[field]?.let { content ->
miniJSON[field] = content
val miniJSON = JsonObject()
listOf("name", "chainId", "shortName", "networkId", "nativeCurrency", "rpc", "faucets", "infoURL").forEach { field ->
jsonObject[field]?.let { content ->
miniJSON[field] = content
}
}
}
miniChainJSONArray.add(miniJSON)
miniChainJSONArray.add(miniJSON)
miniJSONFile.writeText(miniChainJSONArray.toJsonString())
prettyMiniJSONFile.writeText(miniChainJSONArray.toJsonString(prettyPrint = true))
}
miniJSONFile.writeText(miniChainJSONArray.toJsonString())
prettyMiniJSONFile.writeText(miniChainJSONArray.toJsonString(prettyPrint = true))
}
File(buildPath, "index.html").writeText(
"""