diff --git a/CHANGELOG.md b/CHANGELOG.md index d663dc2da385..2244de1fadf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,6 +113,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#10612](https://github.com/cosmos/cosmos-sdk/pull/10612) `baseapp.NewBaseApp` constructor function doesn't take the `sdk.TxDecoder` anymore. This logic has been moved into the TxDecoderMiddleware. * [\#10692](https://github.com/cosmos/cosmos-sdk/pull/10612) `SignerData` takes 2 new fields, `Address` and `PubKey`, which need to get populated when using SIGN_MODE_DIRECT_AUX. * [\#10748](https://github.com/cosmos/cosmos-sdk/pull/10748) Move legacy `x/gov` api to `v1beta1` directory. +* [\#10816](https://github.com/cosmos/cosmos-sdk/pull/10816) Reuse blocked addresses from the bank module. No need to pass them to distribution. ### Client Breaking Changes diff --git a/simapp/app.go b/simapp/app.go index 62bf27771c9a..af060d7b529c 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -273,7 +273,7 @@ func NewSimApp( ) app.DistrKeeper = distrkeeper.NewKeeper( appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), + &stakingKeeper, authtypes.FeeCollectorName, ) app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName), diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index 9bd8285c31e2..50536b2698e8 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -22,8 +22,6 @@ type Keeper struct { bankKeeper types.BankKeeper stakingKeeper types.StakingKeeper - blockedAddrs map[string]bool - feeCollectorName string // name of the FeeCollector ModuleAccount } @@ -31,7 +29,7 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, - feeCollectorName string, blockedAddrs map[string]bool, + feeCollectorName string, ) Keeper { // ensure distribution module account is set @@ -52,7 +50,6 @@ func NewKeeper( bankKeeper: bk, stakingKeeper: sk, feeCollectorName: feeCollectorName, - blockedAddrs: blockedAddrs, } } @@ -63,7 +60,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // SetWithdrawAddr sets a new address that will receive the rewards upon withdrawal func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) error { - if k.blockedAddrs[withdrawAddr.String()] { + if k.bankKeeper.BlockedAddr(withdrawAddr) { return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive external funds", withdrawAddr) } diff --git a/x/distribution/keeper/proposal_handler.go b/x/distribution/keeper/proposal_handler.go index d96bfc64908c..16b218e961ea 100644 --- a/x/distribution/keeper/proposal_handler.go +++ b/x/distribution/keeper/proposal_handler.go @@ -8,15 +8,15 @@ import ( // HandleCommunityPoolSpendProposal is a handler for executing a passed community spend proposal func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolSpendProposal) error { - if k.blockedAddrs[p.Recipient] { - return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive external funds", p.Recipient) - } - recipient, addrErr := sdk.AccAddressFromBech32(p.Recipient) if addrErr != nil { return addrErr } + if k.bankKeeper.BlockedAddr(recipient) { + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive external funds", p.Recipient) + } + err := k.DistributeFromFeePool(ctx, p.Amount, recipient) if err != nil { return err diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index be87675d208a..983a1673daaf 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -27,6 +27,8 @@ type BankKeeper interface { SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + + BlockedAddr(addr sdk.AccAddress) bool } // StakingKeeper expected staking keeper (noalias)