Merge pull request #1379: Account constructor in AccountMaper

fix

fix democoin

fix tests

pass lint

last fix

apply requests

fix build failing

fix docs
This commit is contained in:
mossid
2018-07-09 20:29:14 -07:00
parent 7ba52e8d32
commit bc12880394
21 changed files with 48 additions and 65 deletions
+2 -2
View File
@@ -62,8 +62,8 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
// define and attach the mappers and keepers
app.accountMapper = auth.NewAccountMapper(
cdc,
app.keyAccount, // target store
&types.AppAccount{}, // prototype
app.keyAccount, // target store
auth.ProtoBaseAccount, // prototype
)
app.coinKeeper = bank.NewKeeper(app.accountMapper)
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
+1 -1
View File
@@ -71,7 +71,7 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
app.accountMapper = auth.NewAccountMapper(
cdc,
app.capKeyAccountStore, // target store
&types.AppAccount{}, // prototype
types.ProtoAppAccount, // prototype
)
// Add handlers.
+5
View File
@@ -21,6 +21,11 @@ type AppAccount struct {
Name string `json:"name"`
}
// Constructor for AppAccount
func ProtoAppAccount() auth.Account {
return &AppAccount{}
}
// nolint
func (acc AppAccount) GetName() string { return acc.Name }
func (acc *AppAccount) SetName(name string) { acc.Name = name }
+1 -1
View File
@@ -29,7 +29,7 @@ func TestCoolKeeper(t *testing.T) {
cdc := wire.NewCodec()
auth.RegisterBaseAccount(cdc)
am := auth.NewAccountMapper(cdc, capKey, &auth.BaseAccount{})
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil)
ck := bank.NewKeeper(am)
keeper := NewKeeper(capKey, ck, DefaultCodespace)
+1 -1
View File
@@ -19,7 +19,7 @@ func TestPowHandler(t *testing.T) {
cdc := wire.NewCodec()
auth.RegisterBaseAccount(cdc)
am := auth.NewAccountMapper(cdc, capKey, &auth.BaseAccount{})
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)
+1 -1
View File
@@ -32,7 +32,7 @@ func TestPowKeeperGetSet(t *testing.T) {
cdc := wire.NewCodec()
auth.RegisterBaseAccount(cdc)
am := auth.NewAccountMapper(cdc, capKey, &auth.BaseAccount{})
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)
@@ -35,7 +35,7 @@ func TestKeeperGetSet(t *testing.T) {
cdc := wire.NewCodec()
auth.RegisterBaseAccount(cdc)
accountMapper := auth.NewAccountMapper(cdc, authKey, &auth.BaseAccount{})
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
stakeKeeper := NewKeeper(capKey, bank.NewKeeper(accountMapper), DefaultCodespace)
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
addr := sdk.AccAddress([]byte("some-address"))
@@ -65,7 +65,7 @@ func TestBonding(t *testing.T) {
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
accountMapper := auth.NewAccountMapper(cdc, authKey, &auth.BaseAccount{})
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
coinKeeper := bank.NewKeeper(accountMapper)
stakeKeeper := NewKeeper(capKey, coinKeeper, DefaultCodespace)
addr := sdk.AccAddress([]byte("some-address"))