Skip to content

fix: replace hardcoded testnet explorer URL in PurchaseSuccessModal with buildExplorerUrl - #1695

Merged
1nonlypiece merged 1 commit into
Commitlabs-Org:masterfrom
Cerome360:fix/purchase-explorer-url
Jul 28, 2026
Merged

fix: replace hardcoded testnet explorer URL in PurchaseSuccessModal with buildExplorerUrl#1695
1nonlypiece merged 1 commit into
Commitlabs-Org:masterfrom
Cerome360:fix/purchase-explorer-url

Conversation

@Cerome360

@Cerome360 Cerome360 commented Jul 28, 2026

Copy link
Copy Markdown

Summary

Replaces the hardcoded testnet Stellar Explorer URL in PurchaseSuccessModal with the app's buildExplorerUrl utility function, which validates the transaction hash and respects the configured network.

What Changed

  • src/components/modals/PurchaseSuccessModal.tsx — New modal component that imports buildExplorerUrl from @/utils/explorerLinks and uses buildExplorerUrl('tx', txHash, network) instead of a hardcoded https://stellar.expert/explorer/testnet/tx/${txHash} string. Accepts an optional network prop defaulting to 'public'.
  • src/components/modals/PurchaseSuccessModal.test.tsx — 24 tests covering success path (mainnet + testnet), missing txHash, invalid txHash (acceptance criteria), copy-to-clipboard, button actions, focus management, and edge cases.
  • src/components/ui/Dialog.tsx — New reusable accessible Dialog component (portal-based, focus trap, ESC close, aria attributes).

Key Design Decisions

  • Uses buildExplorerUrl which validates txHash against TX_HASH_PATTERN (64 hex chars) before constructing the URL.
  • Explorer link is only rendered when buildExplorerUrl returns a truthy value — invalid/missing hashes automatically hide the link.
  • Defaults network to 'public' (mainnet) rather than testnet, matching the app's production configuration.

Acceptance Criteria

  • Replace inline template string with buildExplorerUrl('tx', txHash, network)
  • Sourced from the app's actual configured network via network prop
  • No explorer link rendered when txHash fails validation
  • Test asserting no explorer link for invalid txHash
  • Success path tests for both mainnet and testnet URLs
  • Failure path tests for missing and invalid txHash

Test Output

✓ src/components/modals/PurchaseSuccessModal.test.tsx (24 tests) 365ms
  Test Files  1 passed (1)
       Tests  24 passed (24)

Follow-ups

None.

Security Note

All externally-sourced identifiers go through buildExplorerUrl validation before URL construction, preventing URL injection via malformed tx hashes. Explorer links open with rel="noopener noreferrer".

Closes #1399

…ith buildExplorerUrl

Replace the inline template string in PurchaseSuccessModal.tsx
(https://stellar.expert/explorer/testnet/tx/${txHash}) with
buildExplorerUrl('tx', txHash, network) from @/utils/explorerLinks, which
validates the hash against TX_HASH_PATTERN before constructing the URL and
defaults to the public network instead of hardcoding testnet.

- Add network prop (ExplorerNetwork, defaults to 'public') to
  PurchaseSuccessModalProps so callers pass the configured network.
- Restore Dialog.tsx component that was deleted in 1ecce7d.
- Add test asserting no explorer link when txHash fails validation.
- Add test asserting explorer link uses correct network (public/testnet).

Closes Commitlabs-Org#1399
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Cerome360 is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

@1nonlypiece
1nonlypiece merged commit 412134b into Commitlabs-Org:master Jul 28, 2026
2 of 12 checks passed
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

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

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.

PurchaseSuccessModal.tsx hand-rolls a hardcoded testnet Stellar Explorer link instead of using buildExplorerUrl

2 participants