Feat: getStatus pazuz wallet
This commit is contained in:
parent
845c885aad
commit
da7cfd02b0
1 changed files with 20 additions and 48 deletions
|
|
@ -31,7 +31,7 @@ function balance (account, cryptoCode, settings, operatorId) {
|
|||
})
|
||||
})
|
||||
.then(({ data }) => {
|
||||
if (data.error) throw new Error(JSON.stringify({ errorCode: data.error.errorCode, message: data.error.message }))
|
||||
if (data.error) throw new Error(JSON.stringify(data.error))
|
||||
return BN(data.balance)
|
||||
})
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ function sendCoins (account, tx, settings, operatorId) {
|
|||
})
|
||||
.then(({ data }) => {
|
||||
if (data.error && data.error.errorCode === 'sc-001') throw new E.InsufficientFundsError()
|
||||
else if (data.error) throw new Error(JSON.stringify({ errorCode: data.error.errorCode, message: data.error.message }))
|
||||
else if (data.error) throw new Error(JSON.stringify(data.error))
|
||||
const fee = BN(data.fee).round()
|
||||
const txid = data.txid
|
||||
return { txid, fee }
|
||||
|
|
@ -70,57 +70,30 @@ function newAddress (account, info, tx, settings, operatorId) {
|
|||
})
|
||||
}
|
||||
|
||||
function newFunding (account, cryptoCode, settings, operatorId) {
|
||||
return axios.post('/newFunding', {
|
||||
account,
|
||||
cryptoCode,
|
||||
settings,
|
||||
operatorId
|
||||
}).catch(console.error)
|
||||
}
|
||||
|
||||
function getStatus (account, tx, requested, settings, operatorId) {
|
||||
return axios.post('/getStatus', {
|
||||
account,
|
||||
tx,
|
||||
requested,
|
||||
settings,
|
||||
operatorId
|
||||
}).catch(console.error)
|
||||
}
|
||||
|
||||
function sweep (account, cryptoCode, hdIndex, settings, operatorId) {
|
||||
return axios.post('/sweep', {
|
||||
account,
|
||||
cryptoCode,
|
||||
hdIndex,
|
||||
settings,
|
||||
operatorId
|
||||
}).catch(console.error)
|
||||
}
|
||||
|
||||
function cryptoNetwork (account, cryptoCode, settings, operatorId) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => axios.post('/cryptoNetwork', {
|
||||
account,
|
||||
cryptoCode,
|
||||
settings,
|
||||
operatorId
|
||||
}))
|
||||
return checkCryptoCode(tx.cryptoCode)
|
||||
.then(() => axios.get(`/balance/${tx.toAddress}?cryptoCode=${tx.cryptoCode}`))
|
||||
.then(({ data }) => {
|
||||
if (data.error && data.error.errorCode === 'cn-001') return false
|
||||
else if (data.error) throw new Error(JSON.stringify({ error: data.error, message: data.error.message }))
|
||||
return data.cryptoNetwork
|
||||
if (data.error) throw new Error(JSON.stringify(data.error))
|
||||
const confirmed = BN(data.confirmedBalance)
|
||||
const pending = BN(data.pendingBalance)
|
||||
if (confirmed.gte(requested)) return { receivedCryptoAtoms: confirmed, status: 'confirmed' }
|
||||
if (pending.gte(requested)) return { receivedCryptoAtoms: pending, status: 'authorized' }
|
||||
if (pending.gt(0)) return { receivedCryptoAtoms: pending, status: 'insufficientFunds' }
|
||||
return { receivedCryptoAtoms: pending, status: 'notSeen' }
|
||||
})
|
||||
}
|
||||
|
||||
function newFunding (account, cryptoCode, settings, operatorId) {
|
||||
throw new E.NotImplementedError()
|
||||
}
|
||||
|
||||
function sweep (account, cryptoCode, hdIndex, settings, operatorId) {
|
||||
throw new E.NotImplementedError()
|
||||
}
|
||||
|
||||
function isStrictAddress (cryptoCode, toAddress, settings, operatorId) {
|
||||
return axios.post('/isStrictAddress', {
|
||||
cryptoCode,
|
||||
toAddress,
|
||||
settings,
|
||||
operatorId
|
||||
}).catch(console.error)
|
||||
throw new E.NotImplementedError()
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -131,6 +104,5 @@ module.exports = {
|
|||
getStatus,
|
||||
sweep,
|
||||
supportsHd: true,
|
||||
cryptoNetwork,
|
||||
isStrictAddress
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue