Skip to content

fix(mobile): use @miden-sdk/miden-sdk/lazy and @miden-sdk/react/lazy#191

Merged
WiktorStarczewski merged 8 commits intomainfrom
wiktor/use-lazy-sdk
Apr 20, 2026
Merged

fix(mobile): use @miden-sdk/miden-sdk/lazy and @miden-sdk/react/lazy#191
WiktorStarczewski merged 8 commits intomainfrom
wiktor/use-lazy-sdk

Conversation

@WiktorStarczewski
Copy link
Copy Markdown
Collaborator

Summary

Companion PR to miden-client#2076. The Miden client SDKs are splitting into eager (default, top-level-await) and /lazy (no TLA) entry points. The wallet's Capacitor host can't tolerate TLA — the custom-scheme WKWebView hangs on module evaluation — so all imports need to target the /lazy subpath.

Why

capacitor://localhost's WKURLSchemeHandler interacts poorly with top-level await in the main WebView. Re-verified by temporarily restoring TLA in the Cargo glue and running the iOS E2E suite on devnet:

Mint+balance Multi-account Multi-claim Send-private Send-public Wallet-lifecycle × 2
TLA in SDK ✘ timeout 1.9m (React never mounts) skip skip skip skip skip
/lazy (this PR) ✓ 1.7m ✓ 1.2m ✓ 1.4m ✓ 1.8m ✓ 1.7m ✓ 21s / 19s

Total: 7/7 pass in 8.6m, identical to the pre-split baseline.

The dApp-browser WKWebView (vanilla HTTPS, no scheme handler) is NOT affected — TLA resolves in ~70ms there. dApps can continue using the default (eager) entry.

Changes

  • src/**/*.{ts,tsx} — all @miden-sdk/miden-sdk imports rewritten to @miden-sdk/miden-sdk/lazy (26 files).
  • src/screens/consuming-note/ConsumingNote.tsx + src/screens/onboarding/import-wallet-flow/ImportWalletFile.tsx — the two @miden-sdk/react imports switched to @miden-sdk/react/lazy.
  • jest.config.tsmoduleNameMapper uses regex ^@miden-sdk/miden-sdk(/lazy)?$ and ^@miden-sdk/react(/lazy)?$ so both entries map to the same mock.
  • test/jest-mocks.ts — adds jest.mock('@miden-sdk/react/lazy') alongside the default.
  • CHANGELOG.md — 1.14.2 fix entry describing the import switch and the reason.

Test plan

  • yarn test:e2e:mobile:devnet — 7/7 passing (iPhone 17 sim pair, devnet)
  • Depends on client#2076 merging first (or wallet gets node_modules via file: link for CI)
  • Jest unit tests — untested in this iteration; wallet's jest suite is large, leaving for CI

The SDK's default entry (post-split) awaits WASM at module top level via
TLA for ergonomic dApp use. Capacitor's `capacitor://localhost` scheme
handler interacts poorly with that TLA — it hangs the host WebView
indefinitely and the React tree never mounts. Verified against the iOS
E2E suite on devnet: TLA in the Cargo glue → 1 fail, 6 skipped; `/lazy`
everywhere → 7/7 passing in 8.6m.

The dApp-browser WKWebView is unaffected (vanilla HTTPS, no Capacitor
scheme handler). dApps can continue using the eager default.

Wallet-side changes:
- All `@miden-sdk/miden-sdk` imports in src/ → `/lazy`.
- Two `@miden-sdk/react` imports → `/lazy` (useConsume, useImportStore).
- jest.config.ts moduleNameMapper uses regex to map both eager and lazy
  paths to the same mock.
- test/jest-mocks.ts registers the `/lazy` mock alongside the default
  for safety.
Bump moduleResolution to "bundler" so TS honors package.json exports
field; bump eslint-import-resolver-typescript to ^3.9.1 for the same
reason. Apply --fix for import/order on files affected by the resolver
now correctly classifying @miden/dapp-browser.
Fixes mobile build failure on /lazy subpath imports. 0.14.3 aliased
'@miden-sdk/miden-sdk' as a bare-string prefix match, so
'@miden-sdk/miden-sdk/lazy' got rewritten to a non-existent file path
and bypassed the SDK's exports map. 0.14.4 uses an exact-match regex.
- Version Bumping: rewrite for Vite (webpack references removed)
- CDP Bridge: compress to a pointer (full recipe lives in memory file)
- Haptic Feedback: drop component inventory (grep for patterns instead)
- iOS E2E Empirical Status: mark as pre-/lazy-SDK baseline
Previous CLAUDE.md entry pointed at a user-local path under
~/.claude/projects/... which is incoherent for a shared repo. Move
the bringup/usage/recovery material into a committed doc and
link to it relatively from CLAUDE.md.
@WiktorStarczewski WiktorStarczewski merged commit 305b0b8 into main Apr 20, 2026
10 checks passed
@WiktorStarczewski WiktorStarczewski deleted the wiktor/use-lazy-sdk branch April 20, 2026 21:15
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.

1 participant