2020-03-04 19:16:27 +00:00
|
|
|
package committee
|
|
|
|
|
|
|
|
// committee, subcommittee, council, caucus, commission, synod, board
|
2020-03-10 21:41:10 +00:00
|
|
|
/*
|
2020-03-04 19:16:27 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
|
|
|
"github.com/kava-labs/kava/x/committee/keeper"
|
2020-03-10 21:41:10 +00:00
|
|
|
|
2020-03-04 19:16:27 +00:00
|
|
|
"github.com/kava-labs/kava/x/committee/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewHandler creates an sdk.Handler for committee messages
|
|
|
|
func NewHandler(k keeper.Keeper) sdk.Handler {
|
|
|
|
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
|
|
|
|
switch msg := msg.(type) {
|
|
|
|
case types.MsgSubmitProposal:
|
|
|
|
handleMsgSubmitProposal(ctx, k, msg)
|
|
|
|
case types.MsgVote:
|
|
|
|
handleMsgVote(ctx, k, msg)
|
|
|
|
default:
|
|
|
|
errMsg := fmt.Sprintf("unrecognized %s msg type: %T", types.ModuleName, msg)
|
|
|
|
return sdk.ErrUnknownRequest(errMsg).Result()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func handleMsgSubmitProposal(ctx sdk.Context, k keeper.Keeper, msg types.MsgSubmitProposal) sdk.Result {
|
|
|
|
err := keeper.SubmitProposal(ctx, msg)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
|
|
|
|
|
|
|
return sdk.Result{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func handleMsgVote(ctx sdk.Context, k keeper.Keeper, msg types.MsgVote) sdk.Result {
|
|
|
|
err := keeper.AddVote(ctx, msg)
|
|
|
|
|
2020-03-11 19:27:36 +00:00
|
|
|
// Try closing proposal
|
|
|
|
_ = k.CloseOutProposal(ctx, proposalID)
|
|
|
|
|
|
|
|
// if err.Error() == "note enough votes to close proposal" { // TODO
|
|
|
|
// return nil // This is not a reason to error
|
|
|
|
// }
|
|
|
|
// if err != nil {
|
|
|
|
// return err
|
|
|
|
// }
|
|
|
|
|
2020-03-04 19:16:27 +00:00
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
|
|
|
|
|
|
|
return sdk.Result{}
|
|
|
|
}
|
2020-03-10 21:41:10 +00:00
|
|
|
*/
|