Merge PR #2146: x/bank: Keeper Interfaces
* Update banking module to implement and use keeper interfaces * Cleanup/consolidate x/bank keeper interface
This commit is contained in:
parent
173ed6a63d
commit
e13cdc0260
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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))
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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"})
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)})
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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{})
|
||||
|
|
103
x/bank/keeper.go
103
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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{})
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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}))
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue