Skip to content

Commit

Permalink
can't use slices import
Browse files Browse the repository at this point in the history
  • Loading branch information
crodriguezvega committed May 10, 2024
1 parent cc59dcb commit e9d9f69
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions modules/apps/transfer/types/transfer_authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package types
import (
"context"
"math/big"
"slices"
"strings"

"github.com/cosmos/gogoproto/proto"
Expand Down Expand Up @@ -171,17 +170,15 @@ func validateMemo(ctx sdk.Context, memo string, allowedMemos []string) error {
}

gasCostPerIteration := ctx.KVGasConfig().IterNextCostFlat
isMemoAllowed := slices.ContainsFunc(allowedMemos, func(allowedMemo string) bool {
for _, allowedMemo := range allowedMemos {
ctx.GasMeter().ConsumeGas(gasCostPerIteration, "transfer authorization")

return strings.TrimSpace(memo) == strings.TrimSpace(allowedMemo)
})

if !isMemoAllowed {
return errorsmod.Wrapf(ErrInvalidAuthorization, "not allowed memo: %s", memo)
if strings.TrimSpace(memo) == strings.TrimSpace(allowedMemo) {
return nil
}
}

return nil
return errorsmod.Wrapf(ErrInvalidAuthorization, "not allowed memo: %s", memo)
}

// UnboundedSpendLimit returns the sentinel value that can be used
Expand Down

0 comments on commit e9d9f69

Please sign in to comment.