feat: x/blocksdk full module (#192)

* module proto

* lane proto

* proto-gen

* proto-format

* regenerate

* genesis

* stub

* test

* comment

* new keeper functions

* finalize

* lint fix

* proto format

* encounteredLanes

* make protos

* generate

* generate

* msgs

* msgs test

* msg service

* grpc query

* add module

* add module assertions

* add client

* fix proto

* typo
This commit is contained in:
Alex Johnson
2023-11-06 07:49:52 -05:00
committed by GitHub
parent ef654f5cbf
commit 79b9434615
24 changed files with 6860 additions and 15 deletions
+88
View File
@@ -0,0 +1,88 @@
package cli
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra"
"github.com/skip-mev/block-sdk/x/blocksdk/types"
)
// GetQueryCmd returns the cli query commands for the blocksdk module.
func GetQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(
CmdQueryLane(),
CmdQueryLanes(),
)
return cmd
}
// CmdQueryLane implements a command that will return a lane by its ID.
func CmdQueryLane() *cobra.Command {
cmd := &cobra.Command{
Use: "lane",
Short: "Query the a lane by its ID",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
request := &types.QueryLaneRequest{}
response, err := queryClient.Lane(clientCtx.CmdContext, request)
if err != nil {
return err
}
return clientCtx.PrintProto(&response.Lane)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
// CmdQueryLanes implements a command that will return all lanes.
func CmdQueryLanes() *cobra.Command {
cmd := &cobra.Command{
Use: "lanes",
Short: "Query the all lanes",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
request := &types.QueryLanesRequest{}
response, err := queryClient.Lanes(clientCtx.CmdContext, request)
if err != nil {
return err
}
return clientCtx.PrintProto(response)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
+24
View File
@@ -0,0 +1,24 @@
package cli
import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra"
"github.com/skip-mev/block-sdk/x/blocksdk/types"
)
// NewTxCmd returns a root CLI command handler for all x/blocksdk transaction
// commands.
func NewTxCmd() *cobra.Command {
txCmd := &cobra.Command{
Use: types.ModuleName,
Short: "blocksdk transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
txCmd.AddCommand()
return txCmd
}
+42
View File
@@ -0,0 +1,42 @@
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/skip-mev/block-sdk/x/blocksdk/types"
)
var _ types.QueryServer = QueryServer{}
// QueryServer defines the blocksdk module's gRPC querier service.
type QueryServer struct {
keeper Keeper
}
// NewQueryServer creates a new gRPC query server for the blocksdk module.
func NewQueryServer(keeper Keeper) *QueryServer {
return &QueryServer{keeper: keeper}
}
// Lane implements the service to query a Lane by its ID.
func (q QueryServer) Lane(goCtx context.Context, query *types.QueryLaneRequest) (*types.QueryLaneResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
lane, err := q.keeper.GetLane(ctx, query.Id)
if err != nil {
return nil, err
}
return &types.QueryLaneResponse{Lane: lane}, nil
}
// Lanes implements the service to query all Lanes in the stores.
func (q QueryServer) Lanes(goCtx context.Context, _ *types.QueryLanesRequest) (*types.QueryLanesResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
lanes := q.keeper.GetLanes(ctx)
return &types.QueryLanesResponse{Lanes: lanes}, nil
}
+104
View File
@@ -0,0 +1,104 @@
package keeper_test
import (
"cosmossdk.io/math"
"github.com/skip-mev/block-sdk/x/blocksdk/types"
)
func (s *KeeperTestSuite) TestQueryLane() {
// pre-register a lane
registeredLanes := types.Lanes{
types.Lane{
Id: "registered1",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"),
Order: 0,
},
types.Lane{
Id: "registered2",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"),
Order: 1,
},
}
for _, lane := range registeredLanes {
s.Require().NoError(s.blocksdKeeper.AddLane(s.ctx, lane))
}
testCases := []struct {
name string
query *types.QueryLaneRequest
expected types.Lane
wantErr bool
}{
{
name: "invalid lane does not exist",
query: &types.QueryLaneRequest{Id: "invalid"},
expected: types.Lane{},
wantErr: true,
},
{
name: "valid query 1",
query: &types.QueryLaneRequest{Id: registeredLanes[0].Id},
expected: registeredLanes[0],
wantErr: false,
},
{
name: "valid query 2",
query: &types.QueryLaneRequest{Id: registeredLanes[1].Id},
expected: registeredLanes[1],
wantErr: false,
},
}
for _, tc := range testCases {
s.Run(tc.name, func() {
resp, err := s.queryServer.Lane(s.ctx, tc.query)
if tc.wantErr {
s.Require().Error(err)
return
}
s.Require().NoError(err)
s.Require().Equal(tc.expected, resp.GetLane())
})
}
}
func (s *KeeperTestSuite) TestQueryLanes() {
// pre-register a lane
registeredLanes := types.Lanes{
types.Lane{
Id: "registered1",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"),
Order: 0,
},
types.Lane{
Id: "registered2",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"),
Order: 1,
},
}
for _, lane := range registeredLanes {
s.Require().NoError(s.blocksdKeeper.AddLane(s.ctx, lane))
}
testCases := []struct {
name string
query *types.QueryLanesRequest
expected []types.Lane
}{
{
name: "valid",
query: &types.QueryLanesRequest{},
expected: registeredLanes,
},
}
for _, tc := range testCases {
s.Run(tc.name, func() {
resp, err := s.queryServer.Lanes(s.ctx, tc.query)
s.Require().NoError(err)
s.Require().Equal(tc.expected, resp.GetLanes())
})
}
}
+7 -5
View File
@@ -19,10 +19,11 @@ import (
type KeeperTestSuite struct {
suite.Suite
blocksdKeeper keeper.Keeper
encCfg testutils.EncodingConfig
ctx sdk.Context
// msgServer types.MsgServer
blocksdKeeper keeper.Keeper
encCfg testutils.EncodingConfig
ctx sdk.Context
queryServer types.QueryServer
msgServer types.MsgServer
key *storetypes.KVStoreKey
authorityAccount sdk.AccAddress
}
@@ -43,7 +44,8 @@ func (s *KeeperTestSuite) SetupTest() {
s.authorityAccount.String(),
)
// s.msgServer = keeper.NewMsgServerImpl(s.blocksdKeeper)
s.msgServer = keeper.NewMsgServerImpl(s.blocksdKeeper)
s.queryServer = keeper.NewQueryServer(s.blocksdKeeper)
}
func (s *KeeperTestSuite) TestLane() {
+47
View File
@@ -0,0 +1,47 @@
package keeper
import (
"context"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/skip-mev/block-sdk/x/blocksdk/types"
)
var _ types.MsgServer = MsgServer{}
// MsgServer is the wrapper for the x/blocksdk module's msg service.
type MsgServer struct {
Keeper
}
// NewMsgServerImpl returns an implementation of the x/blocksdk MsgServer interface.
func NewMsgServerImpl(keeper Keeper) *MsgServer {
return &MsgServer{Keeper: keeper}
}
// UpdateLane implements the message service for updating a lane that exists in the store.
func (m MsgServer) UpdateLane(goCtx context.Context, msg *types.MsgUpdateLane) (*types.MsgUpdateLaneResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
// ensure that the message signer is the authority
if msg.Authority != m.Keeper.GetAuthority() {
return nil, fmt.Errorf("this message can only be executed by the authority; expected %s, got %s", m.Keeper.GetAuthority(), msg.Authority)
}
oldLane, err := m.GetLane(ctx, msg.Lane.Id)
if err != nil {
return nil, fmt.Errorf("lane with ID %s not found", msg.Lane.Id)
}
if oldLane.Order != msg.Lane.Order {
return nil, fmt.Errorf("unable to change lane order using UpdateLane method")
}
m.setLane(ctx, msg.Lane)
// TODO emit event
return nil, nil
}
+144
View File
@@ -0,0 +1,144 @@
package keeper_test
import (
"math/rand"
"time"
"cosmossdk.io/math"
testutils "github.com/skip-mev/block-sdk/testutils"
"github.com/skip-mev/block-sdk/x/blocksdk/types"
)
func (s *KeeperTestSuite) TestMsgUpdateLane() {
rng := rand.New(rand.NewSource(time.Now().Unix()))
account := testutils.RandomAccounts(rng, 1)[0]
// pre-register a lane
registeredLane := types.Lane{
Id: "registered",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"),
Order: 0,
}
s.Require().NoError(s.blocksdKeeper.AddLane(s.ctx, registeredLane))
testCases := []struct {
name string
msg *types.MsgUpdateLane
pass bool
passBasic bool
}{
{
name: "invalid authority",
msg: &types.MsgUpdateLane{
Authority: "invalid",
Lane: types.Lane{
Id: "test",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"),
Order: 0,
},
},
passBasic: false,
pass: false,
},
{
name: "invalid unauthorized authority",
msg: &types.MsgUpdateLane{
Authority: account.Address.String(),
Lane: types.Lane{
Id: "test",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"),
Order: 0,
},
},
passBasic: true,
pass: false,
},
{
name: "invalid lane ID",
msg: &types.MsgUpdateLane{
Authority: s.authorityAccount.String(),
Lane: types.Lane{
Id: "",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"),
Order: 0,
},
},
passBasic: false,
pass: false,
},
{
name: "invalid MaxBlockSpace",
msg: &types.MsgUpdateLane{
Authority: s.authorityAccount.String(),
Lane: types.Lane{
Id: "",
MaxBlockSpace: math.LegacyMustNewDecFromStr("1.1"),
Order: 0,
},
},
passBasic: false,
pass: false,
},
{
name: "invalid lane does not exist",
msg: &types.MsgUpdateLane{
Authority: s.authorityAccount.String(),
Lane: types.Lane{
Id: "invalid",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"),
Order: 0,
},
},
passBasic: true,
pass: false,
},
{
name: "invalid order modification",
msg: &types.MsgUpdateLane{
Authority: s.authorityAccount.String(),
Lane: types.Lane{
Id: "registered",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.2"),
Order: 1,
},
},
passBasic: true,
pass: false,
},
{
name: "valid",
msg: &types.MsgUpdateLane{
Authority: s.authorityAccount.String(),
Lane: types.Lane{
Id: "registered",
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.2"),
Order: 0,
},
},
passBasic: true,
pass: true,
},
}
for _, tc := range testCases {
s.Run(tc.name, func() {
if !tc.passBasic {
s.Require().Error(tc.msg.ValidateBasic())
return
}
_, err := s.msgServer.UpdateLane(s.ctx, tc.msg)
if tc.pass {
s.Require().NoError(err)
lane, err := s.blocksdKeeper.GetLane(s.ctx, tc.msg.Lane.Id)
s.Require().NoError(err)
s.Require().Equal(tc.msg.Lane, lane)
} else {
s.Require().Error(err)
}
})
}
}
+186
View File
@@ -0,0 +1,186 @@
package blocksdk
import (
"context"
"encoding/json"
"fmt"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
modulev1 "github.com/skip-mev/block-sdk/api/sdk/blocksdk/module/v1"
"github.com/skip-mev/block-sdk/x/blocksdk/client/cli"
"github.com/skip-mev/block-sdk/x/blocksdk/keeper"
"github.com/skip-mev/block-sdk/x/blocksdk/types"
)
var (
_ module.AppModuleBasic = AppModule{}
_ module.HasGenesis = AppModule{}
_ module.HasServices = AppModule{}
_ module.HasInvariants = AppModule{}
_ appmodule.AppModule = AppModule{}
)
// ConsensusVersion defines the current x/blocksdk module consensus version.
const ConsensusVersion = 1
// AppModuleBasic defines the basic application module used by the blocksdk module.
type AppModuleBasic struct {
cdc codec.Codec
}
// Name returns the blocksdk module's name.
func (AppModuleBasic) Name() string {
return types.ModuleName
}
// RegisterLegacyAminoCodec registers the blocksdk module's types on the given LegacyAmino codec.
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
}
// RegisterInterfaces registers the blocksdk module's interface types.
func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
types.RegisterInterfaces(registry)
}
// DefaultGenesis returns default genesis state as raw bytes for the blocksdk module.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesisState())
}
// ValidateGenesis performs genesis state validation for the blocksdk module.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
var genState types.GenesisState
if err := cdc.UnmarshalJSON(bz, &genState); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
}
return genState.Validate()
}
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the blocksdk module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
panic(err)
}
}
// GetTxCmd returns the root tx command for the blocksdk module.
func (AppModuleBasic) GetTxCmd() *cobra.Command {
return cli.NewTxCmd()
}
// GetQueryCmd returns the root query command for the blocksdk module.
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
return cli.GetQueryCmd()
}
type AppModule struct {
AppModuleBasic
keeper keeper.Keeper
}
var _ appmodule.AppModule = AppModule{}
// NewAppModule creates a new AppModule object.
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc},
keeper: keeper,
}
}
// IsAppModule implements the appmodule.AppModule interface.
func (am AppModule) IsAppModule() {}
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (am AppModule) IsOnePerModuleType() {}
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
// RegisterServices registers the gRPC Query and Msg services for the x/blocksdk
// module.
func (am AppModule) RegisterServices(cfc module.Configurator) {
types.RegisterMsgServer(cfc.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfc.QueryServer(), keeper.NewQueryServer(am.keeper))
}
func (a AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {}
// RegisterInvariants registers the invariants of the module. If an invariant
// deviates from its predicted value, the InvariantRegistry triggers appropriate
// logic (most often the chain will be halted).
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
// InitGenesis performs the module's genesis initialization for the blocksdk
// module. It returns no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) {
var genState types.GenesisState
cdc.MustUnmarshalJSON(gs, &genState)
am.keeper.InitGenesis(ctx, genState)
}
// ExportGenesis returns the blocksdk module's exported genesis state as raw
// JSON bytes.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
genState := am.keeper.ExportGenesis(ctx)
return cdc.MustMarshalJSON(genState)
}
func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(ProvideModule),
)
}
type Inputs struct {
depinject.In
Config *modulev1.Module
Cdc codec.Codec
Key *storetypes.KVStoreKey
}
type Outputs struct {
depinject.Out
BlockSDKkeeper keeper.Keeper
Module appmodule.AppModule
}
func ProvideModule(in Inputs) Outputs {
// default to governance authority if not provided
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
if in.Config.Authority != "" {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}
blocksdkKeeper := keeper.NewKeeper(
in.Cdc,
in.Key,
authority.String(),
)
m := NewAppModule(in.Cdc, blocksdkKeeper)
return Outputs{BlockSDKkeeper: blocksdkKeeper, Module: m}
}
+6 -5
View File
@@ -39,11 +39,12 @@ type Lane struct {
// lane (up to maxTxBytes as provided by the request). This is useful for the
// default lane.
MaxBlockSpace cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=max_block_space,json=maxBlockSpace,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"max_block_space"`
// order is the priority ordering of the Lane. Lane orders should be set in
// order of priority starting from 0, monotonically increasing and
// non-overlapping. A lane with a lower order value will have a higher
// priority over a lane with a higher order value. For example, if LaneA has
// priority of 0 and LaneB has a priority of 1, LaneA has priority over LaneB.
// order is the priority ordering of the Lane when processed in
// PrepareProposal and ProcessProposal. Lane orders should be set in order of
// priority starting from 0, monotonically increasing and non-overlapping. A
// lane with a lower order value will have a higher priority over a lane with
// a higher order value. For example, if LaneA has priority of 0 and LaneB
// has a priority of 1, LaneA has priority over LaneB.
Order uint64 `protobuf:"varint,3,opt,name=order,proto3" json:"order,omitempty"`
}
+39
View File
@@ -0,0 +1,39 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewLegacyAmino()
)
func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
}
// RegisterLegacyAminoCodec registers the necessary x/blocksdk interfaces and
// concrete types on the provided LegacyAmino codec. These types are used for
// Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgUpdateLane{}, "block-sdk/x/blocksdk/MsgUpdateLane")
}
// RegisterInterfaces registers the x/blocksdk interfaces types with the
// interface registry.
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgUpdateLane{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
+28
View File
@@ -0,0 +1,28 @@
package types
import (
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ sdk.Msg = &MsgUpdateLane{}
// GetSignBytes implements the LegacyMsg interface.
func (m *MsgUpdateLane) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgUpdateLane message.
func (m *MsgUpdateLane) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(m.Authority)
return []sdk.AccAddress{addr}
}
// ValidateBasic does a sanity check on the provided data.
func (m *MsgUpdateLane) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return errors.Wrap(err, "invalid authority address")
}
return m.Lane.ValidateBasic()
}
+79
View File
@@ -0,0 +1,79 @@
package types_test
import (
"math/rand"
"testing"
"time"
"cosmossdk.io/math"
"github.com/skip-mev/block-sdk/testutils"
"github.com/skip-mev/block-sdk/x/blocksdk/types"
)
func TestMsgUpdateLane_ValidateBasic(t *testing.T) {
testAcc := testutils.RandomAccounts(rand.New(rand.NewSource(time.Now().Unix())), 1)[0]
tests := []struct {
name string
msg types.MsgUpdateLane
wantErr bool
}{
{
name: "invalid empty authority",
msg: types.MsgUpdateLane{
Authority: "",
Lane: types.Lane{
Id: "free",
MaxBlockSpace: math.LegacyOneDec(),
Order: 0,
},
},
wantErr: true,
},
{
name: "invalid authority",
msg: types.MsgUpdateLane{
Authority: "invalid",
Lane: types.Lane{
Id: "free",
MaxBlockSpace: math.LegacyOneDec(),
Order: 0,
},
},
wantErr: true,
},
{
name: "invalid lane",
msg: types.MsgUpdateLane{
Authority: testAcc.Address.String(),
Lane: types.Lane{
Id: "",
MaxBlockSpace: math.LegacyOneDec(),
Order: 0,
},
},
wantErr: true,
},
{
name: "valid",
msg: types.MsgUpdateLane{
Authority: testAcc.Address.String(),
Lane: types.Lane{
Id: "free",
MaxBlockSpace: math.LegacyOneDec(),
Order: 0,
},
},
wantErr: false,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
if err := tc.msg.ValidateBasic(); (err != nil) != tc.wantErr {
t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tc.wantErr)
}
})
}
}
+932
View File
@@ -0,0 +1,932 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: sdk/blocksdk/v1/query.proto
package types
import (
context "context"
fmt "fmt"
_ "github.com/cosmos/cosmos-sdk/types/query"
_ "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
// QueryLaneRequest is the request type for the Query/Lane RPC method.
type QueryLaneRequest struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (m *QueryLaneRequest) Reset() { *m = QueryLaneRequest{} }
func (m *QueryLaneRequest) String() string { return proto.CompactTextString(m) }
func (*QueryLaneRequest) ProtoMessage() {}
func (*QueryLaneRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_0c631e2e97c81d34, []int{0}
}
func (m *QueryLaneRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryLaneRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryLaneRequest.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 *QueryLaneRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryLaneRequest.Merge(m, src)
}
func (m *QueryLaneRequest) XXX_Size() int {
return m.Size()
}
func (m *QueryLaneRequest) XXX_DiscardUnknown() {
xxx_messageInfo_QueryLaneRequest.DiscardUnknown(m)
}
var xxx_messageInfo_QueryLaneRequest proto.InternalMessageInfo
func (m *QueryLaneRequest) GetId() string {
if m != nil {
return m.Id
}
return ""
}
// QueryLaneResponse is the response type for the Query/Lane RPC method.
type QueryLaneResponse struct {
Lane Lane `protobuf:"bytes,1,opt,name=lane,proto3" json:"lane"`
}
func (m *QueryLaneResponse) Reset() { *m = QueryLaneResponse{} }
func (m *QueryLaneResponse) String() string { return proto.CompactTextString(m) }
func (*QueryLaneResponse) ProtoMessage() {}
func (*QueryLaneResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_0c631e2e97c81d34, []int{1}
}
func (m *QueryLaneResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryLaneResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryLaneResponse.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 *QueryLaneResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryLaneResponse.Merge(m, src)
}
func (m *QueryLaneResponse) XXX_Size() int {
return m.Size()
}
func (m *QueryLaneResponse) XXX_DiscardUnknown() {
xxx_messageInfo_QueryLaneResponse.DiscardUnknown(m)
}
var xxx_messageInfo_QueryLaneResponse proto.InternalMessageInfo
func (m *QueryLaneResponse) GetLane() Lane {
if m != nil {
return m.Lane
}
return Lane{}
}
// QueryLaneRequest is the request type for the Query/Lanes RPC method.
type QueryLanesRequest struct {
}
func (m *QueryLanesRequest) Reset() { *m = QueryLanesRequest{} }
func (m *QueryLanesRequest) String() string { return proto.CompactTextString(m) }
func (*QueryLanesRequest) ProtoMessage() {}
func (*QueryLanesRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_0c631e2e97c81d34, []int{2}
}
func (m *QueryLanesRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryLanesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryLanesRequest.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 *QueryLanesRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryLanesRequest.Merge(m, src)
}
func (m *QueryLanesRequest) XXX_Size() int {
return m.Size()
}
func (m *QueryLanesRequest) XXX_DiscardUnknown() {
xxx_messageInfo_QueryLanesRequest.DiscardUnknown(m)
}
var xxx_messageInfo_QueryLanesRequest proto.InternalMessageInfo
// QueryLaneResponse is the response type for the Query/Lanes RPC method.
type QueryLanesResponse struct {
Lanes []Lane `protobuf:"bytes,1,rep,name=lanes,proto3" json:"lanes"`
}
func (m *QueryLanesResponse) Reset() { *m = QueryLanesResponse{} }
func (m *QueryLanesResponse) String() string { return proto.CompactTextString(m) }
func (*QueryLanesResponse) ProtoMessage() {}
func (*QueryLanesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_0c631e2e97c81d34, []int{3}
}
func (m *QueryLanesResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryLanesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryLanesResponse.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 *QueryLanesResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryLanesResponse.Merge(m, src)
}
func (m *QueryLanesResponse) XXX_Size() int {
return m.Size()
}
func (m *QueryLanesResponse) XXX_DiscardUnknown() {
xxx_messageInfo_QueryLanesResponse.DiscardUnknown(m)
}
var xxx_messageInfo_QueryLanesResponse proto.InternalMessageInfo
func (m *QueryLanesResponse) GetLanes() []Lane {
if m != nil {
return m.Lanes
}
return nil
}
func init() {
proto.RegisterType((*QueryLaneRequest)(nil), "sdk.blocksdk.v1.QueryLaneRequest")
proto.RegisterType((*QueryLaneResponse)(nil), "sdk.blocksdk.v1.QueryLaneResponse")
proto.RegisterType((*QueryLanesRequest)(nil), "sdk.blocksdk.v1.QueryLanesRequest")
proto.RegisterType((*QueryLanesResponse)(nil), "sdk.blocksdk.v1.QueryLanesResponse")
}
func init() { proto.RegisterFile("sdk/blocksdk/v1/query.proto", fileDescriptor_0c631e2e97c81d34) }
var fileDescriptor_0c631e2e97c81d34 = []byte{
// 371 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcf, 0x4a, 0xeb, 0x40,
0x14, 0x87, 0x93, 0xdc, 0xf6, 0xc2, 0x9d, 0x0b, 0xfe, 0x19, 0x15, 0x4a, 0x5a, 0xc6, 0x3a, 0x6e,
0x54, 0xe8, 0x0c, 0xad, 0x6f, 0x50, 0x04, 0x5d, 0xb8, 0xb1, 0x4b, 0x77, 0x69, 0x33, 0xc4, 0x21,
0x6d, 0x26, 0xed, 0xa4, 0xc5, 0x52, 0xdd, 0x74, 0xe5, 0x52, 0xf0, 0x45, 0x7c, 0x8c, 0x2e, 0x0b,
0x6e, 0x5c, 0x89, 0xb4, 0x82, 0xaf, 0x21, 0x33, 0x49, 0x6d, 0x88, 0x10, 0x77, 0x87, 0x39, 0xdf,
0x7c, 0xe7, 0x77, 0x86, 0x01, 0x65, 0xe9, 0xfa, 0xb4, 0xdd, 0x15, 0x1d, 0x5f, 0x15, 0xa3, 0x3a,
0xed, 0x0f, 0xd9, 0x60, 0x4c, 0xc2, 0x81, 0x88, 0x04, 0xdc, 0x94, 0xae, 0x4f, 0x56, 0x4d, 0x32,
0xaa, 0xdb, 0x15, 0x4f, 0x08, 0xaf, 0xcb, 0xa8, 0x13, 0x72, 0xea, 0x04, 0x81, 0x88, 0x9c, 0x88,
0x8b, 0x40, 0xc6, 0xb8, 0xbd, 0xeb, 0x09, 0x4f, 0xe8, 0x92, 0xaa, 0x2a, 0x39, 0x2d, 0x77, 0x84,
0xec, 0x09, 0x19, 0x8b, 0x33, 0x13, 0x6c, 0x94, 0x1d, 0xff, 0x3d, 0x4d, 0xf7, 0x31, 0x06, 0x5b,
0x57, 0x0a, 0xbf, 0x74, 0x02, 0xd6, 0x62, 0xfd, 0x21, 0x93, 0x11, 0xdc, 0x00, 0x16, 0x77, 0x4b,
0x66, 0xd5, 0x3c, 0xfa, 0xd7, 0xb2, 0xb8, 0x8b, 0xcf, 0xc0, 0x76, 0x8a, 0x91, 0xa1, 0x08, 0x24,
0x83, 0x14, 0x14, 0xba, 0x4e, 0xc0, 0x34, 0xf6, 0xbf, 0xb1, 0x47, 0x32, 0x9b, 0x10, 0x05, 0x37,
0x0b, 0xb3, 0xb7, 0x7d, 0xa3, 0xa5, 0x41, 0xbc, 0x93, 0xb2, 0xc8, 0x64, 0x14, 0x3e, 0x07, 0x30,
0x7d, 0x98, 0xb8, 0xeb, 0xa0, 0xa8, 0xae, 0xc8, 0x92, 0x59, 0xfd, 0xf3, 0x9b, 0x3c, 0x26, 0x1b,
0x53, 0x0b, 0x14, 0xb5, 0x09, 0xde, 0x81, 0x82, 0x6a, 0xc3, 0x83, 0x1f, 0xb7, 0xb2, 0x8b, 0xda,
0x38, 0x0f, 0x89, 0xb3, 0xe0, 0xda, 0xc3, 0xe7, 0xf3, 0x89, 0x39, 0x7d, 0xf9, 0x78, 0xb2, 0x30,
0xac, 0xc6, 0xcf, 0x57, 0xcb, 0x3e, 0xaa, 0xca, 0x40, 0x27, 0xdc, 0xbd, 0x87, 0x13, 0x50, 0xd4,
0xbb, 0xc0, 0x1c, 0xf7, 0x6a, 0x7b, 0xfb, 0x30, 0x97, 0x49, 0x02, 0x1c, 0xaf, 0x03, 0x20, 0x58,
0xc9, 0x09, 0x20, 0x9b, 0x17, 0xb3, 0x05, 0x32, 0xe7, 0x0b, 0x64, 0xbe, 0x2f, 0x90, 0xf9, 0xb8,
0x44, 0xc6, 0x7c, 0x89, 0x8c, 0xd7, 0x25, 0x32, 0xae, 0x89, 0xc7, 0xa3, 0x9b, 0x61, 0x9b, 0x74,
0x44, 0x8f, 0x4a, 0x9f, 0x87, 0xb5, 0x1e, 0x1b, 0xa5, 0x54, 0xb7, 0x6b, 0x59, 0x34, 0x0e, 0x99,
0x6c, 0xff, 0xd5, 0xbf, 0xe3, 0xf4, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x49, 0x58, 0x65, 0x30, 0xbe,
0x02, 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 {
// Lane queries the a lane by its id.
Lane(ctx context.Context, in *QueryLaneRequest, opts ...grpc.CallOption) (*QueryLaneResponse, error)
// Lane queries all lanes in the x/blocksdk module
Lanes(ctx context.Context, in *QueryLanesRequest, opts ...grpc.CallOption) (*QueryLanesResponse, error)
}
type queryClient struct {
cc grpc1.ClientConn
}
func NewQueryClient(cc grpc1.ClientConn) QueryClient {
return &queryClient{cc}
}
func (c *queryClient) Lane(ctx context.Context, in *QueryLaneRequest, opts ...grpc.CallOption) (*QueryLaneResponse, error) {
out := new(QueryLaneResponse)
err := c.cc.Invoke(ctx, "/sdk.blocksdk.v1.Query/Lane", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *queryClient) Lanes(ctx context.Context, in *QueryLanesRequest, opts ...grpc.CallOption) (*QueryLanesResponse, error) {
out := new(QueryLanesResponse)
err := c.cc.Invoke(ctx, "/sdk.blocksdk.v1.Query/Lanes", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// QueryServer is the server API for Query service.
type QueryServer interface {
// Lane queries the a lane by its id.
Lane(context.Context, *QueryLaneRequest) (*QueryLaneResponse, error)
// Lane queries all lanes in the x/blocksdk module
Lanes(context.Context, *QueryLanesRequest) (*QueryLanesResponse, error)
}
// UnimplementedQueryServer can be embedded to have forward compatible implementations.
type UnimplementedQueryServer struct {
}
func (*UnimplementedQueryServer) Lane(ctx context.Context, req *QueryLaneRequest) (*QueryLaneResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Lane not implemented")
}
func (*UnimplementedQueryServer) Lanes(ctx context.Context, req *QueryLanesRequest) (*QueryLanesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Lanes not implemented")
}
func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
s.RegisterService(&_Query_serviceDesc, srv)
}
func _Query_Lane_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryLaneRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).Lane(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/sdk.blocksdk.v1.Query/Lane",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Lane(ctx, req.(*QueryLaneRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Query_Lanes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryLanesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).Lanes(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/sdk.blocksdk.v1.Query/Lanes",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Lanes(ctx, req.(*QueryLanesRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Query_serviceDesc = grpc.ServiceDesc{
ServiceName: "sdk.blocksdk.v1.Query",
HandlerType: (*QueryServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Lane",
Handler: _Query_Lane_Handler,
},
{
MethodName: "Lanes",
Handler: _Query_Lanes_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "sdk/blocksdk/v1/query.proto",
}
func (m *QueryLaneRequest) 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 *QueryLaneRequest) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryLaneRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Id) > 0 {
i -= len(m.Id)
copy(dAtA[i:], m.Id)
i = encodeVarintQuery(dAtA, i, uint64(len(m.Id)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *QueryLaneResponse) 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 *QueryLaneResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryLaneResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size, err := m.Lane.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 *QueryLanesRequest) 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 *QueryLanesRequest) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryLanesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func (m *QueryLanesResponse) 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 *QueryLanesResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryLanesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Lanes) > 0 {
for iNdEx := len(m.Lanes) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Lanes[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 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 *QueryLaneRequest) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Id)
if l > 0 {
n += 1 + l + sovQuery(uint64(l))
}
return n
}
func (m *QueryLaneResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = m.Lane.Size()
n += 1 + l + sovQuery(uint64(l))
return n
}
func (m *QueryLanesRequest) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func (m *QueryLanesResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if len(m.Lanes) > 0 {
for _, e := range m.Lanes {
l = e.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 *QueryLaneRequest) 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: QueryLaneRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryLaneRequest: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Id", 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.Id = 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 *QueryLaneResponse) 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: QueryLaneResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryLaneResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Lane", 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.Lane.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 *QueryLanesRequest) 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: QueryLanesRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryLanesRequest: 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 *QueryLanesResponse) 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: QueryLanesResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryLanesResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Lanes", 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.Lanes = append(m.Lanes, Lane{})
if err := m.Lanes[len(m.Lanes)-1].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")
)
+254
View File
@@ -0,0 +1,254 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: sdk/blocksdk/v1/query.proto
/*
Package types is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package types
import (
"context"
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
var _ = metadata.Join
func request_Query_Lane_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryLaneRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
}
protoReq.Id, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
}
msg, err := client.Lane(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Lane_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryLaneRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
}
protoReq.Id, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
}
msg, err := server.Lane(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_Lanes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryLanesRequest
var metadata runtime.ServerMetadata
msg, err := client.Lanes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Lanes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryLanesRequest
var metadata runtime.ServerMetadata
msg, err := server.Lanes(ctx, &protoReq)
return msg, metadata, err
}
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
// UnaryRPC :call QueryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
mux.Handle("GET", pattern_Query_Lane_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Lane_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Lane_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Lanes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Lanes_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Lanes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterQueryHandler(ctx, mux, conn)
}
// RegisterQueryHandler registers the http handlers for service Query to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
}
// RegisterQueryHandlerClient registers the http handlers for service Query
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "QueryClient" to call the correct interceptors.
func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
mux.Handle("GET", pattern_Query_Lane_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_Lane_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Lane_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_Lanes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_Lanes_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Lanes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Query_Lane_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"block-sdk", "blocksdk", "v1", "lane", "id"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Lanes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"block-sdk", "blocksdk", "v1", "lanes"}, "", runtime.AssumeColonVerbOpt(false)))
)
var (
forward_Query_Lane_0 = runtime.ForwardResponseMessage
forward_Query_Lanes_0 = runtime.ForwardResponseMessage
)
+592
View File
@@ -0,0 +1,592 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: sdk/blocksdk/v1/tx.proto
package types
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
// MsgUpdateLane defines a request to update an existing lane in the store.
type MsgUpdateLane struct {
Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
Lane Lane `protobuf:"bytes,2,opt,name=lane,proto3" json:"lane"`
}
func (m *MsgUpdateLane) Reset() { *m = MsgUpdateLane{} }
func (m *MsgUpdateLane) String() string { return proto.CompactTextString(m) }
func (*MsgUpdateLane) ProtoMessage() {}
func (*MsgUpdateLane) Descriptor() ([]byte, []int) {
return fileDescriptor_fc6ccd9f56097321, []int{0}
}
func (m *MsgUpdateLane) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgUpdateLane) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgUpdateLane.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 *MsgUpdateLane) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgUpdateLane.Merge(m, src)
}
func (m *MsgUpdateLane) XXX_Size() int {
return m.Size()
}
func (m *MsgUpdateLane) XXX_DiscardUnknown() {
xxx_messageInfo_MsgUpdateLane.DiscardUnknown(m)
}
var xxx_messageInfo_MsgUpdateLane proto.InternalMessageInfo
func (m *MsgUpdateLane) GetAuthority() string {
if m != nil {
return m.Authority
}
return ""
}
func (m *MsgUpdateLane) GetLane() Lane {
if m != nil {
return m.Lane
}
return Lane{}
}
// MsgUpdateLaneResponse defines a response to update an existing lane in the
// store.
type MsgUpdateLaneResponse struct {
}
func (m *MsgUpdateLaneResponse) Reset() { *m = MsgUpdateLaneResponse{} }
func (m *MsgUpdateLaneResponse) String() string { return proto.CompactTextString(m) }
func (*MsgUpdateLaneResponse) ProtoMessage() {}
func (*MsgUpdateLaneResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_fc6ccd9f56097321, []int{1}
}
func (m *MsgUpdateLaneResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgUpdateLaneResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgUpdateLaneResponse.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 *MsgUpdateLaneResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgUpdateLaneResponse.Merge(m, src)
}
func (m *MsgUpdateLaneResponse) XXX_Size() int {
return m.Size()
}
func (m *MsgUpdateLaneResponse) XXX_DiscardUnknown() {
xxx_messageInfo_MsgUpdateLaneResponse.DiscardUnknown(m)
}
var xxx_messageInfo_MsgUpdateLaneResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*MsgUpdateLane)(nil), "sdk.blocksdk.v1.MsgUpdateLane")
proto.RegisterType((*MsgUpdateLaneResponse)(nil), "sdk.blocksdk.v1.MsgUpdateLaneResponse")
}
func init() { proto.RegisterFile("sdk/blocksdk/v1/tx.proto", fileDescriptor_fc6ccd9f56097321) }
var fileDescriptor_fc6ccd9f56097321 = []byte{
// 348 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x4e, 0xc9, 0xd6,
0x4f, 0xca, 0xc9, 0x4f, 0xce, 0x06, 0x31, 0xca, 0x0c, 0xf5, 0x4b, 0x2a, 0xf4, 0x0a, 0x8a, 0xf2,
0x4b, 0xf2, 0x85, 0xf8, 0x8b, 0x53, 0xb2, 0xf5, 0x60, 0x32, 0x7a, 0x65, 0x86, 0x52, 0x22, 0xe9,
0xf9, 0xe9, 0xf9, 0x60, 0x39, 0x7d, 0x10, 0x0b, 0xa2, 0x4c, 0x4a, 0x3c, 0x39, 0xbf, 0x38, 0x37,
0xbf, 0x58, 0x3f, 0xb7, 0x38, 0x1d, 0xa4, 0x3d, 0xb7, 0x38, 0x1d, 0x2a, 0x21, 0x09, 0x91, 0x88,
0x87, 0xe8, 0x80, 0x70, 0xa0, 0x52, 0x82, 0x89, 0xb9, 0x99, 0x79, 0xf9, 0xfa, 0x60, 0x12, 0x2a,
0x24, 0x87, 0xee, 0x0e, 0xb8, 0xcd, 0x60, 0x79, 0xa5, 0xcd, 0x8c, 0x5c, 0xbc, 0xbe, 0xc5, 0xe9,
0xa1, 0x05, 0x29, 0x89, 0x25, 0xa9, 0x3e, 0x89, 0x79, 0xa9, 0x42, 0x66, 0x5c, 0x9c, 0x89, 0xa5,
0x25, 0x19, 0xf9, 0x45, 0x99, 0x25, 0x95, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x12, 0x97,
0xb6, 0xe8, 0x8a, 0x40, 0x6d, 0x72, 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, 0x0e, 0x2e, 0x29, 0xca,
0xcc, 0x4b, 0x0f, 0x42, 0x28, 0x15, 0xd2, 0xe7, 0x62, 0xc9, 0x49, 0xcc, 0x4b, 0x95, 0x60, 0x52,
0x60, 0xd4, 0xe0, 0x36, 0x12, 0xd5, 0x43, 0xf3, 0xa6, 0x1e, 0xc8, 0x70, 0x27, 0x96, 0x13, 0xf7,
0xe4, 0x19, 0x82, 0xc0, 0x0a, 0xad, 0x2c, 0x5f, 0x2c, 0x90, 0x67, 0x68, 0x7a, 0xbe, 0x41, 0x0b,
0x61, 0x48, 0xd7, 0xf3, 0x0d, 0x5a, 0x4a, 0x60, 0x4d, 0xba, 0x20, 0xe7, 0x56, 0x20, 0x5c, 0x8e,
0xe2, 0x46, 0x25, 0x71, 0x2e, 0x51, 0x14, 0x81, 0xa0, 0xd4, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54,
0xa3, 0x24, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x10, 0x2e, 0x2e, 0x24, 0x1f, 0xc9, 0x61, 0xb8,
0x05, 0x45, 0xb3, 0x94, 0x1a, 0x7e, 0x79, 0x98, 0xe1, 0x52, 0xac, 0x0d, 0xcf, 0x37, 0x68, 0x31,
0x3a, 0x79, 0x9c, 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, 0x5e, 0x7a, 0x66,
0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x71, 0x76, 0x66, 0x81, 0x6e, 0x6e, 0x6a,
0x99, 0x3e, 0x56, 0xef, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xe3, 0xc0, 0x18, 0x10,
0x00, 0x00, 0xff, 0xff, 0x9b, 0x33, 0x0c, 0xc1, 0x2d, 0x02, 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 {
// UpdateLane defines a method to update an existing lane in the store.
UpdateLane(ctx context.Context, in *MsgUpdateLane, opts ...grpc.CallOption) (*MsgUpdateLaneResponse, error)
}
type msgClient struct {
cc grpc1.ClientConn
}
func NewMsgClient(cc grpc1.ClientConn) MsgClient {
return &msgClient{cc}
}
func (c *msgClient) UpdateLane(ctx context.Context, in *MsgUpdateLane, opts ...grpc.CallOption) (*MsgUpdateLaneResponse, error) {
out := new(MsgUpdateLaneResponse)
err := c.cc.Invoke(ctx, "/sdk.blocksdk.v1.Msg/UpdateLane", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
type MsgServer interface {
// UpdateLane defines a method to update an existing lane in the store.
UpdateLane(context.Context, *MsgUpdateLane) (*MsgUpdateLaneResponse, error)
}
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
type UnimplementedMsgServer struct {
}
func (*UnimplementedMsgServer) UpdateLane(ctx context.Context, req *MsgUpdateLane) (*MsgUpdateLaneResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateLane not implemented")
}
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
s.RegisterService(&_Msg_serviceDesc, srv)
}
func _Msg_UpdateLane_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgUpdateLane)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).UpdateLane(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/sdk.blocksdk.v1.Msg/UpdateLane",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).UpdateLane(ctx, req.(*MsgUpdateLane))
}
return interceptor(ctx, in, info, handler)
}
var _Msg_serviceDesc = grpc.ServiceDesc{
ServiceName: "sdk.blocksdk.v1.Msg",
HandlerType: (*MsgServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "UpdateLane",
Handler: _Msg_UpdateLane_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "sdk/blocksdk/v1/tx.proto",
}
func (m *MsgUpdateLane) 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 *MsgUpdateLane) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgUpdateLane) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size, err := m.Lane.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 *MsgUpdateLaneResponse) 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 *MsgUpdateLaneResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgUpdateLaneResponse) 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 *MsgUpdateLane) 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.Lane.Size()
n += 1 + l + sovTx(uint64(l))
return n
}
func (m *MsgUpdateLaneResponse) 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 *MsgUpdateLane) 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: MsgUpdateLane: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgUpdateLane: 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 Lane", 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.Lane.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 *MsgUpdateLaneResponse) 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: MsgUpdateLaneResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgUpdateLaneResponse: 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")
)
+171
View File
@@ -0,0 +1,171 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: sdk/blocksdk/v1/tx.proto
/*
Package types is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package types
import (
"context"
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
var _ = metadata.Join
var (
filter_Msg_UpdateLane_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_Msg_UpdateLane_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq MsgUpdateLane
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UpdateLane_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.UpdateLane(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Msg_UpdateLane_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq MsgUpdateLane
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UpdateLane_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.UpdateLane(ctx, &protoReq)
return msg, metadata, err
}
// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux".
// UnaryRPC :call MsgServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead.
func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error {
mux.Handle("POST", pattern_Msg_UpdateLane_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Msg_UpdateLane_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Msg_UpdateLane_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterMsgHandler(ctx, mux, conn)
}
// RegisterMsgHandler registers the http handlers for service Msg to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn))
}
// RegisterMsgHandlerClient registers the http handlers for service Msg
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "MsgClient" to call the correct interceptors.
func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error {
mux.Handle("POST", pattern_Msg_UpdateLane_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Msg_UpdateLane_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Msg_UpdateLane_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Msg_UpdateLane_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"block-sdk", "blocksdk", "v1", "update_lane"}, "", runtime.AssumeColonVerbOpt(false)))
)
var (
forward_Msg_UpdateLane_0 = runtime.ForwardResponseMessage
)