From 9f027cac3e7569ab5300c99748bddb6edb494d01 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Tue, 21 Mar 2023 15:36:47 +0100 Subject: [PATCH] feat(storage): unpin sender on forget --- contracts/cw-storage/src/contract.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contracts/cw-storage/src/contract.rs b/contracts/cw-storage/src/contract.rs index cbc3b015..0a9fa872 100644 --- a/contracts/cw-storage/src/contract.rs +++ b/contracts/cw-storage/src/contract.rs @@ -198,9 +198,13 @@ pub mod execute { pub fn forget_object( deps: DepsMut, - _info: MessageInfo, + info: MessageInfo, object_id: ObjectId, ) -> Result { + if pins().has(deps.storage, (object_id.clone(), info.sender.clone())) { + pins().remove(deps.storage, (object_id.clone(), info.sender))?; + } + if pins() .idx .object @@ -1589,7 +1593,7 @@ mod tests { )], forget_senders: vec![mock_info("bob", &[])], // the sender is the same as the pinner, so forget should work expected_count: 2, - expected_total_size: Uint128::new(13), + expected_total_size: Uint128::new(9), expected_error: None, }, TestForgetCase {