Skip to content

Commit 217f62d

Browse files
authored
feat(go/cli): add query params for market and deployment (#270)
Signed-off-by: Artur Troian <troian@users.noreply.github.com> Co-authored-by: Artur Troian <troian@users.noreply.github.com>
1 parent 5c5cdea commit 217f62d

File tree

7 files changed

+63
-8
lines changed

7 files changed

+63
-8
lines changed

go/cli/deployment_query.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import (
55

66
sdkclient "github.com/cosmos/cosmos-sdk/client"
77

8+
cflags "pkg.akt.dev/go/cli/flags"
89
"pkg.akt.dev/go/node/deployment/v1"
910
dvbeta "pkg.akt.dev/go/node/deployment/v1beta4"
10-
11-
cflags "pkg.akt.dev/go/cli/flags"
1211
)
1312

1413
// GetQueryDeploymentCmds returns the query commands for the deployment module
@@ -24,6 +23,7 @@ func GetQueryDeploymentCmds() *cobra.Command {
2423
GetQueryDeploymentsCmd(),
2524
GetQueryDeploymentCmd(),
2625
GetQueryDeploymentGroupCmds(),
26+
GetQueryDeploymentParamsCmd(),
2727
)
2828

2929
return cmd
@@ -146,3 +146,28 @@ func GetQueryDeploymentGroupCmd() *cobra.Command {
146146

147147
return cmd
148148
}
149+
150+
func GetQueryDeploymentParamsCmd() *cobra.Command {
151+
cmd := &cobra.Command{
152+
Use: "params",
153+
Short: "Query the current deployment parameters",
154+
PersistentPreRunE: QueryPersistentPreRunE,
155+
RunE: func(cmd *cobra.Command, _ []string) error {
156+
ctx := cmd.Context()
157+
cl := MustLightClientFromContext(ctx)
158+
159+
req := &dvbeta.QueryParamsRequest{}
160+
161+
res, err := cl.Query().Deployment().Params(ctx, req)
162+
if err != nil {
163+
return err
164+
}
165+
166+
return cl.ClientContext().PrintProto(res)
167+
},
168+
}
169+
170+
cflags.AddQueryFlagsToCmd(cmd)
171+
172+
return cmd
173+
}

go/cli/market_query.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func GetQueryMarketCmds() *cobra.Command {
2323
GetQueryMarketOrderCmds(),
2424
GetQueryMarketBidCmds(),
2525
GetQueryMarketLeaseCmds(),
26+
GetQueryMarketParamsCmd(),
2627
)
2728

2829
return cmd
@@ -289,3 +290,28 @@ func GetQueryMarketLeaseCmd() *cobra.Command {
289290

290291
return cmd
291292
}
293+
294+
func GetQueryMarketParamsCmd() *cobra.Command {
295+
cmd := &cobra.Command{
296+
Use: "params",
297+
Short: "Query the current market parameters",
298+
PersistentPreRunE: QueryPersistentPreRunE,
299+
RunE: func(cmd *cobra.Command, _ []string) error {
300+
ctx := cmd.Context()
301+
cl := MustLightClientFromContext(ctx)
302+
303+
req := &mvbeta.QueryParamsRequest{}
304+
305+
res, err := cl.Query().Market().Params(ctx, req)
306+
if err != nil {
307+
return err
308+
}
309+
310+
return cl.ClientContext().PrintProto(res)
311+
},
312+
}
313+
314+
cflags.AddQueryFlagsToCmd(cmd)
315+
316+
return cmd
317+
}

go/cli/oracle_query.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func GetQueryOracleCmd() *cobra.Command {
2020
cmd.AddCommand(
2121
GetOraclePricesCmd(),
2222
GetOracleAggregatedPriceCmd(),
23-
GetOracleParamsCmd(),
23+
GetQueryOracleParamsCmd(),
2424
)
2525

2626
return cmd
@@ -102,7 +102,7 @@ func GetOracleAggregatedPriceCmd() *cobra.Command {
102102
return cmd
103103
}
104104

105-
func GetOracleParamsCmd() *cobra.Command {
105+
func GetQueryOracleParamsCmd() *cobra.Command {
106106
cmd := &cobra.Command{
107107
Use: "params",
108108
Short: "Query the current oracle parameters",

go/cli/oracle_suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ func (s *OracleCLITestSuite) TestCLIQueryOracleParams() {
571571

572572
for _, tc := range testCases {
573573
s.Run(tc.name, func() {
574-
cmd := cli.GetOracleParamsCmd()
574+
cmd := cli.GetQueryOracleParamsCmd()
575575
cmd.SetArgs(tc.args)
576576
s.Require().Contains(fmt.Sprint(cmd), strings.TrimSpace(tc.expCmdOutput))
577577
})
@@ -600,7 +600,7 @@ func (s *OracleCLITestSuite) TestCLIQueryOracleParamsExec() {
600600

601601
for _, tc := range testCases {
602602
s.Run(tc.name, func() {
603-
cmd := cli.GetOracleParamsCmd()
603+
cmd := cli.GetQueryOracleParamsCmd()
604604
out, err := clitestutil.ExecTestCLICmd(s.ctx, s.cctx, cmd, tc.args...)
605605

606606
if tc.expectErr {

go/cli/testutil/oracle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ func ExecQueryOraclePrices(ctx context.Context, cctx client.Context, args ...str
2121

2222
// ExecQueryOracleParams is used for testing oracle params query
2323
func ExecQueryOracleParams(ctx context.Context, cctx client.Context, args ...string) (sdktest.BufferWriter, error) {
24-
return ExecTestCLICmd(ctx, cctx, cli.GetOracleParamsCmd(), args...)
24+
return ExecTestCLICmd(ctx, cctx, cli.GetQueryOracleParamsCmd(), args...)
2525
}

go/node/market/v1beta5/params.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ func (p Params) Validate() error {
5656
if err := validateOrderMaxBids(p.OrderMaxBids); err != nil {
5757
return err
5858
}
59+
60+
if err := validateCoins(p.BidMinDeposits); err != nil {
61+
return err
62+
}
63+
5964
return nil
6065
}
6166

proto/node/akash/market/v1beta5/params.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ message Params {
3232
(gogoproto.jsontag) = "bid_min_deposits",
3333
(gogoproto.moretags) = "yaml:\"bid_min_deposits\""
3434
];
35-
3635
}

0 commit comments

Comments
 (0)