Don't pannic on walletDefAddr with no addrs
This commit is contained in:
parent
ccfec98f96
commit
45ddd8e590
@ -80,7 +80,10 @@ class FullNode extends React.Component {
|
||||
this.setState(() => ({tipset: tipset}))
|
||||
|
||||
const addrss = await this.state.client.call('Filecoin.WalletList', [])
|
||||
const defaultAddr = await this.state.client.call('Filecoin.WalletDefaultAddress', [])
|
||||
let defaultAddr = ""
|
||||
if (addrss.length > 0) {
|
||||
defaultAddr = await this.state.client.call('Filecoin.WalletDefaultAddress', [])
|
||||
}
|
||||
|
||||
const balances = await addrss.map(async addr => {
|
||||
let balance = 0
|
||||
|
@ -2,6 +2,7 @@ package impl
|
||||
|
||||
import (
|
||||
"context"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/api"
|
||||
"github.com/filecoin-project/go-lotus/chain"
|
||||
@ -132,6 +133,9 @@ func (a *FullNodeAPI) WalletDefaultAddress(ctx context.Context) (address.Address
|
||||
if err != nil {
|
||||
return address.Undef, err
|
||||
}
|
||||
if len(addrs) == 0 {
|
||||
return address.Undef, xerrors.New("no addresses in wallet")
|
||||
}
|
||||
|
||||
// TODO: store a default address in the config or 'wallet' portion of the repo
|
||||
return addrs[0], nil
|
||||
|
Loading…
Reference in New Issue
Block a user