Skip to content

Commit

Permalink
refactor(x/bank): Simplify the return (#21602)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9672879)
  • Loading branch information
fx0x55 authored and mergify[bot] committed Sep 9, 2024
1 parent 01c0e9b commit 2acebaf
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,15 @@ func (k BaseKeeper) DelegateCoins(ctx context.Context, delegatorAddr, moduleAccA
if err != nil {
return err
}
if err := k.EventService.EventManager(ctx).EmitKV(
if err = k.EventService.EventManager(ctx).EmitKV(
types.EventTypeCoinSpent,
event.NewAttribute(types.AttributeKeySpender, delAddrStr),
event.NewAttribute(sdk.AttributeKeyAmount, amt.String()),
); err != nil {
return err
}

err = k.addCoins(ctx, moduleAccAddr, amt)
if err != nil {
return err
}

return nil
return k.addCoins(ctx, moduleAccAddr, amt)
}

// UndelegateCoins performs undelegation by crediting amt coins to an account with
Expand All @@ -181,21 +176,15 @@ func (k BaseKeeper) UndelegateCoins(ctx context.Context, moduleAccAddr, delegato
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, amt.String())
}

err := k.subUnlockedCoins(ctx, moduleAccAddr, amt)
if err != nil {
if err := k.subUnlockedCoins(ctx, moduleAccAddr, amt); err != nil {
return err
}

if err := k.trackUndelegation(ctx, delegatorAddr, amt); err != nil {
return errorsmod.Wrap(err, "failed to track undelegation")
}

err = k.addCoins(ctx, delegatorAddr, amt)
if err != nil {
return err
}

return nil
return k.addCoins(ctx, delegatorAddr, amt)
}

// GetSupply retrieves the Supply from store
Expand Down

0 comments on commit 2acebaf

Please sign in to comment.