chore: prep for 2.0.6 release - #575
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>
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>
- 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>
fix(core): load wallet & network images on React Native
🦋 Changeset detectedLatest commit: 8e991af 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 41s —— View job PR Review
No breaking changes detected. The Found 2 issue(s)Issue 1: Base64 padding branches have zero test coverageID: fetchutil-test-padding-coverage-a3f1 Context:
Recommendation: Add two small cases: it('should produce correct one-char padding (==)', async () => {
// 'f' -> "Zg=="
global.fetch = jest.fn().mockResolvedValue({
ok: true,
arrayBuffer: async () => new Uint8Array([0x66]).buffer,
headers: { get: () => 'image/png' }
}) as unknown as typeof fetch;
const result = await new FetchUtil({ baseUrl }).fetchImage('/img');
expect(result).toBe('data:image/png;base64,Zg==');
});
it('should produce correct two-char padding (=)', async () => {
// 'fo' -> "Zm8="
global.fetch = jest.fn().mockResolvedValue({
ok: true,
arrayBuffer: async () => new Uint8Array([0x66, 0x6f]).buffer,
headers: { get: () => 'image/png' }
}) as unknown as typeof fetch;
const result = await new FetchUtil({ baseUrl }).fetchImage('/img');
expect(result).toBe('data:image/png;base64,Zm8=');
});Issue 2: Full
|
Embed only the bare media type in the data URL so responses like `image/svg+xml; charset=utf-8` don't produce a malformed `data:image/svg+xml; charset=utf-8;base64,...` that strict parsers reject. Also add test coverage for the base64 one-/two-byte padding branches (previously every fetchImage test used a byte length divisible by 3, so the `=`/`==` padding was never exercised). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Correct padding test name ("double-char" for the one-byte remainder `==` case)
- Rewrite content-type comment so the example data URL is accurate
- Drop the changeset
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix(core): harden fetchImage data URLs + base64 padding test coverage
|
@claude review |
|
Claude finished @ignaciosantise's task in 1m 26s —— View job PR Review
🔄 Incremental Review: Both issues flagged in the previous review have been addressed in subsequent commits. Resolved since last review:
✅ No new issues found in latest commits. |
This pull request fixes image loading for wallets and networks on React Native by changing how image data is fetched and encoded. The main improvement is replacing the use of
response.blob()andFileReader(which are not supported on React Native for binary data) withresponse.arrayBuffer()and a custom base64 encoder. This ensures images load correctly instead of silently failing and showing placeholders. Comprehensive tests are added to cover the new logic.React Native image loading fix:
FetchUtil.fetchImageto useresponse.arrayBuffer()and a custom dependency-free base64 encoder instead ofresponse.blob()andFileReader, resolving image loading failures on React Native._arrayBufferToBase64method toFetchUtilto encode image data without relying on Node or browser globals likeBufferorbtoa.Testing improvements:
FetchUtil.test.tsto verify base64 data URL generation, fallback behaviors, content type defaults, and correct handling of errors and unsupported methods.Documentation and release notes: