Skip to content

feat: add production-grade useWallet hook with state machine, AbortCo…#30

Merged
Queenode merged 1 commit into
Kolo-Org:mainfrom
Skinny001:fix/use-wallet-hook
Jun 23, 2026
Merged

feat: add production-grade useWallet hook with state machine, AbortCo…#30
Queenode merged 1 commit into
Kolo-Org:mainfrom
Skinny001:fix/use-wallet-hook

Conversation

@Skinny001

Copy link
Copy Markdown
Contributor

This pull request introduces a new React hook for wallet management, enhances the Stellar wallet generation process to use encryption for secrets, and adds comprehensive tests for the new functionality. It also updates dependencies to support React and testing libraries. These changes improve both the security of wallet secrets and the testability of wallet-related features.
close #27

Wallet functionality and security:

  • Added a new useWallet React hook and supporting function fetchWalletData in src/hooks/useWallet.ts, providing stateful wallet data fetching and management for the frontend.
  • Updated the Stellar wallet generation logic in StellarService to encrypt the wallet secret and return the encrypted value along with initialization vector (iv) and auth tag, replacing the previous approach that returned the raw secret. [1] [2]
  • Modified UserService to store the encrypted wallet secret (with iv and auth tag) in the database instead of the plaintext secret, improving custodial wallet security. [1] [2]

Testing improvements:

  • Added thorough tests for the new useWallet hook and wallet data fetching in src/__tests__/useWallet.test.ts, covering success, error, abort, and state reset scenarios.
  • Refactored and updated tests in src/__tests__/stellar.service.test.ts to align with the new encrypted secret format and to clean up and clarify test logic. [1] [2] [3] [4] [5] [6]

Dependency updates:

  • Added React (react, react-dom), React Testing Library, JSDOM, and related type packages to package.json to support frontend development and testing.…ntroller, and full test coverage
  • Strict WalletState type (idle | loading | success | error) with useReducer
  • AbortController for race condition / unmount cleanup
  • Proper useEffect dependency array
  • Extracted fetchWalletData() for independent testability
  • Response boundary validation
  • 11 unit tests covering success, failure, abort, unmount, and reset

…ntroller, and full test coverage

- Strict WalletState type (idle | loading | success | error) with useReducer
- AbortController for race condition / unmount cleanup
- Proper useEffect dependency array
- Extracted fetchWalletData() for independent testability
- Response boundary validation
- 11 unit tests covering success, failure, abort, unmount, and reset
@Queenode

Copy link
Copy Markdown
Contributor

thank you for your contribution to Kolo @Skinny001
welldone

@Queenode Queenode merged commit fc2cbde into Kolo-Org:main Jun 23, 2026
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 23, 2026
8 tasks
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.

Duplicate API Calls on Mount

2 participants