From 5e9e1fa9af0bba0f3ad701c3743fb95f4282b9c1 Mon Sep 17 00:00:00 2001 From: jolestar Date: Wed, 11 Oct 2023 13:40:39 +0800 Subject: [PATCH] [MoveosStd] unpack the object when context::remove_object --- moveos/moveos-stdlib/moveos-stdlib/doc/context.md | 9 +++++---- moveos/moveos-stdlib/moveos-stdlib/sources/context.move | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/moveos/moveos-stdlib/moveos-stdlib/doc/context.md b/moveos/moveos-stdlib/moveos-stdlib/doc/context.md index cd87f6f9c2..e68c5c58ed 100644 --- a/moveos/moveos-stdlib/moveos-stdlib/doc/context.md +++ b/moveos/moveos-stdlib/moveos-stdlib/doc/context.md @@ -432,10 +432,10 @@ Borrow mut Object from object store with object_id ## Function `remove_object` -Remove object from object store +Remove object from object store, and unpack the Object -
public fun remove_object<T: key>(self: &mut context::Context, object_id: object_id::ObjectID): object::Object<T>
+
public fun remove_object<T: key>(self: &mut context::Context, object_id: object_id::ObjectID): (object_id::ObjectID, address, T)
 
@@ -444,8 +444,9 @@ Remove object from object store Implementation -
public fun remove_object<T: key>(self: &mut Context, object_id: ObjectID): Object<T> {
-    storage_context::remove<T>(&mut self.storage_context, object_id)
+
public fun remove_object<T: key>(self: &mut Context, object_id: ObjectID): (ObjectID, address, T) {
+    let obj = storage_context::remove<T>(&mut self.storage_context, object_id);
+    object::unpack_internal(obj)
 }
 
diff --git a/moveos/moveos-stdlib/moveos-stdlib/sources/context.move b/moveos/moveos-stdlib/moveos-stdlib/sources/context.move index cb4f03d36a..9bd3f4a641 100644 --- a/moveos/moveos-stdlib/moveos-stdlib/sources/context.move +++ b/moveos/moveos-stdlib/moveos-stdlib/sources/context.move @@ -107,9 +107,10 @@ module moveos_std::context { } #[private_generics(T)] - /// Remove object from object store - public fun remove_object(self: &mut Context, object_id: ObjectID): Object { - storage_context::remove(&mut self.storage_context, object_id) + /// Remove object from object store, and unpack the Object + public fun remove_object(self: &mut Context, object_id: ObjectID): (ObjectID, address, T) { + let obj = storage_context::remove(&mut self.storage_context, object_id); + object::unpack_internal(obj) } public fun contains_object(self: &Context, object_id: ObjectID): bool {