Skip to content

Commit

Permalink
feat: add cli for MsgPruneAcknowledgements (cosmos#5482)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored Jan 8, 2024
1 parent 339655e commit bf12ce3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
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
}

0 comments on commit bf12ce3

Please sign in to comment.