Feat: newAddress route
This commit is contained in:
parent
df37bcc519
commit
845c885aad
1 changed files with 31 additions and 23 deletions
|
|
@ -21,45 +21,53 @@ function checkCryptoCode (cryptoCode) {
|
|||
}
|
||||
|
||||
function balance (account, cryptoCode, settings, operatorId) {
|
||||
return checkCryptoCode(cryptoCode).then(() => {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
return axios.post('/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 }))
|
||||
return BN(data.balance)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function sendCoins (account, tx, settings, operatorId) {
|
||||
const { cryptoCode } = tx
|
||||
return checkCryptoCode(cryptoCode).then(() => {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
return axios.post('/sendCoins', {
|
||||
account,
|
||||
tx,
|
||||
settings,
|
||||
operatorId
|
||||
}).then(({ data }) => {
|
||||
})
|
||||
})
|
||||
.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 }))
|
||||
const fee = BN(data.fee).round()
|
||||
const txid = data.txid
|
||||
return { txid, fee }
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function newAddress (account, info, tx, settings, operatorId) {
|
||||
return axios.post('/newAddress', {
|
||||
return checkCryptoCode(info.cryptoCode)
|
||||
.then(() => axios.post('/newAddress', {
|
||||
account,
|
||||
info,
|
||||
tx,
|
||||
settings,
|
||||
operatorId
|
||||
}).catch(console.error)
|
||||
}))
|
||||
.then(({ data }) => {
|
||||
return data.newAddress
|
||||
})
|
||||
}
|
||||
|
||||
function newFunding (account, cryptoCode, settings, operatorId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue