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 }) => {
|
.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)
|
return BN(data.balance)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +49,7 @@ function sendCoins (account, tx, settings, operatorId) {
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
if (data.error && data.error.errorCode === 'sc-001') throw new E.InsufficientFundsError()
|
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 fee = BN(data.fee).round()
|
||||||
const txid = data.txid
|
const txid = data.txid
|
||||||
return { txid, fee }
|
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) {
|
function getStatus (account, tx, requested, settings, operatorId) {
|
||||||
return axios.post('/getStatus', {
|
return checkCryptoCode(tx.cryptoCode)
|
||||||
account,
|
.then(() => axios.get(`/balance/${tx.toAddress}?cryptoCode=${tx.cryptoCode}`))
|
||||||
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
|
|
||||||
}))
|
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
if (data.error && data.error.errorCode === 'cn-001') return false
|
if (data.error) throw new Error(JSON.stringify(data.error))
|
||||||
else if (data.error) throw new Error(JSON.stringify({ error: data.error, message: data.error.message }))
|
const confirmed = BN(data.confirmedBalance)
|
||||||
return data.cryptoNetwork
|
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) {
|
function isStrictAddress (cryptoCode, toAddress, settings, operatorId) {
|
||||||
return axios.post('/isStrictAddress', {
|
throw new E.NotImplementedError()
|
||||||
cryptoCode,
|
|
||||||
toAddress,
|
|
||||||
settings,
|
|
||||||
operatorId
|
|
||||||
}).catch(console.error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
@ -131,6 +104,5 @@ module.exports = {
|
||||||
getStatus,
|
getStatus,
|
||||||
sweep,
|
sweep,
|
||||||
supportsHd: true,
|
supportsHd: true,
|
||||||
cryptoNetwork,
|
|
||||||
isStrictAddress
|
isStrictAddress
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue