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

Use Numeric type for decimals parameter in FixedNumber.fromValue() #4141

Closed
SalamandraDevs opened this issue Jun 12, 2023 · 2 comments
Closed
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. minor-bump Planned for the next minor version bump. v6 Issues regarding v6

Comments

@SalamandraDevs
Copy link

SalamandraDevs commented Jun 12, 2023

Describe the Feature

The current function signature of FixedNumber.fromValue() is as follows:

FixedNumber.fromValue(value: BigNumberish, decimals?: number, format?: FixedFormat) ⇒ FixedNumber)

The returning numeric values in ethers are bigint, as far as I know, also the Numeric type in ethers is an union of bigint and number types. For that reason I consider that is better to change the type of decimals parameter from number to Numeric to allow bigint type also, letting the function signature as follows.

FixedNumber.fromValue(value: BigNumberish, decimals?: Numeric, format?: FixedFormat) ⇒ FixedNumber)

Code Example

// Currently you have to do this:

`const reserve0Fix = FixedNumber.fromValue(reserve0, Number(token0Decimals));`

// With the modification you could do this:

`const reserve0Fix = FixedNumber.fromValue(reserve0, token0Decimals);`
@SalamandraDevs SalamandraDevs added the enhancement New feature or improvement. label Jun 12, 2023
@ricmoo
Copy link
Member

ricmoo commented Jun 12, 2023

Yes! You are absolutely correct. It should be a Numeric. I’ll make that change in the next minor bump.

@ricmoo ricmoo added on-deck This Enhancement or Bug is currently being worked on. minor-bump Planned for the next minor version bump. labels Jun 12, 2023
@ricmoo
Copy link
Member

ricmoo commented Jun 14, 2023

This has been added in v6.6.0. Try it out and let me know. :)

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6 and removed on-deck This Enhancement or Bug is currently being worked on. labels Jun 14, 2023
@ricmoo ricmoo closed this as completed Jun 14, 2023
Woodpile37 pushed a commit to Woodpile37/ethers.js that referenced this issue Jan 14, 2024
Woodpile37 pushed a commit to Woodpile37/ethers.js that referenced this issue Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. minor-bump Planned for the next minor version bump. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants