Skip to content

Refactor transaction-explorer: fix zero-value handling, simplify fee logic, and optimize address Set creation#440

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

Refactor transaction-explorer: fix zero-value handling, simplify fee logic, and optimize address Set creation#440
jamespepper81 merged 6 commits into
mainfrom
dev

Conversation

@jamespepper81
Copy link
Copy Markdown
Contributor

This pull request introduces performance improvements and minor code quality enhancements to the app/transaction-explorer.tsx file, primarily by memoizing the wallet address set and making small adjustments to variable naming and value handling. The main focus is to optimize address set creation and improve code clarity.

Performance optimizations:

  • Added a memoization function getAddressSet to avoid recreating the wallet address Set on every call, improving efficiency when determining wallet-related addresses.
  • Updated the code to use the memoized getAddressSet instead of creating a new Set inline when building transaction explorer data.

Code quality and clarity:

  • Renamed the userWallet parameter to currentWallet in the buildExplorerData function for improved clarity and consistency.
  • Improved type safety in value calculations by ensuring that vin.value is a number before performing arithmetic operations.
  • Simplified transaction fee calculation by directly using txDetails.fee with a fallback to zero, removing redundant type checking.

Other minor changes:

  • Small formatting and whitespace cleanup for readability.

Copilot AI and others added 6 commits January 9, 2026 20:11
- Add memoization for wallet address Set to improve performance
- Rename userWallet parameter to currentWallet for consistency
- Simplify fee handling logic
- Fix vin.value condition to properly handle zero values
- Remove unnecessary blank lines

Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com>
Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com>
The previous implementation compared a normalized array which would always create a new reference. Now comparing the original addresses reference for proper memoization.

Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com>
Allow the cache to properly handle both null and undefined by storing the exact reference without normalizing to undefined.

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

Refactor transaction-explorer: fix zero-value handling, simplify fee logic, and optimize address Set creation
@jamespepper81 jamespepper81 merged commit a02ec4b 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