feat: (x/bank) add spendable balances cmd (#14045)

This commit is contained in:
Facundo Medica
2023-01-05 19:58:41 +00:00
committed by GitHub
parent 5d6236603c
commit 6ac0c3628e
12 changed files with 2403 additions and 446 deletions
File diff suppressed because it is too large Load Diff
+52 -2
View File
@@ -29,7 +29,7 @@ type QueryClient interface {
// When called from another module, this query might consume a high amount of
// gas if the pagination field is incorrectly set.
AllBalances(ctx context.Context, in *QueryAllBalancesRequest, opts ...grpc.CallOption) (*QueryAllBalancesResponse, error)
// SpendableBalances queries the spenable balance of all coins for a single
// SpendableBalances queries the spendable balance of all coins for a single
// account.
//
// When called from another module, this query might consume a high amount of
@@ -37,6 +37,14 @@ type QueryClient interface {
//
// Since: cosmos-sdk 0.46
SpendableBalances(ctx context.Context, in *QuerySpendableBalancesRequest, opts ...grpc.CallOption) (*QuerySpendableBalancesResponse, error)
// SpendableBalanceByDenom queries the spendable balance of a single denom for
// a single account.
//
// When called from another module, this query might consume a high amount of
// gas if the pagination field is incorrectly set.
//
// Since: cosmos-sdk 0.47
SpendableBalanceByDenom(ctx context.Context, in *QuerySpendableBalanceByDenomRequest, opts ...grpc.CallOption) (*QuerySpendableBalanceByDenomResponse, error)
// TotalSupply queries the total supply of all coins.
//
// When called from another module, this query might consume a high amount of
@@ -107,6 +115,15 @@ func (c *queryClient) SpendableBalances(ctx context.Context, in *QuerySpendableB
return out, nil
}
func (c *queryClient) SpendableBalanceByDenom(ctx context.Context, in *QuerySpendableBalanceByDenomRequest, opts ...grpc.CallOption) (*QuerySpendableBalanceByDenomResponse, error) {
out := new(QuerySpendableBalanceByDenomResponse)
err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/SpendableBalanceByDenom", 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...)
@@ -181,7 +198,7 @@ type QueryServer interface {
// When called from another module, this query might consume a high amount of
// gas if the pagination field is incorrectly set.
AllBalances(context.Context, *QueryAllBalancesRequest) (*QueryAllBalancesResponse, error)
// SpendableBalances queries the spenable balance of all coins for a single
// SpendableBalances queries the spendable balance of all coins for a single
// account.
//
// When called from another module, this query might consume a high amount of
@@ -189,6 +206,14 @@ type QueryServer interface {
//
// Since: cosmos-sdk 0.46
SpendableBalances(context.Context, *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error)
// SpendableBalanceByDenom queries the spendable balance of a single denom for
// a single account.
//
// When called from another module, this query might consume a high amount of
// gas if the pagination field is incorrectly set.
//
// Since: cosmos-sdk 0.47
SpendableBalanceByDenom(context.Context, *QuerySpendableBalanceByDenomRequest) (*QuerySpendableBalanceByDenomResponse, error)
// TotalSupply queries the total supply of all coins.
//
// When called from another module, this query might consume a high amount of
@@ -238,6 +263,9 @@ func (UnimplementedQueryServer) AllBalances(context.Context, *QueryAllBalancesRe
func (UnimplementedQueryServer) SpendableBalances(context.Context, *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SpendableBalances not implemented")
}
func (UnimplementedQueryServer) SpendableBalanceByDenom(context.Context, *QuerySpendableBalanceByDenomRequest) (*QuerySpendableBalanceByDenomResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SpendableBalanceByDenom not implemented")
}
func (UnimplementedQueryServer) TotalSupply(context.Context, *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method TotalSupply not implemented")
}
@@ -326,6 +354,24 @@ func _Query_SpendableBalances_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
func _Query_SpendableBalanceByDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuerySpendableBalanceByDenomRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).SpendableBalanceByDenom(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.bank.v1beta1.Query/SpendableBalanceByDenom",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).SpendableBalanceByDenom(ctx, req.(*QuerySpendableBalanceByDenomRequest))
}
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 {
@@ -471,6 +517,10 @@ var Query_ServiceDesc = grpc.ServiceDesc{
MethodName: "SpendableBalances",
Handler: _Query_SpendableBalances_Handler,
},
{
MethodName: "SpendableBalanceByDenom",
Handler: _Query_SpendableBalanceByDenom_Handler,
},
{
MethodName: "TotalSupply",
Handler: _Query_TotalSupply_Handler,