Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(x/bank): Simplify the return (backport #21602) #21604

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading