Skip to content

Commit 3a839db

Browse files
authored
Merge pull request #919 from pullmerge/main
refactor: use slices.Contains to simplify code
2 parents 4cc250d + b046c04 commit 3a839db

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

wasmbinding/message_plugin.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"slices"
78
"strings"
89
"time"
910

@@ -1105,13 +1106,7 @@ func (m *CustomMessenger) resubmitFailure(ctx sdk.Context, contractAddr sdk.AccA
11051106
}
11061107

11071108
func (m *CustomMessenger) isAdmin(ctx sdk.Context, contractAddr sdk.AccAddress) bool {
1108-
for _, admin := range m.AdminKeeper.GetAdmins(ctx) {
1109-
if admin == contractAddr.String() {
1110-
return true
1111-
}
1112-
}
1113-
1114-
return false
1109+
return slices.Contains(m.AdminKeeper.GetAdmins(ctx), contractAddr.String())
11151110
}
11161111

11171112
func getRegisterFee(fee sdk.Coins) sdk.Coins {

x/revenue/keeper/twap.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package keeper
22

33
import (
44
"fmt"
5+
"slices"
56

67
"cosmossdk.io/math"
78
storetypes "cosmossdk.io/store/types"
@@ -230,10 +231,8 @@ func (k *Keeper) getRewardAssetExponent(ctx sdk.Context) (uint32, error) {
230231
}
231232

232233
for _, unit := range rewardAssetMd.DenomUnits {
233-
for _, alias := range unit.Aliases {
234-
if alias == rewardAssetMd.Symbol {
235-
return unit.Exponent, nil
236-
}
234+
if slices.Contains(unit.Aliases, rewardAssetMd.Symbol) {
235+
return unit.Exponent, nil
237236
}
238237
}
239238
return 0, fmt.Errorf("couldn't find exponent for reward asset alias %s in reward denom metadata", rewardAssetMd.Symbol)

0 commit comments

Comments
 (0)