From 9ce99be28a6a77a28876a353d72ea30d016d2d0c Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 8 Jan 2024 13:27:08 +0100 Subject: [PATCH] feat: add cli for `MsgPruneAcknowledgements` (#5482) (cherry picked from commit bf12ce328b7bfab7f7e04e06b85df7ba04c7c6a6) --- modules/core/04-channel/client/cli/cli.go | 4 +- modules/core/04-channel/client/cli/tx.go | 47 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 modules/core/04-channel/client/cli/tx.go diff --git a/modules/core/04-channel/client/cli/cli.go b/modules/core/04-channel/client/cli/cli.go index 450688502e1..ffba7c25af6 100644 --- a/modules/core/04-channel/client/cli/cli.go +++ b/modules/core/04-channel/client/cli/cli.go @@ -49,7 +49,9 @@ func NewTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - txCmd.AddCommand() + txCmd.AddCommand( + NewPruneAcknowledgementsTxCmd(), + ) return txCmd } diff --git a/modules/core/04-channel/client/cli/tx.go b/modules/core/04-channel/client/cli/tx.go new file mode 100644 index 00000000000..12b82a0f584 --- /dev/null +++ b/modules/core/04-channel/client/cli/tx.go @@ -0,0 +1,47 @@ +package cli + +import ( + "fmt" + "strconv" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" +) + +// NewPruneAcknowledgementsTxCmd returns the command to create a new MsgPruneAcknowledgements transaction +func NewPruneAcknowledgementsTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "prune-acknowledgements [port] [channel] [limit]", + Short: "Prune expired packet acknowledgements stored in IBC state", + Long: `Prune expired packet acknowledgements and receipts stored in IBC state. Packet ackwnowledgements and + receipts are considered expired if a channel has been upgraded.`, + Example: fmt.Sprintf("%s tx ibc prune-acknowledgements [port] [channel] [limit]", version.AppName), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + portID, channelID := args[0], args[1] + limit, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return err + } + + signer := clientCtx.GetFromAddress().String() + msg := types.NewMsgPruneAcknowledgements(portID, channelID, limit, signer) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +}