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:
parent
f072ecaba6
commit
d2b7f56627
@ -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)
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user