difftreelog
CORE-410 Implement token_owner for Refungible token
in: master
2 files changed
pallets/refungible/src/common.rsdiffbeforeafterboth413 TokenId(<TokensMinted<T>>::get(self.id))413 TokenId(<TokensMinted<T>>::get(self.id))414 }414 }415415416 fn token_owner(&self, _token: TokenId) -> Option<T::CrossAccountId> {416 fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId> {417 None417 <Pallet<T>>::token_owner(self.id, token)418 }418 }419419420 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {420 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -1094,6 +1094,19 @@
Ok(())
}
+ fn token_owner(collection_id: CollectionId, token_id: TokenId) -> Option<T::CrossAccountId> {
+ let mut owner = None;
+ let mut count = 0;
+ for key in Balance::<T>::iter_key_prefix((collection_id, token_id)) {
+ count += 1;
+ if count > 1 {
+ return None;
+ }
+ owner = Some(key);
+ }
+ owner
+ }
+
fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<u128> {
<TotalSupply<T>>::try_get((collection_id, token_id)).ok()
}