Improve faucet checks

This commit is contained in:
ligi 2022-11-30 11:15:31 +01:00
parent 8d321eedb5
commit 275fe11351
2 changed files with 21 additions and 1 deletions

View File

@ -315,7 +315,7 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
}
val url = explorer["url"]
if (url == null || url !is String || httpPrefixes.none { prefix -> url.startsWith(prefix) } ) {
if (url == null || url !is String || httpPrefixes.none { prefix -> url.startsWith(prefix) }) {
throw (ExplorerMustWithHttpsOrHttp())
}
@ -350,6 +350,23 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
}
}
jsonObject["faucets"]?.let { faucets ->
if (faucets !is List<*>) {
throw FaucetsMustBeArray()
}
faucets.forEach {
if (it !is String) {
throw FaucetMustBeString()
}
if (it.isBlank()) {
throw FaucetMustBeString()
}
}
}
jsonObject["redFlags"]?.let { redFlags ->
if (redFlags !is List<*>) {
throw RedFlagsMustBeArray()

View File

@ -25,7 +25,10 @@ class ExplorerCannotEndInSlash: Exception("Explorer cannot have a slash on the e
class ExplorerStandardMustBeEIP3091OrNone: Exception("explorer standard must be 'none' or 'EIP3091'")
class ParentHasInvalidType(type: String?): Exception("Parent has invalid type $type - only L2 or shard allowed")
class RedFlagsMustBeArray: Exception("redFlags not an array")
class FaucetsMustBeArray: Exception("faucets not an array")
class RedFlagMustBeString: Exception("redFlag not an string")
class FaucetMustBeString: Exception("faucet not an string")
class FaucetCannotBeBlank: Exception("faucet cannot be blank")
class InvalidRedFlags(flag: String): Exception("redFlags invalid $flag")
class ParentMustBeObject: Exception("parent must be an object")
class ParentMustHaveChainAndType: Exception("parent must have fields 'chain' and 'type'")