chore: update big number package
This commit is contained in:
parent
8aa18dd21c
commit
ea44478b48
30 changed files with 186 additions and 144 deletions
|
|
@ -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,7 +52,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)
|
||||
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('sendtoaddress', [toAddress, coins]))
|
||||
|
|
@ -60,7 +60,7 @@ function sendCoins (account, tx, settings, operatorId) {
|
|||
.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
|
||||
}
|
||||
})
|
||||
|
|
@ -77,7 +77,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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue