From c818a035ac45afe4138a62afeb86ff619e233ae9 Mon Sep 17 00:00:00 2001 From: Mr Lightspeed <95941244+MrLightspeed@users.noreply.github.com> Date: Sun, 26 Oct 2025 19:48:54 -0400 Subject: [PATCH] fix: handle missing RPC endpoints for new chains --- .../kotlin/org/ethereum/lists/tokens/TokenChecker.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/ethereum/lists/tokens/TokenChecker.kt b/src/main/kotlin/org/ethereum/lists/tokens/TokenChecker.kt index 477f8c645..c4f2b0131 100644 --- a/src/main/kotlin/org/ethereum/lists/tokens/TokenChecker.kt +++ b/src/main/kotlin/org/ethereum/lists/tokens/TokenChecker.kt @@ -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) { @@ -193,4 +198,4 @@ fun JsonObject.checkFields(mandatoryFields: List, optionalFields: List