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

Refactor backend public methods taking amounts as floats #11491

Closed
micieslak opened this issue Jul 11, 2023 · 0 comments · Fixed by #11862
Closed

Refactor backend public methods taking amounts as floats #11491

micieslak opened this issue Jul 11, 2023 · 0 comments · Fixed by #11862
Assignees
Labels
bug Something isn't working refactor
Milestone

Comments

@micieslak
Copy link
Member

micieslak commented Jul 11, 2023

Description

As explained in #11376, using floats to pass amounts from UI to the backend is unreliable in some cases and should be replaced by usage of integer amounts in the base units (like wei for eth). The problem seems to occur whenever conversion::eth2Wei is used to convert floats to amount's base units.

#11353 adds minting assets. CommunityTokenDto::suply is changed from int to Uint256 to handle amounts in weis. But when returned to the user supplyByType is used to convert amount to float (precision is lost here). The proposition is to return amount in basic unit instead of floats (as a string) and add additional field for storing multiplier (0 for collectibles and 18 for assets). UI side should take care for proper presentation using utilities provided in #11487.

That approach will allow conducting operations like e.g. airdrop (where UI should check if remaining supply is sufficient to airdrop given amount to X recipients), and others, in a reliable way with no risk for e.g. constructing operation exceeding available supply.

Depends on: #11353

Related to: #11489
Relates to: #11376

@micieslak micieslak added bug Something isn't working ui-team refactor labels Jul 11, 2023
@micieslak micieslak self-assigned this Jul 11, 2023
@alexandraB99 alexandraB99 added this to the 0.15 milestone Aug 9, 2023
micieslak added a commit that referenced this issue Aug 10, 2023
micieslak added a commit that referenced this issue Aug 10, 2023
micieslak added a commit that referenced this issue Aug 17, 2023
micieslak added a commit that referenced this issue Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor
3 participants