diff --git a/api/client/GetAccountBalances/client.go b/api/client/GetAccountBalances/client.go new file mode 100644 index 000000000..b183a5d66 --- /dev/null +++ b/api/client/GetAccountBalances/client.go @@ -0,0 +1,48 @@ +package main + +import ( + "context" + "fmt" + + log "github.com/sirupsen/logrus" + "github.com/spf13/viper" + rpc_model "github.com/zoobc/zoobc-core/common/model" + rpc_service "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 { + log.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 := rpc_service.NewAccountBalanceServiceClient(conn) + + response, err := c.GetAccountBalances(context.Background(), &rpc_model.GetAccountBalancesRequest{ + AccountAddresses: []string{ + "OnEYzI-EMV6UTfoUEzpQUjkSlnqB82-SyRN7469lJTWH", + "BCZEGOb3WNx3fDOVf9ZS4EjvOIv_UeW4TVBQJ_6tHKlE", + "iSJt3H8wFOzlWKsy_UoEWF_OjF6oymHMqthyUMDKSyxb", + }, + }) + + if err != nil { + log.Fatalf("error calling rpc_service.GetAccountBalance: %s", err) + } + + log.Printf("response from remote rpc_service.GetBlockByID(): %s", response) + +} diff --git a/api/handler/accountBalanceHandler.go b/api/handler/accountBalanceHandler.go index ca781834a..9fe4b6514 100644 --- a/api/handler/accountBalanceHandler.go +++ b/api/handler/accountBalanceHandler.go @@ -5,11 +5,15 @@ import ( "github.com/zoobc/zoobc-core/api/service" "github.com/zoobc/zoobc-core/common/model" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) -type AccountBalanceHandler struct { - Service service.AccountBalanceServiceInterface -} +type ( + AccountBalanceHandler struct { + Service service.AccountBalanceServiceInterface + } +) func (abh *AccountBalanceHandler) GetAccountBalance(ctx context.Context, request *model.GetAccountBalanceRequest) (*model.GetAccountBalanceResponse, error) { @@ -22,6 +26,10 @@ func (abh *AccountBalanceHandler) GetAccountBalance(ctx context.Context, func (abh *AccountBalanceHandler) GetAccountBalances(ctx context.Context, request *model.GetAccountBalancesRequest) (*model.GetAccountBalancesResponse, error) { - // todo: implement this after have filter - return nil, nil + + if len(request.AccountAddresses) == 0 { + return nil, status.Error(codes.InvalidArgument, "At least 1 address is required") + } + + return abh.Service.GetAccountBalances(request) } diff --git a/api/service/accountBalanceApiService.go b/api/service/accountBalanceApiService.go index 211056a2f..6ca267407 100644 --- a/api/service/accountBalanceApiService.go +++ b/api/service/accountBalanceApiService.go @@ -12,19 +12,20 @@ import ( type ( AccountBalanceServiceInterface interface { GetAccountBalance(request *model.GetAccountBalanceRequest) (*model.GetAccountBalanceResponse, error) + GetAccountBalances(request *model.GetAccountBalancesRequest) (*model.GetAccountBalancesResponse, error) } AccountBalanceService struct { - AccountBalanceQuery query.AccountBalanceQueryInterface - Executor query.ExecutorInterface + AccountBalanceQuery *query.AccountBalanceQuery + QueryExecutor query.ExecutorInterface } ) func NewAccountBalanceService(executor query.ExecutorInterface, - accountBalanceQuery query.AccountBalanceQueryInterface) *AccountBalanceService { + accountBalanceQuery *query.AccountBalanceQuery) *AccountBalanceService { return &AccountBalanceService{ AccountBalanceQuery: accountBalanceQuery, - Executor: executor, + QueryExecutor: executor, } } @@ -36,7 +37,7 @@ func (abs *AccountBalanceService) GetAccountBalance(request *model.GetAccountBal ) qry, args := abs.AccountBalanceQuery.GetAccountBalanceByAccountAddress(request.AccountAddress) - row, _ = abs.Executor.ExecuteSelectRow(qry, false, args...) + row, _ = abs.QueryExecutor.ExecuteSelectRow(qry, false, args...) err = abs.AccountBalanceQuery.Scan(&accountBalance, row) if err != nil { if err != sql.ErrNoRows { @@ -50,3 +51,37 @@ func (abs *AccountBalanceService) GetAccountBalance(request *model.GetAccountBal AccountBalance: &accountBalance, }, nil } + +func (abs *AccountBalanceService) GetAccountBalances( + request *model.GetAccountBalancesRequest, +) (*model.GetAccountBalancesResponse, error) { + var ( + accountBalances []*model.AccountBalance + caseQ = query.NewCaseQuery() + rows *sql.Rows + err error + ) + + caseQ.Select(abs.AccountBalanceQuery.TableName, abs.AccountBalanceQuery.Fields...) + var accountAddresses []interface{} + for _, v := range request.AccountAddresses { + accountAddresses = append(accountAddresses, v) + } + caseQ.And(caseQ.In("account_address", accountAddresses...)) + + selectQ, args := caseQ.Build() + rows, err = abs.QueryExecutor.ExecuteSelect(selectQ, false, args...) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + defer rows.Close() + + accountBalances, err = abs.AccountBalanceQuery.BuildModel([]*model.AccountBalance{}, rows) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &model.GetAccountBalancesResponse{ + AccountBalances: accountBalances, + }, nil +} diff --git a/api/service/accountBalanceApiService_test.go b/api/service/accountBalanceApiService_test.go index c503d846f..1f15fcc31 100644 --- a/api/service/accountBalanceApiService_test.go +++ b/api/service/accountBalanceApiService_test.go @@ -56,10 +56,41 @@ func (*mockExecutorGetAccountBalanceNotFound) ExecuteSelectRow(qe string, _ bool return row, nil } +func TestNewAccountBalanceService(t *testing.T) { + type args struct { + executor query.ExecutorInterface + accountBalanceQuery *query.AccountBalanceQuery + } + tests := []struct { + name string + args args + want *AccountBalanceService + }{ + { + name: "NewAccountBalanceService:success", + args: args{ + executor: nil, + accountBalanceQuery: nil, + }, + want: &AccountBalanceService{ + AccountBalanceQuery: nil, + QueryExecutor: nil, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := NewAccountBalanceService(tt.args.executor, tt.args.accountBalanceQuery); !reflect.DeepEqual(got, tt.want) { + t.Errorf("NewAccountBalanceService() = %v, want %v", got, tt.want) + } + }) + } +} + func TestAccountBalanceService_GetAccountBalance(t *testing.T) { type fields struct { - AccountBalanceQuery query.AccountBalanceQueryInterface - Executor query.ExecutorInterface + AccountBalanceQuery *query.AccountBalanceQuery + QueryExecutor query.ExecutorInterface } type args struct { request *model.GetAccountBalanceRequest @@ -75,7 +106,7 @@ func TestAccountBalanceService_GetAccountBalance(t *testing.T) { name: "GetAccountBalance:fail", fields: fields{ AccountBalanceQuery: mockAccountBalanceQuery, - Executor: &mockExecutorGetAccountBalanceFail{}, + QueryExecutor: &mockExecutorGetAccountBalanceFail{}, }, args: args{request: &model.GetAccountBalanceRequest{ AccountAddress: "BCZ000000000000", @@ -87,7 +118,7 @@ func TestAccountBalanceService_GetAccountBalance(t *testing.T) { name: "GetAccountBalance:notFound", fields: fields{ AccountBalanceQuery: mockAccountBalanceQuery, - Executor: &mockExecutorGetAccountBalanceNotFound{}, + QueryExecutor: &mockExecutorGetAccountBalanceNotFound{}, }, args: args{request: &model.GetAccountBalanceRequest{ AccountAddress: "BCZ000000000000", @@ -99,7 +130,7 @@ func TestAccountBalanceService_GetAccountBalance(t *testing.T) { name: "GetAccountBalance:success", fields: fields{ AccountBalanceQuery: mockAccountBalanceQuery, - Executor: &mockExecutorGetAccountBalanceSuccess{}, + QueryExecutor: &mockExecutorGetAccountBalanceSuccess{}, }, args: args{request: &model.GetAccountBalanceRequest{ AccountAddress: "BCZ000000000000", @@ -121,46 +152,50 @@ func TestAccountBalanceService_GetAccountBalance(t *testing.T) { t.Run(tt.name, func(t *testing.T) { abs := &AccountBalanceService{ AccountBalanceQuery: tt.fields.AccountBalanceQuery, - Executor: tt.fields.Executor, + QueryExecutor: tt.fields.QueryExecutor, } got, err := abs.GetAccountBalance(tt.args.request) if (err != nil) != tt.wantErr { - t.Errorf("GetAccountBalance() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("AccountBalanceService.GetAccountBalance() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetAccountBalance() got = %v, want %v", got, tt.want) + t.Errorf("AccountBalanceService.GetAccountBalance() = %v, want %v", got, tt.want) } }) } } -func TestNewAccountBalanceService(t *testing.T) { +func TestAccountBalanceService_GetAccountBalances(t *testing.T) { + type fields struct { + AccountBalanceQuery *query.AccountBalanceQuery + QueryExecutor query.ExecutorInterface + } type args struct { - executor query.ExecutorInterface - accountBalanceQuery query.AccountBalanceQueryInterface + request *model.GetAccountBalancesRequest } tests := []struct { - name string - args args - want *AccountBalanceService + name string + fields fields + args args + want *model.GetAccountBalancesResponse + wantErr bool }{ - { - name: "NewAccountBalanceService:success", - args: args{ - executor: nil, - accountBalanceQuery: nil, - }, - want: &AccountBalanceService{ - AccountBalanceQuery: nil, - Executor: nil, - }, - }, + // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := NewAccountBalanceService(tt.args.executor, tt.args.accountBalanceQuery); !reflect.DeepEqual(got, tt.want) { - t.Errorf("NewAccountBalanceService() = %v, want %v", got, tt.want) + abs := &AccountBalanceService{ + AccountBalanceQuery: tt.fields.AccountBalanceQuery, + QueryExecutor: tt.fields.QueryExecutor, + } + got, err := abs.GetAccountBalances(tt.args.request) + if (err != nil) != tt.wantErr { + t.Errorf("AccountBalanceService.GetAccountBalances() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("AccountBalanceService.GetAccountBalances() = %v, want %v", got, tt.want) } }) } diff --git a/common/model/accountBalance.pb.go b/common/model/accountBalance.pb.go index 7367534b3..b23a428c5 100644 --- a/common/model/accountBalance.pb.go +++ b/common/model/accountBalance.pb.go @@ -1,13 +1,161 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: model/accountBalance.proto +/* +Package model is a generated protocol buffer package. + +It is generated from these files: + model/accountBalance.proto + model/accountDataset.proto + model/accountLedger.proto + model/auth.proto + model/batchReceipt.proto + model/blockchain.proto + model/block.proto + model/empty.proto + model/escrow.proto + model/event.proto + model/fileDownload.proto + model/healthCheck.proto + model/host.proto + model/mempool.proto + model/multiSignature.proto + model/nodeHardware.proto + model/node.proto + model/nodeRegistration.proto + model/pagination.proto + model/participationScore.proto + model/peer.proto + model/proofOfOwnership.proto + model/publishedReceipt.proto + model/receipt.proto + model/signature.proto + model/skippedBlocksmith.proto + model/snapshot.proto + model/spineBlockManifest.proto + model/spine.proto + model/transaction.proto + +It has these top-level messages: + AccountBalance + GetAccountBalanceRequest + GetAccountBalanceResponse + GetAccountBalancesRequest + GetAccountBalancesResponse + AccountDataset + GetAccountDatasetsRequest + GetAccountDatasetsResponse + GetAccountDatasetRequest + AccountLedger + GetAccountLedgersRequest + GetAccountLedgersResponse + BatchReceipt + ChainStatus + GetCumulativeDifficultyResponse + GetCumulativeDifficultyRequest + GetCommonMilestoneBlockIdsRequest + GetCommonMilestoneBlockIdsResponse + Block + BlockExtendedInfo + GetBlockRequest + GetBlocksRequest + GetBlocksResponse + GetNextBlockIdsRequest + BlockIdsResponse + GetNextBlocksRequest + BlocksData + SendBlockRequest + SendBlockResponse + Empty + Escrow + GetEscrowTransactionsRequest + GetEscrowTransactionsResponse + GetEscrowTransactionRequest + FileDownloadResponse + FileDownloadRequest + HealthCheckResponse + Host + HostInfo + GetHostPeersResponse + MempoolTransaction + GetMempoolTransactionRequest + GetMempoolTransactionResponse + GetMempoolTransactionsRequest + GetMempoolTransactionsResponse + MultiSignatureInfo + SignatureInfo + PendingSignature + PendingTransaction + GetPendingTransactionsRequest + GetPendingTransactionsResponse + GetPendingTransactionDetailByTransactionHashRequest + GetPendingTransactionDetailByTransactionHashResponse + GetMultisignatureInfoRequest + GetMultisignatureInfoResponse + GetNodeHardwareResponse + GetNodeHardwareRequest + NodeHardware + CPUInformation + HostInformation + MemoryInformation + StorageInformation + Node + NodeKey + GenerateNodeKeyRequest + GenerateNodeKeyResponse + NodeAddress + NodeRegistration + GetNodeRegistrationsRequest + GetNodeRegistrationsResponse + GetNodeRegistrationRequest + GetNodeRegistrationResponse + Pagination + ParticipationScore + Peer + PeerBasicResponse + GetPeerInfoRequest + GetPeerInfoResponse + GetMorePeersResponse + SendPeersRequest + ProofOfOwnership + ProofOfOwnershipMessage + GetProofOfOwnershipRequest + PublishedReceipt + Receipt + SkippedBlocksmith + SnapshotFileInfo + SnapshotPayload + SpineBlockManifest + SpinePublicKey + Transaction + EmptyTransactionBody + SendMoneyTransactionBody + NodeRegistrationTransactionBody + UpdateNodeRegistrationTransactionBody + RemoveNodeRegistrationTransactionBody + ClaimNodeRegistrationTransactionBody + SetupAccountDatasetTransactionBody + RemoveAccountDatasetTransactionBody + ApprovalEscrowTransactionBody + MultiSignatureTransactionBody + GetTransactionRequest + GetTransactionsRequest + GetTransactionsResponse + PostTransactionRequest + PostTransactionResponse + SendTransactionRequest + SendTransactionResponse + RequestBlockTransactionsRequest + SendBlockTransactionsRequest + SendBlockTransactionsResponse + GetTransactionMinimumFeeRequest + GetTransactionMinimumFeeResponse +*/ package model -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -18,45 +166,22 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // AccountBalance represent the transaction data structure stored in the database type AccountBalance struct { - AccountAddress string `protobuf:"bytes,1,opt,name=AccountAddress,proto3" json:"AccountAddress,omitempty"` - BlockHeight uint32 `protobuf:"varint,2,opt,name=BlockHeight,proto3" json:"BlockHeight,omitempty"` - SpendableBalance int64 `protobuf:"varint,3,opt,name=SpendableBalance,proto3" json:"SpendableBalance,omitempty"` - Balance int64 `protobuf:"varint,4,opt,name=Balance,proto3" json:"Balance,omitempty"` - PopRevenue int64 `protobuf:"varint,5,opt,name=PopRevenue,proto3" json:"PopRevenue,omitempty"` - Latest bool `protobuf:"varint,6,opt,name=Latest,proto3" json:"Latest,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + AccountAddress string `protobuf:"bytes,1,opt,name=AccountAddress" json:"AccountAddress,omitempty"` + BlockHeight uint32 `protobuf:"varint,2,opt,name=BlockHeight" json:"BlockHeight,omitempty"` + SpendableBalance int64 `protobuf:"varint,3,opt,name=SpendableBalance" json:"SpendableBalance,omitempty"` + Balance int64 `protobuf:"varint,4,opt,name=Balance" json:"Balance,omitempty"` + PopRevenue int64 `protobuf:"varint,5,opt,name=PopRevenue" json:"PopRevenue,omitempty"` + Latest bool `protobuf:"varint,6,opt,name=Latest" json:"Latest,omitempty"` } -func (m *AccountBalance) Reset() { *m = AccountBalance{} } -func (m *AccountBalance) String() string { return proto.CompactTextString(m) } -func (*AccountBalance) ProtoMessage() {} -func (*AccountBalance) Descriptor() ([]byte, []int) { - return fileDescriptor_44b9b1c521a5bcaa, []int{0} -} - -func (m *AccountBalance) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AccountBalance.Unmarshal(m, b) -} -func (m *AccountBalance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AccountBalance.Marshal(b, m, deterministic) -} -func (m *AccountBalance) XXX_Merge(src proto.Message) { - xxx_messageInfo_AccountBalance.Merge(m, src) -} -func (m *AccountBalance) XXX_Size() int { - return xxx_messageInfo_AccountBalance.Size(m) -} -func (m *AccountBalance) XXX_DiscardUnknown() { - xxx_messageInfo_AccountBalance.DiscardUnknown(m) -} - -var xxx_messageInfo_AccountBalance proto.InternalMessageInfo +func (m *AccountBalance) Reset() { *m = AccountBalance{} } +func (m *AccountBalance) String() string { return proto.CompactTextString(m) } +func (*AccountBalance) ProtoMessage() {} +func (*AccountBalance) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (m *AccountBalance) GetAccountAddress() string { if m != nil { @@ -102,36 +227,13 @@ func (m *AccountBalance) GetLatest() bool { type GetAccountBalanceRequest struct { // Fetch AccountBalance by type/address - AccountAddress string `protobuf:"bytes,1,opt,name=AccountAddress,proto3" json:"AccountAddress,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + AccountAddress string `protobuf:"bytes,1,opt,name=AccountAddress" json:"AccountAddress,omitempty"` } -func (m *GetAccountBalanceRequest) Reset() { *m = GetAccountBalanceRequest{} } -func (m *GetAccountBalanceRequest) String() string { return proto.CompactTextString(m) } -func (*GetAccountBalanceRequest) ProtoMessage() {} -func (*GetAccountBalanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_44b9b1c521a5bcaa, []int{1} -} - -func (m *GetAccountBalanceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetAccountBalanceRequest.Unmarshal(m, b) -} -func (m *GetAccountBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetAccountBalanceRequest.Marshal(b, m, deterministic) -} -func (m *GetAccountBalanceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetAccountBalanceRequest.Merge(m, src) -} -func (m *GetAccountBalanceRequest) XXX_Size() int { - return xxx_messageInfo_GetAccountBalanceRequest.Size(m) -} -func (m *GetAccountBalanceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetAccountBalanceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetAccountBalanceRequest proto.InternalMessageInfo +func (m *GetAccountBalanceRequest) Reset() { *m = GetAccountBalanceRequest{} } +func (m *GetAccountBalanceRequest) String() string { return proto.CompactTextString(m) } +func (*GetAccountBalanceRequest) ProtoMessage() {} +func (*GetAccountBalanceRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } func (m *GetAccountBalanceRequest) GetAccountAddress() string { if m != nil { @@ -141,36 +243,13 @@ func (m *GetAccountBalanceRequest) GetAccountAddress() string { } type GetAccountBalanceResponse struct { - AccountBalance *AccountBalance `protobuf:"bytes,1,opt,name=AccountBalance,proto3" json:"AccountBalance,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetAccountBalanceResponse) Reset() { *m = GetAccountBalanceResponse{} } -func (m *GetAccountBalanceResponse) String() string { return proto.CompactTextString(m) } -func (*GetAccountBalanceResponse) ProtoMessage() {} -func (*GetAccountBalanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_44b9b1c521a5bcaa, []int{2} -} - -func (m *GetAccountBalanceResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetAccountBalanceResponse.Unmarshal(m, b) -} -func (m *GetAccountBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetAccountBalanceResponse.Marshal(b, m, deterministic) -} -func (m *GetAccountBalanceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetAccountBalanceResponse.Merge(m, src) -} -func (m *GetAccountBalanceResponse) XXX_Size() int { - return xxx_messageInfo_GetAccountBalanceResponse.Size(m) -} -func (m *GetAccountBalanceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetAccountBalanceResponse.DiscardUnknown(m) + AccountBalance *AccountBalance `protobuf:"bytes,1,opt,name=AccountBalance" json:"AccountBalance,omitempty"` } -var xxx_messageInfo_GetAccountBalanceResponse proto.InternalMessageInfo +func (m *GetAccountBalanceResponse) Reset() { *m = GetAccountBalanceResponse{} } +func (m *GetAccountBalanceResponse) String() string { return proto.CompactTextString(m) } +func (*GetAccountBalanceResponse) ProtoMessage() {} +func (*GetAccountBalanceResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } func (m *GetAccountBalanceResponse) GetAccountBalance() *AccountBalance { if m != nil { @@ -180,133 +259,33 @@ func (m *GetAccountBalanceResponse) GetAccountBalance() *AccountBalance { } type GetAccountBalancesRequest struct { - // Fetch AccountBalance by its balance (account balance < BalanceLowerThan) - BalanceLowerThan uint32 `protobuf:"varint,1,opt,name=BalanceLowerThan,proto3" json:"BalanceLowerThan,omitempty"` - // Fetch AccountBalance by its balance (account balance > BalanceHigherThan) - BalanceHigherThan uint32 `protobuf:"varint,2,opt,name=BalanceHigherThan,proto3" json:"BalanceHigherThan,omitempty"` - // Fetch AccountBalance by its spendablebalance (account spendablebalance < BalanceLowerThan) - SpendableBalanceLowerThan uint32 `protobuf:"varint,3,opt,name=SpendableBalanceLowerThan,proto3" json:"SpendableBalanceLowerThan,omitempty"` - // Fetch AccountBalance by its spendablebalance (account spendablebalance > BalanceHigherThan) - SpendableBalanceHigherThan uint32 `protobuf:"varint,4,opt,name=SpendableBalanceHigherThan,proto3" json:"SpendableBalanceHigherThan,omitempty"` - // Fetch AccountBalance by its spendablebalance (account spendablebalance < BalanceLowerThan) - PopRevenueBalanceLowerThan uint32 `protobuf:"varint,5,opt,name=PopRevenueBalanceLowerThan,proto3" json:"PopRevenueBalanceLowerThan,omitempty"` - // Fetch AccountBalance by its popRevenuebalance (account popRevenuebalance > BalanceHigherThan) - PopRevenueBalanceHigherThan uint32 `protobuf:"varint,6,opt,name=PopRevenueBalanceHigherThan,proto3" json:"PopRevenueBalanceHigherThan,omitempty"` - // Fetch AccountBalance by its Block height - BlockHeight uint32 `protobuf:"varint,7,opt,name=BlockHeight,proto3" json:"BlockHeight,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + // Fetch AccountBalances by type/addresses + AccountAddresses []string `protobuf:"bytes,1,rep,name=AccountAddresses" json:"AccountAddresses,omitempty"` } -func (m *GetAccountBalancesRequest) Reset() { *m = GetAccountBalancesRequest{} } -func (m *GetAccountBalancesRequest) String() string { return proto.CompactTextString(m) } -func (*GetAccountBalancesRequest) ProtoMessage() {} -func (*GetAccountBalancesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_44b9b1c521a5bcaa, []int{3} -} +func (m *GetAccountBalancesRequest) Reset() { *m = GetAccountBalancesRequest{} } +func (m *GetAccountBalancesRequest) String() string { return proto.CompactTextString(m) } +func (*GetAccountBalancesRequest) ProtoMessage() {} +func (*GetAccountBalancesRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } -func (m *GetAccountBalancesRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetAccountBalancesRequest.Unmarshal(m, b) -} -func (m *GetAccountBalancesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetAccountBalancesRequest.Marshal(b, m, deterministic) -} -func (m *GetAccountBalancesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetAccountBalancesRequest.Merge(m, src) -} -func (m *GetAccountBalancesRequest) XXX_Size() int { - return xxx_messageInfo_GetAccountBalancesRequest.Size(m) -} -func (m *GetAccountBalancesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetAccountBalancesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetAccountBalancesRequest proto.InternalMessageInfo - -func (m *GetAccountBalancesRequest) GetBalanceLowerThan() uint32 { +func (m *GetAccountBalancesRequest) GetAccountAddresses() []string { if m != nil { - return m.BalanceLowerThan + return m.AccountAddresses } - return 0 -} - -func (m *GetAccountBalancesRequest) GetBalanceHigherThan() uint32 { - if m != nil { - return m.BalanceHigherThan - } - return 0 -} - -func (m *GetAccountBalancesRequest) GetSpendableBalanceLowerThan() uint32 { - if m != nil { - return m.SpendableBalanceLowerThan - } - return 0 -} - -func (m *GetAccountBalancesRequest) GetSpendableBalanceHigherThan() uint32 { - if m != nil { - return m.SpendableBalanceHigherThan - } - return 0 -} - -func (m *GetAccountBalancesRequest) GetPopRevenueBalanceLowerThan() uint32 { - if m != nil { - return m.PopRevenueBalanceLowerThan - } - return 0 -} - -func (m *GetAccountBalancesRequest) GetPopRevenueBalanceHigherThan() uint32 { - if m != nil { - return m.PopRevenueBalanceHigherThan - } - return 0 -} - -func (m *GetAccountBalancesRequest) GetBlockHeight() uint32 { - if m != nil { - return m.BlockHeight - } - return 0 + return nil } type GetAccountBalancesResponse struct { // Number of accounts returned - AccountBalanceSize uint32 `protobuf:"varint,1,opt,name=AccountBalanceSize,proto3" json:"AccountBalanceSize,omitempty"` + AccountBalanceSize uint32 `protobuf:"varint,1,opt,name=AccountBalanceSize" json:"AccountBalanceSize,omitempty"` // AccountBalances returned - AccountBalance []*AccountBalance `protobuf:"bytes,2,rep,name=AccountBalance,proto3" json:"AccountBalance,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetAccountBalancesResponse) Reset() { *m = GetAccountBalancesResponse{} } -func (m *GetAccountBalancesResponse) String() string { return proto.CompactTextString(m) } -func (*GetAccountBalancesResponse) ProtoMessage() {} -func (*GetAccountBalancesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_44b9b1c521a5bcaa, []int{4} + AccountBalances []*AccountBalance `protobuf:"bytes,2,rep,name=AccountBalances" json:"AccountBalances,omitempty"` } -func (m *GetAccountBalancesResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetAccountBalancesResponse.Unmarshal(m, b) -} -func (m *GetAccountBalancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetAccountBalancesResponse.Marshal(b, m, deterministic) -} -func (m *GetAccountBalancesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetAccountBalancesResponse.Merge(m, src) -} -func (m *GetAccountBalancesResponse) XXX_Size() int { - return xxx_messageInfo_GetAccountBalancesResponse.Size(m) -} -func (m *GetAccountBalancesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetAccountBalancesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetAccountBalancesResponse proto.InternalMessageInfo +func (m *GetAccountBalancesResponse) Reset() { *m = GetAccountBalancesResponse{} } +func (m *GetAccountBalancesResponse) String() string { return proto.CompactTextString(m) } +func (*GetAccountBalancesResponse) ProtoMessage() {} +func (*GetAccountBalancesResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } func (m *GetAccountBalancesResponse) GetAccountBalanceSize() uint32 { if m != nil { @@ -315,9 +294,9 @@ func (m *GetAccountBalancesResponse) GetAccountBalanceSize() uint32 { return 0 } -func (m *GetAccountBalancesResponse) GetAccountBalance() []*AccountBalance { +func (m *GetAccountBalancesResponse) GetAccountBalances() []*AccountBalance { if m != nil { - return m.AccountBalance + return m.AccountBalances } return nil } @@ -330,33 +309,29 @@ func init() { proto.RegisterType((*GetAccountBalancesResponse)(nil), "model.GetAccountBalancesResponse") } -func init() { proto.RegisterFile("model/accountBalance.proto", fileDescriptor_44b9b1c521a5bcaa) } - -var fileDescriptor_44b9b1c521a5bcaa = []byte{ - // 396 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xcd, 0xae, 0x9a, 0x40, - 0x14, 0xce, 0x88, 0x62, 0x7b, 0x8c, 0x8d, 0x9d, 0xa4, 0x0d, 0xda, 0x2e, 0x08, 0x8b, 0x86, 0x98, - 0x16, 0x9a, 0x76, 0xdb, 0x36, 0x95, 0x4d, 0x5d, 0xb8, 0x68, 0xb0, 0x2b, 0x77, 0x30, 0x9c, 0x08, - 0x29, 0x30, 0x14, 0x86, 0xde, 0xc4, 0x57, 0xb8, 0x0f, 0x70, 0x5f, 0xf0, 0x3e, 0xc8, 0xcd, 0x1d, - 0x51, 0x11, 0xd0, 0xb8, 0x31, 0xf1, 0xfb, 0x3b, 0x33, 0xf3, 0x1d, 0x60, 0x96, 0xf0, 0x00, 0x63, - 0xdb, 0x63, 0x8c, 0x97, 0xa9, 0x70, 0xbc, 0xd8, 0x4b, 0x19, 0x5a, 0x59, 0xce, 0x05, 0xa7, 0x03, - 0xc9, 0x19, 0x8f, 0x04, 0x5e, 0x2d, 0xce, 0x78, 0xfa, 0xe1, 0x88, 0x2c, 0x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 0x35, 0xc9, 0xda, 0xd0, 0xbe, 0xb4, 0x5f, 0x51, 0x3c, 0xfb, 0x4f, 0xdd, 0xb5, 0xc6, 0x0f, 0xf6, - 0xfe, 0xcb, 0x0a, 0xfa, 0x13, 0xde, 0xb5, 0xd8, 0xda, 0x01, 0x54, 0x19, 0x70, 0x4d, 0xd2, 0xdc, - 0xe1, 0x61, 0x6b, 0x87, 0x8d, 0x7b, 0x02, 0xb3, 0xae, 0x66, 0xaa, 0xde, 0x2d, 0xa0, 0xe7, 0xd4, - 0x3a, 0xda, 0x61, 0x55, 0x4e, 0x07, 0xd3, 0xb1, 0x27, 0x3d, 0x5d, 0xb9, 0x79, 0x4f, 0x9c, 0xf9, - 0xc6, 0xdc, 0x46, 0x22, 0x2c, 0x7d, 0x8b, 0xf1, 0xc4, 0xde, 0x71, 0xee, 0xb3, 0xfd, 0xef, 0x27, - 0xc6, 0x73, 0xb4, 0x19, 0x4f, 0x12, 0x9e, 0xda, 0x32, 0xca, 0x57, 0xe5, 0x87, 0xfe, 0xf5, 0x29, - 0x00, 0x00, 0xff, 0xff, 0x29, 0xf8, 0xf6, 0xe9, 0x06, 0x04, 0x00, 0x00, +func init() { proto.RegisterFile("model/accountBalance.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 325 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x4f, 0x4b, 0xc3, 0x40, + 0x10, 0xc5, 0xd9, 0xc6, 0x56, 0x3b, 0xa5, 0x5a, 0x16, 0x94, 0xb5, 0x78, 0x08, 0x39, 0x48, 0x28, + 0x98, 0x88, 0x9e, 0x45, 0x9a, 0x4b, 0x3d, 0x78, 0x90, 0xed, 0xad, 0xb7, 0x64, 0x33, 0xb4, 0xc5, + 0x24, 0x13, 0xbb, 0x1b, 0x0f, 0xfd, 0x0e, 0x7e, 0x4b, 0x3f, 0x88, 0x98, 0xfe, 0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 0x72, 0xbb, 0xf2, 0x48, 0x77, 0xbe, 0x18, 0x0c, 0x9b, 0x48, 0xdb, 0x9a, + 0x1e, 0xf0, 0xaa, 0x35, 0x5d, 0xae, 0x37, 0x55, 0xfb, 0xb2, 0xc1, 0xe1, 0xcf, 0x70, 0x51, 0x43, + 0x89, 0x96, 0x6d, 0xfd, 0x3d, 0x57, 0x3d, 0x1d, 0x8c, 0x66, 0xee, 0x7c, 0x69, 0x16, 0x45, 0xe4, + 0x29, 0x4a, 0xfd, 0x35, 0x51, 0xa4, 0x36, 0xe7, 0x9d, 0xa2, 0x15, 0xfa, 0x8a, 0xd2, 0x94, 0x32, + 0xbf, 0x64, 0x45, 0x9d, 0xf2, 0x67, 0x3e, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xed, 0x5b, 0xec, + 0xcc, 0xb7, 0x02, 0x00, 0x00, } diff --git a/common/schema b/common/schema index b3db1d0e5..bc6bed528 160000 --- a/common/schema +++ b/common/schema @@ -1 +1 @@ -Subproject commit b3db1d0e5e1a6b662237b12f80981ee62474e824 +Subproject commit bc6bed5283da24c6ff7f868373ac425eb3565bd7