From d2ac39cb4672b0281fcbccec441060e40c2901b5 Mon Sep 17 00:00:00 2001 From: lido333 Date: Fri, 28 Mar 2025 00:54:37 +0800 Subject: [PATCH] refactor: slices.Contains (#24162) --- x/auth/types/permissions.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/x/auth/types/permissions.go b/x/auth/types/permissions.go index 8547235003..d8fbe0eda3 100644 --- a/x/auth/types/permissions.go +++ b/x/auth/types/permissions.go @@ -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