Skip to content

Commit 04e922e

Browse files
committed
feat: add check for chainID to detect supported network
Signed-off-by: Ji Hwan <[email protected]>
1 parent ad20838 commit 04e922e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

chainstore/passthrough_store.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ func NewPassthroughStoreWithConfig(rpcURL string, config *ChainStoreConfig) (*Pa
4141
return nil, fmt.Errorf("failed to connect to RPC: %w", err)
4242
}
4343

44+
// Verify the endpoint supports EVM by checking the chain ID
45+
var chainID string
46+
err = client.Call(&chainID, "eth_chainId")
47+
if err != nil {
48+
client.Close()
49+
return nil, fmt.Errorf("failed to retrieve chainID: %w", err)
50+
}
51+
if chainID == "" || chainID == "0x0" {
52+
client.Close()
53+
return nil, fmt.Errorf("invalid or empty chainID: %s", chainID)
54+
}
55+
4456
// Create HTTP client with timeout for signature lookups
4557
httpClient := &http.Client{
4658
Timeout: config.SignatureLookupTimeout,

0 commit comments

Comments
 (0)