chore: update big number package

This commit is contained in:
José Oliveira 2021-06-15 22:34:36 +01:00 committed by Josh Harvey
parent 8aa18dd21c
commit ea44478b48
30 changed files with 186 additions and 144 deletions

View file

@ -37,13 +37,13 @@ function checkCryptoCode (cryptoCode) {
function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getwalletinfo'))
.then(({ balance }) => BN(balance).shift(unitScale).round())
.then(({ balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0))
}
function accountUnconfirmedBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getwalletinfo'))
.then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round())
.then(({ unconfirmed_balance: balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0))
}
// We want a balance that includes all spends (0 conf) but only deposits that
@ -54,7 +54,7 @@ function balance (account, cryptoCode, settings, operatorId) {
function sendCoins (account, tx, settings, operatorId) {
const { toAddress, cryptoAtoms, cryptoCode } = tx
const coins = cryptoAtoms.shift(-unitScale).toFixed(8)
const coins = cryptoAtoms.shiftedBy(-unitScale).toFixed(8)
const checkSendStatus = function (opid) {
return new Promise((resolve, reject) => {
fetch('z_getoperationstatus', [[opid]])
@ -87,7 +87,7 @@ function sendCoins (account, tx, settings, operatorId) {
})
.then((pickedObj) => {
return {
fee: BN(pickedObj.fee).abs().shift(unitScale).round(),
fee: new BN(pickedObj.fee).abs().shiftedBy(unitScale).decimalPlaces(0),
txid: pickedObj.txid
}
})
@ -104,7 +104,7 @@ function newAddress (account, info, tx, settings, operatorId) {
function addressBalance (address, confs) {
return fetch('getreceivedbyaddress', [address, confs])
.then(r => BN(r).shift(unitScale).round())
.then(r => new BN(r).shiftedBy(unitScale).decimalPlaces(0))
}
function confirmedBalance (address, cryptoCode) {