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

Cli module query params #8504

Merged
merged 6 commits into from
Jul 26, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### State Compatible
* [#8494](https://github.com/osmosis-labs/osmosis/pull/8494) Add additional events in x/lockup, x/superfluid, x/concentratedliquidity

* [#8504](https://github.com/osmosis-labs/osmosis/pull/8504) Add missing module params query to CLI

## v25.2.0

* [#8455](https://github.com/osmosis-labs/osmosis/pull/8455) Further comet mempool improvements
Expand Down
29 changes: 26 additions & 3 deletions cmd/osmosisd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ func overwriteConfigTomlValues(serverCtx *server.Context) error {
}()

// Check if the file is writable
if fileInfo.Mode()&os.FileMode(0200) != 0 {
if fileInfo.Mode()&os.FileMode(0o200) != 0 {
// It will be re-read in server.InterceptConfigsPreRunHandler
// this may panic for permissions issues. So we catch the panic.
// Note that this exits with a non-zero exit code if fails to write the file.
Expand Down Expand Up @@ -585,7 +585,7 @@ func overwriteAppTomlValues(serverCtx *server.Context) error {
}

// Check if the file is writable
if fileInfo.Mode()&os.FileMode(0200) != 0 {
if fileInfo.Mode()&os.FileMode(0o200) != 0 {
// It will be re-read in server.InterceptConfigsPreRunHandler
// this may panic for permissions issues. So we catch the panic.
// Note that this exits with a non-zero exit code if fails to write the file.
Expand Down Expand Up @@ -640,7 +640,7 @@ func initAppConfig() (string, interface{}) {
WasmConfig wasmtypes.WasmConfig `mapstructure:"wasm"`
}

var DefaultOsmosisMempoolConfig = OsmosisMempoolConfig{
DefaultOsmosisMempoolConfig := OsmosisMempoolConfig{
MaxGasWantedPerTx: "60000000",
MinGasPriceForArbitrageTx: ".1",
MinGasPriceForHighGasTx: ".0025",
Expand Down Expand Up @@ -816,6 +816,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, t
txCommand(tempApp.ModuleBasics),
keys.Commands(),
)
rootCmd.AddCommand(CmdListQueries(rootCmd))
// add rosetta
rootCmd.AddCommand(rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler))
}
Expand All @@ -826,6 +827,28 @@ func addModuleInitFlags(startCmd *cobra.Command) {
startCmd.Flags().Bool(FlagRejectConfigDefaults, false, "Reject some select recommended default values from being automatically set in the config.toml and app.toml")
}

// CmdListQueries list all available modules' queries
func CmdListQueries(rootCmd *cobra.Command) *cobra.Command {
cmd := &cobra.Command{
Use: "list-queries",
Short: "listing all available modules' queries",
RunE: func(cmd *cobra.Command, args []string) error {
for _, cmd := range rootCmd.Commands() {
if cmd.Name() != "query" {
continue
}
for _, cmd := range cmd.Commands() {
for _, cmd := range cmd.Commands() {
fmt.Println(cmd.CommandPath())
}
}
}
return nil
},
}
return cmd
}

func CmdModuleNameToAddress() *cobra.Command {
cmd := &cobra.Command{
Use: "module-name-to-address [module-name]",
Expand Down
10 changes: 1 addition & 9 deletions proto/osmosis/gamm/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "osmosis/gamm/v1beta1/shared.proto";

// Params holds parameters for the incentives module
message Params {
repeated cosmos.base.v1beta1.Coin pool_creation_fee = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"pool_creation_fee\"",
(gogoproto.nullable) = false
];
}
import "osmosis/gamm/v1beta1/params.proto";

option go_package = "github.com/osmosis-labs/osmosis/v25/x/gamm/types";

Expand Down
17 changes: 17 additions & 0 deletions proto/osmosis/gamm/v1beta1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";
package osmosis.gamm.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/osmosis-labs/osmosis/v25/x/gamm/types";

// Params holds parameters for the incentives module
message Params {
repeated cosmos.base.v1beta1.Coin pool_creation_fee = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"pool_creation_fee\"",
(gogoproto.nullable) = false
];
}
10 changes: 10 additions & 0 deletions proto/osmosis/gamm/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "google/api/annotations.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";
import "osmosis/gamm/v1beta1/shared.proto";
import "osmosis/gamm/v1beta1/params.proto";

option go_package = "github.com/osmosis-labs/osmosis/v25/x/gamm/types";

Expand Down Expand Up @@ -124,8 +125,17 @@ service Query {
option (google.api.http).get =
"/osmosis/gamm/v1beta1/cfmm_concentrated_pool_links";
}

// Params returns gamm module params.
rpc Params(ParamsRequest) returns (ParamsResponse) {
option (google.api.http).get = "/osmosis/gamm/v1beta1/params";
}
}

//=============================== Params
message ParamsRequest {}
message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; }

//=============================== Pool
// Deprecated: please use the alternative in x/poolmanager
message QueryPoolRequest {
Expand Down
10 changes: 9 additions & 1 deletion proto/osmosis/incentives/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "cosmos/base/query/v1beta1/pagination.proto";
import "osmosis/incentives/gauge.proto";
import "osmosis/lockup/lock.proto";
import "osmosis/incentives/group.proto";
import "osmosis/incentives/params.proto";

option go_package = "github.com/osmosis-labs/osmosis/v25/x/incentives/types";

Expand Down Expand Up @@ -95,6 +96,10 @@ service Query {
"/osmosis/incentives/v1beta1/current_weight_by_group_gauge_id/"
"{group_gauge_id}";
}
// Params returns incentives module params.
rpc Params(ParamsRequest) returns (ParamsResponse) {
option (google.api.http).get = "/osmosis/incentives/v1beta1/params";
}
}

message ModuleToDistributeCoinsRequest {}
Expand Down Expand Up @@ -236,4 +241,7 @@ message GaugeWeight {
(gogoproto.moretags) = "yaml:\"weight_ratio\"",
(gogoproto.nullable) = false
];
}
}

message ParamsRequest {}
message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; }
4 changes: 4 additions & 0 deletions x/gamm/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func GetQueryCmd() *cobra.Command {
osmocli.AddQueryCmd(cmd, types.NewQueryClient, GetCmdEstimateSwapExactAmountOut)
osmocli.AddQueryCmd(cmd, types.NewQueryClient, GetConcentratedPoolIdLinkFromCFMMRequest)
osmocli.AddQueryCmd(cmd, types.NewQueryClient, GetCFMMConcentratedPoolLinksRequest)
cmd.AddCommand(
osmocli.GetParams[*types.ParamsRequest](
types.ModuleName, types.NewQueryClient),
)
cmd.AddCommand(
GetCmdNumPools(),
GetCmdPoolParams(),
Expand Down
11 changes: 11 additions & 0 deletions x/gamm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ func NewV2Querier(k Keeper) QuerierV2 {
return QuerierV2{Keeper: k}
}

func (q Querier) Params(ctx context.Context, req *types.ParamsRequest) (*types.ParamsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
sdkCtx := sdk.UnwrapSDKContext(ctx)
params := q.Keeper.GetParams(sdkCtx)
return &types.ParamsResponse{
Params: params,
}, nil
}

// Pool checks if a pool exists and their respective poolWeights.
// Deprecated: use x/poolmanager's Pool query.
// nolint: staticcheck
Expand Down
11 changes: 11 additions & 0 deletions x/gamm/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ import (
poolmanagertypes "github.com/osmosis-labs/osmosis/v25/x/poolmanager/types"
)

func (s *KeeperTestSuite) TestParams() {
queryClient := s.queryClient
ctx := s.Ctx

expectedParams := s.App.GAMMKeeper.GetParams(s.Ctx)

params, err := queryClient.Params(ctx, &types.ParamsRequest{})
s.Require().NoError(err)
s.Require().Equal(expectedParams, params.Params)
}

func (s *KeeperTestSuite) TestCalcExitPoolCoinsFromShares() {
queryClient := s.queryClient
ctx := s.Ctx
Expand Down
Loading