mirror of
https://github.com/Instadapp/chains.git
synced 2024-07-29 22:37:19 +00:00
Normalize names and shortNames (#1412)
This commit is contained in:
parent
62a13890ba
commit
4ba4ca129c
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "OM Chain Mainnet",
|
||||
"chain": "omchain",
|
||||
"name": "OM Platform Mainnet",
|
||||
"chain": "omplatform",
|
||||
"network": "mainnet",
|
||||
"rpc": [
|
||||
"https://rpc-cnx.omplatform.com/"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"decimals": 18
|
||||
},
|
||||
"infoURL": "https://reichain.io",
|
||||
"shortName": "rei",
|
||||
"shortName": "reichain",
|
||||
"chainId": 55555,
|
||||
"networkId": 55555,
|
||||
"explorers": [{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"decimals": 18
|
||||
},
|
||||
"infoURL": "https://ellaism.org",
|
||||
"shortName": "ella",
|
||||
"shortName": "ellaism",
|
||||
"chainId": 64,
|
||||
"networkId": 64,
|
||||
"slip44": 163
|
||||
|
|
|
@ -329,26 +329,30 @@ fun checkChain(chainFile: File, connectRPC: Boolean) {
|
|||
}
|
||||
}
|
||||
|
||||
fun String.normalizeName() = replace(" ","").uppercase()
|
||||
|
||||
/*
|
||||
moshi fails for extra commas
|
||||
https://github.com/ethereum-lists/chains/issues/126
|
||||
*/
|
||||
private fun parseWithMoshi(fileToParse: File) {
|
||||
val parsedChain = chainAdapter.fromJson(fileToParse.readText())
|
||||
if (parsedNames.contains(parsedChain!!.name)) {
|
||||
throw NameMustBeUnique(parsedChain.name)
|
||||
val parsedChainNormalizedName = parsedChain!!.name.normalizeName()
|
||||
if (parsedNames.contains(parsedChainNormalizedName)) {
|
||||
throw NameMustBeUnique(parsedChainNormalizedName)
|
||||
}
|
||||
parsedNames.add(parsedChain.name)
|
||||
parsedNames.add(parsedChainNormalizedName)
|
||||
|
||||
if (parsedShortNames.contains(parsedChain.shortName)) {
|
||||
throw ShortNameMustBeUnique(parsedChain.shortName)
|
||||
val parsedChainNormalizedShortName = parsedChain.shortName.normalizeName()
|
||||
if (parsedShortNames.contains(parsedChainNormalizedShortName)) {
|
||||
throw ShortNameMustBeUnique(parsedChainNormalizedShortName)
|
||||
}
|
||||
|
||||
if (parsedChain.shortName == "*") {
|
||||
if (parsedChainNormalizedShortName == "*") {
|
||||
throw ShortNameMustNotBeStar()
|
||||
}
|
||||
|
||||
parsedShortNames.add(parsedChain.shortName)
|
||||
parsedShortNames.add(parsedChainNormalizedShortName)
|
||||
}
|
||||
|
||||
private fun getNumber(jsonObject: JsonObject, field: String): Long {
|
||||
|
|
Loading…
Reference in New Issue
Block a user