Improve type safety and code clarity in transaction explorer#438
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the type safety, maintainability, and consistency of the
TransactionExplorerScreeninapp/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:
NormalizedVinSource,NormalizedVoutSource, andExtendedTransactionDetailsinterfaces to improve type safety and clarify the structure of normalized transaction data and extended transaction details.buildExplorerDatato use the new interfaces, ensuring consistent structure for inputs (vin) and outputs (vout) and removing use ofas anytype assertions. [1] [2]Constants and code clarity:
SATOSHIS_PER_BTCconstant to replace repeated use of the magic number1e8for satoshis-to-BTC conversions, improving code readability and maintainability. [1] [2] [3]Consistent usage of extended transaction details:
net_amount,vsize,size, etc.) to use the newExtendedTransactionDetailsinterface, ensuring proper typing and reducing potential runtime errors.Variable naming improvements:
currentWalletparameter touserWalletinbuildExplorerDatafor clarity and consistency.