-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
chore: update buffer polyfills - Margelo #21386
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
base: main
Are you sure you want to change the base?
Conversation
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Use faster version of buffer and remove not needed base64 polyfill. It improves performance of `decrypt` in `app/core/Encryptor/lib/quick-crypto.ts`. From 80ms to less than few ms (not measurable by profiler, so very fast now) and possible other places that use `Buffer`. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: ## **Manual testing steps** ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Replaces Buffer polyfill with `@craftzdog/react-native-buffer` and removes `base-64` (btoa/atob) polyfill and lockfile entries. > > - **Polyfills**: > - **Buffer**: Set `global.Buffer` to `@craftzdog/react-native-buffer` in `shim.js`. > - **Base64**: Remove `base-64` import and `global.btoa`/`global.atob` assignments from `shim.js`. > - **Dependencies**: > - Remove `base-64` from `yarn.lock` and references. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 2ae5124. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
||
// Use faster Buffer implementation for React Native | ||
global.Buffer = require('@craftzdog/react-native-buffer').Buffer; // eslint-disable-line import/no-commonjs | ||
|
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.
Bug: Base64 Encoding/Decoding Functions Missing
Removing the base-64
import also removed the global.btoa
and global.atob
polyfills. Since React Native environments typically don't provide these browser APIs natively, btoa
and atob
are now undefined. This causes runtime errors for code relying on these global functions for base64 encoding/decoding.
|
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.
Lgtm
Description
This PR is supporting an external developer change #20811
Credit for the change goes: @Nodonisko
Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Replace Buffer polyfill with @craftzdog/react-native-buffer and drop base-64 btoa/atob polyfills, updating dependencies accordingly.
global.Buffer
with@craftzdog/react-native-buffer
inshim.js
; remove fallback tobuffer
.base-64
usage and globalbtoa
/atob
assignments fromshim.js
.base-64
frompackage.json
andyarn.lock
.Written by Cursor Bugbot for commit 9215530. This will update automatically on new commits. Configure here.