Skip to content

Commit

Permalink
fix: bank gRPC error status codes (#7814)
Browse files Browse the repository at this point in the history
Co-authored-by: SaReN <sahithnarahari@gmail.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
  • Loading branch information
3 people authored Dec 4, 2020
1 parent 1b00c01 commit 7ec3bcd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions x/bank/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (k BaseKeeper) Balance(ctx context.Context, req *types.QueryBalanceRequest)
sdkCtx := sdk.UnwrapSDKContext(ctx)
address, err := sdk.AccAddressFromBech32(req.Address)
if err != nil {
return nil, err
return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error())
}

balance := k.GetBalance(sdkCtx, address, req.Denom)
Expand All @@ -45,9 +45,13 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances
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, err
return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error())
}

sdkCtx := sdk.UnwrapSDKContext(ctx)
Expand Down

0 comments on commit 7ec3bcd

Please sign in to comment.