However, this approach has two notable drawbacks. First, the use of loop iteration for validation can be resource-intensive. Second, since knownModules is a configuration parameter initialized with the keeper, any updates introducing new modules might lead to omissions.
Given these considerations, it would be more efficient and reliable to determine whether an address is a module account by directly checking its account type.
func (k Keeper) isModuleAccount(ctx sdk.Context, addr sdk.AccAddress) bool {
acc := k.authKeeper.GetAccount(ctx, addr)
if acc == nil {
return false
}
_, ok := acc.(authtypes.ModuleAccountI)
return ok
}
The current implementation of
isModuleAccount
relie on iterating throughknownModules
to determine whether an address is a module account. https://github.com/neutron-org/neutron/blob/a6525cb3375631175a69086bdc3314f6f637c0ac/x/tokenfactory/keeper/bankactions.go#L92-L105However, this approach has two notable drawbacks. First, the use of loop iteration for validation can be resource-intensive. Second, since knownModules is a configuration parameter initialized with the keeper, any updates introducing new modules might lead to omissions.
Given these considerations, it would be more efficient and reliable to determine whether an address is a module account by directly checking its account type.