From 9e47c55f44762dd78e50442bbf59c402362700e2 Mon Sep 17 00:00:00 2001 From: zheng-bin Date: Fri, 22 Sep 2023 00:35:21 +0800 Subject: [PATCH] Add address conversion (#777) * Add address conversion --- proto/shentu/cert/v1alpha1/query.proto | 12 + x/cert/keeper/grpc_query.go | 12 + x/cert/types/query.pb.go | 479 ++++++++++++++++++++++--- x/cert/types/query.pb.gw.go | 101 ++++++ 4 files changed, 555 insertions(+), 49 deletions(-) diff --git a/proto/shentu/cert/v1alpha1/query.proto b/proto/shentu/cert/v1alpha1/query.proto index 60554ae6a..663473319 100644 --- a/proto/shentu/cert/v1alpha1/query.proto +++ b/proto/shentu/cert/v1alpha1/query.proto @@ -32,6 +32,10 @@ service Query { rpc Certificates(QueryCertificatesRequest) returns (QueryCertificatesResponse) { option (google.api.http).get = "/shentu/cert/v1alpha1/certificates"; } + + rpc AddrConversion(ConversionToShentuAddrRequest) returns (ConversionToShentuAddrResponse) { + option (google.api.http).get = "/shentu/conversion/to-shentu/{address}"; + } } message QueryCertifierRequest { @@ -81,3 +85,11 @@ message QueryCertificatesResponse { // pagination defines the pagination in the response. //cosmos.base.query.v1beta1.PageResponse pagination = 3; } + +message ConversionToShentuAddrRequest { + string address = 1; +} + +message ConversionToShentuAddrResponse { + string address = 1; +} \ No newline at end of file diff --git a/x/cert/keeper/grpc_query.go b/x/cert/keeper/grpc_query.go index d26d0493f..fb04ce553 100644 --- a/x/cert/keeper/grpc_query.go +++ b/x/cert/keeper/grpc_query.go @@ -11,6 +11,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" qtypes "github.com/cosmos/cosmos-sdk/types/query" + "github.com/shentufoundation/shentu/v2/common" "github.com/shentufoundation/shentu/v2/x/cert/types" ) @@ -137,3 +138,14 @@ func (q Querier) Certificates(c context.Context, req *types.QueryCertificatesReq return &types.QueryCertificatesResponse{Total: total, Certificates: results}, nil } + +func (q Querier) AddrConversion(c context.Context, req *types.ConversionToShentuAddrRequest) (*types.ConversionToShentuAddrResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + shentuAddr, err := common.PrefixToShentu(req.Address) + if err != nil { + return nil, err + } + return &types.ConversionToShentuAddrResponse{Address: shentuAddr}, nil +} diff --git a/x/cert/types/query.pb.go b/x/cert/types/query.pb.go index 593dbb090..741990d31 100644 --- a/x/cert/types/query.pb.go +++ b/x/cert/types/query.pb.go @@ -497,6 +497,94 @@ func (m *QueryCertificatesResponse) GetCertificates() []QueryCertificateResponse return nil } +type ConversionToShentuAddrRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *ConversionToShentuAddrRequest) Reset() { *m = ConversionToShentuAddrRequest{} } +func (m *ConversionToShentuAddrRequest) String() string { return proto.CompactTextString(m) } +func (*ConversionToShentuAddrRequest) ProtoMessage() {} +func (*ConversionToShentuAddrRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d0446c22ac299371, []int{10} +} +func (m *ConversionToShentuAddrRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConversionToShentuAddrRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConversionToShentuAddrRequest.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 *ConversionToShentuAddrRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConversionToShentuAddrRequest.Merge(m, src) +} +func (m *ConversionToShentuAddrRequest) XXX_Size() int { + return m.Size() +} +func (m *ConversionToShentuAddrRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ConversionToShentuAddrRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ConversionToShentuAddrRequest proto.InternalMessageInfo + +func (m *ConversionToShentuAddrRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type ConversionToShentuAddrResponse struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *ConversionToShentuAddrResponse) Reset() { *m = ConversionToShentuAddrResponse{} } +func (m *ConversionToShentuAddrResponse) String() string { return proto.CompactTextString(m) } +func (*ConversionToShentuAddrResponse) ProtoMessage() {} +func (*ConversionToShentuAddrResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d0446c22ac299371, []int{11} +} +func (m *ConversionToShentuAddrResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConversionToShentuAddrResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConversionToShentuAddrResponse.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 *ConversionToShentuAddrResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConversionToShentuAddrResponse.Merge(m, src) +} +func (m *ConversionToShentuAddrResponse) XXX_Size() int { + return m.Size() +} +func (m *ConversionToShentuAddrResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ConversionToShentuAddrResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ConversionToShentuAddrResponse proto.InternalMessageInfo + +func (m *ConversionToShentuAddrResponse) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + func init() { proto.RegisterType((*QueryCertifierRequest)(nil), "shentu.cert.v1alpha1.QueryCertifierRequest") proto.RegisterType((*QueryCertifierResponse)(nil), "shentu.cert.v1alpha1.QueryCertifierResponse") @@ -508,60 +596,67 @@ func init() { proto.RegisterType((*QueryCertificateResponse)(nil), "shentu.cert.v1alpha1.QueryCertificateResponse") proto.RegisterType((*QueryCertificatesRequest)(nil), "shentu.cert.v1alpha1.QueryCertificatesRequest") proto.RegisterType((*QueryCertificatesResponse)(nil), "shentu.cert.v1alpha1.QueryCertificatesResponse") + proto.RegisterType((*ConversionToShentuAddrRequest)(nil), "shentu.cert.v1alpha1.ConversionToShentuAddrRequest") + proto.RegisterType((*ConversionToShentuAddrResponse)(nil), "shentu.cert.v1alpha1.ConversionToShentuAddrResponse") } func init() { proto.RegisterFile("shentu/cert/v1alpha1/query.proto", fileDescriptor_d0446c22ac299371) } var fileDescriptor_d0446c22ac299371 = []byte{ - // 766 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcf, 0x4f, 0x13, 0x4d, - 0x18, 0xc7, 0xbb, 0xbc, 0xc0, 0x4b, 0x07, 0xde, 0x57, 0x33, 0xa9, 0x5a, 0x1a, 0xb2, 0xd4, 0x89, - 0x12, 0x04, 0xd9, 0x49, 0xd1, 0xc4, 0xe8, 0x45, 0x84, 0x88, 0x21, 0x5e, 0xb0, 0xf1, 0xa0, 0x26, - 0x8a, 0xd3, 0x76, 0xba, 0x6c, 0x2c, 0x3b, 0xcb, 0xce, 0x2c, 0x71, 0x43, 0xb8, 0x78, 0xe5, 0x62, - 0xc2, 0xd1, 0xc4, 0xab, 0x26, 0x5e, 0xfd, 0x23, 0x88, 0x27, 0x12, 0x2f, 0x9e, 0x8c, 0x01, 0xff, - 0x10, 0xb3, 0xf3, 0xa3, 0x5d, 0xca, 0x02, 0xeb, 0xa9, 0x9d, 0x99, 0xef, 0xf3, 0x3c, 0x9f, 0x7d, - 0x7e, 0x81, 0x2a, 0x5f, 0xa7, 0xbe, 0x88, 0x70, 0x93, 0x86, 0x02, 0x6f, 0xd5, 0x48, 0x27, 0x58, - 0x27, 0x35, 0xbc, 0x19, 0xd1, 0x30, 0x76, 0x82, 0x90, 0x09, 0x06, 0x4b, 0x4a, 0xe1, 0x24, 0x0a, - 0xc7, 0x28, 0x2a, 0x25, 0x97, 0xb9, 0x4c, 0x0a, 0x70, 0xf2, 0x4f, 0x69, 0x2b, 0x33, 0x4d, 0xc6, - 0x37, 0x18, 0xc7, 0x0d, 0xc2, 0xa9, 0x72, 0x82, 0xb7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 0x3f, 0xb4, 0xad, - 0x83, 0x43, 0xdb, 0xfa, 0x75, 0x68, 0x5b, 0xef, 0x8f, 0xec, 0xc2, 0xc1, 0x91, 0x5d, 0xf8, 0x71, - 0x64, 0x17, 0x5e, 0x60, 0xd7, 0x13, 0xeb, 0x51, 0xc3, 0x69, 0xb2, 0x0d, 0xed, 0xa7, 0xcd, 0x22, - 0xbf, 0x25, 0xa7, 0xdc, 0x38, 0x7e, 0xab, 0x5c, 0x27, 0x7b, 0x85, 0x37, 0x86, 0xe5, 0x6e, 0xbf, - 0xf5, 0x27, 0x00, 0x00, 0xff, 0xff, 0x65, 0x16, 0xfc, 0xad, 0x4b, 0x08, 0x00, 0x00, + // 842 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x95, 0xcf, 0x4f, 0xdb, 0x48, + 0x14, 0xc7, 0x63, 0x96, 0x5f, 0x19, 0x58, 0x76, 0x35, 0xca, 0xee, 0x86, 0x88, 0x35, 0xd9, 0xd1, + 0x2e, 0x62, 0xa1, 0xf1, 0x28, 0x80, 0x54, 0xc1, 0xa5, 0xfc, 0x50, 0xa9, 0x50, 0x2f, 0x34, 0xe5, + 0xd0, 0x56, 0x6a, 0xe9, 0x24, 0x99, 0x18, 0xab, 0xc1, 0x63, 0x3c, 0x63, 0x54, 0x0b, 0x71, 0xe9, + 0x95, 0x4b, 0x25, 0x8e, 0xfd, 0x03, 0x5a, 0x89, 0x6b, 0xff, 0x08, 0x54, 0xf5, 0x80, 0xd4, 0x4b, + 0x4f, 0x55, 0x05, 0xfd, 0x43, 0x2a, 0x8f, 0xc7, 0x8e, 0x09, 0xf9, 0x61, 0x4e, 0xc9, 0xcc, 0x7c, + 0xdf, 0x7b, 0x9f, 0x79, 0xf3, 0xde, 0x33, 0x28, 0xf2, 0x3d, 0x6a, 0x0b, 0x0f, 0xd7, 0xa8, 0x2b, + 0xf0, 0x61, 0x99, 0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 0x7c, 0x87, 0xc2, 0x4d, 0x00, 0x5a, 0xad, 0x99, 0x1f, 0x94, 0xbc, 0x33, 0x86, 0x7a, 0x9c, + 0xa0, 0x8f, 0x8d, 0x70, 0x18, 0xa8, 0x3e, 0x36, 0xb6, 0x89, 0x19, 0xe5, 0xab, 0x92, 0xb0, 0x44, + 0x27, 0x1a, 0x98, 0xec, 0x40, 0xab, 0xd2, 0x92, 0x03, 0x43, 0x82, 0x09, 0xd2, 0x54, 0x09, 0x0d, + 0x17, 0xf0, 0x09, 0x18, 0x4f, 0xe0, 0x04, 0xdd, 0x13, 0x94, 0xa3, 0xd1, 0x39, 0x5b, 0xdd, 0x52, + 0xae, 0x52, 0x77, 0xcd, 0x13, 0x5a, 0x06, 0x7f, 0x6f, 0x30, 0xfb, 0x90, 0xba, 0xdc, 0x62, 0xf6, + 0x0e, 0x7b, 0x2c, 0x1d, 0xae, 0xd5, 0xeb, 0xfd, 0x7b, 0x19, 0xad, 0x00, 0xbd, 0x9b, 0xa9, 0xba, + 0x4c, 0x57, 0xdb, 0x85, 0xcf, 0x23, 0x60, 0x48, 0x72, 0xc2, 0xf7, 0x1a, 0xc8, 0xc6, 0x0d, 0x04, + 0xe7, 0xfb, 0x5f, 0x29, 0x1e, 0x33, 0x85, 0x3b, 0xe9, 0xc4, 0x21, 0x0c, 0xba, 0xf7, 0xe6, 0xcb, + 0x8f, 0xd3, 0x81, 0x65, 0x78, 0x17, 0x77, 0x9d, 0x98, 0xd2, 0x00, 0x1f, 0x29, 0xc8, 0x63, 0x2c, + 0xa7, 0x13, 0x3e, 0x92, 0x3f, 0xc7, 0xf0, 0x54, 0x03, 0xa0, 0x35, 0x28, 0x60, 0xaa, 0xe8, 0x51, + 0x19, 0x16, 0x4a, 0x29, 0xd5, 0x0a, 0x76, 0x56, 0xc2, 0x22, 0x58, 0xec, 0x03, 0xcb, 0xe1, 0x89, + 0x06, 0x46, 0xa3, 0x16, 0x86, 0x73, 0x3d, 0xa2, 0xb4, 0x4d, 0xa0, 0xc2, 0x7c, 0x2a, 0xad, 0xe2, + 0x99, 0x91, 0x3c, 0x45, 0xa8, 0x77, 0xe6, 0x89, 0x66, 0x06, 0xfc, 0xa0, 0x81, 0xb1, 0x44, 0xe9, + 0xc1, 0x52, 0xda, 0x12, 0x0d, 0x99, 0x6e, 0x59, 0xd1, 0x68, 0x45, 0x62, 0x2d, 0xc1, 0x85, 0x9e, + 0x69, 0x0a, 0x4c, 0xf0, 0xd1, 0xf5, 0x81, 0x75, 0x0c, 0xdf, 0x69, 0x60, 0x3c, 0xd9, 0x82, 0x30, + 0x65, 0xf0, 0xf8, 0x49, 0x71, 0x6a, 0xbd, 0xa2, 0x9d, 0x93, 0xb4, 0xff, 0x42, 0xd4, 0x97, 0x96, + 0xc3, 0x33, 0x0d, 0x4c, 0x04, 0xbd, 0xd4, 0xea, 0x30, 0xb8, 0xd8, 0x65, 0x38, 0xf6, 0x6a, 0xdf, + 0xc2, 0xd2, 0xed, 0x8c, 0x14, 0xa9, 0x21, 0x49, 0x67, 0xe1, 0x4c, 0x4c, 0x1a, 0xeb, 0xb1, 0x60, + 0x25, 0xb5, 0x19, 0x37, 0xca, 0xfa, 0xd6, 0xf9, 0xa5, 0xae, 0x5d, 0x5c, 0xea, 0xda, 0xf7, 0x4b, + 0x5d, 0x7b, 0x7b, 0xa5, 0x67, 0x2e, 0xae, 0xf4, 0xcc, 0xd7, 0x2b, 0x3d, 0xf3, 0x0c, 0x9b, 0x96, + 0xd8, 0xf3, 0xaa, 0x46, 0x8d, 0xed, 0x2b, 0x5f, 0x0d, 0xe6, 0xd9, 0x75, 0x39, 0x0a, 0x23, 0xe7, + 0xaf, 0xc3, 0x44, 0x04, 0xc3, 0x97, 0x57, 0x87, 0xe5, 0x07, 0x70, 0xf1, 0x67, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x7f, 0x4b, 0x19, 0x39, 0x70, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -581,6 +676,7 @@ type QueryClient interface { Platform(ctx context.Context, in *QueryPlatformRequest, opts ...grpc.CallOption) (*QueryPlatformResponse, error) Certificate(ctx context.Context, in *QueryCertificateRequest, opts ...grpc.CallOption) (*QueryCertificateResponse, error) Certificates(ctx context.Context, in *QueryCertificatesRequest, opts ...grpc.CallOption) (*QueryCertificatesResponse, error) + AddrConversion(ctx context.Context, in *ConversionToShentuAddrRequest, opts ...grpc.CallOption) (*ConversionToShentuAddrResponse, error) } type queryClient struct { @@ -636,6 +732,15 @@ func (c *queryClient) Certificates(ctx context.Context, in *QueryCertificatesReq return out, nil } +func (c *queryClient) AddrConversion(ctx context.Context, in *ConversionToShentuAddrRequest, opts ...grpc.CallOption) (*ConversionToShentuAddrResponse, error) { + out := new(ConversionToShentuAddrResponse) + err := c.cc.Invoke(ctx, "/shentu.cert.v1alpha1.Query/AddrConversion", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { Certifier(context.Context, *QueryCertifierRequest) (*QueryCertifierResponse, error) @@ -643,6 +748,7 @@ type QueryServer interface { Platform(context.Context, *QueryPlatformRequest) (*QueryPlatformResponse, error) Certificate(context.Context, *QueryCertificateRequest) (*QueryCertificateResponse, error) Certificates(context.Context, *QueryCertificatesRequest) (*QueryCertificatesResponse, error) + AddrConversion(context.Context, *ConversionToShentuAddrRequest) (*ConversionToShentuAddrResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -664,6 +770,9 @@ func (*UnimplementedQueryServer) Certificate(ctx context.Context, req *QueryCert func (*UnimplementedQueryServer) Certificates(ctx context.Context, req *QueryCertificatesRequest) (*QueryCertificatesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Certificates not implemented") } +func (*UnimplementedQueryServer) AddrConversion(ctx context.Context, req *ConversionToShentuAddrRequest) (*ConversionToShentuAddrResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddrConversion not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -759,6 +868,24 @@ func _Query_Certificates_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Query_AddrConversion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ConversionToShentuAddrRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AddrConversion(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/shentu.cert.v1alpha1.Query/AddrConversion", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AddrConversion(ctx, req.(*ConversionToShentuAddrRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "shentu.cert.v1alpha1.Query", HandlerType: (*QueryServer)(nil), @@ -783,6 +910,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Certificates", Handler: _Query_Certificates_Handler, }, + { + MethodName: "AddrConversion", + Handler: _Query_AddrConversion_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "shentu/cert/v1alpha1/query.proto", @@ -1138,6 +1269,66 @@ func (m *QueryCertificatesResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *ConversionToShentuAddrRequest) 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 *ConversionToShentuAddrRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConversionToShentuAddrRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ConversionToShentuAddrResponse) 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 *ConversionToShentuAddrResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConversionToShentuAddrResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1287,6 +1478,32 @@ func (m *QueryCertificatesResponse) Size() (n int) { return n } +func (m *ConversionToShentuAddrRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *ConversionToShentuAddrResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2198,6 +2415,170 @@ func (m *QueryCertificatesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *ConversionToShentuAddrRequest) 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: ConversionToShentuAddrRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConversionToShentuAddrRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConversionToShentuAddrResponse) 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: ConversionToShentuAddrResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConversionToShentuAddrResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/cert/types/query.pb.gw.go b/x/cert/types/query.pb.gw.go index b3d1a836c..e9ed26565 100644 --- a/x/cert/types/query.pb.gw.go +++ b/x/cert/types/query.pb.gw.go @@ -253,6 +253,60 @@ func local_request_Query_Certificates_0(ctx context.Context, marshaler runtime.M } +func request_Query_AddrConversion_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ConversionToShentuAddrRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.AddrConversion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AddrConversion_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ConversionToShentuAddrRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.AddrConversion(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. @@ -374,6 +428,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_AddrConversion_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_AddrConversion_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_AddrConversion_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -515,6 +592,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_AddrConversion_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_AddrConversion_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_AddrConversion_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -528,6 +625,8 @@ var ( pattern_Query_Certificate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"shentu", "cert", "v1alpha1", "certificate", "certificate_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Certificates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"shentu", "cert", "v1alpha1", "certificates"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_AddrConversion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"shentu", "conversion", "to-shentu", "address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -540,4 +639,6 @@ var ( forward_Query_Certificate_0 = runtime.ForwardResponseMessage forward_Query_Certificates_0 = runtime.ForwardResponseMessage + + forward_Query_AddrConversion_0 = runtime.ForwardResponseMessage )