Comments (5)
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.
@wbobeirne Is this something we still want to do?
from mycrypto.
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.
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:
- https://github.com/ethereumjs/ethereumjs-util/blob/f53d34aec3213c39d117ddabf25dcbddca13ce83/index.js#L5
- https://github.com/ethereumjs/ethereumjs-abi/blob/4a33f233cc6a2f50c9a8ae59684ba631c4b91825/package.json#L7
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.
Going to hold off on this until @HenryNguyen5 finishes the typescript changeover, to reduce conflicts.
from mycrypto.
Related Issues (20)
- Adding zkSync L2 network HOT 1
- THORchain derivation path changed over 2022? HOT 1
- What now? all my coins is safety walet . But i dont no why .?? I pay for gass more time i no have any more cash...i woking 12 h ... Ok that for me is to hard help me
- "session not found" and "forbidden key path"
- Can I connect to my old ledger harmony one wallet address from the old chrome extension?
- No way to cancel or speed-up transaction in Destkop app HOT 1
- interact-with-contracts function doesn't answer uptodate data on goerli
- How to build for desktop?
- Trezor Connect v8 is deprecated. Please ask your DeFi platform/wallet developers (not Trezor) to update to Connect v9. HOT 2
- Trustee
- Is MyCrypto dead? HOT 3
- ETC NETWORK OFFLINE HOT 1
- NEED ASAP Upgrade Trezor Connect to v9 HOT 1
- Phoning home to mycryptoapi.com?
- Unable to use WalletConnect without Pairing Code HOT 1
- Wallet issue
- Dogecoin Support HOT 2
- 0xa1b1bbB8070Df2450810b8eB2425D543cfCeF79b
- mycrypto send token
- Error: Invalid string length
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mycrypto.