Rename stake/ to staking/ (#3280)
This commit is contained in:
committed by
Jack Zampolin
parent
df567616a9
commit
78a21353da
@@ -23,9 +23,9 @@ import (
|
||||
sl "github.com/cosmos/cosmos-sdk/x/slashing"
|
||||
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
|
||||
slashing "github.com/cosmos/cosmos-sdk/x/slashing/client/rest"
|
||||
st "github.com/cosmos/cosmos-sdk/x/stake"
|
||||
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
|
||||
stake "github.com/cosmos/cosmos-sdk/x/stake/client/rest"
|
||||
st "github.com/cosmos/cosmos-sdk/x/staking"
|
||||
stakingcmd "github.com/cosmos/cosmos-sdk/x/staking/client/cli"
|
||||
staking "github.com/cosmos/cosmos-sdk/x/staking/client/rest"
|
||||
)
|
||||
|
||||
// rootCmd is the entry point for this binary
|
||||
@@ -65,20 +65,20 @@ func main() {
|
||||
|
||||
// add query/post commands (custom to binary)
|
||||
rootCmd.AddCommand(
|
||||
stakecmd.GetCmdQueryValidator(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryValidators(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryValidatorUnbondingDelegations(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryValidatorRedelegations(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryDelegation(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryDelegations(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryPool(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryParams(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryUnbondingDelegation(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryUnbondingDelegations(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryRedelegation(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryRedelegations(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryValidator(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryValidators(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryValidatorUnbondingDelegations(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryValidatorRedelegations(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryDelegation(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryDelegations(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryPool(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryParams(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryUnbondingDelegation(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryUnbondingDelegations(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryRedelegation(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryRedelegations(st.StoreKey, cdc),
|
||||
slashingcmd.GetCmdQuerySigningInfo(sl.StoreKey, cdc),
|
||||
stakecmd.GetCmdQueryValidatorDelegations(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdQueryValidatorDelegations(st.StoreKey, cdc),
|
||||
authcmd.GetAccountCmd(at.StoreKey, cdc),
|
||||
)
|
||||
|
||||
@@ -86,11 +86,11 @@ func main() {
|
||||
bankcmd.SendTxCmd(cdc),
|
||||
ibccmd.IBCTransferCmd(cdc),
|
||||
ibccmd.IBCRelayCmd(cdc),
|
||||
stakecmd.GetCmdCreateValidator(cdc),
|
||||
stakecmd.GetCmdEditValidator(cdc),
|
||||
stakecmd.GetCmdDelegate(cdc),
|
||||
stakecmd.GetCmdUnbond(st.StoreKey, cdc),
|
||||
stakecmd.GetCmdRedelegate(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdCreateValidator(cdc),
|
||||
stakingcmd.GetCmdEditValidator(cdc),
|
||||
stakingcmd.GetCmdDelegate(cdc),
|
||||
stakingcmd.GetCmdUnbond(st.StoreKey, cdc),
|
||||
stakingcmd.GetCmdRedelegate(st.StoreKey, cdc),
|
||||
slashingcmd.GetCmdUnjail(cdc),
|
||||
)
|
||||
|
||||
@@ -118,6 +118,6 @@ func registerRoutes(rs *lcd.RestServer) {
|
||||
tx.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc)
|
||||
auth.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, at.StoreKey)
|
||||
bank.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
|
||||
stake.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
|
||||
staking.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
|
||||
slashing.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/types"
|
||||
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/cool"
|
||||
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/pow"
|
||||
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestake"
|
||||
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestaking"
|
||||
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/sketchy"
|
||||
)
|
||||
|
||||
@@ -57,7 +57,7 @@ type DemocoinApp struct {
|
||||
coolKeeper cool.Keeper
|
||||
powKeeper pow.Keeper
|
||||
ibcMapper ibc.Mapper
|
||||
stakeKeeper simplestake.Keeper
|
||||
stakingKeeper simplestaking.Keeper
|
||||
|
||||
// Manage getting and setting accounts
|
||||
accountKeeper auth.AccountKeeper
|
||||
@@ -76,7 +76,7 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
||||
capKeyAccountStore: sdk.NewKVStoreKey(auth.StoreKey),
|
||||
capKeyPowStore: sdk.NewKVStoreKey("pow"),
|
||||
capKeyIBCStore: sdk.NewKVStoreKey("ibc"),
|
||||
capKeyStakingStore: sdk.NewKVStoreKey(stake.StoreKey),
|
||||
capKeyStakingStore: sdk.NewKVStoreKey(staking.StoreKey),
|
||||
keyParams: sdk.NewKVStoreKey("params"),
|
||||
tkeyParams: sdk.NewTransientStoreKey("transient_params"),
|
||||
}
|
||||
@@ -96,14 +96,14 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
||||
app.coolKeeper = cool.NewKeeper(app.capKeyMainStore, app.bankKeeper, cool.DefaultCodespace)
|
||||
app.powKeeper = pow.NewKeeper(app.capKeyPowStore, pow.NewConfig("pow", int64(1)), app.bankKeeper, pow.DefaultCodespace)
|
||||
app.ibcMapper = ibc.NewMapper(app.cdc, app.capKeyIBCStore, ibc.DefaultCodespace)
|
||||
app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.bankKeeper, simplestake.DefaultCodespace)
|
||||
app.stakingKeeper = simplestaking.NewKeeper(app.capKeyStakingStore, app.bankKeeper, simplestaking.DefaultCodespace)
|
||||
app.Router().
|
||||
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
|
||||
AddRoute("cool", cool.NewHandler(app.coolKeeper)).
|
||||
AddRoute("pow", app.powKeeper.Handler).
|
||||
AddRoute("sketchy", sketchy.NewHandler()).
|
||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
|
||||
AddRoute("simplestake", simplestake.NewHandler(app.stakeKeeper))
|
||||
AddRoute("simplestaking", simplestaking.NewHandler(app.stakingKeeper))
|
||||
|
||||
// Initialize BaseApp.
|
||||
app.SetInitChainer(app.initChainerFn(app.coolKeeper, app.powKeeper))
|
||||
@@ -128,7 +128,7 @@ func MakeCodec() *codec.Codec {
|
||||
pow.RegisterCodec(cdc)
|
||||
bank.RegisterCodec(cdc)
|
||||
ibc.RegisterCodec(cdc)
|
||||
simplestake.RegisterCodec(cdc)
|
||||
simplestaking.RegisterCodec(cdc)
|
||||
|
||||
// Register AppAccount
|
||||
cdc.RegisterInterface((*auth.Account)(nil), nil)
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/app"
|
||||
coolcmd "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/cool/client/cli"
|
||||
powcmd "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/pow/client/cli"
|
||||
simplestakingcmd "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestake/client/cli"
|
||||
simplestakingcmd "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestaking/client/cli"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package simplestake
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// Register concrete types on codec codec
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterConcrete(MsgBond{}, "simplestake/BondMsg", nil)
|
||||
cdc.RegisterConcrete(MsgUnbond{}, "simplestake/UnbondMsg", nil)
|
||||
}
|
||||
+8
-8
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestake"
|
||||
"github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestaking"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
flagStake = "stake"
|
||||
flagStake = "staking"
|
||||
flagValidator = "validator"
|
||||
)
|
||||
|
||||
@@ -37,9 +37,9 @@ func BondTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
stakeString := viper.GetString(flagStake)
|
||||
if len(stakeString) == 0 {
|
||||
return fmt.Errorf("specify coins to bond with --stake")
|
||||
stakingString := viper.GetString(flagStake)
|
||||
if len(stakingString) == 0 {
|
||||
return fmt.Errorf("specify coins to bond with --staking")
|
||||
}
|
||||
|
||||
valString := viper.GetString(flagValidator)
|
||||
@@ -47,7 +47,7 @@ func BondTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
return fmt.Errorf("specify pubkey to bond to with --validator")
|
||||
}
|
||||
|
||||
stake, err := sdk.ParseCoin(stakeString)
|
||||
staking, err := sdk.ParseCoin(stakingString)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func BondTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
var pubKeyEd ed25519.PubKeyEd25519
|
||||
copy(pubKeyEd[:], rawPubKey)
|
||||
|
||||
msg := simplestake.NewMsgBond(from, stake, pubKeyEd)
|
||||
msg := simplestaking.NewMsgBond(from, staking, pubKeyEd)
|
||||
|
||||
// Build and sign the transaction, then broadcast to a Tendermint
|
||||
// node.
|
||||
@@ -89,7 +89,7 @@ func UnbondTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := simplestake.NewMsgUnbond(from)
|
||||
msg := simplestaking.NewMsgUnbond(from)
|
||||
|
||||
// Build and sign the transaction, then broadcast to a Tendermint
|
||||
// node.
|
||||
@@ -0,0 +1,11 @@
|
||||
package simplestaking
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// Register concrete types on codec codec
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterConcrete(MsgBond{}, "simplestaking/BondMsg", nil)
|
||||
cdc.RegisterConcrete(MsgUnbond{}, "simplestaking/UnbondMsg", nil)
|
||||
}
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
package simplestake
|
||||
package simplestaking
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// simple stake errors reserve 300 ~ 399.
|
||||
// simple staking errors reserve 300 ~ 399.
|
||||
const (
|
||||
DefaultCodespace sdk.CodespaceType = moduleName
|
||||
|
||||
// simplestake errors reserve 300 - 399.
|
||||
// simplestaking errors reserve 300 - 399.
|
||||
CodeEmptyValidator sdk.CodeType = 300
|
||||
CodeInvalidUnbond sdk.CodeType = 301
|
||||
CodeEmptyStake sdk.CodeType = 302
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package simplestake
|
||||
package simplestaking
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// NewHandler returns a handler for "simplestake" type messages.
|
||||
// NewHandler returns a handler for "simplestaking" type messages.
|
||||
func NewHandler(k Keeper) sdk.Handler {
|
||||
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
|
||||
switch msg.(type) {
|
||||
+12
-12
@@ -1,4 +1,4 @@
|
||||
package simplestake
|
||||
package simplestaking
|
||||
|
||||
import (
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
|
||||
stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
const moduleName = "simplestake"
|
||||
const moduleName = "simplestaking"
|
||||
|
||||
// simple stake keeper
|
||||
// simple staking keeper
|
||||
type Keeper struct {
|
||||
ck bank.Keeper
|
||||
|
||||
@@ -60,12 +60,12 @@ func (k Keeper) deleteBondInfo(ctx sdk.Context, addr sdk.AccAddress) {
|
||||
}
|
||||
|
||||
// register a bond with the keeper
|
||||
func (k Keeper) Bond(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey, stake sdk.Coin) (int64, sdk.Error) {
|
||||
if stake.Denom != stakeTypes.DefaultBondDenom {
|
||||
func (k Keeper) Bond(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey, staking sdk.Coin) (int64, sdk.Error) {
|
||||
if staking.Denom != stakingTypes.DefaultBondDenom {
|
||||
return 0, ErrIncorrectStakingToken(k.codespace)
|
||||
}
|
||||
|
||||
_, _, err := k.ck.SubtractCoins(ctx, addr, []sdk.Coin{stake})
|
||||
_, _, err := k.ck.SubtractCoins(ctx, addr, []sdk.Coin{staking})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (k Keeper) Bond(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey,
|
||||
}
|
||||
}
|
||||
|
||||
bi.Power = bi.Power + stake.Amount.Int64()
|
||||
bi.Power = bi.Power + staking.Amount.Int64()
|
||||
|
||||
k.setBondInfo(ctx, addr, bi)
|
||||
return bi.Power, nil
|
||||
@@ -92,7 +92,7 @@ func (k Keeper) Unbond(ctx sdk.Context, addr sdk.AccAddress) (crypto.PubKey, int
|
||||
}
|
||||
k.deleteBondInfo(ctx, addr)
|
||||
|
||||
returnedBond := sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, bi.Power)
|
||||
returnedBond := sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, bi.Power)
|
||||
|
||||
_, _, err := k.ck.AddCoins(ctx, addr, []sdk.Coin{returnedBond})
|
||||
if err != nil {
|
||||
@@ -104,8 +104,8 @@ func (k Keeper) Unbond(ctx sdk.Context, addr sdk.AccAddress) (crypto.PubKey, int
|
||||
|
||||
// FOR TESTING PURPOSES -------------------------------------------------
|
||||
|
||||
func (k Keeper) bondWithoutCoins(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey, stake sdk.Coin) (int64, sdk.Error) {
|
||||
if stake.Denom != stakeTypes.DefaultBondDenom {
|
||||
func (k Keeper) bondWithoutCoins(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey, staking sdk.Coin) (int64, sdk.Error) {
|
||||
if staking.Denom != stakingTypes.DefaultBondDenom {
|
||||
return 0, ErrIncorrectStakingToken(k.codespace)
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func (k Keeper) bondWithoutCoins(ctx sdk.Context, addr sdk.AccAddress, pubKey cr
|
||||
}
|
||||
}
|
||||
|
||||
bi.Power = bi.Power + stake.Amount.Int64()
|
||||
bi.Power = bi.Power + staking.Amount.Int64()
|
||||
|
||||
k.setBondInfo(ctx, addr, bi)
|
||||
return bi.Power, nil
|
||||
+12
-12
@@ -1,4 +1,4 @@
|
||||
package simplestake
|
||||
package simplestaking
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
staketypes "github.com/cosmos/cosmos-sdk/x/stake/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
type testInput struct {
|
||||
@@ -55,10 +55,10 @@ func TestKeeperGetSet(t *testing.T) {
|
||||
input := setupTestInput()
|
||||
ctx := input.ctx
|
||||
|
||||
stakeKeeper := NewKeeper(input.capKey, input.bk, DefaultCodespace)
|
||||
stakingKeeper := NewKeeper(input.capKey, input.bk, DefaultCodespace)
|
||||
addr := sdk.AccAddress([]byte("some-address"))
|
||||
|
||||
bi := stakeKeeper.getBondInfo(ctx, addr)
|
||||
bi := stakingKeeper.getBondInfo(ctx, addr)
|
||||
require.Equal(t, bi, bondInfo{})
|
||||
|
||||
privKey := ed25519.GenPrivKey()
|
||||
@@ -68,9 +68,9 @@ func TestKeeperGetSet(t *testing.T) {
|
||||
Power: int64(10),
|
||||
}
|
||||
fmt.Printf("Pubkey: %v\n", privKey.PubKey())
|
||||
stakeKeeper.setBondInfo(ctx, addr, bi)
|
||||
stakingKeeper.setBondInfo(ctx, addr, bi)
|
||||
|
||||
savedBi := stakeKeeper.getBondInfo(ctx, addr)
|
||||
savedBi := stakingKeeper.getBondInfo(ctx, addr)
|
||||
require.NotNil(t, savedBi)
|
||||
fmt.Printf("Bond Info: %v\n", savedBi)
|
||||
require.Equal(t, int64(10), savedBi.Power)
|
||||
@@ -80,25 +80,25 @@ func TestBonding(t *testing.T) {
|
||||
input := setupTestInput()
|
||||
ctx := input.ctx
|
||||
|
||||
stakeKeeper := NewKeeper(input.capKey, input.bk, DefaultCodespace)
|
||||
stakingKeeper := NewKeeper(input.capKey, input.bk, DefaultCodespace)
|
||||
addr := sdk.AccAddress([]byte("some-address"))
|
||||
privKey := ed25519.GenPrivKey()
|
||||
pubKey := privKey.PubKey()
|
||||
|
||||
_, _, err := stakeKeeper.unbondWithoutCoins(ctx, addr)
|
||||
_, _, err := stakingKeeper.unbondWithoutCoins(ctx, addr)
|
||||
require.Equal(t, err, ErrInvalidUnbond(DefaultCodespace))
|
||||
|
||||
_, err = stakeKeeper.bondWithoutCoins(ctx, addr, pubKey, sdk.NewInt64Coin(staketypes.DefaultBondDenom, 10))
|
||||
_, err = stakingKeeper.bondWithoutCoins(ctx, addr, pubKey, sdk.NewInt64Coin(stakingtypes.DefaultBondDenom, 10))
|
||||
require.Nil(t, err)
|
||||
|
||||
power, err := stakeKeeper.bondWithoutCoins(ctx, addr, pubKey, sdk.NewInt64Coin(staketypes.DefaultBondDenom, 10))
|
||||
power, err := stakingKeeper.bondWithoutCoins(ctx, addr, pubKey, sdk.NewInt64Coin(stakingtypes.DefaultBondDenom, 10))
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, int64(20), power)
|
||||
|
||||
pk, _, err := stakeKeeper.unbondWithoutCoins(ctx, addr)
|
||||
pk, _, err := stakingKeeper.unbondWithoutCoins(ctx, addr)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, pubKey, pk)
|
||||
|
||||
_, _, err = stakeKeeper.unbondWithoutCoins(ctx, addr)
|
||||
_, _, err = stakingKeeper.unbondWithoutCoins(ctx, addr)
|
||||
require.Equal(t, err, ErrInvalidUnbond(DefaultCodespace))
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package simplestake
|
||||
package simplestaking
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@@ -26,7 +26,7 @@ func NewMsgBond(addr sdk.AccAddress, stake sdk.Coin, pubKey crypto.PubKey) MsgBo
|
||||
}
|
||||
|
||||
//nolint
|
||||
func (msg MsgBond) Route() string { return moduleName } //TODO update "stake/createvalidator"
|
||||
func (msg MsgBond) Route() string { return moduleName } //TODO update "staking/createvalidator"
|
||||
func (msg MsgBond) Type() string { return "bond" }
|
||||
func (msg MsgBond) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Address} }
|
||||
|
||||
@@ -66,7 +66,7 @@ func NewMsgUnbond(addr sdk.AccAddress) MsgUnbond {
|
||||
}
|
||||
|
||||
//nolint
|
||||
func (msg MsgUnbond) Route() string { return moduleName } //TODO update "stake/createvalidator"
|
||||
func (msg MsgUnbond) Route() string { return moduleName } //TODO update "staking/createvalidator"
|
||||
func (msg MsgUnbond) Type() string { return "unbond" }
|
||||
func (msg MsgUnbond) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Address} }
|
||||
func (msg MsgUnbond) ValidateBasic() sdk.Error { return nil }
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package simplestake
|
||||
package simplestaking
|
||||
|
||||
import (
|
||||
"testing"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package simplestake
|
||||
package simplestaking
|
||||
|
||||
import "github.com/tendermint/tendermint/crypto"
|
||||
|
||||
@@ -33,7 +33,7 @@ gaiacli keys add validator
|
||||
|
||||
# Add that key into the genesis.app_state.accounts array in the genesis file
|
||||
# NOTE: this command lets you set the number of coins. Make sure this account has some coins
|
||||
# with the genesis.app_state.stake.params.bond_denom denom, the default is stake
|
||||
# with the genesis.app_state.staking.params.bond_denom denom, the default is staking
|
||||
gaiad add-genesis-account $(gaiacli keys show validator -a) 1000stake,1000validatortoken
|
||||
|
||||
# Generate the transaction that creates your validator
|
||||
|
||||
+16
-16
@@ -221,7 +221,7 @@ The action tag always equals the message type returned by the `Type()` function
|
||||
You can find a list of available `tags` on each of the SDK modules:
|
||||
|
||||
- [Common tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/types/tags.go#L57-L63)
|
||||
- [Staking tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/stake/tags/tags.go#L8-L24)
|
||||
- [Staking tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/staking/tags/tags.go#L8-L24)
|
||||
- [Governance tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/gov/tags/tags.go#L8-L22)
|
||||
- [Slashing tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/slashing/handler.go#L52)
|
||||
- [Distribution tags](https://github.com/cosmos/cosmos-sdk/blob/develop/x/distribution/tags/tags.go#L8-L17)
|
||||
@@ -277,13 +277,13 @@ On the upcoming mainnet, you can delegate `atom` to a validator. These [delegato
|
||||
You can query the list of all validators of a specific chain:
|
||||
|
||||
```bash
|
||||
gaiacli query stake validators
|
||||
gaiacli query staking validators
|
||||
```
|
||||
|
||||
If you want to get the information of a single validator you can check it with:
|
||||
|
||||
```bash
|
||||
gaiacli query stake validator <account_cosmosval>
|
||||
gaiacli query staking validator <account_cosmosval>
|
||||
```
|
||||
|
||||
#### Bond Tokens
|
||||
@@ -291,7 +291,7 @@ gaiacli query stake validator <account_cosmosval>
|
||||
On the testnet, we delegate `steak` instead of `atom`. Here's how you can bond tokens to a testnet validator (_i.e._ delegate):
|
||||
|
||||
```bash
|
||||
gaiacli tx stake delegate \
|
||||
gaiacli tx staking delegate \
|
||||
--amount=10steak \
|
||||
--validator=<validator> \
|
||||
--from=<key_name> \
|
||||
@@ -317,7 +317,7 @@ Don't use more `steak` thank you have! You can always get more by using the [Fau
|
||||
Once submitted a delegation to a validator, you can see it's information by using the following command:
|
||||
|
||||
```bash
|
||||
gaiacli query stake delegation \
|
||||
gaiacli query staking delegation \
|
||||
--address-delegator=<account_cosmos> \
|
||||
--validator=<account_cosmosval>
|
||||
```
|
||||
@@ -325,7 +325,7 @@ gaiacli query stake delegation \
|
||||
Or if you want to check all your current delegations with disctinct validators:
|
||||
|
||||
```bash
|
||||
gaiacli query stake delegations <account_cosmos>
|
||||
gaiacli query staking delegations <account_cosmos>
|
||||
```
|
||||
|
||||
You can also get previous delegation(s) status by adding the `--height` flag.
|
||||
@@ -335,7 +335,7 @@ You can also get previous delegation(s) status by adding the `--height` flag.
|
||||
If for any reason the validator misbehaves, or you just want to unbond a certain amount of tokens, use this following command. You can unbond a specific `shares-amount` (eg:`12.1`\) or a `shares-fraction` (eg:`0.25`) with the corresponding flags.
|
||||
|
||||
```bash
|
||||
gaiacli tx stake unbond \
|
||||
gaiacli tx staking unbond \
|
||||
--validator=<account_cosmosval> \
|
||||
--shares-fraction=0.5 \
|
||||
--from=<key_name> \
|
||||
@@ -349,7 +349,7 @@ The unbonding will be automatically completed when the unbonding period has pass
|
||||
Once you begin an unbonding-delegation, you can see it's information by using the following command:
|
||||
|
||||
```bash
|
||||
gaiacli query stake unbonding-delegation \
|
||||
gaiacli query staking unbonding-delegation \
|
||||
--address-delegator=<account_cosmos> \
|
||||
--validator=<account_cosmosval> \
|
||||
```
|
||||
@@ -357,13 +357,13 @@ gaiacli query stake unbonding-delegation \
|
||||
Or if you want to check all your current unbonding-delegations with disctinct validators:
|
||||
|
||||
```bash
|
||||
gaiacli query stake unbonding-delegations <account_cosmos>
|
||||
gaiacli query staking unbonding-delegations <account_cosmos>
|
||||
```
|
||||
|
||||
Additionally, as you can get all the unbonding-delegations from a particular validator:
|
||||
|
||||
```bash
|
||||
gaiacli query stake unbonding-delegations-from <account_cosmosval>
|
||||
gaiacli query staking unbonding-delegations-from <account_cosmosval>
|
||||
```
|
||||
|
||||
To get previous unbonding-delegation(s) status on past blocks, try adding the `--height` flag.
|
||||
@@ -373,7 +373,7 @@ To get previous unbonding-delegation(s) status on past blocks, try adding the `-
|
||||
A redelegation is a type delegation that allows you to bond illiquid tokens from one validator to another:
|
||||
|
||||
```bash
|
||||
gaiacli tx stake redelegate \
|
||||
gaiacli tx staking redelegate \
|
||||
--addr-validator-source=<account_cosmosval> \
|
||||
--addr-validator-dest=<account_cosmosval> \
|
||||
--shares-fraction=50 \
|
||||
@@ -390,7 +390,7 @@ The redelegation will be automatically completed when the unbonding period has p
|
||||
Once you begin an redelegation, you can see it's information by using the following command:
|
||||
|
||||
```bash
|
||||
gaiacli query stake redelegation \
|
||||
gaiacli query staking redelegation \
|
||||
--address-delegator=<account_cosmos> \
|
||||
--addr-validator-source=<account_cosmosval> \
|
||||
--addr-validator-dest=<account_cosmosval> \
|
||||
@@ -399,13 +399,13 @@ gaiacli query stake redelegation \
|
||||
Or if you want to check all your current unbonding-delegations with disctinct validators:
|
||||
|
||||
```bash
|
||||
gaiacli query stake redelegations <account_cosmos>
|
||||
gaiacli query staking redelegations <account_cosmos>
|
||||
```
|
||||
|
||||
Additionally, as you can get all the outgoing redelegations from a particular validator:
|
||||
|
||||
```bash
|
||||
gaiacli query stake redelegations-from <account_cosmosval>
|
||||
gaiacli query staking redelegations-from <account_cosmosval>
|
||||
```
|
||||
|
||||
To get previous redelegation(s) status on past blocks, try adding the `--height` flag.
|
||||
@@ -415,7 +415,7 @@ To get previous redelegation(s) status on past blocks, try adding the `--height`
|
||||
Parameters define high level settings for staking. You can get the current values by using:
|
||||
|
||||
```bash
|
||||
gaiacli query stake parameters
|
||||
gaiacli query staking parameters
|
||||
```
|
||||
|
||||
With the above command you will get the values for:
|
||||
@@ -431,7 +431,7 @@ All these values will be subject to updates though a `governance` process by `Pa
|
||||
A staking `Pool` defines the dynamic parameters of the current state. You can query them with the following command:
|
||||
|
||||
```bash
|
||||
gaiacli query stake pool
|
||||
gaiacli query staking pool
|
||||
```
|
||||
|
||||
With the `pool` command you will get the values for:
|
||||
|
||||
@@ -33,7 +33,7 @@ Don't use more `STAKE` thank you have! You can always get more by using the [Fau
|
||||
:::
|
||||
|
||||
```bash
|
||||
gaiacli tx stake create-validator \
|
||||
gaiacli tx staking create-validator \
|
||||
--amount=5STAKE \
|
||||
--pubkey=$(gaiad tendermint show-validator) \
|
||||
--moniker="choose a moniker" \
|
||||
@@ -91,7 +91,7 @@ A `gentx` is a JSON file carrying a self-delegation. All genesis transactions ar
|
||||
In this case, you need both the signature of the validator and the delegator. Start by creating an unsigned `create-validator` transaction, and save it in a file called `unsignedValTx`:
|
||||
|
||||
```bash
|
||||
gaiacli tx stake create-validator \
|
||||
gaiacli tx staking create-validator \
|
||||
--amount=5STAKE \
|
||||
--pubkey=$(gaiad tendermint show-validator) \
|
||||
--moniker="choose a moniker" \
|
||||
@@ -140,7 +140,7 @@ Once you've collected all genesis transactions in `~/.gaiad/config/gentx`, you c
|
||||
gaiad collect-gentxs
|
||||
```
|
||||
|
||||
__Note:__ The accounts from which you delegate in the `gentx` transactions need to possess staking tokens in the genesis file, otherwise `collect-gentx` will fail.
|
||||
__Note:__ The accounts from which you delegate in the `gentx` transactions need to possess stake tokens in the genesis file, otherwise `collect-gentx` will fail.
|
||||
|
||||
The previous command will collect all genesis transactions and finalise `genesis.json`. To verify the correctness of the configuration and start the node run:
|
||||
|
||||
@@ -155,7 +155,7 @@ You can edit your validator's public description. This info is to identify your
|
||||
The `--identity` can be used as to verify identity with systems like Keybase or UPort. When using with Keybase `--identity` should be populated with a 16-digit string that is generated with a [keybase.io](https://keybase.io) account. It's a cryptographically secure method of verifying your identity across multiple online networks. The Keybase API allows us to retrieve your Keybase avatar. This is how you can add a logo to your validator profile.
|
||||
|
||||
```bash
|
||||
gaiacli tx stake edit-validator
|
||||
gaiacli tx staking edit-validator
|
||||
--moniker="choose a moniker" \
|
||||
--website="https://cosmos.network" \
|
||||
--identity=6A0D65E29A4CBC8E \
|
||||
@@ -177,7 +177,7 @@ __Note__: The `commission-rate` value must adhere to the following invariants:
|
||||
View the validator's information with this command:
|
||||
|
||||
```bash
|
||||
gaiacli query stake validator <account_cosmos>
|
||||
gaiacli query staking validator <account_cosmos>
|
||||
```
|
||||
|
||||
## Track Validator Signing Information
|
||||
|
||||
@@ -6,9 +6,9 @@ See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/bank).
|
||||
|
||||
# Stake
|
||||
|
||||
The `x/stake` module is for Cosmos Delegated-Proof-of-Stake.
|
||||
The `x/staking` module is for Cosmos Delegated-Proof-of-Stake.
|
||||
|
||||
See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/stake).
|
||||
See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/staking).
|
||||
|
||||
See the
|
||||
[specification](https://github.com/cosmos/cosmos-sdk/tree/develop/docs/spec/staking)
|
||||
|
||||
@@ -333,7 +333,7 @@ func UndelegateCoins(to Account, amount Coins) {
|
||||
## Keepers & Handlers
|
||||
|
||||
The `VestingAccount` implementations reside in `x/auth`. However, any keeper in
|
||||
a module (e.g. staking in `x/stake`) wishing to potentially utilize any vesting
|
||||
a module (e.g. staking in `x/staking`) wishing to potentially utilize any vesting
|
||||
coins, must call explicit methods on the `x/bank` keeper (e.g. `DelegateCoins`)
|
||||
opposed to `SendCoins` and `SubtractCoins`.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Create or modify delegation distribution
|
||||
|
||||
- triggered-by: `stake.TxDelegate`, `stake.TxBeginRedelegate`, `stake.TxBeginUnbonding`
|
||||
- triggered-by: `staking.TxDelegate`, `staking.TxBeginRedelegate`, `staking.TxBeginUnbonding`
|
||||
|
||||
The pool of a new delegator bond will be 0 for the height at which the bond was
|
||||
added, or the withdrawal has taken place. This is achieved by setting
|
||||
@@ -10,7 +10,7 @@ added, or the withdrawal has taken place. This is achieved by setting
|
||||
|
||||
## Commission rate change
|
||||
|
||||
- triggered-by: `stake.TxEditValidator`
|
||||
- triggered-by: `staking.TxEditValidator`
|
||||
|
||||
If a validator changes its commission rate, all commission on fees must be
|
||||
simultaneously withdrawn using the transaction `TxWithdrawValidator`.
|
||||
@@ -19,7 +19,7 @@ Additionally the change and associated height must be recorded in a
|
||||
|
||||
## Change in Validator State
|
||||
|
||||
- triggered-by: `stake.Slash`, `stake.UpdateValidator`
|
||||
- triggered-by: `staking.Slash`, `staking.UpdateValidator`
|
||||
|
||||
Whenever a validator is slashed or enters/leaves the validator group all of the
|
||||
validator entitled reward tokens must be simultaneously withdrawn from
|
||||
|
||||
@@ -24,7 +24,7 @@ func GetDelegatorRewardsAll(delegatorAddr sdk.AccAddress, height int64) DecCoins
|
||||
|
||||
// collect all entitled rewards
|
||||
withdraw = 0
|
||||
pool = stake.GetPool()
|
||||
pool = staking.GetPool()
|
||||
feePool = GetFeePool()
|
||||
for delegation = range delegations
|
||||
delInfo = GetDelegationDistInfo(delegation.DelegatorAddr,
|
||||
@@ -55,7 +55,7 @@ func WithdrawDelegationReward(delegatorAddr, validatorAddr, withdrawAddr sdk.Acc
|
||||
height = GetHeight()
|
||||
|
||||
// get all distribution scenarios
|
||||
pool = stake.GetPool()
|
||||
pool = staking.GetPool()
|
||||
feePool = GetFeePool()
|
||||
delInfo = GetDelegationDistInfo(delegatorAddr,
|
||||
validatorAddr)
|
||||
|
||||
@@ -160,14 +160,14 @@ And the pseudocode for the `ProposalProcessingQueue`:
|
||||
// Tally
|
||||
voterIterator = rangeQuery(Governance, <proposalID|'addresses'>) //return all the addresses that voted on the proposal
|
||||
for each (voterAddress, vote) in voterIterator
|
||||
delegations = stakeKeeper.getDelegations(voterAddress) // get all delegations for current voter
|
||||
delegations = stakingKeeper.getDelegations(voterAddress) // get all delegations for current voter
|
||||
|
||||
for each delegation in delegations
|
||||
// make sure delegation.Shares does NOT include shares being unbonded
|
||||
tmpValMap(delegation.ValidatorAddr).Minus += delegation.Shares
|
||||
proposal.updateTally(vote, delegation.Shares)
|
||||
|
||||
_, isVal = stakeKeeper.getValidator(voterAddress)
|
||||
_, isVal = stakingKeeper.getValidator(voterAddress)
|
||||
if (isVal)
|
||||
tmpValMap(voterAddress).Vote = vote
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ type Pool struct {
|
||||
### Params
|
||||
|
||||
Params is global data structure that stores system parameters and defines
|
||||
overall functioning of the stake module.
|
||||
overall functioning of the staking module.
|
||||
|
||||
- Params: `0x00 -> amino(params)`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user