Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Superfluid Params Query (backport #1063) #1064

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions proto/osmosis/superfluid/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ option go_package = "github.com/osmosis-labs/osmosis/v7/x/superfluid/types";
// Query defines the gRPC querier service.
service Query {
// Params returns the total set of minting parameters.
rpc Params(ParamsRequest) returns (ParamsResponse) {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/osmosis/superfluid/v1beta1/params";
}

Expand Down Expand Up @@ -114,8 +114,8 @@ service Query {
// }
}

message ParamsRequest {}
message ParamsResponse {
message QueryParamsRequest {}
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
}
Expand Down
33 changes: 33 additions & 0 deletions x/superfluid/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(
GetCmdQueryParams(),
GetCmdAllSuperfluidAssets(),
GetCmdAssetMultiplier(),
GetCmdAllIntermediaryAccounts(),
Expand All @@ -37,6 +38,38 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
return cmd
}

// GetCmdQueryParams implements a command to fetch superfluid parameters.
func GetCmdQueryParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current superfluid parameters",
Args: cobra.NoArgs,
Long: strings.TrimSpace(`Query parameters for the superfluid module:

$ <appd> query superfluid params
`),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryParamsRequest{}
res, err := queryClient.Params(cmd.Context(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(&res.Params)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdAllSuperfluidAssets returns all superfluid enabled assets
func GetCmdAllSuperfluidAssets() *cobra.Command {
cmd := &cobra.Command{
Expand Down
4 changes: 2 additions & 2 deletions x/superfluid/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
var _ types.QueryServer = Keeper{}

// Params returns the superfluid module params
func (k Keeper) Params(goCtx context.Context, req *types.ParamsRequest) (*types.ParamsResponse, error) {
func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

params := k.GetParams(ctx)

return &types.ParamsResponse{
return &types.QueryParamsResponse{
Params: params,
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion x/superfluid/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func (suite *KeeperTestSuite) TestGRPCParams() {
suite.SetupTest()
res, err := suite.App.SuperfluidKeeper.Params(sdk.WrapSDKContext(suite.Ctx), &types.ParamsRequest{})
res, err := suite.App.SuperfluidKeeper.Params(sdk.WrapSDKContext(suite.Ctx), &types.QueryParamsRequest{})
suite.Require().NoError(err)
suite.Require().True(res.Params.MinimumRiskFactor.Equal(types.DefaultParams().MinimumRiskFactor))
}
Expand Down
Loading