Skip to content

Commit

Permalink
remove legacy rest endpoints as per @anilcse
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnya97 committed Feb 12, 2021
1 parent 065c1b3 commit ac16c90
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 49 deletions.
7 changes: 0 additions & 7 deletions x/gov/client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,3 @@ type VoteReq struct {
Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter
Option string `json:"option" yaml:"option"` // option from OptionSet chosen by the voter
}

// WeightedVoteReq defines the properties of a vote request's body.
type WeightedVoteReq struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter
Options string `json:"options" yaml:"options"` // weighted options from OptionSet chosen by the voter
}
42 changes: 0 additions & 42 deletions x/gov/client/rest/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func registerTxHandlers(clientCtx client.Context, r *mux.Router, phs []ProposalR
r.HandleFunc("/gov/proposals", newPostProposalHandlerFn(clientCtx)).Methods("POST")
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits", RestProposalID), newDepositHandlerFn(clientCtx)).Methods("POST")
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes", RestProposalID), newVoteHandlerFn(clientCtx)).Methods("POST")
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/weightedvotes", RestProposalID), newWeightedVoteHandlerFn(clientCtx)).Methods("POST")
}

func newPostProposalHandlerFn(clientCtx client.Context) http.HandlerFunc {
Expand Down Expand Up @@ -126,44 +125,3 @@ func newVoteHandlerFn(clientCtx client.Context) http.HandlerFunc {
tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg)
}
}

func newWeightedVoteHandlerFn(clientCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
strProposalID := vars[RestProposalID]

if len(strProposalID) == 0 {
rest.WriteErrorResponse(w, http.StatusBadRequest, "proposalId required but not specified")
return
}

proposalID, ok := rest.ParseUint64OrReturnBadRequest(w, strProposalID)
if !ok {
return
}

var req WeightedVoteReq
if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) {
return
}

req.BaseReq = req.BaseReq.Sanitize()
if !req.BaseReq.ValidateBasic(w) {
return
}

// Figure out which vote options user chose
options, err := types.WeightedVoteOptionsFromString(gcutils.NormalizeWeightedVoteOptions(req.Options))
if rest.CheckBadRequestError(w, err) {
return
}

// create the message
msg := types.NewMsgVoteWeighted(req.Voter, proposalID, options)
if rest.CheckBadRequestError(w, msg.ValidateBasic()) {
return
}

tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg)
}
}

0 comments on commit ac16c90

Please sign in to comment.