0g-chain/x/committee/handler.go

50 lines
1.1 KiB
Go
Raw Normal View History

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)
if err != nil {
return err.Result()
}
return sdk.Result{}
}
2020-03-10 21:41:10 +00:00
*/