Bug
contracts/pool/src/lib.rs — pause() sets a Paused storage flag to true but does not check whether the contract is already paused. Calling pause() on an already-paused contract:
- Succeeds silently (no error, no event distinguishing a double-pause from first pause)
- Wastes gas on a no-op write
- Could confuse monitoring systems that count pause events
Same issue applies to unpause() on an already-unpaused contract.
Fix
pub fn pause(env: &Env, admin: Address) {
admin.require_auth();
verify_admin(&env, &admin);
if is_paused(&env) {
return Err(PoolError::AlreadyPaused);
}
env.storage().persistent().set(&DataKey::Paused, &true);
env.events().publish((Symbol::new(&env, "POOL"), Symbol::new(&env, "paused")), admin);
}
pub fn unpause(env: &Env, admin: Address) {
admin.require_auth();
verify_admin(&env, &admin);
if !is_paused(&env) {
return Err(PoolError::NotPaused);
}
env.storage().persistent().set(&DataKey::Paused, &false);
env.events().publish((Symbol::new(&env, "POOL"), Symbol::new(&env, "unpaused")), admin);
}
Apply the same fix to the invoice and credit score contracts.
Acceptance Criteria
References
contracts/pool/src/lib.rs, contracts/invoice/src/lib.rs, contracts/credit_score/src/lib.rs — pause(), unpause()
Bug
contracts/pool/src/lib.rs—pause()sets aPausedstorage flag totruebut does not check whether the contract is already paused. Callingpause()on an already-paused contract:Same issue applies to
unpause()on an already-unpaused contract.Fix
Apply the same fix to the invoice and credit score contracts.
Acceptance Criteria
pause()returnsAlreadyPausedwhen already pausedunpause()returnsNotPausedwhen already unpausedReferences
contracts/pool/src/lib.rs,contracts/invoice/src/lib.rs,contracts/credit_score/src/lib.rs—pause(),unpause()