feat: Add tx encode and decode endpoints for amino txs (#13882)
* add proto changes * make proto-gen * wip: adds tests * wip: tests * remove consoles * wip: fix something * fix: encode amino tests * add decode amino tests * wip: address requested changes * update proto inline docs * address review comments Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr> Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
This commit is contained in:
co-authored by
Amaury M
Julien Robert
atheeshp
parent
00ad3ecedc
commit
e260fc1c89
+2047
-118
File diff suppressed because it is too large
Load Diff
@@ -42,6 +42,14 @@ type ServiceClient interface {
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
TxEncode(ctx context.Context, in *TxEncodeRequest, opts ...grpc.CallOption) (*TxEncodeResponse, error)
|
||||
// TxEncodeAmino encodes an amino transaction.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
TxEncodeAmino(ctx context.Context, in *TxEncodeAminoRequest, opts ...grpc.CallOption) (*TxEncodeAminoResponse, error)
|
||||
// TxDecodeAmino decodes an amino transaction.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
TxDecodeAmino(ctx context.Context, in *TxDecodeAminoRequest, opts ...grpc.CallOption) (*TxDecodeAminoResponse, error)
|
||||
}
|
||||
|
||||
type serviceClient struct {
|
||||
@@ -115,6 +123,24 @@ func (c *serviceClient) TxEncode(ctx context.Context, in *TxEncodeRequest, opts
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *serviceClient) TxEncodeAmino(ctx context.Context, in *TxEncodeAminoRequest, opts ...grpc.CallOption) (*TxEncodeAminoResponse, error) {
|
||||
out := new(TxEncodeAminoResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.tx.v1beta1.Service/TxEncodeAmino", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *serviceClient) TxDecodeAmino(ctx context.Context, in *TxDecodeAminoRequest, opts ...grpc.CallOption) (*TxDecodeAminoResponse, error) {
|
||||
out := new(TxDecodeAminoResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.tx.v1beta1.Service/TxDecodeAmino", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ServiceServer is the server API for Service service.
|
||||
// All implementations must embed UnimplementedServiceServer
|
||||
// for forward compatibility
|
||||
@@ -139,6 +165,14 @@ type ServiceServer interface {
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
TxEncode(context.Context, *TxEncodeRequest) (*TxEncodeResponse, error)
|
||||
// TxEncodeAmino encodes an amino transaction.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
TxEncodeAmino(context.Context, *TxEncodeAminoRequest) (*TxEncodeAminoResponse, error)
|
||||
// TxDecodeAmino decodes an amino transaction.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
TxDecodeAmino(context.Context, *TxDecodeAminoRequest) (*TxDecodeAminoResponse, error)
|
||||
mustEmbedUnimplementedServiceServer()
|
||||
}
|
||||
|
||||
@@ -167,6 +201,12 @@ func (UnimplementedServiceServer) TxDecode(context.Context, *TxDecodeRequest) (*
|
||||
func (UnimplementedServiceServer) TxEncode(context.Context, *TxEncodeRequest) (*TxEncodeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method TxEncode not implemented")
|
||||
}
|
||||
func (UnimplementedServiceServer) TxEncodeAmino(context.Context, *TxEncodeAminoRequest) (*TxEncodeAminoResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method TxEncodeAmino not implemented")
|
||||
}
|
||||
func (UnimplementedServiceServer) TxDecodeAmino(context.Context, *TxDecodeAminoRequest) (*TxDecodeAminoResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method TxDecodeAmino not implemented")
|
||||
}
|
||||
func (UnimplementedServiceServer) mustEmbedUnimplementedServiceServer() {}
|
||||
|
||||
// UnsafeServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
@@ -306,6 +346,42 @@ func _Service_TxEncode_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Service_TxEncodeAmino_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TxEncodeAminoRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ServiceServer).TxEncodeAmino(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.tx.v1beta1.Service/TxEncodeAmino",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ServiceServer).TxEncodeAmino(ctx, req.(*TxEncodeAminoRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Service_TxDecodeAmino_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TxDecodeAminoRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ServiceServer).TxDecodeAmino(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.tx.v1beta1.Service/TxDecodeAmino",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ServiceServer).TxDecodeAmino(ctx, req.(*TxDecodeAminoRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Service_ServiceDesc is the grpc.ServiceDesc for Service service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -341,6 +417,14 @@ var Service_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "TxEncode",
|
||||
Handler: _Service_TxEncode_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "TxEncodeAmino",
|
||||
Handler: _Service_TxEncodeAmino_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "TxDecodeAmino",
|
||||
Handler: _Service_TxDecodeAmino_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/tx/v1beta1/service.proto",
|
||||
|
||||
Reference in New Issue
Block a user