Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: add cli for MsgPruneAcknowledgements (backport #5482) #5543

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 3 additions & 1 deletion modules/core/04-channel/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func NewTxCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

txCmd.AddCommand()
txCmd.AddCommand(
NewPruneAcknowledgementsTxCmd(),
)

return txCmd
}
47 changes: 47 additions & 0 deletions modules/core/04-channel/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -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
}
Loading