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