Commit 68c00403 authored by Dev Ojha's avatar Dev Ojha
Browse files

This commit deletes the legacy REST handlers for all modules except mint and lockup

parent ed101169
Showing with 35 additions and 210 deletions
+35 -210
package rest
import (
"github.com/gorilla/mux"
"github.com/cosmos/cosmos-sdk/client"
)
const (
MethodGet = "GET"
)
// RegisterRoutes registers epochs-related REST handlers to a router.
func RegisterRoutes(clientCtx client.Context, r *mux.Router) {
}
func registerQueryRoutes(clientCtx client.Context, r *mux.Router) {
}
func registerTxHandlers(clientCtx client.Context, r *mux.Router) {
}
......@@ -19,7 +19,6 @@ import (
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/osmosis-labs/osmosis/v7/x/epochs/client/cli"
"github.com/osmosis-labs/osmosis/v7/x/epochs/client/rest"
"github.com/osmosis-labs/osmosis/v7/x/epochs/keeper"
"github.com/osmosis-labs/osmosis/v7/x/epochs/simulation"
"github.com/osmosis-labs/osmosis/v7/x/epochs/types"
......@@ -77,7 +76,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
// RegisterRESTRoutes registers the capability module's REST service handlers.
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
rest.RegisterRoutes(clientCtx, rtr)
}
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
......
package rest
import (
"github.com/gorilla/mux"
"github.com/cosmos/cosmos-sdk/client"
)
func RegisterHandlers(ctx client.Context, r *mux.Router) {
// TODO
}
package rest
package rest
......@@ -20,7 +20,6 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/osmosis-labs/osmosis/v7/x/gamm/client/cli"
"github.com/osmosis-labs/osmosis/v7/x/gamm/client/rest"
"github.com/osmosis-labs/osmosis/v7/x/gamm/keeper"
"github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer"
"github.com/osmosis-labs/osmosis/v7/x/gamm/simulation"
......@@ -63,9 +62,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
//---------------------------------------
// Interfaces.
func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) {
rest.RegisterHandlers(ctx, r)
}
func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) {}
func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck
......
package rest
import (
"github.com/gorilla/mux"
"github.com/cosmos/cosmos-sdk/client"
)
const (
MethodGet = "GET"
)
// RegisterRoutes registers incentives-related REST handlers to a router.
func RegisterRoutes(clientCtx client.Context, r *mux.Router) {
}
func registerQueryRoutes(clientCtx client.Context, r *mux.Router) {
}
func registerTxHandlers(clientCtx client.Context, r *mux.Router) {
}
......@@ -20,7 +20,6 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/osmosis-labs/osmosis/v7/x/incentives/client/cli"
"github.com/osmosis-labs/osmosis/v7/x/incentives/client/rest"
"github.com/osmosis-labs/osmosis/v7/x/incentives/keeper"
"github.com/osmosis-labs/osmosis/v7/x/incentives/simulation"
"github.com/osmosis-labs/osmosis/v7/x/incentives/types"
......@@ -78,7 +77,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
// RegisterRESTRoutes registers the capability module's REST service handlers.
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
rest.RegisterRoutes(clientCtx, rtr)
}
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
......
package client
import (
"net/http"
"github.com/osmosis-labs/osmosis/v7/x/pool-incentives/client/cli"
"github.com/osmosis-labs/osmosis/v7/x/pool-incentives/client/rest"
"github.com/cosmos/cosmos-sdk/client"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
"github.com/cosmos/cosmos-sdk/types/rest"
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
)
var UpdatePoolIncentivesHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpdatePoolIncentivesProposal, rest.ProposalUpdatePoolIncentivesRESTHandler)
var UpdatePoolIncentivesHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpdatePoolIncentivesProposal, emptyRestHandler)
func emptyRestHandler(client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
SubRoute: "unsupported-pool-incentives",
Handler: func(w http.ResponseWriter, r *http.Request) {
rest.WriteErrorResponse(w, http.StatusBadRequest, "Legacy REST Routes are not supported for pool-incentives proposals")
},
}
}
package rest
import (
"net/http"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types"
)
type UpdatePoolIncentivesRequest struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
Records []types.DistrRecord `json:"records" yaml:"records"`
}
func ProposalUpdatePoolIncentivesRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
SubRoute: "update-pool-incentives",
Handler: newUpdatePoolIncentivesHandler(clientCtx),
}
}
func newUpdatePoolIncentivesHandler(clientCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req UpdatePoolIncentivesRequest
if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) {
return
}
req.BaseReq = req.BaseReq.Sanitize()
if !req.BaseReq.ValidateBasic(w) {
return
}
fromAddr, err := sdk.AccAddressFromBech32(req.BaseReq.From)
if rest.CheckBadRequestError(w, err) {
return
}
content := types.NewUpdatePoolIncentivesProposal(req.Title, req.Description, req.Records)
msg, err := govtypes.NewMsgSubmitProposal(content, req.Deposit, fromAddr)
if rest.CheckBadRequestError(w, err) {
return
}
if rest.CheckBadRequestError(w, msg.ValidateBasic()) {
return
}
tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg)
}
}
type ReplacePoolIncentivesRequest struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
Records []types.DistrRecord `json:"records" yaml:"records"`
}
func ProposalReplacePoolIncentivesRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
SubRoute: "replace-pool-incentives",
Handler: newReplacePoolIncentivesHandler(clientCtx),
}
}
func newReplacePoolIncentivesHandler(clientCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req ReplacePoolIncentivesRequest
if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) {
return
}
req.BaseReq = req.BaseReq.Sanitize()
if !req.BaseReq.ValidateBasic(w) {
return
}
fromAddr, err := sdk.AccAddressFromBech32(req.BaseReq.From)
if rest.CheckBadRequestError(w, err) {
return
}
content := types.NewReplacePoolIncentivesProposal(req.Title, req.Description, req.Records)
msg, err := govtypes.NewMsgSubmitProposal(content, req.Deposit, fromAddr)
if rest.CheckBadRequestError(w, err) {
return
}
if rest.CheckBadRequestError(w, msg.ValidateBasic()) {
return
}
tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg)
}
}
package client
import (
"net/http"
"github.com/osmosis-labs/osmosis/v7/x/superfluid/client/cli"
"github.com/osmosis-labs/osmosis/v7/x/superfluid/client/rest"
"github.com/cosmos/cosmos-sdk/types/rest"
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
"github.com/cosmos/cosmos-sdk/client"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
)
var (
SetSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitSetSuperfluidAssetsProposal, rest.ProposalSetSuperfluidAssetsRESTHandler)
RemoveSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitRemoveSuperfluidAssetsProposal, rest.ProposalRemoveSuperfluidAssetsRESTHandler)
SetSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitSetSuperfluidAssetsProposal, emptyRestHandler)
RemoveSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitRemoveSuperfluidAssetsProposal, emptyRestHandler)
)
func emptyRestHandler(client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
SubRoute: "unsupported-superfluid",
Handler: func(w http.ResponseWriter, r *http.Request) {
rest.WriteErrorResponse(w, http.StatusBadRequest, "Legacy REST Routes are not supported for superfluid proposals")
},
}
}
package rest
import (
"net/http"
"github.com/cosmos/cosmos-sdk/client"
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
)
func ProposalSetSuperfluidAssetsRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
SubRoute: "set-superfluid-assets",
Handler: newSetSuperfluidAssetsHandler(clientCtx),
}
}
func newSetSuperfluidAssetsHandler(clientCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
}
}
func ProposalRemoveSuperfluidAssetsRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
SubRoute: "remove-superfluid-assets",
Handler: newRemoveSuperfluidAssetsHandler(clientCtx),
}
}
func newRemoveSuperfluidAssetsHandler(clientCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
}
}
......@@ -19,7 +19,6 @@ import (
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/osmosis-labs/osmosis/v7/x/mint/client/rest"
"github.com/osmosis-labs/osmosis/v7/x/superfluid/client/cli"
"github.com/osmosis-labs/osmosis/v7/x/superfluid/keeper"
"github.com/osmosis-labs/osmosis/v7/x/superfluid/simulation"
......@@ -77,9 +76,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
}
// RegisterRESTRoutes registers the capability module's REST service handlers.
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
rest.RegisterRoutes(clientCtx, rtr)
}
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {}
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment