Skip to content

Commit

Permalink
feat: x/cosmwasmpool proto and query boilerplate (#4764)
Browse files Browse the repository at this point in the history
* feat: x/cosmwasmpool proto and query boilerplate

* add basic wiring to keeper

* updates

* Update x/cosmwasmpool/types/expected_keepers.go

* remove instantiate message from pool model

* Update x/cosmwasmpool/types/params.go

Co-authored-by: Adam Tucker <[email protected]>

* Update x/cosmwasmpool/types/params.go

Co-authored-by: Adam Tucker <[email protected]>

* Update x/cosmwasmpool/model/msgs.go

Co-authored-by: Adam Tucker <[email protected]>

* Update x/cosmwasmpool/model/msgs.go

Co-authored-by: Adam Tucker <[email protected]>

---------

Co-authored-by: Adam Tucker <[email protected]>
  • Loading branch information
p0mvn and czarcas7ic authored Mar 29, 2023
1 parent b8689c9 commit 1fb9da8
Show file tree
Hide file tree
Showing 23 changed files with 2,776 additions and 21 deletions.
19 changes: 19 additions & 0 deletions proto/osmosis/cosmwasmpool/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";
package osmosis.cosmwasmpool.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";
import "google/protobuf/duration.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/types";

// Params holds parameters for the cosmwasmpool module
message Params {}

// GenesisState defines the cosmwasmpool module's genesis state.
message GenesisState {
// params is the container of cosmwasmpool parameters.
Params params = 1 [ (gogoproto.nullable) = false ];
}
20 changes: 20 additions & 0 deletions proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package osmosis.cosmwasmpool.v1beta1;

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/model";

message CosmWasmPool {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (cosmos_proto.implements_interface) = "PoolI";
string pool_address = 1 [ (gogoproto.moretags) = "yaml:\"pool_address\"" ];
string contract_address = 2
[ (gogoproto.moretags) = "yaml:\"contract_address\"" ];
uint64 pool_id = 3;
uint64 code_id = 4;
}
25 changes: 25 additions & 0 deletions proto/osmosis/cosmwasmpool/v1beta1/model/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";
package osmosis.cosmwasmpool.v1beta1;

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

option go_package = "github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/model";

service MsgCreator {
rpc CreateCosmWasmPool(MsgCreateCosmWasmPool)
returns (MsgCreateCosmWasmPoolResponse);
}

// ===================== MsgCreateCosmwasmPool
message MsgCreateCosmWasmPool {
uint64 code_id = 1 [ (gogoproto.moretags) = "yaml:\"code_id\"" ];
bytes instantiate_msg = 2
[ (gogoproto.moretags) = "yaml:\"instantiate_msg\"" ];
string sender = 3 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
}

// Returns a unique poolID to identify the pool with.
message MsgCreateCosmWasmPoolResponse {
uint64 pool_id = 1 [ (gogoproto.customname) = "PoolID" ];
}
25 changes: 25 additions & 0 deletions proto/osmosis/cosmwasmpool/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";
package osmosis.cosmwasmpool.v1beta1;

import "gogoproto/gogo.proto";
import "osmosis/cosmwasmpool/v1beta1/genesis.proto";
import "osmosis/cosmwasmpool/v1beta1/tx.proto";

import "cosmos/base/v1beta1/coin.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/client/queryproto";

service Query {
rpc Params(ParamsRequest) returns (ParamsResponse) {
option (google.api.http).get = "/osmosis/cosmwasmpool/v1beta1/Params";
}
}

//=============================== Params
message ParamsRequest {}
message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; }
10 changes: 10 additions & 0 deletions proto/osmosis/cosmwasmpool/v1beta1/query.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
keeper:
path: "github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool"
struct: "Keeper"
client_path: "github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/client"
queries:
Params:
proto_wrapper:
query_func: "k.GetParams"
cli:
cmd: "GetParams"
9 changes: 9 additions & 0 deletions proto/osmosis/cosmwasmpool/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";
package osmosis.cosmwasmpool.v1beta1;

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

option go_package = "github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/types";

service Msg {}
3 changes: 3 additions & 0 deletions proto/osmosis/poolmanager/v1beta1/module_route.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ enum PoolType {
// Concentrated is the pool model specific to concentrated liquidity. It is
// defined in x/concentrated-liquidity.
Concentrated = 2;
// CosmWasm is the pool model specific to CosmWasm. It is defined in
// x/cosmwasmpool.
CosmWasm = 3;
}

// ModuleRouter defines a route encapsulating pool type.
Expand Down
32 changes: 32 additions & 0 deletions x/cosmwasmpool/client/grpc/grpc_query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package grpc

// THIS FILE IS GENERATED CODE, DO NOT EDIT
// SOURCE AT `proto/osmosis/cosmwasmpool/v1beta1/query.yml`

import (
context "context"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/client"
"github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/client/queryproto"
)

type Querier struct {
Q client.Querier
}

var _ queryproto.QueryServer = Querier{}

func (q Querier) Params(grpcCtx context.Context,
req *queryproto.ParamsRequest,
) (*queryproto.ParamsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
ctx := sdk.UnwrapSDKContext(grpcCtx)
return q.Q.Params(ctx, *req)
}

25 changes: 25 additions & 0 deletions x/cosmwasmpool/client/query_proto_wrap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package client

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool"
"github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/client/queryproto"
)

// This file should evolve to being code gen'd, off of `proto/poolmanager/v1beta/query.yml`

type Querier struct {
K cosmwasmpool.Keeper
}

func NewQuerier(k cosmwasmpool.Keeper) Querier {
return Querier{k}
}

func (q Querier) Params(ctx sdk.Context,
req queryproto.ParamsRequest,
) (*queryproto.ParamsResponse, error) {
params := q.K.GetParams(ctx)
return &queryproto.ParamsResponse{Params: params}, nil
}
Loading

0 comments on commit 1fb9da8

Please sign in to comment.