git.delta.rocks / unique-network / refs/commits / 3cb5e43c69bb

difftreelog

CORE-410 Implement token_owner for Refungible token

Trubnikov Sergey2022-07-07parent: #0427b9a.patch.diff
in: master

2 files changed

modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -413,8 +413,8 @@
 		TokenId(<TokensMinted<T>>::get(self.id))
 	}
 
-	fn token_owner(&self, _token: TokenId) -> Option<T::CrossAccountId> {
-		None
+	fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId> {
+		<Pallet<T>>::token_owner(self.id, token)
 	}
 
 	fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
1094 Ok(())1094 Ok(())
1095 }1095 }
1096
1097 fn token_owner(collection_id: CollectionId, token_id: TokenId) -> Option<T::CrossAccountId> {
1098 let mut owner = None;
1099 let mut count = 0;
1100 for key in Balance::<T>::iter_key_prefix((collection_id, token_id)) {
1101 count += 1;
1102 if count > 1 {
1103 return None;
1104 }
1105 owner = Some(key);
1106 }
1107 owner
1108 }
10961109
1097 fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<u128> {1110 fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<u128> {
1098 <TotalSupply<T>>::try_get((collection_id, token_id)).ok()1111 <TotalSupply<T>>::try_get((collection_id, token_id)).ok()