Giter Site home page Giter Site logo

Move to BN.js about mycrypto HOT 5 CLOSED

crptm avatar crptm commented on August 20, 2024
Move to BN.js

from mycrypto.

Comments (5)

wbobeirne avatar wbobeirne commented on August 20, 2024 2

Looks like this task is going to be a mild pain. I did a little audit of everywhere we use it (As of 8854d42)

We'll likely need to implement a big-numberless way of converting a decimal string into a wei unit string. Fortunately if we switch over to the libs/units classes, I think it should make the bulk of future bignumber handling pretty well contained, aside from gas and a few other instances.

bignumber.js usage

File Conversion steps
common/actions/deterministicWallets.js 1:1 (Type only)
common/actions/wallet.js 1:1 (Type only)
common/libs/erc20.js 1:1
common/libs/transaction.js Rework to only use wei
common/libs/units.js Rework to force everything into wei / use classes
common/reducers/wallet.js 1:1 (Type only)
common/selectors/wallet.js 1:1
common/utils/formatters.js Likely needs to be moved into libs/units.js, assumes decimals
spec/libs/erc20.spec.js Reworked to not use decimals
spec/libs/contract.spec.js Unused
spec/libs/units.spec.js Reworked to not make bigs from decimals
spec/reducers/wallet.spec.js 1:1
spec/utils/formatters.spec.js Mostly removed, see common/utils/formatter.js
.../BalanceSidebar/AccountInfo.jsx 1:1 (Type only)
.../BalanceSidebar/EquivalentValues.jsx Unused
.../BalanceSidebar/index.jsx Unused
common/libs/nodes/INode.js 1:1 (Type only)
common/libs/wallet/trezor.js Uncertain, not sure what values a transaction v can be
.../BalanceSidebar/TokenBalances/TokenRow.jsx 1:1 (Type only)
.../SendTransaction/index.jsx 1:1
common/libs/nodes/rpc/index.js I think token values may need to be reworked, unsure if they come back in "wei"
common/libs/nodes/rpc/utils.js 1:1 (Type only)
spec/libs/nodes/rpc/rpc.spec.js 1:1
.../SendTransaction/components/ConfirmationModal.jsx Will need to stop using the toUnit function

from mycrypto.

dternyak avatar dternyak commented on August 20, 2024

@wbobeirne Is this something we still want to do?

from mycrypto.

crptm avatar crptm commented on August 20, 2024

We want to do it. We already ship it for ethereumjs, it is much more lightweight and wasn't noticed in infinite loops :)

from mycrypto.

dternyak avatar dternyak commented on August 20, 2024

It seems ethereumjs libraries have settled on using BN.js as a standard for handling large numbers in JavaScript.

This is not to be confused with bignumber.js

Examples:

Additionally, the MetaMask team uses BN.js.

In the interest of following this de-jure standard, we should switch to BN.js as well. To solve the issue of BN.js not supporting decimimals, amount state will be kept in Wei.

from mycrypto.

wbobeirne avatar wbobeirne commented on August 20, 2024

Going to hold off on this until @HenryNguyen5 finishes the typescript changeover, to reduce conflicts.

from mycrypto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.