75 lines
1.4 KiB
Go
75 lines
1.4 KiB
Go
|
package cli
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"colinear/x/colinear-core/types"
|
||
|
|
||
|
"github.com/cosmos/cosmos-sdk/client"
|
||
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||
|
"github.com/spf13/cobra"
|
||
|
)
|
||
|
|
||
|
func CmdListAuction() *cobra.Command {
|
||
|
cmd := &cobra.Command{
|
||
|
Use: "list-auction",
|
||
|
Short: "list all auction",
|
||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||
|
clientCtx := client.GetClientContextFromCmd(cmd)
|
||
|
|
||
|
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
queryClient := types.NewQueryClient(clientCtx)
|
||
|
|
||
|
params := &types.QueryAllAuctionRequest{
|
||
|
Pagination: pageReq,
|
||
|
}
|
||
|
|
||
|
res, err := queryClient.AuctionAll(context.Background(), params)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return clientCtx.PrintProto(res)
|
||
|
},
|
||
|
}
|
||
|
|
||
|
flags.AddPaginationFlagsToCmd(cmd, cmd.Use)
|
||
|
flags.AddQueryFlagsToCmd(cmd)
|
||
|
|
||
|
return cmd
|
||
|
}
|
||
|
|
||
|
func CmdShowAuction() *cobra.Command {
|
||
|
cmd := &cobra.Command{
|
||
|
Use: "show-auction [index]",
|
||
|
Short: "shows a auction",
|
||
|
Args: cobra.ExactArgs(1),
|
||
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||
|
clientCtx := client.GetClientContextFromCmd(cmd)
|
||
|
|
||
|
queryClient := types.NewQueryClient(clientCtx)
|
||
|
|
||
|
argIndex := args[0]
|
||
|
|
||
|
params := &types.QueryGetAuctionRequest{
|
||
|
Index: argIndex,
|
||
|
}
|
||
|
|
||
|
res, err := queryClient.Auction(context.Background(), params)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return clientCtx.PrintProto(res)
|
||
|
},
|
||
|
}
|
||
|
|
||
|
flags.AddQueryFlagsToCmd(cmd)
|
||
|
|
||
|
return cmd
|
||
|
}
|