From 27edb30ec71c1b96a4013ad22d619ac0a559f790 Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Fri, 26 Jul 2024 11:14:06 +0800 Subject: [PATCH 1/6] refactor: standardize file naming conventions across domains - Renamed `model.proto` to `account.proto` in the account domain - Renamed `model.proto` to `block.proto` in the block domain - Added `package block;` and `option go_package` in `block.proto` - Renamed `model.proto` to `network.proto` in the network domain - Renamed `model.proto` to `transaction.proto` in the transaction domain Signed-off-by: Sean Zheng --- pb/entity/domain/account/model/{model.proto => account.proto} | 0 pb/entity/domain/block/model/{model.proto => block.proto} | 4 ++++ pb/entity/domain/network/model/{model.proto => network.proto} | 0 .../transaction/model/{model.proto => transaction.proto} | 0 4 files changed, 4 insertions(+) rename pb/entity/domain/account/model/{model.proto => account.proto} (100%) rename pb/entity/domain/block/model/{model.proto => block.proto} (92%) rename pb/entity/domain/network/model/{model.proto => network.proto} (100%) rename pb/entity/domain/transaction/model/{model.proto => transaction.proto} (100%) diff --git a/pb/entity/domain/account/model/model.proto b/pb/entity/domain/account/model/account.proto similarity index 100% rename from pb/entity/domain/account/model/model.proto rename to pb/entity/domain/account/model/account.proto diff --git a/pb/entity/domain/block/model/model.proto b/pb/entity/domain/block/model/block.proto similarity index 92% rename from pb/entity/domain/block/model/model.proto rename to pb/entity/domain/block/model/block.proto index ab92cc3..794cd8a 100644 --- a/pb/entity/domain/block/model/model.proto +++ b/pb/entity/domain/block/model/block.proto @@ -1,4 +1,7 @@ syntax = "proto3"; +package block; + +option go_package = "github.com/blackhorseya/ryze/entity/domain/block/model"; import "google/protobuf/timestamp.proto"; @@ -38,5 +41,6 @@ service BlockService { rpc GetBlock(GetBlockRequest) returns (Block) {} // Retrieves a stream of blocks within a specified height range. + rpc GetBlocks(GetBlocksRequest) returns (stream Block) {} } diff --git a/pb/entity/domain/network/model/model.proto b/pb/entity/domain/network/model/network.proto similarity index 100% rename from pb/entity/domain/network/model/model.proto rename to pb/entity/domain/network/model/network.proto diff --git a/pb/entity/domain/transaction/model/model.proto b/pb/entity/domain/transaction/model/transaction.proto similarity index 100% rename from pb/entity/domain/transaction/model/model.proto rename to pb/entity/domain/transaction/model/transaction.proto From a771a420b55c6ff05f3dcc28d6bcfb6e5c2eb46d Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Fri, 26 Jul 2024 11:17:55 +0800 Subject: [PATCH 2/6] build: refactor protobuf generation and usage in project - Add a target to generate protobuf in the Makefile - Delete account.proto and network.proto - Modify the go_package option in transaction.proto Signed-off-by: Sean Zheng --- Makefile | 6 ++++++ pb/entity/domain/account/model/account.proto | 1 - pb/entity/domain/network/model/network.proto | 1 - pb/entity/domain/transaction/model/transaction.proto | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) delete mode 100644 pb/entity/domain/account/model/account.proto delete mode 100644 pb/entity/domain/network/model/network.proto diff --git a/Makefile b/Makefile index 62f64d5..b85956e 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,12 @@ test: ## test go binary coverage: ## generate coverage report @go test -json -coverprofile=cover.out ./... >result.json +.PHONY: gen-pb +gen-pb: ## generate protobuf + protoc --go_out=. --go_opt=paths=source_relative \ + --go-grpc_out=. --go-grpc_opt=paths=source_relative \ + pb/entity/domain/*/model/*.proto + .PHONY: gen-swagger gen-swagger: ## generate swagger @#swag init -q -g impl.go -d ./adapter/restaurant/restful,./entity,./pkg \ diff --git a/pb/entity/domain/account/model/account.proto b/pb/entity/domain/account/model/account.proto deleted file mode 100644 index 410bfde..0000000 --- a/pb/entity/domain/account/model/account.proto +++ /dev/null @@ -1 +0,0 @@ -syntax = "proto3"; diff --git a/pb/entity/domain/network/model/network.proto b/pb/entity/domain/network/model/network.proto deleted file mode 100644 index 410bfde..0000000 --- a/pb/entity/domain/network/model/network.proto +++ /dev/null @@ -1 +0,0 @@ -syntax = "proto3"; diff --git a/pb/entity/domain/transaction/model/transaction.proto b/pb/entity/domain/transaction/model/transaction.proto index a3dc8e1..eff9fee 100644 --- a/pb/entity/domain/transaction/model/transaction.proto +++ b/pb/entity/domain/transaction/model/transaction.proto @@ -1,4 +1,7 @@ syntax = "proto3"; +package transaction; + +option go_package = "github.com/blackhorseya/ryze/entity/domain/transaction/model"; import "google/protobuf/timestamp.proto"; From c726ca5007934006332133512eb2576d83d74d3e Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Fri, 26 Jul 2024 11:25:16 +0800 Subject: [PATCH 3/6] feat: gen-pb --- .gitignore | 1 + Makefile | 14 +- entity/domain/block/model/block.pb.go | 339 +++++++++++++ entity/domain/block/model/block_grpc.pb.go | 174 +++++++ .../domain/block/model/block_grpc_mock.pb.go | 370 +++++++++++++++ .../transaction/model/transaction.pb.go | 447 ++++++++++++++++++ .../transaction/model/transaction_grpc.pb.go | 215 +++++++++ .../model/transaction_grpc_mock.pb.go | 405 ++++++++++++++++ go.mod | 6 + go.sum | 21 +- 10 files changed, 1982 insertions(+), 10 deletions(-) create mode 100644 entity/domain/block/model/block.pb.go create mode 100644 entity/domain/block/model/block_grpc.pb.go create mode 100644 entity/domain/block/model/block_grpc_mock.pb.go create mode 100644 entity/domain/transaction/model/transaction.pb.go create mode 100644 entity/domain/transaction/model/transaction_grpc.pb.go create mode 100644 entity/domain/transaction/model/transaction_grpc_mock.pb.go diff --git a/.gitignore b/.gitignore index a5bb808..297a50f 100644 --- a/.gitignore +++ b/.gitignore @@ -498,3 +498,4 @@ $RECYCLE.BIN/ bin deployments +result.json diff --git a/Makefile b/Makefile index b85956e..8cf3b28 100644 --- a/Makefile +++ b/Makefile @@ -39,21 +39,19 @@ gazelle: ## run gazelle with bazel .PHONY: build build: ## build go binary - @bazel build //... + @go build ./... .PHONY: test test: ## test go binary - @bazel test --verbose_failures //... - -.PHONY: coverage -coverage: ## generate coverage report @go test -json -coverprofile=cover.out ./... >result.json .PHONY: gen-pb gen-pb: ## generate protobuf - protoc --go_out=. --go_opt=paths=source_relative \ - --go-grpc_out=. --go-grpc_opt=paths=source_relative \ - pb/entity/domain/*/model/*.proto + protoc --proto_path=./pb \ + --go_out=paths=source_relative:./ \ + --go-grpc_out=paths=source_relative,require_unimplemented_servers=false:./ \ + --go-grpc-mock_out=paths=source_relative,require_unimplemented_servers=false:./ \ + ./pb/entity/domain/*/*/*.proto .PHONY: gen-swagger gen-swagger: ## generate swagger diff --git a/entity/domain/block/model/block.pb.go b/entity/domain/block/model/block.pb.go new file mode 100644 index 0000000..6ce2331 --- /dev/null +++ b/entity/domain/block/model/block.pb.go @@ -0,0 +1,339 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc v4.25.3 +// source: entity/domain/block/model/block.proto + +package model + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Represents a block in the blockchain. +type Block struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Unique identifier of the block. + Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // Height of the block in the blockchain. + Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // Timestamp of when the block was created. + Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // List of transaction IDs included in the block. + TransactionIds [][]byte `protobuf:"bytes,4,rep,name=transaction_ids,json=transactionIds,proto3" json:"transaction_ids,omitempty"` +} + +func (x *Block) Reset() { + *x = Block{} + if protoimpl.UnsafeEnabled { + mi := &file_entity_domain_block_model_block_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Block) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Block) ProtoMessage() {} + +func (x *Block) ProtoReflect() protoreflect.Message { + mi := &file_entity_domain_block_model_block_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Block.ProtoReflect.Descriptor instead. +func (*Block) Descriptor() ([]byte, []int) { + return file_entity_domain_block_model_block_proto_rawDescGZIP(), []int{0} +} + +func (x *Block) GetId() []byte { + if x != nil { + return x.Id + } + return nil +} + +func (x *Block) GetHeight() int64 { + if x != nil { + return x.Height + } + return 0 +} + +func (x *Block) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *Block) GetTransactionIds() [][]byte { + if x != nil { + return x.TransactionIds + } + return nil +} + +// Request message for retrieving a single block by its ID. +type GetBlockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Unique identifier of the block to retrieve. + Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetBlockRequest) Reset() { + *x = GetBlockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_entity_domain_block_model_block_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockRequest) ProtoMessage() {} + +func (x *GetBlockRequest) ProtoReflect() protoreflect.Message { + mi := &file_entity_domain_block_model_block_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockRequest.ProtoReflect.Descriptor instead. +func (*GetBlockRequest) Descriptor() ([]byte, []int) { + return file_entity_domain_block_model_block_proto_rawDescGZIP(), []int{1} +} + +func (x *GetBlockRequest) GetId() []byte { + if x != nil { + return x.Id + } + return nil +} + +// Request message for retrieving a range of blocks by their heights. +type GetBlocksRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Starting height of the range of blocks to retrieve. + StartHeight int64 `protobuf:"varint,1,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // Ending height of the range of blocks to retrieve. + EndHeight int64 `protobuf:"varint,2,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` +} + +func (x *GetBlocksRequest) Reset() { + *x = GetBlocksRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_entity_domain_block_model_block_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlocksRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlocksRequest) ProtoMessage() {} + +func (x *GetBlocksRequest) ProtoReflect() protoreflect.Message { + mi := &file_entity_domain_block_model_block_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlocksRequest.ProtoReflect.Descriptor instead. +func (*GetBlocksRequest) Descriptor() ([]byte, []int) { + return file_entity_domain_block_model_block_proto_rawDescGZIP(), []int{2} +} + +func (x *GetBlocksRequest) GetStartHeight() int64 { + if x != nil { + return x.StartHeight + } + return 0 +} + +func (x *GetBlocksRequest) GetEndHeight() int64 { + if x != nil { + return x.EndHeight + } + return 0 +} + +var File_entity_domain_block_model_block_proto protoreflect.FileDescriptor + +var file_entity_domain_block_model_block_proto_rawDesc = []byte{ + 0x0a, 0x25, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x1a, 0x1f, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x92, 0x01, 0x0a, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, 0x0f, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x49, 0x64, 0x73, 0x22, 0x21, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x22, 0x54, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x09, 0x65, 0x6e, 0x64, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x32, 0x7a, 0x0a, + 0x0c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x32, 0x0a, + 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x2e, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x0c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, + 0x00, 0x12, 0x36, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x12, 0x17, + 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x00, 0x30, 0x01, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x68, 0x6f, 0x72, + 0x73, 0x65, 0x79, 0x61, 0x2f, 0x72, 0x79, 0x7a, 0x65, 0x2f, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x6d, 0x6f, + 0x64, 0x65, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_entity_domain_block_model_block_proto_rawDescOnce sync.Once + file_entity_domain_block_model_block_proto_rawDescData = file_entity_domain_block_model_block_proto_rawDesc +) + +func file_entity_domain_block_model_block_proto_rawDescGZIP() []byte { + file_entity_domain_block_model_block_proto_rawDescOnce.Do(func() { + file_entity_domain_block_model_block_proto_rawDescData = protoimpl.X.CompressGZIP(file_entity_domain_block_model_block_proto_rawDescData) + }) + return file_entity_domain_block_model_block_proto_rawDescData +} + +var file_entity_domain_block_model_block_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_entity_domain_block_model_block_proto_goTypes = []any{ + (*Block)(nil), // 0: block.Block + (*GetBlockRequest)(nil), // 1: block.GetBlockRequest + (*GetBlocksRequest)(nil), // 2: block.GetBlocksRequest + (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp +} +var file_entity_domain_block_model_block_proto_depIdxs = []int32{ + 3, // 0: block.Block.timestamp:type_name -> google.protobuf.Timestamp + 1, // 1: block.BlockService.GetBlock:input_type -> block.GetBlockRequest + 2, // 2: block.BlockService.GetBlocks:input_type -> block.GetBlocksRequest + 0, // 3: block.BlockService.GetBlock:output_type -> block.Block + 0, // 4: block.BlockService.GetBlocks:output_type -> block.Block + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_entity_domain_block_model_block_proto_init() } +func file_entity_domain_block_model_block_proto_init() { + if File_entity_domain_block_model_block_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_entity_domain_block_model_block_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Block); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entity_domain_block_model_block_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*GetBlockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entity_domain_block_model_block_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*GetBlocksRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_entity_domain_block_model_block_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_entity_domain_block_model_block_proto_goTypes, + DependencyIndexes: file_entity_domain_block_model_block_proto_depIdxs, + MessageInfos: file_entity_domain_block_model_block_proto_msgTypes, + }.Build() + File_entity_domain_block_model_block_proto = out.File + file_entity_domain_block_model_block_proto_rawDesc = nil + file_entity_domain_block_model_block_proto_goTypes = nil + file_entity_domain_block_model_block_proto_depIdxs = nil +} diff --git a/entity/domain/block/model/block_grpc.pb.go b/entity/domain/block/model/block_grpc.pb.go new file mode 100644 index 0000000..977c905 --- /dev/null +++ b/entity/domain/block/model/block_grpc.pb.go @@ -0,0 +1,174 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.25.3 +// source: entity/domain/block/model/block.proto + +package model + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + BlockService_GetBlock_FullMethodName = "/block.BlockService/GetBlock" + BlockService_GetBlocks_FullMethodName = "/block.BlockService/GetBlocks" +) + +// BlockServiceClient is the client API for BlockService 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 BlockServiceClient interface { + // Retrieves a single block by its ID. + GetBlock(ctx context.Context, in *GetBlockRequest, opts ...grpc.CallOption) (*Block, error) + GetBlocks(ctx context.Context, in *GetBlocksRequest, opts ...grpc.CallOption) (BlockService_GetBlocksClient, error) +} + +type blockServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewBlockServiceClient(cc grpc.ClientConnInterface) BlockServiceClient { + return &blockServiceClient{cc} +} + +func (c *blockServiceClient) GetBlock(ctx context.Context, in *GetBlockRequest, opts ...grpc.CallOption) (*Block, error) { + out := new(Block) + err := c.cc.Invoke(ctx, BlockService_GetBlock_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *blockServiceClient) GetBlocks(ctx context.Context, in *GetBlocksRequest, opts ...grpc.CallOption) (BlockService_GetBlocksClient, error) { + stream, err := c.cc.NewStream(ctx, &BlockService_ServiceDesc.Streams[0], BlockService_GetBlocks_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &blockServiceGetBlocksClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type BlockService_GetBlocksClient interface { + Recv() (*Block, error) + grpc.ClientStream +} + +type blockServiceGetBlocksClient struct { + grpc.ClientStream +} + +func (x *blockServiceGetBlocksClient) Recv() (*Block, error) { + m := new(Block) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// BlockServiceServer is the server API for BlockService service. +// All implementations should embed UnimplementedBlockServiceServer +// for forward compatibility +type BlockServiceServer interface { + // Retrieves a single block by its ID. + GetBlock(context.Context, *GetBlockRequest) (*Block, error) + GetBlocks(*GetBlocksRequest, BlockService_GetBlocksServer) error +} + +// UnimplementedBlockServiceServer should be embedded to have forward compatible implementations. +type UnimplementedBlockServiceServer struct { +} + +func (UnimplementedBlockServiceServer) GetBlock(context.Context, *GetBlockRequest) (*Block, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBlock not implemented") +} +func (UnimplementedBlockServiceServer) GetBlocks(*GetBlocksRequest, BlockService_GetBlocksServer) error { + return status.Errorf(codes.Unimplemented, "method GetBlocks not implemented") +} + +// UnsafeBlockServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to BlockServiceServer will +// result in compilation errors. +type UnsafeBlockServiceServer interface { + mustEmbedUnimplementedBlockServiceServer() +} + +func RegisterBlockServiceServer(s grpc.ServiceRegistrar, srv BlockServiceServer) { + s.RegisterService(&BlockService_ServiceDesc, srv) +} + +func _BlockService_GetBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BlockServiceServer).GetBlock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: BlockService_GetBlock_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BlockServiceServer).GetBlock(ctx, req.(*GetBlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _BlockService_GetBlocks_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetBlocksRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(BlockServiceServer).GetBlocks(m, &blockServiceGetBlocksServer{stream}) +} + +type BlockService_GetBlocksServer interface { + Send(*Block) error + grpc.ServerStream +} + +type blockServiceGetBlocksServer struct { + grpc.ServerStream +} + +func (x *blockServiceGetBlocksServer) Send(m *Block) error { + return x.ServerStream.SendMsg(m) +} + +// BlockService_ServiceDesc is the grpc.ServiceDesc for BlockService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var BlockService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "block.BlockService", + HandlerType: (*BlockServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetBlock", + Handler: _BlockService_GetBlock_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "GetBlocks", + Handler: _BlockService_GetBlocks_Handler, + ServerStreams: true, + }, + }, + Metadata: "entity/domain/block/model/block.proto", +} diff --git a/entity/domain/block/model/block_grpc_mock.pb.go b/entity/domain/block/model/block_grpc_mock.pb.go new file mode 100644 index 0000000..23396dc --- /dev/null +++ b/entity/domain/block/model/block_grpc_mock.pb.go @@ -0,0 +1,370 @@ +// Code generated by protoc-gen-go-grpc-mock. DO NOT EDIT. +// source: entity/domain/block/model/block.proto + +package model + +import ( + context "context" + reflect "reflect" + + gomock "go.uber.org/mock/gomock" + grpc "google.golang.org/grpc" + metadata "google.golang.org/grpc/metadata" +) + +// MockBlockService_GetBlocksClient is a mock of BlockService_GetBlocksClient interface. +type MockBlockService_GetBlocksClient struct { + ctrl *gomock.Controller + recorder *MockBlockService_GetBlocksClientMockRecorder +} + +// MockBlockService_GetBlocksClientMockRecorder is the mock recorder for MockBlockService_GetBlocksClient. +type MockBlockService_GetBlocksClientMockRecorder struct { + mock *MockBlockService_GetBlocksClient +} + +// NewMockBlockService_GetBlocksClient creates a new mock instance. +func NewMockBlockService_GetBlocksClient(ctrl *gomock.Controller) *MockBlockService_GetBlocksClient { + mock := &MockBlockService_GetBlocksClient{ctrl: ctrl} + mock.recorder = &MockBlockService_GetBlocksClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBlockService_GetBlocksClient) EXPECT() *MockBlockService_GetBlocksClientMockRecorder { + return m.recorder +} + +// CloseSend mocks base method. +func (m *MockBlockService_GetBlocksClient) CloseSend() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CloseSend") + ret0, _ := ret[0].(error) + return ret0 +} + +// CloseSend indicates an expected call of CloseSend. +func (mr *MockBlockService_GetBlocksClientMockRecorder) CloseSend() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseSend", reflect.TypeOf((*MockBlockService_GetBlocksClient)(nil).CloseSend)) +} + +// Context mocks base method. +func (m *MockBlockService_GetBlocksClient) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockBlockService_GetBlocksClientMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockBlockService_GetBlocksClient)(nil).Context)) +} + +// Header mocks base method. +func (m *MockBlockService_GetBlocksClient) Header() (metadata.MD, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Header") + ret0, _ := ret[0].(metadata.MD) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Header indicates an expected call of Header. +func (mr *MockBlockService_GetBlocksClientMockRecorder) Header() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Header", reflect.TypeOf((*MockBlockService_GetBlocksClient)(nil).Header)) +} + +// Recv mocks base method. +func (m *MockBlockService_GetBlocksClient) Recv() (*Block, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Recv") + ret0, _ := ret[0].(*Block) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Recv indicates an expected call of Recv. +func (mr *MockBlockService_GetBlocksClientMockRecorder) Recv() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockBlockService_GetBlocksClient)(nil).Recv)) +} + +// RecvMsg mocks base method. +func (m *MockBlockService_GetBlocksClient) RecvMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RecvMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockBlockService_GetBlocksClientMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockBlockService_GetBlocksClient)(nil).RecvMsg), arg0) +} + +// SendMsg mocks base method. +func (m *MockBlockService_GetBlocksClient) SendMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockBlockService_GetBlocksClientMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockBlockService_GetBlocksClient)(nil).SendMsg), arg0) +} + +// Trailer mocks base method. +func (m *MockBlockService_GetBlocksClient) Trailer() metadata.MD { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Trailer") + ret0, _ := ret[0].(metadata.MD) + return ret0 +} + +// Trailer indicates an expected call of Trailer. +func (mr *MockBlockService_GetBlocksClientMockRecorder) Trailer() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Trailer", reflect.TypeOf((*MockBlockService_GetBlocksClient)(nil).Trailer)) +} + +// MockBlockService_GetBlocksServer is a mock of BlockService_GetBlocksServer interface. +type MockBlockService_GetBlocksServer struct { + ctrl *gomock.Controller + recorder *MockBlockService_GetBlocksServerMockRecorder +} + +// MockBlockService_GetBlocksServerMockRecorder is the mock recorder for MockBlockService_GetBlocksServer. +type MockBlockService_GetBlocksServerMockRecorder struct { + mock *MockBlockService_GetBlocksServer +} + +// NewMockBlockService_GetBlocksServer creates a new mock instance. +func NewMockBlockService_GetBlocksServer(ctrl *gomock.Controller) *MockBlockService_GetBlocksServer { + mock := &MockBlockService_GetBlocksServer{ctrl: ctrl} + mock.recorder = &MockBlockService_GetBlocksServerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBlockService_GetBlocksServer) EXPECT() *MockBlockService_GetBlocksServerMockRecorder { + return m.recorder +} + +// Context mocks base method. +func (m *MockBlockService_GetBlocksServer) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockBlockService_GetBlocksServerMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockBlockService_GetBlocksServer)(nil).Context)) +} + +// RecvMsg mocks base method. +func (m *MockBlockService_GetBlocksServer) RecvMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RecvMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockBlockService_GetBlocksServerMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockBlockService_GetBlocksServer)(nil).RecvMsg), arg0) +} + +// Send mocks base method. +func (m *MockBlockService_GetBlocksServer) Send(arg0 *Block) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Send", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Send indicates an expected call of Send. +func (mr *MockBlockService_GetBlocksServerMockRecorder) Send(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockBlockService_GetBlocksServer)(nil).Send), arg0) +} + +// SendHeader mocks base method. +func (m *MockBlockService_GetBlocksServer) SendHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendHeader indicates an expected call of SendHeader. +func (mr *MockBlockService_GetBlocksServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockBlockService_GetBlocksServer)(nil).SendHeader), arg0) +} + +// SendMsg mocks base method. +func (m *MockBlockService_GetBlocksServer) SendMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockBlockService_GetBlocksServerMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockBlockService_GetBlocksServer)(nil).SendMsg), arg0) +} + +// SetHeader mocks base method. +func (m *MockBlockService_GetBlocksServer) SetHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetHeader indicates an expected call of SetHeader. +func (mr *MockBlockService_GetBlocksServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockBlockService_GetBlocksServer)(nil).SetHeader), arg0) +} + +// SetTrailer mocks base method. +func (m *MockBlockService_GetBlocksServer) SetTrailer(arg0 metadata.MD) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTrailer", arg0) +} + +// SetTrailer indicates an expected call of SetTrailer. +func (mr *MockBlockService_GetBlocksServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockBlockService_GetBlocksServer)(nil).SetTrailer), arg0) +} + +// MockBlockServiceClient is a mock of BlockServiceClient interface. +type MockBlockServiceClient struct { + ctrl *gomock.Controller + recorder *MockBlockServiceClientMockRecorder +} + +// MockBlockServiceClientMockRecorder is the mock recorder for MockBlockServiceClient. +type MockBlockServiceClientMockRecorder struct { + mock *MockBlockServiceClient +} + +// NewMockBlockServiceClient creates a new mock instance. +func NewMockBlockServiceClient(ctrl *gomock.Controller) *MockBlockServiceClient { + mock := &MockBlockServiceClient{ctrl: ctrl} + mock.recorder = &MockBlockServiceClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBlockServiceClient) EXPECT() *MockBlockServiceClientMockRecorder { + return m.recorder +} + +// GetBlock mocks base method. +func (m *MockBlockServiceClient) GetBlock(ctx context.Context, in *GetBlockRequest, opts ...grpc.CallOption) (*Block, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, in} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetBlock", varargs...) + ret0, _ := ret[0].(*Block) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetBlock indicates an expected call of GetBlock. +func (mr *MockBlockServiceClientMockRecorder) GetBlock(ctx, in interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, in}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlock", reflect.TypeOf((*MockBlockServiceClient)(nil).GetBlock), varargs...) +} + +// GetBlocks mocks base method. +func (m *MockBlockServiceClient) GetBlocks(ctx context.Context, in *GetBlocksRequest, opts ...grpc.CallOption) (BlockService_GetBlocksClient, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, in} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetBlocks", varargs...) + ret0, _ := ret[0].(BlockService_GetBlocksClient) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetBlocks indicates an expected call of GetBlocks. +func (mr *MockBlockServiceClientMockRecorder) GetBlocks(ctx, in interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, in}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlocks", reflect.TypeOf((*MockBlockServiceClient)(nil).GetBlocks), varargs...) +} + +// MockBlockServiceServer is a mock of BlockServiceServer interface. +type MockBlockServiceServer struct { + ctrl *gomock.Controller + recorder *MockBlockServiceServerMockRecorder +} + +// MockBlockServiceServerMockRecorder is the mock recorder for MockBlockServiceServer. +type MockBlockServiceServerMockRecorder struct { + mock *MockBlockServiceServer +} + +// NewMockBlockServiceServer creates a new mock instance. +func NewMockBlockServiceServer(ctrl *gomock.Controller) *MockBlockServiceServer { + mock := &MockBlockServiceServer{ctrl: ctrl} + mock.recorder = &MockBlockServiceServerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBlockServiceServer) EXPECT() *MockBlockServiceServerMockRecorder { + return m.recorder +} + +// GetBlock mocks base method. +func (m *MockBlockServiceServer) GetBlock(ctx context.Context, in *GetBlockRequest) (*Block, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBlock", ctx, in) + ret0, _ := ret[0].(*Block) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetBlock indicates an expected call of GetBlock. +func (mr *MockBlockServiceServerMockRecorder) GetBlock(ctx, in interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlock", reflect.TypeOf((*MockBlockServiceServer)(nil).GetBlock), ctx, in) +} + +// GetBlocks mocks base method. +func (m *MockBlockServiceServer) GetBlocks(blob *GetBlocksRequest, server BlockService_GetBlocksServer) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBlocks", blob, server) + ret0, _ := ret[0].(error) + return ret0 +} + +// GetBlocks indicates an expected call of GetBlocks. +func (mr *MockBlockServiceServerMockRecorder) GetBlocks(blob, server interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlocks", reflect.TypeOf((*MockBlockServiceServer)(nil).GetBlocks), blob, server) +} diff --git a/entity/domain/transaction/model/transaction.pb.go b/entity/domain/transaction/model/transaction.pb.go new file mode 100644 index 0000000..12f21d2 --- /dev/null +++ b/entity/domain/transaction/model/transaction.pb.go @@ -0,0 +1,447 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc v4.25.3 +// source: entity/domain/transaction/model/transaction.proto + +package model + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Represents a transaction on the blockchain. +type Transaction struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Unique identifier of the transaction. + Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // Identifier of the block that includes this transaction. + BlockId []byte `protobuf:"bytes,2,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` + // Address of the sender. + From []byte `protobuf:"bytes,3,opt,name=from,proto3" json:"from,omitempty"` + // Address of the recipient. + To []byte `protobuf:"bytes,4,opt,name=to,proto3" json:"to,omitempty"` + // Amount of currency transferred in the transaction. + Amount float64 `protobuf:"fixed64,5,opt,name=amount,proto3" json:"amount,omitempty"` + // Timestamp of when the transaction was created. + Timestamp *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (x *Transaction) Reset() { + *x = Transaction{} + if protoimpl.UnsafeEnabled { + mi := &file_entity_domain_transaction_model_transaction_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Transaction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Transaction) ProtoMessage() {} + +func (x *Transaction) ProtoReflect() protoreflect.Message { + mi := &file_entity_domain_transaction_model_transaction_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Transaction.ProtoReflect.Descriptor instead. +func (*Transaction) Descriptor() ([]byte, []int) { + return file_entity_domain_transaction_model_transaction_proto_rawDescGZIP(), []int{0} +} + +func (x *Transaction) GetId() []byte { + if x != nil { + return x.Id + } + return nil +} + +func (x *Transaction) GetBlockId() []byte { + if x != nil { + return x.BlockId + } + return nil +} + +func (x *Transaction) GetFrom() []byte { + if x != nil { + return x.From + } + return nil +} + +func (x *Transaction) GetTo() []byte { + if x != nil { + return x.To + } + return nil +} + +func (x *Transaction) GetAmount() float64 { + if x != nil { + return x.Amount + } + return 0 +} + +func (x *Transaction) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +// Request message for retrieving a single transaction by its ID. +type GetTransactionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Unique identifier of the transaction to retrieve. + Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetTransactionRequest) Reset() { + *x = GetTransactionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_entity_domain_transaction_model_transaction_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetTransactionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTransactionRequest) ProtoMessage() {} + +func (x *GetTransactionRequest) ProtoReflect() protoreflect.Message { + mi := &file_entity_domain_transaction_model_transaction_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTransactionRequest.ProtoReflect.Descriptor instead. +func (*GetTransactionRequest) Descriptor() ([]byte, []int) { + return file_entity_domain_transaction_model_transaction_proto_rawDescGZIP(), []int{1} +} + +func (x *GetTransactionRequest) GetId() []byte { + if x != nil { + return x.Id + } + return nil +} + +// Request message for retrieving all transactions within a specific block. +type GetTransactionsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Identifier of the block to retrieve transactions from. + BlockId []byte `protobuf:"bytes,1,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"` +} + +func (x *GetTransactionsRequest) Reset() { + *x = GetTransactionsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_entity_domain_transaction_model_transaction_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetTransactionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTransactionsRequest) ProtoMessage() {} + +func (x *GetTransactionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_entity_domain_transaction_model_transaction_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTransactionsRequest.ProtoReflect.Descriptor instead. +func (*GetTransactionsRequest) Descriptor() ([]byte, []int) { + return file_entity_domain_transaction_model_transaction_proto_rawDescGZIP(), []int{2} +} + +func (x *GetTransactionsRequest) GetBlockId() []byte { + if x != nil { + return x.BlockId + } + return nil +} + +// Request message for creating a new transaction. +type CreateTransactionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Address of the sender. + From []byte `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` + // Address of the recipient. + To []byte `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` + // Amount of currency to transfer in the transaction. + Amount float64 `protobuf:"fixed64,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *CreateTransactionRequest) Reset() { + *x = CreateTransactionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_entity_domain_transaction_model_transaction_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateTransactionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTransactionRequest) ProtoMessage() {} + +func (x *CreateTransactionRequest) ProtoReflect() protoreflect.Message { + mi := &file_entity_domain_transaction_model_transaction_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateTransactionRequest.ProtoReflect.Descriptor instead. +func (*CreateTransactionRequest) Descriptor() ([]byte, []int) { + return file_entity_domain_transaction_model_transaction_proto_rawDescGZIP(), []int{3} +} + +func (x *CreateTransactionRequest) GetFrom() []byte { + if x != nil { + return x.From + } + return nil +} + +func (x *CreateTransactionRequest) GetTo() []byte { + if x != nil { + return x.To + } + return nil +} + +func (x *CreateTransactionRequest) GetAmount() float64 { + if x != nil { + return x.Amount + } + return 0 +} + +var File_entity_domain_transaction_model_transaction_proto protoreflect.FileDescriptor + +var file_entity_domain_transaction_model_transaction_proto_rawDesc = []byte{ + 0x0a, 0x31, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x65, + 0x6c, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xae, 0x01, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, + 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, + 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x74, 0x6f, + 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x22, 0x27, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x22, 0x33, 0x0a, 0x16, 0x47, + 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, + 0x22, 0x56, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, + 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x74, 0x6f, + 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0x94, 0x02, 0x0a, 0x12, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x50, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x22, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, + 0x00, 0x12, 0x54, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x23, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x30, 0x01, 0x12, 0x56, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x42, + 0x3e, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6c, + 0x61, 0x63, 0x6b, 0x68, 0x6f, 0x72, 0x73, 0x65, 0x79, 0x61, 0x2f, 0x72, 0x79, 0x7a, 0x65, 0x2f, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_entity_domain_transaction_model_transaction_proto_rawDescOnce sync.Once + file_entity_domain_transaction_model_transaction_proto_rawDescData = file_entity_domain_transaction_model_transaction_proto_rawDesc +) + +func file_entity_domain_transaction_model_transaction_proto_rawDescGZIP() []byte { + file_entity_domain_transaction_model_transaction_proto_rawDescOnce.Do(func() { + file_entity_domain_transaction_model_transaction_proto_rawDescData = protoimpl.X.CompressGZIP(file_entity_domain_transaction_model_transaction_proto_rawDescData) + }) + return file_entity_domain_transaction_model_transaction_proto_rawDescData +} + +var file_entity_domain_transaction_model_transaction_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_entity_domain_transaction_model_transaction_proto_goTypes = []any{ + (*Transaction)(nil), // 0: transaction.Transaction + (*GetTransactionRequest)(nil), // 1: transaction.GetTransactionRequest + (*GetTransactionsRequest)(nil), // 2: transaction.GetTransactionsRequest + (*CreateTransactionRequest)(nil), // 3: transaction.CreateTransactionRequest + (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp +} +var file_entity_domain_transaction_model_transaction_proto_depIdxs = []int32{ + 4, // 0: transaction.Transaction.timestamp:type_name -> google.protobuf.Timestamp + 1, // 1: transaction.TransactionService.GetTransaction:input_type -> transaction.GetTransactionRequest + 2, // 2: transaction.TransactionService.GetTransactions:input_type -> transaction.GetTransactionsRequest + 3, // 3: transaction.TransactionService.CreateTransaction:input_type -> transaction.CreateTransactionRequest + 0, // 4: transaction.TransactionService.GetTransaction:output_type -> transaction.Transaction + 0, // 5: transaction.TransactionService.GetTransactions:output_type -> transaction.Transaction + 0, // 6: transaction.TransactionService.CreateTransaction:output_type -> transaction.Transaction + 4, // [4:7] is the sub-list for method output_type + 1, // [1:4] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_entity_domain_transaction_model_transaction_proto_init() } +func file_entity_domain_transaction_model_transaction_proto_init() { + if File_entity_domain_transaction_model_transaction_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_entity_domain_transaction_model_transaction_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Transaction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entity_domain_transaction_model_transaction_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*GetTransactionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entity_domain_transaction_model_transaction_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*GetTransactionsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entity_domain_transaction_model_transaction_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*CreateTransactionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_entity_domain_transaction_model_transaction_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_entity_domain_transaction_model_transaction_proto_goTypes, + DependencyIndexes: file_entity_domain_transaction_model_transaction_proto_depIdxs, + MessageInfos: file_entity_domain_transaction_model_transaction_proto_msgTypes, + }.Build() + File_entity_domain_transaction_model_transaction_proto = out.File + file_entity_domain_transaction_model_transaction_proto_rawDesc = nil + file_entity_domain_transaction_model_transaction_proto_goTypes = nil + file_entity_domain_transaction_model_transaction_proto_depIdxs = nil +} diff --git a/entity/domain/transaction/model/transaction_grpc.pb.go b/entity/domain/transaction/model/transaction_grpc.pb.go new file mode 100644 index 0000000..39d77f2 --- /dev/null +++ b/entity/domain/transaction/model/transaction_grpc.pb.go @@ -0,0 +1,215 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.25.3 +// source: entity/domain/transaction/model/transaction.proto + +package model + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + TransactionService_GetTransaction_FullMethodName = "/transaction.TransactionService/GetTransaction" + TransactionService_GetTransactions_FullMethodName = "/transaction.TransactionService/GetTransactions" + TransactionService_CreateTransaction_FullMethodName = "/transaction.TransactionService/CreateTransaction" +) + +// TransactionServiceClient is the client API for TransactionService 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 TransactionServiceClient interface { + // Retrieves a single transaction by its ID. + GetTransaction(ctx context.Context, in *GetTransactionRequest, opts ...grpc.CallOption) (*Transaction, error) + // Retrieves all transactions within a specific block. + GetTransactions(ctx context.Context, in *GetTransactionsRequest, opts ...grpc.CallOption) (TransactionService_GetTransactionsClient, error) + // Creates a new transaction and returns the created transaction. + CreateTransaction(ctx context.Context, in *CreateTransactionRequest, opts ...grpc.CallOption) (*Transaction, error) +} + +type transactionServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewTransactionServiceClient(cc grpc.ClientConnInterface) TransactionServiceClient { + return &transactionServiceClient{cc} +} + +func (c *transactionServiceClient) GetTransaction(ctx context.Context, in *GetTransactionRequest, opts ...grpc.CallOption) (*Transaction, error) { + out := new(Transaction) + err := c.cc.Invoke(ctx, TransactionService_GetTransaction_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *transactionServiceClient) GetTransactions(ctx context.Context, in *GetTransactionsRequest, opts ...grpc.CallOption) (TransactionService_GetTransactionsClient, error) { + stream, err := c.cc.NewStream(ctx, &TransactionService_ServiceDesc.Streams[0], TransactionService_GetTransactions_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &transactionServiceGetTransactionsClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type TransactionService_GetTransactionsClient interface { + Recv() (*Transaction, error) + grpc.ClientStream +} + +type transactionServiceGetTransactionsClient struct { + grpc.ClientStream +} + +func (x *transactionServiceGetTransactionsClient) Recv() (*Transaction, error) { + m := new(Transaction) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *transactionServiceClient) CreateTransaction(ctx context.Context, in *CreateTransactionRequest, opts ...grpc.CallOption) (*Transaction, error) { + out := new(Transaction) + err := c.cc.Invoke(ctx, TransactionService_CreateTransaction_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// TransactionServiceServer is the server API for TransactionService service. +// All implementations should embed UnimplementedTransactionServiceServer +// for forward compatibility +type TransactionServiceServer interface { + // Retrieves a single transaction by its ID. + GetTransaction(context.Context, *GetTransactionRequest) (*Transaction, error) + // Retrieves all transactions within a specific block. + GetTransactions(*GetTransactionsRequest, TransactionService_GetTransactionsServer) error + // Creates a new transaction and returns the created transaction. + CreateTransaction(context.Context, *CreateTransactionRequest) (*Transaction, error) +} + +// UnimplementedTransactionServiceServer should be embedded to have forward compatible implementations. +type UnimplementedTransactionServiceServer struct { +} + +func (UnimplementedTransactionServiceServer) GetTransaction(context.Context, *GetTransactionRequest) (*Transaction, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTransaction not implemented") +} +func (UnimplementedTransactionServiceServer) GetTransactions(*GetTransactionsRequest, TransactionService_GetTransactionsServer) error { + return status.Errorf(codes.Unimplemented, "method GetTransactions not implemented") +} +func (UnimplementedTransactionServiceServer) CreateTransaction(context.Context, *CreateTransactionRequest) (*Transaction, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateTransaction not implemented") +} + +// UnsafeTransactionServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to TransactionServiceServer will +// result in compilation errors. +type UnsafeTransactionServiceServer interface { + mustEmbedUnimplementedTransactionServiceServer() +} + +func RegisterTransactionServiceServer(s grpc.ServiceRegistrar, srv TransactionServiceServer) { + s.RegisterService(&TransactionService_ServiceDesc, srv) +} + +func _TransactionService_GetTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TransactionServiceServer).GetTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TransactionService_GetTransaction_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TransactionServiceServer).GetTransaction(ctx, req.(*GetTransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TransactionService_GetTransactions_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetTransactionsRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(TransactionServiceServer).GetTransactions(m, &transactionServiceGetTransactionsServer{stream}) +} + +type TransactionService_GetTransactionsServer interface { + Send(*Transaction) error + grpc.ServerStream +} + +type transactionServiceGetTransactionsServer struct { + grpc.ServerStream +} + +func (x *transactionServiceGetTransactionsServer) Send(m *Transaction) error { + return x.ServerStream.SendMsg(m) +} + +func _TransactionService_CreateTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateTransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TransactionServiceServer).CreateTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TransactionService_CreateTransaction_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TransactionServiceServer).CreateTransaction(ctx, req.(*CreateTransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// TransactionService_ServiceDesc is the grpc.ServiceDesc for TransactionService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var TransactionService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "transaction.TransactionService", + HandlerType: (*TransactionServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetTransaction", + Handler: _TransactionService_GetTransaction_Handler, + }, + { + MethodName: "CreateTransaction", + Handler: _TransactionService_CreateTransaction_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "GetTransactions", + Handler: _TransactionService_GetTransactions_Handler, + ServerStreams: true, + }, + }, + Metadata: "entity/domain/transaction/model/transaction.proto", +} diff --git a/entity/domain/transaction/model/transaction_grpc_mock.pb.go b/entity/domain/transaction/model/transaction_grpc_mock.pb.go new file mode 100644 index 0000000..3bd4e88 --- /dev/null +++ b/entity/domain/transaction/model/transaction_grpc_mock.pb.go @@ -0,0 +1,405 @@ +// Code generated by protoc-gen-go-grpc-mock. DO NOT EDIT. +// source: entity/domain/transaction/model/transaction.proto + +package model + +import ( + context "context" + reflect "reflect" + + gomock "go.uber.org/mock/gomock" + grpc "google.golang.org/grpc" + metadata "google.golang.org/grpc/metadata" +) + +// MockTransactionService_GetTransactionsClient is a mock of TransactionService_GetTransactionsClient interface. +type MockTransactionService_GetTransactionsClient struct { + ctrl *gomock.Controller + recorder *MockTransactionService_GetTransactionsClientMockRecorder +} + +// MockTransactionService_GetTransactionsClientMockRecorder is the mock recorder for MockTransactionService_GetTransactionsClient. +type MockTransactionService_GetTransactionsClientMockRecorder struct { + mock *MockTransactionService_GetTransactionsClient +} + +// NewMockTransactionService_GetTransactionsClient creates a new mock instance. +func NewMockTransactionService_GetTransactionsClient(ctrl *gomock.Controller) *MockTransactionService_GetTransactionsClient { + mock := &MockTransactionService_GetTransactionsClient{ctrl: ctrl} + mock.recorder = &MockTransactionService_GetTransactionsClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTransactionService_GetTransactionsClient) EXPECT() *MockTransactionService_GetTransactionsClientMockRecorder { + return m.recorder +} + +// CloseSend mocks base method. +func (m *MockTransactionService_GetTransactionsClient) CloseSend() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CloseSend") + ret0, _ := ret[0].(error) + return ret0 +} + +// CloseSend indicates an expected call of CloseSend. +func (mr *MockTransactionService_GetTransactionsClientMockRecorder) CloseSend() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseSend", reflect.TypeOf((*MockTransactionService_GetTransactionsClient)(nil).CloseSend)) +} + +// Context mocks base method. +func (m *MockTransactionService_GetTransactionsClient) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockTransactionService_GetTransactionsClientMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockTransactionService_GetTransactionsClient)(nil).Context)) +} + +// Header mocks base method. +func (m *MockTransactionService_GetTransactionsClient) Header() (metadata.MD, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Header") + ret0, _ := ret[0].(metadata.MD) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Header indicates an expected call of Header. +func (mr *MockTransactionService_GetTransactionsClientMockRecorder) Header() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Header", reflect.TypeOf((*MockTransactionService_GetTransactionsClient)(nil).Header)) +} + +// Recv mocks base method. +func (m *MockTransactionService_GetTransactionsClient) Recv() (*Transaction, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Recv") + ret0, _ := ret[0].(*Transaction) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Recv indicates an expected call of Recv. +func (mr *MockTransactionService_GetTransactionsClientMockRecorder) Recv() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockTransactionService_GetTransactionsClient)(nil).Recv)) +} + +// RecvMsg mocks base method. +func (m *MockTransactionService_GetTransactionsClient) RecvMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RecvMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockTransactionService_GetTransactionsClientMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockTransactionService_GetTransactionsClient)(nil).RecvMsg), arg0) +} + +// SendMsg mocks base method. +func (m *MockTransactionService_GetTransactionsClient) SendMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockTransactionService_GetTransactionsClientMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockTransactionService_GetTransactionsClient)(nil).SendMsg), arg0) +} + +// Trailer mocks base method. +func (m *MockTransactionService_GetTransactionsClient) Trailer() metadata.MD { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Trailer") + ret0, _ := ret[0].(metadata.MD) + return ret0 +} + +// Trailer indicates an expected call of Trailer. +func (mr *MockTransactionService_GetTransactionsClientMockRecorder) Trailer() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Trailer", reflect.TypeOf((*MockTransactionService_GetTransactionsClient)(nil).Trailer)) +} + +// MockTransactionService_GetTransactionsServer is a mock of TransactionService_GetTransactionsServer interface. +type MockTransactionService_GetTransactionsServer struct { + ctrl *gomock.Controller + recorder *MockTransactionService_GetTransactionsServerMockRecorder +} + +// MockTransactionService_GetTransactionsServerMockRecorder is the mock recorder for MockTransactionService_GetTransactionsServer. +type MockTransactionService_GetTransactionsServerMockRecorder struct { + mock *MockTransactionService_GetTransactionsServer +} + +// NewMockTransactionService_GetTransactionsServer creates a new mock instance. +func NewMockTransactionService_GetTransactionsServer(ctrl *gomock.Controller) *MockTransactionService_GetTransactionsServer { + mock := &MockTransactionService_GetTransactionsServer{ctrl: ctrl} + mock.recorder = &MockTransactionService_GetTransactionsServerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTransactionService_GetTransactionsServer) EXPECT() *MockTransactionService_GetTransactionsServerMockRecorder { + return m.recorder +} + +// Context mocks base method. +func (m *MockTransactionService_GetTransactionsServer) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockTransactionService_GetTransactionsServerMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockTransactionService_GetTransactionsServer)(nil).Context)) +} + +// RecvMsg mocks base method. +func (m *MockTransactionService_GetTransactionsServer) RecvMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RecvMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockTransactionService_GetTransactionsServerMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockTransactionService_GetTransactionsServer)(nil).RecvMsg), arg0) +} + +// Send mocks base method. +func (m *MockTransactionService_GetTransactionsServer) Send(arg0 *Transaction) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Send", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Send indicates an expected call of Send. +func (mr *MockTransactionService_GetTransactionsServerMockRecorder) Send(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockTransactionService_GetTransactionsServer)(nil).Send), arg0) +} + +// SendHeader mocks base method. +func (m *MockTransactionService_GetTransactionsServer) SendHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendHeader indicates an expected call of SendHeader. +func (mr *MockTransactionService_GetTransactionsServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockTransactionService_GetTransactionsServer)(nil).SendHeader), arg0) +} + +// SendMsg mocks base method. +func (m *MockTransactionService_GetTransactionsServer) SendMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockTransactionService_GetTransactionsServerMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockTransactionService_GetTransactionsServer)(nil).SendMsg), arg0) +} + +// SetHeader mocks base method. +func (m *MockTransactionService_GetTransactionsServer) SetHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetHeader indicates an expected call of SetHeader. +func (mr *MockTransactionService_GetTransactionsServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockTransactionService_GetTransactionsServer)(nil).SetHeader), arg0) +} + +// SetTrailer mocks base method. +func (m *MockTransactionService_GetTransactionsServer) SetTrailer(arg0 metadata.MD) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTrailer", arg0) +} + +// SetTrailer indicates an expected call of SetTrailer. +func (mr *MockTransactionService_GetTransactionsServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockTransactionService_GetTransactionsServer)(nil).SetTrailer), arg0) +} + +// MockTransactionServiceClient is a mock of TransactionServiceClient interface. +type MockTransactionServiceClient struct { + ctrl *gomock.Controller + recorder *MockTransactionServiceClientMockRecorder +} + +// MockTransactionServiceClientMockRecorder is the mock recorder for MockTransactionServiceClient. +type MockTransactionServiceClientMockRecorder struct { + mock *MockTransactionServiceClient +} + +// NewMockTransactionServiceClient creates a new mock instance. +func NewMockTransactionServiceClient(ctrl *gomock.Controller) *MockTransactionServiceClient { + mock := &MockTransactionServiceClient{ctrl: ctrl} + mock.recorder = &MockTransactionServiceClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTransactionServiceClient) EXPECT() *MockTransactionServiceClientMockRecorder { + return m.recorder +} + +// CreateTransaction mocks base method. +func (m *MockTransactionServiceClient) CreateTransaction(ctx context.Context, in *CreateTransactionRequest, opts ...grpc.CallOption) (*Transaction, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, in} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateTransaction", varargs...) + ret0, _ := ret[0].(*Transaction) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateTransaction indicates an expected call of CreateTransaction. +func (mr *MockTransactionServiceClientMockRecorder) CreateTransaction(ctx, in interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, in}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTransaction", reflect.TypeOf((*MockTransactionServiceClient)(nil).CreateTransaction), varargs...) +} + +// GetTransaction mocks base method. +func (m *MockTransactionServiceClient) GetTransaction(ctx context.Context, in *GetTransactionRequest, opts ...grpc.CallOption) (*Transaction, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, in} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetTransaction", varargs...) + ret0, _ := ret[0].(*Transaction) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTransaction indicates an expected call of GetTransaction. +func (mr *MockTransactionServiceClientMockRecorder) GetTransaction(ctx, in interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, in}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransaction", reflect.TypeOf((*MockTransactionServiceClient)(nil).GetTransaction), varargs...) +} + +// GetTransactions mocks base method. +func (m *MockTransactionServiceClient) GetTransactions(ctx context.Context, in *GetTransactionsRequest, opts ...grpc.CallOption) (TransactionService_GetTransactionsClient, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, in} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetTransactions", varargs...) + ret0, _ := ret[0].(TransactionService_GetTransactionsClient) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTransactions indicates an expected call of GetTransactions. +func (mr *MockTransactionServiceClientMockRecorder) GetTransactions(ctx, in interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, in}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactions", reflect.TypeOf((*MockTransactionServiceClient)(nil).GetTransactions), varargs...) +} + +// MockTransactionServiceServer is a mock of TransactionServiceServer interface. +type MockTransactionServiceServer struct { + ctrl *gomock.Controller + recorder *MockTransactionServiceServerMockRecorder +} + +// MockTransactionServiceServerMockRecorder is the mock recorder for MockTransactionServiceServer. +type MockTransactionServiceServerMockRecorder struct { + mock *MockTransactionServiceServer +} + +// NewMockTransactionServiceServer creates a new mock instance. +func NewMockTransactionServiceServer(ctrl *gomock.Controller) *MockTransactionServiceServer { + mock := &MockTransactionServiceServer{ctrl: ctrl} + mock.recorder = &MockTransactionServiceServerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTransactionServiceServer) EXPECT() *MockTransactionServiceServerMockRecorder { + return m.recorder +} + +// CreateTransaction mocks base method. +func (m *MockTransactionServiceServer) CreateTransaction(ctx context.Context, in *CreateTransactionRequest) (*Transaction, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateTransaction", ctx, in) + ret0, _ := ret[0].(*Transaction) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateTransaction indicates an expected call of CreateTransaction. +func (mr *MockTransactionServiceServerMockRecorder) CreateTransaction(ctx, in interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTransaction", reflect.TypeOf((*MockTransactionServiceServer)(nil).CreateTransaction), ctx, in) +} + +// GetTransaction mocks base method. +func (m *MockTransactionServiceServer) GetTransaction(ctx context.Context, in *GetTransactionRequest) (*Transaction, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTransaction", ctx, in) + ret0, _ := ret[0].(*Transaction) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTransaction indicates an expected call of GetTransaction. +func (mr *MockTransactionServiceServerMockRecorder) GetTransaction(ctx, in interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransaction", reflect.TypeOf((*MockTransactionServiceServer)(nil).GetTransaction), ctx, in) +} + +// GetTransactions mocks base method. +func (m *MockTransactionServiceServer) GetTransactions(blob *GetTransactionsRequest, server TransactionService_GetTransactionsServer) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTransactions", blob, server) + ret0, _ := ret[0].(error) + return ret0 +} + +// GetTransactions indicates an expected call of GetTransactions. +func (mr *MockTransactionServiceServerMockRecorder) GetTransactions(blob, server interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactions", reflect.TypeOf((*MockTransactionServiceServer)(nil).GetTransactions), blob, server) +} diff --git a/go.mod b/go.mod index e5397d4..5e36acc 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,14 @@ go 1.22.1 require ( github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 + go.uber.org/mock v0.4.0 + google.golang.org/grpc v1.62.1 + google.golang.org/protobuf v1.33.0 ) require ( github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -24,8 +28,10 @@ require ( go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index aba9163..3b06d67 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,12 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -59,14 +63,27 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c h1:lfpJ/2rWPa/kJgxyyXM8PrNnfCzcmxJ265mADgwmvLI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= +google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 79e9ad985615535bf1f195fab49e9479d3c86d8f Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Fri, 26 Jul 2024 11:27:42 +0800 Subject: [PATCH 4/6] feat: generate more test cases and protobufs efficiently - Increase the test count from `11` to `21` - Add a process for generating protobufs - Add a step for injecting tags in protobuf files Signed-off-by: Sean Zheng --- Makefile | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 8cf3b28..8b69890 100644 --- a/Makefile +++ b/Makefile @@ -47,11 +47,21 @@ test: ## test go binary .PHONY: gen-pb gen-pb: ## generate protobuf - protoc --proto_path=./pb \ - --go_out=paths=source_relative:./ \ - --go-grpc_out=paths=source_relative,require_unimplemented_servers=false:./ \ - --go-grpc-mock_out=paths=source_relative,require_unimplemented_servers=false:./ \ - ./pb/entity/domain/*/*/*.proto + @echo Starting generate pb + @find ./pb -name '*.proto' | while read -r proto_file; do \ + protoc --proto_path=./pb \ + --go_out=paths=source_relative:./ \ + --go-grpc_out=paths=source_relative,require_unimplemented_servers=false:./ \ + --go-grpc-mock_out=paths=source_relative,require_unimplemented_servers=false:./ \ + $$proto_file; \ + done + @echo Successfully generated proto + + @echo Starting inject tags + @find ./pb -name '*.pb.go' | while read -r pb_file; do \ + protoc-go-inject-tag -input=$$pb_file; \ + done + @echo Successfully injected tags .PHONY: gen-swagger gen-swagger: ## generate swagger From 16946fdf1e03927198272219f640387ab3a82914 Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Fri, 26 Jul 2024 11:29:46 +0800 Subject: [PATCH 5/6] chore: refactor GitHub actions workflow configuration - Remove setup-bazelisk and cache-bazel steps - Remove coverage step - Update go-version to '^1.20' Signed-off-by: Sean Zheng --- .github/workflows/go.yaml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index e64465d..25aeade 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -25,24 +25,12 @@ jobs: go-version: '^1.20' cache: true - - uses: bazelbuild/setup-bazelisk@v2 - - - name: Mount bazel cache - id: cache-bazel - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel - - name: Build run: make build - name: Test run: make test - - name: coverage - run: make coverage - - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: From 4994713c57d308769e5adc09f7766606c78e7b73 Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Fri, 26 Jul 2024 11:33:41 +0800 Subject: [PATCH 6/6] ci: optimize GitHub workflow for Go project - Remove SonarCloud Scan step from the GitHub workflow for Go Signed-off-by: Sean Zheng --- .github/workflows/go.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index 25aeade..574f4a8 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -30,9 +30,3 @@ jobs: - name: Test run: make test - - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}