mirror of
https://github.com/Instadapp/chains.git
synced 2024-07-29 22:37:19 +00:00
Check RPC schemas
This commit is contained in:
parent
87417e5e6d
commit
5accff5810
|
@ -44,4 +44,7 @@ val ipfs by lazy {
|
||||||
Moshi.Builder().build()
|
Moshi.Builder().build()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val httpPrefixes = listOf("https://", "http://")
|
||||||
|
val rpcPrefixes = httpPrefixes + listOf("wss://", "ws://")
|
|
@ -315,7 +315,7 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
val url = explorer["url"]
|
val url = explorer["url"]
|
||||||
if (url == null || url !is String || !(url.startsWith("https://") || url.startsWith("http://"))) {
|
if (url == null || url !is String || httpPrefixes.none { prefix -> url.startsWith(prefix) } ) {
|
||||||
throw (ExplorerMustWithHttpsOrHttp())
|
throw (ExplorerMustWithHttpsOrHttp())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,6 +412,8 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
|
||||||
throw (RPCMustBeListOfStrings())
|
throw (RPCMustBeListOfStrings())
|
||||||
} else if (it.isBlank()) {
|
} else if (it.isBlank()) {
|
||||||
throw (RPCCannotBeEmpty())
|
throw (RPCCannotBeEmpty())
|
||||||
|
} else if (rpcPrefixes.none { prefix -> it.startsWith(prefix) }) {
|
||||||
|
throw (InvalidRPCPrefix(it))
|
||||||
} else {
|
} else {
|
||||||
if (connectRPC) {
|
if (connectRPC) {
|
||||||
var chainId: BigInteger? = null
|
var chainId: BigInteger? = null
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.ethereum.lists.chains.model
|
package org.ethereum.lists.chains.model
|
||||||
|
|
||||||
|
import org.ethereum.lists.chains.rpcPrefixes
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class FileNameMustMatchChainId : Exception("chainId must match the filename")
|
class FileNameMustMatchChainId : Exception("chainId must match the filename")
|
||||||
|
@ -9,6 +10,7 @@ class ShouldHaveNoMissingFields(fields: Set<String>) : Exception("missing field(
|
||||||
class RPCMustBeList : Exception("rpc must be a list")
|
class RPCMustBeList : Exception("rpc must be a list")
|
||||||
class RPCMustBeListOfStrings : Exception("rpc must be a list of strings")
|
class RPCMustBeListOfStrings : Exception("rpc must be a list of strings")
|
||||||
class RPCCannotBeEmpty : Exception("rpc cannot be empty")
|
class RPCCannotBeEmpty : Exception("rpc cannot be empty")
|
||||||
|
class InvalidRPCPrefix(prefix: String) : Exception("rpc has invalid prefix: $prefix - must be any of $rpcPrefixes")
|
||||||
class ENSMustBeObject: Exception("ens must be an object")
|
class ENSMustBeObject: Exception("ens must be an object")
|
||||||
class ENSMustHaveOnlyRegistry: Exception("ens can only have a registry currently")
|
class ENSMustHaveOnlyRegistry: Exception("ens can only have a registry currently")
|
||||||
class ENSRegistryAddressMustBeValid: Exception("ens registry must have valid address")
|
class ENSRegistryAddressMustBeValid: Exception("ens registry must have valid address")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user