better of handling of wallet balance errors
This commit is contained in:
parent
fafac16742
commit
066c278ed8
1 changed files with 10 additions and 0 deletions
|
|
@ -39,10 +39,20 @@ function fetchWallet (settings, cryptoCode) {
|
|||
})
|
||||
}
|
||||
|
||||
const lastBalance = {}
|
||||
|
||||
function balance (settings, cryptoCode) {
|
||||
return fetchWallet(settings, cryptoCode)
|
||||
.then(r => r.wallet.balance(r.account, cryptoCode))
|
||||
.then(balance => ({balance, timestamp: Date.now()}))
|
||||
.then(r => {
|
||||
lastBalance[cryptoCode] = r
|
||||
return r
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
return lastBalance[cryptoCode]
|
||||
})
|
||||
}
|
||||
|
||||
function sendCoins (settings, toAddress, cryptoAtoms, cryptoCode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue