forked from cerc-io/laconicd
Additional bond commands (#4)
* Add commands to get bonds by id and owner * Add commands to get bond module params and balances * Add commands to refill, withdraw and cancel bond * Add implementations for bond tx commands * Use indexed map to implement command for getting bond by owner * Use collections for bond module params * Clean up
This commit is contained in:
+4112
-49
File diff suppressed because it is too large
Load Diff
@@ -19,15 +19,27 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
Query_Bonds_FullMethodName = "/cerc.bond.v1.Query/Bonds"
|
||||
Query_Params_FullMethodName = "/cerc.bond.v1.Query/Params"
|
||||
Query_Bonds_FullMethodName = "/cerc.bond.v1.Query/Bonds"
|
||||
Query_GetBondById_FullMethodName = "/cerc.bond.v1.Query/GetBondById"
|
||||
Query_GetBondsByOwner_FullMethodName = "/cerc.bond.v1.Query/GetBondsByOwner"
|
||||
Query_GetBondsModuleBalance_FullMethodName = "/cerc.bond.v1.Query/GetBondsModuleBalance"
|
||||
)
|
||||
|
||||
// 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.
|
||||
// Params queries bonds module params.
|
||||
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
|
||||
// Bonds queries bonds list
|
||||
Bonds(ctx context.Context, in *QueryGetBondsRequest, opts ...grpc.CallOption) (*QueryGetBondsResponse, error)
|
||||
// GetBondById
|
||||
GetBondById(ctx context.Context, in *QueryGetBondByIdRequest, opts ...grpc.CallOption) (*QueryGetBondByIdResponse, error)
|
||||
// Get Bonds list by Owner
|
||||
GetBondsByOwner(ctx context.Context, in *QueryGetBondsByOwnerRequest, opts ...grpc.CallOption) (*QueryGetBondsByOwnerResponse, error)
|
||||
// Get Bond module balance
|
||||
GetBondsModuleBalance(ctx context.Context, in *QueryGetBondModuleBalanceRequest, opts ...grpc.CallOption) (*QueryGetBondModuleBalanceResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
@@ -38,6 +50,15 @@ func NewQueryClient(cc grpc.ClientConnInterface) QueryClient {
|
||||
return &queryClient{cc}
|
||||
}
|
||||
|
||||
func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) {
|
||||
out := new(QueryParamsResponse)
|
||||
err := c.cc.Invoke(ctx, Query_Params_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
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...)
|
||||
@@ -47,12 +68,47 @@ func (c *queryClient) Bonds(ctx context.Context, in *QueryGetBondsRequest, opts
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *queryClient) GetBondById(ctx context.Context, in *QueryGetBondByIdRequest, opts ...grpc.CallOption) (*QueryGetBondByIdResponse, error) {
|
||||
out := new(QueryGetBondByIdResponse)
|
||||
err := c.cc.Invoke(ctx, Query_GetBondById_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *queryClient) GetBondsByOwner(ctx context.Context, in *QueryGetBondsByOwnerRequest, opts ...grpc.CallOption) (*QueryGetBondsByOwnerResponse, error) {
|
||||
out := new(QueryGetBondsByOwnerResponse)
|
||||
err := c.cc.Invoke(ctx, Query_GetBondsByOwner_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *queryClient) GetBondsModuleBalance(ctx context.Context, in *QueryGetBondModuleBalanceRequest, opts ...grpc.CallOption) (*QueryGetBondModuleBalanceResponse, error) {
|
||||
out := new(QueryGetBondModuleBalanceResponse)
|
||||
err := c.cc.Invoke(ctx, Query_GetBondsModuleBalance_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.
|
||||
// Params queries bonds module params.
|
||||
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
|
||||
// Bonds queries bonds list
|
||||
Bonds(context.Context, *QueryGetBondsRequest) (*QueryGetBondsResponse, error)
|
||||
// GetBondById
|
||||
GetBondById(context.Context, *QueryGetBondByIdRequest) (*QueryGetBondByIdResponse, error)
|
||||
// Get Bonds list by Owner
|
||||
GetBondsByOwner(context.Context, *QueryGetBondsByOwnerRequest) (*QueryGetBondsByOwnerResponse, error)
|
||||
// Get Bond module balance
|
||||
GetBondsModuleBalance(context.Context, *QueryGetBondModuleBalanceRequest) (*QueryGetBondModuleBalanceResponse, error)
|
||||
mustEmbedUnimplementedQueryServer()
|
||||
}
|
||||
|
||||
@@ -60,9 +116,21 @@ type QueryServer interface {
|
||||
type UnimplementedQueryServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) Bonds(context.Context, *QueryGetBondsRequest) (*QueryGetBondsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Bonds not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) GetBondById(context.Context, *QueryGetBondByIdRequest) (*QueryGetBondByIdResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBondById not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) GetBondsByOwner(context.Context, *QueryGetBondsByOwnerRequest) (*QueryGetBondsByOwnerResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBondsByOwner not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) GetBondsModuleBalance(context.Context, *QueryGetBondModuleBalanceRequest) (*QueryGetBondModuleBalanceResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBondsModuleBalance not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {}
|
||||
|
||||
// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service.
|
||||
@@ -76,6 +144,24 @@ func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) {
|
||||
s.RegisterService(&Query_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryParamsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).Params(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Query_Params_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -94,6 +180,60 @@ func _Query_Bonds_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_GetBondById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryGetBondByIdRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).GetBondById(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Query_GetBondById_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).GetBondById(ctx, req.(*QueryGetBondByIdRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_GetBondsByOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryGetBondsByOwnerRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).GetBondsByOwner(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Query_GetBondsByOwner_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).GetBondsByOwner(ctx, req.(*QueryGetBondsByOwnerRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_GetBondsModuleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryGetBondModuleBalanceRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).GetBondsModuleBalance(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Query_GetBondsModuleBalance_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).GetBondsModuleBalance(ctx, req.(*QueryGetBondModuleBalanceRequest))
|
||||
}
|
||||
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)
|
||||
@@ -101,10 +241,26 @@ var Query_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cerc.bond.v1.Query",
|
||||
HandlerType: (*QueryServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Params",
|
||||
Handler: _Query_Params_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Bonds",
|
||||
Handler: _Query_Bonds_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBondById",
|
||||
Handler: _Query_GetBondById_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBondsByOwner",
|
||||
Handler: _Query_GetBondsByOwner_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBondsModuleBalance",
|
||||
Handler: _Query_GetBondsModuleBalance_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/bond/v1/query.proto",
|
||||
|
||||
+3200
-33
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,10 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
Msg_CreateBond_FullMethodName = "/cerc.bond.v1.Msg/CreateBond"
|
||||
Msg_CreateBond_FullMethodName = "/cerc.bond.v1.Msg/CreateBond"
|
||||
Msg_RefillBond_FullMethodName = "/cerc.bond.v1.Msg/RefillBond"
|
||||
Msg_WithdrawBond_FullMethodName = "/cerc.bond.v1.Msg/WithdrawBond"
|
||||
Msg_CancelBond_FullMethodName = "/cerc.bond.v1.Msg/CancelBond"
|
||||
)
|
||||
|
||||
// MsgClient is the client API for Msg service.
|
||||
@@ -28,6 +31,12 @@ const (
|
||||
type MsgClient interface {
|
||||
// CreateBond defines a method for creating a new bond.
|
||||
CreateBond(ctx context.Context, in *MsgCreateBond, opts ...grpc.CallOption) (*MsgCreateBondResponse, error)
|
||||
// RefillBond defines a method for refilling amount for bond.
|
||||
RefillBond(ctx context.Context, in *MsgRefillBond, opts ...grpc.CallOption) (*MsgRefillBondResponse, error)
|
||||
// WithdrawBond defines a method for withdrawing amount from bond.
|
||||
WithdrawBond(ctx context.Context, in *MsgWithdrawBond, opts ...grpc.CallOption) (*MsgWithdrawBondResponse, error)
|
||||
// CancelBond defines a method for cancelling a bond.
|
||||
CancelBond(ctx context.Context, in *MsgCancelBond, opts ...grpc.CallOption) (*MsgCancelBondResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@@ -47,12 +56,45 @@ func (c *msgClient) CreateBond(ctx context.Context, in *MsgCreateBond, opts ...g
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) RefillBond(ctx context.Context, in *MsgRefillBond, opts ...grpc.CallOption) (*MsgRefillBondResponse, error) {
|
||||
out := new(MsgRefillBondResponse)
|
||||
err := c.cc.Invoke(ctx, Msg_RefillBond_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) WithdrawBond(ctx context.Context, in *MsgWithdrawBond, opts ...grpc.CallOption) (*MsgWithdrawBondResponse, error) {
|
||||
out := new(MsgWithdrawBondResponse)
|
||||
err := c.cc.Invoke(ctx, Msg_WithdrawBond_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) CancelBond(ctx context.Context, in *MsgCancelBond, opts ...grpc.CallOption) (*MsgCancelBondResponse, error) {
|
||||
out := new(MsgCancelBondResponse)
|
||||
err := c.cc.Invoke(ctx, Msg_CancelBond_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)
|
||||
// RefillBond defines a method for refilling amount for bond.
|
||||
RefillBond(context.Context, *MsgRefillBond) (*MsgRefillBondResponse, error)
|
||||
// WithdrawBond defines a method for withdrawing amount from bond.
|
||||
WithdrawBond(context.Context, *MsgWithdrawBond) (*MsgWithdrawBondResponse, error)
|
||||
// CancelBond defines a method for cancelling a bond.
|
||||
CancelBond(context.Context, *MsgCancelBond) (*MsgCancelBondResponse, error)
|
||||
mustEmbedUnimplementedMsgServer()
|
||||
}
|
||||
|
||||
@@ -63,6 +105,15 @@ type UnimplementedMsgServer struct {
|
||||
func (UnimplementedMsgServer) CreateBond(context.Context, *MsgCreateBond) (*MsgCreateBondResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateBond not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) RefillBond(context.Context, *MsgRefillBond) (*MsgRefillBondResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RefillBond not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) WithdrawBond(context.Context, *MsgWithdrawBond) (*MsgWithdrawBondResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method WithdrawBond not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) CancelBond(context.Context, *MsgCancelBond) (*MsgCancelBondResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CancelBond not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
|
||||
|
||||
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
|
||||
@@ -94,6 +145,60 @@ func _Msg_CreateBond_Handler(srv interface{}, ctx context.Context, dec func(inte
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_RefillBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgRefillBond)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).RefillBond(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Msg_RefillBond_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).RefillBond(ctx, req.(*MsgRefillBond))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_WithdrawBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgWithdrawBond)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).WithdrawBond(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Msg_WithdrawBond_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).WithdrawBond(ctx, req.(*MsgWithdrawBond))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_CancelBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgCancelBond)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).CancelBond(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Msg_CancelBond_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).CancelBond(ctx, req.(*MsgCancelBond))
|
||||
}
|
||||
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)
|
||||
@@ -105,6 +210,18 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "CreateBond",
|
||||
Handler: _Msg_CreateBond_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "RefillBond",
|
||||
Handler: _Msg_RefillBond_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "WithdrawBond",
|
||||
Handler: _Msg_WithdrawBond_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CancelBond",
|
||||
Handler: _Msg_CancelBond_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/bond/v1/tx.proto",
|
||||
|
||||
Reference in New Issue
Block a user