Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): immutable state updates in store mutation functions #220

Merged
merged 4 commits into from
Aug 21, 2024

Conversation

drichar
Copy link
Collaborator

@drichar drichar commented Aug 21, 2024

Description

This PR addresses the bug described in issue #219, where store mutation functions were inadvertently modifying state in unexpected ways. The fix ensures that the setActiveAccount, addWallet, and setAccounts functions create new object references for nested state properties, preventing unintended mutations of the original state.

Details

  • Refactored setActiveAccount, addWallet, and setAccounts to create new object references for nested state properties (wallet state, accounts array, active account).
  • Added unit tests to verify the fixes and ensure no unintended state mutations occur.
  • These changes prevent unexpected behavior and potential loss of account information that could result from modifying shared object references.

Closes #219

@drichar drichar changed the title fix(use-wallet): immutable state updates in store mutation functions fix(core): immutable state updates in store mutation functions Aug 21, 2024
@drichar drichar merged commit 22421d4 into main Aug 21, 2024
1 check passed
@drichar drichar deleted the fix/use-wallet/set-active-account-mutates-state branch August 21, 2024 04:07
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.

setActiveAccount inadvertently modifies other accounts in wallet state
1 participant