feat(mobile): open a transaction on the block explorer - #687
Conversation
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 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! 🚀 |
|
@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
left a comment
There was a problem hiding this comment.
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.tsx → Cannot 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.
closes #648
Change
components/TxDetailSheet.tsxshowed the hash but offered no way to check it. Adds a View on explorer action.lib/about.ts— newexplorerTxUrl(hash, network), sitting next to the existingexplorerNetworkSegment/explorerAddressUrlrather than starting a parallel helper module. Returnsnullunless the hash is a 64-character hex string (Stellar tx hashes are 32 bytes), lower-cases it, and trims.components/TxDetailSheet.tsx— aPressablerendered 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'sapp/settings/danger/page.tsxmapping (mainnet→public, otherwisetestnet).On
Linking.openURLThe issue suggested
Linking.openURL. This uses the module's existingopenExternalUrlinstead, 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 toLinking.openURL, and refuses any non-httpsscheme. Same destination, existing convention. Happy to switch to a bareLinking.openURLif you would rather.Verification
frontend/mobile, plainnpm install:npx jest lib/__tests__/about.test.ts→ 20 passed, including 5 new cases forexplorerTxUrl: testnet URL, mainnetpublicsegment, 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.tsis one of the suites that cannot execute on currentmainbecause the AsyncStorage Jest mock is not registered —lib/about.tsimportslib/network.ts, which imports AsyncStorage. That is #658, fixed separately in #686. To verify this branch I applied #686'sjest.setup.jslocally, 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.