Resolve the owner of an Aptos object inside another object
An item stored under a container’s ownership can be absent from a wallet lookup that compares only immediate owners. Decide whether the report needs direct or transitive ownership.
Walk the ownership relation with the framework
In a test fixture, transfer an item into a container controlled by wallet. The first lookup should return the container address. The second tests whether wallet owns the item along the ownership chain. Record the ledger version when comparing separate off-chain reads.
let direct = aptos_framework::object::owner(item);
let controlled = aptos_framework::object::owns(item, wallet);
assert!(direct == container_address && controlled, 0);
Keep effective ownership separate from transfer permissions
Moving the container from Alice to Bob can change the item’s transitive owner while its direct owner remains the container. Recompute descendants when indexing that transfer. Transfer restrictions on objects and limits on traversal depth still apply; a positive ownership check alone does not promise every transfer operation will succeed.