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

feat(controller-utils): support bn.js v4 input to BN functions #4844

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

legobeat
Copy link
Contributor

@legobeat legobeat commented Oct 24, 2024

Explanation

  • Extend types to indicate support for passing in bn.js v4 instances to BN.js utility functions
    • Affected functions:
      • BNToHex
      • fractionBN
      • fromHex
      • toHex
    • If input is v4 instance, return as v4. Otherwise use v5, as previously.
    • fractionBN now uses the original BN implementation when passed a v4 BN instance
  • Use overload signatures to more specifically type BN-related util functions

References

Changelog

@metamask/controller-utils

  • CHANGED: The following functions now accept input from bn.js v4 library:
    • BNToHex
    • fractionBN
    • fromHex
    • toHex
  • FIXED: fractionToBN now returns output using the same bn.js library version that created the input

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Copy link

socket-security bot commented Oct 24, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@types/[email protected] None 0 13.9 kB types

View full report↗︎

@legobeat legobeat force-pushed the utils-bn4-input-support branch 4 times, most recently from 31a26c3 to 5603e03 Compare October 24, 2024 02:45
@legobeat legobeat marked this pull request as ready for review October 24, 2024 02:45
@legobeat legobeat requested review from a team as code owners October 24, 2024 02:45
@legobeat legobeat force-pushed the utils-bn4-input-support branch 3 times, most recently from adaf327 to 5e5dfd5 Compare October 24, 2024 17:23
Affected functions:
- BNToHex
- fractionBN
- fromHex
- toHex

If input is v4 instance, return as v4. Otherwise use v5, as previously.
@legobeat legobeat merged commit a8ca323 into MetaMask:main Oct 25, 2024
119 checks passed
@legobeat legobeat deleted the utils-bn4-input-support branch October 25, 2024 22:40
Gudahtt added a commit that referenced this pull request Oct 28, 2024
AugmentedMode pushed a commit that referenced this pull request Oct 28, 2024
…s" (#4858)

Reverts #4844

This is being reverted temporarily because `create-release-branch` is
incompatible with the `npm:` dependency alias format used in that PR. We
can reintroduce this change after resolving that problem.
Gudahtt added a commit that referenced this pull request Nov 1, 2024
The `@metamask/create-release-branch` package has been updated one
minor version. This was done to get support for `npm:` aliases, which
is needed to re-introduce #4844 (which was reverted).
Gudahtt added a commit that referenced this pull request Nov 1, 2024
## Explanation

The `@metamask/create-release-branch` package has been updated one minor
version. This was done to get support for `npm:` aliases, which is
needed to re-introduce #4844 (which was reverted).

## References

Unblocks the re-application of #4844

## Changelog

N/A

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants