Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Review comment to introduce MsgCreateGroupAccountI
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Mar 9, 2020
1 parent 8d6ee8b commit 914e3e4
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 136 deletions.
16 changes: 6 additions & 10 deletions incubator/group/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ func NewHandler(k Keeper) sdk.Handler {
return handleMsgUpdateGroupComment(ctx, k, msg)
case MsgUpdateGroupMembers:
return handleMsgUpdateGroupMembers(ctx, k, msg)

// todo: @aaronc is this message type supposed to be handled or for extensions only?
//case MsgCreateGroupAccountBase:
//case MsgProposeBase:

case MsgCreateGroupAccountStd:
return handleMsgCreateGroupAccountStd(ctx, k, msg)
case MsgCreateGroupAccountI:
return handleMsgCreateGroupAccountI(ctx, k, msg)
case MsgVote:
return handleMsgVote(ctx, k, msg)
case MsgExec:
Expand Down Expand Up @@ -62,12 +57,13 @@ func handleMsgExec(ctx sdk.Context, k Keeper, msg MsgExec) (*sdk.Result, error)
}, nil
}

func handleMsgCreateGroupAccountStd(ctx sdk.Context, k Keeper, msg MsgCreateGroupAccountStd) (*sdk.Result, error) {
acc, err := k.CreateGroupAccount(ctx, msg.Base.Admin, msg.Base.Group, *msg.DecisionPolicy.GetThreshold(), msg.Base.Comment)
func handleMsgCreateGroupAccountI(ctx sdk.Context, k Keeper, msg MsgCreateGroupAccountI) (*sdk.Result, error) {
decisionPolicy := msg.GetDecisionPolicy()
acc, err := k.CreateGroupAccount(ctx, msg.GetBase().Admin, msg.GetBase().Group, *decisionPolicy.GetThreshold(), msg.GetBase().Comment)
if err != nil {
return nil, errors.Wrap(err, "create group account")
}
return buildGroupAccountResult(ctx, msg.Base.Admin, acc, "created")
return buildGroupAccountResult(ctx, msg.GetBase().Admin, acc, "created")
}

func buildGroupAccountResult(ctx sdk.Context, admin sdk.AccAddress, acc sdk.AccAddress, note string) (*sdk.Result, error) {
Expand Down
19 changes: 17 additions & 2 deletions incubator/group/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/pkg/errors"
)

var _ sdk.Msg = &MsgCreateGroup{}

const (
msgTypeCreateGroup = "create_group"
msgTypeUpdateGroupAdmin = "update_group_admin"
Expand All @@ -21,6 +19,13 @@ const (
msgTypeExecProposal = "exec_proposal"
)

type MsgCreateGroupAccountI interface {
GetBase() MsgCreateGroupAccountBase
GetDecisionPolicy() StdDecisionPolicy
}

var _ sdk.Msg = &MsgCreateGroup{}

func (m MsgCreateGroup) Route() string { return ModuleName }
func (m MsgCreateGroup) Type() string { return msgTypeCreateGroup }

Expand Down Expand Up @@ -243,6 +248,16 @@ func (m MsgCreateGroupAccountStd) ValidateBasic() error {
return nil
}

var _ MsgCreateGroupAccountI = MsgCreateGroupAccountStd{}

func (m MsgCreateGroupAccountStd) GetBase() MsgCreateGroupAccountBase {
return m.Base
}

func (m MsgCreateGroupAccountStd) GetDecisionPolicy() StdDecisionPolicy {
return m.DecisionPolicy
}

var _ sdk.Msg = &MsgVote{}

func (m MsgVote) Route() string { return ModuleName }
Expand Down
Loading

0 comments on commit 914e3e4

Please sign in to comment.