diff --git a/crates/sui-storage/src/indexes.rs b/crates/sui-storage/src/indexes.rs index e4ce9ccec89f2..aafe5f8b8c9fb 100644 --- a/crates/sui-storage/src/indexes.rs +++ b/crates/sui-storage/src/indexes.rs @@ -482,7 +482,7 @@ impl IndexStore { &self.tables.transactions_to_addr, mutated_objects.filter_map(|(_, owner)| { owner - .get_owner_address() + .get_address_owner_address() .ok() .map(|addr| ((addr, sequence), digest)) }), diff --git a/crates/sui-types/src/object.rs b/crates/sui-types/src/object.rs index c9a67b46288ba..22f007b9c1cca 100644 --- a/crates/sui-types/src/object.rs +++ b/crates/sui-types/src/object.rs @@ -488,6 +488,19 @@ pub enum Owner { } impl Owner { + // NOTE: only return address of AddressOwner, otherwise return error, + // ObjectOwner's address is converted from object id, thus we will skip it. + pub fn get_address_owner_address(&self) -> SuiResult { + match self { + Self::AddressOwner(address) => Ok(*address), + Self::Shared { .. } | Self::Immutable | Self::ObjectOwner(_) => { + Err(SuiError::UnexpectedOwnerType) + } + } + } + + // NOTE: this function will return address of both AddressOwner and ObjectOwner, + // address of ObjectOwner is converted from object id, even though the type is SuiAddress. pub fn get_owner_address(&self) -> SuiResult { match self { Self::AddressOwner(address) | Self::ObjectOwner(address) => Ok(*address),