Skip to content

fix(globe-wallet): remove SpendLimit/DailySpent when removing asset (#89) - #109

Open
ZacLou wants to merge 1 commit into
Orbit-Wal:mainfrom
ZacLou:fix/remove-asset-cleans-spend-state
Open

fix(globe-wallet): remove SpendLimit/DailySpent when removing asset (#89)#109
ZacLou wants to merge 1 commit into
Orbit-Wal:mainfrom
ZacLou:fix/remove-asset-cleans-spend-state

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 2, 2026

Copy link
Copy Markdown

Closes #89

remove_asset previously left the per-asset SpendLimit and DailySpent entries in persistent storage, causing two problems:

  1. Unbounded persistent-storage growth over a wallet's lifetime.
  2. A surprise when the user removes an asset and later re-adds it: the old limit silently reapplies.

This change cleans up both keys alongside the UserAssets entry, matching the cleanup already done by migrate_user_assets.

Added tests

  • test_remove_asset_clears_spend_limit_and_daily_spent — proves the limit resets to 0 after removal and that re-adding starts fresh.
  • test_remove_asset_keeps_other_asset_limits_intact — proves removing one asset does not affect another user's asset limits.

No public API or enum discriminants are changed.

Closes Orbit-Wal#89.


emove_asset previously left the per-asset SpendLimit and DailySpent
entries in persistent storage, causing unbounded storage growth and
surprising behavior when the asset was re-added later. Clean them up
alongside the UserAssets entry, matching the cleanup already done by
migrate_user_assets.

Also adds tests proving the limit resets to 0 after removal, re-adding
starts fresh, and other asset limits are untouched.
@ZacLou

ZacLou commented Sep 2, 2026

Copy link
Copy Markdown
Author

Local verification passed on Windows:

  • cargo test -p globe-wallet → 88 unit tests + 1 reentrancy integration test passed.
  • cargo clippy -p globe-wallet -- -A deprecated → clean (the repo has pre-existing deprecation warnings from the legacy transfer_admin path).

The two new regression tests specifically cover the orphaned-state bug described in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants