diff --git a/PENDING.md b/PENDING.md index f297e6a4af6a..73dda31fcdbc 100644 --- a/PENDING.md +++ b/PENDING.md @@ -3,6 +3,18 @@ BREAKING CHANGES * [baseapp] Msgs are no longer run on CheckTx, removed `ctx.IsCheckTx()` * [x/stake] Fixed the period check for the inflation calculation +* \#1606 The following CLI commands have been switched to use `--from` + * `gaiacli stake create-validator --address-validator` + * `gaiacli stake edit-validator --address-validator` + * `gaiacli stake delegate --address-delegator` + * `gaiacli stake unbond begin --address-delegator` + * `gaiacli stake unbond complete --address-delegator` + * `gaiacli stake redelegate begin --address-delegator` + * `gaiacli stake redelegate complete --address-delegator` + * `gaiacli stake unrevoke [validator-address]` + * `gaiacli gov submit-proposal --proposer` + * `gaiacli gov deposit --depositer` + * `gaiacli gov vote --voter` FEATURES * [lcd] Can now query governance proposals by ProposalStatus diff --git a/cmd/gaia/cli_test/cli_test.go b/cmd/gaia/cli_test/cli_test.go index 650021d315ab..beac340970fb 100644 --- a/cmd/gaia/cli_test/cli_test.go +++ b/cmd/gaia/cli_test/cli_test.go @@ -118,7 +118,6 @@ func TestGaiaCLICreateValidator(t *testing.T) { // create validator cvStr := fmt.Sprintf("gaiacli stake create-validator %v", flags) cvStr += fmt.Sprintf(" --from=%s", "bar") - cvStr += fmt.Sprintf(" --address-validator=%s", barAddr) cvStr += fmt.Sprintf(" --pubkey=%s", barCeshPubKey) cvStr += fmt.Sprintf(" --amount=%v", "2steak") cvStr += fmt.Sprintf(" --moniker=%v", "bar-vally") @@ -137,7 +136,6 @@ func TestGaiaCLICreateValidator(t *testing.T) { unbondStr := fmt.Sprintf("gaiacli stake unbond begin %v", flags) unbondStr += fmt.Sprintf(" --from=%s", "bar") unbondStr += fmt.Sprintf(" --address-validator=%s", barAddr) - unbondStr += fmt.Sprintf(" --address-delegator=%s", barAddr) unbondStr += fmt.Sprintf(" --shares-amount=%v", "1") success := executeWrite(t, unbondStr, pass) @@ -176,7 +174,15 @@ func TestGaiaCLISubmitProposal(t *testing.T) { fooAcc := executeGetAccount(t, fmt.Sprintf("gaiacli account %s %v", fooAddr, flags)) require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf("steak").Int64()) - executeWrite(t, fmt.Sprintf("gaiacli gov submit-proposal %v --proposer=%s --deposit=5steak --type=Text --title=Test --description=test --from=foo", flags, fooAddr), pass) + // unbond a single share + spStr := fmt.Sprintf("gaiacli gov submit-proposal %v", flags) + spStr += fmt.Sprintf(" --from=%s", "foo") + spStr += fmt.Sprintf(" --deposit=%s", "5steak") + spStr += fmt.Sprintf(" --type=%s", "Text") + spStr += fmt.Sprintf(" --title=%s", "Test") + spStr += fmt.Sprintf(" --description=%s", "test") + + executeWrite(t, spStr, pass) tests.WaitForNextNBlocksTM(2, port) fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli account %s %v", fooAddr, flags)) @@ -186,7 +192,12 @@ func TestGaiaCLISubmitProposal(t *testing.T) { require.Equal(t, int64(1), proposal1.GetProposalID()) require.Equal(t, gov.StatusDepositPeriod, proposal1.GetStatus()) - executeWrite(t, fmt.Sprintf("gaiacli gov deposit %v --depositer=%s --deposit=10steak --proposalID=1 --from=foo", flags, fooAddr), pass) + depositStr := fmt.Sprintf("gaiacli gov deposit %v", flags) + depositStr += fmt.Sprintf(" --from=%s", "foo") + depositStr += fmt.Sprintf(" --deposit=%s", "10steak") + depositStr += fmt.Sprintf(" --proposalID=%s", "1") + + executeWrite(t, depositStr, pass) tests.WaitForNextNBlocksTM(2, port) fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli account %s %v", fooAddr, flags)) @@ -195,10 +206,15 @@ func TestGaiaCLISubmitProposal(t *testing.T) { require.Equal(t, int64(1), proposal1.GetProposalID()) require.Equal(t, gov.StatusVotingPeriod, proposal1.GetStatus()) - executeWrite(t, fmt.Sprintf("gaiacli gov vote %v --proposalID=1 --voter=%s --option=Yes --from=foo", flags, fooAddr), pass) + voteStr := fmt.Sprintf("gaiacli gov vote %v", flags) + voteStr += fmt.Sprintf(" --from=%s", "foo") + voteStr += fmt.Sprintf(" --proposalID=%s", "1") + voteStr += fmt.Sprintf(" --option=%s", "Yes") + + executeWrite(t, voteStr, pass) tests.WaitForNextNBlocksTM(2, port) - vote := executeGetVote(t, fmt.Sprintf("gaiacli gov query-vote --proposalID=1 --voter=%s --output=json %v", fooAddr, flags)) + vote := executeGetVote(t, fmt.Sprintf("gaiacli gov query-vote --proposalID=1 --voter=%s --output=json %v", fooAddr, flags)) require.Equal(t, int64(1), vote.ProposalID) require.Equal(t, gov.OptionYes, vote.Option) } diff --git a/docs/sdk/clients.md b/docs/sdk/clients.md index 9fa015908d7b..0767745e5148 100644 --- a/docs/sdk/clients.md +++ b/docs/sdk/clients.md @@ -119,9 +119,8 @@ On the testnet, we delegate `steak` instead of `atom`. Here's how you can bond t ```bash gaiacli stake delegate \ --amount=10steak \ - --address-delegator= \ --address-validator=$(gaiad tendermint show_validator) \ - --name= \ + --from= \ --chain-id=gaia-6002 ``` @@ -136,15 +135,16 @@ While tokens are bonded, they are pooled with all the other bonded tokens in the If for any reason the validator misbehaves, or you want to unbond a certain amount of tokens, use this following command. You can unbond a specific amount of`shares`\(eg:`12.1`\) or all of them \(`MAX`\). ```bash -gaiacli stake unbond \ - --address-delegator= \ +gaiacli stake unbond begin \ --address-validator=$(gaiad tendermint show_validator) \ - --shares=MAX \ - --name= \ + --shares-percent=1 \ + --from= \ --chain-id=gaia-6002 ``` -You can check your balance and your stake delegation to see that the unbonding went through successfully. +Later you must use the `gaiacli stake unbond complete` command to finish +unbonding at which point you can can check your balance and your stake +delegation to see that the unbonding went through successfully. ```bash gaiacli account diff --git a/docs/sdk/gaiacli.md b/docs/sdk/gaiacli.md index f42bfd14535f..cd4271e42220 100644 --- a/docs/sdk/gaiacli.md +++ b/docs/sdk/gaiacli.md @@ -108,9 +108,8 @@ On the testnet, we delegate `steak` instead of `atom`. Here's how you can bond t ```bash gaiacli stake delegate \ --amount=10steak \ - --address-delegator= \ --address-validator=$(gaiad tendermint show_validator) \ - --name= \ + --from= \ --chain-id=gaia-6002 ``` @@ -125,15 +124,16 @@ While tokens are bonded, they are pooled with all the other bonded tokens in the If for any reason the validator misbehaves, or you want to unbond a certain amount of tokens, use this following command. You can unbond a specific amount of`shares`\(eg:`12.1`\) or all of them \(`MAX`\). ```bash -gaiacli stake unbond \ - --address-delegator= \ +gaiacli stake unbond begin \ --address-validator=$(gaiad tendermint show_validator) \ - --shares=MAX \ - --name= \ + --shares-percent=1 \ + --from= \ --chain-id=gaia-6002 ``` -You can check your balance and your stake delegation to see that the unbonding went through successfully. +Later you must use the `gaiacli stake unbond complete` command to finish +unbonding at which point you can can check your balance and your stake +delegation to see that the unbonding went through successfully. ```bash gaiacli account diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index 88c4b7d170e0..c1bb62bc708a 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -20,8 +20,6 @@ const ( flagDescription = "description" flagProposalType = "type" flagDeposit = "deposit" - flagProposer = "proposer" - flagDepositer = "depositer" flagVoter = "voter" flagOption = "option" ) @@ -32,13 +30,15 @@ func GetCmdSubmitProposal(cdc *wire.Codec) *cobra.Command { Use: "submit-proposal", Short: "Submit a proposal along with an initial deposit", RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) + title := viper.GetString(flagTitle) description := viper.GetString(flagDescription) strProposalType := viper.GetString(flagProposalType) initialDeposit := viper.GetString(flagDeposit) // get the from address from the name flag - from, err := sdk.AccAddressFromBech32(viper.GetString(flagProposer)) + fromAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -54,7 +54,7 @@ func GetCmdSubmitProposal(cdc *wire.Codec) *cobra.Command { } // create the message - msg := gov.NewMsgSubmitProposal(title, description, proposalType, from, amount) + msg := gov.NewMsgSubmitProposal(title, description, proposalType, fromAddr, amount) err = msg.ValidateBasic() if err != nil { @@ -62,10 +62,8 @@ func GetCmdSubmitProposal(cdc *wire.Codec) *cobra.Command { } // build and sign the transaction, then broadcast to Tendermint - ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) // proposalID must be returned, and it is a part of response ctx.PrintResponse = true - err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc) if err != nil { return err @@ -78,7 +76,6 @@ func GetCmdSubmitProposal(cdc *wire.Codec) *cobra.Command { cmd.Flags().String(flagDescription, "", "description of proposal") cmd.Flags().String(flagProposalType, "", "proposalType of proposal") cmd.Flags().String(flagDeposit, "", "deposit of proposal") - cmd.Flags().String(flagProposer, "", "proposer of proposal") return cmd } @@ -89,8 +86,10 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command { Use: "deposit", Short: "deposit tokens for activing proposal", RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) + // get the from address from the name flag - depositer, err := sdk.AccAddressFromBech32(viper.GetString(flagDepositer)) + depositerAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -103,7 +102,7 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command { } // create the message - msg := gov.NewMsgDeposit(depositer, proposalID, amount) + msg := gov.NewMsgDeposit(depositerAddr, proposalID, amount) err = msg.ValidateBasic() if err != nil { @@ -111,8 +110,6 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command { } // build and sign the transaction, then broadcast to Tendermint - ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc) if err != nil { return err @@ -122,7 +119,6 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command { } cmd.Flags().String(flagProposalID, "", "proposalID of proposal depositing on") - cmd.Flags().String(flagDepositer, "", "depositer of deposit") cmd.Flags().String(flagDeposit, "", "amount of deposit") return cmd @@ -134,9 +130,9 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command { Use: "vote", Short: "vote for an active proposal, options: Yes/No/NoWithVeto/Abstain", RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - bechVoter := viper.GetString(flagVoter) - voter, err := sdk.AccAddressFromBech32(bechVoter) + voterAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -151,18 +147,17 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command { } // create the message - msg := gov.NewMsgVote(voter, proposalID, byteVoteOption) + msg := gov.NewMsgVote(voterAddr, proposalID, byteVoteOption) err = msg.ValidateBasic() if err != nil { return err } - fmt.Printf("Vote[Voter:%s,ProposalID:%d,Option:%s]", bechVoter, msg.ProposalID, msg.Option.String()) + fmt.Printf("Vote[Voter:%s,ProposalID:%d,Option:%s]", + voterAddr.String(), msg.ProposalID, msg.Option.String()) // build and sign the transaction, then broadcast to Tendermint - ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc) if err != nil { return err @@ -172,7 +167,6 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command { } cmd.Flags().String(flagProposalID, "", "proposalID of proposal voting on") - cmd.Flags().String(flagVoter, "", "bech32 voter address") cmd.Flags().String(flagOption, "", "vote option {Yes, No, NoWithVeto, Abstain}") return cmd diff --git a/x/slashing/client/cli/tx.go b/x/slashing/client/cli/tx.go index 15458ad1a84a..ab8911c119ba 100644 --- a/x/slashing/client/cli/tx.go +++ b/x/slashing/client/cli/tx.go @@ -14,12 +14,12 @@ import ( func GetCmdUnrevoke(cdc *wire.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "unrevoke", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(0), Short: "unrevoke validator previously revoked for downtime", RunE: func(cmd *cobra.Command, args []string) error { ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - validatorAddr, err := sdk.AccAddressFromBech32(args[0]) + validatorAddr, err := ctx.GetFromAddress() if err != nil { return err } diff --git a/x/stake/client/cli/tx.go b/x/stake/client/cli/tx.go index 72317c82c9c6..e391bad8c1e7 100644 --- a/x/stake/client/cli/tx.go +++ b/x/stake/client/cli/tx.go @@ -28,7 +28,7 @@ func GetCmdCreateValidator(cdc *wire.Codec) *cobra.Command { if err != nil { return err } - validatorAddr, err := sdk.AccAddressFromBech32(viper.GetString(FlagAddressValidator)) + validatorAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -74,7 +74,6 @@ func GetCmdCreateValidator(cdc *wire.Codec) *cobra.Command { cmd.Flags().AddFlagSet(fsPk) cmd.Flags().AddFlagSet(fsAmount) cmd.Flags().AddFlagSet(fsDescription) - cmd.Flags().AddFlagSet(fsValidator) cmd.Flags().AddFlagSet(fsDelegator) return cmd } @@ -85,8 +84,9 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command { Use: "edit-validator", Short: "edit and existing validator account", RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - validatorAddr, err := sdk.AccAddressFromBech32(viper.GetString(FlagAddressValidator)) + validatorAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -99,8 +99,6 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgEditValidator(validatorAddr, description) // build and sign the transaction, then broadcast to Tendermint - ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc) if err != nil { return err @@ -111,7 +109,6 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command { } cmd.Flags().AddFlagSet(fsDescription) - cmd.Flags().AddFlagSet(fsValidator) return cmd } @@ -121,12 +118,14 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command { Use: "delegate", Short: "delegate liquid tokens to an validator", RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) + amount, err := sdk.ParseCoin(viper.GetString(FlagAmount)) if err != nil { return err } - delegatorAddr, err := sdk.AccAddressFromBech32(viper.GetString(FlagAddressDelegator)) + delegatorAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -138,8 +137,6 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgDelegate(delegatorAddr, validatorAddr, amount) // build and sign the transaction, then broadcast to Tendermint - ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc) if err != nil { return err @@ -150,7 +147,6 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command { } cmd.Flags().AddFlagSet(fsAmount) - cmd.Flags().AddFlagSet(fsDelegator) cmd.Flags().AddFlagSet(fsValidator) return cmd } @@ -175,9 +171,10 @@ func GetCmdBeginRedelegate(storeName string, cdc *wire.Codec) *cobra.Command { Use: "begin", Short: "begin redelegation", RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) var err error - delegatorAddr, err := sdk.AccAddressFromBech32(viper.GetString(FlagAddressDelegator)) + delegatorAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -202,8 +199,6 @@ func GetCmdBeginRedelegate(storeName string, cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgBeginRedelegate(delegatorAddr, validatorSrcAddr, validatorDstAddr, sharesAmount) // build and sign the transaction, then broadcast to Tendermint - ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc) if err != nil { return err @@ -214,7 +209,6 @@ func GetCmdBeginRedelegate(storeName string, cdc *wire.Codec) *cobra.Command { } cmd.Flags().AddFlagSet(fsShares) - cmd.Flags().AddFlagSet(fsDelegator) cmd.Flags().AddFlagSet(fsRedelegation) return cmd } @@ -266,8 +260,9 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command { Use: "complete", Short: "complete redelegation", RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - delegatorAddr, err := sdk.AccAddressFromBech32(viper.GetString(FlagAddressDelegator)) + delegatorAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -283,8 +278,6 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgCompleteRedelegate(delegatorAddr, validatorSrcAddr, validatorDstAddr) // build and sign the transaction, then broadcast to Tendermint - ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc) if err != nil { return err @@ -293,7 +286,6 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command { return nil }, } - cmd.Flags().AddFlagSet(fsDelegator) cmd.Flags().AddFlagSet(fsRedelegation) return cmd } @@ -318,8 +310,9 @@ func GetCmdBeginUnbonding(storeName string, cdc *wire.Codec) *cobra.Command { Use: "begin", Short: "begin unbonding", RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - delegatorAddr, err := sdk.AccAddressFromBech32(viper.GetString(FlagAddressDelegator)) + delegatorAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -340,8 +333,6 @@ func GetCmdBeginUnbonding(storeName string, cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgBeginUnbonding(delegatorAddr, validatorAddr, sharesAmount) // build and sign the transaction, then broadcast to Tendermint - ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc) if err != nil { return err @@ -352,7 +343,6 @@ func GetCmdBeginUnbonding(storeName string, cdc *wire.Codec) *cobra.Command { } cmd.Flags().AddFlagSet(fsShares) - cmd.Flags().AddFlagSet(fsDelegator) cmd.Flags().AddFlagSet(fsValidator) return cmd } @@ -363,8 +353,9 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command { Use: "complete", Short: "complete unbonding", RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - delegatorAddr, err := sdk.AccAddressFromBech32(viper.GetString(FlagAddressDelegator)) + delegatorAddr, err := ctx.GetFromAddress() if err != nil { return err } @@ -376,8 +367,6 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgCompleteUnbonding(delegatorAddr, validatorAddr) // build and sign the transaction, then broadcast to Tendermint - ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc)) - err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc) if err != nil { return err @@ -386,7 +375,6 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command { return nil }, } - cmd.Flags().AddFlagSet(fsDelegator) cmd.Flags().AddFlagSet(fsValidator) return cmd }