x/distribution: CLI & Module Tweaks (#6684)
* init commit * cleanup methods * fix
This commit is contained in:
@@ -93,7 +93,7 @@ withdraw_addr_enabled: true`,
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.GetCommands(cli.GetCmdQueryParams())[0]
|
||||
cmd := cli.GetCmdQueryParams()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
@@ -158,7 +158,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorOutstandingRewards() {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.GetCommands(cli.GetCmdQueryValidatorOutstandingRewards())[0]
|
||||
cmd := cli.GetCmdQueryValidatorOutstandingRewards()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
@@ -228,7 +228,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorCommission() {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.GetCommands(cli.GetCmdQueryValidatorCommission())[0]
|
||||
cmd := cli.GetCmdQueryValidatorCommission()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
@@ -314,7 +314,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorSlashes() {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.GetCommands(cli.GetCmdQueryValidatorSlashes())[0]
|
||||
cmd := cli.GetCmdQueryValidatorSlashes()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
@@ -420,7 +420,7 @@ total:
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.GetCommands(cli.GetCmdQueryDelegatorRewards())[0]
|
||||
cmd := cli.GetCmdQueryDelegatorRewards()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
@@ -470,7 +470,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryCommunityPool() {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.GetCommands(cli.GetCmdQueryCommunityPool())[0]
|
||||
cmd := cli.GetCmdQueryCommunityPool()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
@@ -593,7 +593,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.PostCommands(cli.NewWithdrawAllRewardsCmd())[0]
|
||||
cmd := cli.NewWithdrawAllRewardsCmd()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
@@ -656,7 +656,7 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.PostCommands(cli.NewSetWithdrawAddrCmd())[0]
|
||||
cmd := cli.NewSetWithdrawAddrCmd()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
@@ -719,7 +719,7 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.PostCommands(cli.NewFundCommunityPoolCmd())[0]
|
||||
cmd := cli.NewFundCommunityPoolCmd()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
@@ -812,7 +812,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := flags.PostCommands(cli.GetCmdSubmitProposal())[0]
|
||||
cmd := cli.GetCmdSubmitProposal()
|
||||
_, out := testutil.ApplyMockIO(cmd)
|
||||
|
||||
clientCtx := val.ClientCtx.WithOutput(out)
|
||||
|
||||
@@ -25,21 +25,21 @@ func GetQueryCmd() *cobra.Command {
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
distQueryCmd.AddCommand(flags.GetCommands(
|
||||
distQueryCmd.AddCommand(
|
||||
GetCmdQueryParams(),
|
||||
GetCmdQueryValidatorOutstandingRewards(),
|
||||
GetCmdQueryValidatorCommission(),
|
||||
GetCmdQueryValidatorSlashes(),
|
||||
GetCmdQueryDelegatorRewards(),
|
||||
GetCmdQueryCommunityPool(),
|
||||
)...)
|
||||
)
|
||||
|
||||
return distQueryCmd
|
||||
}
|
||||
|
||||
// GetCmdQueryParams implements the query params command.
|
||||
func GetCmdQueryParams() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "params",
|
||||
Args: cobra.NoArgs,
|
||||
Short: "Query distribution params",
|
||||
@@ -64,12 +64,15 @@ func GetCmdQueryParams() *cobra.Command {
|
||||
return clientCtx.PrintOutput(params)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryValidatorOutstandingRewards implements the query validator
|
||||
// outstanding rewards command.
|
||||
func GetCmdQueryValidatorOutstandingRewards() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "validator-outstanding-rewards [validator]",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Short: "Query distribution outstanding (un-withdrawn) rewards for a validator and all their delegations",
|
||||
@@ -116,11 +119,14 @@ $ %s query distribution validator-outstanding-rewards cosmosvaloper1lwjmdnks33xw
|
||||
return clientCtx.PrintOutput(outstandingRewards)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryValidatorCommission implements the query validator commission command.
|
||||
func GetCmdQueryValidatorCommission() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "commission [validator]",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Short: "Query distribution validator commission",
|
||||
@@ -158,11 +164,14 @@ $ %s query distribution commission cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9l
|
||||
return clientCtx.PrintOutput(valCom)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryValidatorSlashes implements the query validator slashes command.
|
||||
func GetCmdQueryValidatorSlashes() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "slashes [validator] [start-height] [end-height]",
|
||||
Args: cobra.ExactArgs(3),
|
||||
Short: "Query distribution validator slashes",
|
||||
@@ -216,11 +225,14 @@ $ %s query distribution slashes cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmq
|
||||
return clientCtx.PrintOutput(slashes)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryDelegatorRewards implements the query delegator rewards command.
|
||||
func GetCmdQueryDelegatorRewards() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "rewards [delegator-addr] [validator-addr]",
|
||||
Args: cobra.RangeArgs(1, 2),
|
||||
Short: "Query all distribution delegator rewards or rewards from a particular validator",
|
||||
@@ -282,11 +294,14 @@ $ %s query distribution rewards cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p co
|
||||
return clientCtx.PrintOutput(result)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryCommunityPool returns the command for fetching community pool info
|
||||
func GetCmdQueryCommunityPool() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "community-pool",
|
||||
Args: cobra.NoArgs,
|
||||
Short: "Query the amount of coins in the community pool",
|
||||
@@ -319,4 +334,7 @@ $ %s query distribution community-pool
|
||||
return clientCtx.PrintOutput(result)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ func NewTxCmd() *cobra.Command {
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
distTxCmd.AddCommand(flags.PostCommands(
|
||||
distTxCmd.AddCommand(
|
||||
NewWithdrawRewardsCmd(),
|
||||
NewWithdrawAllRewardsCmd(),
|
||||
NewSetWithdrawAddrCmd(),
|
||||
NewFundCommunityPoolCmd(),
|
||||
)...)
|
||||
)
|
||||
|
||||
return distTxCmd
|
||||
}
|
||||
@@ -122,6 +122,7 @@ $ %s tx distribution withdraw-rewards cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx
|
||||
}
|
||||
|
||||
cmd.Flags().Bool(FlagCommission, false, "Withdraw the validator's commission in addition to the rewards")
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -165,11 +166,12 @@ $ %s tx distribution withdraw-all-rewards --from mykey
|
||||
}
|
||||
|
||||
cmd.Flags().Int(FlagMaxMessagesPerTx, MaxMessagesPerTxDefault, "Limit the number of messages per tx (0 for unlimited)")
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func NewSetWithdrawAddrCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "set-withdraw-addr [withdraw-addr]",
|
||||
Short: "change the default withdraw address for rewards associated with an address",
|
||||
Long: strings.TrimSpace(
|
||||
@@ -203,10 +205,13 @@ $ %s tx distribution set-withdraw-addr cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func NewFundCommunityPoolCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "fund-community-pool [amount]",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Short: "Funds the community pool with the specified amount",
|
||||
@@ -240,11 +245,14 @@ $ %s tx distribution fund-community-pool 100uatom --from mykey
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdSubmitProposal implements the command to submit a community-pool-spend proposal
|
||||
func GetCmdSubmitProposal() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "community-pool-spend [proposal-file]",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Short: "Submit a community pool spend proposal",
|
||||
@@ -305,4 +313,7 @@ Where proposal.json contains:
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user