Skip to content

Improve type safety and code clarity in transaction explorer#438

Merged
jamespepper81 merged 4 commits into
mainfrom
dev
Jan 9, 2026
Merged

Improve type safety and code clarity in transaction explorer#438
jamespepper81 merged 4 commits into
mainfrom
dev

Conversation

@jamespepper81
Copy link
Copy Markdown
Contributor

This pull request improves the type safety, maintainability, and consistency of the TransactionExplorerScreen in app/transaction-explorer.tsx. The main changes include introducing new TypeScript interfaces for transaction normalization, replacing magic numbers with a named constant for satoshis-to-BTC conversion, and refactoring the transaction data processing logic to use these improvements throughout.

Type safety and normalization improvements:

  • Added NormalizedVinSource, NormalizedVoutSource, and ExtendedTransactionDetails interfaces to improve type safety and clarify the structure of normalized transaction data and extended transaction details.
  • Updated the normalization logic in buildExplorerData to use the new interfaces, ensuring consistent structure for inputs (vin) and outputs (vout) and removing use of as any type assertions. [1] [2]

Constants and code clarity:

  • Introduced the SATOSHIS_PER_BTC constant to replace repeated use of the magic number 1e8 for satoshis-to-BTC conversions, improving code readability and maintainability. [1] [2] [3]

Consistent usage of extended transaction details:

  • Refactored all references to extra transaction fields (such as net_amount, vsize, size, etc.) to use the new ExtendedTransactionDetails interface, ensuring proper typing and reducing potential runtime errors.

Variable naming improvements:

  • Renamed the currentWallet parameter to userWallet in buildExplorerData for clarity and consistency.

Copilot AI and others added 4 commits January 9, 2026 19:45
- Rename currentWallet to userWallet for clarity
- Add NormalizedVinSource interface for type safety
- Add NormalizedVoutSource interface for type safety
- Add SATOSHIS_PER_BTC constant to replace magic number
- Add ExtendedTransactionDetails interface to replace type assertions

Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com>
Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com>
…t-parameter

Improve type safety and code clarity in transaction explorer
@jamespepper81 jamespepper81 merged commit ad9c944 into main Jan 9, 2026
4 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.

2 participants