refactor: slices.Contains (#24162)

This commit is contained in:
lido333 2025-03-28 00:54:37 +08:00 committed by GitHub
parent 193a7390c4
commit d2ac39cb46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@ package types
import (
"fmt"
"slices"
"strings"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -30,12 +31,7 @@ func NewPermissionsForAddress(name string, permissions []string) PermissionsForA
// HasPermission returns whether the PermissionsForAddress contains permission.
func (pa PermissionsForAddress) HasPermission(permission string) bool {
for _, perm := range pa.permissions {
if perm == permission {
return true
}
}
return false
return slices.Contains(pa.permissions, permission)
}
// GetAddress returns the address of the PermissionsForAddress object