Skip to content

Commit

Permalink
feat: adding clis for total ack and timeout queries (#1043)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored Mar 2, 2022
1 parent 9137084 commit d788adf
Showing 1 changed file with 93 additions and 1 deletion.
94 changes: 93 additions & 1 deletion modules/apps/29-fee/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func GetCmdTotalRecvFees() *cobra.Command {
Short: "Query the total receive fees for a packet",
Long: "Query the total receive fees for a packet",
Args: cobra.ExactArgs(3),
Example: fmt.Sprintf("%s query ibc-fee transfer channel-5 100", version.AppName),
Example: fmt.Sprintf("%s query ibc-fee total-recv-fees transfer channel-5 100", version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
Expand Down Expand Up @@ -57,3 +57,95 @@ func GetCmdTotalRecvFees() *cobra.Command {

return cmd
}

// GetCmdTotalAckFees returns the command handler for the Query/TotalAckFees rpc.
func GetCmdTotalAckFees() *cobra.Command {
cmd := &cobra.Command{
Use: "total-ack-fees [port-id] [channel-id] [sequence]",
Short: "Query the total acknowledgement fees for a packet",
Long: "Query the total acknowledgement fees for a packet",
Args: cobra.ExactArgs(3),
Example: fmt.Sprintf("%s query ibc-fee total-ack-fees transfer channel-5 100", version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

portID, channelID := args[0], args[1]
seq, err := strconv.ParseUint(args[2], 10, 64)
if err != nil {
return err
}

packetID := channeltypes.NewPacketId(channelID, portID, seq)

if err := packetID.Validate(); err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

req := &types.QueryTotalAckFeesRequest{
PacketId: packetID,
}

res, err := queryClient.TotalAckFees(cmd.Context(), req)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdTotalTimeoutFees returns the command handler for the Query/TotalTimeoutFees rpc.
func GetCmdTotalTimeoutFees() *cobra.Command {
cmd := &cobra.Command{
Use: "total-timeout-fees [port-id] [channel-id] [sequence]",
Short: "Query the total timeout fees for a packet",
Long: "Query the total timeout fees for a packet",
Args: cobra.ExactArgs(3),
Example: fmt.Sprintf("%s query ibc-fee total-timeout-fees transfer channel-5 100", version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

portID, channelID := args[0], args[1]
seq, err := strconv.ParseUint(args[2], 10, 64)
if err != nil {
return err
}

packetID := channeltypes.NewPacketId(channelID, portID, seq)

if err := packetID.Validate(); err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

req := &types.QueryTotalTimeoutFeesRequest{
PacketId: packetID,
}

res, err := queryClient.TotalTimeoutFees(cmd.Context(), req)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

0 comments on commit d788adf

Please sign in to comment.