Skip to content

feat(mobile): open a transaction on the block explorer - #687

Merged
Miracle656 merged 1 commit into
Miracle656:mainfrom
DevQwinB:feat/mobile-tx-explorer-link
Aug 30, 2026
Merged

feat(mobile): open a transaction on the block explorer#687
Miracle656 merged 1 commit into
Miracle656:mainfrom
DevQwinB:feat/mobile-tx-explorer-link

Conversation

@DevQwinB

Copy link
Copy Markdown
Contributor

closes #648

Change

components/TxDetailSheet.tsx showed the hash but offered no way to check it. Adds a View on explorer action.

  • lib/about.ts — new explorerTxUrl(hash, network), sitting next to the existing explorerNetworkSegment / explorerAddressUrl rather than starting a parallel helper module. Returns null unless the hash is a 64-character hex string (Stellar tx hashes are 32 bytes), lower-cases it, and trims.
  • components/TxDetailSheet.tsx — a Pressable rendered only when the URL resolves, so the sheet never offers a link that would 404.

The network segment comes from useNetwork(), not a constant — the app is dual-network at runtime, and a hardcoded segment would send half the links to a page reporting the transaction does not exist. This matches the web wallet's app/settings/danger/page.tsx mapping (mainnetpublic, otherwise testnet).

On Linking.openURL

The issue suggested Linking.openURL. This uses the module's existing openExternalUrl instead, which the About screen already routes every outbound link through: it opens an in-app browser tab (which, unlike a handoff to the system browser, cannot be mistaken for the wallet itself), falls back to Linking.openURL, and refuses any non-https scheme. Same destination, existing convention. Happy to switch to a bare Linking.openURL if you would rather.

Verification

frontend/mobile, plain npm install:

  • npx jest lib/__tests__/about.test.ts20 passed, including 5 new cases for explorerTxUrl: testnet URL, mainnet public segment, upper-case normalisation, whitespace trimming, and null for non-hex / too-short / too-long / empty / null input.
  • npm run typecheck → clean.
  • npx expo lint → 0 errors (9 pre-existing warnings, none in the touched files).

Note on running the tests: lib/__tests__/about.test.ts is one of the suites that cannot execute on current main because the AsyncStorage Jest mock is not registered — lib/about.ts imports lib/network.ts, which imports AsyncStorage. That is #658, fixed separately in #686. To verify this branch I applied #686's jest.setup.js locally, ran the suite, then removed it — this PR contains no Jest config change, so the two do not conflict. Once #686 lands, these tests run in CI unaided.

The transaction detail sheet showed the hash but offered no way to check
it. The hash is the only independently verifiable thing about a payment,
and copying it out to find an explorer by hand is enough friction on
mobile that most people will not.

Add `explorerTxUrl` next to the existing `explorerAddressUrl` in
lib/about.ts and a "View on explorer" action on the sheet. The network
segment is resolved from the active network through `useNetwork`, not
hardcoded — the app is dual-network at runtime, so a fixed segment would
send half the links to a page reporting the transaction does not exist.

Opening goes through the existing `openExternalUrl`, which the About
screen already uses: an in-app browser tab that cannot be mistaken for
the wallet, falling back to the platform handler. The action is hidden
when there is no hash, or the hash is not a 64-character hex string, so
the sheet never offers a link that would 404.
@DevQwinB
DevQwinB requested a review from Miracle656 as a code owner August 30, 2026 13:28
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@DevQwinB Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

@DevQwinB is attempting to deploy a commit to the miracle656's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Miracle656 Miracle656 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Small PR, and every detail I'd check is already handled.

The network segment is right, which is the thing most explorer links get wrong:

return name === 'mainnet' ? 'public' : 'testnet';

stellar.expert uses public, not mainnet. Hard-coding the wrong one produces a link that 404s only for mainnet users — so it looks fine in testnet development and breaks for exactly the people with real money.

And it reads the network at call time, not from a constant:

The network segment comes from the active network rather than a constant — the app is dual-network at runtime, and a mainnet hash looked up on testnet reads as "this transaction does not exist".

That's precisely the failure mode, and stating it in the comment is worth more than the line of code.

Invalid input returns null rather than a link. 64-hex for hashes, 56 chars plus a C/G prefix for addresses, with contracts and accounts routed to their own explorer paths. Offering a link you know will 404 is worse than showing the bare hash, and this gets that the right way round.

20 tests, including the two that matter — uses the public network segment on mainnet for both the address and transaction helpers — plus the negative cases.

Verified on the merge result:

merge into main:  0 conflicts
Test Suites:      1 failed, 28 passed, 29 total
Tests:            425 passed

The single failure is QuickActions.test.tsxCannot find module 'expo-asset', which is #689 and pre-existing. No regressions from this PR.

Worth knowing since you're working in mobile: #686 merged an hour ago and took the suite from 10 failing to 1. npx jest locally is a real signal again, and once #689 lands the CI job goes green for the first time in weeks.

Merging.

@Miracle656
Miracle656 merged commit fbb26f9 into Miracle656:main Aug 30, 2026
9 of 15 checks passed
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.

Mobile: transaction details have no link to a block explorer

2 participants