fix(account): fix get invalid account balance not return error
This commit is contained in:
parent
310b81a0c7
commit
cbd2eb7bba
|
@ -3,6 +3,7 @@ package grpc
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/meshplus/bitxhub-kit/types"
|
"github.com/meshplus/bitxhub-kit/types"
|
||||||
"github.com/meshplus/bitxhub-model/pb"
|
"github.com/meshplus/bitxhub-model/pb"
|
||||||
|
@ -16,6 +17,10 @@ type Account struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cbs *ChainBrokerService) GetAccountBalance(ctx context.Context, req *pb.Address) (*pb.Response, error) {
|
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)
|
addr := types.String2Address(req.Address)
|
||||||
|
|
||||||
account := cbs.api.Account().GetAccount(addr)
|
account := cbs.api.Account().GetAccount(addr)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -22,7 +22,7 @@ require (
|
||||||
github.com/libp2p/go-libp2p-core v0.3.0
|
github.com/libp2p/go-libp2p-core v0.3.0
|
||||||
github.com/magiconair/properties v1.8.1
|
github.com/magiconair/properties v1.8.1
|
||||||
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20200728032028-8dba332fa0ed
|
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/meshplus/bitxhub-model v1.0.0-rc4.0.20200724062514-baa44473e4d8
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
github.com/multiformats/go-multiaddr v0.2.0
|
github.com/multiformats/go-multiaddr v0.2.0
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -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.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 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.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.20200729105047-4407a5e4e168 h1:OUZuHqVUNMPMkpSc9cxAkUlsRDTb25l8NtOsps3sF74=
|
||||||
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/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 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.20200514093243-7e8ae60d1c19/go.mod h1:QK8aACbxtZEA3Hk1BOCirW0uxMWLsMrLDpWz9FweIKM=
|
||||||
github.com/meshplus/bitxhub-model v1.0.0-rc4.0.20200724062514-baa44473e4d8 h1:FlD+ETNIVTJ3gyceEdqqo6wvBkrYiTfLB6XM0tGH1Yw=
|
github.com/meshplus/bitxhub-model v1.0.0-rc4.0.20200724062514-baa44473e4d8 h1:FlD+ETNIVTJ3gyceEdqqo6wvBkrYiTfLB6XM0tGH1Yw=
|
||||||
|
|
Loading…
Reference in New Issue