diff --git a/pkg/rpc/server/da_visualization.go b/pkg/rpc/server/da_visualization.go index f39ea3d514..ea003c6460 100644 --- a/pkg/rpc/server/da_visualization.go +++ b/pkg/rpc/server/da_visualization.go @@ -118,7 +118,7 @@ func (s *DAVisualizationServer) handleDASubmissions(w http.ResponseWriter, r *ht // If not an aggregator, return empty submissions with a message if !s.isAggregator { - response := map[string]interface{}{ + response := map[string]any{ "is_aggregator": false, "submissions": []DASubmissionInfo{}, "total": 0, @@ -139,7 +139,7 @@ func (s *DAVisualizationServer) handleDASubmissions(w http.ResponseWriter, r *ht } // Build response - response := map[string]interface{}{ + response := map[string]any{ "submissions": reversed, "total": len(reversed), } @@ -192,7 +192,7 @@ func (s *DAVisualizationServer) handleDABlobDetails(w http.ResponseWriter, r *ht } blob := blobs[0] - response := map[string]interface{}{ + response := map[string]any{ "id": blobID, "height": height, "commitment": hex.EncodeToString(commitment), @@ -215,7 +215,7 @@ func (s *DAVisualizationServer) handleDAStats(w http.ResponseWriter, r *http.Req // If not an aggregator, return empty stats if !s.isAggregator { - stats := map[string]interface{}{ + stats := map[string]any{ "is_aggregator": false, "total_submissions": 0, "message": "This node is not an aggregator and does not submit to the DA layer", @@ -264,7 +264,7 @@ func (s *DAVisualizationServer) handleDAStats(w http.ResponseWriter, r *http.Req lastSubmission = &s.submissions[len(s.submissions)-1].Timestamp } - stats := map[string]interface{}{ + stats := map[string]any{ "total_submissions": totalSubmissions, "success_count": successCount, "error_count": errorCount, @@ -272,7 +272,7 @@ func (s *DAVisualizationServer) handleDAStats(w http.ResponseWriter, r *http.Req "total_blob_size": totalBlobSize, "avg_blob_size": avgBlobSize, "avg_gas_price": avgGasPrice, - "time_range": map[string]interface{}{ + "time_range": map[string]any{ "first": firstSubmission, "last": lastSubmission, }, @@ -292,7 +292,7 @@ func (s *DAVisualizationServer) handleDAHealth(w http.ResponseWriter, r *http.Re // If not an aggregator, return simplified health status if !s.isAggregator { - health := map[string]interface{}{ + health := map[string]any{ "is_aggregator": false, "status": "n/a", "message": "This node is not an aggregator and does not submit to the DA layer", @@ -409,12 +409,12 @@ func (s *DAVisualizationServer) handleDAHealth(w http.ResponseWriter, r *http.Re } } - health := map[string]interface{}{ + health := map[string]any{ "status": healthStatus, "is_healthy": isHealthy, "connection_status": connectionStatus, "connection_healthy": connectionHealthy, - "metrics": map[string]interface{}{ + "metrics": map[string]any{ "recent_error_rate": fmt.Sprintf("%.1f%%", errorRate), "recent_errors": recentErrors, "recent_successes": recentSuccesses, @@ -454,7 +454,7 @@ func (s *DAVisualizationServer) handleDAVisualizationHTML(w http.ResponseWriter, } return s[start:end] }, - "len": func(items interface{}) int { + "len": func(items any) int { // Handle different types gracefully switch v := items.(type) { case []DASubmissionInfo: diff --git a/pkg/rpc/server/da_visualization_non_aggregator_test.go b/pkg/rpc/server/da_visualization_non_aggregator_test.go index 1d197aadc5..2c67489562 100644 --- a/pkg/rpc/server/da_visualization_non_aggregator_test.go +++ b/pkg/rpc/server/da_visualization_non_aggregator_test.go @@ -43,7 +43,7 @@ func TestNonAggregatorHandleDASubmissions(t *testing.T) { assert.Equal(t, http.StatusOK, rr.Code) assert.Equal(t, "application/json", rr.Header().Get("Content-Type")) - var response map[string]interface{} + var response map[string]any err = json.Unmarshal(rr.Body.Bytes(), &response) require.NoError(t, err) @@ -51,7 +51,7 @@ func TestNonAggregatorHandleDASubmissions(t *testing.T) { assert.Equal(t, float64(0), response["total"]) assert.Contains(t, response["message"], "not an aggregator") - submissions, ok := response["submissions"].([]interface{}) + submissions, ok := response["submissions"].([]any) require.True(t, ok) assert.Equal(t, 0, len(submissions)) } @@ -73,7 +73,7 @@ func TestNonAggregatorHandleDAStats(t *testing.T) { assert.Equal(t, http.StatusOK, rr.Code) assert.Equal(t, "application/json", rr.Header().Get("Content-Type")) - var response map[string]interface{} + var response map[string]any err = json.Unmarshal(rr.Body.Bytes(), &response) require.NoError(t, err) @@ -99,7 +99,7 @@ func TestNonAggregatorHandleDAHealth(t *testing.T) { assert.Equal(t, http.StatusOK, rr.Code) assert.Equal(t, "application/json", rr.Header().Get("Content-Type")) - var response map[string]interface{} + var response map[string]any err = json.Unmarshal(rr.Body.Bytes(), &response) require.NoError(t, err) diff --git a/pkg/rpc/server/da_visualization_test.go b/pkg/rpc/server/da_visualization_test.go index 49642bc155..099bd3c5b1 100644 --- a/pkg/rpc/server/da_visualization_test.go +++ b/pkg/rpc/server/da_visualization_test.go @@ -136,16 +136,16 @@ func TestHandleDASubmissions(t *testing.T) { assert.Equal(t, http.StatusOK, rr.Code) assert.Equal(t, "application/json", rr.Header().Get("Content-Type")) - var response map[string]interface{} + var response map[string]any err = json.Unmarshal(rr.Body.Bytes(), &response) require.NoError(t, err) assert.Equal(t, float64(1), response["total"]) - submissions, ok := response["submissions"].([]interface{}) + submissions, ok := response["submissions"].([]any) require.True(t, ok) assert.Equal(t, 1, len(submissions)) - submission := submissions[0].(map[string]interface{}) + submission := submissions[0].(map[string]any) assert.Equal(t, float64(100), submission["height"]) assert.Equal(t, float64(1024), submission["blob_size"]) assert.Equal(t, 0.5, submission["gas_price"]) diff --git a/tools/blob-decoder/main.go b/tools/blob-decoder/main.go index ea54a7c737..20ad5b92c9 100644 --- a/tools/blob-decoder/main.go +++ b/tools/blob-decoder/main.go @@ -25,12 +25,12 @@ var templatesFS embed.FS // DecodedBlob represents the result of decoding a blob type DecodedBlob struct { - Type string `json:"type"` - Data interface{} `json:"data"` - RawHex string `json:"rawHex"` - Size int `json:"size"` - Timestamp time.Time `json:"timestamp"` - Error string `json:"error,omitempty"` + Type string `json:"type"` + Data any `json:"data"` + RawHex string `json:"rawHex"` + Size int `json:"size"` + Timestamp time.Time `json:"timestamp"` + Error string `json:"error,omitempty"` } func main() { @@ -164,7 +164,7 @@ func decodeBlob(data []byte) DecodedBlob { } // Check if it's JSON - var jsonData interface{} + var jsonData any if err := json.Unmarshal(data, &jsonData); err == nil { return DecodedBlob{ Type: "JSON", @@ -175,14 +175,14 @@ func decodeBlob(data []byte) DecodedBlob { // Return as unknown binary return DecodedBlob{ Type: "Unknown", - Data: map[string]interface{}{ + Data: map[string]any{ "message": "Unable to decode blob format", "preview": hex.EncodeToString(data[:min(100, len(data))]), }, } } -func tryDecodeHeader(data []byte) interface{} { +func tryDecodeHeader(data []byte) any { var headerPb pb.SignedHeader if err := proto.Unmarshal(data, &headerPb); err != nil { return nil @@ -199,14 +199,14 @@ func tryDecodeHeader(data []byte) interface{} { } // Return a map with the actual header fields - return map[string]interface{}{ + return map[string]any{ // BaseHeader fields "height": signedHeader.Height(), "time": signedHeader.Time().Format(time.RFC3339Nano), "chainId": signedHeader.ChainID(), // Version - "version": map[string]interface{}{ + "version": map[string]any{ "block": signedHeader.Version.Block, "app": signedHeader.Version.App, }, @@ -222,30 +222,30 @@ func tryDecodeHeader(data []byte) interface{} { // Signature fields "signature": bytesToHex(signedHeader.Signature), - "signer": map[string]interface{}{ + "signer": map[string]any{ "address": bytesToHex(signedHeader.Signer.Address), "pubKey": "", }, } } -func tryDecodeSignedData(data []byte) interface{} { +func tryDecodeSignedData(data []byte) any { var signedData types.SignedData if err := signedData.UnmarshalBinary(data); err != nil { return nil } // Create transaction list - transactions := make([]map[string]interface{}, len(signedData.Txs)) + transactions := make([]map[string]any, len(signedData.Txs)) for i, tx := range signedData.Txs { - transactions[i] = map[string]interface{}{ + transactions[i] = map[string]any{ "index": i, "size": len(tx), "data": bytesToHex(tx), } } - result := map[string]interface{}{ + result := map[string]any{ "transactions": transactions, "transactionCount": len(signedData.Txs), "signature": bytesToHex(signedData.Signature), @@ -273,7 +273,7 @@ func bytesToHex(b []byte) string { return hex.EncodeToString(b) } -func sendJSONResponse(w http.ResponseWriter, data interface{}) { +func sendJSONResponse(w http.ResponseWriter, data any) { w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(data); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError)