mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
Merge pull request #1074 from ripple/update-bignumber
update bignumber dependency
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
"dependencies": {
|
||||
"@types/lodash": "^4.14.136",
|
||||
"@types/ws": "^3.2.0",
|
||||
"bignumber.js": "^4.1.0",
|
||||
"bignumber.js": "^9.0.0",
|
||||
"https-proxy-agent": "^3.0.0",
|
||||
"jsonschema": "1.2.2",
|
||||
"lodash": "^4.17.4",
|
||||
|
||||
@@ -93,7 +93,7 @@ export const computeTrustlineHash = (address1: string, address2: string, currenc
|
||||
const address1Hex = addressToHex(address1)
|
||||
const address2Hex = addressToHex(address2)
|
||||
|
||||
const swap = (new BigNumber(address1Hex, 16)).greaterThan(
|
||||
const swap = (new BigNumber(address1Hex, 16)).isGreaterThan(
|
||||
new BigNumber(address2Hex, 16))
|
||||
const lowAddressHex = swap ? address2Hex : address1Hex
|
||||
const highAddressHex = swap ? address1Hex : address2Hex
|
||||
|
||||
@@ -83,7 +83,7 @@ function xrpToDrops(xrp: string | BigNumber): string {
|
||||
` too many decimal places.`)
|
||||
}
|
||||
|
||||
return (new BigNumber(xrp)).times(1000000.0).floor().toString(10)
|
||||
return (new BigNumber(xrp)).times(1000000.0).integerValue(BigNumber.ROUND_FLOOR).toString(10)
|
||||
}
|
||||
|
||||
function toRippledAmount(amount: Amount): RippledAmount {
|
||||
|
||||
@@ -17,7 +17,7 @@ export type FormattedAccountOrder = {
|
||||
// TODO: remove this function once rippled provides quality directly
|
||||
function computeQuality(takerGets, takerPays) {
|
||||
const quotient = new BigNumber(takerPays.value).dividedBy(takerGets.value)
|
||||
return quotient.toDigits(16, BigNumber.ROUND_HALF_UP).toString()
|
||||
return quotient.precision(16, BigNumber.ROUND_HALF_UP).toString()
|
||||
}
|
||||
|
||||
// rippled 'account_offers' returns a different format for orders than 'tx'
|
||||
|
||||
@@ -8,7 +8,7 @@ function parseField(info, value) {
|
||||
return Buffer.from(value, 'hex').toString('ascii')
|
||||
}
|
||||
if (info.shift) {
|
||||
return (new BigNumber(value)).shift(-info.shift).toNumber()
|
||||
return (new BigNumber(value)).shiftedBy(-info.shift).toNumber()
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ function adjustQualityForXRP(
|
||||
const denominatorShift = (takerGetsCurrency === 'XRP' ? -6 : 0)
|
||||
const shift = numeratorShift - denominatorShift
|
||||
return shift === 0 ? quality :
|
||||
(new BigNumber(quality)).shift(shift).toString()
|
||||
(new BigNumber(quality)).shiftedBy(shift).toString()
|
||||
}
|
||||
|
||||
function parseQuality(quality?: number|null): number|undefined {
|
||||
if (typeof quality !== 'number') {
|
||||
return undefined
|
||||
}
|
||||
return (new BigNumber(quality)).shift(-9).toNumber()
|
||||
return (new BigNumber(quality)).shiftedBy(-9).toNumber()
|
||||
}
|
||||
|
||||
function parseTimestamp(rippleTime?: number|null): string|undefined {
|
||||
|
||||
@@ -73,7 +73,7 @@ function addDirectXrpPath(paths: RippledPathsResponse, xrpBalance: string
|
||||
// Add XRP "path" only if the source acct has enough XRP to make the payment
|
||||
const destinationAmount = paths.destination_amount
|
||||
// @ts-ignore: destinationAmount can be a currency amount object! Fix!
|
||||
if ((new BigNumber(xrpBalance)).greaterThanOrEqualTo(destinationAmount)) {
|
||||
if ((new BigNumber(xrpBalance)).isGreaterThanOrEqualTo(destinationAmount)) {
|
||||
paths.alternatives.unshift({
|
||||
paths_computed: [],
|
||||
source_amount: paths.destination_amount
|
||||
|
||||
@@ -62,7 +62,7 @@ function setTransactionFields(txJSON: utils.TransactionJSON, input: FormattedSet
|
||||
*/
|
||||
|
||||
function convertTransferRate(transferRate: number): number {
|
||||
return (new BigNumber(transferRate)).shift(9).toNumber()
|
||||
return (new BigNumber(transferRate)).shiftedBy(9).toNumber()
|
||||
}
|
||||
|
||||
function formatSignerEntry(signer: WeightedSigner): object {
|
||||
|
||||
@@ -183,7 +183,7 @@ function checkTxSerialization(serialized: string, tx: utils.TransactionJSON): vo
|
||||
function checkFee(api: RippleAPI, txFee: string): void {
|
||||
const fee = new BigNumber(txFee)
|
||||
const maxFeeDrops = xrpToDrops(api._maxFeeXRP)
|
||||
if (fee.greaterThan(maxFeeDrops)) {
|
||||
if (fee.isGreaterThan(maxFeeDrops)) {
|
||||
throw new utils.common.errors.ValidationError(
|
||||
`"Fee" should not exceed "${maxFeeDrops}". ` +
|
||||
'To use a higher fee, set `maxFeeXRP` in the RippleAPI constructor.'
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import {RippleAPI} from '..'
|
||||
|
||||
function convertQuality(quality) {
|
||||
return (new BigNumber(quality)).shift(9).truncated().toNumber()
|
||||
return (new BigNumber(quality)).shiftedBy(9).integerValue(BigNumber.ROUND_DOWN).toNumber()
|
||||
}
|
||||
|
||||
function createTrustlineTransaction(account: string,
|
||||
|
||||
@@ -218,7 +218,7 @@ function prepareTransaction(txJSON: TransactionJSON, api: RippleAPI,
|
||||
instructions.signersCount + 1
|
||||
if (instructions.fee !== undefined) {
|
||||
const fee = new BigNumber(instructions.fee)
|
||||
if (fee.greaterThan(api._maxFeeXRP)) {
|
||||
if (fee.isGreaterThan(api._maxFeeXRP)) {
|
||||
return Promise.reject(new ValidationError(`Fee of ${fee.toString(10)} XRP exceeds ` +
|
||||
`max of ${api._maxFeeXRP} XRP. To use this fee, increase ` +
|
||||
'`maxFeeXRP` in the RippleAPI constructor.'))
|
||||
|
||||
@@ -3636,7 +3636,7 @@ describe('RippleAPI', function () {
|
||||
.dividedBy(order.specification.quantity.value)
|
||||
.toString();
|
||||
}
|
||||
assert((new BigNumber(rate)).greaterThanOrEqualTo(previousRate),
|
||||
assert((new BigNumber(rate)).isGreaterThanOrEqualTo(previousRate),
|
||||
'Rates must be sorted from least to greatest: ' +
|
||||
rate + ' should be >= ' + previousRate);
|
||||
previousRate = rate;
|
||||
@@ -3894,7 +3894,7 @@ describe('RippleAPI', function () {
|
||||
.dividedBy(order.specification.quantity.value)
|
||||
.toString();
|
||||
}
|
||||
assert((new BigNumber(rate)).greaterThanOrEqualTo(previousRate),
|
||||
assert((new BigNumber(rate)).isGreaterThanOrEqualTo(previousRate),
|
||||
'Rates must be sorted from least to greatest: ' +
|
||||
rate + ' should be >= ' + previousRate);
|
||||
previousRate = rate;
|
||||
|
||||
@@ -3437,7 +3437,7 @@ describe('X-address Usage', function () {
|
||||
.dividedBy(order.specification.quantity.value)
|
||||
.toString();
|
||||
}
|
||||
assert((new BigNumber(rate)).greaterThanOrEqualTo(previousRate),
|
||||
assert((new BigNumber(rate)).isGreaterThanOrEqualTo(previousRate),
|
||||
'Rates must be sorted from least to greatest: ' +
|
||||
rate + ' should be >= ' + previousRate);
|
||||
previousRate = rate;
|
||||
@@ -3695,7 +3695,7 @@ describe('X-address Usage', function () {
|
||||
.dividedBy(order.specification.quantity.value)
|
||||
.toString();
|
||||
}
|
||||
assert((new BigNumber(rate)).greaterThanOrEqualTo(previousRate),
|
||||
assert((new BigNumber(rate)).isGreaterThanOrEqualTo(previousRate),
|
||||
'Rates must be sorted from least to greatest: ' +
|
||||
rate + ' should be >= ' + previousRate);
|
||||
previousRate = rate;
|
||||
|
||||
@@ -568,10 +568,10 @@ bignumber.js@8.1.1:
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-8.1.1.tgz#4b072ae5aea9c20f6730e4e5d529df1271c4d885"
|
||||
integrity sha512-QD46ppGintwPGuL1KqmwhR0O+N2cZUg8JG/VzwI2e28sM9TqHjQB10lI4QAaMHVbLzwVLLAwEglpKPViWX+5NQ==
|
||||
|
||||
bignumber.js@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1"
|
||||
integrity sha512-eJzYkFYy9L4JzXsbymsFn3p54D+llV27oTQ+ziJG7WFRheJcNZilgVXMG0LoZtlQSKBsJdWtLFqOD0u+U0jZKA==
|
||||
bignumber.js@^9.0.0:
|
||||
version "9.0.0"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075"
|
||||
integrity sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==
|
||||
|
||||
binary-extensions@^1.0.0:
|
||||
version "1.13.1"
|
||||
|
||||
Reference in New Issue
Block a user