Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/main/kotlin/org/ethereum/lists/tokens/TokenChecker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ fun getRPC(chainId: ChainId): EthereumRPC? {
return null
}
if (rpcMap[chainId.value] == null) {
val chain = chains?.first { it.chainId == chainId.value.toLong() }
val chain = chains?.firstOrNull { it.chainId == chainId.value.toLong() }

val rpc = chain?.rpc?.firstOrNull {
if (chain == null) {
println("No RPC endpoint available for chainId ${chainId.value} – ensure ethereum-lists/chains includes this network.")
return null
}

val rpc = chain.rpc?.firstOrNull {
try {
HttpEthereumRPC(it).chainId()?.value == chainId.value
} catch (e: Exception) {
Expand Down Expand Up @@ -193,4 +198,4 @@ fun JsonObject.checkFields(mandatoryFields: List<String>, optionalFields: List<S
throw IllegalArgumentException("$this contains unknown $unknownFields")
}

}
}
Loading