forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cli for
MsgPruneAcknowledgements
(cosmos#5482)
- Loading branch information
1 parent
339655e
commit bf12ce3
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |