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

TokenRatesController: Use browser compat eq check #3663

Merged
merged 3 commits into from
Dec 14, 2023

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Dec 13, 2023

Explanation

isDeepStrictEqual is a function from Node's util module. However, it doesn't exist in a browser context, so using it crashes the extension.

This commit replaces this function with fast-equals' strictDeepEqual function, which essentially does the same thing as isDeepStrictEqual in a more robust way.

Changelog

(Updated in PR)

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

@mcmire mcmire requested a review from a team as a code owner December 13, 2023 21:17
`isDeepStrictEqual` is a function from Node's `util` module. However, it
doesn't exist in a browser context, so using it crashes the extension.

This commit replaces this function with `fast-equals`'
[`strictDeepEqual`][1] function, which essentially does the same thing
as [`isDeepStrictEqual`][2] in a more robust way.

[1]: https://github.com/planttheidea/fast-equals/blob/7564fcf46a187d011261d4a6d60724cb2ec3a75d/src/equals.ts
[2]: https://github.com/sindresorhus/core-assert/blob/fa0ab246046a81deb4cac841fee8b89b4cb3b296/index.js#L165
@mcmire mcmire force-pushed the fix-equality-check-in-token-rates-controller branch from 3d633a2 to 8033f29 Compare December 13, 2023 21:17
@@ -27,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **BREAKING:** Remove `CoinGeckoResponse` and `CoinGeckoPlatform` types ([#3600](https://github.com/MetaMask/core/pull/3600))
- These types were previously used in TokenRatesController to represent data returned from the CoinGecko API. There is no equivalent.

### Fixed
- Fix TokenRatesController to prevent redundant token rate updates when tokens change ([#3647](https://github.com/MetaMask/core/pull/3647), [#3663](https://github.com/MetaMask/core/pull/3663))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is copied from the changelog notes for #3647; I also added this PR, since it's a fix for that change.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@mcmire mcmire merged commit 9cd6067 into main Dec 14, 2023
136 checks passed
@mcmire mcmire deleted the fix-equality-check-in-token-rates-controller branch December 14, 2023 00:06
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