Skip to content

Commit

Permalink
fix bump fumn
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt committed Nov 15, 2024
1 parent a1bb7b1 commit 7f699b5
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions x/sequencers/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package keeper

import (
"context"
"errors"
"fmt"

upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

errorsmod "cosmossdk.io/errors"
Expand Down Expand Up @@ -138,34 +138,28 @@ func (m msgServer) BumpAccountSequences(goCtx context.Context, msg *types.MsgBum

ctx := sdk.UnwrapSDKContext(goCtx)

var allErrors error
var err error
m.accountKeeper.IterateAccounts(ctx, func(account authtypes.AccountI) bool {
// handle well known accounts
accType := proto.MessageName(account)
_, toHandle := handleAccounts[accType]
if toHandle {
err := m.bumpAccountSequence(ctx, account)
allErrors = errors.Join(allErrors, err)
} else {
// check if it can be handled by something custom
for _, f := range m.accountBumpFilters {
toBump, err := f(accType, account)
if err != nil {
allErrors = errors.Join(allErrors, fmt.Errorf("filter account: %w", err))
return false
}
if toBump {
err := m.bumpAccountSequence(ctx, account)
allErrors = errors.Join(allErrors, err)
break
}
_, ok := handleAccounts[accType]
i := 0
for !ok && i < len(m.accountBumpFilters) {
ok, err = m.accountBumpFilters[i](accType, account)
if err != nil {
return true
}
i++
}
if ok {
err = m.bumpAccountSequence(ctx, account)
if err != nil {
return true
}
}
return false
})

// we could decide to stop or continue
return &types.MsgBumpAccountSequencesResponse{}, allErrors
return &types.MsgBumpAccountSequencesResponse{}, err
}

func (m msgServer) bumpAccountSequence(ctx sdk.Context, acc authtypes.AccountI) error {
Expand Down

0 comments on commit 7f699b5

Please sign in to comment.