Merge PR #2273: Rename coinKeeper -> bankKeeper

This commit is contained in:
Christopher Goes 2018-09-08 16:12:58 +08:00 committed by GitHub
commit ffb4c5ec7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 111 additions and 110 deletions

View File

@ -52,7 +52,7 @@ type GaiaApp struct {
// Manage getting and setting accounts // Manage getting and setting accounts
accountMapper auth.AccountMapper accountMapper auth.AccountMapper
feeCollectionKeeper auth.FeeCollectionKeeper feeCollectionKeeper auth.FeeCollectionKeeper
coinKeeper bank.Keeper bankKeeper bank.Keeper
ibcMapper ibc.Mapper ibcMapper ibc.Mapper
stakeKeeper stake.Keeper stakeKeeper stake.Keeper
slashingKeeper slashing.Keeper slashingKeeper slashing.Keeper
@ -89,19 +89,19 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
) )
// add handlers // add handlers
app.coinKeeper = bank.NewKeeper(app.accountMapper) app.bankKeeper = bank.NewKeeper(app.accountMapper)
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace)) app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams) app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams)
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.coinKeeper, app.RegisterCodespace(stake.DefaultCodespace)) app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace)) app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
app.stakeKeeper = app.stakeKeeper.WithValidatorHooks(app.slashingKeeper.ValidatorHooks()) app.stakeKeeper = app.stakeKeeper.WithValidatorHooks(app.slashingKeeper.ValidatorHooks())
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper.Setter(), app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace)) app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper.Setter(), app.bankKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection) app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
// register message routes // register message routes
app.Router(). app.Router().
AddRoute("bank", bank.NewHandler(app.coinKeeper)). AddRoute("bank", bank.NewHandler(app.bankKeeper)).
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper)). AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
AddRoute("stake", stake.NewHandler(app.stakeKeeper)). AddRoute("stake", stake.NewHandler(app.stakeKeeper)).
AddRoute("slashing", slashing.NewHandler(app.slashingKeeper)). AddRoute("slashing", slashing.NewHandler(app.slashingKeeper)).
AddRoute("gov", gov.NewHandler(app.govKeeper)) AddRoute("gov", gov.NewHandler(app.govKeeper))

View File

@ -111,7 +111,7 @@ func invariants(app *GaiaApp) []simulation.Invariant {
func(t *testing.T, baseapp *baseapp.BaseApp, log string) { func(t *testing.T, baseapp *baseapp.BaseApp, log string) {
banksim.NonnegativeBalanceInvariant(app.accountMapper)(t, baseapp, log) banksim.NonnegativeBalanceInvariant(app.accountMapper)(t, baseapp, log)
govsim.AllInvariants()(t, baseapp, log) govsim.AllInvariants()(t, baseapp, log)
stakesim.AllInvariants(app.coinKeeper, app.stakeKeeper, app.accountMapper)(t, baseapp, log) stakesim.AllInvariants(app.bankKeeper, app.stakeKeeper, app.accountMapper)(t, baseapp, log)
slashingsim.AllInvariants()(t, baseapp, log) slashingsim.AllInvariants()(t, baseapp, log)
}, },
} }

View File

@ -140,7 +140,7 @@ type GaiaApp struct {
// Manage getting and setting accounts // Manage getting and setting accounts
accountMapper auth.AccountMapper accountMapper auth.AccountMapper
feeCollectionKeeper auth.FeeCollectionKeeper feeCollectionKeeper auth.FeeCollectionKeeper
coinKeeper bank.Keeper bankKeeper bank.Keeper
ibcMapper ibc.Mapper ibcMapper ibc.Mapper
stakeKeeper stake.Keeper stakeKeeper stake.Keeper
slashingKeeper slashing.Keeper slashingKeeper slashing.Keeper
@ -173,16 +173,16 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseAp
) )
// add handlers // add handlers
app.coinKeeper = bank.NewKeeper(app.accountMapper) app.bankKeeper = bank.NewKeeper(app.accountMapper)
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace)) app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams) app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams)
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.coinKeeper, app.RegisterCodespace(stake.DefaultCodespace)) app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace)) app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
// register message routes // register message routes
app.Router(). app.Router().
AddRoute("bank", bank.NewHandler(app.coinKeeper)). AddRoute("bank", bank.NewHandler(app.bankKeeper)).
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper)). AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
AddRoute("stake", stake.NewHandler(app.stakeKeeper)) AddRoute("stake", stake.NewHandler(app.stakeKeeper))
// initialize BaseApp // initialize BaseApp

View File

@ -285,7 +285,7 @@ it can't increment sequence numbers, change PubKeys, or otherwise.
A `bank.Keeper` is easily instantiated from an `AccountMapper`: A `bank.Keeper` is easily instantiated from an `AccountMapper`:
```go ```go
coinKeeper = bank.NewKeeper(accountMapper) bankKeeper = bank.NewKeeper(accountMapper)
``` ```
We can then use it within a handler, instead of working directly with the We can then use it within a handler, instead of working directly with the
@ -295,7 +295,7 @@ We can then use it within a handler, instead of working directly with the
// Finds account with addr in AccountMapper. // Finds account with addr in AccountMapper.
// Adds coins to account's coin array. // Adds coins to account's coin array.
// Sets updated account in AccountMapper // Sets updated account in AccountMapper
app.coinKeeper.AddCoins(ctx, addr, coins) app.bankKeeper.AddCoins(ctx, addr, coins)
``` ```
See the [bank.Keeper API See the [bank.Keeper API
@ -336,7 +336,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
// Set various mappers/keepers to interact easily with underlying stores // Set various mappers/keepers to interact easily with underlying stores
accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount) accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount)
coinKeeper := bank.NewKeeper(accountMapper) bankKeeper := bank.NewKeeper(accountMapper)
feeKeeper := auth.NewFeeCollectionKeeper(cdc, keyFees) feeKeeper := auth.NewFeeCollectionKeeper(cdc, keyFees)
app.SetAnteHandler(auth.NewAnteHandler(accountMapper, feeKeeper)) app.SetAnteHandler(auth.NewAnteHandler(accountMapper, feeKeeper))
@ -344,7 +344,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
// Register message routes. // Register message routes.
// Note the handler gets access to // Note the handler gets access to
app.Router(). app.Router().
AddRoute("send", bank.NewHandler(coinKeeper)) AddRoute("send", bank.NewHandler(bankKeeper))
// Mount stores and load the latest state. // Mount stores and load the latest state.
app.MountStoresIAVL(keyAccount, keyFees) app.MountStoresIAVL(keyAccount, keyFees)

View File

@ -31,7 +31,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
// Set various mappers/keepers to interact easily with underlying stores // Set various mappers/keepers to interact easily with underlying stores
accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount) accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount)
coinKeeper := bank.NewKeeper(accountMapper) bankKeeper := bank.NewKeeper(accountMapper)
feeKeeper := auth.NewFeeCollectionKeeper(cdc, keyFees) feeKeeper := auth.NewFeeCollectionKeeper(cdc, keyFees)
app.SetAnteHandler(auth.NewAnteHandler(accountMapper, feeKeeper)) app.SetAnteHandler(auth.NewAnteHandler(accountMapper, feeKeeper))
@ -39,7 +39,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
// Register message routes. // Register message routes.
// Note the handler gets access to // Note the handler gets access to
app.Router(). app.Router().
AddRoute("bank", bank.NewHandler(coinKeeper)) AddRoute("bank", bank.NewHandler(bankKeeper))
// Mount stores and load the latest state. // Mount stores and load the latest state.
app.MountStoresIAVL(keyAccount, keyFees) app.MountStoresIAVL(keyAccount, keyFees)

View File

@ -29,7 +29,7 @@ func NewApp4(logger log.Logger, db dbm.DB) *bapp.BaseApp {
// Set various mappers/keepers to interact easily with underlying stores // Set various mappers/keepers to interact easily with underlying stores
accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount) accountMapper := auth.NewAccountMapper(cdc, keyAccount, auth.ProtoBaseAccount)
coinKeeper := bank.NewKeeper(accountMapper) bankKeeper := bank.NewKeeper(accountMapper)
// TODO // TODO
keyFees := sdk.NewKVStoreKey("fee") keyFees := sdk.NewKVStoreKey("fee")
@ -43,7 +43,7 @@ func NewApp4(logger log.Logger, db dbm.DB) *bapp.BaseApp {
// Register message routes. // Register message routes.
// Note the handler gets access to the account store. // Note the handler gets access to the account store.
app.Router(). app.Router().
AddRoute("bank", bank.NewHandler(coinKeeper)) AddRoute("bank", bank.NewHandler(bankKeeper))
// Mount stores and load the latest state. // Mount stores and load the latest state.
app.MountStoresIAVL(keyAccount, keyFees) app.MountStoresIAVL(keyAccount, keyFees)

View File

@ -33,16 +33,16 @@ 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. - 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 ```go
app.coinKeeper = bank.NewKeeper(app.accountMapper) app.bankKeeper = bank.NewKeeper(app.accountMapper)
app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.coinKeeper,app.RegisterCodespace(simplestake.DefaultCodespace)) app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.bankKeeper,app.RegisterCodespace(simplestake.DefaultCodespace))
app.simpleGovKeeper = simpleGov.NewKeeper(app.capKeySimpleGovStore, app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(simpleGov.DefaultCodespace)) app.simpleGovKeeper = simpleGov.NewKeeper(app.capKeySimpleGovStore, app.bankKeeper, app.stakeKeeper, app.RegisterCodespace(simpleGov.DefaultCodespace))
``` ```
- Declare the handlers. - Declare the handlers.
```go ```go
app.Router(). app.Router().
AddRoute("bank", bank.NewHandler(app.coinKeeper)). AddRoute("bank", bank.NewHandler(app.bankKeeper)).
AddRoute("simplestake", simplestake.NewHandler(app.stakeKeeper)). AddRoute("simplestake", simplestake.NewHandler(app.stakeKeeper)).
AddRoute("simpleGov", simpleGov.NewHandler(app.simpleGovKeeper)) AddRoute("simpleGov", simpleGov.NewHandler(app.simpleGovKeeper))
``` ```

View File

@ -38,7 +38,7 @@ type SimpleGovApp struct {
// keepers // keepers
feeCollectionKeeper auth.FeeCollectionKeeper feeCollectionKeeper auth.FeeCollectionKeeper
coinKeeper bank.Keeper bankKeeper bank.Keeper
stakeKeeper simplestake.Keeper stakeKeeper simplestake.Keeper
simpleGovKeeper simpleGov.Keeper simpleGovKeeper simpleGov.Keeper

View File

@ -37,7 +37,7 @@ type BasecoinApp struct {
// manage getting and setting accounts // manage getting and setting accounts
accountMapper auth.AccountMapper accountMapper auth.AccountMapper
feeCollectionKeeper auth.FeeCollectionKeeper feeCollectionKeeper auth.FeeCollectionKeeper
coinKeeper bank.Keeper bankKeeper bank.Keeper
ibcMapper ibc.Mapper ibcMapper ibc.Mapper
} }
@ -67,13 +67,13 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
return &types.AppAccount{} return &types.AppAccount{}
}, },
) )
app.coinKeeper = bank.NewKeeper(app.accountMapper) app.bankKeeper = bank.NewKeeper(app.accountMapper)
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace)) app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
// register message routes // register message routes
app.Router(). app.Router().
AddRoute("bank", bank.NewHandler(app.coinKeeper)). AddRoute("bank", bank.NewHandler(app.bankKeeper)).
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper)) AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper))
// perform initialization logic // perform initialization logic
app.SetInitChainer(app.initChainer) app.SetInitChainer(app.initChainer)

View File

@ -41,7 +41,7 @@ type DemocoinApp struct {
// keepers // keepers
feeCollectionKeeper auth.FeeCollectionKeeper feeCollectionKeeper auth.FeeCollectionKeeper
coinKeeper bank.Keeper bankKeeper bank.Keeper
coolKeeper cool.Keeper coolKeeper cool.Keeper
powKeeper pow.Keeper powKeeper pow.Keeper
ibcMapper ibc.Mapper ibcMapper ibc.Mapper
@ -75,17 +75,17 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
) )
// Add handlers. // Add handlers.
app.coinKeeper = bank.NewKeeper(app.accountMapper) app.bankKeeper = bank.NewKeeper(app.accountMapper)
app.coolKeeper = cool.NewKeeper(app.capKeyMainStore, app.coinKeeper, app.RegisterCodespace(cool.DefaultCodespace)) app.coolKeeper = cool.NewKeeper(app.capKeyMainStore, app.bankKeeper, app.RegisterCodespace(cool.DefaultCodespace))
app.powKeeper = pow.NewKeeper(app.capKeyPowStore, pow.NewConfig("pow", int64(1)), app.coinKeeper, app.RegisterCodespace(pow.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)) app.ibcMapper = ibc.NewMapper(app.cdc, app.capKeyIBCStore, app.RegisterCodespace(ibc.DefaultCodespace))
app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.coinKeeper, app.RegisterCodespace(simplestake.DefaultCodespace)) app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.bankKeeper, app.RegisterCodespace(simplestake.DefaultCodespace))
app.Router(). app.Router().
AddRoute("bank", bank.NewHandler(app.coinKeeper)). AddRoute("bank", bank.NewHandler(app.bankKeeper)).
AddRoute("cool", cool.NewHandler(app.coolKeeper)). AddRoute("cool", cool.NewHandler(app.coolKeeper)).
AddRoute("pow", app.powKeeper.Handler). AddRoute("pow", app.powKeeper.Handler).
AddRoute("sketchy", sketchy.NewHandler()). AddRoute("sketchy", sketchy.NewHandler()).
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.coinKeeper)). AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
AddRoute("simplestake", simplestake.NewHandler(app.stakeKeeper)) AddRoute("simplestake", simplestake.NewHandler(app.stakeKeeper))
// Initialize BaseApp. // Initialize BaseApp.

View File

@ -49,8 +49,8 @@ func getMockApp(t *testing.T) *mock.App {
RegisterWire(mapp.Cdc) RegisterWire(mapp.Cdc)
keyCool := sdk.NewKVStoreKey("cool") keyCool := sdk.NewKVStoreKey("cool")
coinKeeper := bank.NewKeeper(mapp.AccountMapper) bankKeeper := bank.NewKeeper(mapp.AccountMapper)
keeper := NewKeeper(keyCool, coinKeeper, mapp.RegisterCodespace(DefaultCodespace)) keeper := NewKeeper(keyCool, bankKeeper, mapp.RegisterCodespace(DefaultCodespace))
mapp.Router().AddRoute("cool", NewHandler(keeper)) mapp.Router().AddRoute("cool", NewHandler(keeper))
mapp.SetInitChainer(getInitChainer(mapp, keeper, "ice-cold")) mapp.SetInitChainer(getInitChainer(mapp, keeper, "ice-cold"))

View File

@ -25,9 +25,9 @@ func getMockApp(t *testing.T) *mock.App {
RegisterWire(mapp.Cdc) RegisterWire(mapp.Cdc)
keyPOW := sdk.NewKVStoreKey("pow") keyPOW := sdk.NewKVStoreKey("pow")
coinKeeper := bank.NewKeeper(mapp.AccountMapper) bankKeeper := bank.NewKeeper(mapp.AccountMapper)
config := Config{"pow", 1} config := Config{"pow", 1}
keeper := NewKeeper(keyPOW, config, coinKeeper, mapp.RegisterCodespace(DefaultCodespace)) keeper := NewKeeper(keyPOW, config, bankKeeper, mapp.RegisterCodespace(DefaultCodespace))
mapp.Router().AddRoute("pow", keeper.Handler) mapp.Router().AddRoute("pow", keeper.Handler)
mapp.SetInitChainer(getInitChainer(mapp, keeper)) mapp.SetInitChainer(getInitChainer(mapp, keeper))

View File

@ -21,13 +21,13 @@ type Keeper struct {
codespace sdk.CodespaceType codespace sdk.CodespaceType
} }
func NewKeeper(key sdk.StoreKey, coinKeeper bank.Keeper, codespace sdk.CodespaceType) Keeper { func NewKeeper(key sdk.StoreKey, bankKeeper bank.Keeper, codespace sdk.CodespaceType) Keeper {
cdc := wire.NewCodec() cdc := wire.NewCodec()
wire.RegisterCrypto(cdc) wire.RegisterCrypto(cdc)
return Keeper{ return Keeper{
key: key, key: key,
cdc: cdc, cdc: cdc,
ck: coinKeeper, ck: bankKeeper,
codespace: codespace, codespace: codespace,
} }
} }

View File

@ -66,8 +66,8 @@ func TestBonding(t *testing.T) {
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount) accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
coinKeeper := bank.NewKeeper(accountMapper) bankKeeper := bank.NewKeeper(accountMapper)
stakeKeeper := NewKeeper(capKey, coinKeeper, DefaultCodespace) stakeKeeper := NewKeeper(capKey, bankKeeper, DefaultCodespace)
addr := sdk.AccAddress([]byte("some-address")) addr := sdk.AccAddress([]byte("some-address"))
privKey := ed25519.GenPrivKey() privKey := ed25519.GenPrivKey()
pubKey := privKey.PubKey() pubKey := privKey.PubKey()

View File

@ -16,8 +16,8 @@ func getBenchmarkMockApp() (*mock.App, error) {
mapp := mock.NewApp() mapp := mock.NewApp()
RegisterWire(mapp.Cdc) RegisterWire(mapp.Cdc)
coinKeeper := NewKeeper(mapp.AccountMapper) bankKeeper := NewKeeper(mapp.AccountMapper)
mapp.Router().AddRoute("bank", NewHandler(coinKeeper)) mapp.Router().AddRoute("bank", NewHandler(bankKeeper))
err := mapp.CompleteSetup([]*sdk.KVStoreKey{}) err := mapp.CompleteSetup([]*sdk.KVStoreKey{})
return mapp, err return mapp, err

View File

@ -34,7 +34,7 @@ func TestKeeper(t *testing.T) {
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount) accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
coinKeeper := NewKeeper(accountMapper) bankKeeper := NewKeeper(accountMapper)
addr := sdk.AccAddress([]byte("addr1")) addr := sdk.AccAddress([]byte("addr1"))
addr2 := sdk.AccAddress([]byte("addr2")) addr2 := sdk.AccAddress([]byte("addr2"))
@ -43,57 +43,57 @@ func TestKeeper(t *testing.T) {
// Test GetCoins/SetCoins // Test GetCoins/SetCoins
accountMapper.SetAccount(ctx, acc) accountMapper.SetAccount(ctx, acc)
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
coinKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}) bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
// Test HasCoins // Test HasCoins
require.True(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})) require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
require.True(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})) require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
require.False(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})) require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
require.False(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)})) require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)}))
// Test AddCoins // Test AddCoins
coinKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}) bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 25)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 25)}))
coinKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 15)}) bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 15)})
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 15), sdk.NewInt64Coin("foocoin", 25)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 15), sdk.NewInt64Coin("foocoin", 25)}))
// Test SubtractCoins // Test SubtractCoins
coinKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}) bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
coinKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)}) bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)})
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
coinKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 11)}) bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 11)})
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
coinKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 10)}) bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 10)})
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
require.False(t, coinKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)})) require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}))
// Test SendCoins // Test SendCoins
coinKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}) bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})) require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
_, err2 := coinKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 50)}) _, err2 := bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 50)})
assert.Implements(t, (*sdk.Error)(nil), err2) assert.Implements(t, (*sdk.Error)(nil), err2)
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})) require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
coinKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)}) bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)})
coinKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)}) bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)})
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5)}))
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)})) require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)}))
// Test InputOutputCoins // Test InputOutputCoins
input1 := NewInput(addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)}) input1 := NewInput(addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)})
output1 := NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)}) output1 := NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)})
coinKeeper.InputOutputCoins(ctx, []Input{input1}, []Output{output1}) bankKeeper.InputOutputCoins(ctx, []Input{input1}, []Output{output1})
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 7)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 7)}))
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 8)})) require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 8)}))
inputs := []Input{ inputs := []Input{
NewInput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 3)}), NewInput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 3)}),
@ -104,10 +104,10 @@ func TestKeeper(t *testing.T) {
NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}), NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}),
NewOutput(addr3, sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)}), NewOutput(addr3, sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)}),
} }
coinKeeper.InputOutputCoins(ctx, inputs, outputs) bankKeeper.InputOutputCoins(ctx, inputs, outputs)
require.True(t, coinKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 21), sdk.NewInt64Coin("foocoin", 4)})) require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 21), sdk.NewInt64Coin("foocoin", 4)}))
require.True(t, coinKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 7), sdk.NewInt64Coin("foocoin", 6)})) require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 7), sdk.NewInt64Coin("foocoin", 6)}))
require.True(t, coinKeeper.GetCoins(ctx, addr3).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)})) require.True(t, bankKeeper.GetCoins(ctx, addr3).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)}))
} }
@ -119,7 +119,7 @@ func TestSendKeeper(t *testing.T) {
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount) accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
coinKeeper := NewKeeper(accountMapper) bankKeeper := NewKeeper(accountMapper)
sendKeeper := NewSendKeeper(accountMapper) sendKeeper := NewSendKeeper(accountMapper)
addr := sdk.AccAddress([]byte("addr1")) addr := sdk.AccAddress([]byte("addr1"))
@ -131,7 +131,7 @@ func TestSendKeeper(t *testing.T) {
accountMapper.SetAccount(ctx, acc) accountMapper.SetAccount(ctx, acc)
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{})) require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
coinKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}) bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})) require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
// Test HasCoins // Test HasCoins
@ -140,7 +140,7 @@ func TestSendKeeper(t *testing.T) {
require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})) require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)})) require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)}))
coinKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}) bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})
// Test SendCoins // Test SendCoins
sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}) sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})
@ -152,7 +152,7 @@ func TestSendKeeper(t *testing.T) {
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})) require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})) require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
coinKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)}) bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)})
sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)}) sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)})
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5)})) require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5)}))
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)})) require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)}))
@ -188,7 +188,7 @@ func TestViewKeeper(t *testing.T) {
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger()) ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount) accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
coinKeeper := NewKeeper(accountMapper) bankKeeper := NewKeeper(accountMapper)
viewKeeper := NewViewKeeper(accountMapper) viewKeeper := NewViewKeeper(accountMapper)
addr := sdk.AccAddress([]byte("addr1")) addr := sdk.AccAddress([]byte("addr1"))
@ -198,7 +198,7 @@ func TestViewKeeper(t *testing.T) {
accountMapper.SetAccount(ctx, acc) accountMapper.SetAccount(ctx, acc)
require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{})) require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
coinKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}) bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})) require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
// Test HasCoins // Test HasCoins

View File

@ -18,8 +18,8 @@ func TestBankWithRandomMessages(t *testing.T) {
bank.RegisterWire(mapp.Cdc) bank.RegisterWire(mapp.Cdc)
mapper := mapp.AccountMapper mapper := mapp.AccountMapper
coinKeeper := bank.NewKeeper(mapper) bankKeeper := bank.NewKeeper(mapper)
mapp.Router().AddRoute("bank", bank.NewHandler(coinKeeper)) mapp.Router().AddRoute("bank", bank.NewHandler(bankKeeper))
err := mapp.CompleteSetup([]*sdk.KVStoreKey{}) err := mapp.CompleteSetup([]*sdk.KVStoreKey{})
if err != nil { if err != nil {

View File

@ -4,7 +4,7 @@ package stake
//type Keeper struct { //type Keeper struct {
//storeKey sdk.StoreKey //storeKey sdk.StoreKey
//cdc *wire.Codec //cdc *wire.Codec
//coinKeeper bank.Keeper //bankKeeper bank.Keeper
//// codespace //// codespace
//codespace sdk.CodespaceType //codespace sdk.CodespaceType
@ -14,7 +14,7 @@ package stake
//keeper := Keeper{ //keeper := Keeper{
//storeKey: key, //storeKey: key,
//cdc: cdc, //cdc: cdc,
//coinKeeper: ck, //bankKeeper: ck,
//codespace: codespace, //codespace: codespace,
//} //}
//return keeper //return keeper

View File

@ -151,6 +151,7 @@ func SimulateMsgVote(k gov.Keeper, sk stake.Keeper) simulation.Operation {
return operationSimulateMsgVote(k, sk, nil, -1) return operationSimulateMsgVote(k, sk, nil, -1)
} }
// nolint: unparam
func operationSimulateMsgVote(k gov.Keeper, sk stake.Keeper, key crypto.PrivKey, proposalID int64) simulation.Operation { func operationSimulateMsgVote(k gov.Keeper, sk stake.Keeper, key crypto.PrivKey, proposalID int64) simulation.Operation {
return func(tb testing.TB, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, keys []crypto.PrivKey, log string, event func(string)) (action string, fOp []simulation.FutureOperation, err sdk.Error) { return func(tb testing.TB, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, keys []crypto.PrivKey, log string, event func(string)) (action string, fOp []simulation.FutureOperation, err sdk.Error) {
if key == nil { if key == nil {

View File

@ -24,13 +24,13 @@ func TestGovWithRandomMessages(t *testing.T) {
bank.RegisterWire(mapp.Cdc) bank.RegisterWire(mapp.Cdc)
gov.RegisterWire(mapp.Cdc) gov.RegisterWire(mapp.Cdc)
mapper := mapp.AccountMapper mapper := mapp.AccountMapper
coinKeeper := bank.NewKeeper(mapper) bankKeeper := bank.NewKeeper(mapper)
stakeKey := sdk.NewKVStoreKey("stake") stakeKey := sdk.NewKVStoreKey("stake")
stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, coinKeeper, stake.DefaultCodespace) stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, bankKeeper, stake.DefaultCodespace)
paramKey := sdk.NewKVStoreKey("params") paramKey := sdk.NewKVStoreKey("params")
paramKeeper := params.NewKeeper(mapp.Cdc, paramKey) paramKeeper := params.NewKeeper(mapp.Cdc, paramKey)
govKey := sdk.NewKVStoreKey("gov") govKey := sdk.NewKVStoreKey("gov")
govKeeper := gov.NewKeeper(mapp.Cdc, govKey, paramKeeper.Setter(), coinKeeper, stakeKeeper, gov.DefaultCodespace) govKeeper := gov.NewKeeper(mapp.Cdc, govKey, paramKeeper.Setter(), bankKeeper, stakeKeeper, gov.DefaultCodespace)
mapp.Router().AddRoute("gov", gov.NewHandler(govKeeper)) mapp.Router().AddRoute("gov", gov.NewHandler(govKeeper))
mapp.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { mapp.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
gov.EndBlocker(ctx, govKeeper) gov.EndBlocker(ctx, govKeeper)

View File

@ -21,8 +21,8 @@ func getMockApp(t *testing.T) *mock.App {
RegisterWire(mapp.Cdc) RegisterWire(mapp.Cdc)
keyIBC := sdk.NewKVStoreKey("ibc") keyIBC := sdk.NewKVStoreKey("ibc")
ibcMapper := NewMapper(mapp.Cdc, keyIBC, mapp.RegisterCodespace(DefaultCodespace)) ibcMapper := NewMapper(mapp.Cdc, keyIBC, mapp.RegisterCodespace(DefaultCodespace))
coinKeeper := bank.NewKeeper(mapp.AccountMapper) bankKeeper := bank.NewKeeper(mapp.AccountMapper)
mapp.Router().AddRoute("ibc", NewHandler(ibcMapper, coinKeeper)) mapp.Router().AddRoute("ibc", NewHandler(ibcMapper, bankKeeper))
require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{keyIBC})) require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{keyIBC}))
return mapp return mapp

View File

@ -28,9 +28,9 @@ func getMockApp(t *testing.T) (*mock.App, stake.Keeper, Keeper) {
keyStake := sdk.NewKVStoreKey("stake") keyStake := sdk.NewKVStoreKey("stake")
keySlashing := sdk.NewKVStoreKey("slashing") keySlashing := sdk.NewKVStoreKey("slashing")
keyParams := sdk.NewKVStoreKey("params") keyParams := sdk.NewKVStoreKey("params")
coinKeeper := bank.NewKeeper(mapp.AccountMapper) bankKeeper := bank.NewKeeper(mapp.AccountMapper)
paramsKeeper := params.NewKeeper(mapp.Cdc, keyParams) paramsKeeper := params.NewKeeper(mapp.Cdc, keyParams)
stakeKeeper := stake.NewKeeper(mapp.Cdc, keyStake, coinKeeper, mapp.RegisterCodespace(stake.DefaultCodespace)) stakeKeeper := stake.NewKeeper(mapp.Cdc, keyStake, bankKeeper, mapp.RegisterCodespace(stake.DefaultCodespace))
keeper := NewKeeper(mapp.Cdc, keySlashing, stakeKeeper, paramsKeeper.Getter(), mapp.RegisterCodespace(DefaultCodespace)) keeper := NewKeeper(mapp.Cdc, keySlashing, stakeKeeper, paramsKeeper.Getter(), mapp.RegisterCodespace(DefaultCodespace))
mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper)) mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper))

View File

@ -34,8 +34,8 @@ func getMockApp(t *testing.T) (*mock.App, Keeper) {
RegisterWire(mApp.Cdc) RegisterWire(mApp.Cdc)
keyStake := sdk.NewKVStoreKey("stake") keyStake := sdk.NewKVStoreKey("stake")
coinKeeper := bank.NewKeeper(mApp.AccountMapper) bankKeeper := bank.NewKeeper(mApp.AccountMapper)
keeper := NewKeeper(mApp.Cdc, keyStake, coinKeeper, mApp.RegisterCodespace(DefaultCodespace)) keeper := NewKeeper(mApp.Cdc, keyStake, bankKeeper, mApp.RegisterCodespace(DefaultCodespace))
mApp.Router().AddRoute("stake", NewHandler(keeper)) mApp.Router().AddRoute("stake", NewHandler(keeper))
mApp.SetEndBlocker(getEndBlocker(keeper)) mApp.SetEndBlocker(getEndBlocker(keeper))

View File

@ -234,7 +234,7 @@ func (k Keeper) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.Co
if subtractAccount { if subtractAccount {
// Account new shares, save // Account new shares, save
_, _, err = k.coinKeeper.SubtractCoins(ctx, delegation.DelegatorAddr, sdk.Coins{bondAmt}) _, _, err = k.bankKeeper.SubtractCoins(ctx, delegation.DelegatorAddr, sdk.Coins{bondAmt})
if err != nil { if err != nil {
return return
} }
@ -362,7 +362,7 @@ func (k Keeper) BeginUnbonding(ctx sdk.Context,
// no need to create the ubd object just complete now // no need to create the ubd object just complete now
if completeNow { if completeNow {
_, _, err := k.coinKeeper.AddCoins(ctx, delAddr, sdk.Coins{balance}) _, _, err := k.bankKeeper.AddCoins(ctx, delAddr, sdk.Coins{balance})
if err != nil { if err != nil {
return err return err
} }
@ -395,7 +395,7 @@ func (k Keeper) CompleteUnbonding(ctx sdk.Context, delAddr sdk.AccAddress, valAd
return types.ErrNotMature(k.Codespace(), "unbonding", "unit-time", ubd.MinTime, ctxTime) return types.ErrNotMature(k.Codespace(), "unbonding", "unit-time", ubd.MinTime, ctxTime)
} }
_, _, err := k.coinKeeper.AddCoins(ctx, ubd.DelegatorAddr, sdk.Coins{ubd.Balance}) _, _, err := k.bankKeeper.AddCoins(ctx, ubd.DelegatorAddr, sdk.Coins{ubd.Balance})
if err != nil { if err != nil {
return err return err
} }

View File

@ -12,7 +12,7 @@ import (
type Keeper struct { type Keeper struct {
storeKey sdk.StoreKey storeKey sdk.StoreKey
cdc *wire.Codec cdc *wire.Codec
coinKeeper bank.Keeper bankKeeper bank.Keeper
validatorHooks sdk.ValidatorHooks validatorHooks sdk.ValidatorHooks
// codespace // codespace
@ -23,7 +23,7 @@ func NewKeeper(cdc *wire.Codec, key sdk.StoreKey, ck bank.Keeper, codespace sdk.
keeper := Keeper{ keeper := Keeper{
storeKey: key, storeKey: key,
cdc: cdc, cdc: cdc,
coinKeeper: ck, bankKeeper: ck,
validatorHooks: nil, validatorHooks: nil,
codespace: codespace, codespace: codespace,
} }

View File

@ -21,9 +21,9 @@ func TestStakeWithRandomMessages(t *testing.T) {
bank.RegisterWire(mapp.Cdc) bank.RegisterWire(mapp.Cdc)
mapper := mapp.AccountMapper mapper := mapp.AccountMapper
coinKeeper := bank.NewKeeper(mapper) bankKeeper := bank.NewKeeper(mapper)
stakeKey := sdk.NewKVStoreKey("stake") stakeKey := sdk.NewKVStoreKey("stake")
stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, coinKeeper, stake.DefaultCodespace) stakeKeeper := stake.NewKeeper(mapp.Cdc, stakeKey, bankKeeper, stake.DefaultCodespace)
mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper)) mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper))
mapp.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { mapp.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
validatorUpdates := stake.EndBlocker(ctx, stakeKeeper) validatorUpdates := stake.EndBlocker(ctx, stakeKeeper)
@ -55,7 +55,7 @@ func TestStakeWithRandomMessages(t *testing.T) {
}, []simulation.RandSetup{ }, []simulation.RandSetup{
Setup(mapp, stakeKeeper), Setup(mapp, stakeKeeper),
}, []simulation.Invariant{ }, []simulation.Invariant{
AllInvariants(coinKeeper, stakeKeeper, mapp.AccountMapper), AllInvariants(bankKeeper, stakeKeeper, mapp.AccountMapper),
}, 10, 100, }, 10, 100,
false, false,
) )