Skip to content

feat: support ?address= URL param for send-to-address deep linking#17

Merged
PastaPastaPasta merged 1 commit intoPastaPastaPasta:mainfrom
thephez:feat/url-deep-link-address
Mar 4, 2026
Merged

feat: support ?address= URL param for send-to-address deep linking#17
PastaPastaPasta merged 1 commit intoPastaPastaPasta:mainfrom
thephez:feat/url-deep-link-address

Conversation

@thephez
Copy link
Copy Markdown
Contributor

@thephez thephez commented Mar 3, 2026

Summary

Adds support for a ?address= URL query parameter that deep-links directly into the "Send to Platform Address" screen with the recipient address pre-filled. The correct network (testnet/mainnet) is automatically inferred from the bech32m address prefix (tdash vs dash), so no separate ?network= param is needed.

Highlights:

  • Parse ?address=<bech32m> in init() and auto-navigate to send-to-address mode with the address pre-populated
  • Infer network from the address HRP (tdash1... → testnet, dash1... → mainnet), falling back to the existing ?network= param
  • Invalid addresses are silently ignored, loading the normal home screen

Example URLs

https://bridge.example.com/?address=tdash1qqqqqxs856en8
https://bridge.example.com/?address=dash1qqqqqxs856en8

Summary by CodeRabbit

  • New Features
    • Added deep-link support: Users can now share URLs with pre-filled recipient addresses that automatically populate the send form.
    • Implemented automatic network detection based on address parameters; the app intelligently selects the correct network when a valid address is provided.
    • Added URL parameter support for explicit network selection and address pre-filling.

Infer network from bech32m address prefix (tdash/dash) and pre-fill
the send-to-platform-address screen, enabling shareable direct links.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 3, 2026

📝 Walkthrough

Walkthrough

The PR enhances src/main.ts initialization logic to support URL-based deep-linking. It adds network inference from a bech32m-encoded address parameter (?address) that checks against MAINNET and TESTNET platform HRPs, and automatically switches the app to the appropriate network while pre-populating the send-to-address flow when a valid address is provided.

Changes

Cohort / File(s) Summary
Network Deep-Linking
src/main.ts, src/config.js
Added MAINNET and TESTNET exports; enhanced initialization to infer network from bech32m-decoded ?address parameter, validate against platform HRPs, and auto-enter send_to_address flow with pre-filled recipient when address matches network.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A link through the deep, an address so neat,
With bech32m decoded, the network complete,
MAINNET or TESTNET, the choice flows through,
Pre-filled and ready—the bridge brings you through! 🌉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature being added: support for a ?address= URL parameter for deep linking into send-to-address mode.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main.ts (1)

128-132: Optional: avoid double bech32m decode in init flow.

Line 115 decodes once for inference, then Line 129 calls validatePlatformAddress(...), which decodes again. Caching a validated deep-link value in init() would reduce duplication and keep the deep-link path single-pass.

♻️ Proposed refactor
-  const addressParam = urlParams.get('address')?.trim();
+  const addressParam = urlParams.get('address')?.trim();
+  let deepLinkAddress: string | undefined;

   if (addressParam) {
     try {
       const decoded = bech32m.decode(addressParam as `${string}1${string}`);
       if (decoded.prefix === MAINNET.platformHrp) network = 'mainnet';
       else if (decoded.prefix === TESTNET.platformHrp) network = 'testnet';
+      if (decoded.prefix === getNetwork(network).platformHrp) {
+        deepLinkAddress = addressParam;
+      }
     } catch {
       // Invalid address — will be ignored below
     }
   }

@@
-  if (addressParam && validatePlatformAddress(addressParam, network)) {
+  if (deepLinkAddress) {
     state = setMode(state, 'send_to_address');
-    state = setRecipientPlatformAddress(state, addressParam);
+    state = setRecipientPlatformAddress(state, deepLinkAddress);
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.ts` around lines 128 - 132, The init flow currently decodes the
bech32m deep-link twice (once earlier for inference and again via
validatePlatformAddress(addressParam, network)); to avoid duplicate decoding,
decode/validate the deep-link once in init() and cache the result (e.g., let
decodedAddress or validatedAddress) and use that cached value for both the
inference logic and when calling setMode/state updates; update the conditional
to check the cached validation result instead of calling validatePlatformAddress
a second time and pass the cached/decoded address to setRecipientPlatformAddress
so the deep-link path is single-pass (refer to symbols addressParam, init(),
validatePlatformAddress, setMode, setRecipientPlatformAddress).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main.ts`:
- Around line 128-132: The init flow currently decodes the bech32m deep-link
twice (once earlier for inference and again via
validatePlatformAddress(addressParam, network)); to avoid duplicate decoding,
decode/validate the deep-link once in init() and cache the result (e.g., let
decodedAddress or validatedAddress) and use that cached value for both the
inference logic and when calling setMode/state updates; update the conditional
to check the cached validation result instead of calling validatePlatformAddress
a second time and pass the cached/decoded address to setRecipientPlatformAddress
so the deep-link path is single-pass (refer to symbols addressParam, init(),
validatePlatformAddress, setMode, setRecipientPlatformAddress).

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1642aa and 9bbee87.

📒 Files selected for processing (1)
  • src/main.ts

Copy link
Copy Markdown
Contributor Author

@thephez thephez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure address is the best name for the param?

@PastaPastaPasta PastaPastaPasta merged commit 16167e2 into PastaPastaPasta:main Mar 4, 2026
3 checks passed
@thephez thephez deleted the feat/url-deep-link-address branch March 5, 2026 13:44
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