Add status field and remove deprecated field

This commit is contained in:
ligi 2022-05-19 18:16:23 +02:00
parent 3c85532ed6
commit 6d9978eda2
No known key found for this signature in database
GPG Key ID: 8E81894010ABF23D
11 changed files with 48 additions and 16 deletions

View File

@ -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:

View File

@ -12,5 +12,5 @@
"shortName": "mrock-old",
"chainId": 1286,
"networkId": 1286,
"deprecated": true
"status": "deprecated"
}

View File

@ -12,5 +12,5 @@
"shortName": "cennz-old",
"chainId": 1337,
"networkId": 1337,
"deprecated": true
}
"status": "deprecated"
}

View File

@ -15,5 +15,5 @@
"shortName": "SO1-old",
"chainId": 218,
"networkId": 218,
"deprecated": true
"status":"deprecated"
}

View File

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

View File

@ -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<String>) {
@ -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 {

View File

@ -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")

View File

@ -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

View File

@ -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"
}

View File

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