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

Constants for minimum and maximum signed integer values #1576

Closed
jmcph4 opened this issue May 19, 2021 · 3 comments
Closed

Constants for minimum and maximum signed integer values #1576

jmcph4 opened this issue May 19, 2021 · 3 comments
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.

Comments

@jmcph4
Copy link

jmcph4 commented May 19, 2021

Is your feature request related to a problem? Please describe.
When testing smart contracts, a common requirement is to test the boundaries of the domain of a given type. For example, a signed 256-bit integer (int256 in Solidity's type system) would have a domain of [-2**255-1, 2**255-1]. Currently, Ethers' BigNumber implementation has a constant for the maximum legal value of a 256-bit unsigned integer, ethers.constants.MaxUint256. While the minimum for unsigned integers is trivially zero, the case isn't the same for signed integers.

Describe the solution you'd like
Ethers should expose additional constants for both the minimum and maximum legal values of signed 256-bit integers (i.e., int256), like so:

  • ethers.constants.MaxInt256
  • ethers.constants.MinInt256

Describe alternatives you've considered
Clear documentation on how else to coerce a minimum signed 256-bit integer.

Additional context
N/A

@ricmoo
Copy link
Member

ricmoo commented May 20, 2021

These make sense to add and I’ll get to them on my next low-hanging-fruit sweep. :)

@ricmoo ricmoo added enhancement New feature or improvement. minor-bump Planned for the next minor version bump. labels May 20, 2021
@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label May 27, 2021
@ricmoo
Copy link
Member

ricmoo commented May 27, 2021

This will be going into the upcoming EIP-1559 minor bump. I've already added it locally.

@ricmoo
Copy link
Member

ricmoo commented Jun 1, 2021

Added in 5.3.0. Try it out and let me know how it works.

Thanks! :)

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Jun 1, 2021
pull bot pushed a commit to shapeshift/ethers.js that referenced this issue Jun 4, 2021
pull bot pushed a commit to shapeshift/ethers.js that referenced this issue Jun 4, 2021
@ricmoo ricmoo closed this as completed Jun 11, 2021
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.
Projects
None yet
Development

No branches or pull requests

2 participants