removed seal

This commit is contained in:
Sunny Aggarwal 2018-04-22 23:36:15 -07:00
parent d613c2b9e6
commit 016a1c8ec9
6 changed files with 4 additions and 47 deletions

View File

@ -58,7 +58,7 @@ func NewGaiaApp(logger log.Logger, db dbm.DB) *GaiaApp {
app.cdc,
app.keyMain, // target store
&auth.BaseAccount{}, // prototype
).Seal()
)
// add handlers
app.coinKeeper = bank.NewKeeper(app.accountMapper)

View File

@ -61,7 +61,7 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
cdc,
app.capKeyMainStore, // target store
&types.AppAccount{}, // prototype
).Seal()
)
// Add handlers.
coinKeeper := bank.NewKeeper(app.accountMapper)

View File

@ -66,7 +66,7 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
cdc,
app.capKeyMainStore, // target store
&types.AppAccount{}, // prototype
).Seal()
)
// Add handlers.
coinKeeper := bank.NewKeeper(app.accountMapper)

View File

@ -9,7 +9,6 @@ import (
)
var _ sdk.AccountMapper = (*accountMapper)(nil)
var _ sdk.AccountMapper = (*sealedAccountMapper)(nil)
// Implements sdk.AccountMapper.
// This AccountMapper encodes/decodes accounts using the
@ -37,21 +36,6 @@ func NewAccountMapper(cdc *wire.Codec, key sdk.StoreKey, proto sdk.Account) acco
}
}
// Returns the go-amino codec. You may need to register interfaces
// and concrete types here, if your app's sdk.Account
// implementation includes interface fields.
// NOTE: It is not secure to expose the codec, so check out
// .Seal().
func (am accountMapper) WireCodec() *wire.Codec {
return am.cdc
}
// Returns a "sealed" accountMapper.
// The codec is not accessible from a sealedAccountMapper.
func (am accountMapper) Seal() sealedAccountMapper {
return sealedAccountMapper{am}
}
// Implements sdk.AccountMapper.
func (am accountMapper) NewAccountWithAddress(ctx sdk.Context, addr sdk.Address) sdk.Account {
acc := am.clonePrototype()
@ -78,19 +62,6 @@ func (am accountMapper) SetAccount(ctx sdk.Context, acc sdk.Account) {
store.Set(addr, bz)
}
//----------------------------------------
// sealedAccountMapper
type sealedAccountMapper struct {
accountMapper
}
// There's no way for external modules to mutate the
// sam.accountMapper.cdc from here, even with reflection.
func (sam sealedAccountMapper) WireCodec() *wire.Codec {
panic("accountMapper is sealed")
}
//----------------------------------------
// misc.

View File

@ -57,17 +57,3 @@ func TestAccountMapperGetSet(t *testing.T) {
assert.NotNil(t, acc)
assert.Equal(t, newSequence, acc.GetSequence())
}
func TestAccountMapperSealed(t *testing.T) {
_, capKey := setupMultiStore()
cdc := wire.NewCodec()
RegisterBaseAccount(cdc)
// normal mapper exposes the wire codec
mapper := NewAccountMapper(cdc, capKey, &BaseAccount{})
assert.NotNil(t, mapper.WireCodec())
// seal mapper, should panic when we try to get the codec
mapperSealed := mapper.Seal()
assert.Panics(t, func() { mapperSealed.WireCodec() })
}

View File

@ -138,7 +138,7 @@ func createTestInput(t *testing.T, isCheckTx bool, initCoins int64) (sdk.Context
cdc, // amino codec
keyMain, // target store
&auth.BaseAccount{}, // prototype
).Seal()
)
ck := bank.NewKeeper(accountMapper)
keeper := NewKeeper(cdc, keyStake, ck, DefaultCodespace)
keeper.setPool(ctx, initialPool())