Skip to content

Commit

Permalink
fix: bank gRPC error status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
fdymylja committed Nov 4, 2020
1 parent 71166c8 commit e80ad61
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 e80ad61

Please sign in to comment.