Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toNano(1e-7) produces inadequate result #58

Closed
mcnckc opened this issue Jun 2, 2022 · 7 comments · May be fixed by #59
Closed

toNano(1e-7) produces inadequate result #58

mcnckc opened this issue Jun 2, 2022 · 7 comments · May be fixed by #59

Comments

@mcnckc
Copy link

mcnckc commented Jun 2, 2022

toNano(1e-6) works fine but
toNano(1e-7).toNumber() results in 2377000000000 on my machine.
It seems like it is exactly the reason why one can't send less than 1e-6 TON using the web wallet based on this library - https://ton.app/wallets/web-ton-wallet.
Correct me if I'm wrong, but by the standard one should be able to send less than 1000 nanoTON, despite it doesn't seem like a critical issue.
I know that the average fee is much greater.

@slavafomin
Copy link
Contributor

We are on it, thank you for reporting this!

@slavafomin
Copy link
Contributor

I've created an upstream issue: ethjs/ethjs-unit#6.

@slavafomin
Copy link
Contributor

Fixed in the upstream library: ethjs/ethjs-unit#7.

@tolya-yanot
Copy link
Contributor

tolya-yanot commented Jun 3, 2022

@mcnckc thanks for the report! This is a bug in the ethjs-unit that tonweb is using. Fixed in tonweb 0.0.42.

Since using Numbers in a crypto is basically a bad practice, in version 0.0.42, in addition to fixing the ethjs-unit, we forbade passing Numbers as an argument at all.

Please pass numbers as strings or BN objects.

This breaks backwards compatibility a bit, but I think it's a good idea to allow developers to avoid precision bugs.

@EmelyanenkoK
Copy link
Contributor

EmelyanenkoK commented Jun 3, 2022

@mcnckc please contact @ton_bugs_bot to get bounty reward

@Afz85
Copy link

Afz85 commented Jun 14, 2024

Afz185

@Afz85
Copy link

Afz85 commented Jun 14, 2024

[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants