Skip to content

feat(core,ui): in-app browser (platform wrapper) detection - #99

Closed
Sanka-D wants to merge 1 commit into
XRPL-Commons:developfrom
Sanka-D:feat/platform-wrapper-detection
Closed

feat(core,ui): in-app browser (platform wrapper) detection#99
Sanka-D wants to merge 1 commit into
XRPL-Commons:developfrom
Sanka-D:feat/platform-wrapper-detection

Conversation

@Sanka-D

@Sanka-D Sanka-D commented Jul 1, 2026

Copy link
Copy Markdown

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 returns true when the dApp is running inside its in-app browser.
  • WalletManager.getPlatformWrapper() — returns the first adapter reporting true. Each check is bounded by TIME.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 explicit primary-wallet attribute is set (that still wins).

As in SWK, isPlatformWrapper is 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 — optional isPlatformWrapper() on WalletAdapter.
  • packages/core/src/constants.tsTIME.PLATFORM_WRAPPER_TIMEOUT.
  • packages/core/src/wallet-manager.tsgetPlatformWrapper().
  • packages/ui/src/wallet-connector.ts — detect on open + promote (falls back to primary-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

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>
@RomThpt

RomThpt commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Review: feat(core,ui): in-app browser (platform wrapper) detection

Verdict: approve_with_nits — CI green (docs-build + test-and-build)

Points positifs

  • Implementation soignee, pattern capability conforme a develop.
  • 3 tests manager solides (adapter detecte, null quand aucun, timeout fake timers).
  • Purement additif, semver-minor.

Nits

  • Detection sequentielle apres availability checks : getPlatformWrapper() (line 369) ne commence qu apres les isAvailable(), ajoutant jusqu a +500ms au premier open. Pourrait etre lance en parallele.
  • Timeout timer jamais clear (line 286) : setTimeout dans Promise.race non capture/clear quand l adapter gagne.
  • Empty primary-wallet attribute (line 775) : getAttribute("primary-wallet") ?? this.detectedWrapperId ne traite pas "" comme unset -> suppression promotion detectee.
  • Docs non mises a jour : getPlatformWrapper() et isPlatformWrapper() absents de docs/guide/api-reference.md et adapter-integration.md.

Tests

Manque : path rejection (isPlatformWrapper throw), first-match ordering, et tout test UI pour la promotion logic.

@Sanka-D

Sanka-D commented Jul 16, 2026

Copy link
Copy Markdown
Author

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.

@Sanka-D

Sanka-D commented Jul 16, 2026

Copy link
Copy Markdown
Author

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.

@Sanka-D Sanka-D closed this Jul 16, 2026
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.

2 participants