Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Upstream to evaluate Liquid staking #12917

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions proto/cosmos/app/module/v1alpha1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "cosmos/app/v1alpha1/module.proto";
// Module is the module config object for the cosmos.app v1 app module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/cosmos/cosmos-sdk/app"
use_package: {name: "cosmos.app.v1alpha1"}
go_import: "github.com/cosmos/cosmos-sdk/simapp"
use_package: { name: "cosmos.app.v1alpha1" }
};
}
107 changes: 0 additions & 107 deletions x/distribution/abci_test.go

This file was deleted.

46 changes: 46 additions & 0 deletions x/distribution/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func GetQueryCmd() *cobra.Command {
GetCmdQueryValidatorSlashes(),
GetCmdQueryDelegatorRewards(),
GetCmdQueryCommunityPool(),
GetCmdQueryTokenizeShareRecordReward(),
)

return distQueryCmd
Expand Down Expand Up @@ -319,3 +320,48 @@ $ %s query distribution community-pool
flags.AddQueryFlagsToCmd(cmd)
return cmd
}

// GetCmdQueryTokenizeShareRecordReward implements the query tokenize share record rewards
func GetCmdQueryTokenizeShareRecordReward() *cobra.Command {
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix()

cmd := &cobra.Command{
Use: "tokenize-share-record-rewards [owner]",
Args: cobra.ExactArgs(1),
Short: "Query distribution tokenize share record rewards",
Long: strings.TrimSpace(
fmt.Sprintf(`Query the query tokenize share record rewards.

Example:
$ %s query distribution tokenize-share-record-rewards %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
`,
version.AppName, bech32PrefixAccAddr,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

ownerAddr, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
return err
}

res, err := queryClient.TokenizeShareRecordReward(
cmd.Context(),
&types.QueryTokenizeShareRecordRewardRequest{OwnerAddress: ownerAddr.String()},
)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
return cmd
}
83 changes: 79 additions & 4 deletions x/distribution/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"fmt"
"strconv"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -41,6 +42,8 @@ func NewTxCmd() *cobra.Command {
NewWithdrawAllRewardsCmd(),
NewSetWithdrawAddrCmd(),
NewFundCommunityPoolCmd(),
NewWithdrawTokenizeShareRecordRewardCmd(),
NewWithdrawAllTokenizeShareRecordRewardCmd(),
)

return distTxCmd
Expand All @@ -52,6 +55,7 @@ func newSplitAndApply(
genOrBroadcastFn newGenerateOrBroadcastFunc, clientCtx client.Context,
fs *pflag.FlagSet, msgs []sdk.Msg, chunkSize int,
) error {

if chunkSize == 0 {
return genOrBroadcastFn(clientCtx, fs, msgs...)
}
Expand All @@ -74,7 +78,6 @@ func newSplitAndApply(
return nil
}

// NewWithdrawRewardsCmd returns a CLI command handler for creating a MsgWithdrawDelegatorReward transaction.
func NewWithdrawRewardsCmd() *cobra.Command {
bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix()

Expand Down Expand Up @@ -110,6 +113,12 @@ $ %s tx distribution withdraw-rewards %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
msgs = append(msgs, types.NewMsgWithdrawValidatorCommission(valAddr))
}

for _, msg := range msgs {
if err := msg.ValidateBasic(); err != nil {
return err
}
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...)
},
}
Expand All @@ -120,7 +129,6 @@ $ %s tx distribution withdraw-rewards %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
return cmd
}

// NewWithdrawAllRewardsCmd returns a CLI command handler for creating a MsgWithdrawDelegatorReward transaction.
func NewWithdrawAllRewardsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "withdraw-all-rewards",
Expand Down Expand Up @@ -184,7 +192,6 @@ $ %[1]s tx distribution withdraw-all-rewards --from mykey
return cmd
}

// NewSetWithdrawAddrCmd returns a CLI command handler for creating a MsgSetWithdrawAddress transaction.
func NewSetWithdrawAddrCmd() *cobra.Command {
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix()

Expand Down Expand Up @@ -223,7 +230,6 @@ $ %s tx distribution set-withdraw-addr %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
return cmd
}

// NewFundCommunityPoolCmd returns a CLI command handler for creating a MsgFundCommunityPool transaction.
func NewFundCommunityPoolCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "fund-community-pool [amount]",
Expand Down Expand Up @@ -326,3 +332,72 @@ Where proposal.json contains:

return cmd
}

// WithdrawAllTokenizeShareRecordReward defines a method to withdraw reward for all owning TokenizeShareRecord
func NewWithdrawAllTokenizeShareRecordRewardCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "withdraw-all-tokenize-share-rewards",
Args: cobra.ExactArgs(0),
Short: "Withdraw reward for all owning TokenizeShareRecord",
Long: strings.TrimSpace(
fmt.Sprintf(`Withdraw reward for all owned TokenizeShareRecord

Example:
$ %s tx distribution withdraw-tokenize-share-rewards --from mykey
`,
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgWithdrawAllTokenizeShareRecordReward(clientCtx.GetFromAddress())

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

// WithdrawTokenizeShareRecordReward defines a method to withdraw reward for an owning TokenizeShareRecord
func NewWithdrawTokenizeShareRecordRewardCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "withdraw-tokenize-share-rewards",
Args: cobra.ExactArgs(1),
Short: "Withdraw reward for an owning TokenizeShareRecord",
Long: strings.TrimSpace(
fmt.Sprintf(`Withdraw reward for an owned TokenizeShareRecord

Example:
$ %s tx distribution withdraw-tokenize-share-rewards 1 --from mykey
`,
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

recordId, err := strconv.Atoi(args[0])
if err != nil {
return err
}

msg := types.NewMsgWithdrawTokenizeShareRecordReward(clientCtx.GetFromAddress(), uint64(recordId))

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
Loading