MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.18k stars 1.12k forks source link

[Bug]: Different big number libraries being used #9850

Open infiniteflower opened 5 months ago

infiniteflower commented 5 months ago

Describe the bug

We have multiple BigNumber libraries in use right now, bignumber.js, bn.js, etc

You can see this from app/util/number/index.js

import { BN, stripHexPrefix } from 'ethereumjs-util';
import { utils as ethersUtils } from 'ethers';
import convert from 'ethjs-unit';
import {
  BNToHex,
  hexToBN as controllerHexToBN,
} from '@metamask/controller-utils';
import numberToBN from 'number-to-bn';
import BigNumber from 'bignumber.js';

Would be good to settle on a single library.

Expected behavior

A singular BigNumber library should be used to prevent incompatibilities or strange/unexpected behavior from happening.

Screenshots/Recordings

No response

Steps to reproduce

n/a

Error messages or log output

No response

Version

7.24.0

Build type

None

Device

Android, iOS

Operating system

iOS, Android

Additional context

No response

Severity

No response

NicolasMassart commented 5 months ago

Make sure to check if these multiple libraries were introduced for some reasons or just tech debt.

If it has impact on some other processing we do, for instance in controllers or other libs using BN, we may keep them all but centralise them in the utility file and abstract them so only one interface is used in the app. Then we fix dependencies one at a time.

legobeat commented 1 month ago

Progress on this is being made here: