refactor: using slices.Contains to simplify the code (#23634)

Signed-off-by: sjtucoder <sjtucoder@icloud.com.>
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
This commit is contained in:
sjtucoder 2025-02-13 05:43:17 +09:00 committed by GitHub
parent f072ecaba6
commit d2b7f56627
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 13 deletions

View File

@ -228,10 +228,5 @@ func (srv msgServer) ResetCircuitBreaker(ctx context.Context, msg *types.MsgRese
// hasPermissionForMsg returns true if the account can trip or reset the message.
func hasPermissionForMsg(perms types.Permissions, msg string) bool {
for _, msgurl := range perms.LimitTypeUrls {
if msg == msgurl {
return true
}
}
return false
return slices.Contains(perms.LimitTypeUrls, msg)
}

View File

@ -6,6 +6,7 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"slices"
"strings"
errorsmod "cosmossdk.io/errors"
@ -1140,13 +1141,7 @@ func (k Keeper) validateMembers(members []group.MemberRequest) error {
// isProposer checks that an address is a proposer of a given proposal.
func isProposer(proposal group.Proposal, address string) bool {
for _, proposer := range proposal.Proposers {
if proposer == address {
return true
}
}
return false
return slices.Contains(proposal.Proposers, address)
}
func validateMsgs(msgs []sdk.Msg) error {