From 9d9001ab6217503c817e94dbb0fb995623034b92 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 29 Mar 2018 06:33:45 +0200 Subject: [PATCH 1/3] renamed staking to simplestake --- Gopkg.lock | 2 +- examples/basecoin/app/app.go | 12 ++++++------ examples/basecoin/cmd/basecli/main.go | 9 +++++---- x/{staking => simplestake}/commands/commands.go | 6 +++--- x/{staking => simplestake}/errors.go | 0 x/{staking => simplestake}/handler.go | 0 x/{staking => simplestake}/keeper.go | 2 ++ x/{staking => simplestake}/keeper_test.go | 0 x/{staking => simplestake}/msgs.go | 4 ++-- x/{staking => simplestake}/msgs_test.go | 0 x/{staking => simplestake}/types.go | 0 11 files changed, 19 insertions(+), 16 deletions(-) rename x/{staking => simplestake}/commands/commands.go (92%) rename x/{staking => simplestake}/errors.go (100%) rename x/{staking => simplestake}/handler.go (100%) rename x/{staking => simplestake}/keeper.go (98%) rename x/{staking => simplestake}/keeper_test.go (100%) rename x/{staking => simplestake}/msgs.go (97%) rename x/{staking => simplestake}/msgs_test.go (100%) rename x/{staking => simplestake}/types.go (100%) diff --git a/Gopkg.lock b/Gopkg.lock index 267acf32b..377390297 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -458,6 +458,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "cce90fda84a63ae5b41b40f0edc357eec4020d17fdd61585960ad537418749ea" + inputs-digest = "ed1f3f7f1728cd02945f90ca780e9bdc982573a36a5cc8d7e9f19fb40ba2ca19" solver-name = "gps-cdcl" solver-version = 1 diff --git a/examples/basecoin/app/app.go b/examples/basecoin/app/app.go index 3178b2057..871e3c18e 100644 --- a/examples/basecoin/app/app.go +++ b/examples/basecoin/app/app.go @@ -15,7 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/ibc" - "github.com/cosmos/cosmos-sdk/x/staking" + simplestake "github.com/cosmos/cosmos-sdk/x/simplestake" "github.com/cosmos/cosmos-sdk/examples/basecoin/types" "github.com/cosmos/cosmos-sdk/examples/basecoin/x/cool" @@ -47,7 +47,7 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp { cdc: MakeCodec(), capKeyMainStore: sdk.NewKVStoreKey("main"), capKeyIBCStore: sdk.NewKVStoreKey("ibc"), - capKeyStakingStore: sdk.NewKVStoreKey("staking"), + capKeyStakingStore: sdk.NewKVStoreKey("stake"), } // define the accountMapper @@ -60,13 +60,13 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp { coinKeeper := bank.NewCoinKeeper(app.accountMapper) coolKeeper := cool.NewKeeper(app.capKeyMainStore, coinKeeper) ibcMapper := ibc.NewIBCMapper(app.cdc, app.capKeyIBCStore) - stakeKeeper := staking.NewKeeper(app.capKeyStakingStore, coinKeeper) + stakeKeeper := simplestake.NewKeeper(app.capKeyStakingStore, coinKeeper) app.Router(). AddRoute("bank", bank.NewHandler(coinKeeper), nil). AddRoute("cool", cool.NewHandler(coolKeeper), coolKeeper.InitGenesis). AddRoute("sketchy", sketchy.NewHandler(), nil). AddRoute("ibc", ibc.NewHandler(ibcMapper, coinKeeper), nil). - AddRoute("staking", staking.NewHandler(stakeKeeper), nil) + AddRoute("simplestake", simplestake.NewHandler(stakeKeeper), nil) // initialize BaseApp app.SetTxDecoder(app.txDecoder) @@ -100,8 +100,8 @@ func MakeCodec() *wire.Codec { oldwire.ConcreteType{cool.SetTrendMsg{}, msgTypeSetTrend}, oldwire.ConcreteType{ibc.IBCTransferMsg{}, msgTypeIBCTransferMsg}, oldwire.ConcreteType{ibc.IBCReceiveMsg{}, msgTypeIBCReceiveMsg}, - oldwire.ConcreteType{staking.BondMsg{}, msgTypeBondMsg}, - oldwire.ConcreteType{staking.UnbondMsg{}, msgTypeUnbondMsg}, + oldwire.ConcreteType{simplestake.BondMsg{}, msgTypeBondMsg}, + oldwire.ConcreteType{simplestake.UnbondMsg{}, msgTypeUnbondMsg}, ) const accTypeApp = 0x1 diff --git a/examples/basecoin/cmd/basecli/main.go b/examples/basecoin/cmd/basecli/main.go index 6fabc612c..1c4b5833b 100644 --- a/examples/basecoin/cmd/basecli/main.go +++ b/examples/basecoin/cmd/basecli/main.go @@ -2,9 +2,10 @@ package main import ( "errors" - "github.com/spf13/cobra" "os" + "github.com/spf13/cobra" + "github.com/tendermint/tmlibs/cli" "github.com/cosmos/cosmos-sdk/client" @@ -18,7 +19,7 @@ import ( authcmd "github.com/cosmos/cosmos-sdk/x/auth/commands" bankcmd "github.com/cosmos/cosmos-sdk/x/bank/commands" ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/commands" - stakingcmd "github.com/cosmos/cosmos-sdk/x/staking/commands" + simplestakingcmd "github.com/cosmos/cosmos-sdk/x/simplestake/commands" "github.com/cosmos/cosmos-sdk/examples/basecoin/app" "github.com/cosmos/cosmos-sdk/examples/basecoin/types" @@ -77,11 +78,11 @@ func main() { basecliCmd.AddCommand( client.PostCommands( ibccmd.IBCRelayCmd(cdc), - stakingcmd.BondTxCmd(cdc), + simplestakingcmd.BondTxCmd(cdc), )...) basecliCmd.AddCommand( client.PostCommands( - stakingcmd.UnbondTxCmd(cdc), + simplestakingcmd.UnbondTxCmd(cdc), )...) // add proxy, version and key info diff --git a/x/staking/commands/commands.go b/x/simplestake/commands/commands.go similarity index 92% rename from x/staking/commands/commands.go rename to x/simplestake/commands/commands.go index 79520ebef..0bb9b5649 100644 --- a/x/staking/commands/commands.go +++ b/x/simplestake/commands/commands.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/builder" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/wire" - "github.com/cosmos/cosmos-sdk/x/staking" + simplestake "github.com/cosmos/cosmos-sdk/x/simplestake" ) const ( @@ -76,7 +76,7 @@ func (co commander) bondTxCmd(cmd *cobra.Command, args []string) error { var pubKeyEd crypto.PubKeyEd25519 copy(pubKeyEd[:], rawPubKey) - msg := staking.NewBondMsg(from, stake, pubKeyEd.Wrap()) + msg := simplestake.NewBondMsg(from, stake, pubKeyEd.Wrap()) return co.sendMsg(msg) } @@ -87,7 +87,7 @@ func (co commander) unbondTxCmd(cmd *cobra.Command, args []string) error { return err } - msg := staking.NewUnbondMsg(from) + msg := simplestake.NewUnbondMsg(from) return co.sendMsg(msg) } diff --git a/x/staking/errors.go b/x/simplestake/errors.go similarity index 100% rename from x/staking/errors.go rename to x/simplestake/errors.go diff --git a/x/staking/handler.go b/x/simplestake/handler.go similarity index 100% rename from x/staking/handler.go rename to x/simplestake/handler.go diff --git a/x/staking/keeper.go b/x/simplestake/keeper.go similarity index 98% rename from x/staking/keeper.go rename to x/simplestake/keeper.go index 615f94fae..d9fcf713c 100644 --- a/x/staking/keeper.go +++ b/x/simplestake/keeper.go @@ -10,6 +10,8 @@ import ( const stakingToken = "steak" +const moduleName = "simplestake" + type Keeper struct { ck bank.CoinKeeper diff --git a/x/staking/keeper_test.go b/x/simplestake/keeper_test.go similarity index 100% rename from x/staking/keeper_test.go rename to x/simplestake/keeper_test.go diff --git a/x/staking/msgs.go b/x/simplestake/msgs.go similarity index 97% rename from x/staking/msgs.go rename to x/simplestake/msgs.go index 9bbf425c7..23a5de25c 100644 --- a/x/staking/msgs.go +++ b/x/simplestake/msgs.go @@ -26,7 +26,7 @@ func NewBondMsg(addr sdk.Address, stake sdk.Coin, pubKey crypto.PubKey) BondMsg } func (msg BondMsg) Type() string { - return "staking" + return moduleName } func (msg BondMsg) ValidateBasic() sdk.Error { @@ -71,7 +71,7 @@ func NewUnbondMsg(addr sdk.Address) UnbondMsg { } func (msg UnbondMsg) Type() string { - return "staking" + return moduleName } func (msg UnbondMsg) ValidateBasic() sdk.Error { diff --git a/x/staking/msgs_test.go b/x/simplestake/msgs_test.go similarity index 100% rename from x/staking/msgs_test.go rename to x/simplestake/msgs_test.go diff --git a/x/staking/types.go b/x/simplestake/types.go similarity index 100% rename from x/staking/types.go rename to x/simplestake/types.go From 81d542d4384ce1e94906d1f111eefe0234579cc6 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 29 Mar 2018 06:36:40 +0200 Subject: [PATCH 2/3] updated changelog.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01d342ef6..362e84e00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ FEATURES * [types] StdFee, and StdTx takes the StdFee * [specs] Progression of MVPs for IBC * [x/ibc] Initial shell of IBC functionality (no proofs) -* [x/staking] Simple staking module with bonding/unbonding +* [x/simplestake] Simple staking module with bonding/unbonding IMPROVEMENTS From bc1d9e6f93882661ec96d4de242d3bcdae86004f Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 29 Mar 2018 06:40:06 +0200 Subject: [PATCH 3/3] fixed package name --- examples/basecoin/app/app.go | 2 +- x/simplestake/commands/commands.go | 2 +- x/simplestake/errors.go | 4 ++-- x/simplestake/handler.go | 4 ++-- x/simplestake/keeper.go | 2 +- x/simplestake/keeper_test.go | 2 +- x/simplestake/msgs.go | 2 +- x/simplestake/msgs_test.go | 2 +- x/simplestake/types.go | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/basecoin/app/app.go b/examples/basecoin/app/app.go index 871e3c18e..e8d1a0011 100644 --- a/examples/basecoin/app/app.go +++ b/examples/basecoin/app/app.go @@ -15,7 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/ibc" - simplestake "github.com/cosmos/cosmos-sdk/x/simplestake" + "github.com/cosmos/cosmos-sdk/x/simplestake" "github.com/cosmos/cosmos-sdk/examples/basecoin/types" "github.com/cosmos/cosmos-sdk/examples/basecoin/x/cool" diff --git a/x/simplestake/commands/commands.go b/x/simplestake/commands/commands.go index 0bb9b5649..19d6cddbf 100644 --- a/x/simplestake/commands/commands.go +++ b/x/simplestake/commands/commands.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/builder" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/wire" - simplestake "github.com/cosmos/cosmos-sdk/x/simplestake" + "github.com/cosmos/cosmos-sdk/x/simplestake" ) const ( diff --git a/x/simplestake/errors.go b/x/simplestake/errors.go index 6c3e4d34b..f69ffcbeb 100644 --- a/x/simplestake/errors.go +++ b/x/simplestake/errors.go @@ -1,11 +1,11 @@ -package staking +package simplestake import ( sdk "github.com/cosmos/cosmos-sdk/types" ) const ( - // Staking errors reserve 300 - 399. + // simplestake errors reserve 300 - 399. CodeEmptyValidator sdk.CodeType = 300 CodeInvalidUnbond sdk.CodeType = 301 CodeEmptyStake sdk.CodeType = 302 diff --git a/x/simplestake/handler.go b/x/simplestake/handler.go index b405490b1..31e5a7d24 100644 --- a/x/simplestake/handler.go +++ b/x/simplestake/handler.go @@ -1,4 +1,4 @@ -package staking +package simplestake import ( abci "github.com/tendermint/abci/types" @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// NewHandler returns a handler for "bank" type messages. +// NewHandler returns a handler for "simplestake" type messages. func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { switch msg := msg.(type) { diff --git a/x/simplestake/keeper.go b/x/simplestake/keeper.go index d9fcf713c..e5892f3e2 100644 --- a/x/simplestake/keeper.go +++ b/x/simplestake/keeper.go @@ -1,4 +1,4 @@ -package staking +package simplestake import ( crypto "github.com/tendermint/go-crypto" diff --git a/x/simplestake/keeper_test.go b/x/simplestake/keeper_test.go index 120365891..9f2615590 100644 --- a/x/simplestake/keeper_test.go +++ b/x/simplestake/keeper_test.go @@ -1,4 +1,4 @@ -package staking +package simplestake import ( "fmt" diff --git a/x/simplestake/msgs.go b/x/simplestake/msgs.go index 23a5de25c..2ab0e1bad 100644 --- a/x/simplestake/msgs.go +++ b/x/simplestake/msgs.go @@ -1,4 +1,4 @@ -package staking +package simplestake import ( "encoding/json" diff --git a/x/simplestake/msgs_test.go b/x/simplestake/msgs_test.go index 7c9dd228c..49a8feec5 100644 --- a/x/simplestake/msgs_test.go +++ b/x/simplestake/msgs_test.go @@ -1,4 +1,4 @@ -package staking +package simplestake import ( "testing" diff --git a/x/simplestake/types.go b/x/simplestake/types.go index 9f1d045bc..3371fc977 100644 --- a/x/simplestake/types.go +++ b/x/simplestake/types.go @@ -1,4 +1,4 @@ -package staking +package simplestake import crypto "github.com/tendermint/go-crypto"