Keep a nested Sui inventory object discoverable by ID
A tool can belong to a rack while retaining an identity visible to off-chain clients. Dynamic object fields provide different discovery behavior from storing the tool inside an ordinary dynamic field.
Attach an object as an object field
Assume Tool has key and store and the rack module controls its UID. Capture the tool’s ID before moving it into the rack. Borrowing by the typed slot confirms that the same object remains attached.
use sui::dynamic_object_field as children;
let child_id = object::id(&tool);
children::add(&mut rack.id, 1u8, tool);
let stored = children::borrow<u8, Tool>(&rack.id, 1u8);
assert!(object::id(stored) == child_id, 0);
Separate discovery from permission to move the child
An off-chain reader can track the attached tool by its object ID. To remove it in Move, the application still needs mutable access to the rack and the matching field name. An inventory UI should therefore use the parent’s withdrawal rule when enabling its release button. A discoverable ID alone gives no authority to withdraw.