diff --git a/query.pb.gw.go b/api/v1/query.pb.gw.go similarity index 98% rename from query.pb.gw.go rename to api/v1/query.pb.gw.go index 35adba8..1b42f65 100644 --- a/query.pb.gw.go +++ b/api/v1/query.pb.gw.go @@ -2,11 +2,11 @@ // source: cosmosregistry/example/v1/query.proto /* -Package example is a reverse proxy. +Package examplev1 is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package example +package examplev1 import ( "context" @@ -321,11 +321,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Counter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmosregistry", "example", "v1", "counter", "address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Counter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmosregistry", "example", "v1", "counter", "address"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Counters_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmosregistry", "example", "v1", "counters"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Counters_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmosregistry", "example", "v1", "counters"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmosregistry", "example", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmosregistry", "example", "v1", "params"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/codec.go b/codec.go index 857c13b..13c105d 100644 --- a/codec.go +++ b/codec.go @@ -4,13 +4,15 @@ import ( types "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + + examplev1 "github.com/cosmosregistry/example/api/v1" ) // RegisterInterfaces registers the interfaces types with the interface registry. func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgUpdateParams{}, - &MsgIncrementCounter{}, + &examplev1.MsgUpdateParams{}, + &examplev1.MsgIncrementCounter{}, ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &examplev1.Msg_ServiceDesc) } diff --git a/genesis.go b/genesis.go index 0d86df4..f56bb19 100644 --- a/genesis.go +++ b/genesis.go @@ -1,14 +1,16 @@ package example +import examplev1 "github.com/cosmosregistry/example/api/v1" + // NewGenesisState creates a new genesis state with default values. -func NewGenesisState() *GenesisState { - return &GenesisState{ +func NewGenesisState() *examplev1.GenesisState { + return &examplev1.GenesisState{ Params: DefaultParams(), } } -// Validate performs basic genesis state validation returning an error upon any -func (gs *GenesisState) Validate() error { +// ValidateGenesis performs basic genesis state validation returning an error upon any +func ValidateGenesis(gs *examplev1.GenesisState) error { uniq := make(map[string]bool) for _, counter := range gs.Counters { if _, ok := uniq[counter.Address]; ok { @@ -18,7 +20,7 @@ func (gs *GenesisState) Validate() error { uniq[counter.Address] = true } - if err := gs.Params.Validate(); err != nil { + if err := ValidateParams(gs.Params); err != nil { return err } diff --git a/keeper/genesis.go b/keeper/genesis.go index 5645f43..d7ed139 100644 --- a/keeper/genesis.go +++ b/keeper/genesis.go @@ -3,12 +3,12 @@ package keeper import ( "context" - "github.com/cosmosregistry/example" + examplev1 "github.com/cosmosregistry/example/api/v1" ) // InitGenesis initializes the module state from a genesis state. -func (k *Keeper) InitGenesis(ctx context.Context, data *example.GenesisState) error { - if err := k.Params.Set(ctx, data.Params); err != nil { +func (k *Keeper) InitGenesis(ctx context.Context, data *examplev1.GenesisState) error { + if err := k.Params.Set(ctx, *data.Params); err != nil { // TODO: not good. return err } @@ -22,15 +22,15 @@ func (k *Keeper) InitGenesis(ctx context.Context, data *example.GenesisState) er } // ExportGenesis exports the module state to a genesis state. -func (k *Keeper) ExportGenesis(ctx context.Context) (*example.GenesisState, error) { +func (k *Keeper) ExportGenesis(ctx context.Context) (*examplev1.GenesisState, error) { params, err := k.Params.Get(ctx) if err != nil { return nil, err } - var counters []example.Counter + var counters []*examplev1.Counter if err := k.Counter.Walk(ctx, nil, func(address string, count uint64) (bool, error) { - counters = append(counters, example.Counter{ + counters = append(counters, &examplev1.Counter{ Address: address, Count: count, }) @@ -40,8 +40,8 @@ func (k *Keeper) ExportGenesis(ctx context.Context) (*example.GenesisState, erro return nil, err } - return &example.GenesisState{ - Params: params, + return &examplev1.GenesisState{ + Params: ¶ms, Counters: counters, }, nil } diff --git a/keeper/genesis_test.go b/keeper/genesis_test.go index d7b59fa..ff20d6e 100644 --- a/keeper/genesis_test.go +++ b/keeper/genesis_test.go @@ -4,14 +4,15 @@ import ( "testing" "github.com/cosmosregistry/example" + examplev1 "github.com/cosmosregistry/example/api/v1" "github.com/stretchr/testify/require" ) func TestInitGenesis(t *testing.T) { fixture := initFixture(t) - data := &example.GenesisState{ - Counters: []example.Counter{ + data := &examplev1.GenesisState{ + Counters: []*examplev1.Counter{ { Address: fixture.addrs[0].String(), Count: 5, @@ -35,7 +36,7 @@ func TestInitGenesis(t *testing.T) { func TestExportGenesis(t *testing.T) { fixture := initFixture(t) - _, err := fixture.msgServer.IncrementCounter(fixture.ctx, &example.MsgIncrementCounter{ + _, err := fixture.msgServer.IncrementCounter(fixture.ctx, &examplev1.MsgIncrementCounter{ Sender: fixture.addrs[0].String(), }) require.NoError(t, err) diff --git a/keeper/keeper.go b/keeper/keeper.go index f331bce..30ec3cb 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmosregistry/example" + examplev1 "github.com/cosmosregistry/example/api/v1" ) type Keeper struct { @@ -21,7 +22,7 @@ type Keeper struct { // state management Schema collections.Schema - Params collections.Item[example.Params] + Params collections.Item[examplev1.Params] Counter collections.Map[string, uint64] } @@ -36,7 +37,7 @@ func NewKeeper(cdc codec.BinaryCodec, addressCodec address.Codec, storeService s cdc: cdc, addressCodec: addressCodec, authority: authority, - Params: collections.NewItem(sb, example.ParamsKey, "params", codec.CollValue[example.Params](cdc)), + Params: collections.NewItem(sb, example.ParamsKey, "params", codec.CollValue[examplev1.Params](cdc)), Counter: collections.NewMap(sb, example.CounterKey, "counter", collections.StringKey, collections.Uint64Value), } diff --git a/keeper/keeper_test.go b/keeper/keeper_test.go index d7eba28..9f75c7f 100644 --- a/keeper/keeper_test.go +++ b/keeper/keeper_test.go @@ -12,14 +12,15 @@ import ( moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmosregistry/example" + examplev1 "github.com/cosmosregistry/example/api/v1" "github.com/cosmosregistry/example/keeper" ) type testFixture struct { ctx sdk.Context k keeper.Keeper - msgServer example.MsgServer - queryServer example.QueryServer + msgServer examplev1.MsgServer + queryServer examplev1.QueryServer addrs []sdk.AccAddress } diff --git a/keeper/msg_server.go b/keeper/msg_server.go index 139c470..443f4c7 100644 --- a/keeper/msg_server.go +++ b/keeper/msg_server.go @@ -8,21 +8,24 @@ import ( "cosmossdk.io/collections" "github.com/cosmosregistry/example" + examplev1 "github.com/cosmosregistry/example/api/v1" ) type msgServer struct { + examplev1.UnimplementedMsgServer + k Keeper } -var _ example.MsgServer = msgServer{} +var _ examplev1.MsgServer = msgServer{} // NewMsgServerImpl returns an implementation of the module MsgServer interface. -func NewMsgServerImpl(keeper Keeper) example.MsgServer { +func NewMsgServerImpl(keeper Keeper) examplev1.MsgServer { return &msgServer{k: keeper} } // IncrementCounter defines the handler for the MsgIncrementCounter message. -func (ms msgServer) IncrementCounter(ctx context.Context, msg *example.MsgIncrementCounter) (*example.MsgIncrementCounterResponse, error) { +func (ms msgServer) IncrementCounter(ctx context.Context, msg *examplev1.MsgIncrementCounter) (*examplev1.MsgIncrementCounterResponse, error) { if _, err := ms.k.addressCodec.StringToBytes(msg.Sender); err != nil { return nil, fmt.Errorf("invalid sender address: %w", err) } @@ -38,11 +41,11 @@ func (ms msgServer) IncrementCounter(ctx context.Context, msg *example.MsgIncrem return nil, err } - return &example.MsgIncrementCounterResponse{}, nil + return &examplev1.MsgIncrementCounterResponse{}, nil } // UpdateParams params is defining the handler for the MsgUpdateParams message. -func (ms msgServer) UpdateParams(ctx context.Context, msg *example.MsgUpdateParams) (*example.MsgUpdateParamsResponse, error) { +func (ms msgServer) UpdateParams(ctx context.Context, msg *examplev1.MsgUpdateParams) (*examplev1.MsgUpdateParamsResponse, error) { if _, err := ms.k.addressCodec.StringToBytes(msg.Authority); err != nil { return nil, fmt.Errorf("invalid authority address: %w", err) } @@ -51,13 +54,13 @@ func (ms msgServer) UpdateParams(ctx context.Context, msg *example.MsgUpdatePara return nil, fmt.Errorf("unauthorized, authority does not match the module's authority: got %s, want %s", msg.Authority, authority) } - if err := msg.Params.Validate(); err != nil { + if err := example.ValidateParams(msg.Params); err != nil { return nil, err } - if err := ms.k.Params.Set(ctx, msg.Params); err != nil { + if err := ms.k.Params.Set(ctx, *msg.Params); err != nil { // TODO: not good. return nil, err } - return &example.MsgUpdateParamsResponse{}, nil + return &examplev1.MsgUpdateParamsResponse{}, nil } diff --git a/keeper/msg_server_test.go b/keeper/msg_server_test.go index 2c6447c..b9e5372 100644 --- a/keeper/msg_server_test.go +++ b/keeper/msg_server_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/cosmosregistry/example" + examplev1 "github.com/cosmosregistry/example/api/v1" "github.com/stretchr/testify/require" ) @@ -14,28 +14,28 @@ func TestUpdateParams(t *testing.T) { testCases := []struct { name string - request *example.MsgUpdateParams + request *examplev1.MsgUpdateParams expectErrMsg string }{ { name: "set invalid authority (not an address)", - request: &example.MsgUpdateParams{ + request: &examplev1.MsgUpdateParams{ Authority: "foo", }, expectErrMsg: "invalid authority address", }, { name: "set invalid authority (not defined authority)", - request: &example.MsgUpdateParams{ + request: &examplev1.MsgUpdateParams{ Authority: f.addrs[1].String(), }, expectErrMsg: fmt.Sprintf("unauthorized, authority does not match the module's authority: got %s, want %s", f.addrs[1].String(), f.k.GetAuthority()), }, { name: "set valid params", - request: &example.MsgUpdateParams{ + request: &examplev1.MsgUpdateParams{ Authority: f.k.GetAuthority(), - Params: example.Params{}, + Params: &examplev1.Params{}, }, expectErrMsg: "", }, @@ -61,20 +61,20 @@ func TestIncrementCounter(t *testing.T) { testCases := []struct { name string - request *example.MsgIncrementCounter + request *examplev1.MsgIncrementCounter expectErrMsg string expectedCounter uint64 }{ { name: "set invalid sender (not an address)", - request: &example.MsgIncrementCounter{ + request: &examplev1.MsgIncrementCounter{ Sender: "foo", }, expectErrMsg: "invalid sender address", }, { name: "set valid sender", - request: &example.MsgIncrementCounter{ + request: &examplev1.MsgIncrementCounter{ Sender: "cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5", }, expectErrMsg: "", diff --git a/keeper/query_server.go b/keeper/query_server.go index 359676e..9abce17 100644 --- a/keeper/query_server.go +++ b/keeper/query_server.go @@ -9,23 +9,26 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + queryv1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmosregistry/example" + examplev1 "github.com/cosmosregistry/example/api/v1" ) -var _ example.QueryServer = queryServer{} +var _ examplev1.QueryServer = queryServer{} // NewQueryServerImpl returns an implementation of the module QueryServer. -func NewQueryServerImpl(k Keeper) example.QueryServer { - return queryServer{k} +func NewQueryServerImpl(k Keeper) examplev1.QueryServer { + return queryServer{k: k} } type queryServer struct { + examplev1.UnimplementedQueryServer + k Keeper } // Counter defines the handler for the Query/Counter RPC method. -func (qs queryServer) Counter(ctx context.Context, req *example.QueryCounterRequest) (*example.QueryCounterResponse, error) { +func (qs queryServer) Counter(ctx context.Context, req *examplev1.QueryCounterRequest) (*examplev1.QueryCounterResponse, error) { if _, err := qs.k.addressCodec.StringToBytes(req.Address); err != nil { return nil, fmt.Errorf("invalid sender address: %w", err) } @@ -33,23 +36,31 @@ func (qs queryServer) Counter(ctx context.Context, req *example.QueryCounterRequ counter, err := qs.k.Counter.Get(ctx, req.Address) if err != nil { if errors.Is(err, collections.ErrNotFound) { - return &example.QueryCounterResponse{Counter: 0}, nil + return &examplev1.QueryCounterResponse{Counter: 0}, nil } return nil, status.Error(codes.Internal, err.Error()) } - return &example.QueryCounterResponse{Counter: counter}, nil + return &examplev1.QueryCounterResponse{Counter: counter}, nil } // Counters defines the handler for the Query/Counters RPC method. -func (qs queryServer) Counters(ctx context.Context, req *example.QueryCountersRequest) (*example.QueryCountersResponse, error) { +func (qs queryServer) Counters(ctx context.Context, req *examplev1.QueryCountersRequest) (*examplev1.QueryCountersResponse, error) { + reqPagination := &query.PageRequest{ + Key: req.Pagination.Key, + Offset: req.Pagination.Offset, + Limit: req.Pagination.Limit, + CountTotal: req.Pagination.CountTotal, + Reverse: req.Pagination.Reverse, + } + counters, pageRes, err := query.CollectionPaginate( ctx, qs.k.Counter, - req.Pagination, - func(key string, value uint64) (*example.Counter, error) { - return &example.Counter{ + reqPagination, + func(key string, value uint64) (*examplev1.Counter, error) { + return &examplev1.Counter{ Address: key, Count: value, }, nil @@ -58,19 +69,24 @@ func (qs queryServer) Counters(ctx context.Context, req *example.QueryCountersRe return nil, err } - return &example.QueryCountersResponse{Counters: counters, Pagination: pageRes}, nil + respPagination := &queryv1beta1.PageResponse{ + NextKey: pageRes.NextKey, + Total: pageRes.Total, + } // TODO have helper in the SDK for this. + + return &examplev1.QueryCountersResponse{Counters: counters, Pagination: respPagination}, nil } // Params defines the handler for the Query/Params RPC method. -func (qs queryServer) Params(ctx context.Context, req *example.QueryParamsRequest) (*example.QueryParamsResponse, error) { +func (qs queryServer) Params(ctx context.Context, req *examplev1.QueryParamsRequest) (*examplev1.QueryParamsResponse, error) { params, err := qs.k.Params.Get(ctx) if err != nil { if errors.Is(err, collections.ErrNotFound) { - return &example.QueryParamsResponse{Params: example.Params{}}, nil + return &examplev1.QueryParamsResponse{Params: &examplev1.Params{}}, nil } return nil, status.Error(codes.Internal, err.Error()) } - return &example.QueryParamsResponse{Params: params}, nil + return &examplev1.QueryParamsResponse{Params: ¶ms}, nil } diff --git a/keeper/query_server_test.go b/keeper/query_server_test.go index 89ae027..31cd278 100644 --- a/keeper/query_server_test.go +++ b/keeper/query_server_test.go @@ -3,32 +3,33 @@ package keeper_test import ( "testing" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmosregistry/example" + queryv1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" "github.com/stretchr/testify/require" + + examplev1 "github.com/cosmosregistry/example/api/v1" ) func TestQueryParams(t *testing.T) { f := initFixture(t) require := require.New(t) - resp, err := f.queryServer.Params(f.ctx, &example.QueryParamsRequest{}) + resp, err := f.queryServer.Params(f.ctx, &examplev1.QueryParamsRequest{}) require.NoError(err) - require.Equal(example.Params{}, resp.Params) + require.Equal(examplev1.Params{}, resp.Params) } func TestQueryCounter(t *testing.T) { f := initFixture(t) require := require.New(t) - resp, err := f.queryServer.Counter(f.ctx, &example.QueryCounterRequest{Address: f.addrs[0].String()}) + resp, err := f.queryServer.Counter(f.ctx, &examplev1.QueryCounterRequest{Address: f.addrs[0].String()}) require.NoError(err) require.Equal(uint64(0), resp.Counter) - _, err = f.msgServer.IncrementCounter(f.ctx, &example.MsgIncrementCounter{Sender: f.addrs[0].String()}) + _, err = f.msgServer.IncrementCounter(f.ctx, &examplev1.MsgIncrementCounter{Sender: f.addrs[0].String()}) require.NoError(err) - resp, err = f.queryServer.Counter(f.ctx, &example.QueryCounterRequest{Address: f.addrs[0].String()}) + resp, err = f.queryServer.Counter(f.ctx, &examplev1.QueryCounterRequest{Address: f.addrs[0].String()}) require.NoError(err) require.Equal(uint64(1), resp.Counter) } @@ -37,14 +38,14 @@ func TestQueryCounters(t *testing.T) { f := initFixture(t) require := require.New(t) - resp, err := f.queryServer.Counters(f.ctx, &example.QueryCountersRequest{}) + resp, err := f.queryServer.Counters(f.ctx, &examplev1.QueryCountersRequest{}) require.NoError(err) require.Equal(0, len(resp.Counters)) - _, err = f.msgServer.IncrementCounter(f.ctx, &example.MsgIncrementCounter{Sender: f.addrs[0].String()}) + _, err = f.msgServer.IncrementCounter(f.ctx, &examplev1.MsgIncrementCounter{Sender: f.addrs[0].String()}) require.NoError(err) - resp, err = f.queryServer.Counters(f.ctx, &example.QueryCountersRequest{}) + resp, err = f.queryServer.Counters(f.ctx, &examplev1.QueryCountersRequest{}) require.NoError(err) require.Equal(1, len(resp.Counters)) require.Equal(uint64(1), resp.Counters[0].Count) @@ -55,22 +56,22 @@ func TestQueryCountersPaginated(t *testing.T) { f := initFixture(t) require := require.New(t) - resp, err := f.queryServer.Counters(f.ctx, &example.QueryCountersRequest{Pagination: &query.PageRequest{Limit: 1}}) + resp, err := f.queryServer.Counters(f.ctx, &examplev1.QueryCountersRequest{Pagination: &queryv1beta1.PageRequest{Limit: 1}}) require.NoError(err) require.Equal(0, len(resp.Counters)) - _, err = f.msgServer.IncrementCounter(f.ctx, &example.MsgIncrementCounter{Sender: f.addrs[0].String()}) + _, err = f.msgServer.IncrementCounter(f.ctx, &examplev1.MsgIncrementCounter{Sender: f.addrs[0].String()}) require.NoError(err) - _, err = f.msgServer.IncrementCounter(f.ctx, &example.MsgIncrementCounter{Sender: f.addrs[1].String()}) + _, err = f.msgServer.IncrementCounter(f.ctx, &examplev1.MsgIncrementCounter{Sender: f.addrs[1].String()}) require.NoError(err) - resp, err = f.queryServer.Counters(f.ctx, &example.QueryCountersRequest{Pagination: &query.PageRequest{Limit: 1}}) + resp, err = f.queryServer.Counters(f.ctx, &examplev1.QueryCountersRequest{Pagination: &queryv1beta1.PageRequest{Limit: 1}}) require.NoError(err) require.Equal(1, len(resp.Counters)) require.Equal(uint64(1), resp.Counters[0].Count) require.Equal(f.addrs[1].String(), resp.Counters[0].Address) - resp, err = f.queryServer.Counters(f.ctx, &example.QueryCountersRequest{}) + resp, err = f.queryServer.Counters(f.ctx, &examplev1.QueryCountersRequest{}) require.NoError(err) require.Equal(2, len(resp.Counters)) } diff --git a/module/module.go b/module/module.go index c4f2620..02acf1b 100644 --- a/module/module.go +++ b/module/module.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmosregistry/example" + examplev1 "github.com/cosmosregistry/example/api/v1" "github.com/cosmosregistry/example/keeper" ) @@ -53,7 +54,7 @@ func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the example module. func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { - if err := example.RegisterQueryHandlerClient(context.Background(), mux, example.NewQueryClient(clientCtx)); err != nil { + if err := examplev1.RegisterQueryHandlerClient(context.Background(), mux, examplev1.NewQueryClient(clientCtx)); err != nil { panic(err) } } @@ -68,8 +69,8 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - example.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) - example.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) + examplev1.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + examplev1.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) // Register in place module state migration migrations // m := keeper.NewMigrator(am.keeper) @@ -85,18 +86,18 @@ func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { // ValidateGenesis performs genesis state validation for the circuit module. func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { - var data example.GenesisState + var data examplev1.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", example.ModuleName, err) } - return data.Validate() + return example.ValidateGenesis(&data) } // InitGenesis performs genesis initialization for the example module. // It returns no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { - var genesisState example.GenesisState + var genesisState examplev1.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil { diff --git a/params.go b/params.go index 4f52450..b03ea63 100644 --- a/params.go +++ b/params.go @@ -1,14 +1,16 @@ package example +import examplev1 "github.com/cosmosregistry/example/api/v1" + // DefaultParams returns default module parameters. -func DefaultParams() Params { - return Params{ +func DefaultParams() *examplev1.Params { + return &examplev1.Params{ // Set default values here. } } -// Validate does the sanity check on the params. -func (p Params) Validate() error { +// ValidateParams does the sanity check on the params. +func ValidateParams(p *examplev1.Params) error { // Sanity check goes here. return nil } diff --git a/proto/buf.gen.gogo.yaml b/proto/buf.gen.gogo.yaml deleted file mode 100644 index e3cd0b1..0000000 --- a/proto/buf.gen.gogo.yaml +++ /dev/null @@ -1,8 +0,0 @@ -version: v1 -plugins: - - name: gocosmos - out: .. - opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,Mcosmos/orm/v1/orm.proto=cosmossdk.io/orm - - name: grpc-gateway - out: .. - opt: logtostderr=true,allow_colon_final_segments=true diff --git a/proto/buf.gen.pulsar.yaml b/proto/buf.gen.yaml similarity index 92% rename from proto/buf.gen.pulsar.yaml rename to proto/buf.gen.yaml index 41f5309..596d939 100644 --- a/proto/buf.gen.pulsar.yaml +++ b/proto/buf.gen.yaml @@ -18,3 +18,6 @@ plugins: - name: go-cosmos-orm out: .. opt: paths=source_relative,Mcosmos/app/v1alpha1/module.proto=cosmossdk.io/api/cosmos/app/v1alpha1 + - name: grpc-gateway + out: .. + opt: paths=source_relative diff --git a/query.pb.go b/query.pb.go deleted file mode 100644 index 814d73f..0000000 --- a/query.pb.go +++ /dev/null @@ -1,1388 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmosregistry/example/v1/query.proto - -package example - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - query "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// QueryCounterRequest is the request type for the Query/Counter RPC -// method. -type QueryCounterRequest struct { - // address defines the address to query for the counter. - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` -} - -func (m *QueryCounterRequest) Reset() { *m = QueryCounterRequest{} } -func (m *QueryCounterRequest) String() string { return proto.CompactTextString(m) } -func (*QueryCounterRequest) ProtoMessage() {} -func (*QueryCounterRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_63eea967130d0f16, []int{0} -} -func (m *QueryCounterRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCounterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCounterRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryCounterRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCounterRequest.Merge(m, src) -} -func (m *QueryCounterRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryCounterRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCounterRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCounterRequest proto.InternalMessageInfo - -func (m *QueryCounterRequest) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -// QueryCounterResponse is the response type for the Query/Counter RPC -// method. -type QueryCounterResponse struct { - // counter defines the current counter for the sender. - Counter uint64 `protobuf:"varint,1,opt,name=counter,proto3" json:"counter,omitempty"` -} - -func (m *QueryCounterResponse) Reset() { *m = QueryCounterResponse{} } -func (m *QueryCounterResponse) String() string { return proto.CompactTextString(m) } -func (*QueryCounterResponse) ProtoMessage() {} -func (*QueryCounterResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_63eea967130d0f16, []int{1} -} -func (m *QueryCounterResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCounterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCounterResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryCounterResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCounterResponse.Merge(m, src) -} -func (m *QueryCounterResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryCounterResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCounterResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCounterResponse proto.InternalMessageInfo - -func (m *QueryCounterResponse) GetCounter() uint64 { - if m != nil { - return m.Counter - } - return 0 -} - -// QueryCountersResponse is the request type for the Query/Counters RPC -type QueryCountersRequest struct { - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryCountersRequest) Reset() { *m = QueryCountersRequest{} } -func (m *QueryCountersRequest) String() string { return proto.CompactTextString(m) } -func (*QueryCountersRequest) ProtoMessage() {} -func (*QueryCountersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_63eea967130d0f16, []int{2} -} -func (m *QueryCountersRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCountersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCountersRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryCountersRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCountersRequest.Merge(m, src) -} -func (m *QueryCountersRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryCountersRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCountersRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCountersRequest proto.InternalMessageInfo - -func (m *QueryCountersRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryCountersResponse is the response type for the Query/Counters RPC -// method. -type QueryCountersResponse struct { - // counters defines all the counters in the store. - Counters []*Counter `protobuf:"bytes,1,rep,name=counters,proto3" json:"counters,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryCountersResponse) Reset() { *m = QueryCountersResponse{} } -func (m *QueryCountersResponse) String() string { return proto.CompactTextString(m) } -func (*QueryCountersResponse) ProtoMessage() {} -func (*QueryCountersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_63eea967130d0f16, []int{3} -} -func (m *QueryCountersResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCountersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCountersResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryCountersResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCountersResponse.Merge(m, src) -} -func (m *QueryCountersResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryCountersResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCountersResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCountersResponse proto.InternalMessageInfo - -func (m *QueryCountersResponse) GetCounters() []*Counter { - if m != nil { - return m.Counters - } - return nil -} - -func (m *QueryCountersResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryParamsRequest is the request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_63eea967130d0f16, []int{4} -} -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) -} -func (m *QueryParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo - -// QueryParamsResponse is the response type for the Query/Params RPC method. -type QueryParamsResponse struct { - // params defines the parameters of the module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` -} - -func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } -func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryParamsResponse) ProtoMessage() {} -func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_63eea967130d0f16, []int{5} -} -func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsResponse.Merge(m, src) -} -func (m *QueryParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo - -func (m *QueryParamsResponse) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -func init() { - proto.RegisterType((*QueryCounterRequest)(nil), "cosmosregistry.example.v1.QueryCounterRequest") - proto.RegisterType((*QueryCounterResponse)(nil), "cosmosregistry.example.v1.QueryCounterResponse") - proto.RegisterType((*QueryCountersRequest)(nil), "cosmosregistry.example.v1.QueryCountersRequest") - proto.RegisterType((*QueryCountersResponse)(nil), "cosmosregistry.example.v1.QueryCountersResponse") - proto.RegisterType((*QueryParamsRequest)(nil), "cosmosregistry.example.v1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "cosmosregistry.example.v1.QueryParamsResponse") -} - -func init() { - proto.RegisterFile("cosmosregistry/example/v1/query.proto", fileDescriptor_63eea967130d0f16) -} - -var fileDescriptor_63eea967130d0f16 = []byte{ - // 544 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4f, 0x6f, 0xd3, 0x4c, - 0x10, 0xc6, 0xb3, 0xed, 0xfb, 0x26, 0xed, 0xf6, 0xc4, 0x12, 0xa4, 0x60, 0x90, 0x21, 0xae, 0x0a, - 0xa5, 0xa2, 0xbb, 0x49, 0x38, 0x21, 0x24, 0x24, 0x02, 0x02, 0x71, 0x2b, 0xe6, 0x06, 0x12, 0x68, - 0x93, 0xae, 0x8c, 0xa5, 0xda, 0xeb, 0x7a, 0x37, 0x11, 0x11, 0xe2, 0xc2, 0x89, 0x23, 0x82, 0x0f, - 0x00, 0x17, 0x24, 0x8e, 0x1c, 0xf8, 0x10, 0x3d, 0x56, 0x70, 0xe1, 0x84, 0x50, 0x82, 0xe0, 0x6b, - 0x20, 0xef, 0xce, 0xd2, 0x1a, 0x91, 0x3f, 0x97, 0xc8, 0x9e, 0x99, 0x67, 0xe6, 0xb7, 0xcf, 0x6c, - 0x8c, 0x37, 0xfa, 0x52, 0x25, 0x52, 0xe5, 0x22, 0x8a, 0x95, 0xce, 0x47, 0x4c, 0x3c, 0xe5, 0x49, - 0xb6, 0x27, 0xd8, 0xb0, 0xcd, 0xf6, 0x07, 0x22, 0x1f, 0xd1, 0x2c, 0x97, 0x5a, 0x92, 0xd3, 0xe5, - 0x32, 0x0a, 0x65, 0x74, 0xd8, 0xf6, 0xb6, 0x6c, 0x8a, 0xf5, 0xb8, 0x12, 0x56, 0xc3, 0x86, 0xed, - 0x9e, 0xd0, 0xbc, 0xcd, 0x32, 0x1e, 0xc5, 0x29, 0xd7, 0xb1, 0x4c, 0x6d, 0x1b, 0x6f, 0xc6, 0x34, - 0x3d, 0xca, 0x84, 0x82, 0xb2, 0xb3, 0x91, 0x94, 0xd1, 0x9e, 0x60, 0x3c, 0x8b, 0x19, 0x4f, 0x53, - 0xa9, 0x4d, 0x0f, 0x97, 0x3d, 0x03, 0x03, 0xdd, 0xac, 0xe3, 0xa0, 0xde, 0x09, 0x9e, 0xc4, 0xa9, - 0x64, 0xe6, 0x17, 0x42, 0xf5, 0x48, 0x46, 0xd2, 0x3c, 0xb2, 0xe2, 0x09, 0xa2, 0x70, 0xa2, 0xc7, - 0x36, 0x61, 0x5f, 0x6c, 0x2a, 0xb8, 0x8b, 0x4f, 0xde, 0x2b, 0x5a, 0xde, 0x94, 0x83, 0x54, 0x8b, - 0x3c, 0x14, 0xfb, 0x03, 0xa1, 0x34, 0xe9, 0xe0, 0x1a, 0xdf, 0xdd, 0xcd, 0x85, 0x52, 0x0d, 0x74, - 0x1e, 0x6d, 0xae, 0x76, 0x1b, 0x9f, 0x3f, 0x6d, 0xd7, 0x41, 0x79, 0xc3, 0x66, 0xee, 0xeb, 0x3c, - 0x4e, 0xa3, 0xd0, 0x15, 0x06, 0x2d, 0x5c, 0x2f, 0xb7, 0x52, 0x99, 0x4c, 0x95, 0x20, 0x0d, 0x5c, - 0xeb, 0xdb, 0x90, 0xe9, 0xf5, 0x5f, 0xe8, 0x5e, 0x83, 0x47, 0x65, 0x85, 0x72, 0xd3, 0x6f, 0x63, - 0x7c, 0x64, 0xa7, 0x11, 0xad, 0x75, 0x2e, 0x50, 0x98, 0x5e, 0x78, 0x4f, 0xad, 0x0d, 0xe0, 0x3d, - 0xdd, 0xe1, 0x91, 0x00, 0x6d, 0x78, 0x4c, 0x19, 0xbc, 0x43, 0xf8, 0xd4, 0x5f, 0x03, 0x80, 0xe9, - 0x3a, 0x5e, 0x01, 0x88, 0xe2, 0x80, 0xcb, 0x9b, 0x6b, 0x9d, 0x80, 0x4e, 0x5d, 0x3b, 0x75, 0x27, - 0xfa, 0xa3, 0x21, 0x77, 0x4a, 0x84, 0x4b, 0x86, 0xf0, 0xe2, 0x5c, 0x42, 0x3b, 0xbc, 0x84, 0x58, - 0xc7, 0xc4, 0x10, 0xee, 0xf0, 0x9c, 0x27, 0xce, 0x80, 0xe0, 0x21, 0x6c, 0xc5, 0x45, 0x81, 0xfa, - 0x16, 0xae, 0x66, 0x26, 0x02, 0x9e, 0x34, 0x67, 0x30, 0x5b, 0x69, 0x77, 0xf5, 0xe0, 0xdb, 0xb9, - 0xca, 0x87, 0x5f, 0x1f, 0xb7, 0x50, 0x08, 0xda, 0xce, 0xcf, 0x65, 0xfc, 0xbf, 0xe9, 0x4e, 0xde, - 0x23, 0x5c, 0x83, 0xb3, 0x11, 0x3a, 0xa3, 0xd7, 0x3f, 0x6e, 0x88, 0xc7, 0x16, 0xae, 0xb7, 0xf0, - 0xc1, 0xd5, 0x97, 0x05, 0xc5, 0x8b, 0x2f, 0x3f, 0xde, 0x2c, 0x51, 0x72, 0x99, 0x4d, 0xff, 0x77, - 0x80, 0xc9, 0xec, 0x19, 0x5c, 0xac, 0xe7, 0xe4, 0x2d, 0xc2, 0x2b, 0x6e, 0x85, 0x64, 0xd1, 0xc1, - 0xce, 0x4c, 0xaf, 0xb5, 0xb8, 0x00, 0x50, 0x5b, 0x47, 0xa8, 0x1b, 0x64, 0x7d, 0x3e, 0xaa, 0x22, - 0xaf, 0x11, 0xae, 0x5a, 0xc7, 0xc9, 0xf6, 0xbc, 0x71, 0xa5, 0x55, 0x7b, 0x74, 0xd1, 0x72, 0x60, - 0xbb, 0x64, 0xb0, 0xd6, 0x49, 0x73, 0x06, 0x96, 0x5d, 0x74, 0xf7, 0xda, 0xc1, 0xd8, 0x47, 0x87, - 0x63, 0x1f, 0x7d, 0x1f, 0xfb, 0xe8, 0xd5, 0xc4, 0xaf, 0x1c, 0x4e, 0xfc, 0xca, 0xd7, 0x89, 0x5f, - 0x79, 0xd0, 0x8c, 0x62, 0xfd, 0x64, 0xd0, 0xa3, 0x7d, 0x99, 0x4c, 0x69, 0xd3, 0xab, 0x9a, 0xef, - 0xc3, 0x95, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xc1, 0x5e, 0x9b, 0x35, 0x05, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Counter returns the current counter value. - Counter(ctx context.Context, in *QueryCounterRequest, opts ...grpc.CallOption) (*QueryCounterResponse, error) - // Counters returns all the counter values. - Counters(ctx context.Context, in *QueryCountersRequest, opts ...grpc.CallOption) (*QueryCountersResponse, error) - // Params returns the module parameters. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) Counter(ctx context.Context, in *QueryCounterRequest, opts ...grpc.CallOption) (*QueryCounterResponse, error) { - out := new(QueryCounterResponse) - err := c.cc.Invoke(ctx, "/cosmosregistry.example.v1.Query/Counter", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) Counters(ctx context.Context, in *QueryCountersRequest, opts ...grpc.CallOption) (*QueryCountersResponse, error) { - out := new(QueryCountersResponse) - err := c.cc.Invoke(ctx, "/cosmosregistry.example.v1.Query/Counters", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/cosmosregistry.example.v1.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Counter returns the current counter value. - Counter(context.Context, *QueryCounterRequest) (*QueryCounterResponse, error) - // Counters returns all the counter values. - Counters(context.Context, *QueryCountersRequest) (*QueryCountersResponse, error) - // Params returns the module parameters. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) Counter(ctx context.Context, req *QueryCounterRequest) (*QueryCounterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Counter not implemented") -} -func (*UnimplementedQueryServer) Counters(ctx context.Context, req *QueryCountersRequest) (*QueryCountersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Counters not implemented") -} -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_Counter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryCounterRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Counter(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cosmosregistry.example.v1.Query/Counter", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Counter(ctx, req.(*QueryCounterRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_Counters_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryCountersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Counters(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cosmosregistry.example.v1.Query/Counters", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Counters(ctx, req.(*QueryCountersRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cosmosregistry.example.v1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cosmosregistry.example.v1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Counter", - Handler: _Query_Counter_Handler, - }, - { - MethodName: "Counters", - Handler: _Query_Counters_Handler, - }, - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmosregistry/example/v1/query.proto", -} - -func (m *QueryCounterRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryCounterRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCounterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryCounterResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryCounterResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCounterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Counter != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Counter)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryCountersRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryCountersRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCountersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryCountersResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryCountersResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCountersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Counters) > 0 { - for iNdEx := len(m.Counters) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Counters[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryCounterRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryCounterResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Counter != 0 { - n += 1 + sovQuery(uint64(m.Counter)) - } - return n -} - -func (m *QueryCountersRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryCountersResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Counters) > 0 { - for _, e := range m.Counters { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryCounterRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryCounterRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCounterRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryCounterResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryCounterResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCounterResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Counter", wireType) - } - m.Counter = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Counter |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryCountersRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryCountersRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCountersRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryCountersResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryCountersResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCountersResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Counters", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Counters = append(m.Counters, &Counter{}) - if err := m.Counters[len(m.Counters)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipQuery(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthQuery - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupQuery - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthQuery - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") -) diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 0e4a7bf..242102b 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -2,26 +2,12 @@ set -e -echo "Generating gogo proto code" +echo "Generating proto code" cd proto -proto_dirs=$(find . -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) -for dir in $proto_dirs; do - for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do - # this regex checks if a proto file has its go_package set to github.com/cosmosregistry/example/api/... - # gogo proto files SHOULD ONLY be generated if this is false - # we don't want gogo proto to run for proto files which are natively built for google.golang.org/protobuf - if grep -q "option go_package" "$file" && grep -H -o -c 'option go_package.*github.com/cosmosregistry/example/api' "$file" | grep -q ':0$'; then - buf generate --template buf.gen.gogo.yaml $file - fi - done -done - -echo "Generating pulsar proto code" -buf generate --template buf.gen.pulsar.yaml +buf generate --template buf.gen.yaml cd .. -cp -r github.com/cosmosregistry/example/* ./ rm -rf api && mkdir api mv cosmosregistry/example/* ./api rm -rf github.com cosmosregistry \ No newline at end of file diff --git a/tx.pb.go b/tx.pb.go deleted file mode 100644 index d47ddff..0000000 --- a/tx.pb.go +++ /dev/null @@ -1,933 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmosregistry/example/v1/tx.proto - -package example - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// MsgIncrementCounter defines the Msg/IncrementCounter request type. -type MsgIncrementCounter struct { - // sender is the message sender. - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` -} - -func (m *MsgIncrementCounter) Reset() { *m = MsgIncrementCounter{} } -func (m *MsgIncrementCounter) String() string { return proto.CompactTextString(m) } -func (*MsgIncrementCounter) ProtoMessage() {} -func (*MsgIncrementCounter) Descriptor() ([]byte, []int) { - return fileDescriptor_e12a2f8fd7fd29c8, []int{0} -} -func (m *MsgIncrementCounter) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgIncrementCounter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgIncrementCounter.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgIncrementCounter) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgIncrementCounter.Merge(m, src) -} -func (m *MsgIncrementCounter) XXX_Size() int { - return m.Size() -} -func (m *MsgIncrementCounter) XXX_DiscardUnknown() { - xxx_messageInfo_MsgIncrementCounter.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgIncrementCounter proto.InternalMessageInfo - -func (m *MsgIncrementCounter) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -// MsgIncrementCounterResponse defines the Msg/IncrementCounter response type. -type MsgIncrementCounterResponse struct { -} - -func (m *MsgIncrementCounterResponse) Reset() { *m = MsgIncrementCounterResponse{} } -func (m *MsgIncrementCounterResponse) String() string { return proto.CompactTextString(m) } -func (*MsgIncrementCounterResponse) ProtoMessage() {} -func (*MsgIncrementCounterResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e12a2f8fd7fd29c8, []int{1} -} -func (m *MsgIncrementCounterResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgIncrementCounterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgIncrementCounterResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgIncrementCounterResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgIncrementCounterResponse.Merge(m, src) -} -func (m *MsgIncrementCounterResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgIncrementCounterResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgIncrementCounterResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgIncrementCounterResponse proto.InternalMessageInfo - -// MsgUpdateParams is the Msg/UpdateParams request type. -type MsgUpdateParams struct { - // authority is the address that controls the module - // NOTE: Defaults to the governance module unless overwritten. - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the module parameters to update. - // NOTE: All parameters must be supplied. - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` -} - -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_e12a2f8fd7fd29c8, []int{2} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -func (m *MsgUpdateParams) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgUpdateParams) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -type MsgUpdateParamsResponse struct { -} - -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e12a2f8fd7fd29c8, []int{3} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgIncrementCounter)(nil), "cosmosregistry.example.v1.MsgIncrementCounter") - proto.RegisterType((*MsgIncrementCounterResponse)(nil), "cosmosregistry.example.v1.MsgIncrementCounterResponse") - proto.RegisterType((*MsgUpdateParams)(nil), "cosmosregistry.example.v1.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmosregistry.example.v1.MsgUpdateParamsResponse") -} - -func init() { - proto.RegisterFile("cosmosregistry/example/v1/tx.proto", fileDescriptor_e12a2f8fd7fd29c8) -} - -var fileDescriptor_e12a2f8fd7fd29c8 = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0x2e, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x29, 0xaa, 0xd4, 0x4f, 0xad, 0x48, 0xcc, 0x2d, - 0xc8, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, - 0x44, 0x55, 0xa3, 0x07, 0x55, 0xa3, 0x57, 0x66, 0x28, 0x25, 0x0e, 0x91, 0xd2, 0xcf, 0x2d, 0x4e, - 0x07, 0x69, 0xc9, 0x2d, 0x4e, 0x87, 0xe8, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x33, 0xf5, - 0x41, 0x2c, 0xa8, 0xa8, 0x60, 0x62, 0x6e, 0x66, 0x5e, 0xbe, 0x3e, 0x98, 0x84, 0x0a, 0xa9, 0xe2, - 0x71, 0x40, 0x65, 0x41, 0x6a, 0x31, 0x54, 0x19, 0xd4, 0x0d, 0xf1, 0x10, 0x23, 0x21, 0x1c, 0x88, - 0x94, 0x52, 0x33, 0x23, 0x97, 0xb0, 0x6f, 0x71, 0xba, 0x67, 0x5e, 0x72, 0x51, 0x6a, 0x6e, 0x6a, - 0x5e, 0x89, 0x73, 0x7e, 0x69, 0x5e, 0x49, 0x6a, 0x91, 0x90, 0x01, 0x17, 0x5b, 0x71, 0x6a, 0x5e, - 0x4a, 0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, 0x50, - 0x9d, 0x8e, 0x29, 0x29, 0x45, 0xa9, 0xc5, 0xc5, 0xc1, 0x25, 0x45, 0x99, 0x79, 0xe9, 0x41, 0x50, - 0x75, 0x56, 0x56, 0x4d, 0xcf, 0x37, 0x68, 0x41, 0x39, 0x5d, 0xcf, 0x37, 0x68, 0x69, 0xe1, 0x70, - 0x1b, 0x16, 0xdb, 0x94, 0x64, 0xb9, 0xa4, 0xb1, 0x08, 0x07, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, - 0xa7, 0x2a, 0x9d, 0x62, 0xe4, 0xe2, 0xf7, 0x2d, 0x4e, 0x0f, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x0d, - 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0x16, 0x32, 0xe3, 0xe2, 0x4c, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, - 0x2c, 0xa9, 0x24, 0xe8, 0x46, 0x84, 0x52, 0x21, 0x17, 0x2e, 0xb6, 0x02, 0xb0, 0x09, 0x12, 0x4c, - 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x8a, 0x7a, 0x38, 0x23, 0x48, 0x0f, 0x62, 0x95, 0x13, 0xe7, 0x89, - 0x7b, 0xf2, 0x0c, 0x2b, 0x9e, 0x6f, 0xd0, 0x62, 0x0c, 0x82, 0xea, 0xb5, 0xb2, 0x04, 0x79, 0x16, - 0x61, 0x2a, 0xc8, 0xbf, 0x6a, 0xb8, 0xfd, 0x8b, 0xec, 0x70, 0x25, 0x49, 0x2e, 0x71, 0x34, 0x21, - 0x98, 0x3f, 0x8d, 0x7e, 0x30, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x55, 0x71, 0x09, 0x60, 0x44, - 0x88, 0x1e, 0x1e, 0x77, 0x62, 0x09, 0x3b, 0x29, 0x33, 0xd2, 0xd4, 0xc3, 0xdc, 0x20, 0x94, 0xc7, - 0xc5, 0x83, 0x12, 0xce, 0x5a, 0xf8, 0xcd, 0x41, 0x56, 0x2b, 0x65, 0x44, 0xbc, 0x5a, 0x98, 0x7d, - 0x52, 0xac, 0x0d, 0xa0, 0x80, 0x75, 0xb2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, - 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, - 0x86, 0x28, 0xc5, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xec, 0x41, - 0x9c, 0xc4, 0x06, 0x4e, 0xcb, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x27, 0xc8, 0xe8, 0xbd, - 0x90, 0x03, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - // IncrementCounter increments the counter. - IncrementCounter(ctx context.Context, in *MsgIncrementCounter, opts ...grpc.CallOption) (*MsgIncrementCounterResponse, error) - // UpdateParams updates the module parameters. - UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) IncrementCounter(ctx context.Context, in *MsgIncrementCounter, opts ...grpc.CallOption) (*MsgIncrementCounterResponse, error) { - out := new(MsgIncrementCounterResponse) - err := c.cc.Invoke(ctx, "/cosmosregistry.example.v1.Msg/IncrementCounter", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/cosmosregistry.example.v1.Msg/UpdateParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // IncrementCounter increments the counter. - IncrementCounter(context.Context, *MsgIncrementCounter) (*MsgIncrementCounterResponse, error) - // UpdateParams updates the module parameters. - UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) IncrementCounter(ctx context.Context, req *MsgIncrementCounter) (*MsgIncrementCounterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method IncrementCounter not implemented") -} -func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_IncrementCounter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgIncrementCounter) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).IncrementCounter(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cosmosregistry.example.v1.Msg/IncrementCounter", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).IncrementCounter(ctx, req.(*MsgIncrementCounter)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cosmosregistry.example.v1.Msg/UpdateParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cosmosregistry.example.v1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "IncrementCounter", - Handler: _Msg_IncrementCounter_Handler, - }, - { - MethodName: "UpdateParams", - Handler: _Msg_UpdateParams_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmosregistry/example/v1/tx.proto", -} - -func (m *MsgIncrementCounter) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgIncrementCounter) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgIncrementCounter) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgIncrementCounterResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgIncrementCounterResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgIncrementCounterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgIncrementCounter) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgIncrementCounterResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgIncrementCounter) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgIncrementCounter: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgIncrementCounter: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgIncrementCounterResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgIncrementCounterResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgIncrementCounterResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTx(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -) diff --git a/types.pb.go b/types.pb.go deleted file mode 100644 index 48fe8cf..0000000 --- a/types.pb.go +++ /dev/null @@ -1,726 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmosregistry/example/v1/types.proto - -package example - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Params defines the parameters of the module. -type Params struct { -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_b9d1cf6348eb2ada, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -// Counter defines a counter object. -// It is used only for genesis purposes. Collections does not need to use it. -type Counter struct { - // count defines the count of the counter. - Count uint64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` - // address defines the address that is associated with the count. - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` -} - -func (m *Counter) Reset() { *m = Counter{} } -func (m *Counter) String() string { return proto.CompactTextString(m) } -func (*Counter) ProtoMessage() {} -func (*Counter) Descriptor() ([]byte, []int) { - return fileDescriptor_b9d1cf6348eb2ada, []int{1} -} -func (m *Counter) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Counter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Counter.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Counter) XXX_Merge(src proto.Message) { - xxx_messageInfo_Counter.Merge(m, src) -} -func (m *Counter) XXX_Size() int { - return m.Size() -} -func (m *Counter) XXX_DiscardUnknown() { - xxx_messageInfo_Counter.DiscardUnknown(m) -} - -var xxx_messageInfo_Counter proto.InternalMessageInfo - -func (m *Counter) GetCount() uint64 { - if m != nil { - return m.Count - } - return 0 -} - -func (m *Counter) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -// GenesisState is the state that must be provided at genesis. -type GenesisState struct { - // counter defines the counter object. - Counters []Counter `protobuf:"bytes,1,rep,name=counters,proto3" json:"counters"` - // params defines all the parameters of the module. - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` -} - -func (m *GenesisState) Reset() { *m = GenesisState{} } -func (m *GenesisState) String() string { return proto.CompactTextString(m) } -func (*GenesisState) ProtoMessage() {} -func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_b9d1cf6348eb2ada, []int{2} -} -func (m *GenesisState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *GenesisState) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisState) XXX_Size() int { - return m.Size() -} -func (m *GenesisState) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisState) GetCounters() []Counter { - if m != nil { - return m.Counters - } - return nil -} - -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -func init() { - proto.RegisterType((*Params)(nil), "cosmosregistry.example.v1.Params") - proto.RegisterType((*Counter)(nil), "cosmosregistry.example.v1.Counter") - proto.RegisterType((*GenesisState)(nil), "cosmosregistry.example.v1.GenesisState") -} - -func init() { - proto.RegisterFile("cosmosregistry/example/v1/types.proto", fileDescriptor_b9d1cf6348eb2ada) -} - -var fileDescriptor_b9d1cf6348eb2ada = []byte{ - // 325 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0x2e, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x29, 0xaa, 0xd4, 0x4f, 0xad, 0x48, 0xcc, 0x2d, - 0xc8, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x92, 0x44, 0x55, 0xa6, 0x07, 0x55, 0xa6, 0x57, 0x66, 0x28, 0x05, 0x95, 0x8a, 0x07, - 0x2b, 0xd4, 0x87, 0x70, 0x20, 0xba, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0x21, 0xe2, 0x20, 0x16, - 0x54, 0x54, 0x30, 0x31, 0x37, 0x33, 0x2f, 0x5f, 0x1f, 0x4c, 0x42, 0x84, 0x94, 0x74, 0xb8, 0xd8, - 0x02, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0xad, 0x94, 0xba, 0x9e, 0x6f, 0xd0, 0x92, 0xc5, 0xe1, 0x28, - 0x88, 0x1a, 0xa5, 0x0a, 0x2e, 0x76, 0xe7, 0xfc, 0xd2, 0xbc, 0x92, 0xd4, 0x22, 0x21, 0x11, 0x2e, - 0xd6, 0x64, 0x10, 0x53, 0x82, 0x51, 0x81, 0x51, 0x83, 0x25, 0x08, 0xc2, 0x11, 0x32, 0xe2, 0x62, - 0x4f, 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, 0x96, 0x60, 0x52, 0x60, 0xd4, 0xe0, 0x74, 0x92, 0xb8, - 0xb4, 0x45, 0x57, 0x04, 0xea, 0x34, 0x47, 0x88, 0x4c, 0x70, 0x49, 0x51, 0x66, 0x5e, 0x7a, 0x10, - 0x4c, 0xa1, 0x95, 0x32, 0xc8, 0x62, 0x39, 0x1c, 0x16, 0x43, 0xad, 0x53, 0x9a, 0xcf, 0xc8, 0xc5, - 0xe3, 0x9e, 0x9a, 0x97, 0x5a, 0x9c, 0x59, 0x1c, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0xe4, 0xc9, 0xc5, - 0x91, 0x0c, 0x91, 0x2b, 0x96, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xd2, 0xc3, 0x19, 0x54, - 0x7a, 0x50, 0x63, 0x9c, 0x38, 0x4f, 0xdc, 0x93, 0x67, 0x58, 0xf1, 0x7c, 0x83, 0x16, 0x63, 0x10, - 0x5c, 0xbb, 0x90, 0x0b, 0x17, 0x5b, 0x01, 0xd8, 0x7f, 0x60, 0x37, 0x73, 0x1b, 0x29, 0xe2, 0x31, - 0x08, 0x12, 0x10, 0xc8, 0xe6, 0x40, 0xf5, 0x3a, 0x59, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, - 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, - 0xb1, 0x1c, 0x43, 0x94, 0x62, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, - 0x76, 0x6f, 0x26, 0xb1, 0x81, 0x63, 0xc3, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x8e, 0x91, - 0x6a, 0x15, 0x02, 0x00, 0x00, -} - -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *Counter) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Counter) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Counter) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x12 - } - if m.Count != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Count)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *GenesisState) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Counters) > 0 { - for iNdEx := len(m.Counters) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Counters[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *Counter) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Count != 0 { - n += 1 + sovTypes(uint64(m.Count)) - } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Counters) > 0 { - for _, e := range m.Counters { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - l = m.Params.Size() - n += 1 + l + sovTypes(uint64(l)) - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Counter) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Counter: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Counter: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) - } - m.Count = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Count |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GenesisState) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Counters", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Counters = append(m.Counters, Counter{}) - if err := m.Counters[len(m.Counters)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTypes - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -)