feat(core,ui): in-app browser (platform wrapper) detection - #99
Conversation
Ports Stellar Wallets Kit's isPlatformWrapper concept: detect when the dApp is running inside a wallet's in-app browser and promote that wallet. - WalletAdapter.isPlatformWrapper?() — optional, per-adapter (as in SWK). - WalletManager.getPlatformWrapper() — returns the first adapter reporting true, each check bounded by TIME.PLATFORM_WRAPPER_TIMEOUT (500ms) so a slow adapter can't delay detection. - <xrpl-wallet-connector> detects on open and promotes the wrapping wallet to the top of the list, unless an explicit primary-wallet attribute is set. Lands the mechanism + wiring; individual wallets opt in by implementing the method (no bundled adapter has a verifiable in-app-browser signal today). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review: feat(core,ui): in-app browser (platform wrapper) detectionVerdict: approve_with_nits — CI green (docs-build + test-and-build) Points positifs
Nits
TestsManque : path rejection (isPlatformWrapper throw), first-match ordering, et tout test UI pour la promotion logic. |
|
Pre-live review: the abstraction and timeout are reasonable, but no adapter in this PR implements isPlatformWrapper. The feature has no observable production effect. Recommendation: keep it out of the release until at least one real adapter implementation and browser-specific tests are included. |
|
Closing for the pre-live merge train: this PR adds the isPlatformWrapper() abstraction, but no production adapter implements it, so it currently has no observable effect. It can be reopened or replaced once it includes a real adapter implementation and browser/mobile regression tests. |
Part 3/4 of closing the Stellar-Wallets-Kit feature gap. Additive & backward compatible.
Gap #1 — no in-app browser detection
When a user opens a dApp from inside a mobile wallet's built-in browser, xrpl-connect had no way to know, so it couldn't surface that wallet first. SWK exposes an optional per-module
isPlatformWrapper()for exactly this.Fix (faithful port of SWK's optional-method design)
WalletAdapter.isPlatformWrapper?()— optional; an adapter returnstruewhen the dApp is running inside its in-app browser.WalletManager.getPlatformWrapper()— returns the first adapter reportingtrue. Each check is bounded byTIME.PLATFORM_WRAPPER_TIMEOUT(500 ms, matching SWK) so a slow adapter can't delay detection; adapters without the method are skipped.<xrpl-wallet-connector>— on open, detects the wrapper and promotes it to the top of the list, unless an explicitprimary-walletattribute is set (that still wins).As in SWK,
isPlatformWrapperis an optional per-wallet method — this PR lands the mechanism + manager/UI wiring; individual wallets opt in by implementing it (no bundled adapter ships a verifiable in-app-browser signal today, so none is fabricated here).Changes
packages/core/src/types.ts— optionalisPlatformWrapper()onWalletAdapter.packages/core/src/constants.ts—TIME.PLATFORM_WRAPPER_TIMEOUT.packages/core/src/wallet-manager.ts—getPlatformWrapper().packages/ui/src/wallet-connector.ts— detect on open + promote (falls back toprimary-wallet).packages/core/tests/wallet-manager.test.ts— +3 tests (detect / none / timeout).Verification
pnpm build(full workspace, 13/13) ✅pnpm test— core 16 passed (+3), ui 4 ✅pnpm lint✅ ·prettier --check✅🤖 Generated with Claude Code