git.delta.rocks / unique-network / refs/commits / da952fd3c8fb

difftreelog

initial commit

PraetorP2022-07-11parent: #5ffdcf0.patch.diff
in: master

14 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -70,6 +70,15 @@
 		token: TokenId,
 		at: Option<BlockHash>,
 	) -> Result<Option<CrossAccountId>>;
+
+	#[method(name = "unique_tokenOwners")]
+	fn token_owners(
+		&self,
+		collection: CollectionId,
+		token: TokenId,
+		at: Option<BlockHash>,
+	) -> Result<Vec<CrossAccountId>>;
+
 	#[method(name = "unique_topmostTokenOwner")]
 	fn topmost_token_owner(
 		&self,
@@ -473,6 +482,7 @@
 	pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>, unique_api);
 	pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);
 	pass_method!(total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<u128>, unique_api);
+	pass_method!(token_owners(collection: CollectionId, token: TokenId) -> Vec<CrossAccountId>, unique_api);
 }
 
 #[allow(deprecated)]
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -1748,6 +1748,9 @@
 	/// * `token` - The token for which you need to find out the owner.
 	fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId>;
 
+	/// Token owners
+	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId>;
+
 	/// Get the value of the token property by key.
 	///
 	/// * `token` - Token with the property to get.
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -362,6 +362,10 @@
 		None
 	}
 
+	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {
+		<Pallet<T>>::token_owners(self.id, token).unwrap_or_else(|| vec![])
+	}
+
 	fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {
 		None
 	}
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -95,7 +95,7 @@
 use pallet_evm_coder_substrate::WithRecorder;
 use sp_core::H160;
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
-use sp_std::{collections::btree_map::BTreeMap};
+use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
 
 pub use pallet::*;
 
@@ -613,4 +613,20 @@
 			nesting_budget,
 		)
 	}
+
+	pub fn token_owners(
+		collection: CollectionId,
+		_token: TokenId,
+	) -> Option<Vec<T::CrossAccountId>> {
+		let res: Vec<T::CrossAccountId> = <Balance<T>>::iter_prefix((collection,))
+			.map(|r| r.0)
+			.take(10)
+			.collect();
+
+		if res.len() == 0 {
+			None
+		} else {
+			Some(res)
+		}
+	}
 }
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
before · pallets/nonfungible/src/common.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use core::marker::PhantomData;1819use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};20use up_data_structs::{21	TokenId, CreateItemExData, CollectionId, budget::Budget, Property, PropertyKey,22	PropertyKeyPermission, PropertyValue,23};24use pallet_common::{25	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,26	weights::WeightInfo as _,27};28use sp_runtime::DispatchError;29use sp_std::vec::Vec;3031use crate::{32	AccountBalance, Allowance, Config, CreateItemData, Error, NonfungibleHandle, Owned, Pallet,33	SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,34};3536pub struct CommonWeights<T: Config>(PhantomData<T>);37impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {38	fn create_item() -> Weight {39		<SelfWeightOf<T>>::create_item()40	}4142	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {43		match data {44			CreateItemExData::NFT(t) => {45				<SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)46					+ t.iter()47						.map(|t| {48							if t.properties.len() > 0 {49								Self::set_token_properties(t.properties.len() as u32)50							} else {51								052							}53						})54						.sum::<u64>()55			}56			_ => 0,57		}58	}5960	fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {61		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32)62			+ data63				.iter()64				.filter_map(|t| match t {65					up_data_structs::CreateItemData::NFT(n) if n.properties.len() > 0 => {66						Some(Self::set_token_properties(n.properties.len() as u32))67					}68					_ => None,69				})70				.sum::<u64>()71	}7273	fn burn_item() -> Weight {74		<SelfWeightOf<T>>::burn_item()75	}7677	fn set_collection_properties(amount: u32) -> Weight {78		<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)79	}8081	fn delete_collection_properties(amount: u32) -> Weight {82		<pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)83	}8485	fn set_token_properties(amount: u32) -> Weight {86		<SelfWeightOf<T>>::set_token_properties(amount)87	}8889	fn delete_token_properties(amount: u32) -> Weight {90		<SelfWeightOf<T>>::delete_token_properties(amount)91	}9293	fn set_token_property_permissions(amount: u32) -> Weight {94		<SelfWeightOf<T>>::set_token_property_permissions(amount)95	}9697	fn transfer() -> Weight {98		<SelfWeightOf<T>>::transfer()99	}100101	fn approve() -> Weight {102		<SelfWeightOf<T>>::approve()103	}104105	fn transfer_from() -> Weight {106		<SelfWeightOf<T>>::transfer_from()107	}108109	fn burn_from() -> Weight {110		<SelfWeightOf<T>>::burn_from()111	}112113	fn burn_recursively_self_raw() -> Weight {114		<SelfWeightOf<T>>::burn_recursively_self_raw()115	}116117	fn burn_recursively_breadth_raw(amount: u32) -> Weight {118		<SelfWeightOf<T>>::burn_recursively_breadth_plus_self_plus_self_per_each_raw(amount)119			.saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))120	}121}122123fn map_create_data<T: Config>(124	data: up_data_structs::CreateItemData,125	to: &T::CrossAccountId,126) -> Result<CreateItemData<T>, DispatchError> {127	match data {128		up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData::<T> {129			properties: data.properties,130			owner: to.clone(),131		}),132		_ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),133	}134}135136/// Implementation of `CommonCollectionOperations` for `NonfungibleHandle`. It wraps Nonfungible Pallete137/// methods and adds weight info.138impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {139	fn create_item(140		&self,141		sender: T::CrossAccountId,142		to: T::CrossAccountId,143		data: up_data_structs::CreateItemData,144		nesting_budget: &dyn Budget,145	) -> DispatchResultWithPostInfo {146		with_weight(147			<Pallet<T>>::create_item(148				self,149				&sender,150				map_create_data::<T>(data, &to)?,151				nesting_budget,152			),153			<CommonWeights<T>>::create_item(),154		)155	}156157	fn create_multiple_items(158		&self,159		sender: T::CrossAccountId,160		to: T::CrossAccountId,161		data: Vec<up_data_structs::CreateItemData>,162		nesting_budget: &dyn Budget,163	) -> DispatchResultWithPostInfo {164		let weight = <CommonWeights<T>>::create_multiple_items(&data);165		let data = data166			.into_iter()167			.map(|d| map_create_data::<T>(d, &to))168			.collect::<Result<Vec<_>, DispatchError>>()?;169170		with_weight(171			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),172			weight,173		)174	}175176	fn create_multiple_items_ex(177		&self,178		sender: <T>::CrossAccountId,179		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,180		nesting_budget: &dyn Budget,181	) -> DispatchResultWithPostInfo {182		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);183		let data = match data {184			up_data_structs::CreateItemExData::NFT(nft) => nft,185			_ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),186		};187188		with_weight(189			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),190			weight,191		)192	}193194	fn set_collection_properties(195		&self,196		sender: T::CrossAccountId,197		properties: Vec<Property>,198	) -> DispatchResultWithPostInfo {199		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);200201		with_weight(202			<Pallet<T>>::set_collection_properties(self, &sender, properties),203			weight,204		)205	}206207	fn delete_collection_properties(208		&self,209		sender: &T::CrossAccountId,210		property_keys: Vec<PropertyKey>,211	) -> DispatchResultWithPostInfo {212		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);213214		with_weight(215			<Pallet<T>>::delete_collection_properties(self, sender, property_keys),216			weight,217		)218	}219220	fn set_token_properties(221		&self,222		sender: T::CrossAccountId,223		token_id: TokenId,224		properties: Vec<Property>,225		nesting_budget: &dyn Budget,226	) -> DispatchResultWithPostInfo {227		let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);228229		with_weight(230			<Pallet<T>>::set_token_properties(231				self,232				&sender,233				token_id,234				properties.into_iter(),235				false,236				nesting_budget,237			),238			weight,239		)240	}241242	fn delete_token_properties(243		&self,244		sender: T::CrossAccountId,245		token_id: TokenId,246		property_keys: Vec<PropertyKey>,247		nesting_budget: &dyn Budget,248	) -> DispatchResultWithPostInfo {249		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);250251		with_weight(252			<Pallet<T>>::delete_token_properties(253				self,254				&sender,255				token_id,256				property_keys.into_iter(),257				nesting_budget,258			),259			weight,260		)261	}262263	fn set_token_property_permissions(264		&self,265		sender: &T::CrossAccountId,266		property_permissions: Vec<PropertyKeyPermission>,267	) -> DispatchResultWithPostInfo {268		let weight =269			<CommonWeights<T>>::set_token_property_permissions(property_permissions.len() as u32);270271		with_weight(272			<Pallet<T>>::set_token_property_permissions(self, sender, property_permissions),273			weight,274		)275	}276277	fn burn_item(278		&self,279		sender: T::CrossAccountId,280		token: TokenId,281		amount: u128,282	) -> DispatchResultWithPostInfo {283		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);284		if amount == 1 {285			with_weight(286				<Pallet<T>>::burn(self, &sender, token),287				<CommonWeights<T>>::burn_item(),288			)289		} else {290			Ok(().into())291		}292	}293294	fn burn_item_recursively(295		&self,296		sender: T::CrossAccountId,297		token: TokenId,298		self_budget: &dyn Budget,299		breadth_budget: &dyn Budget,300	) -> DispatchResultWithPostInfo {301		<Pallet<T>>::burn_recursively(self, &sender, token, self_budget, breadth_budget)302	}303304	fn transfer(305		&self,306		from: T::CrossAccountId,307		to: T::CrossAccountId,308		token: TokenId,309		amount: u128,310		nesting_budget: &dyn Budget,311	) -> DispatchResultWithPostInfo {312		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);313		if amount == 1 {314			with_weight(315				<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),316				<CommonWeights<T>>::transfer(),317			)318		} else {319			Ok(().into())320		}321	}322323	fn approve(324		&self,325		sender: T::CrossAccountId,326		spender: T::CrossAccountId,327		token: TokenId,328		amount: u128,329	) -> DispatchResultWithPostInfo {330		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);331332		with_weight(333			if amount == 1 {334				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))335			} else {336				<Pallet<T>>::set_allowance(self, &sender, token, None)337			},338			<CommonWeights<T>>::approve(),339		)340	}341342	fn transfer_from(343		&self,344		sender: T::CrossAccountId,345		from: T::CrossAccountId,346		to: T::CrossAccountId,347		token: TokenId,348		amount: u128,349		nesting_budget: &dyn Budget,350	) -> DispatchResultWithPostInfo {351		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);352353		if amount == 1 {354			with_weight(355				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),356				<CommonWeights<T>>::transfer_from(),357			)358		} else {359			Ok(().into())360		}361	}362363	fn burn_from(364		&self,365		sender: T::CrossAccountId,366		from: T::CrossAccountId,367		token: TokenId,368		amount: u128,369		nesting_budget: &dyn Budget,370	) -> DispatchResultWithPostInfo {371		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);372373		if amount == 1 {374			with_weight(375				<Pallet<T>>::burn_from(self, &sender, &from, token, nesting_budget),376				<CommonWeights<T>>::burn_from(),377			)378		} else {379			Ok(().into())380		}381	}382383	fn check_nesting(384		&self,385		sender: T::CrossAccountId,386		from: (CollectionId, TokenId),387		under: TokenId,388		nesting_budget: &dyn Budget,389	) -> sp_runtime::DispatchResult {390		<Pallet<T>>::check_nesting(self, sender, from, under, nesting_budget)391	}392393	fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId)) {394		<Pallet<T>>::nest((self.id, under), to_nest);395	}396397	fn unnest(&self, under: TokenId, to_unnest: (CollectionId, TokenId)) {398		<Pallet<T>>::unnest((self.id, under), to_unnest);399	}400401	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {402		<Owned<T>>::iter_prefix((self.id, account))403			.map(|(id, _)| id)404			.collect()405	}406407	fn collection_tokens(&self) -> Vec<TokenId> {408		<TokenData<T>>::iter_prefix((self.id,))409			.map(|(id, _)| id)410			.collect()411	}412413	fn token_exists(&self, token: TokenId) -> bool {414		<Pallet<T>>::token_exists(self, token)415	}416417	fn last_token_id(&self) -> TokenId {418		TokenId(<TokensMinted<T>>::get(self.id))419	}420421	fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId> {422		<TokenData<T>>::get((self.id, token)).map(|t| t.owner)423	}424425	fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue> {426		<Pallet<T>>::token_properties((self.id, token_id))427			.get(key)428			.cloned()429	}430431	fn token_properties(&self, token_id: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property> {432		let properties = <Pallet<T>>::token_properties((self.id, token_id));433434		keys.map(|keys| {435			keys.into_iter()436				.filter_map(|key| {437					properties.get(&key).map(|value| Property {438						key,439						value: value.clone(),440					})441				})442				.collect()443		})444		.unwrap_or_else(|| {445			properties446				.into_iter()447				.map(|(key, value)| Property { key, value })448				.collect()449		})450	}451452	fn total_supply(&self) -> u32 {453		<Pallet<T>>::total_supply(self)454	}455456	fn account_balance(&self, account: T::CrossAccountId) -> u32 {457		<AccountBalance<T>>::get((self.id, account))458	}459460	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {461		if <TokenData<T>>::get((self.id, token))462			.map(|a| a.owner == account)463			.unwrap_or(false)464		{465			1466		} else {467			0468		}469	}470471	fn allowance(472		&self,473		sender: T::CrossAccountId,474		spender: T::CrossAccountId,475		token: TokenId,476	) -> u128 {477		if <TokenData<T>>::get((self.id, token))478			.map(|a| a.owner != sender)479			.unwrap_or(true)480		{481			0482		} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {483			1484		} else {485			0486		}487	}488489	fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>> {490		None491	}492493	fn total_pieces(&self, token: TokenId) -> Option<u128> {494		if <TokenData<T>>::contains_key((self.id, token)) {495			Some(1)496		} else {497			None498		}499	}500}
after · pallets/nonfungible/src/common.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use core::marker::PhantomData;1819use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};20use up_data_structs::{21	TokenId, CreateItemExData, CollectionId, budget::Budget, Property, PropertyKey,22	PropertyKeyPermission, PropertyValue,23};24use pallet_common::{25	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,26	weights::WeightInfo as _,27};28use sp_runtime::DispatchError;29use sp_std::{vec::Vec, vec};3031use crate::{32	AccountBalance, Allowance, Config, CreateItemData, Error, NonfungibleHandle, Owned, Pallet,33	SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,34};3536pub struct CommonWeights<T: Config>(PhantomData<T>);37impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {38	fn create_item() -> Weight {39		<SelfWeightOf<T>>::create_item()40	}4142	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {43		match data {44			CreateItemExData::NFT(t) => {45				<SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)46					+ t.iter()47						.map(|t| {48							if t.properties.len() > 0 {49								Self::set_token_properties(t.properties.len() as u32)50							} else {51								052							}53						})54						.sum::<u64>()55			}56			_ => 0,57		}58	}5960	fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {61		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32)62			+ data63				.iter()64				.filter_map(|t| match t {65					up_data_structs::CreateItemData::NFT(n) if n.properties.len() > 0 => {66						Some(Self::set_token_properties(n.properties.len() as u32))67					}68					_ => None,69				})70				.sum::<u64>()71	}7273	fn burn_item() -> Weight {74		<SelfWeightOf<T>>::burn_item()75	}7677	fn set_collection_properties(amount: u32) -> Weight {78		<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)79	}8081	fn delete_collection_properties(amount: u32) -> Weight {82		<pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)83	}8485	fn set_token_properties(amount: u32) -> Weight {86		<SelfWeightOf<T>>::set_token_properties(amount)87	}8889	fn delete_token_properties(amount: u32) -> Weight {90		<SelfWeightOf<T>>::delete_token_properties(amount)91	}9293	fn set_token_property_permissions(amount: u32) -> Weight {94		<SelfWeightOf<T>>::set_token_property_permissions(amount)95	}9697	fn transfer() -> Weight {98		<SelfWeightOf<T>>::transfer()99	}100101	fn approve() -> Weight {102		<SelfWeightOf<T>>::approve()103	}104105	fn transfer_from() -> Weight {106		<SelfWeightOf<T>>::transfer_from()107	}108109	fn burn_from() -> Weight {110		<SelfWeightOf<T>>::burn_from()111	}112113	fn burn_recursively_self_raw() -> Weight {114		<SelfWeightOf<T>>::burn_recursively_self_raw()115	}116117	fn burn_recursively_breadth_raw(amount: u32) -> Weight {118		<SelfWeightOf<T>>::burn_recursively_breadth_plus_self_plus_self_per_each_raw(amount)119			.saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))120	}121}122123fn map_create_data<T: Config>(124	data: up_data_structs::CreateItemData,125	to: &T::CrossAccountId,126) -> Result<CreateItemData<T>, DispatchError> {127	match data {128		up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData::<T> {129			properties: data.properties,130			owner: to.clone(),131		}),132		_ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),133	}134}135136/// Implementation of `CommonCollectionOperations` for `NonfungibleHandle`. It wraps Nonfungible Pallete137/// methods and adds weight info.138impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {139	fn create_item(140		&self,141		sender: T::CrossAccountId,142		to: T::CrossAccountId,143		data: up_data_structs::CreateItemData,144		nesting_budget: &dyn Budget,145	) -> DispatchResultWithPostInfo {146		with_weight(147			<Pallet<T>>::create_item(148				self,149				&sender,150				map_create_data::<T>(data, &to)?,151				nesting_budget,152			),153			<CommonWeights<T>>::create_item(),154		)155	}156157	fn create_multiple_items(158		&self,159		sender: T::CrossAccountId,160		to: T::CrossAccountId,161		data: Vec<up_data_structs::CreateItemData>,162		nesting_budget: &dyn Budget,163	) -> DispatchResultWithPostInfo {164		let weight = <CommonWeights<T>>::create_multiple_items(&data);165		let data = data166			.into_iter()167			.map(|d| map_create_data::<T>(d, &to))168			.collect::<Result<Vec<_>, DispatchError>>()?;169170		with_weight(171			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),172			weight,173		)174	}175176	fn create_multiple_items_ex(177		&self,178		sender: <T>::CrossAccountId,179		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,180		nesting_budget: &dyn Budget,181	) -> DispatchResultWithPostInfo {182		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);183		let data = match data {184			up_data_structs::CreateItemExData::NFT(nft) => nft,185			_ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),186		};187188		with_weight(189			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),190			weight,191		)192	}193194	fn set_collection_properties(195		&self,196		sender: T::CrossAccountId,197		properties: Vec<Property>,198	) -> DispatchResultWithPostInfo {199		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);200201		with_weight(202			<Pallet<T>>::set_collection_properties(self, &sender, properties),203			weight,204		)205	}206207	fn delete_collection_properties(208		&self,209		sender: &T::CrossAccountId,210		property_keys: Vec<PropertyKey>,211	) -> DispatchResultWithPostInfo {212		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);213214		with_weight(215			<Pallet<T>>::delete_collection_properties(self, sender, property_keys),216			weight,217		)218	}219220	fn set_token_properties(221		&self,222		sender: T::CrossAccountId,223		token_id: TokenId,224		properties: Vec<Property>,225		nesting_budget: &dyn Budget,226	) -> DispatchResultWithPostInfo {227		let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);228229		with_weight(230			<Pallet<T>>::set_token_properties(231				self,232				&sender,233				token_id,234				properties.into_iter(),235				false,236				nesting_budget,237			),238			weight,239		)240	}241242	fn delete_token_properties(243		&self,244		sender: T::CrossAccountId,245		token_id: TokenId,246		property_keys: Vec<PropertyKey>,247		nesting_budget: &dyn Budget,248	) -> DispatchResultWithPostInfo {249		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);250251		with_weight(252			<Pallet<T>>::delete_token_properties(253				self,254				&sender,255				token_id,256				property_keys.into_iter(),257				nesting_budget,258			),259			weight,260		)261	}262263	fn set_token_property_permissions(264		&self,265		sender: &T::CrossAccountId,266		property_permissions: Vec<PropertyKeyPermission>,267	) -> DispatchResultWithPostInfo {268		let weight =269			<CommonWeights<T>>::set_token_property_permissions(property_permissions.len() as u32);270271		with_weight(272			<Pallet<T>>::set_token_property_permissions(self, sender, property_permissions),273			weight,274		)275	}276277	fn burn_item(278		&self,279		sender: T::CrossAccountId,280		token: TokenId,281		amount: u128,282	) -> DispatchResultWithPostInfo {283		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);284		if amount == 1 {285			with_weight(286				<Pallet<T>>::burn(self, &sender, token),287				<CommonWeights<T>>::burn_item(),288			)289		} else {290			Ok(().into())291		}292	}293294	fn burn_item_recursively(295		&self,296		sender: T::CrossAccountId,297		token: TokenId,298		self_budget: &dyn Budget,299		breadth_budget: &dyn Budget,300	) -> DispatchResultWithPostInfo {301		<Pallet<T>>::burn_recursively(self, &sender, token, self_budget, breadth_budget)302	}303304	fn transfer(305		&self,306		from: T::CrossAccountId,307		to: T::CrossAccountId,308		token: TokenId,309		amount: u128,310		nesting_budget: &dyn Budget,311	) -> DispatchResultWithPostInfo {312		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);313		if amount == 1 {314			with_weight(315				<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),316				<CommonWeights<T>>::transfer(),317			)318		} else {319			Ok(().into())320		}321	}322323	fn approve(324		&self,325		sender: T::CrossAccountId,326		spender: T::CrossAccountId,327		token: TokenId,328		amount: u128,329	) -> DispatchResultWithPostInfo {330		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);331332		with_weight(333			if amount == 1 {334				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))335			} else {336				<Pallet<T>>::set_allowance(self, &sender, token, None)337			},338			<CommonWeights<T>>::approve(),339		)340	}341342	fn transfer_from(343		&self,344		sender: T::CrossAccountId,345		from: T::CrossAccountId,346		to: T::CrossAccountId,347		token: TokenId,348		amount: u128,349		nesting_budget: &dyn Budget,350	) -> DispatchResultWithPostInfo {351		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);352353		if amount == 1 {354			with_weight(355				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),356				<CommonWeights<T>>::transfer_from(),357			)358		} else {359			Ok(().into())360		}361	}362363	fn burn_from(364		&self,365		sender: T::CrossAccountId,366		from: T::CrossAccountId,367		token: TokenId,368		amount: u128,369		nesting_budget: &dyn Budget,370	) -> DispatchResultWithPostInfo {371		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);372373		if amount == 1 {374			with_weight(375				<Pallet<T>>::burn_from(self, &sender, &from, token, nesting_budget),376				<CommonWeights<T>>::burn_from(),377			)378		} else {379			Ok(().into())380		}381	}382383	fn check_nesting(384		&self,385		sender: T::CrossAccountId,386		from: (CollectionId, TokenId),387		under: TokenId,388		nesting_budget: &dyn Budget,389	) -> sp_runtime::DispatchResult {390		<Pallet<T>>::check_nesting(self, sender, from, under, nesting_budget)391	}392393	fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId)) {394		<Pallet<T>>::nest((self.id, under), to_nest);395	}396397	fn unnest(&self, under: TokenId, to_unnest: (CollectionId, TokenId)) {398		<Pallet<T>>::unnest((self.id, under), to_unnest);399	}400401	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {402		<Owned<T>>::iter_prefix((self.id, account))403			.map(|(id, _)| id)404			.collect()405	}406407	fn collection_tokens(&self) -> Vec<TokenId> {408		<TokenData<T>>::iter_prefix((self.id,))409			.map(|(id, _)| id)410			.collect()411	}412413	fn token_exists(&self, token: TokenId) -> bool {414		<Pallet<T>>::token_exists(self, token)415	}416417	fn last_token_id(&self) -> TokenId {418		TokenId(<TokensMinted<T>>::get(self.id))419	}420421	fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId> {422		<TokenData<T>>::get((self.id, token)).map(|t| t.owner)423	}424425	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {426		self.token_owner(token).map_or_else(|| vec![], |t| vec![t])427	}428429	fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue> {430		<Pallet<T>>::token_properties((self.id, token_id))431			.get(key)432			.cloned()433	}434435	fn token_properties(&self, token_id: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property> {436		let properties = <Pallet<T>>::token_properties((self.id, token_id));437438		keys.map(|keys| {439			keys.into_iter()440				.filter_map(|key| {441					properties.get(&key).map(|value| Property {442						key,443						value: value.clone(),444					})445				})446				.collect()447		})448		.unwrap_or_else(|| {449			properties450				.into_iter()451				.map(|(key, value)| Property { key, value })452				.collect()453		})454	}455456	fn total_supply(&self) -> u32 {457		<Pallet<T>>::total_supply(self)458	}459460	fn account_balance(&self, account: T::CrossAccountId) -> u32 {461		<AccountBalance<T>>::get((self.id, account))462	}463464	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {465		if <TokenData<T>>::get((self.id, token))466			.map(|a| a.owner == account)467			.unwrap_or(false)468		{469			1470		} else {471			0472		}473	}474475	fn allowance(476		&self,477		sender: T::CrossAccountId,478		spender: T::CrossAccountId,479		token: TokenId,480	) -> u128 {481		if <TokenData<T>>::get((self.id, token))482			.map(|a| a.owner != sender)483			.unwrap_or(true)484		{485			0486		} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {487			1488		} else {489			0490		}491	}492493	fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>> {494		None495	}496497	fn total_pieces(&self, token: TokenId) -> Option<u128> {498		if <TokenData<T>>::contains_key((self.id, token)) {499			Some(1)500		} else {501			None502		}503	}504}
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -438,6 +438,10 @@
 		<Pallet<T>>::token_owner(self.id, token)
 	}
 
+	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {
+		<Pallet<T>>::token_owners(self.id, token).unwrap_or_else(|| vec![])
+	}
+
 	fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {
 		None
 	}
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -1134,4 +1134,20 @@
 	) -> DispatchResult {
 		<PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)
 	}
+	
+	pub fn token_owners(
+		collection_id: CollectionId,
+		token: TokenId,
+	) -> Option<Vec<T::CrossAccountId>> {
+		let res: Vec<T::CrossAccountId> = <Balance<T>>::iter_prefix((collection_id, token))
+			.map(|r| r.0)
+			.take(10)
+			.collect();
+
+		if res.len() == 0 {
+			None
+		} else {
+			Some(res)
+		}
+	}
 }
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -81,5 +81,6 @@
 		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;
 		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;
 		fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;
+		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec::<CrossAccountId>>;
 	}
 }
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -40,6 +40,11 @@
                 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
                     dispatch_unique_runtime!(collection.token_owner(token))
                 }
+
+                fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec::<CrossAccountId>, DispatchError>  {
+                   dispatch_unique_runtime!(collection.token_owners(token))
+                }
+
                 fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
                     let budget = up_data_structs::budget::Value::new(10);
 
modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -80,6 +80,7 @@
     "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts",
     "testEthCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createCollection.test.ts",
     "testRFT": "mocha --timeout 9999999 -r ts-node/register ./**/refungible.test.ts",
+    "testRPC": "mocha --timeout 9999999 -r ts-node/register ./**/rpc.test.ts",
     "polkadot-types-fetch-metadata": "curl -H 'Content-Type: application/json' -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9933 > src/interfaces/metadata.json",
     "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",
     "polkadot-types-from-chain": "ts-node ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .",
modifiedtests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-rpc.ts
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -709,6 +709,10 @@
        **/
       tokenOwner: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>>;
       /**
+       * Get token owners
+       **/
+      tokenOwners: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletEvmAccountBasicCrossAccountIdRepr>>>;
+      /**
        * Get token properties
        **/
       tokenProperties: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, propertyKeys?: Vec<Text> | (Text | string)[], at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsProperty>>>;
modifiedtests/src/interfaces/unique/definitions.tsdiffbeforeafterboth
--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -49,6 +49,7 @@
     balance: fun('Get amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),
     allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),
     tokenOwner: fun('Get token owner', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),
+    tokenOwners: fun('Get token owners', [collectionParam, tokenParam], `Vec<${CROSS_ACCOUNT_ID_TYPE}>`),
     topmostTokenOwner: fun('Get token owner, in case of nested token - find parent recursive', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),
     tokenChildren: fun('Get tokens nested directly into the token', [collectionParam, tokenParam], 'Vec<UpDataStructsTokenChild>'),
     constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -53,14 +53,14 @@
   it('Create refungible collection and token', async () => {
     await usingApi(async api => {
       const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});
-      expect(createCollectionResult.success).to.be.true;    
+      expect(createCollectionResult.success).to.be.true;
       const collectionId  = createCollectionResult.collectionId;
-
+      
       const itemCountBefore = await getLastTokenId(api, collectionId);
       const result = await createRefungibleToken(api, alice, collectionId, 100n);
-
+      
       const itemCountAfter = await getLastTokenId(api, collectionId);
-
+      
       // What to expect
       // tslint:disable-next-line:no-unused-expression
       expect(result.success).to.be.true;
@@ -69,7 +69,39 @@
       expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());
     });
   });
-
+  
+  it('RPC method tokenOnewrs for refungible collection and token', async () => {
+    await usingApi(async (api, privateKeyWrapper) => {
+      const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
+      const facelessCrowd = Array.from(Array(7).keys()).map(i => normalizeAccountId(privateKeyWrapper(i.toString())));
+      
+      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});
+      const collectionId = createCollectionResult.collectionId;
+      
+      const result = await createRefungibleToken(api, alice, collectionId, 10_000n);
+      const aliceTokenId = result.itemId;
+      
+      
+      await transfer(api, collectionId, aliceTokenId, alice, bob, 1000n);
+      await transfer(api, collectionId, aliceTokenId, alice, ethAcc, 900n);
+      
+      for (let i = 0; i < 7; i++) {
+        await transfer(api, collectionId, aliceTokenId, alice, facelessCrowd[i], 50*(i+1));
+      } 
+      
+      const owners = await api.rpc.unique.tokenOwners(collectionId, aliceTokenId);
+      const ids = (owners.toJSON() as CrossAccountId[]).map(s => normalizeAccountId(s));
+      
+      const aliceID = normalizeAccountId(alice);
+      const bobId = normalizeAccountId(bob);
+      
+      // What to expect
+      // tslint:disable-next-line:no-unused-expression
+      expect(ids).to.deep.include.members([aliceID, ethAcc, bobId, ...facelessCrowd]);
+      expect(owners.length == 10).to.be.true;
+    });
+  });
+  
   it('Transfer token pieces', async () => {
     await usingApi(async api => {
       const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;
modifiedtests/src/rpc.test.tsdiffbeforeafterboth
--- a/tests/src/rpc.test.ts
+++ b/tests/src/rpc.test.ts
@@ -1,12 +1,53 @@
+import {IKeyringPair} from '@polkadot/types/types';
 import {expect} from 'chai';
 import usingApi from './substrate/substrate-api';
-import {createCollectionExpectSuccess, getTokenOwner} from './util/helpers';
+import {createCollection, createCollectionExpectSuccess, createFungibleItemExpectSuccess, CrossAccountId, getTokenOwner, normalizeAccountId, transfer, U128_MAX} from './util/helpers';
+
+let alice: IKeyringPair;
+let bob: IKeyringPair;
+
 
-describe('getTokenOwner', () => {
+describe('integration test: RPC methods', () => {
+  before(async () => {
+    await usingApi(async (api, privateKeyWrapper) => {
+      alice = privateKeyWrapper('//Alice');
+      bob = privateKeyWrapper('//Bob');
+    });
+  });
+
+  
   it('returns None for fungible collection', async () => {
     await usingApi(async api => {
       const collection = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
       await expect(getTokenOwner(api, collection, 0)).to.be.rejectedWith(/^owner == null$/);
     });
   });
+  
+  it('RPC method tokenOnewrs for fungible collection and token', async () => {
+    await usingApi(async (api, privateKeyWrapper) => {
+      const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
+      const facelessCrowd = Array.from(Array(7).keys()).map(i => normalizeAccountId(privateKeyWrapper(i.toString())));
+      
+      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}});
+      const collectionId = createCollectionResult.collectionId;
+      const aliceTokenId = await createFungibleItemExpectSuccess(alice, collectionId, {Value: U128_MAX}, alice.address);
+     
+      await transfer(api, collectionId, aliceTokenId, alice, bob, 1000n);
+      await transfer(api, collectionId, aliceTokenId, alice, ethAcc, 900n);
+            
+      for (let i = 0; i < 7; i++) {
+        await transfer(api, collectionId, aliceTokenId, alice, facelessCrowd[i], 1);
+      } 
+      
+      const owners = await api.rpc.unique.tokenOwners(collectionId, aliceTokenId);
+      const ids = (owners.toJSON() as CrossAccountId[]).map(s => normalizeAccountId(s));
+      const aliceID = normalizeAccountId(alice);
+      const bobId = normalizeAccountId(bob);
+
+      // What to expect
+      // tslint:disable-next-line:no-unused-expression
+      expect(ids).to.deep.include.members([aliceID, ethAcc, bobId, ...facelessCrowd]);
+      expect(owners.length == 10).to.be.true;
+    });
+  });
 });
\ No newline at end of file