forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR cosmos#4797: blacklist module accounts from receiving txs
- Loading branch information
1 parent
83b1a9f
commit 8c989fd
Showing
20 changed files
with
313 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#4795 restrict module accounts from receiving transactions. | ||
Allowing this would cause an invariant on the module account coins. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package keeper | ||
|
||
// DONTCOVER | ||
|
||
import ( | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
dbm "github.com/tendermint/tendermint/libs/db" | ||
"github.com/tendermint/tendermint/libs/log" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/store" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth" | ||
"github.com/cosmos/cosmos-sdk/x/bank/internal/types" | ||
"github.com/cosmos/cosmos-sdk/x/params" | ||
) | ||
|
||
type testInput struct { | ||
cdc *codec.Codec | ||
ctx sdk.Context | ||
k Keeper | ||
ak auth.AccountKeeper | ||
pk params.Keeper | ||
} | ||
|
||
func setupTestInput() testInput { | ||
db := dbm.NewMemDB() | ||
|
||
cdc := codec.New() | ||
auth.RegisterCodec(cdc) | ||
codec.RegisterCrypto(cdc) | ||
|
||
authCapKey := sdk.NewKVStoreKey("authCapKey") | ||
keyParams := sdk.NewKVStoreKey("params") | ||
tkeyParams := sdk.NewTransientStoreKey("transient_params") | ||
|
||
ms := store.NewCommitMultiStore(db) | ||
ms.MountStoreWithDB(authCapKey, sdk.StoreTypeIAVL, db) | ||
ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) | ||
ms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db) | ||
ms.LoadLatestVersion() | ||
|
||
blacklistedAddrs := make(map[string]bool) | ||
blacklistedAddrs[sdk.AccAddress([]byte("moduleAcc")).String()] = true | ||
|
||
pk := params.NewKeeper(cdc, keyParams, tkeyParams, params.DefaultCodespace) | ||
|
||
ak := auth.NewAccountKeeper( | ||
cdc, authCapKey, pk.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount, | ||
) | ||
ctx := sdk.NewContext(ms, abci.Header{ChainID: "test-chain-id"}, false, log.NewNopLogger()) | ||
|
||
ak.SetParams(ctx, auth.DefaultParams()) | ||
|
||
bankKeeper := NewBaseKeeper(ak, pk.Subspace(types.DefaultParamspace), types.DefaultCodespace, blacklistedAddrs) | ||
bankKeeper.SetSendEnabled(ctx, true) | ||
|
||
return testInput{cdc: cdc, ctx: ctx, k: bankKeeper, ak: ak, pk: pk} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.