From 73c5fdf1f9b7c2ae48af7bffb964eb5a18295631 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Wed, 19 Sep 2018 00:10:33 -0400 Subject: [PATCH] more cli related --- cmd/gaia/cmd/gaiacli/main.go | 14 ++++++++++++++ x/distribution/client/cli/tx.go | 4 ++-- x/distribution/types/codec.go | 1 - x/distribution/types/msg.go | 18 +++++++++--------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/cmd/gaia/cmd/gaiacli/main.go b/cmd/gaia/cmd/gaiacli/main.go index c216bb2eb0..166359201a 100644 --- a/cmd/gaia/cmd/gaiacli/main.go +++ b/cmd/gaia/cmd/gaiacli/main.go @@ -101,6 +101,20 @@ func main() { stakeCmd, ) + //Add distribution commands + distrCmd := &cobra.Command{ + Use: "distribution", + Short: "withdraw rewards for delegation and validation", + } + distrCmd.AddCommand( + client.PostCommands( + stakecmd.GetCmdWithdrawDelegationRewardsAll(cdc), + stakecmd.GetCmdSetWithdrawAddr(cdc), + )...) + rootCmd.AddCommand( + distrCmd, + ) + //Add stake commands govCmd := &cobra.Command{ Use: "gov", diff --git a/x/distribution/client/cli/tx.go b/x/distribution/client/cli/tx.go index ca10471c64..f9cd858bb1 100644 --- a/x/distribution/client/cli/tx.go +++ b/x/distribution/client/cli/tx.go @@ -80,7 +80,7 @@ func GetCmdWithdrawDelegationRewardsAll(cdc *wire.Codec) *cobra.Command { } // GetCmdDelegate implements the delegate command. -func GetCmdWithdrawDelegationRewardsAll(cdc *wire.Codec) *cobra.Command { +func GetCmdSetWithdrawAddr(cdc *wire.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "set-withdraw-addr [withdraw-addr]", Short: "change the default withdraw address for rewards associated with an address", @@ -103,7 +103,7 @@ func GetCmdWithdrawDelegationRewardsAll(cdc *wire.Codec) *cobra.Command { return err } - msg := distr.NewMsgModifyWithdrawAddress(delAddr, withdrawAddr) + msg := distr.NewMsgSetWithdrawAddress(delAddr, withdrawAddr) // build and sign the transaction, then broadcast to Tendermint return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index 84fee76a3a..ece45a004f 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -4,7 +4,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// XXX TODO // Register concrete types on codec codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgWithdrawDelegationRewardsAll{}, "cosmos-sdk/MsgWithdrawDelegationRewardsAll", nil) diff --git a/x/distribution/types/msg.go b/x/distribution/types/msg.go index 3808752f1d..ce77285c15 100644 --- a/x/distribution/types/msg.go +++ b/x/distribution/types/msg.go @@ -9,34 +9,34 @@ import ( const MsgType = "distr" // Verify interface at compile time -var _, _ sdk.Msg = &MsgModifyWithdrawAddress{}, &MsgWithdrawDelegatorRewardsAll{} +var _, _ sdk.Msg = &MsgSetWithdrawAddress{}, &MsgWithdrawDelegatorRewardsAll{} var _, _ sdk.Msg = &MsgWithdrawDelegationReward{}, &MsgWithdrawValidatorRewardsAll{} //______________________________________________________________________ // msg struct for changing the withdraw address for a delegator (or validator self-delegation) -type MsgModifyWithdrawAddress struct { +type MsgSetWithdrawAddress struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` WithdrawAddr sdk.AccAddress `json:"delegator_addr"` } -func NewMsgModifyWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgModifyWithdrawAddress { - return MsgModifyWithdrawAddress{ +func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgSetWithdrawAddress { + return MsgSetWithdrawAddress{ DelegatorAddr: delAddr, WithdrawAddr: withdrawAddr, } } -func (msg MsgModifyWithdrawAddress) Type() string { return MsgType } -func (msg MsgModifyWithdrawAddress) Name() string { return "withdraw_delegation_rewards_all" } +func (msg MsgSetWithdrawAddress) Type() string { return MsgType } +func (msg MsgSetWithdrawAddress) Name() string { return "withdraw_delegation_rewards_all" } // Return address that must sign over msg.GetSignBytes() -func (msg MsgModifyWithdrawAddress) GetSigners() []sdk.AccAddress { +func (msg MsgSetWithdrawAddress) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sdk.AccAddress(msg.DelegatorAddr)} } // get the bytes for the message signer to sign on -func (msg MsgModifyWithdrawAddress) GetSignBytes() []byte { +func (msg MsgSetWithdrawAddress) GetSignBytes() []byte { b, err := MsgCdc.MarshalJSON(msg) if err != nil { panic(err) @@ -45,7 +45,7 @@ func (msg MsgModifyWithdrawAddress) GetSignBytes() []byte { } // quick validity check -func (msg MsgModifyWithdrawAddress) ValidateBasic() sdk.Error { +func (msg MsgSetWithdrawAddress) ValidateBasic() sdk.Error { if msg.DelegatorAddr == nil { return ErrNilDelegatorAddr(DefaultCodespace) }