From 06276759295f613169bbf613a97f8ccf790000c3 Mon Sep 17 00:00:00 2001 From: HaoyangLiu Date: Sun, 23 Sep 2018 15:48:49 +0800 Subject: [PATCH] Remove uesless code --- x/auth/client/rest/query.go | 56 --------------------------------- x/bank/client/rest/broadcast.go | 2 +- x/bank/client/rest/sendtx.go | 6 ---- 3 files changed, 1 insertion(+), 63 deletions(-) diff --git a/x/auth/client/rest/query.go b/x/auth/client/rest/query.go index 23ca193ec4..db11cedb9f 100644 --- a/x/auth/client/rest/query.go +++ b/x/auth/client/rest/query.go @@ -26,17 +26,6 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec, ).Methods("POST") } -func RegisterLiteRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec, storeName string) { - r.HandleFunc( - "/bank/balances/{address}", - QueryBalancesRequestHandlerFn(storeName, cdc, authcmd.GetAccountDecoder(cdc), cliCtx), - ).Methods("GET") - r.HandleFunc( - "/tx/sign", - SignTxRequestHandlerFn(cdc, cliCtx), - ).Methods("POST") -} - // query accountREST Handler func QueryAccountRequestHandlerFn( storeName string, cdc *codec.Codec, @@ -81,48 +70,3 @@ func QueryAccountRequestHandlerFn( w.Write(output) } } - -// query accountREST Handler -func QueryBalancesRequestHandlerFn( - storeName string, cdc *codec.Codec, - decoder auth.AccountDecoder, cliCtx context.CLIContext, -) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - bech32addr := vars["address"] - - addr, err := sdk.AccAddressFromBech32(bech32addr) - if err != nil { - utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - res, err := cliCtx.QueryStore(auth.AddressStoreKey(addr), storeName) - if err != nil { - utils.WriteErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("couldn't query account. Error: %s", err.Error())) - return - } - - // the query will return empty if there is no data for this account - if len(res) == 0 { - w.WriteHeader(http.StatusNoContent) - return - } - - // decode the value - account, err := decoder(res) - if err != nil { - utils.WriteErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("couldn't parse query result. Result: %s. Error: %s", res, err.Error())) - return - } - - // print out whole account - output, err := cdc.MarshalJSON(account.GetCoins()) - if err != nil { - utils.WriteErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("couldn't marshall query result. Error: %s", err.Error())) - return - } - - w.Write(output) - } -} diff --git a/x/bank/client/rest/broadcast.go b/x/bank/client/rest/broadcast.go index 2ab7da0874..e81e154ef6 100644 --- a/x/bank/client/rest/broadcast.go +++ b/x/bank/client/rest/broadcast.go @@ -57,7 +57,7 @@ func BroadcastTxRequestHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) ht } default: utils.WriteErrorResponse(w, http.StatusInternalServerError, - "unsupported return type. supported types: block, sync, async") + "Unsupported return type. Supported types: block, sync, async") return } diff --git a/x/bank/client/rest/sendtx.go b/x/bank/client/rest/sendtx.go index 0312737705..242614d118 100644 --- a/x/bank/client/rest/sendtx.go +++ b/x/bank/client/rest/sendtx.go @@ -23,12 +23,6 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec, r.HandleFunc("/tx/broadcast", BroadcastTxRequestHandlerFn(cdc, cliCtx)).Methods("POST") } -// RegisterRoutes - Central function to define routes that get registered by the main application -func RegisterLiteRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec, kb keys.Keybase) { - r.HandleFunc("/bank/{address}/transfers", SendRequestHandlerFn(cdc, kb, cliCtx)).Methods("POST") - r.HandleFunc("/txs", BroadcastTxRequestHandlerFn(cdc, cliCtx)).Methods("POST") -} - type sendBody struct { // fees is not used currently // Fees sdk.Coin `json="fees"`