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-12 15:43:17 -05:00
committed by GitHub
co-authored by Alex | Interchain Labs
parent f072ecaba6
commit d2b7f56627
2 changed files with 3 additions and 13 deletions
+1 -6
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)
}
+2 -7
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 {