Skip to content

Commit

Permalink
chore: add CLI to query swap
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeseung-bae committed May 21, 2024
1 parent 47f6b44 commit 628e3bc
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion x/fswap/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
cmd.AddCommand(
CmdQuerySwapped(),
CmdQueryTotalSwappableAmount(),
CmdQuerySwap(),
CmdQuerySwaps(),
)
return cmd
Expand Down Expand Up @@ -86,10 +87,40 @@ func CmdQueryTotalSwappableAmount() *cobra.Command {
return cmd
}

func CmdQuerySwap() *cobra.Command {
cmd := &cobra.Command{
Use: "swap [from_denom] [to_denom]",
Short: "shows a swap",
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)

req := &types.QuerySwapRequest{
FromDenom: args[0],
ToDenom: args[1],
}

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

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
return cmd
}

func CmdQuerySwaps() *cobra.Command {
cmd := &cobra.Command{
Use: "swaps",
Short: "shows the all the swaps that proposed",
Short: "shows the all the swaps",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
Expand Down

0 comments on commit 628e3bc

Please sign in to comment.