Skip to content

Commit c208375

Browse files
committed
Adjust validation
1 parent 14c5f2c commit c208375

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/config/network.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,18 @@ func (n *NetworkConfig) Validate() error {
141141
continue
142142
}
143143
}
144-
// if the network is not forked, we need to validate RPC endpoints and private keys
145-
if _, httpOk := n.RpcHttpUrls[network]; !httpOk {
146-
if _, wsOk := n.RpcWsUrls[network]; !wsOk {
147-
return fmt.Errorf("at least one HTTP or WS RPC endpoint for %s network must be set", network)
148-
}
144+
145+
// If the network is not forked, we need to validate RPC endpoints and private keys
146+
_, httpOk := n.RpcHttpUrls[network]
147+
_, wsOk := n.RpcWsUrls[network]
148+
// WS can be present but only if HTTP is also available
149+
if wsOk && !httpOk {
150+
return fmt.Errorf("WS RPC endpoint for %s network is set without an HTTP endpoint; only HTTP or both HTTP and WS are allowed", network)
151+
}
152+
153+
// Validate that there is at least one HTTP endpoint
154+
if !httpOk {
155+
return fmt.Errorf("at least one HTTP RPC endpoint for %s network must be set", network)
149156
}
150157

151158
if _, ok := n.WalletKeys[network]; !ok {

0 commit comments

Comments
 (0)