From ccbf55afd689a0a43a116d63f6e72f751e920130 Mon Sep 17 00:00:00 2001 From: ligi Date: Wed, 29 Dec 2021 22:08:15 +0100 Subject: [PATCH] Add Explorer field to model --- .../kotlin/org/ethereum/lists/chains/Main.kt | 4 ++-- .../org/ethereum/lists/chains/model/Chain.kt | 19 ++++++++++--------- .../ethereum/lists/chains/model/Explorer.kt | 7 +++++++ .../ethereum/lists/chains/TheChainChecker.kt | 2 +- .../eip155-1.json} | 5 +++++ .../invalid/sameshortname/eip155-1.json | 5 +++++ 6 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 src/main/kotlin/org/ethereum/lists/chains/model/Explorer.kt rename src/test/resources/test_chains/invalid/{eip155-extracomma.json => extracomma/eip155-1.json} (76%) diff --git a/src/main/kotlin/org/ethereum/lists/chains/Main.kt b/src/main/kotlin/org/ethereum/lists/chains/Main.kt index 523ca1ce..ff65b415 100644 --- a/src/main/kotlin/org/ethereum/lists/chains/Main.kt +++ b/src/main/kotlin/org/ethereum/lists/chains/Main.kt @@ -138,8 +138,6 @@ fun checkIcon(icon: File) { fun checkChain(chainFile: File, connectRPC: Boolean) { println("processing $chainFile") - parseWithMoshi(chainFile) - val jsonObject = Klaxon().parseJsonObject(chainFile.reader()) val chainAsLong = getNumber(jsonObject, "chainId") @@ -248,6 +246,8 @@ fun checkChain(chainFile: File, connectRPC: Boolean) { } + parseWithMoshi(chainFile) + if (connectRPC) { if (jsonObject["rpc"] is List<*>) { (jsonObject["rpc"] as List<*>).forEach { diff --git a/src/main/kotlin/org/ethereum/lists/chains/model/Chain.kt b/src/main/kotlin/org/ethereum/lists/chains/model/Chain.kt index 86d29ec1..e65077dd 100644 --- a/src/main/kotlin/org/ethereum/lists/chains/model/Chain.kt +++ b/src/main/kotlin/org/ethereum/lists/chains/model/Chain.kt @@ -1,13 +1,14 @@ package org.ethereum.lists.chains.model data class Chain( - val name: String, - val shortName: String, - val chain: String, - val network: String, - val chainId: Long, - val networkId: Long, - val rpc: List, - val faucets: List, - val infoURL: String, + val name: String, + val shortName: String, + val chain: String, + val network: String, + val chainId: Long, + val networkId: Long, + val rpc: List, + val faucets: List, + val explorers: List?, + val infoURL: String, ) \ No newline at end of file diff --git a/src/main/kotlin/org/ethereum/lists/chains/model/Explorer.kt b/src/main/kotlin/org/ethereum/lists/chains/model/Explorer.kt new file mode 100644 index 00000000..932d9119 --- /dev/null +++ b/src/main/kotlin/org/ethereum/lists/chains/model/Explorer.kt @@ -0,0 +1,7 @@ +package org.ethereum.lists.chains.model + +data class Explorer( + val name: String, + val url: String, + val standard: String +) \ No newline at end of file diff --git a/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt b/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt index bd3c3ad4..19a0a681 100644 --- a/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt +++ b/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt @@ -172,7 +172,7 @@ class TheChainChecker { @Test(expected = JsonEncodingException::class) fun shouldFailForExtraComma() { - val file = getFile("invalid/eip155-extracomma.json") + val file = getFile("invalid/extracomma/eip155-1.json") checkChain(file, false) } diff --git a/src/test/resources/test_chains/invalid/eip155-extracomma.json b/src/test/resources/test_chains/invalid/extracomma/eip155-1.json similarity index 76% rename from src/test/resources/test_chains/invalid/eip155-extracomma.json rename to src/test/resources/test_chains/invalid/extracomma/eip155-1.json index 8fa947c1..4d18cd85 100644 --- a/src/test/resources/test_chains/invalid/eip155-extracomma.json +++ b/src/test/resources/test_chains/invalid/extracomma/eip155-1.json @@ -9,6 +9,11 @@ "https://mainnet.infura.io/v3/${INFURA_API_KEY}", "https://api.mycryptoapi.com/eth" ], + "nativeCurrency": { + "name": "Ether", + "symbol": "ETH", + "decimals": 18 + }, "faucets": [], "infoURL": "https://ethereum.org", } diff --git a/src/test/resources/test_chains/invalid/sameshortname/eip155-1.json b/src/test/resources/test_chains/invalid/sameshortname/eip155-1.json index d3f9eee1..104eaab3 100644 --- a/src/test/resources/test_chains/invalid/sameshortname/eip155-1.json +++ b/src/test/resources/test_chains/invalid/sameshortname/eip155-1.json @@ -9,6 +9,11 @@ "https://mainnet.infura.io/v3/${INFURA_API_KEY}", "https://api.mycryptoapi.com/eth" ], + "nativeCurrency": { + "name": "Görli Ether", + "symbol": "GOR", + "decimals": 18 + }, "faucets": [], "infoURL": "https://ethereum.org" }