Skip to content

Commit

Permalink
chore: example change name (#1512)
Browse files Browse the repository at this point in the history
* change name

* update ve

* Delete keeper_test.go
  • Loading branch information
samricotta authored Feb 6, 2024
1 parent 6cf672f commit b033428
Show file tree
Hide file tree
Showing 36 changed files with 179 additions and 242 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build/tutoriald
build/exampled
build/
data/
config/
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The published content currently lives in a few separate folders:

Meet the people [behind the Cosmos SDK and contributors](https://github.com/cosmos/sdk-tutorials/graphs/contributors).

## Viewing Tutorial Builds
## Viewing Example Builds

There are two ways to see what your changes will look like in production before the updated pages are published:

Expand Down
8 changes: 4 additions & 4 deletions tutorials/base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ifeq (,$(VERSION))
endif

# Update the ldflags with the app, client & server names
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=tutorial \
-X github.com/cosmos/cosmos-sdk/version.AppName=tutoriald \
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=example \
-X github.com/cosmos/cosmos-sdk/version.AppName=exampled \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)

Expand All @@ -27,8 +27,8 @@ all: install
install:
@echo "--> ensure dependencies have not been modified"
@go mod verify
@echo "--> installing tutoriald"
@go install $(BUILD_FLAGS) -mod=readonly ./cmd/tutoriald
@echo "--> installing exampled"
@go install $(BUILD_FLAGS) -mod=readonly ./cmd/exampled

init:
./scripts/init.sh
30 changes: 15 additions & 15 deletions tutorials/base/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ var DefaultNodeHome string
var AppConfigYAML []byte

var (
_ runtime.AppI = (*TutorialApp)(nil)
_ servertypes.Application = (*TutorialApp)(nil)
_ runtime.AppI = (*ExampleApp)(nil)
_ servertypes.Application = (*ExampleApp)(nil)
)

// TutorialApp extends an ABCI application, but with most of its parameters exported.
// ExampleApp extends an ABCI application, but with most of its parameters exported.
// They are exported for convenience in creating helper functions, as object
// capabilities aren't needed for testing.
type TutorialApp struct {
type ExampleApp struct {
*runtime.App
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
Expand All @@ -76,7 +76,7 @@ func init() {
panic(err)
}

DefaultNodeHome = filepath.Join(userHomeDir, ".tutoriald")
DefaultNodeHome = filepath.Join(userHomeDir, ".exampled")
}

// AppConfig returns the default app config.
Expand All @@ -92,17 +92,17 @@ func AppConfig() depinject.Config {
)
}

// NewTutorialApp returns a reference to an initialized tutorialApp.
func NewTutorialApp(
// NewExampleApp returns a reference to an initialized ExampleApp.
func NewExampleApp(
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) (*TutorialApp, error) {
) (*ExampleApp, error) {
var (
app = &TutorialApp{}
app = &ExampleApp{}
appBuilder *runtime.AppBuilder
)

Expand Down Expand Up @@ -149,13 +149,13 @@ func NewTutorialApp(
return app, nil
}

// LegacyAmino returns tutorialApp's amino codec.
func (app *TutorialApp) LegacyAmino() *codec.LegacyAmino {
// LegacyAmino returns ExampleApp's amino codec.
func (app *ExampleApp) LegacyAmino() *codec.LegacyAmino {
return app.legacyAmino
}

// GetKey returns the KVStoreKey for the provided store key.
func (app *TutorialApp) GetKey(storeKey string) *storetypes.KVStoreKey {
func (app *ExampleApp) GetKey(storeKey string) *storetypes.KVStoreKey {
sk := app.UnsafeFindStoreKey(storeKey)
kvStoreKey, ok := sk.(*storetypes.KVStoreKey)
if !ok {
Expand All @@ -164,7 +164,7 @@ func (app *TutorialApp) GetKey(storeKey string) *storetypes.KVStoreKey {
return kvStoreKey
}

func (app *TutorialApp) kvStoreKeys() map[string]*storetypes.KVStoreKey {
func (app *ExampleApp) kvStoreKeys() map[string]*storetypes.KVStoreKey {
keys := make(map[string]*storetypes.KVStoreKey)
for _, k := range app.GetStoreKeys() {
if kv, ok := k.(*storetypes.KVStoreKey); ok {
Expand All @@ -176,13 +176,13 @@ func (app *TutorialApp) kvStoreKeys() map[string]*storetypes.KVStoreKey {
}

// SimulationManager implements the SimulationApp interface
func (app *TutorialApp) SimulationManager() *module.SimulationManager {
func (app *ExampleApp) SimulationManager() *module.SimulationManager {
return app.sm
}

// RegisterAPIRoutes registers all application module routes with the provided
// API server.
func (app *TutorialApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
func (app *ExampleApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
app.App.RegisterAPIRoutes(apiSvr, apiConfig)
// register swagger API in app.go so that other applications can override easily
if err := server.RegisterSwaggerAPI(apiSvr.ClientCtx, apiSvr.Router, apiConfig.Swagger); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tutorials/base/app/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ modules:
- name: runtime
config:
"@type": cosmos.app.runtime.v1alpha1.Module
app_name: TutorialApp
app_name: ExampleApp
# During begin block slashing happens after distr.BeginBlocker so that
# there is nothing left over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant.
# NOTE: staking module is required if HistoricalEntries param > 0
Expand Down
4 changes: 2 additions & 2 deletions tutorials/base/app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// ExportAppStateAndValidators exports the state of the application for a genesis file.
func (app *TutorialApp) ExportAppStateAndValidators(
func (app *ExampleApp) ExportAppStateAndValidators(
forZeroHeight bool,
jailAllowedAddrs []string,
modulesToExport []string,
Expand Down Expand Up @@ -52,7 +52,7 @@ func (app *TutorialApp) ExportAppStateAndValidators(

// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature, which will be deprecated in favor of export at a block height
func (app *TutorialApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
func (app *ExampleApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

// check if there is a allowed address list
Expand Down
4 changes: 2 additions & 2 deletions tutorials/base/app/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
)

const (
CoinUnit = "tutorial"
CoinUnit = "example"

DefaultBondDenom = CoinUnit

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address.
Bech32PrefixAccAddr = "tutorial"
Bech32PrefixAccAddr = "example"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func txCommand() *cobra.Command {
// newApp is an appCreator
func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
baseappOptions := server.DefaultBaseappOptions(appOpts)
app, err := app.NewTutorialApp(logger, db, traceStore, true, appOpts, baseappOptions...)
app, err := app.NewExampleApp(logger, db, traceStore, true, appOpts, baseappOptions...)
if err != nil {
panic(err)
}
Expand All @@ -119,8 +119,8 @@ func appExport(
modulesToExport []string,
) (servertypes.ExportedApp, error) {
var (
tutorialApp *app.TutorialApp
err error
ExampleApp *app.ExampleApp
err error
)

// this check is necessary as we use the flag in x/upgrade.
Expand All @@ -140,20 +140,20 @@ func appExport(
appOpts = viperAppOpts

if height != -1 {
tutorialApp, err = app.NewTutorialApp(logger, db, traceStore, false, appOpts)
ExampleApp, err = app.NewExampleApp(logger, db, traceStore, false, appOpts)
if err != nil {
return servertypes.ExportedApp{}, err
}

if err := tutorialApp.LoadHeight(height); err != nil {
if err := ExampleApp.LoadHeight(height); err != nil {
return servertypes.ExportedApp{}, err
}
} else {
tutorialApp, err = app.NewTutorialApp(logger, db, traceStore, true, appOpts)
ExampleApp, err = app.NewExampleApp(logger, db, traceStore, true, appOpts)
if err != nil {
return servertypes.ExportedApp{}, err
}
}

return tutorialApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)
return ExampleApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/cosmos/sdk-tutorials/tutorials/base/app"
)

// NewRootCmd creates a new root command for tutoriald. It is called once in the
// NewRootCmd creates a new root command for exampled. It is called once in the
// main function.
func NewRootCmd() *cobra.Command {
var (
Expand Down Expand Up @@ -60,8 +60,8 @@ func NewRootCmd() *cobra.Command {
}

rootCmd := &cobra.Command{
Use: "tutoriald",
Short: "tutoriald - the tutorial chain app",
Use: "exampled",
Short: "exampled - the example chain app",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
// set the default command outputs
cmd.SetOut(cmd.OutOrStdout())
Expand Down Expand Up @@ -101,7 +101,7 @@ func NewRootCmd() *cobra.Command {

// overwrite the minimum gas price from the app configuration
srvCfg := serverconfig.DefaultConfig()
srvCfg.MinGasPrices = "0tutorial"
srvCfg.MinGasPrices = "0example"

// overwrite the block timeout
cmtCfg := cmtcfg.DefaultConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/cosmos/sdk-tutorials/tutorials/base/app"
"github.com/cosmos/sdk-tutorials/tutorials/base/app/params"
"github.com/cosmos/sdk-tutorials/tutorials/base/cmd/tutoriald/cmd"
"github.com/cosmos/sdk-tutorials/tutorials/base/cmd/exampled/cmd"
)

func main() {
Expand Down
24 changes: 12 additions & 12 deletions tutorials/base/scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env bash

rm -r ~/.tutoriald || true
tutorialD_BIN=$(which tutoriald)
# configure tutoriald
$tutorialD_BIN config set client chain-id demo
$tutorialD_BIN config set client keyring-backend test
$tutorialD_BIN keys add alice
$tutorialD_BIN keys add bob
$tutorialD_BIN init test --chain-id demo --default-denom tutorial
rm -r ~/.exampled || true
exampled_BIN=$(which exampled)
# configure exampled
$exampled_BIN config set client chain-id demo
$exampled_BIN config set client keyring-backend test
$exampled_BIN keys add alice
$exampled_BIN keys add bob
$exampled_BIN init test --chain-id demo --default-denom example
# update genesis
$tutorialD_BIN genesis add-genesis-account alice 10000000tutorial --keyring-backend test
$tutorialD_BIN genesis add-genesis-account bob 1000tutorial --keyring-backend test
$exampled_BIN genesis add-genesis-account alice 10000000example --keyring-backend test
$exampled_BIN genesis add-genesis-account bob 1000example --keyring-backend test
# create default validator
$tutorialD_BIN genesis gentx alice 1000000tutorial --chain-id demo
$tutorialD_BIN genesis collect-gentxs
$exampled_BIN genesis gentx alice 1000000example --chain-id demo
$exampled_BIN genesis collect-gentxs
40 changes: 20 additions & 20 deletions tutorials/nameservice/base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

# ********** process linker flags **********

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=tutorial \
-X github.com/cosmos/cosmos-sdk/version.AppName=tutoriald \
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=example \
-X github.com/cosmos/cosmos-sdk/version.AppName=exampled \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
Expand Down Expand Up @@ -88,12 +88,12 @@ all: lint test install
###############################################################################

install: enforce-go-version
@echo "Installing tutoriald..."
go install -mod=readonly $(BUILD_FLAGS) ./cmd/tutoriald
@echo "Installing exampled..."
go install -mod=readonly $(BUILD_FLAGS) ./cmd/exampled

build: enforce-go-version
@echo "Building tutoriald..."
go build $(BUILD_FLAGS) -o $(BUILDDIR)/ ./cmd/tutoriald
@echo "Building exampled..."
go build $(BUILD_FLAGS) -o $(BUILDDIR)/ ./cmd/exampled

enforce-go-version:
@echo "Go version: $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION)"
Expand Down Expand Up @@ -137,20 +137,20 @@ format:
###############################################################################

start-localnet: build
rm -rf ~/.tutoriald
./build/tutoriald init liveness --chain-id cosmos-1 --default-denom uatom
./build/tutoriald config set client chain-id cosmos-1
./build/tutoriald config set client keyring-backend test
./build/tutoriald keys add val1
./build/tutoriald keys add alice
./build/tutoriald keys add bob
./build/tutoriald genesis add-genesis-account val1 10000000000000000000000000uatom
./build/tutoriald genesis add-genesis-account alice 1000000000000000000uatom
./build/tutoriald genesis add-genesis-account bob 1000000000000000000uatom
./build/tutoriald genesis gentx val1 1000000000uatom --chain-id cosmos-1
./build/tutoriald genesis collect-gentxs
sed -i.bak'' 's/minimum-gas-prices = ""/minimum-gas-prices = "0.025uatom"/' ~/.tutoriald/config/app.toml
./build/tutoriald start --val-key val1
rm -rf ~/.exampled
./build/exampled init liveness --chain-id cosmos-1 --default-denom uatom
./build/exampled config set client chain-id cosmos-1
./build/exampled config set client keyring-backend test
./build/exampled keys add val1
./build/exampled keys add alice
./build/exampled keys add bob
./build/exampled genesis add-genesis-account val1 10000000000000000000000000uatom
./build/exampled genesis add-genesis-account alice 1000000000000000000uatom
./build/exampled genesis add-genesis-account bob 1000000000000000000uatom
./build/exampled genesis gentx val1 1000000000uatom --chain-id cosmos-1
./build/exampled genesis collect-gentxs
sed -i.bak'' 's/minimum-gas-prices = ""/minimum-gas-prices = "0.025uatom"/' ~/.exampled/config/app.toml
./build/exampled start --val-key val1
###############################################################################
### Tests & Simulation ###
###############################################################################
Expand Down
Loading

0 comments on commit b033428

Please sign in to comment.