Cleanup GetBalance call and warn if actor does not exist
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
007edf7830
commit
7532f92c98
@ -217,7 +217,7 @@ 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)
|
||||
return types.NewInt(0), xerrors.Errorf("get actor: %w", err)
|
||||
}
|
||||
|
||||
return act.Balance, nil
|
||||
|
@ -3,6 +3,7 @@ package cli
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@ -101,7 +102,10 @@ var walletBalance = &cli.Command{
|
||||
}
|
||||
|
||||
balance, err := api.WalletBalance(ctx, addr)
|
||||
if err != nil {
|
||||
|
||||
if errors.Is(err, types.ErrActorNotFound) {
|
||||
log.Warnf("actor not found with address: %s", addr)
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user