diff --git a/README.md b/README.md index 6588439c..c8e770c8 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ If the chain is an L2 or a shard of another chain you can link it to the parent where you need to specify type 2 and the reference to an existing parent. The field about bridges is optional. +You can add a `status` field e.g. to `deprecate` a chain (a chain should never be deleted as this would open the door to replay attacks) +Other options for `status` are `active` (default) or `incubating` + ## Aggregation There are also aggregated json files with all chains automatically assembled: diff --git a/_data/chains/eip155-1286.json b/_data/chains/eip155-1286.json index 87c2353c..cf48e92d 100644 --- a/_data/chains/eip155-1286.json +++ b/_data/chains/eip155-1286.json @@ -12,5 +12,5 @@ "shortName": "mrock-old", "chainId": 1286, "networkId": 1286, - "deprecated": true + "status": "deprecated" } diff --git a/_data/chains/eip155-1337.json b/_data/chains/eip155-1337.json index b30f09d2..990b6aaf 100644 --- a/_data/chains/eip155-1337.json +++ b/_data/chains/eip155-1337.json @@ -12,5 +12,5 @@ "shortName": "cennz-old", "chainId": 1337, "networkId": 1337, - "deprecated": true -} \ No newline at end of file + "status": "deprecated" +} diff --git a/_data/chains/eip155-218.json b/_data/chains/eip155-218.json index fae3262a..4a030a42 100644 --- a/_data/chains/eip155-218.json +++ b/_data/chains/eip155-218.json @@ -15,5 +15,5 @@ "shortName": "SO1-old", "chainId": 218, "networkId": 218, - "deprecated": true + "status":"deprecated" } 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 20ec2842..418b9972 100644 --- a/processor/src/main/kotlin/org/ethereum/lists/chains/Env.kt +++ b/processor/src/main/kotlin/org/ethereum/lists/chains/Env.kt @@ -23,7 +23,7 @@ val optionalFields = listOf( "title", "network", "parent", - "deprecated" + "status" ) 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 786f9352..2873836a 100644 --- a/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt +++ b/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt @@ -17,7 +17,7 @@ val dataPath = File(basePath, "_data") val iconsPath = File(dataPath, "icons") val chainsPath = File(dataPath, "chains") -private val allFiles = chainsPath.listFiles() ?: error("$chainsPath must contain the chain json files - but it does not") +private val allFiles = chainsPath.listFiles() ?: error("${chainsPath.absolutePath} must contain the chain json files - but it does not") private val allChainFiles = allFiles.filter { !it.isDirectory } fun main(args: Array) { @@ -235,9 +235,12 @@ fun checkChain(chainFile: File, connectRPC: Boolean) { throw ENSRegistryAddressMustBeValid() } } - jsonObject["deprecated"]?.let { - if (it !is Boolean) { - throw DeprecatedMustBeBoolean() + jsonObject["status"]?.let { + if (it !is String) { + throw StatusMustBeString() + } + if (!setOf("incubating","active","deprecated").contains(it)) { + throw StatusMustBeIncubatingActiveOrDeprecated() } } jsonObject["parent"]?.let { 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 f02e62da..92633ccf 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 @@ -26,7 +26,8 @@ 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") +class StatusMustBeString: Exception("status must be a string") +class StatusMustBeIncubatingActiveOrDeprecated: Exception("status must be either incubating, active or deprecated") class NativeCurrencyMustBeObject: Exception("Native currency must be object") class NativeCurrencySymbolMustBeString: Exception("Native currency symbol must be string") class NativeCurrencySymbolMustHaveLessThan7Chars: Exception("Native currency symbol must have less than 7 chars") 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 17d213a2..6ab8ea30 100644 --- a/processor/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt +++ b/processor/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt @@ -221,9 +221,14 @@ 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(expected = StatusMustBeString::class) + fun shouldFailOnInvalidStatusType() { + checkChain(getFile("invalid/invalid_status/eip155-1.json"), false) + } + + @Test(expected = StatusMustBeIncubatingActiveOrDeprecated::class) + fun shouldFailOnInvalidStatus() { + checkChain(getFile("invalid/invalid_status/eip155-2.json"), false) } @Test diff --git a/processor/src/test/resources/test_chains/invalid/invalid_deprecation/eip155-1.json b/processor/src/test/resources/test_chains/invalid/invalid_status/eip155-1.json similarity index 94% rename from processor/src/test/resources/test_chains/invalid/invalid_deprecation/eip155-1.json rename to processor/src/test/resources/test_chains/invalid/invalid_status/eip155-1.json index 11a8782e..72d00fe8 100644 --- a/processor/src/test/resources/test_chains/invalid/invalid_deprecation/eip155-1.json +++ b/processor/src/test/resources/test_chains/invalid/invalid_status/eip155-1.json @@ -17,5 +17,5 @@ "decimals": 18 }, "explorers": [], - "deprecated": "yolo" + "status": 1 } \ No newline at end of file diff --git a/processor/src/test/resources/test_chains/invalid/invalid_status/eip155-2.json b/processor/src/test/resources/test_chains/invalid/invalid_status/eip155-2.json new file mode 100644 index 00000000..aaa9ffb3 --- /dev/null +++ b/processor/src/test/resources/test_chains/invalid/invalid_status/eip155-2.json @@ -0,0 +1,21 @@ +{ + "name": "Ethereum Mainnet", + "shortName": "eth", + "chain": "ETH", + "network": "mainnet", + "chainId": 2, + "networkId": 2, + "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": [], + "status": "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 847e295f..457f8964 100644 --- a/processor/src/test/resources/test_chains/valid/eip155-1.json +++ b/processor/src/test/resources/test_chains/valid/eip155-1.json @@ -15,6 +15,5 @@ "name": "Ether", "symbol": "ETH", "decimals": 18 - }, - "deprecated": true + } }