Skip to content

Conversation

sethkfman
Copy link
Contributor

@sethkfman sethkfman commented Oct 17, 2025

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

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Note

Replace Buffer polyfill with @craftzdog/react-native-buffer and drop base-64 btoa/atob polyfills, updating dependencies accordingly.

  • Polyfills/Runtime:
    • Replace global.Buffer with @craftzdog/react-native-buffer in shim.js; remove fallback to buffer.
    • Remove base-64 usage and global btoa/atob assignments from shim.js.
  • Dependencies:
    • Remove base-64 from package.json and yarn.lock.

Written by Cursor Bugbot for commit 9215530. This will update automatically on new commits. Configure here.

Nodonisko and others added 2 commits October 6, 2025 16:43
<!--
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 -->
Copy link
Contributor

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.

@metamaskbot metamaskbot added the team-mobile-platform Mobile Platform team label Oct 17, 2025

// Use faster Buffer implementation for React Native
global.Buffer = require('@craftzdog/react-native-buffer').Buffer; // eslint-disable-line import/no-commonjs

Copy link

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.

Fix in Cursor Fix in Web

Copy link

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-S team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants