remove legacy rest endpoints as per @anilCSE
This commit is contained in:
parent
065c1b39ce
commit
ac16c90e5c
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue