Skip to content

Commit 956e7bd

Browse files
committed
Add status field and remove deprecated field
1 parent 314123e commit 956e7bd

File tree

11 files changed

+48
-16
lines changed

11 files changed

+48
-16
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ If the chain is an L2 or a shard of another chain you can link it to the parent
6969

7070
where you need to specify type 2 and the reference to an existing parent. The field about bridges is optional.
7171

72+
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)
73+
Other options for `status` are `active` (default) or `incubating`
74+
7275
## Aggregation
7376

7477
There are also aggregated json files with all chains automatically assembled:

_data/chains/eip155-1286.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
"shortName": "mrock-old",
1313
"chainId": 1286,
1414
"networkId": 1286,
15-
"deprecated": true
15+
"status": "deprecated"
1616
}

_data/chains/eip155-1337.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
"shortName": "cennz-old",
1313
"chainId": 1337,
1414
"networkId": 1337,
15-
"deprecated": true
16-
}
15+
"status": "deprecated"
16+
}

_data/chains/eip155-218.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
"shortName": "SO1-old",
1616
"chainId": 218,
1717
"networkId": 218,
18-
"deprecated": true
18+
"status":"deprecated"
1919
}

processor/src/main/kotlin/org/ethereum/lists/chains/Env.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ val optionalFields = listOf(
2323
"title",
2424
"network",
2525
"parent",
26-
"deprecated"
26+
"status"
2727
)
2828

2929
val moshi: Moshi = Moshi.Builder().build()

processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ val dataPath = File(basePath, "_data")
1717
val iconsPath = File(dataPath, "icons")
1818

1919
val chainsPath = File(dataPath, "chains")
20-
private val allFiles = chainsPath.listFiles() ?: error("$chainsPath must contain the chain json files - but it does not")
20+
private val allFiles = chainsPath.listFiles() ?: error("${chainsPath.absolutePath} must contain the chain json files - but it does not")
2121
private val allChainFiles = allFiles.filter { !it.isDirectory }
2222

2323
fun main(args: Array<String>) {
@@ -235,9 +235,12 @@ fun checkChain(chainFile: File, connectRPC: Boolean) {
235235
throw ENSRegistryAddressMustBeValid()
236236
}
237237
}
238-
jsonObject["deprecated"]?.let {
239-
if (it !is Boolean) {
240-
throw DeprecatedMustBeBoolean()
238+
jsonObject["status"]?.let {
239+
if (it !is String) {
240+
throw StatusMustBeString()
241+
}
242+
if (!setOf("incubating","active","deprecated").contains(it)) {
243+
throw StatusMustBeIncubatingActiveOrDeprecated()
241244
}
242245
}
243246
jsonObject["parent"]?.let {

processor/src/main/kotlin/org/ethereum/lists/chains/model/Exceptions.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class ParentBridgeNoArray: Exception("parent bridge must be array")
2626
class BridgeNoObject: Exception("parent bridges must be array consisting of json objects")
2727
class BridgeOnlyURL: Exception("parent bridge only contain an URL")
2828
class ParentChainDoesNotExist(chain: String): Exception("Referenced parent chain ($chain) does not exist")
29-
class DeprecatedMustBeBoolean: Exception("deprecated must be boolean")
29+
class StatusMustBeString: Exception("status must be a string")
30+
class StatusMustBeIncubatingActiveOrDeprecated: Exception("status must be either incubating, active or deprecated")
3031
class NativeCurrencyMustBeObject: Exception("Native currency must be object")
3132
class NativeCurrencySymbolMustBeString: Exception("Native currency symbol must be string")
3233
class NativeCurrencySymbolMustHaveLessThan7Chars: Exception("Native currency symbol must have less than 7 chars")

processor/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt

+8-3
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,14 @@ class TheChainChecker {
221221
checkChain(getFile("invalid/explorermissingurl/eip155-1.json"), false)
222222
}
223223

224-
@Test(expected = DeprecatedMustBeBoolean::class)
225-
fun shouldFailOnInvalidDeprecation() {
226-
checkChain(getFile("invalid/invalid_deprecation/eip155-1.json"), false)
224+
@Test(expected = StatusMustBeString::class)
225+
fun shouldFailOnInvalidStatusType() {
226+
checkChain(getFile("invalid/invalid_status/eip155-1.json"), false)
227+
}
228+
229+
@Test(expected = StatusMustBeIncubatingActiveOrDeprecated::class)
230+
fun shouldFailOnInvalidStatus() {
231+
checkChain(getFile("invalid/invalid_status/eip155-2.json"), false)
227232
}
228233

229234
@Test

processor/src/test/resources/test_chains/invalid/invalid_deprecation/eip155-1.json processor/src/test/resources/test_chains/invalid/invalid_status/eip155-1.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
"decimals": 18
1818
},
1919
"explorers": [],
20-
"deprecated": "yolo"
20+
"status": 1
2121
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Ethereum Mainnet",
3+
"shortName": "eth",
4+
"chain": "ETH",
5+
"network": "mainnet",
6+
"chainId": 2,
7+
"networkId": 2,
8+
"rpc": [
9+
"https://mainnet.infura.io/v3/${INFURA_API_KEY}",
10+
"https://api.mycryptoapi.com/eth"
11+
],
12+
"faucets": [],
13+
"infoURL": "https://ethereum.org",
14+
"nativeCurrency": {
15+
"name": "Ether",
16+
"symbol": "ETH",
17+
"decimals": 18
18+
},
19+
"explorers": [],
20+
"status": "yolo"
21+
}

processor/src/test/resources/test_chains/valid/eip155-1.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@
1515
"name": "Ether",
1616
"symbol": "ETH",
1717
"decimals": 18
18-
},
19-
"deprecated": true
18+
}
2019
}

0 commit comments

Comments
 (0)