fix(core): load wallet & network images on React Native - #574
Conversation
FetchUtil.fetchImage built its data URL with response.blob() + FileReader, but on React Native fetch(...).blob() throws "Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not supported" for binary responses, so wallet and network images silently failed to load. Read the bytes via response.arrayBuffer() and base64-encode them into the data URL instead (dependency-free encoder, since RN guarantees neither Buffer nor btoa). Adds unit tests for fetchImage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: c300bde The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Claude finished @ignaciosantise's task in 2m 42s —— View job Code Review
Found 1 issue(s)Issue 1:
|
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Match the release convention of bumping every published package on each release, consistent with the other changeset on this branch and prior releases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes React Native wallet/network logo loading by replacing response.blob() + FileReader (which fails on RN for binary responses) with response.arrayBuffer() and a dependency-free base64 data URL encoder, plus adds unit tests and a changeset.
Changes:
- Update
FetchUtil.fetchImageto builddata:<content-type>;base64,...fromResponse.arrayBuffer(). - Add
_arrayBufferToBase64helper to avoid relying onBlob,FileReader,Buffer, orbtoa. - Add Jest coverage for success, missing content-type, avoiding
.blob(), and error cases; include a patch changeset.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/utils/FetchUtil.ts | Switch image loading to ArrayBuffer→base64 data URLs for RN compatibility; add encoder helper. |
| packages/core/src/tests/utils/FetchUtil.test.ts | Add unit tests validating the new ArrayBuffer-based implementation and error handling. |
| .changeset/fix-fetch-image-blob-arraybuffer.md | Document the patch release and the RN-specific fix rationale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@claude review |
|
Claude finished @ignaciosantise's task in 1m 21s —— View job Code Review🔄 Incremental Review: 2 issues remain / 1 newly flagged
Found 3 issue(s)Issue 1:
|
- Return undefined for non-2xx responses so error bodies aren't base64-encoded into a bogus data URL that RN's Image silently fails to render instead of falling back to the placeholder. - Accumulate base64 output into an array and join once to avoid per-iteration string allocations / GC pressure on the RN JS thread. - Add ok: true to the fetchImage success mocks and a non-ok test case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Problem
Wallet and network logos in the connect modal never load on React Native — the list shows only placeholder icons on both iOS and Android (wallet names load fine, since those come from plain JSON).
Root cause is in
FetchUtil.fetchImage(packages/core/src/utils/FetchUtil.ts), which builds the image data URL withresponse.blob()+FileReader.readAsDataURL:On React Native,
fetch(...).blob()for a binary (image) response throws:RN's
Blobimplementation can't be constructed from anArrayBufferbody, so the promise rejects,fetchImagereturnsundefined, andAssetUtil.getWalletImagefalls back to the placeholder. This is the only.blob()usage in the codebase.Observed with Expo SDK 56 / React Native 0.85.3 (New Architecture),
@reown/appkit-*@2.0.5. The imagefetchitself succeeds (HTTP 200,content-type: image/webp); only theblob()step fails.Fix
Read the response as an
ArrayBufferand base64-encode it into the data URL, avoidingBlob/FileReaderentirely:The base64 encoder is dependency-free — React Native guarantees neither a global
Buffernorbtoa, so relying on either would be fragile for a library.Tests
Adds unit tests for
fetchImage(ArrayBuffer → base64 data URL, default content-type,blob()not called, error →undefined). Fullpackages/coresuite passes:Verification
Patched into a multichain AppKit + wagmi app on Expo SDK 56 / RN 0.85.3:
🤖 Generated with Claude Code