fix: revert BTC wallet automatic creation
This commit is contained in:
parent
46484957e7
commit
063b9b1dbe
2 changed files with 4 additions and 22 deletions
|
|
@ -20,17 +20,10 @@ function fetch (method, params) {
|
|||
function errorHandle (e) {
|
||||
const err = JSON.parse(e.message)
|
||||
switch (err.code) {
|
||||
case -4:
|
||||
return loadWallet()
|
||||
case -5:
|
||||
return logger.error(`${err}`)
|
||||
case -6:
|
||||
throw new E.InsufficientFundsError()
|
||||
case -18:
|
||||
return createWallet()
|
||||
case -35:
|
||||
// Wallet is already loaded, just return
|
||||
return
|
||||
default:
|
||||
throw e
|
||||
}
|
||||
|
|
@ -38,20 +31,7 @@ function errorHandle (e) {
|
|||
|
||||
function checkCryptoCode (cryptoCode) {
|
||||
if (cryptoCode !== 'BTC') return Promise.reject(new Error('Unsupported crypto: ' + cryptoCode))
|
||||
return Promise.resolve().then(loadWallet)
|
||||
}
|
||||
|
||||
function createWallet () {
|
||||
return fetch('createwallet', ['wallet'])
|
||||
.then(loadWallet)
|
||||
}
|
||||
|
||||
function loadWallet () {
|
||||
return fetch('loadwallet', ['wallet', true])
|
||||
// Catching the error here to suppress error code -35
|
||||
// This improves UX on the initial wallet load and serves as error sink
|
||||
// for wallet creation/loading related issues before actual business logic runs
|
||||
.catch(errorHandle)
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
function accountBalance (cryptoCode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue