diff --git a/api/generate.go b/api/generate.go new file mode 100644 index 0000000..93096ce --- /dev/null +++ b/api/generate.go @@ -0,0 +1,3 @@ +package api + +//go:generate protoc -I . ./token-redemption.proto --go_out=plugins=grpc:. diff --git a/api/token-redemption.pb.go b/api/token-redemption.pb.go new file mode 100644 index 0000000..b8ee1bb --- /dev/null +++ b/api/token-redemption.pb.go @@ -0,0 +1,212 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: token-redemption.proto + +package api + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// 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.ProtoPackageIsVersion3 // please upgrade the proto package + +type Request struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} +func (*Request) Descriptor() ([]byte, []int) { + return fileDescriptor_7cacfaf902f20ee9, []int{0} +} + +func (m *Request) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Request.Unmarshal(m, b) +} +func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Request.Marshal(b, m, deterministic) +} +func (m *Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_Request.Merge(m, src) +} +func (m *Request) XXX_Size() int { + return xxx_messageInfo_Request.Size(m) +} +func (m *Request) XXX_DiscardUnknown() { + xxx_messageInfo_Request.DiscardUnknown(m) +} + +var xxx_messageInfo_Request proto.InternalMessageInfo + +func (m *Request) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *Request) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type Response struct { + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} +func (*Response) Descriptor() ([]byte, []int) { + return fileDescriptor_7cacfaf902f20ee9, []int{1} +} + +func (m *Response) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Response.Unmarshal(m, b) +} +func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Response.Marshal(b, m, deterministic) +} +func (m *Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_Response.Merge(m, src) +} +func (m *Response) XXX_Size() int { + return xxx_messageInfo_Response.Size(m) +} +func (m *Response) XXX_DiscardUnknown() { + xxx_messageInfo_Response.DiscardUnknown(m) +} + +var xxx_messageInfo_Response proto.InternalMessageInfo + +func (m *Response) GetSuccess() bool { + if m != nil { + return m.Success + } + return false +} + +func (m *Response) GetMsg() string { + if m != nil { + return m.Msg + } + return "" +} + +func init() { + proto.RegisterType((*Request)(nil), "swagapi.Request") + proto.RegisterType((*Response)(nil), "swagapi.Response") +} + +func init() { proto.RegisterFile("token-redemption.proto", fileDescriptor_7cacfaf902f20ee9) } + +var fileDescriptor_7cacfaf902f20ee9 = []byte{ + // 186 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2b, 0xc9, 0xcf, 0x4e, + 0xcd, 0xd3, 0x2d, 0x4a, 0x4d, 0x49, 0xcd, 0x2d, 0x28, 0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x62, 0x2f, 0x2e, 0x4f, 0x4c, 0x4f, 0x2c, 0xc8, 0x54, 0xb2, 0xe4, 0x62, 0x0f, + 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0x12, 0xe1, 0x62, 0x05, 0xab, 0x96, 0x60, 0x54, 0x60, + 0xd4, 0xe0, 0x0c, 0x82, 0x70, 0x84, 0x24, 0xb8, 0xd8, 0x13, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, + 0x25, 0x98, 0xc0, 0xe2, 0x30, 0xae, 0x92, 0x19, 0x17, 0x47, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, + 0x71, 0x2a, 0x48, 0x55, 0x71, 0x69, 0x72, 0x32, 0x48, 0x15, 0x48, 0x37, 0x47, 0x10, 0x8c, 0x2b, + 0x24, 0xc0, 0xc5, 0x9c, 0x5b, 0x9c, 0x0e, 0xd5, 0x0b, 0x62, 0x1a, 0x59, 0x71, 0xb1, 0x07, 0x97, + 0x27, 0xa6, 0x3b, 0x06, 0x78, 0x0a, 0xe9, 0x73, 0xb1, 0x05, 0xa5, 0xa6, 0xa4, 0xa6, 0xe6, 0x0a, + 0x09, 0xe8, 0x41, 0x5d, 0xa4, 0x07, 0x75, 0x8e, 0x94, 0x20, 0x92, 0x08, 0xc4, 0x16, 0x25, 0x06, + 0x27, 0xd6, 0x28, 0xe6, 0xc4, 0x82, 0xcc, 0x24, 0x36, 0xb0, 0x2f, 0x8c, 0x01, 0x01, 0x00, 0x00, + 0xff, 0xff, 0xf8, 0x3c, 0x52, 0x97, 0xdf, 0x00, 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 + +// SwagAPIClient is the client API for SwagAPI service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type SwagAPIClient interface { + Redeem(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) +} + +type swagAPIClient struct { + cc *grpc.ClientConn +} + +func NewSwagAPIClient(cc *grpc.ClientConn) SwagAPIClient { + return &swagAPIClient{cc} +} + +func (c *swagAPIClient) Redeem(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, "/swagapi.SwagAPI/Redeem", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SwagAPIServer is the server API for SwagAPI service. +type SwagAPIServer interface { + Redeem(context.Context, *Request) (*Response, error) +} + +func RegisterSwagAPIServer(s *grpc.Server, srv SwagAPIServer) { + s.RegisterService(&_SwagAPI_serviceDesc, srv) +} + +func _SwagAPI_Redeem_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SwagAPIServer).Redeem(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/swagapi.SwagAPI/Redeem", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SwagAPIServer).Redeem(ctx, req.(*Request)) + } + return interceptor(ctx, in, info, handler) +} + +var _SwagAPI_serviceDesc = grpc.ServiceDesc{ + ServiceName: "swagapi.SwagAPI", + HandlerType: (*SwagAPIServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Redeem", + Handler: _SwagAPI_Redeem_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "token-redemption.proto", +} diff --git a/api/token-redemption.proto b/api/token-redemption.proto new file mode 100644 index 0000000..1994b5d --- /dev/null +++ b/api/token-redemption.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package swagapi; +option go_package = "api"; + +message Request { + string token = 1; + string address = 2; +} + +message Response { + bool success = 1; + string msg = 2; +} + +service SwagAPI { + rpc Redeem(Request) returns (Response) {} +} + +