-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(cherry picked from commit 55992eb) Co-authored-by: Teddy Ding <[email protected]>
- Loading branch information
1 parent
c6ba7d5
commit 42ad83c
Showing
4 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
protocol/x/perpetuals/client/cli/query_all_liquidity_tiers.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func CmdQueryAllLiquidityTiers() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "get-all-liquidity-tiers", | ||
Short: "get all liquidity tiers", | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
clientCtx := client.GetClientContextFromCmd(cmd) | ||
queryClient := types.NewQueryClient(clientCtx) | ||
res, err := queryClient.AllLiquidityTiers( | ||
context.Background(), | ||
&types.QueryAllLiquidityTiersRequest{}, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
28 changes: 28 additions & 0 deletions
28
protocol/x/perpetuals/client/cli/query_all_liquidity_tiers_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//go:build all || integration_test | ||
|
||
package cli_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
tmcli "github.com/cometbft/cometbft/libs/cli" | ||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/client/cli" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAllLiquidityTiers(t *testing.T) { | ||
net, _, _ := networkWithLiquidityTierAndPerpetualObjects(t, 2, 2) | ||
ctx := net.Validators[0].ClientCtx | ||
|
||
common := []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)} | ||
|
||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdQueryAllLiquidityTiers(), common) | ||
require.NoError(t, err) | ||
|
||
var resp types.QueryAllLiquidityTiersResponse | ||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) | ||
require.Equal(t, 2, len(resp.LiquidityTiers)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters