Skip to content

feat: hooks first architecture#564

Closed
Copilot wants to merge 1 commit into
feat/hooks-first-architecturefrom
copilot/sub-pr-563
Closed

feat: hooks first architecture#564
Copilot wants to merge 1 commit into
feat/hooks-first-architecturefrom
copilot/sub-pr-563

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 3, 2025

Refactors vault service to a hooks-first architecture, separating business logic (hooks) from pure utility functions (services) and presentation (components).

Architecture Changes

  • Three-layer service structure: calculations, validations, and transformers as pure functions
  • React hooks orchestration: deposit flow logic moved to useDepositValidation and useDepositTransaction
  • Documentation: added architecture guide and migration patterns

Bug Fixes

  • Precision safety in formatSatoshisToBtc: replaced Number conversion with bigint arithmetic throughout to prevent loss for values ≥ 2^53
  • Input validation in parseBtcToSatoshis: handles edge cases (empty strings, decimals-only input like ".5", multiple decimal points)
  • Magic numbers extracted: fee calculation constants (BASE_TX_SIZE, PER_INPUT_SIZE, FEE_RATE) now named and configurable
  • Unused imports removed: cleaned up useDepositTransaction and useDepositValidation
// Before: precision loss risk
const btc = Number(satoshis) / 100_000_000;

// After: bigint arithmetic
const whole = satoshis / SATOSHIS_PER_BTC;
const fraction = satoshis % SATOSHIS_PER_BTC;

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Make requested changes to #563 feat: hooks first architecture Nov 3, 2025
Copilot AI requested a review from jonybur November 3, 2025 16:36
@jonybur jonybur closed this Nov 3, 2025
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