Skip to content

Eth <> Wei + ERC20 Formatting functions for Utils.cs #10

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

Merged
merged 12 commits into from
Nov 29, 2022
Merged

Eth <> Wei + ERC20 Formatting functions for Utils.cs #10

merged 12 commits into from
Nov 29, 2022

Conversation

0xFirekeeper
Copy link
Member

ToWei, ToEth and FormatERC20 functions added.

@0xFirekeeper
Copy link
Member Author

Ok this should be good now

Copy link
Member

@joaquim-verges joaquim-verges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! just a couple of comments

{
BigInteger weiBigInt = 0;
if (!BigInteger.TryParse(wei, out weiBigInt))
return "INVALID_ARGUMENTS";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want to throw here instead no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you, wasn't sure what's best

if (!BigInteger.TryParse(wei, out weiBigInt))
return "INVALID_ARGUMENTS";
double eth = (double)weiBigInt / DECIMALS_18;
return eth.ToString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about just calling FormatERC20 here? that way we can expose decimalsToDisplay as an optional param on ToEth too which is super useful

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep good point!

@0xFirekeeper
Copy link
Member Author

Here we go!

Copy link
Member

@joaquim-verges joaquim-verges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing, thank you!

@joaquim-verges joaquim-verges merged commit 4072136 into thirdweb-dev:main Nov 29, 2022
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 this pull request may close these issues.

2 participants