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 904d62f6..ee2f58d8 100644 --- a/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt +++ b/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt @@ -284,6 +284,11 @@ private fun parseWithMoshi(fileToParse: File) { if (parsedShortNames.contains(parsedChain.shortName)) { throw ShortNameMustBeUnique(parsedChain.shortName) } + + if (parsedChain.shortName == "*") { + throw ShortNameMustNotBeStar() + } + parsedShortNames.add(parsedChain.shortName) } 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 2b88a7d4..9be8edbb 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 @@ -11,7 +11,8 @@ class ENSMustHaveOnlyRegistry: Exception("ens can only have a registry currently class ENSRegistryAddressMustBeValid: Exception("ens registry must have valid address") class NameMustBeUnique(dup: String): Exception(" name must be unique - but found `$dup` more than once") class ShortNameMustBeUnique(dup: String): Exception("short name must be unique - but found `$dup` more than once") -class UnsupportedNamespace(): Exception("So far only the EIP155 namespace is supported") +class ShortNameMustNotBeStar: Exception("short name must not be '*'") +class UnsupportedNamespace: Exception("So far only the EIP155 namespace is supported") class ExplorersMustBeArray: Exception("explorers must be an array") class ExplorerMustHaveName: Exception("Explorer must have name") class ExplorerInvalidUrl: Exception("Explorer have url starting with https://") 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 19a0a681..a4c23394 100644 --- a/processor/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt +++ b/processor/src/test/kotlin/org/ethereum/lists/chains/TheChainChecker.kt @@ -177,6 +177,13 @@ class TheChainChecker { checkChain(file, false) } + @Test(expected = ShortNameMustNotBeStar::class) + fun shouldFailForStarShortName() { + val file = getFile("invalid/shortNameMustNotBeStar/eip155-1.json") + + checkChain(file, false) + } + @Test(expected = NameMustBeUnique::class) fun shouldFailOnNonUniqueName() { checkChain(getFile("valid/eip155-1.json"), false) diff --git a/processor/src/test/resources/test_chains/invalid/shortNameMustNotBeStar/eip155-1.json b/processor/src/test/resources/test_chains/invalid/shortNameMustNotBeStar/eip155-1.json new file mode 100644 index 00000000..bb4c8f1e --- /dev/null +++ b/processor/src/test/resources/test_chains/invalid/shortNameMustNotBeStar/eip155-1.json @@ -0,0 +1,20 @@ +{ + "name": "Ethereum Mainnet", + "shortName": "*", + "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": [] +} \ No newline at end of file