forked from cerc-io/laconicd
Add commands to create and list bonds (#3)
* Add message service with a create bond command * Add query proto file with bonds list query * Remove legacy amino coded registration * Add bond to auth module config * Use collections package for bond module state
This commit is contained in:
parent
5ee988ccd8
commit
e511051f3e
@ -608,6 +608,7 @@ type GenesisState struct {
|
||||
// params defines all the parameters of the module.
|
||||
Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"`
|
||||
// bonds defines all the bonds
|
||||
// TODO: Add nullable = false ?
|
||||
Bonds []*Bond `protobuf:"bytes,2,rep,name=bonds,proto3" json:"bonds,omitempty"`
|
||||
}
|
||||
|
||||
|
1255
api/cerc/bond/v1/query.pulsar.go
Normal file
1255
api/cerc/bond/v1/query.pulsar.go
Normal file
File diff suppressed because it is too large
Load Diff
111
api/cerc/bond/v1/query_grpc.pb.go
Normal file
111
api/cerc/bond/v1/query_grpc.pb.go
Normal file
@ -0,0 +1,111 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc (unknown)
|
||||
// source: cerc/bond/v1/query.proto
|
||||
|
||||
package bondv1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
Query_Bonds_FullMethodName = "/cerc.bond.v1.Query/Bonds"
|
||||
)
|
||||
|
||||
// QueryClient is the client API for Query service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type QueryClient interface {
|
||||
// Bonds queries bonds list.
|
||||
Bonds(ctx context.Context, in *QueryGetBondsRequest, opts ...grpc.CallOption) (*QueryGetBondsResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewQueryClient(cc grpc.ClientConnInterface) QueryClient {
|
||||
return &queryClient{cc}
|
||||
}
|
||||
|
||||
func (c *queryClient) Bonds(ctx context.Context, in *QueryGetBondsRequest, opts ...grpc.CallOption) (*QueryGetBondsResponse, error) {
|
||||
out := new(QueryGetBondsResponse)
|
||||
err := c.cc.Invoke(ctx, Query_Bonds_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// QueryServer is the server API for Query service.
|
||||
// All implementations must embed UnimplementedQueryServer
|
||||
// for forward compatibility
|
||||
type QueryServer interface {
|
||||
// Bonds queries bonds list.
|
||||
Bonds(context.Context, *QueryGetBondsRequest) (*QueryGetBondsResponse, error)
|
||||
mustEmbedUnimplementedQueryServer()
|
||||
}
|
||||
|
||||
// UnimplementedQueryServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedQueryServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedQueryServer) Bonds(context.Context, *QueryGetBondsRequest) (*QueryGetBondsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Bonds not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {}
|
||||
|
||||
// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to QueryServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeQueryServer interface {
|
||||
mustEmbedUnimplementedQueryServer()
|
||||
}
|
||||
|
||||
func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) {
|
||||
s.RegisterService(&Query_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Query_Bonds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryGetBondsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).Bonds(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Query_Bonds_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).Bonds(ctx, req.(*QueryGetBondsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Query_ServiceDesc is the grpc.ServiceDesc for Query service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Query_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cerc.bond.v1.Query",
|
||||
HandlerType: (*QueryServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Bonds",
|
||||
Handler: _Query_Bonds_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/bond/v1/query.proto",
|
||||
}
|
1216
api/cerc/bond/v1/tx.pulsar.go
Normal file
1216
api/cerc/bond/v1/tx.pulsar.go
Normal file
File diff suppressed because it is too large
Load Diff
111
api/cerc/bond/v1/tx_grpc.pb.go
Normal file
111
api/cerc/bond/v1/tx_grpc.pb.go
Normal file
@ -0,0 +1,111 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc (unknown)
|
||||
// source: cerc/bond/v1/tx.proto
|
||||
|
||||
package bondv1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
Msg_CreateBond_FullMethodName = "/cerc.bond.v1.Msg/CreateBond"
|
||||
)
|
||||
|
||||
// MsgClient is the client API for Msg service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type MsgClient interface {
|
||||
// CreateBond defines a method for creating a new bond.
|
||||
CreateBond(ctx context.Context, in *MsgCreateBond, opts ...grpc.CallOption) (*MsgCreateBondResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewMsgClient(cc grpc.ClientConnInterface) MsgClient {
|
||||
return &msgClient{cc}
|
||||
}
|
||||
|
||||
func (c *msgClient) CreateBond(ctx context.Context, in *MsgCreateBond, opts ...grpc.CallOption) (*MsgCreateBondResponse, error) {
|
||||
out := new(MsgCreateBondResponse)
|
||||
err := c.cc.Invoke(ctx, Msg_CreateBond_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
// All implementations must embed UnimplementedMsgServer
|
||||
// for forward compatibility
|
||||
type MsgServer interface {
|
||||
// CreateBond defines a method for creating a new bond.
|
||||
CreateBond(context.Context, *MsgCreateBond) (*MsgCreateBondResponse, error)
|
||||
mustEmbedUnimplementedMsgServer()
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedMsgServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedMsgServer) CreateBond(context.Context, *MsgCreateBond) (*MsgCreateBondResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateBond not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
|
||||
|
||||
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to MsgServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeMsgServer interface {
|
||||
mustEmbedUnimplementedMsgServer()
|
||||
}
|
||||
|
||||
func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) {
|
||||
s.RegisterService(&Msg_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Msg_CreateBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgCreateBond)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).CreateBond(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Msg_CreateBond_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).CreateBond(ctx, req.(*MsgCreateBond))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cerc.bond.v1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CreateBond",
|
||||
Handler: _Msg_CreateBond_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/bond/v1/tx.proto",
|
||||
}
|
@ -25,6 +25,7 @@ modules:
|
||||
permissions: [burner, staking]
|
||||
- account: not_bonded_tokens_pool
|
||||
permissions: [burner, staking]
|
||||
- account: bond
|
||||
- name: bank
|
||||
config:
|
||||
"@type": cosmos.bank.module.v1.Module
|
||||
|
6
go.mod
6
go.mod
@ -27,9 +27,12 @@ require (
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.3
|
||||
github.com/cosmos/cosmos-sdk v0.50.3
|
||||
github.com/cosmos/gogoproto v1.4.11
|
||||
github.com/golang/protobuf v1.5.3
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0
|
||||
github.com/spf13/cobra v1.8.0
|
||||
github.com/spf13/viper v1.17.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f
|
||||
google.golang.org/grpc v1.60.1
|
||||
google.golang.org/protobuf v1.32.0
|
||||
)
|
||||
|
||||
@ -84,7 +87,6 @@ require (
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/glog v1.2.0 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/btree v1.1.2 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
@ -159,9 +161,7 @@ require (
|
||||
golang.org/x/term v0.15.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
|
||||
google.golang.org/grpc v1.60.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
@ -10,8 +10,7 @@ import "cosmos/base/v1beta1/coin.proto";
|
||||
// Params defines the parameters of the bond module.
|
||||
message Params {
|
||||
// max_bond_amount is maximum amount to bond
|
||||
cosmos.base.v1beta1.Coin max_bond_amount = 1
|
||||
[
|
||||
cosmos.base.v1beta1.Coin max_bond_amount = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "json:\"max_bond_amount\" yaml:\"max_bond_amount\""
|
||||
];
|
||||
|
@ -1 +0,0 @@
|
||||
// Not present in laconicd
|
@ -13,5 +13,6 @@ message GenesisState {
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
// bonds defines all the bonds
|
||||
// TODO: Add nullable = false ?
|
||||
repeated Bond bonds = 2 [(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""];
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cerc.bond.v1;
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconic2d/x/bond";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cerc/bond/v1/bond.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/query/v1beta1/pagination.proto";
|
||||
// import "cosmos/query/v1/query.proto";
|
||||
|
||||
// Query defines the gRPC querier service for bond module
|
||||
service Query {
|
||||
// Bonds queries bonds list.
|
||||
rpc Bonds(QueryGetBondsRequest) returns (QueryGetBondsResponse) {
|
||||
// option (cosmos.query.v1.module_query_safe) = true; // Add?
|
||||
option (google.api.http).get = "/cerc/bond/v1/bonds";
|
||||
}
|
||||
}
|
||||
|
||||
// QueryGetBondById queries a bonds.
|
||||
message QueryGetBondsRequest {
|
||||
// pagination defines an optional pagination for the request.
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
// QueryGetBondsResponse is response type for get the bonds by bond-id
|
||||
message QueryGetBondsResponse {
|
||||
repeated Bond bonds = 1 [(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""];
|
||||
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cerc.bond.v1;
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconic2d/x/bond";
|
||||
|
||||
import "cosmos/msg/v1/msg.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
// TODO: Add remaining messages
|
||||
|
||||
// Msg defines the bond Msg service.
|
||||
service Msg {
|
||||
option (cosmos.msg.v1.service) = true;
|
||||
|
||||
// CreateBond defines a method for creating a new bond.
|
||||
rpc CreateBond(MsgCreateBond) returns (MsgCreateBondResponse) {
|
||||
option (google.api.http).post = "/cerc/bond/v1/create_bond";
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// MsgCreateBond defines a SDK message for creating a new bond.
|
||||
message MsgCreateBond {
|
||||
option (cosmos.msg.v1.signer) = "signer";
|
||||
|
||||
string signer = 1;
|
||||
repeated cosmos.base.v1beta1.Coin coins = 2 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "json:\"coins\" yaml:\"coins\""
|
||||
];
|
||||
}
|
||||
|
||||
// MsgCreateBondResponse defines the Msg/CreateBond response type.
|
||||
message MsgCreateBondResponse {
|
||||
string id = 1;
|
||||
}
|
@ -1,26 +1,18 @@
|
||||
package bond
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
types "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
)
|
||||
|
||||
// RegisterLegacyAminoCodec registers the necessary x/bond interfaces and concrete types
|
||||
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
|
||||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
// cdc.RegisterConcrete(&MsgCreateBond{}, "bond/MsgCreateBond", nil)
|
||||
// cdc.RegisterConcrete(&MsgRefillBond{}, "bond/MsgRefillBond", nil)
|
||||
// cdc.RegisterConcrete(&MsgWithdrawBond{}, "bond/MsgWithdrawBond", nil)
|
||||
// cdc.RegisterConcrete(&MsgCancelBond{}, "bond/MsgCancelBond", nil)
|
||||
}
|
||||
|
||||
// RegisterInterfaces registers the interfaces types with the interface registry.
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
// registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
// &MsgCreateBond{},
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgCreateBond{},
|
||||
// &MsgRefillBond{},
|
||||
// &MsgCancelBond{},
|
||||
// &MsgWithdrawBond{},
|
||||
// )
|
||||
// msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
)
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
15
x/bond/events.go
Normal file
15
x/bond/events.go
Normal file
@ -0,0 +1,15 @@
|
||||
package bond
|
||||
|
||||
// bond module event types
|
||||
|
||||
const (
|
||||
EventTypeCreateBond = "crate_bond"
|
||||
EventTypeRefillBond = "refill_bond"
|
||||
EventTypeCancelBond = "cancel_bond"
|
||||
EventTypeWithdrawBond = "withdraw_bond"
|
||||
|
||||
AttributeKeySigner = "signer"
|
||||
AttributeKeyAmount = "amount"
|
||||
AttributeKeyBondID = "bond_id"
|
||||
AttributeValueCategory = ModuleName
|
||||
)
|
@ -28,6 +28,7 @@ type GenesisState struct {
|
||||
// params defines all the parameters of the module.
|
||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||
// bonds defines all the bonds
|
||||
// TODO: Add nullable = false ?
|
||||
Bonds []*Bond `protobuf:"bytes,2,rep,name=bonds,proto3" json:"bonds,omitempty" json:"bonds" yaml:"bonds"`
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,11 @@ import (
|
||||
func (k *Keeper) InitGenesis(ctx sdk.Context, data *bond.GenesisState) error {
|
||||
k.SetParams(ctx, data.Params)
|
||||
|
||||
// Save bonds in store.
|
||||
for _, bond := range data.Bonds {
|
||||
k.SaveBond(ctx, bond)
|
||||
if err := k.Bonds.Set(ctx, bond.Id, *bond); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -19,7 +22,11 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *bond.GenesisState) error {
|
||||
// ExportGenesis exports the module state to a genesis state.
|
||||
func (k *Keeper) ExportGenesis(ctx sdk.Context) (*bond.GenesisState, error) {
|
||||
params := k.GetParams(ctx)
|
||||
bonds := k.ListBonds(ctx)
|
||||
|
||||
bonds, err := k.ListBonds(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &bond.GenesisState{Params: params, Bonds: bonds}, nil
|
||||
}
|
||||
|
@ -1,38 +1,48 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"git.vdb.to/cerc-io/laconic2d/x/bond"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/store"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
|
||||
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
||||
)
|
||||
|
||||
// TODO: Add genesis.go?
|
||||
|
||||
type Keeper struct {
|
||||
// Store keys
|
||||
storeKey storetypes.StoreKey
|
||||
|
||||
// Codecs
|
||||
cdc codec.BinaryCodec
|
||||
|
||||
// External keepers
|
||||
// accountKeeper auth.AccountKeeper
|
||||
// bankKeeper bank.Keeper
|
||||
accountKeeper auth.AccountKeeper
|
||||
bankKeeper bank.Keeper
|
||||
|
||||
// Track bond usage in other cosmos-sdk modules (more like a usage tracker).
|
||||
// usageKeepers []types.BondUsageKeeper
|
||||
|
||||
// paramSubspace paramtypes.Subspace
|
||||
|
||||
// State management
|
||||
Schema collections.Schema
|
||||
Bonds collections.Map[string, bondtypes.Bond]
|
||||
}
|
||||
|
||||
// NewKeeper creates new instances of the bond Keeper
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec,
|
||||
// accountKeeper auth.AccountKeeper,
|
||||
// bankKeeper bank.Keeper,
|
||||
storeService store.KVStoreService,
|
||||
accountKeeper auth.AccountKeeper,
|
||||
bankKeeper bank.Keeper,
|
||||
// usageKeepers []types.BondUsageKeeper,
|
||||
storeKey storetypes.StoreKey,
|
||||
// ps paramtypes.Subspace,
|
||||
) Keeper {
|
||||
// set KeyTable if it has not already been set
|
||||
@ -40,26 +50,103 @@ func NewKeeper(
|
||||
// ps = ps.WithKeyTable(types.ParamKeyTable())
|
||||
// }
|
||||
|
||||
return Keeper{
|
||||
// accountKeeper: accountKeeper,
|
||||
// bankKeeper: bankKeeper,
|
||||
storeKey: storeKey,
|
||||
sb := collections.NewSchemaBuilder(storeService)
|
||||
k := Keeper{
|
||||
cdc: cdc,
|
||||
accountKeeper: accountKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
Bonds: collections.NewMap(sb, bondtypes.BondsKey, "bonds", collections.StringKey, codec.CollValue[bondtypes.Bond](cdc)),
|
||||
// usageKeepers: usageKeepers,
|
||||
// paramSubspace: ps,
|
||||
}
|
||||
|
||||
schema, err := sb.Build()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
k.Schema = schema
|
||||
|
||||
return k
|
||||
}
|
||||
|
||||
// TODO: Add keeper methods
|
||||
// BondID simplifies generation of bond IDs.
|
||||
type BondID struct {
|
||||
Address sdk.Address
|
||||
AccNum uint64
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
// SaveBond - saves a bond to the store.
|
||||
func (k Keeper) SaveBond(ctx sdk.Context, bond *bond.Bond) {
|
||||
// TODO: Implement
|
||||
// Generate creates the bond ID.
|
||||
func (bondID BondID) Generate() string {
|
||||
hasher := sha256.New()
|
||||
str := fmt.Sprintf("%s:%d:%d", bondID.Address.String(), bondID.AccNum, bondID.Sequence)
|
||||
hasher.Write([]byte(str))
|
||||
return hex.EncodeToString(hasher.Sum(nil))
|
||||
}
|
||||
|
||||
// CreateBond creates a new bond.
|
||||
func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins sdk.Coins) (*bondtypes.Bond, error) {
|
||||
// Check if account has funds.
|
||||
for _, coin := range coins {
|
||||
balance := k.bankKeeper.HasBalance(ctx, ownerAddress, coin)
|
||||
if !balance {
|
||||
return nil, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "failed to create bond; Insufficient funds")
|
||||
}
|
||||
}
|
||||
|
||||
// Generate bond ID.
|
||||
account := k.accountKeeper.GetAccount(ctx, ownerAddress)
|
||||
bondID := BondID{
|
||||
Address: ownerAddress,
|
||||
AccNum: account.GetAccountNumber(),
|
||||
Sequence: account.GetSequence(),
|
||||
}.Generate()
|
||||
|
||||
maxBondAmount := k.getMaxBondAmount(ctx)
|
||||
|
||||
bond := bondtypes.Bond{Id: bondID, Owner: ownerAddress.String(), Balance: coins}
|
||||
if bond.Balance.IsAnyGT(maxBondAmount) {
|
||||
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded.")
|
||||
}
|
||||
|
||||
// Move funds into the bond account module.
|
||||
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, bondtypes.ModuleName, bond.Balance)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Save bond in store.
|
||||
if err := k.Bonds.Set(ctx, bond.Id, bond); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &bond, nil
|
||||
}
|
||||
|
||||
// ListBonds - get all bonds.
|
||||
func (k Keeper) ListBonds(ctx sdk.Context) []*bond.Bond {
|
||||
// TODO: Implement
|
||||
var bonds []*bond.Bond
|
||||
return bonds
|
||||
func (k Keeper) ListBonds(ctx sdk.Context) ([]*bondtypes.Bond, error) {
|
||||
var bonds []*bondtypes.Bond
|
||||
|
||||
iter, err := k.Bonds.Iterate(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for ; iter.Valid(); iter.Next() {
|
||||
bond, err := iter.Value()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bonds = append(bonds, &bond)
|
||||
}
|
||||
|
||||
return bonds, nil
|
||||
}
|
||||
|
||||
func (k Keeper) getMaxBondAmount(ctx sdk.Context) sdk.Coins {
|
||||
params := k.GetParams(ctx)
|
||||
maxBondAmount := params.MaxBondAmount
|
||||
return sdk.NewCoins(maxBondAmount)
|
||||
}
|
||||
|
@ -1,15 +1,50 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconic2d/x/bond"
|
||||
)
|
||||
|
||||
type msgServer struct {
|
||||
k Keeper
|
||||
}
|
||||
|
||||
// TODO: Generate types
|
||||
// var _ bond.MsgServer = msgServer{}
|
||||
var _ bond.MsgServer = msgServer{}
|
||||
|
||||
// NewMsgServerImpl returns an implementation of the module MsgServer interface.
|
||||
// func NewMsgServerImpl(keeper Keeper) bond.MsgServer {
|
||||
// return &msgServer{k: keeper}
|
||||
// }
|
||||
func NewMsgServerImpl(keeper Keeper) bond.MsgServer {
|
||||
return &msgServer{k: keeper}
|
||||
}
|
||||
|
||||
// TODO: Add write methods
|
||||
// TODO: Add remaining write methods
|
||||
|
||||
func (ms msgServer) CreateBond(c context.Context, msg *bond.MsgCreateBond) (*bond.MsgCreateBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = ms.k.CreateBond(ctx, signerAddress, msg.Coins)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
bond.EventTypeCreateBond,
|
||||
sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer),
|
||||
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, bond.AttributeValueCategory),
|
||||
sdk.NewAttribute(bond.AttributeKeySigner, msg.Signer),
|
||||
),
|
||||
})
|
||||
|
||||
return &bond.MsgCreateBondResponse{}, nil
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
// GetMaxBondAmount max bond amount
|
||||
func (k Keeper) GetMaxBondAmount(ctx sdk.Context) (res sdk.Coin) {
|
||||
// TODO: Implement
|
||||
return sdk.Coin{}
|
||||
return sdk.NewCoin(sdk.DefaultBondDenom, bond.DefaultMaxBondAmountTokens)
|
||||
}
|
||||
|
||||
// GetParams - Get all parameter as types.Params.
|
||||
|
@ -1,15 +1,32 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.vdb.to/cerc-io/laconic2d/x/bond"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// TODO: Add remaining query methods
|
||||
|
||||
type queryServer struct {
|
||||
k Keeper
|
||||
}
|
||||
|
||||
// TODO: Generate types
|
||||
// var _ bond.QueryServer = queryServer{}
|
||||
var _ bond.QueryServer = queryServer{}
|
||||
|
||||
// NewQueryServerImpl returns an implementation of the module QueryServer.
|
||||
// func NewQueryServerImpl(k Keeper) checkers.QueryServer {
|
||||
// return queryServer{k}
|
||||
// }
|
||||
func NewQueryServerImpl(k Keeper) bond.QueryServer {
|
||||
return queryServer{k}
|
||||
}
|
||||
|
||||
// TODO: Add read methods
|
||||
func (qs queryServer) Bonds(c context.Context, _ *bond.QueryGetBondsRequest) (*bond.QueryGetBondsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
resp, err := qs.k.ListBonds(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &bond.QueryGetBondsResponse{Bonds: resp}, nil
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package bond
|
||||
|
||||
import "cosmossdk.io/collections"
|
||||
|
||||
const (
|
||||
ModuleName = "bond"
|
||||
|
||||
@ -8,3 +10,8 @@ const (
|
||||
|
||||
// TODO: Add required keys
|
||||
)
|
||||
|
||||
// Store prefixes
|
||||
var (
|
||||
BondsKey = collections.NewPrefix(0)
|
||||
)
|
||||
|
@ -3,6 +3,8 @@ package module
|
||||
import (
|
||||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
|
||||
"cosmossdk.io/client/v2/autocli"
|
||||
|
||||
bondv1 "git.vdb.to/cerc-io/laconic2d/api/cerc/bond/v1"
|
||||
)
|
||||
|
||||
var _ autocli.HasAutoCLIConfig = AppModule{}
|
||||
@ -10,7 +12,29 @@ var _ autocli.HasAutoCLIConfig = AppModule{}
|
||||
// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.
|
||||
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
|
||||
return &autocliv1.ModuleOptions{
|
||||
Query: nil,
|
||||
Tx: nil,
|
||||
Query: &autocliv1.ServiceCommandDescriptor{
|
||||
Service: bondv1.Query_ServiceDesc.ServiceName,
|
||||
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
|
||||
{
|
||||
RpcMethod: "Bonds",
|
||||
Use: "list",
|
||||
Short: "List bonds",
|
||||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{},
|
||||
},
|
||||
},
|
||||
},
|
||||
Tx: &autocliv1.ServiceCommandDescriptor{
|
||||
Service: bondv1.Msg_ServiceDesc.ServiceName,
|
||||
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
|
||||
{
|
||||
RpcMethod: "CreateBond",
|
||||
Use: "create [amount]",
|
||||
Short: "Create bond",
|
||||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
|
||||
{ProtoField: "coins"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ package module
|
||||
|
||||
import (
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/depinject"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
|
||||
modulev1 "git.vdb.to/cerc-io/laconic2d/api/cerc/bond/module/v1"
|
||||
"git.vdb.to/cerc-io/laconic2d/x/bond/keeper"
|
||||
@ -29,8 +31,11 @@ func init() {
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
|
||||
Key *storetypes.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
StoreService store.KVStoreService
|
||||
|
||||
AccountKeeper auth.AccountKeeper
|
||||
BankKeeper bank.Keeper
|
||||
}
|
||||
|
||||
type ModuleOutputs struct {
|
||||
@ -41,7 +46,7 @@ type ModuleOutputs struct {
|
||||
}
|
||||
|
||||
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
k := keeper.NewKeeper(in.Cdc, in.Key)
|
||||
k := keeper.NewKeeper(in.Cdc, in.StoreService, in.AccountKeeper, in.BankKeeper)
|
||||
m := NewAppModule(in.Cdc, k)
|
||||
|
||||
return ModuleOutputs{Module: m, Keeper: k}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package module
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
@ -24,6 +25,7 @@ var (
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
_ module.HasGenesis = AppModule{}
|
||||
_ module.HasServices = AppModule{}
|
||||
_ module.HasConsensusVersion = AppModule{}
|
||||
)
|
||||
|
||||
// ConsensusVersion defines the current module consensus version
|
||||
@ -53,15 +55,13 @@ func (AppModule) Name() string { return bond.ModuleName }
|
||||
|
||||
// RegisterLegacyAminoCodec registers the bond module's types on the LegacyAmino codec.
|
||||
// New modules do not need to support Amino.
|
||||
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
bond.RegisterLegacyAminoCodec(cdc)
|
||||
}
|
||||
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
|
||||
|
||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bond module.
|
||||
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
||||
// if err := bond.RegisterQueryHandlerClient(context.Background(), mux, bond.NewQueryClient(clientCtx)); err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
if err := bond.RegisterQueryHandlerClient(context.Background(), mux, bond.NewQueryClient(clientCtx)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterInterfaces registers interfaces and implementations of the bond module.
|
||||
@ -69,6 +69,9 @@ func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
bond.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
// ConsensusVersion implements AppModule/ConsensusVersion.
|
||||
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
||||
|
||||
// module.HasGenesis
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the module.
|
||||
@ -112,6 +115,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
|
||||
|
||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
// Register servers
|
||||
// bond.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
|
||||
// bond.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper))
|
||||
bond.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
|
||||
bond.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper))
|
||||
}
|
||||
|
671
x/bond/query.pb.go
Normal file
671
x/bond/query.pb.go
Normal file
@ -0,0 +1,671 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: cerc/bond/v1/query.proto
|
||||
|
||||
package bond
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
query "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
|
||||
|
||||
// QueryGetBondById queries a bonds.
|
||||
type QueryGetBondsRequest struct {
|
||||
// pagination defines an optional pagination for the request.
|
||||
Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"`
|
||||
}
|
||||
|
||||
func (m *QueryGetBondsRequest) Reset() { *m = QueryGetBondsRequest{} }
|
||||
func (m *QueryGetBondsRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryGetBondsRequest) ProtoMessage() {}
|
||||
func (*QueryGetBondsRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_d3221677ed35cdfb, []int{0}
|
||||
}
|
||||
func (m *QueryGetBondsRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *QueryGetBondsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_QueryGetBondsRequest.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 *QueryGetBondsRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_QueryGetBondsRequest.Merge(m, src)
|
||||
}
|
||||
func (m *QueryGetBondsRequest) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *QueryGetBondsRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_QueryGetBondsRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_QueryGetBondsRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *QueryGetBondsRequest) GetPagination() *query.PageRequest {
|
||||
if m != nil {
|
||||
return m.Pagination
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// QueryGetBondsResponse is response type for get the bonds by bond-id
|
||||
type QueryGetBondsResponse struct {
|
||||
Bonds []*Bond `protobuf:"bytes,1,rep,name=bonds,proto3" json:"bonds,omitempty" json:"bonds" yaml:"bonds"`
|
||||
// pagination defines the pagination in the response.
|
||||
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
|
||||
}
|
||||
|
||||
func (m *QueryGetBondsResponse) Reset() { *m = QueryGetBondsResponse{} }
|
||||
func (m *QueryGetBondsResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryGetBondsResponse) ProtoMessage() {}
|
||||
func (*QueryGetBondsResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_d3221677ed35cdfb, []int{1}
|
||||
}
|
||||
func (m *QueryGetBondsResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *QueryGetBondsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_QueryGetBondsResponse.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 *QueryGetBondsResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_QueryGetBondsResponse.Merge(m, src)
|
||||
}
|
||||
func (m *QueryGetBondsResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *QueryGetBondsResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_QueryGetBondsResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_QueryGetBondsResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *QueryGetBondsResponse) GetBonds() []*Bond {
|
||||
if m != nil {
|
||||
return m.Bonds
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *QueryGetBondsResponse) GetPagination() *query.PageResponse {
|
||||
if m != nil {
|
||||
return m.Pagination
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*QueryGetBondsRequest)(nil), "cerc.bond.v1.QueryGetBondsRequest")
|
||||
proto.RegisterType((*QueryGetBondsResponse)(nil), "cerc.bond.v1.QueryGetBondsResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cerc/bond/v1/query.proto", fileDescriptor_d3221677ed35cdfb) }
|
||||
|
||||
var fileDescriptor_d3221677ed35cdfb = []byte{
|
||||
// 368 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x4a, 0x2b, 0x31,
|
||||
0x14, 0x86, 0x3b, 0xbd, 0xf4, 0x2e, 0xd2, 0xbb, 0xca, 0x6d, 0xb9, 0xbd, 0x55, 0xc7, 0x32, 0x05,
|
||||
0x2d, 0x82, 0x09, 0x33, 0xee, 0x04, 0x37, 0x5d, 0xd8, 0xad, 0x76, 0xe9, 0x42, 0xc8, 0xcc, 0x84,
|
||||
0x30, 0xd2, 0xe6, 0x4c, 0x9b, 0x74, 0xb0, 0x5b, 0x9f, 0x40, 0xf0, 0x29, 0x7c, 0x13, 0x97, 0x05,
|
||||
0x37, 0xae, 0x44, 0x5a, 0x9f, 0xc0, 0x27, 0x90, 0x24, 0x15, 0x5b, 0x15, 0xdd, 0xcd, 0xf0, 0x7f,
|
||||
0xff, 0x39, 0x5f, 0x12, 0xd4, 0x48, 0xf8, 0x38, 0xa1, 0x31, 0xc8, 0x94, 0x16, 0x21, 0x1d, 0x4d,
|
||||
0xf8, 0x78, 0x4a, 0xf2, 0x31, 0x68, 0xc0, 0x7f, 0x4c, 0x42, 0x4c, 0x42, 0x8a, 0xb0, 0x59, 0x13,
|
||||
0x20, 0xc0, 0x06, 0xd4, 0x7c, 0x39, 0xa6, 0xf9, 0x6f, 0xad, 0x6d, 0x59, 0x17, 0x6c, 0x0a, 0x00,
|
||||
0x31, 0xe0, 0x94, 0xe5, 0x19, 0x65, 0x52, 0x82, 0x66, 0x3a, 0x03, 0xa9, 0x96, 0xe9, 0x5e, 0x02,
|
||||
0x6a, 0x08, 0x8a, 0xc6, 0x4c, 0x71, 0xb7, 0x93, 0x16, 0x61, 0xcc, 0x35, 0x0b, 0x69, 0xce, 0x44,
|
||||
0x26, 0x2d, 0xec, 0xd8, 0xe0, 0x1c, 0xd5, 0x4e, 0x0d, 0xd1, 0xe3, 0xba, 0x0b, 0x32, 0x55, 0x7d,
|
||||
0x3e, 0x9a, 0x70, 0xa5, 0xf1, 0x31, 0x42, 0xef, 0x6c, 0xc3, 0x6b, 0x79, 0x9d, 0x6a, 0xb4, 0x43,
|
||||
0xdc, 0x60, 0x62, 0x06, 0x13, 0x77, 0x98, 0xe5, 0x60, 0x72, 0xc2, 0x04, 0x5f, 0x76, 0xfb, 0x2b,
|
||||
0xcd, 0xe0, 0xd6, 0x43, 0xf5, 0x0f, 0x0b, 0x54, 0x0e, 0x52, 0x71, 0xdc, 0x43, 0x15, 0x73, 0x22,
|
||||
0xd5, 0xf0, 0x5a, 0xbf, 0x3a, 0xd5, 0x08, 0x93, 0xd5, 0x0b, 0x21, 0x86, 0xed, 0x6e, 0xbd, 0x3c,
|
||||
0x6e, 0xff, 0xbf, 0x50, 0x20, 0x0f, 0x03, 0x8b, 0x06, 0xad, 0x29, 0x1b, 0x0e, 0xde, 0x7e, 0xfa,
|
||||
0xae, 0x8f, 0x7b, 0x6b, 0xaa, 0x65, 0xab, 0xba, 0xfb, 0xa3, 0xaa, 0xb3, 0x58, 0x75, 0x8d, 0x0a,
|
||||
0x54, 0xb1, 0xaa, 0x78, 0x88, 0x2a, 0xd6, 0x15, 0x07, 0xeb, 0x52, 0x5f, 0xdd, 0x54, 0xb3, 0xfd,
|
||||
0x2d, 0xe3, 0xd6, 0x04, 0x1b, 0x57, 0xf7, 0xcf, 0x37, 0xe5, 0x3a, 0xfe, 0x4b, 0x3f, 0x3d, 0xa9,
|
||||
0xea, 0x1e, 0xdd, 0xcd, 0x7d, 0x6f, 0x36, 0xf7, 0xbd, 0xa7, 0xb9, 0xef, 0x5d, 0x2f, 0xfc, 0xd2,
|
||||
0x6c, 0xe1, 0x97, 0x1e, 0x16, 0x7e, 0xe9, 0xac, 0x2d, 0x32, 0x4d, 0x8a, 0x34, 0x26, 0x1a, 0x6c,
|
||||
0x71, 0x3f, 0x03, 0x3a, 0x60, 0x09, 0xc8, 0x2c, 0x89, 0x52, 0x7a, 0x69, 0xfb, 0xf1, 0x6f, 0xfb,
|
||||
0x92, 0x07, 0xaf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x32, 0xed, 0x9c, 0x6c, 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 {
|
||||
// Bonds queries bonds list.
|
||||
Bonds(ctx context.Context, in *QueryGetBondsRequest, opts ...grpc.CallOption) (*QueryGetBondsResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
cc grpc1.ClientConn
|
||||
}
|
||||
|
||||
func NewQueryClient(cc grpc1.ClientConn) QueryClient {
|
||||
return &queryClient{cc}
|
||||
}
|
||||
|
||||
func (c *queryClient) Bonds(ctx context.Context, in *QueryGetBondsRequest, opts ...grpc.CallOption) (*QueryGetBondsResponse, error) {
|
||||
out := new(QueryGetBondsResponse)
|
||||
err := c.cc.Invoke(ctx, "/cerc.bond.v1.Query/Bonds", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// QueryServer is the server API for Query service.
|
||||
type QueryServer interface {
|
||||
// Bonds queries bonds list.
|
||||
Bonds(context.Context, *QueryGetBondsRequest) (*QueryGetBondsResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedQueryServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedQueryServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedQueryServer) Bonds(ctx context.Context, req *QueryGetBondsRequest) (*QueryGetBondsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Bonds not implemented")
|
||||
}
|
||||
|
||||
func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
|
||||
s.RegisterService(&_Query_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Query_Bonds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryGetBondsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).Bonds(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cerc.bond.v1.Query/Bonds",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).Bonds(ctx, req.(*QueryGetBondsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Query_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cerc.bond.v1.Query",
|
||||
HandlerType: (*QueryServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Bonds",
|
||||
Handler: _Query_Bonds_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/bond/v1/query.proto",
|
||||
}
|
||||
|
||||
func (m *QueryGetBondsRequest) 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 *QueryGetBondsRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *QueryGetBondsRequest) 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 *QueryGetBondsResponse) 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 *QueryGetBondsResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *QueryGetBondsResponse) 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.Bonds) > 0 {
|
||||
for iNdEx := len(m.Bonds) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Bonds[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 *QueryGetBondsRequest) 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 *QueryGetBondsResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Bonds) > 0 {
|
||||
for _, e := range m.Bonds {
|
||||
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 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 *QueryGetBondsRequest) 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: QueryGetBondsRequest: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: QueryGetBondsRequest: 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 *QueryGetBondsResponse) 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: QueryGetBondsResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: QueryGetBondsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Bonds", 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.Bonds = append(m.Bonds, &Bond{})
|
||||
if err := m.Bonds[len(m.Bonds)-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 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")
|
||||
)
|
171
x/bond/query.pb.gw.go
Normal file
171
x/bond/query.pb.gw.go
Normal file
@ -0,0 +1,171 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: cerc/bond/v1/query.proto
|
||||
|
||||
/*
|
||||
Package bond is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package bond
|
||||
|
||||
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_Query_Bonds_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_Bonds_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetBondsRequest
|
||||
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_Query_Bonds_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Bonds(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Bonds_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetBondsRequest
|
||||
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_Query_Bonds_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.Bonds(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_Bonds_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_Bonds_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_Bonds_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_Bonds_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_Bonds_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_Bonds_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Bonds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cerc", "bond", "v1", "bonds"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Query_Bonds_0 = runtime.ForwardResponseMessage
|
||||
)
|
656
x/bond/tx.pb.go
Normal file
656
x/bond/tx.pb.go
Normal file
@ -0,0 +1,656 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: cerc/bond/v1/tx.proto
|
||||
|
||||
package bond
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
_ "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
|
||||
|
||||
// MsgCreateBond defines a SDK message for creating a new bond.
|
||||
type MsgCreateBond struct {
|
||||
Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"`
|
||||
Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins" json:"coins" yaml:"coins"`
|
||||
}
|
||||
|
||||
func (m *MsgCreateBond) Reset() { *m = MsgCreateBond{} }
|
||||
func (m *MsgCreateBond) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgCreateBond) ProtoMessage() {}
|
||||
func (*MsgCreateBond) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_efb1a132c2c5bd62, []int{0}
|
||||
}
|
||||
func (m *MsgCreateBond) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgCreateBond) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgCreateBond.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 *MsgCreateBond) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgCreateBond.Merge(m, src)
|
||||
}
|
||||
func (m *MsgCreateBond) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgCreateBond) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgCreateBond.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgCreateBond proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgCreateBond) GetSigner() string {
|
||||
if m != nil {
|
||||
return m.Signer
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgCreateBond) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins {
|
||||
if m != nil {
|
||||
return m.Coins
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MsgCreateBondResponse defines the Msg/CreateBond response type.
|
||||
type MsgCreateBondResponse struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MsgCreateBondResponse) Reset() { *m = MsgCreateBondResponse{} }
|
||||
func (m *MsgCreateBondResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgCreateBondResponse) ProtoMessage() {}
|
||||
func (*MsgCreateBondResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_efb1a132c2c5bd62, []int{1}
|
||||
}
|
||||
func (m *MsgCreateBondResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgCreateBondResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgCreateBondResponse.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 *MsgCreateBondResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgCreateBondResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgCreateBondResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgCreateBondResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgCreateBondResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgCreateBondResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgCreateBondResponse) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgCreateBond)(nil), "cerc.bond.v1.MsgCreateBond")
|
||||
proto.RegisterType((*MsgCreateBondResponse)(nil), "cerc.bond.v1.MsgCreateBondResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cerc/bond/v1/tx.proto", fileDescriptor_efb1a132c2c5bd62) }
|
||||
|
||||
var fileDescriptor_efb1a132c2c5bd62 = []byte{
|
||||
// 405 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xbf, 0x6f, 0xd3, 0x40,
|
||||
0x14, 0xc7, 0x6d, 0x57, 0xad, 0xc4, 0x15, 0x18, 0x2c, 0x0a, 0x8d, 0x8b, 0x9c, 0xe0, 0x0e, 0x44,
|
||||
0x95, 0x7a, 0x27, 0x87, 0xad, 0x12, 0x4b, 0x3a, 0x67, 0xc9, 0xc8, 0x82, 0xce, 0xe7, 0xd3, 0x71,
|
||||
0x10, 0xdf, 0x33, 0x7e, 0x87, 0xd5, 0x2e, 0x80, 0xfa, 0x17, 0x20, 0xf1, 0x5f, 0x30, 0x75, 0xe0,
|
||||
0x8f, 0xe8, 0x18, 0x89, 0x85, 0x29, 0xa0, 0x04, 0x29, 0x3b, 0x7f, 0x01, 0xb2, 0x7d, 0x91, 0x92,
|
||||
0x85, 0xc9, 0xef, 0xc7, 0xf7, 0x7d, 0xde, 0xd7, 0xf7, 0xc8, 0x91, 0x90, 0x95, 0x60, 0x19, 0x98,
|
||||
0x9c, 0xd5, 0x29, 0xb3, 0x57, 0xb4, 0xac, 0xc0, 0x42, 0x78, 0xbf, 0x29, 0xd3, 0xa6, 0x4c, 0xeb,
|
||||
0x34, 0x7a, 0x22, 0x00, 0x0b, 0x40, 0x56, 0xa0, 0x6a, 0x54, 0x05, 0xaa, 0x4e, 0x16, 0x3d, 0x52,
|
||||
0xa0, 0xa0, 0x0d, 0x59, 0x13, 0xb9, 0xea, 0x53, 0x05, 0xa0, 0x66, 0x92, 0xf1, 0x52, 0x33, 0x6e,
|
||||
0x0c, 0x58, 0x6e, 0x35, 0x18, 0x74, 0xdd, 0xd8, 0xc1, 0x32, 0x8e, 0x92, 0xd5, 0x69, 0x26, 0x2d,
|
||||
0x4f, 0x99, 0x00, 0x6d, 0xba, 0x7e, 0xf2, 0xdd, 0x27, 0x0f, 0x26, 0xa8, 0x2e, 0x2b, 0xc9, 0xad,
|
||||
0x1c, 0x83, 0xc9, 0xc3, 0xc7, 0xe4, 0x00, 0xb5, 0x32, 0xb2, 0x3a, 0xf6, 0x07, 0xfe, 0xf0, 0xde,
|
||||
0xd4, 0x65, 0xe1, 0x47, 0xb2, 0xdf, 0xcc, 0xe1, 0x71, 0x30, 0xd8, 0x1b, 0x1e, 0x8e, 0x7a, 0xb4,
|
||||
0x23, 0xd3, 0x86, 0x4c, 0x1d, 0x99, 0x5e, 0x82, 0x36, 0xe3, 0xc9, 0xdd, 0xa2, 0xef, 0xfd, 0x5d,
|
||||
0xf4, 0x7b, 0x6f, 0x11, 0xcc, 0x45, 0xd2, 0x4e, 0x25, 0x83, 0x6b, 0x5e, 0xcc, 0x36, 0xc9, 0xb7,
|
||||
0x5f, 0xfd, 0xa1, 0xd2, 0xf6, 0xcd, 0x87, 0x8c, 0x0a, 0x28, 0x98, 0xf3, 0xd8, 0x7d, 0xce, 0x31,
|
||||
0x7f, 0xc7, 0xec, 0x75, 0x29, 0xb1, 0xa5, 0xe1, 0xb4, 0x5b, 0x7b, 0x71, 0x78, 0xb3, 0xbe, 0x3d,
|
||||
0x73, 0x66, 0x92, 0xe7, 0xe4, 0x68, 0xc7, 0xf5, 0x54, 0x62, 0x09, 0x06, 0x65, 0xf8, 0x90, 0x04,
|
||||
0x3a, 0x77, 0xce, 0x03, 0x9d, 0x8f, 0x3e, 0x91, 0xbd, 0x09, 0xaa, 0xf0, 0x3d, 0x21, 0x5b, 0xbf,
|
||||
0x78, 0x42, 0xb7, 0x1f, 0x9c, 0xee, 0x90, 0xa2, 0xd3, 0xff, 0x34, 0x37, 0x6b, 0x92, 0x67, 0x37,
|
||||
0x3f, 0xfe, 0x7c, 0x0d, 0x4e, 0x92, 0x1e, 0xdb, 0xb9, 0xa8, 0x68, 0x95, 0xaf, 0x9b, 0x34, 0xda,
|
||||
0xff, 0xbc, 0xbe, 0x3d, 0xf3, 0xc7, 0x2f, 0xef, 0x96, 0xb1, 0x3f, 0x5f, 0xc6, 0xfe, 0xef, 0x65,
|
||||
0xec, 0x7f, 0x59, 0xc5, 0xde, 0x7c, 0x15, 0x7b, 0x3f, 0x57, 0xb1, 0xf7, 0xea, 0x54, 0x69, 0x4b,
|
||||
0xeb, 0x3c, 0xa3, 0x16, 0x5a, 0xca, 0xb9, 0x06, 0x36, 0xe3, 0x02, 0x8c, 0x16, 0xa3, 0x9c, 0x5d,
|
||||
0xb5, 0xd0, 0xec, 0xa0, 0x3d, 0xd3, 0x8b, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbd, 0x7f, 0x1d,
|
||||
0xaa, 0x3a, 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 {
|
||||
// CreateBond defines a method for creating a new bond.
|
||||
CreateBond(ctx context.Context, in *MsgCreateBond, opts ...grpc.CallOption) (*MsgCreateBondResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
cc grpc1.ClientConn
|
||||
}
|
||||
|
||||
func NewMsgClient(cc grpc1.ClientConn) MsgClient {
|
||||
return &msgClient{cc}
|
||||
}
|
||||
|
||||
func (c *msgClient) CreateBond(ctx context.Context, in *MsgCreateBond, opts ...grpc.CallOption) (*MsgCreateBondResponse, error) {
|
||||
out := new(MsgCreateBondResponse)
|
||||
err := c.cc.Invoke(ctx, "/cerc.bond.v1.Msg/CreateBond", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
type MsgServer interface {
|
||||
// CreateBond defines a method for creating a new bond.
|
||||
CreateBond(context.Context, *MsgCreateBond) (*MsgCreateBondResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedMsgServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedMsgServer) CreateBond(ctx context.Context, req *MsgCreateBond) (*MsgCreateBondResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateBond not implemented")
|
||||
}
|
||||
|
||||
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
|
||||
s.RegisterService(&_Msg_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Msg_CreateBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgCreateBond)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).CreateBond(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cerc.bond.v1.Msg/CreateBond",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).CreateBond(ctx, req.(*MsgCreateBond))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cerc.bond.v1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CreateBond",
|
||||
Handler: _Msg_CreateBond_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/bond/v1/tx.proto",
|
||||
}
|
||||
|
||||
func (m *MsgCreateBond) 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 *MsgCreateBond) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgCreateBond) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Coins) > 0 {
|
||||
for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTx(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if len(m.Signer) > 0 {
|
||||
i -= len(m.Signer)
|
||||
copy(dAtA[i:], m.Signer)
|
||||
i = encodeVarintTx(dAtA, i, uint64(len(m.Signer)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgCreateBondResponse) 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 *MsgCreateBondResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgCreateBondResponse) 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 = encodeVarintTx(dAtA, i, uint64(len(m.Id)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
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 *MsgCreateBond) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Signer)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
if len(m.Coins) > 0 {
|
||||
for _, e := range m.Coins {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgCreateBondResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Id)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTx(uint64(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 *MsgCreateBond) 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: MsgCreateBond: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgCreateBond: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Signer", 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.Signer = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Coins", 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
|
||||
}
|
||||
m.Coins = append(m.Coins, types.Coin{})
|
||||
if err := m.Coins[len(m.Coins)-1].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 *MsgCreateBondResponse) 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: MsgCreateBondResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgCreateBondResponse: 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 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.Id = 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 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
x/bond/tx.pb.gw.go
Normal file
171
x/bond/tx.pb.gw.go
Normal file
@ -0,0 +1,171 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: cerc/bond/v1/tx.proto
|
||||
|
||||
/*
|
||||
Package bond is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package bond
|
||||
|
||||
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_CreateBond_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Msg_CreateBond_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq MsgCreateBond
|
||||
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_CreateBond_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.CreateBond(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Msg_CreateBond_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq MsgCreateBond
|
||||
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_CreateBond_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.CreateBond(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_CreateBond_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_CreateBond_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_CreateBond_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_CreateBond_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_CreateBond_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_CreateBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Msg_CreateBond_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cerc", "bond", "v1", "create_bond"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Msg_CreateBond_0 = runtime.ForwardResponseMessage
|
||||
)
|
Loading…
Reference in New Issue
Block a user