Skip to content

Commit

Permalink
Fix parsing connection id
Browse files Browse the repository at this point in the history
  • Loading branch information
artemskriabin committed Oct 17, 2024
1 parent 9f50670 commit ad75b64
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ethermint/rpc/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"math/big"
"net"
"net/http"
"strconv"
"sync"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -225,8 +226,16 @@ func (s *websocketsServer) readLoop(wsConn *wsConn) {
continue
}

connID, ok := msg["id"].(float64)
if !ok {
var connID float64
switch id := msg["id"].(type) {
case string:
connID, err = strconv.ParseFloat(id, 64)
case float64:
connID = id
default:
err = fmt.Errorf("unknown type")
}
if err != nil {
s.sendErrResponse(
wsConn,
fmt.Errorf("invalid type for connection ID: %T", msg["id"]).Error(),
Expand Down

0 comments on commit ad75b64

Please sign in to comment.