Skip to content

Commit 95908bf

Browse files
committed
x
1 parent 8213ea6 commit 95908bf

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

api/api.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -1697,14 +1697,17 @@ func (api *Server) getProtocolAccount(ctx context.Context, height uint64, addr s
16971697
Height: fmt.Sprintf("%d", height),
16981698
}
16991699
out, err = api.ReadState2(ctx, req)
1700-
if err != nil {
1700+
if err != nil && errors.Cause(err) == codes.NotFound {
1701+
balance = "0"
1702+
} else if err != nil {
17011703
return nil, err
1704+
} else {
1705+
acc := iotextypes.AccountMeta{}
1706+
if err := proto.Unmarshal(out.GetData(), &acc); err != nil {
1707+
return nil, errors.Wrap(err, "failed to unmarshal account meta")
1708+
}
1709+
balance = acc.GetBalance()
17021710
}
1703-
acc := iotextypes.AccountMeta{}
1704-
if err := proto.Unmarshal(out.GetData(), &acc); err != nil {
1705-
return nil, errors.Wrap(err, "failed to unmarshal account meta")
1706-
}
1707-
balance = acc.GetBalance()
17081711
}
17091712
header, err := api.bc.BlockHeaderByHeight(height)
17101713
if err != nil {

0 commit comments

Comments
 (0)