Add rest routes for proposals;
This commit is contained in:
@@ -12,9 +12,8 @@ var ProposalHandlers = []govclient.ProposalHandler{
|
||||
govclient.NewProposalHandler(cli.ProposalStoreCodeCmd, rest.StoreCodeProposalHandler),
|
||||
govclient.NewProposalHandler(cli.ProposalInstantiateContractCmd, rest.InstantiateProposalHandler),
|
||||
govclient.NewProposalHandler(cli.ProposalMigrateContractCmd, rest.MigrateProposalHandler),
|
||||
// TODO: enable rest
|
||||
//govclient.NewProposalHandler(cli.ProposalExecuteContractCmd, rest.ExecuteProposalHandler),
|
||||
//govclient.NewProposalHandler(cli.ProposalSudoContractCmd, rest.SudoProposalHandler),
|
||||
govclient.NewProposalHandler(cli.ProposalExecuteContractCmd, rest.ExecuteProposalHandler),
|
||||
govclient.NewProposalHandler(cli.ProposalSudoContractCmd, rest.SudoProposalHandler),
|
||||
govclient.NewProposalHandler(cli.ProposalUpdateContractAdminCmd, rest.UpdateContractAdminProposalHandler),
|
||||
govclient.NewProposalHandler(cli.ProposalClearContractAdminCmd, rest.ClearContractAdminProposalHandler),
|
||||
govclient.NewProposalHandler(cli.ProposalPinCodesCmd, rest.PinCodeProposalHandler),
|
||||
|
||||
@@ -162,6 +162,95 @@ func MigrateProposalHandler(cliCtx client.Context) govrest.ProposalRESTHandler {
|
||||
}
|
||||
}
|
||||
|
||||
type ExecuteProposalJSONReq struct {
|
||||
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
|
||||
|
||||
Title string `json:"title" yaml:"title"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
|
||||
Proposer string `json:"proposer" yaml:"proposer"`
|
||||
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
|
||||
|
||||
Contract string `json:"contract" yaml:"contract"`
|
||||
Msg json.RawMessage `json:"msg" yaml:"msg"`
|
||||
// RunAs is the role that is passed to the contract's environment
|
||||
RunAs string `json:"run_as" yaml:"run_as"`
|
||||
}
|
||||
|
||||
func (s ExecuteProposalJSONReq) Content() govtypes.Content {
|
||||
return &types.ExecuteContractProposal{
|
||||
Title: s.Title,
|
||||
Description: s.Description,
|
||||
Contract: s.Contract,
|
||||
Msg: types.RawContractMessage(s.Msg),
|
||||
RunAs: s.RunAs,
|
||||
}
|
||||
}
|
||||
func (s ExecuteProposalJSONReq) GetProposer() string {
|
||||
return s.Proposer
|
||||
}
|
||||
func (s ExecuteProposalJSONReq) GetDeposit() sdk.Coins {
|
||||
return s.Deposit
|
||||
}
|
||||
func (s ExecuteProposalJSONReq) GetBaseReq() rest.BaseReq {
|
||||
return s.BaseReq
|
||||
}
|
||||
func ExecuteProposalHandler(cliCtx client.Context) govrest.ProposalRESTHandler {
|
||||
return govrest.ProposalRESTHandler{
|
||||
SubRoute: "wasm_execute",
|
||||
Handler: func(w http.ResponseWriter, r *http.Request) {
|
||||
var req ExecuteProposalJSONReq
|
||||
if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) {
|
||||
return
|
||||
}
|
||||
toStdTxResponse(cliCtx, w, req)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type SudoProposalJSONReq struct {
|
||||
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
|
||||
|
||||
Title string `json:"title" yaml:"title"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
|
||||
Proposer string `json:"proposer" yaml:"proposer"`
|
||||
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
|
||||
|
||||
Contract string `json:"contract" yaml:"contract"`
|
||||
Msg json.RawMessage `json:"msg" yaml:"msg"`
|
||||
}
|
||||
|
||||
func (s SudoProposalJSONReq) Content() govtypes.Content {
|
||||
return &types.SudoContractProposal{
|
||||
Title: s.Title,
|
||||
Description: s.Description,
|
||||
Contract: s.Contract,
|
||||
Msg: types.RawContractMessage(s.Msg),
|
||||
}
|
||||
}
|
||||
func (s SudoProposalJSONReq) GetProposer() string {
|
||||
return s.Proposer
|
||||
}
|
||||
func (s SudoProposalJSONReq) GetDeposit() sdk.Coins {
|
||||
return s.Deposit
|
||||
}
|
||||
func (s SudoProposalJSONReq) GetBaseReq() rest.BaseReq {
|
||||
return s.BaseReq
|
||||
}
|
||||
func SudoProposalHandler(cliCtx client.Context) govrest.ProposalRESTHandler {
|
||||
return govrest.ProposalRESTHandler{
|
||||
SubRoute: "wasm_sudo",
|
||||
Handler: func(w http.ResponseWriter, r *http.Request) {
|
||||
var req SudoProposalJSONReq
|
||||
if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) {
|
||||
return
|
||||
}
|
||||
toStdTxResponse(cliCtx, w, req)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type UpdateAdminJSONReq struct {
|
||||
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package keeper
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
Reference in New Issue
Block a user