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
[SDK] add two new utilities toEther and toWei #421
Conversation
🦋 Changeset detectedLatest commit: 755f018 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I think it might be better for it to be |
@nachoiacovino In that case we will have to change the name from |
@yehia67 nah i actually like |
also make sure to add a changeset 🙏 |
what about the other way around? from units to wei for custom erc20? |
@joaquim-verges @nachoiacovino I can add two utilities |
@joaquim-verges should I remove all |
} | ||
|
||
export function toWei(amount: BigNumberish): BigNumber { | ||
return utils.parseEther(AmountSchema.parse(amount)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you do y have to parse anything, just pass the BigNumberish value in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"pasreEther" params accept string only parseEther(ether: string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right so it should be the opposite then:
toEther(amount: BigNumberish)
and
toWei(amount: Amount)
} | ||
|
||
export function toWei(amount: BigNumberish): BigNumber { | ||
return utils.parseEther(AmountSchema.parse(amount)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right so it should be the opposite then:
toEther(amount: BigNumberish)
and
toWei(amount: Amount)
@joaquim-verges for |
|
@joaquim-verges yes make 100% sense |
thx @yehia67! |
#411