mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 01:08:02 +00:00
feat: remove decimal.js and big-integer (#2379)
Reduces the bundle size by 8% (41kb) BigInteger is now well supported so the library is no longer needed. BigNumber was already being used by xrpl and they had almost identical interfaces as they are both based on Java.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const { coreTypes } = require('../src/types')
|
||||
const Decimal = require('decimal.js')
|
||||
const BigNumber = require('bignumber.js')
|
||||
|
||||
const { encodeAccountID } = require('ripple-address-codec')
|
||||
const { binary } = require('../src/coretypes')
|
||||
@@ -26,7 +26,7 @@ function assertEqualAmountJSON(actual, expected) {
|
||||
expect(actual.issuer).toEqual(expected.issuer)
|
||||
expect(
|
||||
actual.value === expected.value ||
|
||||
new Decimal(actual.value).equals(new Decimal(expected.value)),
|
||||
new BigNumber(actual.value).eq(new BigNumber(expected.value)),
|
||||
).toBe(true)
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ function amountParsingTests() {
|
||||
const json = toJSON(value)
|
||||
assertEqualAmountJSON(json, f.test_json)
|
||||
if (f.exponent) {
|
||||
const exponent = new Decimal(json.value)
|
||||
const exponent = new BigNumber(json.value)
|
||||
expect(exponent.e - 15).toEqual(f.exponent)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ const { encode, decode } = require('../src')
|
||||
const { makeParser, BytesList, BinarySerializer } = binary
|
||||
const { coreTypes } = require('../src/types')
|
||||
const { UInt8, UInt16, UInt32, UInt64, STObject } = coreTypes
|
||||
const bigInt = require('big-integer')
|
||||
const { Buffer } = require('buffer/')
|
||||
|
||||
const { loadFixture } = require('./utils')
|
||||
@@ -167,7 +166,7 @@ check(UInt64, 0xfeffffff, [0, 0, 0, 0, 254, 255, 255, 255])
|
||||
check(UInt64, -1, 'throws')
|
||||
check(UInt64, 0, [0, 0, 0, 0, 0, 0, 0, 0])
|
||||
check(UInt64, 1, [0, 0, 0, 0, 0, 0, 0, 1])
|
||||
check(UInt64, bigInt(1), [0, 0, 0, 0, 0, 0, 0, 1])
|
||||
check(UInt64, BigInt(1), [0, 0, 0, 0, 0, 0, 0, 1])
|
||||
|
||||
function deliverMinTest() {
|
||||
test('can serialize DeliverMin', () => {
|
||||
|
||||
Reference in New Issue
Block a user