Mobile Wallet Deeplinking
This page reflects the current WalletConnect and mobile deeplink behavior in the dapp. The deeplink system was simplified after refactors: we no longer persist session topics or maintain a dedicated WalletConnect store. Instead, deeplinking is handled in two places: the Connect Modal during connection and a lightweight helper used by transaction/signing flows to wake the wallet app.
What exists now
1) Connection-time WalletConnect handoff (ConnectModal)
When a user selects the WalletConnect connector, the Connect Modal listens for the display_uri event. On desktop, it shows a QR view; on mobile, it immediately redirects the browser to the WalletConnect URI.
- File:
dapp/components/wallet/connectModal/hooks/useWalletConnection.ts - Key behavior:
display_urisetsqrUrifor the UI.- On mobile,
window.location.href = uriperforms the handoff. - No session topic persistence or URI sanitization is performed.
2) Best-effort wallet wake link (openWalletDeeplink)
After writes or signatures, the dapp uses a minimal helper to re-open the wallet app. This helper does not rebuild a session topic or guarantee OS chooser behavior; it simply navigates to a WC-style URI to prompt a handoff.
- File:
dapp/app/utils/walletDeeplink.ts - Default behavior:
- Uses the fallback URI
wc:ritoswap. - Appends a timestamp query string to force a fresh navigation on repeat calls.
- Uses the fallback URI
import { openWalletDeeplink } from '@/app/utils/walletDeeplink'
if (isMobileDevice() && connector?.id === 'walletConnect') {
openWalletDeeplink()
}This helper is called from:
dapp/app/hooks/useMintBurn.tsdapp/app/gate/components/GateModal/GateModal.tsxdapp/app/gate/components/GatePageWrapper.tsxdapp/components/wallet/processingModal/ProcessingModal.tsxdapp/components/wallet/OpenWalletButton/OpenWalletButton.tsx
Global redirect/popup guards
The app installs a lightweight guard to block known WalletConnect-related redirects and popups on mobile Chrome:
- File:
dapp/app/hooks/useWalletConnectGuards.ts - Behavior:
- Blocks navigation to a small blacklist of wallet domains.
- Blocks HTTP/HTTPS popups on Android Chrome.
- Does not manage any WalletConnect session state.
This guard is wired from dapp/components/providers/providers.tsx.
File map
- walletDeeplink.ts
- useWalletConnectGuards.ts
- useMintBurn.ts
- GateModal.tsx
- GatePageWrapper.tsx
- useWalletConnection.ts
- ProcessingModal.tsx
- OpenWalletButton.tsx
Constraints and expectations
Deeplinking is best-effort. The current helper does not persist WalletConnect session topics, does not sanitize URIs, and does not guarantee that a wallet chooser will appear. Validate on real devices whenever you change wallet flows.
WalletConnect availability
WalletConnect is optional. If NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID is not set, the app runs with injected wallets only (see dapp/components/providers/providers.tsx). Injected mobile wallets (e.g., MetaMask in-app browser) still work without any deeplink helper.
Related docs
docs/content/dapp/wallet-ui/connectModal.mdxdocs/content/dapp/smart-contract-ui/processing-modal.mdxdocs/content/dapp/smart-contract-data/use-mint-burn.mdxdocs/content/dapp/tokengate.mdx