Skip to content

Commit

Permalink
feat: ics29 cli for query total recv fees (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored Mar 1, 2022
1 parent 5f8fc9f commit 4623772
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/apps/29-fee/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func GetQueryCmd() *cobra.Command {
}

queryCmd.AddCommand(
// TODO
GetCmdTotalRecvFees(),
)

return queryCmd
Expand Down
58 changes: 57 additions & 1 deletion modules/apps/29-fee/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
package cli

// TODO
import (
"fmt"
"strconv"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
"github.com/spf13/cobra"
)

// GetCmdTotalRecvFees returns the command handler for the Query/TotalRecvFees rpc.
func GetCmdTotalRecvFees() *cobra.Command {
cmd := &cobra.Command{
Use: "total-recv-fees [port-id] [channel-id] [sequence]",
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),
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.QueryTotalRecvFeesRequest{
PacketId: packetID,
}

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

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

0 comments on commit 4623772

Please sign in to comment.