Skip to content

fix(learn-token): enforce require_not_paused on admin and config operations (#500) - #514

Open
lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:fix/admin-config-pause-check-500
Open

lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:fix/admin-config-pause-check-500

Conversation

@lmduy2612

Copy link
Copy Markdown

Summary of Changes

Enforces emergency pause checks across all 10 administrative and configuration functions in LearnToken as specified in #500:

  1. set_transfer_restriction
  2. add_to_whitelist
  3. remove_from_whitelist
  4. snapshot
  5. record_balance_snapshot
  6. grant_role
  7. revoke_role
  8. add_admin
  9. remove_admin
  10. increase_allowance

Each function now calls Self::require_not_paused(&env) immediately following authentication, ensuring that an emergency pause halts all state mutations.

Verification & Testing

  • Added 10 dedicated #[should_panic(expected = "contract is paused")] unit tests in tests/unit/token_tests.rs verifying that each operation reverts when paused:
    • test_set_transfer_restriction_fails_while_paused
    • test_add_to_whitelist_fails_while_paused
    • test_remove_from_whitelist_fails_while_paused
    • test_snapshot_fails_while_paused
    • test_record_balance_snapshot_fails_while_paused
    • test_grant_role_fails_while_paused
    • test_revoke_role_fails_while_paused
    • test_add_admin_fails_while_paused
    • test_remove_admin_fails_while_paused
    • test_increase_allowance_fails_while_paused
  • Added test_unpause_restores_admin_and_config_operations asserting that operations succeed after unpause.
  • All 89 unit tests pass in cargo test --test token_tests.
  • All 4 tests in tests/integration/emergency_pause_flow.rs pass.
  • 0 warnings in cargo clippy --test token_tests.

Closes #500

…ations

- Add Self::require_not_paused(&env) checks to set_transfer_restriction, add_to_whitelist, remove_from_whitelist, snapshot, record_balance_snapshot, grant_role, revoke_role, add_admin, remove_admin, and increase_allowance
- Add dedicated unit tests verifying all 10 operations panic when paused and resume upon unpause
- Clean up test sequence numbers and assertions in token_tests.rs

Closes ChainLearnOfficial#500
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.

Multiple learn-token admin and configuration functions bypass pause state check

2 participants