4
4
"bytes"
5
5
"context"
6
6
"fmt"
7
+ "slices"
7
8
"strings"
8
9
9
10
"cosmossdk.io/collections"
@@ -137,6 +138,7 @@ func (srv msgServer) TripCircuitBreaker(ctx context.Context, msg *types.MsgTripC
137
138
// have been paused using TripCircuitBreaker.
138
139
func (srv msgServer ) ResetCircuitBreaker (ctx context.Context , msg * types.MsgResetCircuitBreaker ) (* types.MsgResetCircuitBreakerResponse , error ) {
139
140
keeper := srv .Keeper
141
+ msgTypeUrls := msg .MsgTypeUrls
140
142
address , err := srv .addressCodec .StringToBytes (msg .Authority )
141
143
if err != nil {
142
144
return nil , err
@@ -148,7 +150,29 @@ func (srv msgServer) ResetCircuitBreaker(ctx context.Context, msg *types.MsgRese
148
150
return nil , err
149
151
}
150
152
151
- for _ , msgTypeURL := range msg .MsgTypeUrls {
153
+ // check if msgURL is empty
154
+ if len (msgTypeUrls ) == 0 {
155
+ switch {
156
+ case perms .Level == types .Permissions_LEVEL_SUPER_ADMIN || perms .Level == types .Permissions_LEVEL_ALL_MSGS || bytes .Equal (address , srv .GetAuthority ()):
157
+ // if the sender is a super admin or the module authority, will remove all disabled msgs
158
+ srv .DisableList .Walk (ctx , nil , func (msgUrl string ) (stop bool , err error ) {
159
+ msgTypeUrls = append (msgTypeUrls , msgUrl )
160
+ return false , nil
161
+ })
162
+
163
+ case perms .Level == types .Permissions_LEVEL_SOME_MSGS :
164
+ // if the sender has permission for some messages, will remove all disabled msgs that in the perms.LimitTypeUrls
165
+ srv .DisableList .Walk (ctx , nil , func (msgUrl string ) (stop bool , err error ) {
166
+ if slices .Contains (perms .LimitTypeUrls , msgUrl ) {
167
+ msgTypeUrls = append (msgTypeUrls , msgUrl )
168
+ }
169
+ return false , nil
170
+ })
171
+ default :
172
+ }
173
+ }
174
+
175
+ for _ , msgTypeURL := range msgTypeUrls {
152
176
// check if the message is in the list of allowed messages
153
177
isAllowed , err := srv .IsAllowed (ctx , msgTypeURL )
154
178
if err != nil {
@@ -176,7 +200,7 @@ func (srv msgServer) ResetCircuitBreaker(ctx context.Context, msg *types.MsgRese
176
200
}
177
201
}
178
202
179
- urls := strings .Join (msg . GetMsgTypeUrls () , "," )
203
+ urls := strings .Join (msgTypeUrls , "," )
180
204
181
205
if err = srv .Keeper .EventService .EventManager (ctx ).EmitKV (
182
206
"reset_circuit_breaker" ,
0 commit comments