Merge pull request #448 from filecoin-project/fix/wallet-error

Cleanup GetBalance call and warn if actor does not exist
This commit is contained in:
Whyrusleeping 2019-10-24 21:17:23 +08:00 committed by GitHub
commit 705637b69f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -217,7 +217,10 @@ func (sm *StateManager) GetActor(addr address.Address, ts *types.TipSet) (*types
func (sm *StateManager) GetBalance(addr address.Address, ts *types.TipSet) (types.BigInt, error) {
act, err := sm.GetActor(addr, ts)
if err != nil {
return types.BigInt{}, xerrors.Errorf("get actor: %w", err)
if xerrors.Is(err, types.ErrActorNotFound) {
return types.NewInt(0), nil
}
return types.EmptyInt, xerrors.Errorf("get actor: %w", err)
}
return act.Balance, nil

View File

@ -12,7 +12,7 @@ type FIL BigInt
func (f FIL) String() string {
r := new(big.Rat).SetFrac(f.Int, big.NewInt(build.FilecoinPrecision))
return strings.TrimRight(r.FloatString(18), "0")
return strings.TrimRight(r.FloatString(18), "0.")
}
func ParseFIL(s string) (FIL, error) {