minor cleanup

This commit is contained in:
Ethan Buchman 2018-06-27 07:59:20 -04:00
parent fc81c14a16
commit 6a5a8b4721
4 changed files with 13 additions and 17 deletions

View File

@ -243,7 +243,7 @@ Note this handler has unfettered access to the store specified by the capability
For this first example, we will define a simple account that is JSON encoded:
```go
type app1Account struct {
type appAccount struct {
Coins sdk.Coins `json:"coins"`
}
```
@ -294,7 +294,7 @@ func handleFrom(store sdk.KVStore, from sdk.Address, amt sdk.Coins) sdk.Result {
}
// Unmarshal the JSON account bytes.
var acc app1Account
var acc appAccount
err := json.Unmarshal(accBytes, &acc)
if err != nil {
// InternalError
@ -326,10 +326,10 @@ func handleFrom(store sdk.KVStore, from sdk.Address, amt sdk.Coins) sdk.Result {
func handleTo(store sdk.KVStore, to sdk.Address, amt sdk.Coins) sdk.Result {
// Add msg amount to receiver account
accBytes := store.Get(to)
var acc app1Account
var acc appAccount
if accBytes == nil {
// Receiver account does not already exist, create a new one.
acc = app1Account{}
acc = appAccount{}
} else {
// Receiver account already exists. Retrieve and decode it.
err := json.Unmarshal(accBytes, &acc)

View File

@ -149,7 +149,7 @@ func handleFrom(store sdk.KVStore, from sdk.Address, amt sdk.Coins) sdk.Result {
}
// Unmarshal the JSON account bytes.
var acc app1Account
var acc appAccount
err := json.Unmarshal(accBytes, &acc)
if err != nil {
// InternalError
@ -181,10 +181,10 @@ func handleFrom(store sdk.KVStore, from sdk.Address, amt sdk.Coins) sdk.Result {
func handleTo(store sdk.KVStore, to sdk.Address, amt sdk.Coins) sdk.Result {
// Add msg amount to receiver account
accBytes := store.Get(to)
var acc app1Account
var acc appAccount
if accBytes == nil {
// Receiver account does not already exist, create a new one.
acc = app1Account{}
acc = appAccount{}
} else {
// Receiver account already exists. Retrieve and decode it.
err := json.Unmarshal(accBytes, &acc)
@ -210,7 +210,7 @@ func handleTo(store sdk.KVStore, to sdk.Address, amt sdk.Coins) sdk.Result {
return sdk.Result{}
}
type app1Account struct {
type appAccount struct {
Coins sdk.Coins `json:"coins"`
}

View File

@ -25,7 +25,6 @@ var (
)
func NewCodec() *wire.Codec {
// TODO register
cdc := wire.NewCodec()
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
cdc.RegisterConcrete(MsgSend{}, "example/MsgSend", nil)
@ -190,10 +189,10 @@ func handleMsgIssue(ctx sdk.Context, keyMain *sdk.KVStoreKey, keyAcc *sdk.KVStor
// Add coins to receiver account
bz := accStore.Get(o.Address)
var acc account
var acc appAccount
if bz == nil {
// Receiver account does not already exist, create a new one.
acc = account{}
acc = appAccount{}
} else {
// Receiver account already exists. Retrieve and decode it.
err := json.Unmarshal(bz, &acc)
@ -219,7 +218,7 @@ func handleMsgIssue(ctx sdk.Context, keyMain *sdk.KVStoreKey, keyAcc *sdk.KVStor
}
return sdk.Result{
// TODO: Tags
// TODO: Tags
}
}
@ -238,11 +237,6 @@ func (tx app2Tx) GetMsgs() []sdk.Msg {
return []sdk.Msg{tx.Msg}
}
// TODO: remove the need for this
func (tx app2Tx) GetMemo() string {
return ""
}
func (tx app2Tx) GetSignatures() []auth.StdSignature {
return tx.Signatures
}

View File

@ -21,6 +21,7 @@ const (
func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
// Create the codec with registered Msg types
cdc := NewCodec()
// Create the base application object.
@ -32,6 +33,7 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
keyFees := sdk.NewKVStoreKey("fee")
// Set various mappers/keepers to interact easily with underlying stores
// TODO: Need to register Account interface or use different Codec
accountMapper := auth.NewAccountMapper(cdc, keyAccount, &auth.BaseAccount{})
accountKeeper := bank.NewKeeper(accountMapper)
metadataMapper := NewApp3MetaDataMapper(keyMain)