@@ -42,7 +42,7 @@ type BasecoinApp struct {
|
||||
keyIBC *sdk.KVStoreKey
|
||||
|
||||
// manage getting and setting accounts
|
||||
accountMapper auth.AccountMapper
|
||||
accountKeeper auth.AccountKeeper
|
||||
feeCollectionKeeper auth.FeeCollectionKeeper
|
||||
bankKeeper bank.Keeper
|
||||
ibcMapper ibc.Mapper
|
||||
@@ -67,14 +67,14 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
|
||||
}
|
||||
|
||||
// define and attach the mappers and keepers
|
||||
app.accountMapper = auth.NewAccountMapper(
|
||||
app.accountKeeper = auth.NewAccountKeeper(
|
||||
cdc,
|
||||
app.keyAccount, // target store
|
||||
func() auth.Account {
|
||||
return &types.AppAccount{}
|
||||
},
|
||||
)
|
||||
app.bankKeeper = bank.NewBaseKeeper(app.accountMapper)
|
||||
app.bankKeeper = bank.NewBaseKeeper(app.accountKeeper)
|
||||
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
|
||||
|
||||
// register message routes
|
||||
@@ -86,7 +86,7 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
|
||||
app.SetInitChainer(app.initChainer)
|
||||
app.SetBeginBlocker(app.BeginBlocker)
|
||||
app.SetEndBlocker(app.EndBlocker)
|
||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper, app.feeCollectionKeeper))
|
||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountKeeper, app.feeCollectionKeeper))
|
||||
|
||||
// mount the multistore and load the latest state
|
||||
app.MountStoresIAVL(app.keyMain, app.keyAccount, app.keyIBC)
|
||||
@@ -153,8 +153,8 @@ func (app *BasecoinApp) initChainer(ctx sdk.Context, req abci.RequestInitChain)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
acc.AccountNumber = app.accountMapper.GetNextAccountNumber(ctx)
|
||||
app.accountMapper.SetAccount(ctx, acc)
|
||||
acc.AccountNumber = app.accountKeeper.GetNextAccountNumber(ctx)
|
||||
app.accountKeeper.SetAccount(ctx, acc)
|
||||
}
|
||||
|
||||
return abci.ResponseInitChain{}
|
||||
@@ -177,7 +177,7 @@ func (app *BasecoinApp) ExportAppStateAndValidators() (appState json.RawMessage,
|
||||
return false
|
||||
}
|
||||
|
||||
app.accountMapper.IterateAccounts(ctx, appendAccountsFn)
|
||||
app.accountKeeper.IterateAccounts(ctx, appendAccountsFn)
|
||||
|
||||
genState := types.GenesisState{Accounts: accounts}
|
||||
appState, err = codec.MarshalJSONIndent(app.cdc, genState)
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestGenesis(t *testing.T) {
|
||||
|
||||
// create a context for the BaseApp
|
||||
ctx := baseApp.BaseApp.NewContext(true, abci.Header{})
|
||||
res := baseApp.accountMapper.GetAccount(ctx, baseAcct.Address)
|
||||
res := baseApp.accountKeeper.GetAccount(ctx, baseAcct.Address)
|
||||
require.Equal(t, appAcct, res)
|
||||
|
||||
// reload app and ensure the account is still there
|
||||
@@ -76,6 +76,6 @@ func TestGenesis(t *testing.T) {
|
||||
})
|
||||
|
||||
ctx = baseApp.BaseApp.NewContext(true, abci.Header{})
|
||||
res = baseApp.accountMapper.GetAccount(ctx, baseAcct.Address)
|
||||
res = baseApp.accountKeeper.GetAccount(ctx, baseAcct.Address)
|
||||
require.Equal(t, appAcct, res)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ var _ auth.Account = (*AppAccount)(nil)
|
||||
|
||||
// AppAccount is a custom extension for this application. It is an example of
|
||||
// extending auth.BaseAccount with custom fields. It is compatible with the
|
||||
// stock auth.AccountMapper, since auth.AccountMapper uses the flexible go-amino
|
||||
// stock auth.AccountKeeper, since auth.AccountKeeper uses the flexible go-amino
|
||||
// library.
|
||||
type AppAccount struct {
|
||||
auth.BaseAccount
|
||||
|
||||
@@ -55,7 +55,7 @@ type DemocoinApp struct {
|
||||
stakeKeeper simplestake.Keeper
|
||||
|
||||
// Manage getting and setting accounts
|
||||
accountMapper auth.AccountMapper
|
||||
accountKeeper auth.AccountKeeper
|
||||
}
|
||||
|
||||
func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
||||
@@ -74,15 +74,15 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
||||
capKeyStakingStore: sdk.NewKVStoreKey("stake"),
|
||||
}
|
||||
|
||||
// Define the accountMapper.
|
||||
app.accountMapper = auth.NewAccountMapper(
|
||||
// Define the accountKeeper.
|
||||
app.accountKeeper = auth.NewAccountKeeper(
|
||||
cdc,
|
||||
app.capKeyAccountStore, // target store
|
||||
types.ProtoAppAccount, // prototype
|
||||
)
|
||||
|
||||
// Add handlers.
|
||||
app.bankKeeper = bank.NewBaseKeeper(app.accountMapper)
|
||||
app.bankKeeper = bank.NewBaseKeeper(app.accountKeeper)
|
||||
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))
|
||||
@@ -98,7 +98,7 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
||||
// Initialize BaseApp.
|
||||
app.SetInitChainer(app.initChainerFn(app.coolKeeper, app.powKeeper))
|
||||
app.MountStoresIAVL(app.capKeyMainStore, app.capKeyAccountStore, app.capKeyPowStore, app.capKeyIBCStore, app.capKeyStakingStore)
|
||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper, app.feeCollectionKeeper))
|
||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountKeeper, app.feeCollectionKeeper))
|
||||
err := app.LoadLatestVersion(app.capKeyMainStore)
|
||||
if err != nil {
|
||||
cmn.Exit(err.Error())
|
||||
@@ -148,7 +148,7 @@ func (app *DemocoinApp) initChainerFn(coolKeeper cool.Keeper, powKeeper pow.Keep
|
||||
panic(err) // TODO https://github.com/cosmos/cosmos-sdk/issues/468
|
||||
// return sdk.ErrGenesisParse("").TraceCause(err, "")
|
||||
}
|
||||
app.accountMapper.SetAccount(ctx, acc)
|
||||
app.accountKeeper.SetAccount(ctx, acc)
|
||||
}
|
||||
|
||||
// Application specific genesis handling
|
||||
@@ -182,7 +182,7 @@ func (app *DemocoinApp) ExportAppStateAndValidators() (appState json.RawMessage,
|
||||
accounts = append(accounts, account)
|
||||
return false
|
||||
}
|
||||
app.accountMapper.IterateAccounts(ctx, appendAccount)
|
||||
app.accountKeeper.IterateAccounts(ctx, appendAccount)
|
||||
|
||||
genState := types.GenesisState{
|
||||
Accounts: accounts,
|
||||
|
||||
@@ -60,13 +60,13 @@ func TestGenesis(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
// A checkTx context
|
||||
ctx := bapp.BaseApp.NewContext(true, abci.Header{})
|
||||
res1 := bapp.accountMapper.GetAccount(ctx, baseAcc.Address)
|
||||
res1 := bapp.accountKeeper.GetAccount(ctx, baseAcc.Address)
|
||||
require.Equal(t, acc, res1)
|
||||
|
||||
// reload app and ensure the account is still there
|
||||
bapp = NewDemocoinApp(logger, db)
|
||||
bapp.InitChain(abci.RequestInitChain{AppStateBytes: []byte("{}")})
|
||||
ctx = bapp.BaseApp.NewContext(true, abci.Header{})
|
||||
res1 = bapp.accountMapper.GetAccount(ctx, baseAcc.Address)
|
||||
res1 = bapp.accountKeeper.GetAccount(ctx, baseAcc.Address)
|
||||
require.Equal(t, acc, res1)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func getMockApp(t *testing.T) *mock.App {
|
||||
|
||||
RegisterCodec(mapp.Cdc)
|
||||
keyCool := sdk.NewKVStoreKey("cool")
|
||||
bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper)
|
||||
bankKeeper := bank.NewBaseKeeper(mapp.AccountKeeper)
|
||||
keeper := NewKeeper(keyCool, bankKeeper, mapp.RegisterCodespace(DefaultCodespace))
|
||||
mapp.Router().AddRoute("cool", NewHandler(keeper))
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestMsgQuiz(t *testing.T) {
|
||||
|
||||
// A checkTx context (true)
|
||||
ctxCheck := mapp.BaseApp.NewContext(true, abci.Header{})
|
||||
res1 := mapp.AccountMapper.GetAccount(ctxCheck, addr1)
|
||||
res1 := mapp.AccountKeeper.GetAccount(ctxCheck, addr1)
|
||||
require.Equal(t, acc1, res1)
|
||||
|
||||
// Set the trend, submit a really cool quiz and check for reward
|
||||
|
||||
@@ -29,7 +29,7 @@ func (k Keeper) GetTrend(ctx sdk.Context) string {
|
||||
return string(bz)
|
||||
}
|
||||
|
||||
// Implements sdk.AccountMapper.
|
||||
// Implements sdk.AccountKeeper.
|
||||
func (k Keeper) setTrend(ctx sdk.Context, newTrend string) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(trendKey, []byte(newTrend))
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestCoolKeeper(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
auth.RegisterBaseAccount(cdc)
|
||||
|
||||
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
||||
am := auth.NewAccountKeeper(cdc, capKey, auth.ProtoBaseAccount)
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, nil)
|
||||
ck := bank.NewBaseKeeper(am)
|
||||
keeper := NewKeeper(capKey, ck, DefaultCodespace)
|
||||
|
||||
@@ -25,7 +25,7 @@ func getMockApp(t *testing.T) *mock.App {
|
||||
|
||||
RegisterCodec(mapp.Cdc)
|
||||
keyPOW := sdk.NewKVStoreKey("pow")
|
||||
bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper)
|
||||
bankKeeper := bank.NewBaseKeeper(mapp.AccountKeeper)
|
||||
config := Config{"pow", 1}
|
||||
keeper := NewKeeper(keyPOW, config, bankKeeper, mapp.RegisterCodespace(DefaultCodespace))
|
||||
mapp.Router().AddRoute("pow", keeper.Handler)
|
||||
@@ -69,7 +69,7 @@ func TestMsgMine(t *testing.T) {
|
||||
|
||||
// A checkTx context (true)
|
||||
ctxCheck := mapp.BaseApp.NewContext(true, abci.Header{})
|
||||
res1 := mapp.AccountMapper.GetAccount(ctxCheck, addr1)
|
||||
res1 := mapp.AccountKeeper.GetAccount(ctxCheck, addr1)
|
||||
require.Equal(t, acc1, res1)
|
||||
|
||||
// Mine and check for reward
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestPowHandler(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
auth.RegisterBaseAccount(cdc)
|
||||
|
||||
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
||||
am := auth.NewAccountKeeper(cdc, capKey, auth.ProtoBaseAccount)
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
config := NewConfig("pow", int64(1))
|
||||
ck := bank.NewBaseKeeper(am)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestPowKeeperGetSet(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
auth.RegisterBaseAccount(cdc)
|
||||
|
||||
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
||||
am := auth.NewAccountKeeper(cdc, capKey, auth.ProtoBaseAccount)
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
config := NewConfig("pow", int64(1))
|
||||
ck := bank.NewBaseKeeper(am)
|
||||
|
||||
@@ -35,8 +35,8 @@ func TestKeeperGetSet(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
auth.RegisterBaseAccount(cdc)
|
||||
|
||||
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
|
||||
stakeKeeper := NewKeeper(capKey, bank.NewBaseKeeper(accountMapper), DefaultCodespace)
|
||||
accountKeeper := auth.NewAccountKeeper(cdc, authKey, auth.ProtoBaseAccount)
|
||||
stakeKeeper := NewKeeper(capKey, bank.NewBaseKeeper(accountKeeper), DefaultCodespace)
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
addr := sdk.AccAddress([]byte("some-address"))
|
||||
|
||||
@@ -65,8 +65,8 @@ func TestBonding(t *testing.T) {
|
||||
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
|
||||
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
|
||||
bankKeeper := bank.NewBaseKeeper(accountMapper)
|
||||
accountKeeper := auth.NewAccountKeeper(cdc, authKey, auth.ProtoBaseAccount)
|
||||
bankKeeper := bank.NewBaseKeeper(accountKeeper)
|
||||
stakeKeeper := NewKeeper(capKey, bankKeeper, DefaultCodespace)
|
||||
addr := sdk.AccAddress([]byte("some-address"))
|
||||
privKey := ed25519.GenPrivKey()
|
||||
|
||||
Reference in New Issue
Block a user