Skip to content

Commit

Permalink
chore: fix query cli
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeseung-bae committed May 3, 2024
1 parent 47d684f commit d15f3e5
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions x/fswap/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ func GetQueryCmd(queryRoute string) *cobra.Command {

func CmdQuerySwapped() *cobra.Command {
cmd := &cobra.Command{
Use: "swapped",
Use: "swapped [from_denom] [to_denom]",
Short: "shows the current swap status, including both old and new coin amount",
Args: cobra.NoArgs,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.Swapped(cmd.Context(), &types.QuerySwappedRequest{})
req := &types.QuerySwappedRequest{
FromDenom: args[0],
ToDenom: args[1],
}
res, err := queryClient.Swapped(cmd.Context(), req)
if err != nil {
return err
}
Expand All @@ -56,17 +59,21 @@ func CmdQuerySwapped() *cobra.Command {

func CmdQueryTotalSwappableAmount() *cobra.Command {
cmd := &cobra.Command{
Use: "total-swappable-amount",
Use: "total-swappable-amount [from_denom] [to_denom]",
Short: "shows the current total amount of new coin that're swappable",
Args: cobra.NoArgs,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.TotalSwappableToCoinAmount(cmd.Context(), &types.QueryTotalSwappableToCoinAmountRequest{})
req := &types.QueryTotalSwappableToCoinAmountRequest{
FromDenom: args[0],
ToDenom: args[1],
}
res, err := queryClient.TotalSwappableToCoinAmount(cmd.Context(), req)
if err != nil {
return err
}
Expand Down

0 comments on commit d15f3e5

Please sign in to comment.