Skip to content

Commit

Permalink
refactor: using slices.Contains to simplify the code
Browse files Browse the repository at this point in the history
Signed-off-by: dashangcun <[email protected]>
  • Loading branch information
dashangcun committed Jan 13, 2025
1 parent 8ce300b commit 827b1b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
9 changes: 2 additions & 7 deletions app/ante/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ante

import (
"fmt"
"slices"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -94,11 +95,5 @@ func (ald AuthzLimiterDecorator) checkDisabledMsgs(msgs []sdk.Msg, isAuthzInnerM
// isDisabledMsg returns true if the given message is in the list of restricted
// messages from the AnteHandler.
func (ald AuthzLimiterDecorator) isDisabledMsg(msgTypeURL string) bool {
for _, disabledType := range ald.disabledMsgTypes {
if msgTypeURL == disabledType {
return true
}
}

return false
return slices.Contains(ald.disabledMsgTypes, msgTypeURL)
}
8 changes: 2 additions & 6 deletions x/crosschain/types/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"slices"
)

func (m *Status) AbortRefunded() {
Expand Down Expand Up @@ -56,12 +57,7 @@ func (m *Status) ValidateTransition(newStatus CctxStatus) bool {
if !isOldStatusValid {
return false
}
for _, status := range nextStatusList {
if status == newStatus {
return true
}
}
return false
return slices.Contains(nextStatusList, newStatus)
}

func stateTransitionMap() map[CctxStatus][]CctxStatus {
Expand Down

0 comments on commit 827b1b7

Please sign in to comment.