From 96400441ad1232d758f77758ea7cc1a5405c74ea Mon Sep 17 00:00:00 2001 From: Hanjun Kim Date: Thu, 20 Jun 2024 18:48:14 +0900 Subject: [PATCH] fix: do not block bank sends to stakeibc module accounts --- app/app.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 68d2a28f..0efa58da 100644 --- a/app/app.go +++ b/app/app.go @@ -147,6 +147,7 @@ import ( apphook "github.com/milkyway-labs/milkyway/app/hook" ibcwasmhooks "github.com/milkyway-labs/milkyway/app/ibc-hooks" appkeepers "github.com/milkyway-labs/milkyway/app/keepers" + "github.com/milkyway-labs/milkyway/utils" "github.com/milkyway-labs/milkyway/x/bank" bankkeeper "github.com/milkyway-labs/milkyway/x/bank/keeper" "github.com/milkyway-labs/milkyway/x/epochs" @@ -417,7 +418,7 @@ func NewMilkyWayApp( appCodec, runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, - app.ModuleAccountAddrs(), + app.BlacklistedModuleAccountAddrs(), authorityAddr, logger, ) @@ -1306,6 +1307,21 @@ func (app *MilkyWayApp) ModuleAccountAddrs() map[string]bool { return modAccAddrs } +// ModuleAccountAddrs returns all the app's module account addresses. +func (app *MilkyWayApp) BlacklistedModuleAccountAddrs() map[string]bool { + modAccAddrs := make(map[string]bool) + // DO NOT REMOVE: StringMapKeys fixes non-deterministic map iteration + for _, acc := range utils.StringMapKeys(maccPerms) { + // don't blacklist stakeibc module account, so that it can ibc transfer tokens + if acc == stakeibctypes.ModuleName || + acc == stakeibctypes.RewardCollectorName { + continue + } + modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true + } + return modAccAddrs +} + // LegacyAmino returns SimApp's amino codec. // // NOTE: This is solely to be used for testing purposes as it may be desirable