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

@ -35,13 +35,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
@ -52,14 +52,14 @@ 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)
return checkCryptoCode(cryptoCode)
.then(() => fetch('sendtoaddress', [toAddress, coins]))
.then((txId) => fetch('gettransaction', [txId]))
.then((res) => _.pick(['fee', 'txid'], res))
.then((pickedObj) => {
return {
fee: BN(pickedObj.fee).abs().shift(unitScale).round(),
fee: new BN(pickedObj.fee).abs().shiftedBy(unitScale).decimalPlaces(0),
txid: pickedObj.txid
}
})
@ -76,7 +76,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) {