From 9e848bfe380848b3715ae185e23aa9c7208e1271 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sat, 19 Mar 2022 11:04:23 -0400 Subject: [PATCH 1/5] updates --- proto/cosmos/bank/v1beta1/query.proto | 30 ++ x/bank/keeper/grpc_query.go | 42 ++ x/bank/types/query.pb.go | 656 +++++++++++++++++++++++--- x/bank/types/query.pb.gw.go | 116 +++++ 4 files changed, 770 insertions(+), 74 deletions(-) diff --git a/proto/cosmos/bank/v1beta1/query.proto b/proto/cosmos/bank/v1beta1/query.proto index 98750639ca68..0d81a20d988a 100644 --- a/proto/cosmos/bank/v1beta1/query.proto +++ b/proto/cosmos/bank/v1beta1/query.proto @@ -22,6 +22,12 @@ service Query { option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}"; } + // SpendableBalances queries the spenable balance of all coins for a single + // account. + rpc SpendableBalances(QuerySpendableBalancesRequest) returns (QuerySpendableBalancesResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/spendable_balances/{address}"; + } + // TotalSupply queries the total supply of all coins. rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) { option (google.api.http).get = "/cosmos/bank/v1beta1/supply"; @@ -96,6 +102,30 @@ message QueryAllBalancesResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } +// QuerySpendableBalancesRequest defines the gRPC request structure for querying +// an account's spendable balances. +message QuerySpendableBalancesRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address to query spendable balances for. + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QuerySpendableBalancesResponse defines the gRPC response structure for querying +// an account's spendable balances. +message QuerySpendableBalancesResponse { + // balances is the spendable balances of all the coins. + repeated cosmos.base.v1beta1.Coin balances = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // method. message QueryTotalSupplyRequest { diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 70c780dcf5e6..163947bcb85f 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -75,6 +75,48 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances return &types.QueryAllBalancesResponse{Balances: balances, Pagination: pageRes}, nil } +// SpendableBalances implements a gRPC query handler for retrieving an account's +// spendable balances. +func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpendableBalancesRequest) (*types.QuerySpendableBalancesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + if req.Address == "" { + return nil, status.Error(codes.InvalidArgument, "address cannot be empty") + } + + addr, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error()) + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + balances := sdk.NewCoins() + accountStore := k.getAccountStore(sdkCtx, addr) + + pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, value []byte) error { + var amount sdk.Int + if err := amount.Unmarshal(value); err != nil { + return err + } + balances = append(balances, sdk.NewCoin(string(key), amount)) + return nil + }) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + result := sdk.NewCoins() + spendable := k.SpendableCoins(sdkCtx, addr) + + for _, c := range balances { + result = append(result, sdk.NewCoin(c.Denom, spendable.AmountOf(c.Denom))) + } + + return &types.QuerySpendableBalancesResponse{Balances: result, Pagination: pageRes}, nil +} + // TotalSupply implements the Query/TotalSupply gRPC method func (k BaseKeeper) TotalSupply(ctx context.Context, req *types.QueryTotalSupplyRequest) (*types.QueryTotalSupplyResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) diff --git a/x/bank/types/query.pb.go b/x/bank/types/query.pb.go index 942d6713dd64..922e7f5a27d9 100644 --- a/x/bank/types/query.pb.go +++ b/x/bank/types/query.pb.go @@ -217,6 +217,104 @@ func (m *QueryAllBalancesResponse) GetPagination() *query.PageResponse { return nil } +// QuerySpendableBalancesRequest defines the gRPC request structure for querying +// an account's spendable balances. +type QuerySpendableBalancesRequest struct { + // address is the address to query spendable balances for. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySpendableBalancesRequest) Reset() { *m = QuerySpendableBalancesRequest{} } +func (m *QuerySpendableBalancesRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySpendableBalancesRequest) ProtoMessage() {} +func (*QuerySpendableBalancesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6fc1939682df13, []int{4} +} +func (m *QuerySpendableBalancesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpendableBalancesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpendableBalancesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySpendableBalancesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpendableBalancesRequest.Merge(m, src) +} +func (m *QuerySpendableBalancesRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySpendableBalancesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpendableBalancesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpendableBalancesRequest proto.InternalMessageInfo + +// QuerySpendableBalancesResponse defines the gRPC response structure for querying +// an account's spendable balances. +type QuerySpendableBalancesResponse struct { + // balances is the spendable balances of all the coins. + Balances github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=balances,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"balances"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySpendableBalancesResponse) Reset() { *m = QuerySpendableBalancesResponse{} } +func (m *QuerySpendableBalancesResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySpendableBalancesResponse) ProtoMessage() {} +func (*QuerySpendableBalancesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6fc1939682df13, []int{5} +} +func (m *QuerySpendableBalancesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpendableBalancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpendableBalancesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySpendableBalancesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpendableBalancesResponse.Merge(m, src) +} +func (m *QuerySpendableBalancesResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySpendableBalancesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpendableBalancesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpendableBalancesResponse proto.InternalMessageInfo + +func (m *QuerySpendableBalancesResponse) GetBalances() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Balances + } + return nil +} + +func (m *QuerySpendableBalancesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // method. type QueryTotalSupplyRequest struct { @@ -230,7 +328,7 @@ func (m *QueryTotalSupplyRequest) Reset() { *m = QueryTotalSupplyRequest func (m *QueryTotalSupplyRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyRequest) ProtoMessage() {} func (*QueryTotalSupplyRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{4} + return fileDescriptor_9c6fc1939682df13, []int{6} } func (m *QueryTotalSupplyRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -274,7 +372,7 @@ func (m *QueryTotalSupplyResponse) Reset() { *m = QueryTotalSupplyRespon func (m *QueryTotalSupplyResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyResponse) ProtoMessage() {} func (*QueryTotalSupplyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{5} + return fileDescriptor_9c6fc1939682df13, []int{7} } func (m *QueryTotalSupplyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -327,7 +425,7 @@ func (m *QuerySupplyOfRequest) Reset() { *m = QuerySupplyOfRequest{} } func (m *QuerySupplyOfRequest) String() string { return proto.CompactTextString(m) } func (*QuerySupplyOfRequest) ProtoMessage() {} func (*QuerySupplyOfRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{6} + return fileDescriptor_9c6fc1939682df13, []int{8} } func (m *QuerySupplyOfRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -373,7 +471,7 @@ func (m *QuerySupplyOfResponse) Reset() { *m = QuerySupplyOfResponse{} } func (m *QuerySupplyOfResponse) String() string { return proto.CompactTextString(m) } func (*QuerySupplyOfResponse) ProtoMessage() {} func (*QuerySupplyOfResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{7} + return fileDescriptor_9c6fc1939682df13, []int{9} } func (m *QuerySupplyOfResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -417,7 +515,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{8} + return fileDescriptor_9c6fc1939682df13, []int{10} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -455,7 +553,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{9} + return fileDescriptor_9c6fc1939682df13, []int{11} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -501,7 +599,7 @@ func (m *QueryDenomsMetadataRequest) Reset() { *m = QueryDenomsMetadataR func (m *QueryDenomsMetadataRequest) String() string { return proto.CompactTextString(m) } func (*QueryDenomsMetadataRequest) ProtoMessage() {} func (*QueryDenomsMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{10} + return fileDescriptor_9c6fc1939682df13, []int{12} } func (m *QueryDenomsMetadataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -550,7 +648,7 @@ func (m *QueryDenomsMetadataResponse) Reset() { *m = QueryDenomsMetadata func (m *QueryDenomsMetadataResponse) String() string { return proto.CompactTextString(m) } func (*QueryDenomsMetadataResponse) ProtoMessage() {} func (*QueryDenomsMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{11} + return fileDescriptor_9c6fc1939682df13, []int{13} } func (m *QueryDenomsMetadataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -603,7 +701,7 @@ func (m *QueryDenomMetadataRequest) Reset() { *m = QueryDenomMetadataReq func (m *QueryDenomMetadataRequest) String() string { return proto.CompactTextString(m) } func (*QueryDenomMetadataRequest) ProtoMessage() {} func (*QueryDenomMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{12} + return fileDescriptor_9c6fc1939682df13, []int{14} } func (m *QueryDenomMetadataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -650,7 +748,7 @@ func (m *QueryDenomMetadataResponse) Reset() { *m = QueryDenomMetadataRe func (m *QueryDenomMetadataResponse) String() string { return proto.CompactTextString(m) } func (*QueryDenomMetadataResponse) ProtoMessage() {} func (*QueryDenomMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{13} + return fileDescriptor_9c6fc1939682df13, []int{15} } func (m *QueryDenomMetadataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -700,7 +798,7 @@ func (m *QueryDenomOwnersRequest) Reset() { *m = QueryDenomOwnersRequest func (m *QueryDenomOwnersRequest) String() string { return proto.CompactTextString(m) } func (*QueryDenomOwnersRequest) ProtoMessage() {} func (*QueryDenomOwnersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{14} + return fileDescriptor_9c6fc1939682df13, []int{16} } func (m *QueryDenomOwnersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -757,7 +855,7 @@ func (m *DenomOwner) Reset() { *m = DenomOwner{} } func (m *DenomOwner) String() string { return proto.CompactTextString(m) } func (*DenomOwner) ProtoMessage() {} func (*DenomOwner) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{15} + return fileDescriptor_9c6fc1939682df13, []int{17} } func (m *DenomOwner) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -811,7 +909,7 @@ func (m *QueryDenomOwnersResponse) Reset() { *m = QueryDenomOwnersRespon func (m *QueryDenomOwnersResponse) String() string { return proto.CompactTextString(m) } func (*QueryDenomOwnersResponse) ProtoMessage() {} func (*QueryDenomOwnersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{16} + return fileDescriptor_9c6fc1939682df13, []int{18} } func (m *QueryDenomOwnersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -859,6 +957,8 @@ func init() { proto.RegisterType((*QueryBalanceResponse)(nil), "cosmos.bank.v1beta1.QueryBalanceResponse") proto.RegisterType((*QueryAllBalancesRequest)(nil), "cosmos.bank.v1beta1.QueryAllBalancesRequest") proto.RegisterType((*QueryAllBalancesResponse)(nil), "cosmos.bank.v1beta1.QueryAllBalancesResponse") + proto.RegisterType((*QuerySpendableBalancesRequest)(nil), "cosmos.bank.v1beta1.QuerySpendableBalancesRequest") + proto.RegisterType((*QuerySpendableBalancesResponse)(nil), "cosmos.bank.v1beta1.QuerySpendableBalancesResponse") proto.RegisterType((*QueryTotalSupplyRequest)(nil), "cosmos.bank.v1beta1.QueryTotalSupplyRequest") proto.RegisterType((*QueryTotalSupplyResponse)(nil), "cosmos.bank.v1beta1.QueryTotalSupplyResponse") proto.RegisterType((*QuerySupplyOfRequest)(nil), "cosmos.bank.v1beta1.QuerySupplyOfRequest") @@ -877,67 +977,70 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/query.proto", fileDescriptor_9c6fc1939682df13) } var fileDescriptor_9c6fc1939682df13 = []byte{ - // 948 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcf, 0x6f, 0xe3, 0x44, - 0x14, 0xce, 0x14, 0x36, 0x6d, 0x5f, 0x80, 0xc3, 0x6c, 0x10, 0xad, 0xcb, 0x26, 0xc8, 0xa0, 0x6d, - 0xbb, 0xb4, 0x76, 0x9b, 0x45, 0x82, 0xe5, 0x82, 0x9a, 0x45, 0x70, 0x40, 0x68, 0x8b, 0x97, 0x13, - 0x12, 0x8a, 0x26, 0x89, 0x31, 0x56, 0x13, 0x8f, 0x37, 0xe3, 0xb0, 0x44, 0xd5, 0x4a, 0x88, 0x13, - 0xb7, 0x45, 0xe2, 0x82, 0x84, 0x10, 0x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0x2c, 0x24, 0x8a, 0x9a, 0x16, 0xf4, 0x3b, 0x02, 0x4f, 0xa6, 0x9a, 0x1c, 0xb5, 0xe6, 0x27, - 0xc8, 0x6a, 0xa0, 0x86, 0x5d, 0xd8, 0x1e, 0x71, 0xbd, 0x24, 0x71, 0x59, 0x74, 0x2f, 0x13, 0x97, - 0x54, 0x46, 0xb4, 0x74, 0xab, 0xb4, 0x4f, 0xe5, 0xc2, 0x3d, 0xfa, 0x2d, 0x81, 0xa7, 0xd2, 0xb3, - 0x86, 0x2e, 0xca, 0x3c, 0x3d, 0xfc, 0x8c, 0x83, 0xe2, 0x0e, 0x85, 0xce, 0x73, 0x0a, 0x2b, 0xfd, - 0x9a, 0x40, 0x25, 0xd1, 0xdb, 0xf2, 0xee, 0xfc, 0x6c, 0xe7, 0xcf, 0xbb, 0xf3, 0x19, 0x0d, 0xd3, - 0x3c, 0x94, 0xd0, 0x5e, 0xa4, 0xbb, 0xf3, 0xa1, 0x61, 0x2f, 0xd5, 0x1a, 0x36, 0x6f, 0x9e, 0x9d, - 0xd7, 0xc8, 0xc3, 0xf3, 0x1a, 0xf9, 0xeb, 0xbc, 0x46, 0x3e, 0xbf, 0xa8, 0x95, 0x1e, 0x5e, 0xd4, - 0x4a, 0xbf, 0x5f, 0xd4, 0x4a, 0xef, 0xed, 0xe6, 0x7e, 0x97, 0x7d, 0xac, 0x62, 0xcb, 0xcf, 0xb3, - 0x76, 0x59, 0xfe, 0x5f, 0xb9, 0xfe, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xc4, 0x6d, 0x36, - 0xa2, 0x0d, 0x00, 0x00, + // 1008 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0xbf, 0x6f, 0x23, 0x45, + 0x14, 0xf6, 0x04, 0xce, 0xc9, 0x3d, 0x03, 0x12, 0x73, 0x46, 0x24, 0x1b, 0x62, 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68, 0xf5, 0x76, 0x45, 0x42, 0x7b, + 0x86, 0x6e, 0xce, 0x86, 0x86, 0x53, 0x40, 0x6b, 0x58, 0xbb, 0x7e, 0x7a, 0x56, 0x22, 0xf7, 0xce, + 0x4a, 0xe4, 0xb7, 0xb3, 0x12, 0xf9, 0xf8, 0xbc, 0x94, 0xbb, 0x77, 0x5e, 0xca, 0xfd, 0x7c, 0x5e, + 0xca, 0xbd, 0xb9, 0x99, 0xfa, 0xa2, 0x7c, 0x4f, 0xc5, 0x96, 0x0f, 0xcb, 0x66, 0x5e, 0xfe, 0x9b, + 0xbb, 0xfb, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xb5, 0x9c, 0x3a, 0xd9, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -956,6 +1059,9 @@ type QueryClient interface { Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) // AllBalances queries the balance of all coins for a single account. AllBalances(ctx context.Context, in *QueryAllBalancesRequest, opts ...grpc.CallOption) (*QueryAllBalancesResponse, error) + // SpendableBalances queries the spenable balance of all coins for a single + // account. + SpendableBalances(ctx context.Context, in *QuerySpendableBalancesRequest, opts ...grpc.CallOption) (*QuerySpendableBalancesResponse, error) // TotalSupply queries the total supply of all coins. TotalSupply(ctx context.Context, in *QueryTotalSupplyRequest, opts ...grpc.CallOption) (*QueryTotalSupplyResponse, error) // SupplyOf queries the supply of a single coin. @@ -998,6 +1104,15 @@ func (c *queryClient) AllBalances(ctx context.Context, in *QueryAllBalancesReque return out, nil } +func (c *queryClient) SpendableBalances(ctx context.Context, in *QuerySpendableBalancesRequest, opts ...grpc.CallOption) (*QuerySpendableBalancesResponse, error) { + out := new(QuerySpendableBalancesResponse) + err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/SpendableBalances", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) TotalSupply(ctx context.Context, in *QueryTotalSupplyRequest, opts ...grpc.CallOption) (*QueryTotalSupplyResponse, error) { out := new(QueryTotalSupplyResponse) err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/TotalSupply", in, out, opts...) @@ -1058,6 +1173,9 @@ type QueryServer interface { Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error) // AllBalances queries the balance of all coins for a single account. AllBalances(context.Context, *QueryAllBalancesRequest) (*QueryAllBalancesResponse, error) + // SpendableBalances queries the spenable balance of all coins for a single + // account. + SpendableBalances(context.Context, *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error) // TotalSupply queries the total supply of all coins. TotalSupply(context.Context, *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) // SupplyOf queries the supply of a single coin. @@ -1084,6 +1202,9 @@ func (*UnimplementedQueryServer) Balance(ctx context.Context, req *QueryBalanceR func (*UnimplementedQueryServer) AllBalances(ctx context.Context, req *QueryAllBalancesRequest) (*QueryAllBalancesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AllBalances not implemented") } +func (*UnimplementedQueryServer) SpendableBalances(ctx context.Context, req *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SpendableBalances not implemented") +} func (*UnimplementedQueryServer) TotalSupply(ctx context.Context, req *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalSupply not implemented") } @@ -1143,6 +1264,24 @@ func _Query_AllBalances_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Query_SpendableBalances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySpendableBalancesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SpendableBalances(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.bank.v1beta1.Query/SpendableBalances", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SpendableBalances(ctx, req.(*QuerySpendableBalancesRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_TotalSupply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryTotalSupplyRequest) if err := dec(in); err != nil { @@ -1263,6 +1402,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "AllBalances", Handler: _Query_AllBalances_Handler, }, + { + MethodName: "SpendableBalances", + Handler: _Query_SpendableBalances_Handler, + }, { MethodName: "TotalSupply", Handler: _Query_TotalSupply_Handler, @@ -1455,6 +1598,97 @@ func (m *QueryAllBalancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *QuerySpendableBalancesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySpendableBalancesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpendableBalancesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QuerySpendableBalancesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySpendableBalancesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpendableBalancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Balances) > 0 { + for iNdEx := len(m.Balances) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Balances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryTotalSupplyRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2013,6 +2247,42 @@ func (m *QueryAllBalancesResponse) Size() (n int) { return n } +func (m *QuerySpendableBalancesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySpendableBalancesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Balances) > 0 { + for _, e := range m.Balances { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QueryTotalSupplyRequest) Size() (n int) { if m == nil { return 0 @@ -2640,6 +2910,244 @@ func (m *QueryAllBalancesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QuerySpendableBalancesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuerySpendableBalancesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpendableBalancesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySpendableBalancesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuerySpendableBalancesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpendableBalancesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balances", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Balances = append(m.Balances, types.Coin{}) + if err := m.Balances[len(m.Balances)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryTotalSupplyRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/bank/types/query.pb.gw.go b/x/bank/types/query.pb.gw.go index 477363012121..2608b3642664 100644 --- a/x/bank/types/query.pb.gw.go +++ b/x/bank/types/query.pb.gw.go @@ -175,6 +175,78 @@ func local_request_Query_AllBalances_0(ctx context.Context, marshaler runtime.Ma } +var ( + filter_Query_SpendableBalances_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_SpendableBalances_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySpendableBalancesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpendableBalances_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SpendableBalances(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_SpendableBalances_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySpendableBalancesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpendableBalances_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SpendableBalances(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_TotalSupply_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -473,6 +545,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_SpendableBalances_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_SpendableBalances_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_SpendableBalances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_TotalSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -674,6 +766,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_SpendableBalances_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_SpendableBalances_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_SpendableBalances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_TotalSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -802,6 +914,8 @@ var ( pattern_Query_AllBalances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "balances", "address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_SpendableBalances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "spendable_balances", "address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TotalSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "bank", "v1beta1", "supply"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_SupplyOf_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"cosmos", "bank", "v1beta1", "supply", "by_denom"}, "", runtime.AssumeColonVerbOpt(false))) @@ -820,6 +934,8 @@ var ( forward_Query_AllBalances_0 = runtime.ForwardResponseMessage + forward_Query_SpendableBalances_0 = runtime.ForwardResponseMessage + forward_Query_TotalSupply_0 = runtime.ForwardResponseMessage forward_Query_SupplyOf_0 = runtime.ForwardResponseMessage From f979395566fca80e086acd4f58f7ae1fe763093b Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sat, 19 Mar 2022 11:13:44 -0400 Subject: [PATCH 2/5] cl++ --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 136af434525a..833f06b022f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (x/bank) [\#11417](https://github.com/cosmos/cosmos-sdk/pull/11417) Introduce a new `SpendableBalances` gRPC query that retrieves an account's total (paginated) spenable balances. * (x/upgrade) [\#11116](https://github.com/cosmos/cosmos-sdk/pull/11116) `MsgSoftwareUpgrade` and has been added to support v1beta2 msgs-based gov proposals. * [\#11308](https://github.com/cosmos/cosmos-sdk/pull/11308) Added a mandatory metadata field to Vote in x/gov v1beta2. * [\#10977](https://github.com/cosmos/cosmos-sdk/pull/10977) Now every cosmos message protobuf definition must be extended with a ``cosmos.msg.v1.signer`` option to signal the signer fields in a language agnostic way. From 7a2f9fd0abc2fd32dba11431fd67b4542c35a6c6 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 22 Mar 2022 11:28:50 -0400 Subject: [PATCH 3/5] tests++ --- x/bank/keeper/grpc_query_test.go | 53 ++++++++++++++++++++++++++++++++ x/bank/keeper/keeper_test.go | 2 +- x/bank/types/querier.go | 7 +++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/x/bank/keeper/grpc_query_test.go b/x/bank/keeper/grpc_query_test.go index ed58dcb7f356..0e1d8abd3de5 100644 --- a/x/bank/keeper/grpc_query_test.go +++ b/x/bank/keeper/grpc_query_test.go @@ -3,12 +3,15 @@ package keeper_test import ( gocontext "context" "fmt" + "time" + "github.com/cosmos/cosmos-sdk/baseapp" sdktestutil "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -87,6 +90,56 @@ func (suite *IntegrationTestSuite) TestQueryAllBalances() { suite.Nil(res.Pagination.NextKey) } +func (suite *IntegrationTestSuite) TestSpendableBalances() { + app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient + _, _, addr := testdata.KeyTestPubAddr() + ctx = ctx.WithBlockTime(time.Now()) + + _, err := queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), &types.QuerySpendableBalancesRequest{}) + suite.Require().Error(err) + + pageReq := &query.PageRequest{ + Key: nil, + Limit: 2, + CountTotal: false, + } + req := types.NewQuerySpendableBalancesRequest(addr, pageReq) + + res, err := queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), req) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.True(res.Balances.IsZero()) + + fooCoins := newFooCoin(50) + barCoins := newBarCoin(30) + + origCoins := sdk.NewCoins(fooCoins, barCoins) + acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) + acc = vestingtypes.NewContinuousVestingAccount( + acc.(*authtypes.BaseAccount), + sdk.NewCoins(fooCoins), + ctx.BlockTime().Unix(), + ctx.BlockTime().Add(time.Hour).Unix(), + ) + + app.AccountKeeper.SetAccount(ctx, acc) + suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) + + // move time forward for some tokens to vest + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(30 * time.Minute)) + queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, app.BankKeeper) + queryClient = types.NewQueryClient(queryHelper) + + res, err = queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), req) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Equal(2, res.Balances.Len()) + suite.Nil(res.Pagination.NextKey) + suite.EqualValues(30, res.Balances[0].Amount.Int64()) + suite.EqualValues(25, res.Balances[1].Amount.Int64()) +} + func (suite *IntegrationTestSuite) TestQueryTotalSupply() { app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient res, err := queryClient.TotalSupply(gocontext.Background(), &types.QueryTotalSupplyRequest{}) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 760c0289d3e4..1ccb47f9fc7d 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -95,7 +95,7 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str func (suite *IntegrationTestSuite) SetupTest() { app := simapp.Setup(suite.T(), false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) app.BankKeeper.SetParams(ctx, types.DefaultParams()) diff --git a/x/bank/types/querier.go b/x/bank/types/querier.go index 1ef0093386e4..117b87f17c68 100644 --- a/x/bank/types/querier.go +++ b/x/bank/types/querier.go @@ -25,6 +25,13 @@ func NewQueryAllBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *Qu return &QueryAllBalancesRequest{Address: addr.String(), Pagination: req} } +// NewQuerySpendableBalancesRequest creates a new instance of a +// QuerySpendableBalancesRequest. +// nolint:interfacer +func NewQuerySpendableBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QuerySpendableBalancesRequest { + return &QuerySpendableBalancesRequest{Address: addr.String(), Pagination: req} +} + // QueryTotalSupplyParams defines the params for the following queries: // // - 'custom/bank/totalSupply' From deecd03fe2b3051697f04a9e26b1d3cd1f7d7fd0 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 22 Mar 2022 13:44:53 -0400 Subject: [PATCH 4/5] updates --- x/bank/keeper/grpc_query.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 163947bcb85f..8233da109455 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -81,9 +81,6 @@ func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpend if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - if req.Address == "" { - return nil, status.Error(codes.InvalidArgument, "address cannot be empty") - } addr, err := sdk.AccAddressFromBech32(req.Address) if err != nil { From ff133064bf7b50673612908c447c4e45d7d3b8f0 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 22 Mar 2022 13:46:25 -0400 Subject: [PATCH 5/5] updates --- x/bank/keeper/grpc_query.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 8233da109455..032e9e5ecfff 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -91,13 +91,10 @@ func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpend balances := sdk.NewCoins() accountStore := k.getAccountStore(sdkCtx, addr) + zeroAmt := sdk.ZeroInt() pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, value []byte) error { - var amount sdk.Int - if err := amount.Unmarshal(value); err != nil { - return err - } - balances = append(balances, sdk.NewCoin(string(key), amount)) + balances = append(balances, sdk.NewCoin(string(key), zeroAmt)) return nil }) if err != nil {