-
Notifications
You must be signed in to change notification settings - Fork 209
/
bid.go
98 lines (77 loc) · 1.89 KB
/
bid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package cli
import (
sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
types "github.com/akash-network/akash-api/go/node/market/v1beta4"
aclient "github.com/akash-network/node/client"
)
func cmdGetBids() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "Query for all bids",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
cctx, err := sdkclient.GetClientQueryContext(cmd)
if err != nil {
return err
}
qq, err := aclient.DiscoverQueryClient(ctx, cctx)
if err != nil {
return err
}
bfilters, err := BidFiltersFromFlags(cmd.Flags())
if err != nil {
return err
}
pageReq, err := sdkclient.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}
params := &types.QueryBidsRequest{
Filters: bfilters,
Pagination: pageReq,
}
res, err := qq.Bids(cmd.Context(), params)
if err != nil {
return err
}
return qq.ClientContext().PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "bids")
AddBidFilterFlags(cmd.Flags())
return cmd
}
func cmdGetBid() *cobra.Command {
cmd := &cobra.Command{
Use: "get",
Short: "Query order",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
cctx, err := sdkclient.GetClientQueryContext(cmd)
if err != nil {
return err
}
qq, err := aclient.DiscoverQueryClient(ctx, cctx)
if err != nil {
return err
}
bidID, err := BidIDFromFlags(cmd.Flags())
if err != nil {
return err
}
res, err := qq.Bid(cmd.Context(), &types.QueryBidRequest{ID: bidID})
if err != nil {
return err
}
return qq.ClientContext().PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
AddQueryBidIDFlags(cmd.Flags())
MarkReqBidIDFlags(cmd)
return cmd
}