Jelajahi Sumber

common, graphql: fix hash/address decoding + UI content type

Péter Szilágyi 6 tahun lalu
induk
melakukan
49b86a2859
2 mengubah file dengan 3 tambahan dan 3 penghapusan
  1. 2 2
      common/types.go
  2. 1 1
      graphql/graphiql.go

+ 2 - 2
common/types.go

@@ -149,7 +149,7 @@ func (h *Hash) UnmarshalGraphQL(input interface{}) error {
 	var err error
 	switch input := input.(type) {
 	case string:
-		*h = HexToHash(input)
+		err = h.UnmarshalText([]byte(input))
 	default:
 		err = fmt.Errorf("Unexpected type for Bytes32: %v", input)
 	}
@@ -288,7 +288,7 @@ func (a *Address) UnmarshalGraphQL(input interface{}) error {
 	var err error
 	switch input := input.(type) {
 	case string:
-		*a = HexToAddress(input)
+		err = a.UnmarshalText([]byte(input))
 	default:
 		err = fmt.Errorf("Unexpected type for Address: %v", input)
 	}

+ 1 - 1
graphql/graphiql.go

@@ -52,7 +52,7 @@ func (h GraphiQL) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 		respond(w, errorJSON("only GET requests are supported"), http.StatusMethodNotAllowed)
 		return
 	}
-
+	w.Header().Set("Content-Type", "text/html")
 	w.Write(graphiql)
 }