Improve deprecation of chains

closes #1003
This commit is contained in:
ligi 2022-03-30 15:36:25 +02:00
parent 5a7564fe61
commit da94738893
No known key found for this signature in database
GPG Key ID: 8E81894010ABF23D
8 changed files with 48 additions and 15 deletions

View File

@ -1,5 +1,5 @@
{
"name": "Moonrock",
"name": "Moonrock old",
"chain": "MOON",
"rpc": [],
"faucets": [],
@ -9,7 +9,8 @@
"decimals": 18
},
"infoURL": "",
"shortName": "mrock",
"shortName": "mrock-old",
"chainId": 1286,
"networkId": 1286
"networkId": 1286,
"deprecated": true
}

View File

@ -1,5 +1,5 @@
{
"name": "SoterOne Mainnet",
"name": "SoterOne Mainnet old",
"chain": "SOTER",
"rpc": [
"https://rpc.soter.one"
@ -12,7 +12,8 @@
"decimals": 18
},
"infoURL": "https://www.soterone.com",
"shortName": "SO1",
"shortName": "SO1-old",
"chainId": 218,
"networkId": 218
"networkId": 218,
"deprecated": true
}

View File

@ -22,7 +22,8 @@ val optionalFields = listOf(
"explorers",
"title",
"network",
"parent"
"parent",
"deprecated"
)
val moshi: Moshi = Moshi.Builder().build()

View File

@ -93,10 +93,8 @@ private fun doChecks(doRPCConnect: Boolean) {
checkIcon(it)
}
allFiles.filter { it.isDirectory }.forEach {
if (it.name != "deprecated") {
error("the only directory allowed is 'deprecated'")
}
allFiles.filter { it.isDirectory }.forEach { _ ->
error("should not contain a directory")
}
}
@ -214,7 +212,11 @@ fun checkChain(chainFile: File, connectRPC: Boolean) {
throw ENSRegistryAddressMustBeValid()
}
}
jsonObject["deprecated"]?.let {
if (it !is Boolean) {
throw DeprecatedMustBeBoolean()
}
}
jsonObject["parent"]?.let {
if (it !is JsonObject) {
throw ParentMustBeObject()

View File

@ -26,3 +26,4 @@ class ParentBridgeNoArray: Exception("parent bridge must be array")
class BridgeNoObject: Exception("parent bridges must be array consisting of json objects")
class BridgeOnlyURL: Exception("parent bridge only contain an URL")
class ParentChainDoesNotExist(chain: String): Exception("Referenced parent chain ($chain) does not exist")
class DeprecatedMustBeBoolean: Exception("deprecated must be boolean")

View File

@ -221,6 +221,11 @@ class TheChainChecker {
checkChain(getFile("invalid/explorermissingurl/eip155-1.json"), false)
}
@Test(expected = DeprecatedMustBeBoolean::class)
fun shouldFailOnInvalidDeprecation() {
checkChain(getFile("invalid/invalid_deprecation/eip155-1.json"), false)
}
@Test
fun canParse2chains() {
checkChain(getFile("valid/eip155-1.json"), false)

View File

@ -0,0 +1,21 @@
{
"name": "Ethereum Mainnet",
"shortName": "eth",
"chain": "ETH",
"network": "mainnet",
"chainId": 1,
"networkId": 1,
"rpc": [
"https://mainnet.infura.io/v3/${INFURA_API_KEY}",
"https://api.mycryptoapi.com/eth"
],
"faucets": [],
"infoURL": "https://ethereum.org",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"explorers": [],
"deprecated": "yolo"
}

View File

@ -15,5 +15,6 @@
"name": "Ether",
"symbol": "ETH",
"decimals": 18
}
},
"deprecated": true
}