diff --git a/cmd/gaia/app/app.go b/cmd/gaia/app/app.go index 14ed1b2c1..c80da0bd0 100644 --- a/cmd/gaia/app/app.go +++ b/cmd/gaia/app/app.go @@ -89,7 +89,7 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio ) // add handlers - app.bankKeeper = bank.NewKeeper(app.accountMapper) + app.bankKeeper = bank.NewBaseKeeper(app.accountMapper) app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace)) app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams) app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace)) diff --git a/cmd/gaia/cmd/gaiadebug/hack.go b/cmd/gaia/cmd/gaiadebug/hack.go index a321a5082..b2f1183b3 100644 --- a/cmd/gaia/cmd/gaiadebug/hack.go +++ b/cmd/gaia/cmd/gaiadebug/hack.go @@ -173,7 +173,7 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseAp ) // add handlers - app.bankKeeper = bank.NewKeeper(app.accountMapper) + app.bankKeeper = bank.NewBaseKeeper(app.accountMapper) app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace)) app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams) app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace)) diff --git a/docs/sdk/core/app3.md b/docs/sdk/core/app3.md index fea42d449..b84313adc 100644 --- a/docs/sdk/core/app3.md +++ b/docs/sdk/core/app3.md @@ -285,7 +285,7 @@ it can't increment sequence numbers, change PubKeys, or otherwise. A `bank.Keeper` is easily instantiated from an `AccountMapper`: ```go -bankKeeper = bank.NewKeeper(accountMapper) +bankKeeper = bank.NewBaseKeeper(accountMapper) ``` We can then use it within a handler, instead of working directly with the @@ -336,7 +336,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp { // Set various mappers/keepers to interact easily with underlying stores accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount) - bankKeeper := bank.NewKeeper(accountMapper) + bankKeeper := bank.NewBaseKeeper(accountMapper) feeKeeper := auth.NewFeeCollectionKeeper(cdc, keyFees) app.SetAnteHandler(auth.NewAnteHandler(accountMapper, feeKeeper)) diff --git a/docs/sdk/core/examples/app3.go b/docs/sdk/core/examples/app3.go index a423e3743..787c75d96 100644 --- a/docs/sdk/core/examples/app3.go +++ b/docs/sdk/core/examples/app3.go @@ -31,7 +31,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp { // Set various mappers/keepers to interact easily with underlying stores accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount) - bankKeeper := bank.NewKeeper(accountMapper) + bankKeeper := bank.NewBaseKeeper(accountMapper) feeKeeper := auth.NewFeeCollectionKeeper(cdc, keyFees) app.SetAnteHandler(auth.NewAnteHandler(accountMapper, feeKeeper)) diff --git a/docs/sdk/core/examples/app4.go b/docs/sdk/core/examples/app4.go index be4e5f4f4..620913bb6 100644 --- a/docs/sdk/core/examples/app4.go +++ b/docs/sdk/core/examples/app4.go @@ -29,7 +29,7 @@ func NewApp4(logger log.Logger, db dbm.DB) *bapp.BaseApp { // Set various mappers/keepers to interact easily with underlying stores accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount) - bankKeeper := bank.NewKeeper(accountMapper) + bankKeeper := bank.NewBaseKeeper(accountMapper) // TODO keyFees := sdk.NewKVStoreKey("fee") diff --git a/docs/sdk/sdk-by-examples/simple-governance/app-constructor.md b/docs/sdk/sdk-by-examples/simple-governance/app-constructor.md index 76c8a7a14..149e97277 100644 --- a/docs/sdk/sdk-by-examples/simple-governance/app-constructor.md +++ b/docs/sdk/sdk-by-examples/simple-governance/app-constructor.md @@ -33,7 +33,7 @@ var cdc = MakeCodec() - Instantiate the keepers. Note that keepers generally need access to other module's keepers. In this case, make sure you only pass an instance of the keeper for the functionality that is needed. If a keeper only needs to read in another module's store, a read-only keeper should be passed to it. ```go -app.bankKeeper = bank.NewKeeper(app.accountMapper) +app.bankKeeper = bank.NewBaseKeeper(app.accountMapper) app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.bankKeeper,app.RegisterCodespace(simplestake.DefaultCodespace)) app.simpleGovKeeper = simpleGov.NewKeeper(app.capKeySimpleGovStore, app.bankKeeper, app.stakeKeeper, app.RegisterCodespace(simpleGov.DefaultCodespace)) ``` diff --git a/examples/basecoin/app/app.go b/examples/basecoin/app/app.go index 001d05d3a..6330e9f31 100644 --- a/examples/basecoin/app/app.go +++ b/examples/basecoin/app/app.go @@ -67,7 +67,7 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba return &types.AppAccount{} }, ) - app.bankKeeper = bank.NewKeeper(app.accountMapper) + app.bankKeeper = bank.NewBaseKeeper(app.accountMapper) app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace)) // register message routes diff --git a/examples/democoin/app/app.go b/examples/democoin/app/app.go index a7078a3b1..e66dc0cb3 100644 --- a/examples/democoin/app/app.go +++ b/examples/democoin/app/app.go @@ -75,7 +75,7 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp { ) // Add handlers. - app.bankKeeper = bank.NewKeeper(app.accountMapper) + app.bankKeeper = bank.NewBaseKeeper(app.accountMapper) app.coolKeeper = cool.NewKeeper(app.capKeyMainStore, app.bankKeeper, app.RegisterCodespace(cool.DefaultCodespace)) app.powKeeper = pow.NewKeeper(app.capKeyPowStore, pow.NewConfig("pow", int64(1)), app.bankKeeper, app.RegisterCodespace(pow.DefaultCodespace)) app.ibcMapper = ibc.NewMapper(app.cdc, app.capKeyIBCStore, app.RegisterCodespace(ibc.DefaultCodespace)) diff --git a/examples/democoin/x/cool/app_test.go b/examples/democoin/x/cool/app_test.go index 9e1aa776e..8d778045e 100644 --- a/examples/democoin/x/cool/app_test.go +++ b/examples/democoin/x/cool/app_test.go @@ -49,7 +49,7 @@ func getMockApp(t *testing.T) *mock.App { RegisterWire(mapp.Cdc) keyCool := sdk.NewKVStoreKey("cool") - bankKeeper := bank.NewKeeper(mapp.AccountMapper) + bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper) keeper := NewKeeper(keyCool, bankKeeper, mapp.RegisterCodespace(DefaultCodespace)) mapp.Router().AddRoute("cool", NewHandler(keeper)) diff --git a/examples/democoin/x/cool/keeper_test.go b/examples/democoin/x/cool/keeper_test.go index ab59ea610..50b38fc3e 100644 --- a/examples/democoin/x/cool/keeper_test.go +++ b/examples/democoin/x/cool/keeper_test.go @@ -31,7 +31,7 @@ func TestCoolKeeper(t *testing.T) { am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount) ctx := sdk.NewContext(ms, abci.Header{}, false, nil) - ck := bank.NewKeeper(am) + ck := bank.NewBaseKeeper(am) keeper := NewKeeper(capKey, ck, DefaultCodespace) err := InitGenesis(ctx, keeper, Genesis{"icy"}) diff --git a/examples/democoin/x/pow/app_test.go b/examples/democoin/x/pow/app_test.go index 2aa4ea9b0..de8642e4c 100644 --- a/examples/democoin/x/pow/app_test.go +++ b/examples/democoin/x/pow/app_test.go @@ -25,7 +25,7 @@ func getMockApp(t *testing.T) *mock.App { RegisterWire(mapp.Cdc) keyPOW := sdk.NewKVStoreKey("pow") - bankKeeper := bank.NewKeeper(mapp.AccountMapper) + bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper) config := Config{"pow", 1} keeper := NewKeeper(keyPOW, config, bankKeeper, mapp.RegisterCodespace(DefaultCodespace)) mapp.Router().AddRoute("pow", keeper.Handler) diff --git a/examples/democoin/x/pow/handler_test.go b/examples/democoin/x/pow/handler_test.go index a203d2776..03613f716 100644 --- a/examples/democoin/x/pow/handler_test.go +++ b/examples/democoin/x/pow/handler_test.go @@ -22,7 +22,7 @@ func TestPowHandler(t *testing.T) { am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount) ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) config := NewConfig("pow", int64(1)) - ck := bank.NewKeeper(am) + ck := bank.NewBaseKeeper(am) keeper := NewKeeper(capKey, config, ck, DefaultCodespace) handler := keeper.Handler diff --git a/examples/democoin/x/pow/keeper_test.go b/examples/democoin/x/pow/keeper_test.go index a6802cb21..dbab3e617 100644 --- a/examples/democoin/x/pow/keeper_test.go +++ b/examples/democoin/x/pow/keeper_test.go @@ -35,7 +35,7 @@ func TestPowKeeperGetSet(t *testing.T) { am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount) ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) config := NewConfig("pow", int64(1)) - ck := bank.NewKeeper(am) + ck := bank.NewBaseKeeper(am) keeper := NewKeeper(capKey, config, ck, DefaultCodespace) err := InitGenesis(ctx, keeper, Genesis{uint64(1), uint64(0)}) diff --git a/examples/democoin/x/simplestake/keeper_test.go b/examples/democoin/x/simplestake/keeper_test.go index 393bc1b33..417356f66 100644 --- a/examples/democoin/x/simplestake/keeper_test.go +++ b/examples/democoin/x/simplestake/keeper_test.go @@ -36,7 +36,7 @@ func TestKeeperGetSet(t *testing.T) { auth.RegisterBaseAccount(cdc) accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount) - stakeKeeper := NewKeeper(capKey, bank.NewKeeper(accountMapper), DefaultCodespace) + stakeKeeper := NewKeeper(capKey, bank.NewBaseKeeper(accountMapper), DefaultCodespace) ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) addr := sdk.AccAddress([]byte("some-address")) @@ -66,7 +66,7 @@ func TestBonding(t *testing.T) { ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount) - bankKeeper := bank.NewKeeper(accountMapper) + bankKeeper := bank.NewBaseKeeper(accountMapper) stakeKeeper := NewKeeper(capKey, bankKeeper, DefaultCodespace) addr := sdk.AccAddress([]byte("some-address")) privKey := ed25519.GenPrivKey() diff --git a/store/transientstore.go b/store/transientstore.go index 89cbaf693..a3ce89631 100644 --- a/store/transientstore.go +++ b/store/transientstore.go @@ -1,8 +1,8 @@ package store import ( - dbm "github.com/tendermint/tendermint/libs/db" sdk "github.com/cosmos/cosmos-sdk/types" + dbm "github.com/tendermint/tendermint/libs/db" ) var _ KVStore = (*transientStore)(nil) diff --git a/x/bank/bench_test.go b/x/bank/bench_test.go index 3d84a892d..998d4e4bc 100644 --- a/x/bank/bench_test.go +++ b/x/bank/bench_test.go @@ -16,7 +16,7 @@ func getBenchmarkMockApp() (*mock.App, error) { mapp := mock.NewApp() RegisterWire(mapp.Cdc) - bankKeeper := NewKeeper(mapp.AccountMapper) + bankKeeper := NewBaseKeeper(mapp.AccountMapper) mapp.Router().AddRoute("bank", NewHandler(bankKeeper)) err := mapp.CompleteSetup([]*sdk.KVStoreKey{}) diff --git a/x/bank/keeper.go b/x/bank/keeper.go index 1494c8caf..2da4eedc8 100644 --- a/x/bank/keeper.go +++ b/x/bank/keeper.go @@ -15,102 +15,149 @@ const ( costAddCoins sdk.Gas = 10 ) -// Keeper manages transfers between accounts -type Keeper struct { +// Keeper defines a module interface that facilitates the transfer of coins +// between accounts. +type Keeper interface { + SendKeeper + SetCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) sdk.Error + SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error) + AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error) +} + +var _ Keeper = (*BaseKeeper)(nil) + +// BaseKeeper manages transfers between accounts. It implements the Keeper +// interface. +type BaseKeeper struct { am auth.AccountMapper } -// NewKeeper returns a new Keeper -func NewKeeper(am auth.AccountMapper) Keeper { - return Keeper{am: am} +// NewBaseKeeper returns a new BaseKeeper +func NewBaseKeeper(am auth.AccountMapper) BaseKeeper { + return BaseKeeper{am: am} } // GetCoins returns the coins at the addr. -func (keeper Keeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { +func (keeper BaseKeeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { return getCoins(ctx, keeper.am, addr) } // SetCoins sets the coins at the addr. -func (keeper Keeper) SetCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) sdk.Error { +func (keeper BaseKeeper) SetCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) sdk.Error { return setCoins(ctx, keeper.am, addr, amt) } // HasCoins returns whether or not an account has at least amt coins. -func (keeper Keeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool { +func (keeper BaseKeeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool { return hasCoins(ctx, keeper.am, addr, amt) } // SubtractCoins subtracts amt from the coins at the addr. -func (keeper Keeper) SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error) { +func (keeper BaseKeeper) SubtractCoins( + ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins, +) (sdk.Coins, sdk.Tags, sdk.Error) { + return subtractCoins(ctx, keeper.am, addr, amt) } // AddCoins adds amt to the coins at the addr. -func (keeper Keeper) AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error) { +func (keeper BaseKeeper) AddCoins( + ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins, +) (sdk.Coins, sdk.Tags, sdk.Error) { + return addCoins(ctx, keeper.am, addr, amt) } // SendCoins moves coins from one account to another -func (keeper Keeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error) { +func (keeper BaseKeeper) SendCoins( + ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins, +) (sdk.Tags, sdk.Error) { + return sendCoins(ctx, keeper.am, fromAddr, toAddr, amt) } // InputOutputCoins handles a list of inputs and outputs -func (keeper Keeper) InputOutputCoins(ctx sdk.Context, inputs []Input, outputs []Output) (sdk.Tags, sdk.Error) { +func (keeper BaseKeeper) InputOutputCoins(ctx sdk.Context, inputs []Input, outputs []Output) (sdk.Tags, sdk.Error) { return inputOutputCoins(ctx, keeper.am, inputs, outputs) } //______________________________________________________________________________________________ -// SendKeeper only allows transfers between accounts, without the possibility of creating coins -type SendKeeper struct { +// SendKeeper defines a module interface that facilitates the transfer of coins +// between accounts without the possibility of creating coins. +type SendKeeper interface { + ViewKeeper + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error) + InputOutputCoins(ctx sdk.Context, inputs []Input, outputs []Output) (sdk.Tags, sdk.Error) +} + +var _ SendKeeper = (*BaseSendKeeper)(nil) + +// SendKeeper only allows transfers between accounts without the possibility of +// creating coins. It implements the SendKeeper interface. +type BaseSendKeeper struct { am auth.AccountMapper } -// NewSendKeeper returns a new Keeper -func NewSendKeeper(am auth.AccountMapper) SendKeeper { - return SendKeeper{am: am} +// NewBaseSendKeeper returns a new BaseSendKeeper. +func NewBaseSendKeeper(am auth.AccountMapper) BaseSendKeeper { + return BaseSendKeeper{am: am} } // GetCoins returns the coins at the addr. -func (keeper SendKeeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { +func (keeper BaseSendKeeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { return getCoins(ctx, keeper.am, addr) } // HasCoins returns whether or not an account has at least amt coins. -func (keeper SendKeeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool { +func (keeper BaseSendKeeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool { return hasCoins(ctx, keeper.am, addr, amt) } // SendCoins moves coins from one account to another -func (keeper SendKeeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error) { +func (keeper BaseSendKeeper) SendCoins( + ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins, +) (sdk.Tags, sdk.Error) { + return sendCoins(ctx, keeper.am, fromAddr, toAddr, amt) } // InputOutputCoins handles a list of inputs and outputs -func (keeper SendKeeper) InputOutputCoins(ctx sdk.Context, inputs []Input, outputs []Output) (sdk.Tags, sdk.Error) { +func (keeper BaseSendKeeper) InputOutputCoins( + ctx sdk.Context, inputs []Input, outputs []Output, +) (sdk.Tags, sdk.Error) { + return inputOutputCoins(ctx, keeper.am, inputs, outputs) } //______________________________________________________________________________________________ -// ViewKeeper only allows reading of balances -type ViewKeeper struct { +// ViewKeeper defines a module interface that facilitates read only access to +// account balances. +type ViewKeeper interface { + GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool +} + +var _ ViewKeeper = (*BaseViewKeeper)(nil) + +// BaseViewKeeper implements a read only keeper implementation of ViewKeeper. +type BaseViewKeeper struct { am auth.AccountMapper } -// NewViewKeeper returns a new Keeper -func NewViewKeeper(am auth.AccountMapper) ViewKeeper { - return ViewKeeper{am: am} +// NewBaseViewKeeper returns a new BaseViewKeeper. +func NewBaseViewKeeper(am auth.AccountMapper) BaseViewKeeper { + return BaseViewKeeper{am: am} } // GetCoins returns the coins at the addr. -func (keeper ViewKeeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { +func (keeper BaseViewKeeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { return getCoins(ctx, keeper.am, addr) } // HasCoins returns whether or not an account has at least amt coins. -func (keeper ViewKeeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool { +func (keeper BaseViewKeeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool { return hasCoins(ctx, keeper.am, addr, amt) } diff --git a/x/bank/keeper_test.go b/x/bank/keeper_test.go index 36c0000e7..ee45ae1ca 100644 --- a/x/bank/keeper_test.go +++ b/x/bank/keeper_test.go @@ -34,7 +34,7 @@ func TestKeeper(t *testing.T) { ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount) - bankKeeper := NewKeeper(accountMapper) + bankKeeper := NewBaseKeeper(accountMapper) addr := sdk.AccAddress([]byte("addr1")) addr2 := sdk.AccAddress([]byte("addr2")) @@ -119,8 +119,8 @@ func TestSendKeeper(t *testing.T) { ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount) - bankKeeper := NewKeeper(accountMapper) - sendKeeper := NewSendKeeper(accountMapper) + bankKeeper := NewBaseKeeper(accountMapper) + sendKeeper := NewBaseSendKeeper(accountMapper) addr := sdk.AccAddress([]byte("addr1")) addr2 := sdk.AccAddress([]byte("addr2")) @@ -188,8 +188,8 @@ func TestViewKeeper(t *testing.T) { ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount) - bankKeeper := NewKeeper(accountMapper) - viewKeeper := NewViewKeeper(accountMapper) + bankKeeper := NewBaseKeeper(accountMapper) + viewKeeper := NewBaseViewKeeper(accountMapper) addr := sdk.AccAddress([]byte("addr1")) acc := accountMapper.NewAccountWithAddress(ctx, addr) diff --git a/x/bank/simulation/sim_test.go b/x/bank/simulation/sim_test.go index 38461bad4..f0279abef 100644 --- a/x/bank/simulation/sim_test.go +++ b/x/bank/simulation/sim_test.go @@ -18,7 +18,7 @@ func TestBankWithRandomMessages(t *testing.T) { bank.RegisterWire(mapp.Cdc) mapper := mapp.AccountMapper - bankKeeper := bank.NewKeeper(mapper) + bankKeeper := bank.NewBaseKeeper(mapper) mapp.Router().AddRoute("bank", bank.NewHandler(bankKeeper)) err := mapp.CompleteSetup([]*sdk.KVStoreKey{}) diff --git a/x/gov/simulation/sim_test.go b/x/gov/simulation/sim_test.go index 317864a61..b7f0be580 100644 --- a/x/gov/simulation/sim_test.go +++ b/x/gov/simulation/sim_test.go @@ -24,7 +24,7 @@ func TestGovWithRandomMessages(t *testing.T) { bank.RegisterWire(mapp.Cdc) gov.RegisterWire(mapp.Cdc) mapper := mapp.AccountMapper - bankKeeper := bank.NewKeeper(mapper) + bankKeeper := bank.NewBaseKeeper(mapper) stakeKey := sdk.NewKVStoreKey("stake") stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, bankKeeper, stake.DefaultCodespace) paramKey := sdk.NewKVStoreKey("params") diff --git a/x/gov/test_common.go b/x/gov/test_common.go index 502cfbbf0..a0d556521 100644 --- a/x/gov/test_common.go +++ b/x/gov/test_common.go @@ -31,7 +31,7 @@ func getMockApp(t *testing.T, numGenAccs int) (*mock.App, Keeper, stake.Keeper, keyGov := sdk.NewKVStoreKey("gov") pk := params.NewKeeper(mapp.Cdc, keyGlobalParams) - ck := bank.NewKeeper(mapp.AccountMapper) + ck := bank.NewBaseKeeper(mapp.AccountMapper) sk := stake.NewKeeper(mapp.Cdc, keyStake, ck, mapp.RegisterCodespace(stake.DefaultCodespace)) keeper := NewKeeper(mapp.Cdc, keyGov, pk.Setter(), ck, sk, DefaultCodespace) mapp.Router().AddRoute("gov", NewHandler(keeper)) diff --git a/x/ibc/app_test.go b/x/ibc/app_test.go index eed7c982c..07c3616ce 100644 --- a/x/ibc/app_test.go +++ b/x/ibc/app_test.go @@ -21,7 +21,7 @@ func getMockApp(t *testing.T) *mock.App { RegisterWire(mapp.Cdc) keyIBC := sdk.NewKVStoreKey("ibc") ibcMapper := NewMapper(mapp.Cdc, keyIBC, mapp.RegisterCodespace(DefaultCodespace)) - bankKeeper := bank.NewKeeper(mapp.AccountMapper) + bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper) mapp.Router().AddRoute("ibc", NewHandler(ibcMapper, bankKeeper)) require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{keyIBC})) diff --git a/x/ibc/ibc_test.go b/x/ibc/ibc_test.go index 88718b4a2..acc484e0a 100644 --- a/x/ibc/ibc_test.go +++ b/x/ibc/ibc_test.go @@ -65,7 +65,7 @@ func TestIBC(t *testing.T) { ctx := defaultContext(key) am := auth.NewAccountMapper(cdc, key, auth.ProtoBaseAccount) - ck := bank.NewKeeper(am) + ck := bank.NewBaseKeeper(am) src := newAddress() dest := newAddress() diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index e0b84cef7..4ceeac94d 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -28,7 +28,7 @@ func getMockApp(t *testing.T) (*mock.App, stake.Keeper, Keeper) { keyStake := sdk.NewKVStoreKey("stake") keySlashing := sdk.NewKVStoreKey("slashing") keyParams := sdk.NewKVStoreKey("params") - bankKeeper := bank.NewKeeper(mapp.AccountMapper) + bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper) paramsKeeper := params.NewKeeper(mapp.Cdc, keyParams) stakeKeeper := stake.NewKeeper(mapp.Cdc, keyStake, bankKeeper, mapp.RegisterCodespace(stake.DefaultCodespace)) diff --git a/x/slashing/test_common.go b/x/slashing/test_common.go index afbe47d55..b10c640f5 100644 --- a/x/slashing/test_common.go +++ b/x/slashing/test_common.go @@ -65,7 +65,7 @@ func createTestInput(t *testing.T) (sdk.Context, bank.Keeper, stake.Keeper, para ctx := sdk.NewContext(ms, abci.Header{Time: time.Unix(0, 0)}, false, log.NewTMLogger(os.Stdout)) cdc := createTestCodec() accountMapper := auth.NewAccountMapper(cdc, keyAcc, auth.ProtoBaseAccount) - ck := bank.NewKeeper(accountMapper) + ck := bank.NewBaseKeeper(accountMapper) params := params.NewKeeper(cdc, keyParams) sk := stake.NewKeeper(cdc, keyStake, ck, stake.DefaultCodespace) genesis := stake.DefaultGenesisState() diff --git a/x/stake/app_test.go b/x/stake/app_test.go index 98dc8d56f..b5cf90433 100644 --- a/x/stake/app_test.go +++ b/x/stake/app_test.go @@ -34,7 +34,7 @@ func getMockApp(t *testing.T) (*mock.App, Keeper) { RegisterWire(mApp.Cdc) keyStake := sdk.NewKVStoreKey("stake") - bankKeeper := bank.NewKeeper(mApp.AccountMapper) + bankKeeper := bank.NewBaseKeeper(mApp.AccountMapper) keeper := NewKeeper(mApp.Cdc, keyStake, bankKeeper, mApp.RegisterCodespace(DefaultCodespace)) mApp.Router().AddRoute("stake", NewHandler(keeper)) diff --git a/x/stake/keeper/test_common.go b/x/stake/keeper/test_common.go index b84ce9d93..247ff262b 100644 --- a/x/stake/keeper/test_common.go +++ b/x/stake/keeper/test_common.go @@ -106,7 +106,7 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initCoins int64) (sdk.Context keyAcc, // target store auth.ProtoBaseAccount, // prototype ) - ck := bank.NewKeeper(accountMapper) + ck := bank.NewBaseKeeper(accountMapper) keeper := NewKeeper(cdc, keyStake, ck, types.DefaultCodespace) keeper.SetPool(ctx, types.InitialPool()) keeper.SetNewParams(ctx, types.DefaultParams()) diff --git a/x/stake/simulation/sim_test.go b/x/stake/simulation/sim_test.go index 3feec637b..6ad8b4182 100644 --- a/x/stake/simulation/sim_test.go +++ b/x/stake/simulation/sim_test.go @@ -21,7 +21,7 @@ func TestStakeWithRandomMessages(t *testing.T) { bank.RegisterWire(mapp.Cdc) mapper := mapp.AccountMapper - bankKeeper := bank.NewKeeper(mapper) + bankKeeper := bank.NewBaseKeeper(mapper) stakeKey := sdk.NewKVStoreKey("stake") stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, bankKeeper, stake.DefaultCodespace) mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper))