Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ebuchman committed Jun 27, 2018
1 parent fc81c14 commit 6a5a8b4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
8 changes: 4 additions & 4 deletions docs/core/app1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
```
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions docs/core/examples/app1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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"`
}

Expand Down
12 changes: 3 additions & 9 deletions docs/core/examples/app2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -219,7 +218,7 @@ func handleMsgIssue(ctx sdk.Context, keyMain *sdk.KVStoreKey, keyAcc *sdk.KVStor
}

return sdk.Result{
// TODO: Tags
// TODO: Tags
}

}
Expand All @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions docs/core/examples/app3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 6a5a8b4

Please sign in to comment.