diff --git a/_data/chains/deprecated/eip155-1286.json b/_data/chains/eip155-1286.json similarity index 63% rename from _data/chains/deprecated/eip155-1286.json rename to _data/chains/eip155-1286.json index 3cc60c66..87c2353c 100644 --- a/_data/chains/deprecated/eip155-1286.json +++ b/_data/chains/eip155-1286.json @@ -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 -} \ No newline at end of file + "networkId": 1286, + "deprecated": true +} diff --git a/_data/chains/deprecated/eip155-218.json b/_data/chains/eip155-218.json similarity index 71% rename from _data/chains/deprecated/eip155-218.json rename to _data/chains/eip155-218.json index 9cc2c382..fae3262a 100644 --- a/_data/chains/deprecated/eip155-218.json +++ b/_data/chains/eip155-218.json @@ -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 } diff --git a/processor/src/main/kotlin/org/ethereum/lists/chains/Env.kt b/processor/src/main/kotlin/org/ethereum/lists/chains/Env.kt index fbb13991..20ec2842 100644 --- a/processor/src/main/kotlin/org/ethereum/lists/chains/Env.kt +++ b/processor/src/main/kotlin/org/ethereum/lists/chains/Env.kt @@ -22,7 +22,8 @@ val optionalFields = listOf( "explorers", "title", "network", - "parent" + "parent", + "deprecated" ) val moshi: Moshi = Moshi.Builder().build() diff --git a/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt b/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt index 05c30ca2..ace5915c 100644 --- a/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt +++ b/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt @@ -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() diff --git a/processor/src/main/kotlin/org/ethereum/lists/chains/model/Exceptions.kt b/processor/src/main/kotlin/org/ethereum/lists/chains/model/Exceptions.kt index 1f0830e1..522e9eb2 100644 --- a/processor/src/main/kotlin/org/ethereum/lists/chains/model/Exceptions.kt +++ b/processor/src/main/kotlin/org/ethereum/lists/chains/model/Exceptions.kt @@ -25,4 +25,5 @@ class ParentHasExtraFields(fields: Set): Exception("parent has extra fie 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") \ No newline at end of file +class ParentChainDoesNotExist(chain: String): Exception("Referenced parent chain ($chain) does not exist") +class DeprecatedMustBeBoolean: Exception("deprecated must be boolean") \ No newline at end of file diff --git a/processor/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt b/processor/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt index 327d8eb4..17d213a2 100644 --- a/processor/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt +++ b/processor/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt @@ -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) diff --git a/processor/src/test/resources/test_chains/invalid/invalid_deprecation/eip155-1.json b/processor/src/test/resources/test_chains/invalid/invalid_deprecation/eip155-1.json new file mode 100644 index 00000000..11a8782e --- /dev/null +++ b/processor/src/test/resources/test_chains/invalid/invalid_deprecation/eip155-1.json @@ -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" +} \ No newline at end of file diff --git a/processor/src/test/resources/test_chains/valid/eip155-1.json b/processor/src/test/resources/test_chains/valid/eip155-1.json index 457f8964..847e295f 100644 --- a/processor/src/test/resources/test_chains/valid/eip155-1.json +++ b/processor/src/test/resources/test_chains/valid/eip155-1.json @@ -15,5 +15,6 @@ "name": "Ether", "symbol": "ETH", "decimals": 18 - } + }, + "deprecated": true }