Skip to content

Commit

Permalink
emit proper events
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Apr 22, 2022
1 parent 628d0c9 commit 2d44c5d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions x/profile/keeper/msg_update_validator_description.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func (k msgServer) UpdateValidatorDescription(
ctx := sdk.UnwrapSDKContext(goCtx)

// Check if the validator address is already in the store
validator, found := k.GetValidator(ctx, msg.Address)
if !found {
validator, valfound := k.GetValidator(ctx, msg.Address)
if !valfound {
validator = types.Validator{
Address: msg.Address,
Description: types.ValidatorDescription{},
Expand All @@ -40,9 +40,16 @@ func (k msgServer) UpdateValidatorDescription(
}

k.SetValidator(ctx, validator)
err := ctx.EventManager().EmitTypedEvent(
&types.EventValidatorUpdated{
Validator: validator})
var err error
if valfound {
err = ctx.EventManager().EmitTypedEvent(
&types.EventValidatorUpdated{
Validator: validator})
} else {
err = ctx.EventManager().EmitTypedEvent(
&types.EventValidatorCreated{
Validator: validator})
}

return &types.MsgUpdateValidatorDescriptionResponse{}, err
}

0 comments on commit 2d44c5d

Please sign in to comment.