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:
commit
705637b69f
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user