rename blacklist to blocked (#6455)
* rename blacklisted to cannotSendTo * add changelog * rename to blockedAddrs Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
parent
d82114df2b
commit
eb3f7e6473
@ -124,6 +124,7 @@ be used to retrieve the actual proposal `Content`. Also the `NewMsgSubmitProposa
|
||||
* (modules) [\#6336](https://github.com/cosmos/cosmos-sdk/pull/6336) `AppModuleBasic.RegisterQueryService` method was added to support gRPC queries, and `QuerierRoute` and `NewQuerierHandler` were deprecated.
|
||||
* (modules) [\#6311](https://github.com/cosmos/cosmos-sdk/issues/6311) Remove `alias.go` usage
|
||||
* (x/auth) [\#6443](https://github.com/cosmos/cosmos-sdk/issues/6443) Move `FeeTx` and `TxWithMemo` interfaces from `x/auth/ante` to `types`.
|
||||
* (modules) [\#6447](https://github.com/cosmos/cosmos-sdk/issues/6447) Rename `blacklistedAddrs` to `blockedAddrs`.
|
||||
|
||||
Migration guide:
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ or `.v3`.
|
||||
[Buf's recommended version suffix](https://buf.build/docs/lint-checkers#package_version_suffix)
|
||||
(ex. `v1alpha1`) _should_ be used for non-stable packages. These packages should
|
||||
likely be excluded from breaking change detection and _should_ generally
|
||||
be blacklisted from usage by smart contracts/persistent scripts to prevent them
|
||||
be blocked from usage by smart contracts/persistent scripts to prevent them
|
||||
from breaking. The SDK _should_ mark any packages as alpha or beta where the
|
||||
API is likely to change significantly in the near future.
|
||||
|
||||
|
||||
@ -224,7 +224,7 @@ func NewSimApp(
|
||||
appCodec, keys[auth.StoreKey], app.subspaces[auth.ModuleName], auth.ProtoBaseAccount, maccPerms,
|
||||
)
|
||||
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
||||
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.subspaces[banktypes.ModuleName], app.BlacklistedAccAddrs(),
|
||||
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.subspaces[banktypes.ModuleName], app.BlockedAddrs(),
|
||||
)
|
||||
stakingKeeper := stakingkeeper.NewKeeper(
|
||||
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.subspaces[stakingtypes.ModuleName],
|
||||
@ -443,14 +443,15 @@ func (app *SimApp) ModuleAccountAddrs() map[string]bool {
|
||||
return modAccAddrs
|
||||
}
|
||||
|
||||
// BlacklistedAccAddrs returns all the app's module account addresses black listed for receiving tokens.
|
||||
func (app *SimApp) BlacklistedAccAddrs() map[string]bool {
|
||||
blacklistedAddrs := make(map[string]bool)
|
||||
// BlockedAddrs returns all the app's module account addresses that are not
|
||||
// allowed to receive external tokens.
|
||||
func (app *SimApp) BlockedAddrs() map[string]bool {
|
||||
blockedAddrs := make(map[string]bool)
|
||||
for acc := range maccPerms {
|
||||
blacklistedAddrs[auth.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc]
|
||||
blockedAddrs[auth.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc]
|
||||
}
|
||||
|
||||
return blacklistedAddrs
|
||||
return blockedAddrs
|
||||
}
|
||||
|
||||
// Codec returns SimApp's codec.
|
||||
|
||||
@ -36,13 +36,13 @@ func TestSimAppExport(t *testing.T) {
|
||||
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
|
||||
}
|
||||
|
||||
// ensure that black listed addresses are properly set in bank keeper
|
||||
func TestBlackListedAddrs(t *testing.T) {
|
||||
// ensure that blocked addresses are properly set in bank keeper
|
||||
func TestBlockedAddrs(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0)
|
||||
|
||||
for acc := range maccPerms {
|
||||
require.Equal(t, !allowedReceivingModAcc[acc], app.BankKeeper.BlacklistedAddr(app.AccountKeeper.GetModuleAddress(acc)))
|
||||
require.Equal(t, !allowedReceivingModAcc[acc], app.BankKeeper.BlockedAddr(app.AccountKeeper.GetModuleAddress(acc)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ func handleMsgSend(ctx sdk.Context, k keeper.Keeper, msg *types.MsgSend) (*sdk.R
|
||||
return nil, types.ErrSendDisabled
|
||||
}
|
||||
|
||||
if k.BlacklistedAddr(msg.ToAddress) {
|
||||
if k.BlockedAddr(msg.ToAddress) {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive transactions", msg.ToAddress)
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ func handleMsgMultiSend(ctx sdk.Context, k keeper.Keeper, msg *types.MsgMultiSen
|
||||
}
|
||||
|
||||
for _, out := range msg.Outputs {
|
||||
if k.BlacklistedAddr(out.Address) {
|
||||
if k.BlockedAddr(out.Address) {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive transactions", out.Address)
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ type BaseKeeper struct {
|
||||
|
||||
func NewBaseKeeper(
|
||||
cdc codec.Marshaler, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace,
|
||||
blacklistedAddrs map[string]bool,
|
||||
blockedAddrs map[string]bool,
|
||||
) BaseKeeper {
|
||||
|
||||
// set KeyTable if it has not already been set
|
||||
@ -66,7 +66,7 @@ func NewBaseKeeper(
|
||||
}
|
||||
|
||||
return BaseKeeper{
|
||||
BaseSendKeeper: NewBaseSendKeeper(cdc, storeKey, ak, paramSpace, blacklistedAddrs),
|
||||
BaseSendKeeper: NewBaseSendKeeper(cdc, storeKey, ak, paramSpace, blockedAddrs),
|
||||
ak: ak,
|
||||
cdc: cdc,
|
||||
storeKey: storeKey,
|
||||
|
||||
@ -26,7 +26,7 @@ type SendKeeper interface {
|
||||
GetSendEnabled(ctx sdk.Context) bool
|
||||
SetSendEnabled(ctx sdk.Context, enabled bool)
|
||||
|
||||
BlacklistedAddr(addr sdk.AccAddress) bool
|
||||
BlockedAddr(addr sdk.AccAddress) bool
|
||||
}
|
||||
|
||||
var _ SendKeeper = (*BaseSendKeeper)(nil)
|
||||
@ -42,20 +42,20 @@ type BaseSendKeeper struct {
|
||||
paramSpace paramtypes.Subspace
|
||||
|
||||
// list of addresses that are restricted from receiving transactions
|
||||
blacklistedAddrs map[string]bool
|
||||
blockedAddrs map[string]bool
|
||||
}
|
||||
|
||||
func NewBaseSendKeeper(
|
||||
cdc codec.Marshaler, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blacklistedAddrs map[string]bool,
|
||||
cdc codec.Marshaler, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool,
|
||||
) BaseSendKeeper {
|
||||
|
||||
return BaseSendKeeper{
|
||||
BaseViewKeeper: NewBaseViewKeeper(cdc, storeKey, ak),
|
||||
cdc: cdc,
|
||||
ak: ak,
|
||||
storeKey: storeKey,
|
||||
paramSpace: paramSpace,
|
||||
blacklistedAddrs: blacklistedAddrs,
|
||||
BaseViewKeeper: NewBaseViewKeeper(cdc, storeKey, ak),
|
||||
cdc: cdc,
|
||||
ak: ak,
|
||||
storeKey: storeKey,
|
||||
paramSpace: paramSpace,
|
||||
blockedAddrs: blockedAddrs,
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,8 +264,8 @@ func (k BaseSendKeeper) SetSendEnabled(ctx sdk.Context, enabled bool) {
|
||||
k.paramSpace.Set(ctx, types.ParamStoreKeySendEnabled, &enabled)
|
||||
}
|
||||
|
||||
// BlacklistedAddr checks if a given address is blacklisted (i.e restricted from
|
||||
// receiving funds)
|
||||
func (k BaseSendKeeper) BlacklistedAddr(addr sdk.AccAddress) bool {
|
||||
return k.blacklistedAddrs[addr.String()]
|
||||
// BlockedAddr checks if a given address is restricted from
|
||||
// receiving funds.
|
||||
func (k BaseSendKeeper) BlockedAddr(addr sdk.AccAddress) bool {
|
||||
return k.blockedAddrs[addr.String()]
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ type Keeper struct {
|
||||
bankKeeper types.BankKeeper
|
||||
stakingKeeper types.StakingKeeper
|
||||
|
||||
blacklistedAddrs map[string]bool
|
||||
blockedAddrs map[string]bool
|
||||
|
||||
feeCollectorName string // name of the FeeCollector ModuleAccount
|
||||
}
|
||||
@ -30,7 +30,7 @@ type Keeper struct {
|
||||
func NewKeeper(
|
||||
cdc codec.Marshaler, key sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||
ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper,
|
||||
feeCollectorName string, blacklistedAddrs map[string]bool,
|
||||
feeCollectorName string, blockedAddrs map[string]bool,
|
||||
) Keeper {
|
||||
|
||||
// ensure distribution module account is set
|
||||
@ -51,7 +51,7 @@ func NewKeeper(
|
||||
bankKeeper: bk,
|
||||
stakingKeeper: sk,
|
||||
feeCollectorName: feeCollectorName,
|
||||
blacklistedAddrs: blacklistedAddrs,
|
||||
blockedAddrs: blockedAddrs,
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,8 +62,8 @@ 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.blacklistedAddrs[withdrawAddr.String()] {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is blacklisted from receiving external funds", withdrawAddr)
|
||||
if k.blockedAddrs[withdrawAddr.String()] {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive external funds", withdrawAddr)
|
||||
}
|
||||
|
||||
if !k.GetWithdrawAddrEnabled(ctx) {
|
||||
|
||||
@ -10,8 +10,8 @@ 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.blacklistedAddrs[p.Recipient.String()] {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is blacklisted from receiving external funds", p.Recipient)
|
||||
if k.blockedAddrs[p.Recipient.String()] {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive external funds", p.Recipient)
|
||||
}
|
||||
|
||||
err := k.DistributeFromFeePool(ctx, p.Amount, p.Recipient)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user