Skip to content

Commit

Permalink
Merge pull request meshplus#134 from meshplus/fix/account-balance
Browse files Browse the repository at this point in the history
fix(account): fix get invalid account balance not return error
  • Loading branch information
0xforever9 authored Jul 29, 2020
2 parents 99f3b01 + cbd2eb7 commit bba753c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions api/grpc/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package grpc
import (
"context"
"encoding/json"
"fmt"

"github.com/meshplus/bitxhub-kit/types"
"github.com/meshplus/bitxhub-model/pb"
Expand All @@ -16,6 +17,10 @@ type Account struct {
}

func (cbs *ChainBrokerService) GetAccountBalance(ctx context.Context, req *pb.Address) (*pb.Response, error) {
if !types.IsValidAddressByte([]byte(req.Address)) {
return nil, fmt.Errorf("invalid account address: %v", req.Address)
}

addr := types.String2Address(req.Address)

account := cbs.api.Account().GetAccount(addr)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/libp2p/go-libp2p-core v0.3.0
github.com/magiconair/properties v1.8.1
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20200728032028-8dba332fa0ed
github.com/meshplus/bitxhub-kit v1.0.1-0.20200728033443-0aaa0b3cf4c2
github.com/meshplus/bitxhub-kit v1.0.1-0.20200729105047-4407a5e4e168
github.com/meshplus/bitxhub-model v1.0.0-rc4.0.20200724062514-baa44473e4d8
github.com/mitchellh/go-homedir v1.1.0
github.com/multiformats/go-multiaddr v0.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ github.com/meshplus/bitxhub-kit v1.0.0-rc1 h1:gNi8IFU5CMHT3KE2I4ACj5alMW9h/4cV8x
github.com/meshplus/bitxhub-kit v1.0.0-rc1/go.mod h1:ra/AhOkPvpElI+wXrB9G6DjdcrdxFU3vMwA5MYKr9D0=
github.com/meshplus/bitxhub-kit v1.0.1-0.20200727075316-ea098a3c3411 h1:iA/VUBsZqsk2ZB9KrJRLl8X0tPUQqle2c7HRCHLFmDE=
github.com/meshplus/bitxhub-kit v1.0.1-0.20200727075316-ea098a3c3411/go.mod h1:8Pprmnq+2fFi5kJP0qcbwPl/fe22nro0OamjtwD0LJM=
github.com/meshplus/bitxhub-kit v1.0.1-0.20200728033443-0aaa0b3cf4c2 h1:bkArMGFQdZW3WO2A3Fx+J6vdV/ISXFBCJP3RTXwgJzk=
github.com/meshplus/bitxhub-kit v1.0.1-0.20200728033443-0aaa0b3cf4c2/go.mod h1:8Pprmnq+2fFi5kJP0qcbwPl/fe22nro0OamjtwD0LJM=
github.com/meshplus/bitxhub-kit v1.0.1-0.20200729105047-4407a5e4e168 h1:OUZuHqVUNMPMkpSc9cxAkUlsRDTb25l8NtOsps3sF74=
github.com/meshplus/bitxhub-kit v1.0.1-0.20200729105047-4407a5e4e168/go.mod h1:8Pprmnq+2fFi5kJP0qcbwPl/fe22nro0OamjtwD0LJM=
github.com/meshplus/bitxhub-model v1.0.0-rc4.0.20200514093243-7e8ae60d1c19 h1:D0n0/NqaueI6r+/cJIjYzWwjZ9j/5l36r/c8MYqTdXg=
github.com/meshplus/bitxhub-model v1.0.0-rc4.0.20200514093243-7e8ae60d1c19/go.mod h1:QK8aACbxtZEA3Hk1BOCirW0uxMWLsMrLDpWz9FweIKM=
github.com/meshplus/bitxhub-model v1.0.0-rc4.0.20200724062514-baa44473e4d8 h1:FlD+ETNIVTJ3gyceEdqqo6wvBkrYiTfLB6XM0tGH1Yw=
Expand Down

0 comments on commit bba753c

Please sign in to comment.