Skip to content

Commit

Permalink
hellochain compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
okwme committed Oct 22, 2019
1 parent 1d9709b commit 146644a
Show file tree
Hide file tree
Showing 43 changed files with 155 additions and 112 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions hellochain/app.go
Expand Up @@ -3,14 +3,14 @@ package hellochain
import (
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/sdk-tutorials/utils/starter"
"github.com/cosmos/sdk-application-tutorial/hellochain/utils/starter"

//import greeter types
"github.com/cosmos/hellochain/x/greeter"
gtypes "github.com/cosmos/hellochain/x/greeter/types"
"github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter"
gtypes "github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter/types"
)

const appName = "hellochain"
Expand Down
6 changes: 3 additions & 3 deletions hellochain/cmd/hccli/main.go
Expand Up @@ -3,9 +3,9 @@ package main
import (
"github.com/tendermint/tendermint/libs/cli"

app "github.com/cosmos/hellochain"
"github.com/cosmos/hellochain/x/greeter"
"github.com/cosmos/sdk-tutorials/utils/starter"
app "github.com/cosmos/sdk-application-tutorial/hellochain"
"github.com/cosmos/sdk-application-tutorial/hellochain/utils/starter"
"github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions hellochain/cmd/hcd/main.go
Expand Up @@ -3,8 +3,8 @@ package main
import (
"github.com/tendermint/tendermint/libs/cli"

app "github.com/cosmos/hellochain"
"github.com/cosmos/sdk-tutorials/utils/starter"
app "github.com/cosmos/sdk-application-tutorial/hellochain"
"github.com/cosmos/sdk-application-tutorial/hellochain/utils/starter"
)

func main() {
Expand Down
14 changes: 5 additions & 9 deletions hellochain/go.mod
@@ -1,12 +1,10 @@
module github.com/cosmos/hellochain
module github.com/cosmos/sdk-application-tutorial/hellochain

go 1.12

require (
github.com/cosmos/cosmos-sdk v0.36.0-rc1
github.com/gogo/protobuf v1.2.1
github.com/cosmos/cosmos-sdk v0.37.3
github.com/gorilla/mux v1.7.0
github.com/magiconair/properties v1.8.1 // indirect
github.com/mattn/go-isatty v0.0.8 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
Expand All @@ -16,15 +14,13 @@ require (
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.4.0
github.com/tendermint/go-amino v0.15.0
github.com/tendermint/tendermint v0.32.1
github.com/tendermint/tendermint v0.32.6
github.com/tendermint/tm-db v0.2.0
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 // indirect
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 // indirect
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 // indirect
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190822000311-fc82fb2afd64 // indirect
google.golang.org/appengine v1.4.0 // indirect
google.golang.org/genproto v0.0.0-20190611190212-a7e196e89fd3 // indirect
google.golang.org/grpc v1.21.1 // indirect
gopkg.in/yaml.v2 v2.2.2

)
87 changes: 51 additions & 36 deletions hellochain/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hellochain/tutorial/00-intro.md
Expand Up @@ -15,7 +15,7 @@ functionality in the form of our `greeter` module.
### Starter

To speed up this tutorial, A lot of basic functionality comes packaged for you
in the [starter](https://github.com/cosmos/hellochain/tree/master/starter)
in the [starter](https://github.com/cosmos/sdk-application-tutorial/hellochain/tree/master/starter)
package. It will provide basic accounts, a bank, authentication, transaction
(Tx) verification as well as some helper functions for building CLI tools.
`starter` is your "crutch" for this tutorial. It is a heavily configured
Expand Down
4 changes: 2 additions & 2 deletions hellochain/tutorial/01-simple-app.md
Expand Up @@ -21,10 +21,10 @@ package hellochain
import (
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tendermint/libs/db"
dbm "github.com/tendermint/tm-db"
"github.com/tendermint/tendermint/libs/log"

"github.com/cosmos/sdk-tutorials/utils/starter"
"github.com/cosmos/sdk-application-tutorial/hellochain/utils/starter"
)

const appName = "hellochain"
Expand Down
4 changes: 2 additions & 2 deletions hellochain/tutorial/02-simple-start.md
Expand Up @@ -20,8 +20,8 @@ package main
import (
"github.com/tendermint/tendermint/libs/cli"

app "github.com/cosmos/hellochain"
"github.com/cosmos/sdk-tutorials/utils/starter"
app "github.com/cosmos/sdk-application-tutorial/hellochain"
"github.com/cosmos/sdk-application-tutorial/hellochain/utils/starter"
)

func main() {
Expand Down
Expand Up @@ -7,11 +7,12 @@ import (

abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
pvm "github.com/tendermint/tendermint/privval"
tmtypes "github.com/tendermint/tendermint/types"

dbm "github.com/tendermint/tm-db"

bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
Expand Down Expand Up @@ -93,6 +94,21 @@ func (app *AppStarter) InitChainer(ctx sdk.Context, req abci.RequestInitChain) a
panic(err)
}

/*
---------------------NOTICE-----------------------
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
The code below is a hack to override the
functionality of tendermint. It is done here like
this so that you can focus on building fun custom
modules instead of all the necessary plumbing
required when building a production-ready app with
proof-of-stake. Don't worry about it now but
PLEASE NOTE that this is NOT BEST PRACTICE!
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
---------------------------------------------------
*/
privValidator := pvm.LoadOrGenFilePV(
config.PrivValidatorKeyFile(), config.PrivValidatorStateFile())
valPubKey := tmtypes.TM2PB.PubKey(privValidator.GetPubKey())
Expand Down Expand Up @@ -187,14 +203,14 @@ func NewAppStarter(appName string, logger log.Logger, db dbm.DB, moduleBasics ..
app.accountKeeper,
bankSupspace,
bank.DefaultCodespace,
app.ModuleAccountAddrs(),
)

app.supplyKeeper = supply.NewKeeper(
app.Cdc,
app.keySupply,
app.accountKeeper,
app.bankKeeper,
supply.DefaultCodespace,
maccPerms)

app.Mm = module.NewManager(
Expand All @@ -218,6 +234,16 @@ func (app *AppStarter) GetCodec() *codec.Codec {
return app.Cdc
}

// ModuleAccountAddrs returns all the app's module account addresses.
func (app *AppStarter) ModuleAccountAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range maccPerms {
modAccAddrs[supply.NewModuleAddress(acc).String()] = true
}

return modAccAddrs
}

// InitializeStarter configures the app. NOTE ModuleBasics must be complete before calling this
func (app *AppStarter) InitializeStarter() {

Expand Down Expand Up @@ -264,7 +290,8 @@ func NewAppCreator(creator func(log.Logger, dbm.DB) abci.Application) server.App

// NewAppExporter wraps and returns a function for exporting application state
func NewAppExporter(creator func(log.Logger, dbm.DB) abci.Application) server.AppExporter {
return func(logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailWhiteList []string) (json.RawMessage, []tmtypes.GenesisValidator, error) {
return func(logger log.Logger, db dbm.DB, traceStore io.Writer, height int64,
forZeroHeight bool, jailWhiteList []string) (json.RawMessage, []tmtypes.GenesisValidator, error) {
return nil, nil, nil
}
}
File renamed without changes.
Expand Up @@ -139,7 +139,8 @@ type ServerCommandParams struct {
}

// NewServerCommandParams collects the params for a server command
func NewServerCommandParams(name string, desc string, creator server.AppCreator, exporter server.AppExporter) ServerCommandParams {
func NewServerCommandParams(name string, desc string, creator server.AppCreator,
exporter server.AppExporter) ServerCommandParams {
return ServerCommandParams{name, desc, creator, exporter}
}

Expand Down Expand Up @@ -167,7 +168,8 @@ func NewServerCommand(params ServerCommandParams) *cobra.Command {
rootCmd.AddCommand(
genutilcli.InitCmd(ctx, cdc, ModuleBasics, DefaultNodeHome),
genutilcli.CollectGenTxsCmd(ctx, cdc, genaccounts.AppModuleBasic{}, DefaultNodeHome),
genutilcli.GenTxCmd(ctx, cdc, ModuleBasics, staking.AppModuleBasic{}, genaccounts.AppModuleBasic{}, DefaultNodeHome, DefaultCLIHome),
genutilcli.GenTxCmd(ctx, cdc, ModuleBasics, staking.AppModuleBasic{},
genaccounts.AppModuleBasic{}, DefaultNodeHome, DefaultCLIHome),
genutilcli.ValidateGenesisCmd(ctx, cdc, ModuleBasics),
genaccscli.AddGenesisAccountCmd(ctx, cdc, DefaultNodeHome, DefaultCLIHome),
)
Expand Down
2 changes: 1 addition & 1 deletion hellochain/x/greeter/client/cli/query.go
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec"

types "github.com/cosmos/hellochain/x/greeter/types"
types "github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter/types"
)

// GetQueryCmd returns the parent query command for the greeter module
Expand Down
2 changes: 1 addition & 1 deletion hellochain/x/greeter/client/cli/tx.go
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
gtypes "github.com/cosmos/hellochain/x/greeter/types"
gtypes "github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter/types"
)

// GetTxCmd returns the parent transaction command for the greeting module
Expand Down
3 changes: 2 additions & 1 deletion hellochain/x/greeter/handler.go
Expand Up @@ -2,8 +2,9 @@ package greeter

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
gtypes "github.com/cosmos/hellochain/x/greeter/types"
gtypes "github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter/types"
)

// NewHandler returns a handler for "greeter" type messages.
Expand Down
5 changes: 3 additions & 2 deletions hellochain/x/greeter/keeper.go
Expand Up @@ -2,12 +2,13 @@ package greeter

import (
"github.com/cosmos/cosmos-sdk/codec"
gtypes "github.com/cosmos/hellochain/x/greeter/types"
gtypes "github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine
// Keeper maintains the link to data storage and exposes getter/setter methods for the various
// parts of the state machine
type Keeper struct {
storeKey sdk.StoreKey // Unexposed key to access store from sdk.Context

Expand Down
6 changes: 3 additions & 3 deletions hellochain/x/greeter/module.go
Expand Up @@ -6,10 +6,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
gtypes "github.com/cosmos/hellochain/x/greeter/types"
starter "github.com/cosmos/sdk-tutorials/utils/starter"
"github.com/cosmos/sdk-application-tutorial/hellochain/utils/starter"
gtypes "github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter/types"

"github.com/cosmos/hellochain/x/greeter/client/cli"
"github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter/client/cli"
)

// AppModuleBasic is the minimal struct for a module
Expand Down
2 changes: 1 addition & 1 deletion hellochain/x/greeter/querier.go
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
gtypes "github.com/cosmos/hellochain/x/greeter/types"
gtypes "github.com/cosmos/sdk-application-tutorial/hellochain/x/greeter/types"
)

// query endpoints supported by the hellochain Querier
Expand Down
3 changes: 2 additions & 1 deletion hellochain/x/greeter/types/types.go
Expand Up @@ -21,7 +21,8 @@ var (
ModuleCdc = codec.New()
)

// struct containing the data of the Greeting. json and yaml tags are used to specify field names when marshalled to json
// struct containing the data of the Greeting. json and yaml tags are used to specify field names
// when marshalled to json
type Greeting struct {
Sender sdk.AccAddress `json:"sender" yaml:"sender"` // address of the account "sending" the greeting
Recipient sdk.AccAddress `json:"receiver" yaml:"receiver"` // address of the account "receiving" the greeting
Expand Down
2 changes: 1 addition & 1 deletion nameservice/app.go
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/supply"

"github.com/cosmos/sdk-application-tutorial/x/nameservice"
"github.com/cosmos/sdk-application-tutorial/nameservice/x/nameservice"
)

const appName = "nameservice"
Expand Down
2 changes: 1 addition & 1 deletion nameservice/cmd/nscli/main.go
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/version"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
app "github.com/cosmos/sdk-application-tutorial"
app "github.com/cosmos/sdk-application-tutorial/nameservice"
"github.com/spf13/cobra"
"github.com/spf13/viper"
amino "github.com/tendermint/go-amino"
Expand Down
2 changes: 1 addition & 1 deletion nameservice/cmd/nsd/main.go
Expand Up @@ -15,7 +15,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
app "github.com/cosmos/sdk-application-tutorial"
app "github.com/cosmos/sdk-application-tutorial/nameservice"
abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
Expand Down
2 changes: 1 addition & 1 deletion nameservice/go.mod
@@ -1,4 +1,4 @@
module github.com/cosmos/sdk-application-tutorial
module github.com/cosmos/sdk-application-tutorial/nameservice

go 1.13

Expand Down
2 changes: 1 addition & 1 deletion nameservice/tutorial/01-app-init.md
Expand Up @@ -28,7 +28,7 @@ import (
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/sdk-application-tutorial/x/nameservice"
"github.com/cosmos/sdk-application-tutorial/nameservice/x/nameservice"

bam "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
2 changes: 1 addition & 1 deletion nameservice/tutorial/02-keeper.md
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/sdk-application-tutorial/x/nameservice/types"
"github.com/cosmos/sdk-application-tutorial/nameservice/x/nameservice/types"
)

// Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine
Expand Down
2 changes: 1 addition & 1 deletion nameservice/tutorial/06-queriers.md
Expand Up @@ -47,7 +47,7 @@ package keeper

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/sdk-application-tutorial/x/nameservice/internal/types"
"github.com/cosmos/sdk-application-tutorial/nameservice/x/nameservice/internal/types"

sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
Expand Down
6 changes: 3 additions & 3 deletions nameservice/tutorial/08-cli.md
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/sdk-application-tutorial/x/nameservice/types"
"github.com/cosmos/sdk-application-tutorial/nameservice/x/nameservice/types"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -124,7 +124,7 @@ Notes on the above code:

Now that the query interactions are defined, it is time to move on to transaction generation in `tx.go`:

> _*NOTE*_: Your application needs to import the code you just wrote. Here the import path is set to this repository (`github.com/cosmos/sdk-application-tutorial/x/nameservice`). If you are following along in your own repo you will need to change the import path to reflect that (`github.com/{ .Username }/{ .Project.Repo }/x/nameservice`).
> _*NOTE*_: Your application needs to import the code you just wrote. Here the import path is set to this repository (`github.com/cosmos/sdk-application-tutorial/nameservice/x/nameservice`). If you are following along in your own repo you will need to change the import path to reflect that (`github.com/{ .Username }/{ .Project.Repo }/x/nameservice`).
```go
package cli
Expand All @@ -138,7 +138,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/cosmos/sdk-application-tutorial/x/nameservice/types"
"github.com/cosmos/sdk-application-tutorial/nameservice/x/nameservice/types"
)

func GetTxCmd(storeKey string, cdc *codec.Codec) *cobra.Command {
Expand Down
4 changes: 2 additions & 2 deletions nameservice/tutorial/09-rest.md
Expand Up @@ -10,7 +10,7 @@ Your module can also expose a REST interface to allow programatic access to the

Add in the `imports` and `const`s to get started:

> _*NOTE*_: Your application needs to import the code you just wrote. Here the import path is set to this repository (`github.com/cosmos/sdk-application-tutorial/x/nameservice`). If you are following along in your own repo you will need to change the import path to reflect that (`github.com/{ .Username }/{ .Project.Repo }/x/nameservice`).
> _*NOTE*_: Your application needs to import the code you just wrote. Here the import path is set to this repository (`github.com/cosmos/sdk-application-tutorial/nameservice/x/nameservice`). If you are following along in your own repo you will need to change the import path to reflect that (`github.com/{ .Username }/{ .Project.Repo }/x/nameservice`).
```go
package rest
Expand All @@ -20,7 +20,7 @@ import (
"net/http"

"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/sdk-application-tutorial/x/nameservice/types"
"github.com/cosmos/sdk-application-tutorial/nameservice/x/nameservice/types"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down

0 comments on commit 146644a

Please sign in to comment.