From bf6521b385ef60102f8f820a149b94c134604a6f Mon Sep 17 00:00:00 2001 From: astaphobia Date: Wed, 26 Feb 2020 16:01:35 +0800 Subject: [PATCH 1/2] no need to validate current block height --- common/transaction/sendMoney.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/common/transaction/sendMoney.go b/common/transaction/sendMoney.go index 3c2ca882c..d10ff5a1b 100644 --- a/common/transaction/sendMoney.go +++ b/common/transaction/sendMoney.go @@ -292,7 +292,6 @@ Escrow Part func (tx *SendMoney) EscrowValidate(dbTx bool) error { var ( accountBalance model.AccountBalance - block *model.Block err error row *sql.Row ) @@ -310,14 +309,6 @@ func (tx *SendMoney) EscrowValidate(dbTx bool) error { return blocker.NewBlocker(blocker.ValidationErr, "RecipientAddressRequired") } - block, err = util.GetLastBlock(tx.QueryExecutor, tx.BlockQuery) - if err != nil { - return blocker.NewBlocker(blocker.ValidationErr, err.Error()) - } - if uint64(block.GetHeight()) >= tx.Escrow.GetTimeout() { - return blocker.NewBlocker(blocker.ValidationErr, "TransactionExpired") - } - // todo: this is temporary solution, later we should depend on coinbase, so no genesis transaction exclusion in // validation needed if tx.SenderAddress != constant.MainchainGenesisAccountAddress { From c017838f9005b7dce27b66454d284df69544039c Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 3 Mar 2020 17:50:55 +0800 Subject: [PATCH 2/2] functionality test get escrow by id --- api/client/GetEscrowTransaction/main.go | 45 ++++++++ api/handler/escrowTransactionHandler.go | 7 ++ api/service/escrowTransactionApiService.go | 32 +++++- .../escrowTransactionApiService_test.go | 81 +++++++++++++ common/model/escrow.pb.go | 108 ++++++++++++------ common/service/escrow.pb.go | 57 ++++++--- common/service/escrow.pb.gw.go | 46 +++++++- 7 files changed, 322 insertions(+), 54 deletions(-) create mode 100644 api/client/GetEscrowTransaction/main.go diff --git a/api/client/GetEscrowTransaction/main.go b/api/client/GetEscrowTransaction/main.go new file mode 100644 index 000000000..3a45402ef --- /dev/null +++ b/api/client/GetEscrowTransaction/main.go @@ -0,0 +1,45 @@ +package main + +import ( + "context" + "fmt" + "log" + + "github.com/sirupsen/logrus" + "github.com/spf13/viper" + rpcModel "github.com/zoobc/zoobc-core/common/model" + rpcService "github.com/zoobc/zoobc-core/common/service" + "github.com/zoobc/zoobc-core/common/util" + "google.golang.org/grpc" +) + +func main() { + var apiRPCPort int + if err := util.LoadConfig("../../../resource", "config", "toml"); err != nil { + logrus.Fatal(err) + } else { + apiRPCPort = viper.GetInt("apiRPCPort") + if apiRPCPort == 0 { + apiRPCPort = 8080 + } + } + + conn, err := grpc.Dial(fmt.Sprintf(":%d", apiRPCPort), grpc.WithInsecure()) + if err != nil { + log.Fatalf("did not connect: %s", err) + } + defer conn.Close() + + c := rpcService.NewEscrowTransactionServiceClient(conn) + + response, err := c.GetEscrowTransaction(context.Background(), &rpcModel.GetEscrowTransactionRequest{ + ID: -2747806915165203447, + }) + + if err != nil { + log.Fatalf("error calling : %s", err) + } + + log.Printf("response from remote : %s", response) + +} diff --git a/api/handler/escrowTransactionHandler.go b/api/handler/escrowTransactionHandler.go index 623684835..5d876a89b 100644 --- a/api/handler/escrowTransactionHandler.go +++ b/api/handler/escrowTransactionHandler.go @@ -19,3 +19,10 @@ func (eh *EscrowTransactionHandler) GetEscrowTransactions( ) (*model.GetEscrowTransactionsResponse, error) { return eh.Service.GetEscrowTransactions(req) } + +func (eh *EscrowTransactionHandler) GetEscrowTransaction( + _ context.Context, + req *model.GetEscrowTransactionRequest, +) (*model.Escrow, error) { + return eh.Service.GetEscrowTransaction(req) +} diff --git a/api/service/escrowTransactionApiService.go b/api/service/escrowTransactionApiService.go index 67c1a3c0f..3ebf9a68f 100644 --- a/api/service/escrowTransactionApiService.go +++ b/api/service/escrowTransactionApiService.go @@ -14,6 +14,7 @@ type ( // EscrowTransactionServiceInterface interface that contain methods of escrow transaction EscrowTransactionServiceInterface interface { GetEscrowTransactions(request *model.GetEscrowTransactionsRequest) (*model.GetEscrowTransactionsResponse, error) + GetEscrowTransaction(request *model.GetEscrowTransactionRequest) (*model.Escrow, error) } // EscrowTransactionService struct that contain fields that needed escrowTransactionService struct { @@ -59,7 +60,7 @@ func (es *escrowTransactionService) GetEscrowTransactions( } caseQuery.And(caseQuery.In("status", statuses...)) } - if params.GetID() > 0 { + if params.GetID() != 0 { caseQuery.And(caseQuery.Equal("id", params.GetID())) } @@ -108,3 +109,32 @@ func (es *escrowTransactionService) GetEscrowTransactions( Escrows: escrows, }, nil } + +// GetEscrowTransaction to get escrow by id and status +func (es *escrowTransactionService) GetEscrowTransaction( + request *model.GetEscrowTransactionRequest, +) (*model.Escrow, error) { + var ( + escrowQuery = query.NewEscrowTransactionQuery() + escrow model.Escrow + row *sql.Row + err error + ) + + caseQuery := query.CaseQuery{ + Query: bytes.NewBuffer([]byte{}), + } + + caseQuery.Select(escrowQuery.TableName, escrowQuery.Fields...) + caseQuery.Where(caseQuery.Equal("id", request.GetID())) + caseQuery.Where(caseQuery.Equal("latest", 1)) + + qStr, qArgs := caseQuery.Build() + + row, _ = es.Query.ExecuteSelectRow(qStr, false, qArgs...) + err = escrowQuery.Scan(&escrow, row) + if err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + return &escrow, nil +} diff --git a/api/service/escrowTransactionApiService_test.go b/api/service/escrowTransactionApiService_test.go index bae353735..8bf8b6f09 100644 --- a/api/service/escrowTransactionApiService_test.go +++ b/api/service/escrowTransactionApiService_test.go @@ -123,3 +123,84 @@ func TestEscrowTransactionService_GetEscrowTransactions(t *testing.T) { }) } } + +type ( + mockExecutorGetEscrow struct { + query.ExecutorInterface + } +) + +func (*mockExecutorGetEscrow) ExecuteSelectRow(string, bool, ...interface{}) (*sql.Row, error) { + db, mock, _ := sqlmock.New() + mockedRow := mock.NewRows(query.NewEscrowTransactionQuery().Fields) + mockedRow.AddRow( + int64(1), + "BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN", + "BCZD_VxfO2S9aziIL3cn_cXW7uPDVPOrnXuP98GEAUC7", + "BCZKLvgUYZ1KKx-jtF9KoJskjVPvB9jpIjfzzI6zDW0J", + int64(10), + int64(1), + uint64(120), + model.EscrowStatus_Approved, + uint32(0), + true, + "", + ) + mock.ExpectQuery("").WillReturnRows(mockedRow) + row := db.QueryRow("") + return row, nil +} + +func Test_escrowTransactionService_GetEscrowTransaction(t *testing.T) { + type fields struct { + Query query.ExecutorInterface + } + type args struct { + request *model.GetEscrowTransactionRequest + } + tests := []struct { + name string + fields fields + args args + want *model.Escrow + wantErr bool + }{ + { + name: "wantSuccess", + fields: fields{ + Query: &mockExecutorGetEscrow{}, + }, + args: args{ + request: &model.GetEscrowTransactionRequest{ + ID: 918263123, + }, + }, + want: &model.Escrow{ + ID: 1, + SenderAddress: "BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN", + RecipientAddress: "BCZD_VxfO2S9aziIL3cn_cXW7uPDVPOrnXuP98GEAUC7", + ApproverAddress: "BCZKLvgUYZ1KKx-jtF9KoJskjVPvB9jpIjfzzI6zDW0J", + Amount: 10, + Commission: 1, + Timeout: 120, + Status: model.EscrowStatus_Approved, + Latest: true, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + es := &escrowTransactionService{ + Query: tt.fields.Query, + } + got, err := es.GetEscrowTransaction(tt.args.request) + if (err != nil) != tt.wantErr { + t.Errorf("GetEscrowTransaction() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetEscrowTransaction() got = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/common/model/escrow.pb.go b/common/model/escrow.pb.go index f407c7aa9..73216c100 100644 --- a/common/model/escrow.pb.go +++ b/common/model/escrow.pb.go @@ -326,48 +326,90 @@ func (m *GetEscrowTransactionsResponse) GetEscrows() []*Escrow { return nil } +// GetEscrowTransactionRequest represents GetEscrowTransaction parameter +type GetEscrowTransactionRequest struct { + ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetEscrowTransactionRequest) Reset() { *m = GetEscrowTransactionRequest{} } +func (m *GetEscrowTransactionRequest) String() string { return proto.CompactTextString(m) } +func (*GetEscrowTransactionRequest) ProtoMessage() {} +func (*GetEscrowTransactionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c4ffdfca00fa52ba, []int{3} +} + +func (m *GetEscrowTransactionRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetEscrowTransactionRequest.Unmarshal(m, b) +} +func (m *GetEscrowTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetEscrowTransactionRequest.Marshal(b, m, deterministic) +} +func (m *GetEscrowTransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetEscrowTransactionRequest.Merge(m, src) +} +func (m *GetEscrowTransactionRequest) XXX_Size() int { + return xxx_messageInfo_GetEscrowTransactionRequest.Size(m) +} +func (m *GetEscrowTransactionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetEscrowTransactionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetEscrowTransactionRequest proto.InternalMessageInfo + +func (m *GetEscrowTransactionRequest) GetID() int64 { + if m != nil { + return m.ID + } + return 0 +} + func init() { proto.RegisterEnum("model.EscrowStatus", EscrowStatus_name, EscrowStatus_value) proto.RegisterEnum("model.EscrowApproval", EscrowApproval_name, EscrowApproval_value) proto.RegisterType((*Escrow)(nil), "model.Escrow") proto.RegisterType((*GetEscrowTransactionsRequest)(nil), "model.GetEscrowTransactionsRequest") proto.RegisterType((*GetEscrowTransactionsResponse)(nil), "model.GetEscrowTransactionsResponse") + proto.RegisterType((*GetEscrowTransactionRequest)(nil), "model.GetEscrowTransactionRequest") } func init() { proto.RegisterFile("model/escrow.proto", fileDescriptor_c4ffdfca00fa52ba) } var fileDescriptor_c4ffdfca00fa52ba = []byte{ - // 510 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x5f, 0x8f, 0xd2, 0x40, - 0x14, 0xc5, 0x77, 0xca, 0x52, 0xd8, 0xcb, 0x82, 0x75, 0x4c, 0x36, 0xcd, 0x66, 0x4d, 0x1a, 0x62, - 0xb4, 0x62, 0xa4, 0x8a, 0x9f, 0x00, 0x84, 0x28, 0x89, 0x0f, 0x9b, 0x81, 0x27, 0xdf, 0x4a, 0x7b, - 0xc3, 0x8e, 0xd2, 0x99, 0xda, 0x99, 0xaa, 0xf1, 0x73, 0xf8, 0x7d, 0x35, 0x9d, 0x29, 0x6c, 0xd9, - 0x3f, 0x2f, 0x24, 0xfd, 0x9d, 0x73, 0x87, 0xb9, 0xe7, 0xb4, 0x40, 0x33, 0x99, 0xe2, 0x2e, 0x42, - 0x95, 0x14, 0xf2, 0xd7, 0x38, 0x2f, 0xa4, 0x96, 0xb4, 0x6d, 0xd8, 0xe5, 0x85, 0x95, 0xf2, 0x78, - 0xcb, 0x45, 0xac, 0xb9, 0x14, 0x56, 0x1e, 0xfe, 0x73, 0xc0, 0x5d, 0x18, 0x3f, 0xa5, 0xe0, 0x2c, - 0xe7, 0x3e, 0x09, 0x48, 0xd8, 0x9a, 0x39, 0xef, 0x08, 0x73, 0x96, 0x73, 0xfa, 0x02, 0xfa, 0x2b, - 0x14, 0x29, 0x16, 0xd3, 0x34, 0x2d, 0x50, 0x29, 0xdf, 0x09, 0x48, 0x78, 0xc6, 0x8e, 0x21, 0x1d, - 0x81, 0xc7, 0x30, 0xe1, 0x39, 0x47, 0xa1, 0xf7, 0xc6, 0x96, 0x31, 0xde, 0xe3, 0x34, 0x84, 0x27, - 0xd3, 0x3c, 0x2f, 0xe4, 0xcf, 0xdb, 0x33, 0x4f, 0x8d, 0xf5, 0x2e, 0xa6, 0x97, 0xe0, 0x4e, 0x33, - 0x59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xf2, 0xb4, 0xbe, 0xc6, 0xad, 0xc0, 0x1a, 0xa6, 0xe1, - 0x06, 0x9e, 0x3f, 0x92, 0x8a, 0xca, 0xa5, 0x50, 0x48, 0x7d, 0x68, 0xaf, 0xa5, 0x8e, 0x77, 0x26, - 0x0c, 0x5b, 0xae, 0x05, 0xf4, 0x15, 0x74, 0xec, 0x5c, 0xf5, 0xba, 0xb6, 0xc2, 0xde, 0xa4, 0x7f, - 0xb4, 0x31, 0xdb, 0xab, 0xa3, 0x39, 0x9c, 0x37, 0x43, 0xa0, 0x3d, 0xe8, 0x5c, 0xa3, 0x48, 0xb9, - 0xd8, 0x7a, 0x27, 0xf4, 0x1c, 0xba, 0x75, 0xbe, 0xa9, 0x47, 0xaa, 0x27, 0x86, 0xdf, 0x30, 0xd1, - 0x98, 0x7a, 0x4e, 0x65, 0x5c, 0xfc, 0xce, 0x79, 0x81, 0xa9, 0xd7, 0x1a, 0xbd, 0x86, 0x81, 0x3d, - 0xc5, 0xda, 0xe3, 0x5d, 0x25, 0xd7, 0xa3, 0xde, 0x09, 0x05, 0x70, 0xed, 0xa4, 0x47, 0x66, 0xa3, - 0xaf, 0xe1, 0x96, 0xeb, 0x9b, 0x72, 0x33, 0x4e, 0x64, 0x16, 0xfd, 0x91, 0x72, 0x93, 0xd8, 0xdf, - 0xb7, 0x89, 0x2c, 0x30, 0x4a, 0x64, 0x96, 0x49, 0x11, 0x99, 0xcb, 0x6e, 0x5c, 0xf3, 0x81, 0x7e, - 0xf8, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x24, 0x19, 0xbf, 0x2c, 0xd5, 0x03, 0x00, 0x00, + // 520 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x53, 0x51, 0x6f, 0xd3, 0x30, + 0x18, 0x9c, 0xd3, 0x35, 0xed, 0xbe, 0xae, 0x25, 0x18, 0x69, 0x8a, 0xc6, 0x90, 0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6b, 0x23, 0xec, 0x8c, 0xbb, 0x07, + 0x8e, 0xd9, 0x8e, 0xed, 0x5f, 0xc3, 0xf3, 0x63, 0x7b, 0xec, 0x82, 0x3f, 0xf2, 0x20, 0x06, 0x33, + 0x38, 0xaf, 0xe7, 0x46, 0x3b, 0xd0, 0xba, 0x41, 0x91, 0x70, 0xb1, 0xf1, 0x4e, 0xe8, 0x39, 0xb4, + 0xab, 0x4a, 0x12, 0x8f, 0x94, 0x7f, 0x0c, 0xbf, 0x61, 0xac, 0x31, 0xf1, 0x9c, 0x52, 0x38, 0xff, + 0x9d, 0xf1, 0x1c, 0x13, 0xaf, 0x31, 0x78, 0x03, 0x3d, 0xbb, 0x8a, 0x95, 0x47, 0xdb, 0x92, 0xae, + 0x46, 0xbd, 0x13, 0x0a, 0xe0, 0xda, 0x49, 0x8f, 0x4c, 0x07, 0x5f, 0xc3, 0x0d, 0xd7, 0xb7, 0xc5, + 0x7a, 0x18, 0xcb, 0x74, 0xf4, 0x47, 0xca, 0x75, 0x6c, 0xbf, 0xef, 0x62, 0x99, 0xe3, 0x28, 0x96, + 0x69, 0x2a, 0xc5, 0xc8, 0xf8, 0x5b, 0xbb, 0xe6, 0x4d, 0x7f, 0xf8, 0x1f, 0x00, 0x00, 0xff, 0xff, + 0x28, 0x31, 0xe2, 0x7b, 0x08, 0x04, 0x00, 0x00, } diff --git a/common/service/escrow.pb.go b/common/service/escrow.pb.go index fea6c5425..bd32fcdcd 100644 --- a/common/service/escrow.pb.go +++ b/common/service/escrow.pb.go @@ -10,8 +10,6 @@ import ( model "github.com/zoobc/zoobc-core/common/model" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" math "math" ) @@ -29,20 +27,22 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package func init() { proto.RegisterFile("service/escrow.proto", fileDescriptor_23585460a3adf6bf) } var fileDescriptor_23585460a3adf6bf = []byte{ - // 203 bytes of a gzipped FileDescriptorProto + // 232 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x4f, 0x2d, 0x4e, 0x2e, 0xca, 0x2f, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x8a, 0x4a, 0x09, 0xe5, 0xe6, 0xa7, 0xa4, 0xe6, 0xa0, 0x48, 0x4a, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, 0xe5, 0xe5, 0x97, 0x24, - 0x96, 0x64, 0xe6, 0xe7, 0x15, 0x43, 0x64, 0x8d, 0x36, 0x30, 0x72, 0x49, 0xb8, 0x82, 0x95, 0x87, + 0x96, 0x64, 0xe6, 0xe7, 0x15, 0x43, 0x64, 0x8d, 0x56, 0x33, 0x71, 0x49, 0xb8, 0x82, 0x95, 0x87, 0x14, 0x25, 0xe6, 0x15, 0x27, 0x26, 0x83, 0x24, 0x83, 0x21, 0xc6, 0x09, 0x4d, 0x66, 0xe4, 0x12, 0x75, 0x4f, 0x2d, 0xc1, 0x90, 0x2f, 0x16, 0x52, 0xd6, 0x03, 0xdb, 0xa4, 0x87, 0x55, 0x36, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x4a, 0x05, 0xbf, 0xa2, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x25, 0xfd, 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0x69, 0x2a, 0xa9, 0xeb, 0x97, 0x19, 0x42, 0x5d, 0xae, - 0x8f, 0xcf, 0x58, 0x27, 0x9d, 0x28, 0xad, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, - 0x5c, 0xfd, 0xaa, 0xfc, 0xfc, 0xa4, 0x64, 0x08, 0xa9, 0x9b, 0x9c, 0x5f, 0x94, 0xaa, 0x9f, 0x9c, - 0x9f, 0x9b, 0x9b, 0x9f, 0xa7, 0x0f, 0x0d, 0x92, 0x24, 0x36, 0xb0, 0x3f, 0x8d, 0x01, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x32, 0xe4, 0x14, 0xe6, 0x3a, 0x01, 0x00, 0x00, + 0x8f, 0xcf, 0x58, 0xa1, 0x4a, 0x2e, 0x11, 0x6c, 0xf2, 0x42, 0x4a, 0x78, 0xac, 0x83, 0x39, 0x89, + 0x17, 0xaa, 0x06, 0xa2, 0x40, 0x49, 0x0f, 0x6c, 0xb7, 0x86, 0x90, 0x1a, 0x01, 0xbb, 0xa1, 0xda, + 0x9d, 0x74, 0xa2, 0xb4, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xab, + 0xf2, 0xf3, 0x93, 0x92, 0x21, 0xa4, 0x6e, 0x72, 0x7e, 0x51, 0xaa, 0x7e, 0x72, 0x7e, 0x6e, 0x6e, + 0x7e, 0x9e, 0x3e, 0x34, 0x36, 0x92, 0xd8, 0xc0, 0x41, 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, + 0x87, 0x94, 0x87, 0xcf, 0xb5, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -58,6 +58,7 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type EscrowTransactionServiceClient interface { GetEscrowTransactions(ctx context.Context, in *model.GetEscrowTransactionsRequest, opts ...grpc.CallOption) (*model.GetEscrowTransactionsResponse, error) + GetEscrowTransaction(ctx context.Context, in *model.GetEscrowTransactionRequest, opts ...grpc.CallOption) (*model.Escrow, error) } type escrowTransactionServiceClient struct { @@ -77,17 +78,19 @@ func (c *escrowTransactionServiceClient) GetEscrowTransactions(ctx context.Conte return out, nil } +func (c *escrowTransactionServiceClient) GetEscrowTransaction(ctx context.Context, in *model.GetEscrowTransactionRequest, opts ...grpc.CallOption) (*model.Escrow, error) { + out := new(model.Escrow) + err := c.cc.Invoke(ctx, "/service.EscrowTransactionService/GetEscrowTransaction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // EscrowTransactionServiceServer is the server API for EscrowTransactionService service. type EscrowTransactionServiceServer interface { GetEscrowTransactions(context.Context, *model.GetEscrowTransactionsRequest) (*model.GetEscrowTransactionsResponse, error) -} - -// UnimplementedEscrowTransactionServiceServer can be embedded to have forward compatible implementations. -type UnimplementedEscrowTransactionServiceServer struct { -} - -func (*UnimplementedEscrowTransactionServiceServer) GetEscrowTransactions(ctx context.Context, req *model.GetEscrowTransactionsRequest) (*model.GetEscrowTransactionsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetEscrowTransactions not implemented") + GetEscrowTransaction(context.Context, *model.GetEscrowTransactionRequest) (*model.Escrow, error) } func RegisterEscrowTransactionServiceServer(s *grpc.Server, srv EscrowTransactionServiceServer) { @@ -112,6 +115,24 @@ func _EscrowTransactionService_GetEscrowTransactions_Handler(srv interface{}, ct return interceptor(ctx, in, info, handler) } +func _EscrowTransactionService_GetEscrowTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(model.GetEscrowTransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EscrowTransactionServiceServer).GetEscrowTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/service.EscrowTransactionService/GetEscrowTransaction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EscrowTransactionServiceServer).GetEscrowTransaction(ctx, req.(*model.GetEscrowTransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _EscrowTransactionService_serviceDesc = grpc.ServiceDesc{ ServiceName: "service.EscrowTransactionService", HandlerType: (*EscrowTransactionServiceServer)(nil), @@ -120,6 +141,10 @@ var _EscrowTransactionService_serviceDesc = grpc.ServiceDesc{ MethodName: "GetEscrowTransactions", Handler: _EscrowTransactionService_GetEscrowTransactions_Handler, }, + { + MethodName: "GetEscrowTransaction", + Handler: _EscrowTransactionService_GetEscrowTransaction_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "service/escrow.proto", diff --git a/common/service/escrow.pb.gw.go b/common/service/escrow.pb.gw.go index a0324220a..a5eadc17d 100644 --- a/common/service/escrow.pb.gw.go +++ b/common/service/escrow.pb.gw.go @@ -37,14 +37,28 @@ func request_EscrowTransactionService_GetEscrowTransactions_0(ctx context.Contex var protoReq model.GetEscrowTransactionsRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_EscrowTransactionService_GetEscrowTransactions_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EscrowTransactionService_GetEscrowTransactions_0); err != nil { + + msg, err := client.GetEscrowTransactions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +var ( + filter_EscrowTransactionService_GetEscrowTransaction_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_EscrowTransactionService_GetEscrowTransaction_0(ctx context.Context, marshaler runtime.Marshaler, client EscrowTransactionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq model.GetEscrowTransactionRequest + var metadata runtime.ServerMetadata + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_EscrowTransactionService_GetEscrowTransaction_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.GetEscrowTransactions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.GetEscrowTransaction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -107,13 +121,37 @@ func RegisterEscrowTransactionServiceHandlerClient(ctx context.Context, mux *run }) + mux.Handle("GET", pattern_EscrowTransactionService_GetEscrowTransaction_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_EscrowTransactionService_GetEscrowTransaction_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_EscrowTransactionService_GetEscrowTransaction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( - pattern_EscrowTransactionService_GetEscrowTransactions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "escrow", "GetEscrowTransactionsRequest"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_EscrowTransactionService_GetEscrowTransactions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "escrow", "GetEscrowTransactionsRequest"}, "")) + + pattern_EscrowTransactionService_GetEscrowTransaction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "escrow", "GetEscrowTransactionRequest"}, "")) ) var ( forward_EscrowTransactionService_GetEscrowTransactions_0 = runtime.ForwardResponseMessage + + forward_EscrowTransactionService_GetEscrowTransaction_0 = runtime.ForwardResponseMessage )