Skip to content

Commit

Permalink
Remove setting BigNumber.DEBUG to true to avoid global impact.
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Feb 9, 2024
1 parent 29875cb commit c793e10
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

### Breaking Changes
* Starting from **v10.0.0-beta.0**, we set [`BigNumber.DEBUG`](https://mikemcl.github.io/bignumber.js/#debug) in `bignumber.js` to `true`, which would affect all code using `BigNumber`. In this release, we have removed the relevant setting, meaning that `BigNumber.DEBUG` will remain at its default setting, which is not enabling DEBUG mode. ([#729](https://github.com/stellar/js-stellar-base/pull/729)).

## [`v10.0.2`](https://github.com/stellar/js-stellar-base/compare/v10.0.1...v10.0.2)

Expand Down
2 changes: 1 addition & 1 deletion src/account.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BigNumber from 'bignumber.js';
import BigNumber from './util/bignumber';

import { StrKey } from './strkey';

Expand Down
3 changes: 0 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* eslint-disable import/no-import-module-exports */
import BigNumber from 'bignumber.js';
import xdr from './xdr';

BigNumber.DEBUG = true; // gives us exceptions on bad constructor values

export { xdr };
export { hash } from './hashing';
export { sign, verify, FastSigning } from './signing';
Expand Down
2 changes: 1 addition & 1 deletion src/memo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UnsignedHyper } from '@stellar/js-xdr';
import BigNumber from 'bignumber.js';
import BigNumber from './util/bignumber';
import xdr from './xdr';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/operation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-bitwise */

import { Hyper } from '@stellar/js-xdr';
import BigNumber from 'bignumber.js';
import BigNumber from './util/bignumber';
import { trimEnd } from './util/util';
import { best_r } from './util/continued_fraction';
import { Asset } from './asset';
Expand Down
2 changes: 1 addition & 1 deletion src/operations/bump_sequence.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hyper } from '@stellar/js-xdr';
import BigNumber from 'bignumber.js';
import BigNumber from '../util/bignumber';
import xdr from '../xdr';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/operations/change_trust.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hyper } from '@stellar/js-xdr';
import BigNumber from 'bignumber.js';
import BigNumber from '../util/bignumber';
import xdr from '../xdr';
import { Asset } from '../asset';
import { LiquidityPoolAsset } from '../liquidity_pool_asset';
Expand Down
2 changes: 1 addition & 1 deletion src/transaction_builder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UnsignedHyper } from '@stellar/js-xdr';
import BigNumber from 'bignumber.js';
import BigNumber from './util/bignumber';

import xdr from './xdr';

Expand Down
7 changes: 7 additions & 0 deletions src/util/bignumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import OriginBigNumber from 'bignumber.js';

const BigNumber = OriginBigNumber.clone();

BigNumber.DEBUG = true; // gives us exceptions on bad constructor values

export default BigNumber;
2 changes: 1 addition & 1 deletion src/util/continued_fraction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BigNumber from 'bignumber.js';
import BigNumber from './bignumber';

// eslint-disable-next-line no-bitwise
const MAX_INT = ((1 << 31) >>> 0) - 1;
Expand Down
12 changes: 12 additions & 0 deletions test/unit/util/bignumber_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import BigNumber from 'bignumber.js';
import SDKBigNumber from '../../../src/util/bignumber';

describe('bignumber', function () {
it('Debug mode has been enabled in the cloned bignumber.', function () {
expect(SDKBigNumber.DEBUG).to.be.true;
});

it('Debug mode has been disabled (default setting) in the original bignumber.', function () {
expect(BigNumber.DEBUG).to.be.undefined;
});
});

0 comments on commit c793e10

Please sign in to comment.