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

difftreelog

chore fix code review requests

Grigoriy Simonov2022-12-06parent: #cd0ba0d.patch.diff
in: master

36 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
before · client/rpc/src/lib.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/>.1617// Original License18use std::sync::Arc;1920use codec::{Decode, Encode};21use jsonrpsee::{22	core::{RpcResult as Result},23	proc_macros::rpc,24};25use anyhow::anyhow;26use sp_runtime::traits::{AtLeast32BitUnsigned, Member};27use up_data_structs::{28	RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId, Property,29	PropertyKeyPermission, TokenData, TokenChild,30};31use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};32use sp_blockchain::HeaderBackend;33use up_rpc::UniqueApi as UniqueRuntimeApi;34use app_promotion_rpc::AppPromotionApi as AppPromotionRuntimeApi;3536// RMRK37use rmrk_rpc::RmrkApi as RmrkRuntimeApi;38use up_data_structs::{39	RmrkCollectionId, RmrkNftId, RmrkBaseId, RmrkNftChild, RmrkThemeName, RmrkResourceId,40};4142pub use app_promotion_unique_rpc::AppPromotionApiServer;43pub use rmrk_unique_rpc::RmrkApiServer;4445#[rpc(server)]46#[async_trait]47pub trait UniqueApi<BlockHash, CrossAccountId, AccountId> {48	/// Get tokens owned by account.49	#[method(name = "unique_accountTokens")]50	fn account_tokens(51		&self,52		collection: CollectionId,53		account: CrossAccountId,54		at: Option<BlockHash>,55	) -> Result<Vec<TokenId>>;5657	/// Get tokens contained within a collection.58	#[method(name = "unique_collectionTokens")]59	fn collection_tokens(60		&self,61		collection: CollectionId,62		at: Option<BlockHash>,63	) -> Result<Vec<TokenId>>;6465	/// Check if the token exists.66	#[method(name = "unique_tokenExists")]67	fn token_exists(68		&self,69		collection: CollectionId,70		token: TokenId,71		at: Option<BlockHash>,72	) -> Result<bool>;7374	/// Get the token owner.75	#[method(name = "unique_tokenOwner")]76	fn token_owner(77		&self,78		collection: CollectionId,79		token: TokenId,80		at: Option<BlockHash>,81	) -> Result<Option<CrossAccountId>>;8283	/// Returns 10 tokens owners in no particular order.84	#[method(name = "unique_tokenOwners")]85	fn token_owners(86		&self,87		collection: CollectionId,88		token: TokenId,89		at: Option<BlockHash>,90	) -> Result<Vec<CrossAccountId>>;9192	/// Get the topmost token owner in the hierarchy of a possibly nested token.93	#[method(name = "unique_topmostTokenOwner")]94	fn topmost_token_owner(95		&self,96		collection: CollectionId,97		token: TokenId,98		at: Option<BlockHash>,99	) -> Result<Option<CrossAccountId>>;100101	/// Get tokens nested directly into the token.102	#[method(name = "unique_tokenChildren")]103	fn token_children(104		&self,105		collection: CollectionId,106		token: TokenId,107		at: Option<BlockHash>,108	) -> Result<Vec<TokenChild>>;109110	/// Get collection properties, optionally limited to the provided keys.111	#[method(name = "unique_collectionProperties")]112	fn collection_properties(113		&self,114		collection: CollectionId,115		keys: Option<Vec<String>>,116		at: Option<BlockHash>,117	) -> Result<Vec<Property>>;118119	/// Get token properties, optionally limited to the provided keys.120	#[method(name = "unique_tokenProperties")]121	fn token_properties(122		&self,123		collection: CollectionId,124		token_id: TokenId,125		keys: Option<Vec<String>>,126		at: Option<BlockHash>,127	) -> Result<Vec<Property>>;128129	/// Get property permissions, optionally limited to the provided keys.130	#[method(name = "unique_propertyPermissions")]131	fn property_permissions(132		&self,133		collection: CollectionId,134		keys: Option<Vec<String>>,135		at: Option<BlockHash>,136	) -> Result<Vec<PropertyKeyPermission>>;137138	/// Get token data, including properties, optionally limited to the provided keys, and total pieces for an RFT.139	#[method(name = "unique_tokenData")]140	fn token_data(141		&self,142		collection: CollectionId,143		token_id: TokenId,144		keys: Option<Vec<String>>,145		at: Option<BlockHash>,146	) -> Result<TokenData<CrossAccountId>>;147148	/// Get the amount of distinctive tokens present in a collection.149	#[method(name = "unique_totalSupply")]150	fn total_supply(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;151152	/// Get the amount of any user tokens owned by an account.153	#[method(name = "unique_accountBalance")]154	fn account_balance(155		&self,156		collection: CollectionId,157		account: CrossAccountId,158		at: Option<BlockHash>,159	) -> Result<u32>;160161	/// Get the amount of a specific token owned by an account.162	#[method(name = "unique_balance")]163	fn balance(164		&self,165		collection: CollectionId,166		account: CrossAccountId,167		token: TokenId,168		at: Option<BlockHash>,169	) -> Result<String>;170171	/// Get the amount of currently possible sponsored transactions on a token for the fee to be taken off a sponsor.172	#[method(name = "unique_allowance")]173	fn allowance(174		&self,175		collection: CollectionId,176		sender: CrossAccountId,177		spender: CrossAccountId,178		token: TokenId,179		at: Option<BlockHash>,180	) -> Result<String>;181182	/// Get the list of admin accounts of a collection.183	#[method(name = "unique_adminlist")]184	fn adminlist(185		&self,186		collection: CollectionId,187		at: Option<BlockHash>,188	) -> Result<Vec<CrossAccountId>>;189190	/// Get the list of accounts allowed to operate within a collection.191	#[method(name = "unique_allowlist")]192	fn allowlist(193		&self,194		collection: CollectionId,195		at: Option<BlockHash>,196	) -> Result<Vec<CrossAccountId>>;197198	/// Check if a user is allowed to operate within a collection.199	#[method(name = "unique_allowed")]200	fn allowed(201		&self,202		collection: CollectionId,203		user: CrossAccountId,204		at: Option<BlockHash>,205	) -> Result<bool>;206207	/// Get the last token ID created in a collection.208	#[method(name = "unique_lastTokenId")]209	fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;210211	/// Get collection info by the specified ID.212	#[method(name = "unique_collectionById")]213	fn collection_by_id(214		&self,215		collection: CollectionId,216		at: Option<BlockHash>,217	) -> Result<Option<RpcCollection<AccountId>>>;218219	/// Get chain stats about collections.220	#[method(name = "unique_collectionStats")]221	fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;222223	/// Get the number of blocks until sponsoring a transaction is available.224	#[method(name = "unique_nextSponsored")]225	fn next_sponsored(226		&self,227		collection: CollectionId,228		account: CrossAccountId,229		token: TokenId,230		at: Option<BlockHash>,231	) -> Result<Option<u64>>;232233	/// Get effective collection limits. If not explicitly set, get the chain defaults.234	#[method(name = "unique_effectiveCollectionLimits")]235	fn effective_collection_limits(236		&self,237		collection_id: CollectionId,238		at: Option<BlockHash>,239	) -> Result<Option<CollectionLimits>>;240241	/// Get the total amount of pieces of an RFT.242	#[method(name = "unique_totalPieces")]243	fn total_pieces(244		&self,245		collection_id: CollectionId,246		token_id: TokenId,247		at: Option<BlockHash>,248	) -> Result<Option<String>>;249250	/// Get whether an operator is approved by a given owner.251	#[method(name = "unique_isApprovedForAll")]252	fn is_approved_for_all(253		&self,254		collection: CollectionId,255		owner: CrossAccountId,256		operator: CrossAccountId,257		at: Option<BlockHash>,258	) -> Result<bool>;259}260261mod app_promotion_unique_rpc {262	use super::*;263264	#[rpc(server)]265	#[async_trait]266	pub trait AppPromotionApi<BlockHash, BlockNumber, CrossAccountId, AccountId> {267		/// Returns the total amount of staked tokens.268		#[method(name = "appPromotion_totalStaked")]269		fn total_staked(270			&self,271			staker: Option<CrossAccountId>,272			at: Option<BlockHash>,273		) -> Result<String>;274275		///Returns the total amount of staked tokens per block when staked.276		#[method(name = "appPromotion_totalStakedPerBlock")]277		fn total_staked_per_block(278			&self,279			staker: CrossAccountId,280			at: Option<BlockHash>,281		) -> Result<Vec<(BlockNumber, String)>>;282283		/// Returns the total amount of tokens pending withdrawal from staking.284		#[method(name = "appPromotion_pendingUnstake")]285		fn pending_unstake(286			&self,287			staker: Option<CrossAccountId>,288			at: Option<BlockHash>,289		) -> Result<String>;290291		/// Returns the total amount of tokens pending withdrawal from staking per block.292		#[method(name = "appPromotion_pendingUnstakePerBlock")]293		fn pending_unstake_per_block(294			&self,295			staker: CrossAccountId,296			at: Option<BlockHash>,297		) -> Result<Vec<(BlockNumber, String)>>;298	}299}300301mod rmrk_unique_rpc {302	use super::*;303304	#[rpc(server)]305	#[async_trait]306	pub trait RmrkApi<307		BlockHash,308		AccountId,309		CollectionInfo,310		NftInfo,311		ResourceInfo,312		PropertyInfo,313		BaseInfo,314		PartType,315		Theme,316	>317	{318		/// Get the latest created collection ID.319		#[method(name = "rmrk_lastCollectionIdx")]320		fn last_collection_idx(&self, at: Option<BlockHash>) -> Result<RmrkCollectionId>;321322		/// Get collection info by ID.323		#[method(name = "rmrk_collectionById")]324		fn collection_by_id(325			&self,326			id: RmrkCollectionId,327			at: Option<BlockHash>,328		) -> Result<Option<CollectionInfo>>;329330		/// Get NFT info by collection and NFT IDs.331		#[method(name = "rmrk_nftById")]332		fn nft_by_id(333			&self,334			collection_id: RmrkCollectionId,335			nft_id: RmrkNftId,336			at: Option<BlockHash>,337		) -> Result<Option<NftInfo>>;338339		/// Get tokens owned by an account in a collection.340		#[method(name = "rmrk_accountTokens")]341		fn account_tokens(342			&self,343			account_id: AccountId,344			collection_id: RmrkCollectionId,345			at: Option<BlockHash>,346		) -> Result<Vec<RmrkNftId>>;347348		/// Get tokens nested in an NFT - its direct children (not the children's children).349		#[method(name = "rmrk_nftChildren")]350		fn nft_children(351			&self,352			collection_id: RmrkCollectionId,353			nft_id: RmrkNftId,354			at: Option<BlockHash>,355		) -> Result<Vec<RmrkNftChild>>;356357		/// Get collection properties, created by the user - not the proxy-specific properties.358		#[method(name = "rmrk_collectionProperties")]359		fn collection_properties(360			&self,361			collection_id: RmrkCollectionId,362			filter_keys: Option<Vec<String>>,363			at: Option<BlockHash>,364		) -> Result<Vec<PropertyInfo>>;365366		/// Get NFT properties, created by the user - not the proxy-specific properties.367		#[method(name = "rmrk_nftProperties")]368		fn nft_properties(369			&self,370			collection_id: RmrkCollectionId,371			nft_id: RmrkNftId,372			filter_keys: Option<Vec<String>>,373			at: Option<BlockHash>,374		) -> Result<Vec<PropertyInfo>>;375376		/// Get data of resources of an NFT.377		#[method(name = "rmrk_nftResources")]378		fn nft_resources(379			&self,380			collection_id: RmrkCollectionId,381			nft_id: RmrkNftId,382			at: Option<BlockHash>,383		) -> Result<Vec<ResourceInfo>>;384385		/// Get the priority of a resource in an NFT.386		#[method(name = "rmrk_nftResourcePriority")]387		fn nft_resource_priority(388			&self,389			collection_id: RmrkCollectionId,390			nft_id: RmrkNftId,391			resource_id: RmrkResourceId,392			at: Option<BlockHash>,393		) -> Result<Option<u32>>;394395		/// Get base info by its ID.396		#[method(name = "rmrk_base")]397		fn base(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Option<BaseInfo>>;398399		/// Get all parts of a base.400		#[method(name = "rmrk_baseParts")]401		fn base_parts(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Vec<PartType>>;402403		/// Get the theme names belonging to a base.404		#[method(name = "rmrk_themeNames")]405		fn theme_names(406			&self,407			base_id: RmrkBaseId,408			at: Option<BlockHash>,409		) -> Result<Vec<RmrkThemeName>>;410411		/// Get theme info, including properties, optionally limited to the provided keys.412		#[method(name = "rmrk_themes")]413		fn theme(414			&self,415			base_id: RmrkBaseId,416			theme_name: String,417			filter_keys: Option<Vec<String>>,418			at: Option<BlockHash>,419		) -> Result<Option<Theme>>;420	}421}422423macro_rules! define_struct_for_server_api {424	($name:ident) => {425		pub struct $name<C, P> {426			client: Arc<C>,427			_marker: std::marker::PhantomData<P>,428		}429430		impl<C, P> $name<C, P> {431			pub fn new(client: Arc<C>) -> Self {432				Self {433					client,434					_marker: Default::default(),435				}436			}437		}438	};439}440441define_struct_for_server_api!(Unique);442define_struct_for_server_api!(AppPromotion);443define_struct_for_server_api!(Rmrk);444445macro_rules! pass_method {446	(447		$method_name:ident(448			$($(#[map(|$map_arg:ident| $map:expr)])? $name:ident: $ty:ty),* $(,)?449		) -> $result:ty $(=> $mapper:expr)?,450		//$runtime_name:ident $(<$($lt: tt),+>)*451		$runtime_api_macro:ident452		$(; changed_in $ver:expr, $changed_method_name:ident ($($changed_name:expr), * $(,)?) => $fixer:expr)*453	) => {454		fn $method_name(455			&self,456			$(457				$name: $ty,458			)*459			at: Option<<Block as BlockT>::Hash>,460		) -> Result<$result> {461			let api = self.client.runtime_api();462			let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));463			let _api_version = if let Ok(Some(api_version)) =464				api.api_version::<$runtime_api_macro!()>(&at)465			{466				api_version467			} else {468				// unreachable for our runtime469				return Err(anyhow!("api is not available").into())470			};471472			let result = $(if _api_version < $ver {473				api.$changed_method_name(&at, $($changed_name),*).map(|r| r.map($fixer))474			} else)*475			{ api.$method_name(&at, $($((|$map_arg: $ty| $map))? ($name)),*) };476477			Ok(result478				.map_err(|e| anyhow!("unable to query: {e}"))?479				.map_err(|e| anyhow!("runtime error: {e:?}"))$(.map($mapper))??)480		}481	};482}483484macro_rules! unique_api {485	() => {486		dyn UniqueRuntimeApi<Block, CrossAccountId, AccountId>487	};488}489490macro_rules! app_promotion_api {491	() => {492		dyn AppPromotionRuntimeApi<Block, BlockNumber, CrossAccountId, AccountId>493	};494}495496macro_rules! rmrk_api {497	() => {498		dyn RmrkRuntimeApi<Block, AccountId, CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme>499	};500}501502#[allow(deprecated)]503impl<C, Block, CrossAccountId, AccountId>504	UniqueApiServer<<Block as BlockT>::Hash, CrossAccountId, AccountId> for Unique<C, Block>505where506	Block: BlockT,507	AccountId: Decode,508	C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,509	C::Api: UniqueRuntimeApi<Block, CrossAccountId, AccountId>,510	CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,511{512	pass_method!(513		account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>, unique_api514	);515	pass_method!(516		collection_tokens(collection: CollectionId) -> Vec<TokenId>, unique_api517	);518	pass_method!(519		token_exists(collection: CollectionId, token: TokenId) -> bool, unique_api520	);521	pass_method!(522		token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>, unique_api523	);524	pass_method!(525		topmost_token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>, unique_api526	);527	pass_method!(token_children(collection: CollectionId, token: TokenId) -> Vec<TokenChild>, unique_api);528	pass_method!(total_supply(collection: CollectionId) -> u32, unique_api);529	pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32, unique_api);530	pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string(), unique_api);531	pass_method!(532		allowance(collection: CollectionId, sender: CrossAccountId, spender: CrossAccountId, token: TokenId) -> String => |v| v.to_string(),533		unique_api534	);535536	pass_method!(collection_properties(537		collection: CollectionId,538539		#[map(|keys| string_keys_to_bytes_keys(keys))]540		keys: Option<Vec<String>>541	) -> Vec<Property>, unique_api);542543	pass_method!(token_properties(544		collection: CollectionId,545		token_id: TokenId,546547		#[map(|keys| string_keys_to_bytes_keys(keys))]548		keys: Option<Vec<String>>549	) -> Vec<Property>, unique_api);550551	pass_method!(property_permissions(552		collection: CollectionId,553554		#[map(|keys| string_keys_to_bytes_keys(keys))]555		keys: Option<Vec<String>>556	) -> Vec<PropertyKeyPermission>, unique_api);557558	pass_method!(559		token_data(560			collection: CollectionId,561			token_id: TokenId,562563			#[map(|keys| string_keys_to_bytes_keys(keys))]564			keys: Option<Vec<String>>,565		) -> TokenData<CrossAccountId>, unique_api;566		changed_in 3, token_data_before_version_3(collection, token_id, string_keys_to_bytes_keys(keys)) => |value| value.into()567	);568569	pass_method!(adminlist(collection: CollectionId) -> Vec<CrossAccountId>, unique_api);570	pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>, unique_api);571	pass_method!(allowed(collection: CollectionId, user: CrossAccountId) -> bool, unique_api);572	pass_method!(last_token_id(collection: CollectionId) -> TokenId, unique_api);573	pass_method!(574		collection_by_id(collection: CollectionId) -> Option<RpcCollection<AccountId>>, unique_api;575		changed_in 3, collection_by_id_before_version_3(collection) => |value| value.map(|coll| coll.into())576	);577	pass_method!(collection_stats() -> CollectionStats, unique_api);578	pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>, unique_api);579	pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);580	pass_method!(total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<String> => |o| o.map(|number| number.to_string()) , unique_api);581	pass_method!(token_owners(collection: CollectionId, token: TokenId) -> Vec<CrossAccountId>, unique_api);582	pass_method!(is_approved_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> bool, unique_api);583}584585impl<C, Block, BlockNumber, CrossAccountId, AccountId>586	app_promotion_unique_rpc::AppPromotionApiServer<587		<Block as BlockT>::Hash,588		BlockNumber,589		CrossAccountId,590		AccountId,591	> for AppPromotion<C, Block>592where593	Block: BlockT,594	BlockNumber: Decode + Member + AtLeast32BitUnsigned,595	AccountId: Decode,596	C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,597	CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,598	C::Api: AppPromotionRuntimeApi<Block, BlockNumber, CrossAccountId, AccountId>,599{600	pass_method!(total_staked(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), app_promotion_api);601	pass_method!(total_staked_per_block(staker: CrossAccountId) -> Vec<(BlockNumber, String)> =>602		|v| v603		.into_iter()604		.map(|(b, a)| (b, a.to_string()))605		.collect::<Vec<_>>(), app_promotion_api);606	pass_method!(pending_unstake(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), app_promotion_api);607	pass_method!(pending_unstake_per_block(staker: CrossAccountId) -> Vec<(BlockNumber, String)> =>608		|v| v609		.into_iter()610		.map(|(b, a)| (b, a.to_string()))611		.collect::<Vec<_>>(), app_promotion_api);612}613614#[allow(deprecated)]615impl<616		C,617		Block,618		AccountId,619		CollectionInfo,620		NftInfo,621		ResourceInfo,622		PropertyInfo,623		BaseInfo,624		PartType,625		Theme,626	>627	rmrk_unique_rpc::RmrkApiServer<628		<Block as BlockT>::Hash,629		AccountId,630		CollectionInfo,631		NftInfo,632		ResourceInfo,633		PropertyInfo,634		BaseInfo,635		PartType,636		Theme,637	> for Rmrk<C, Block>638where639	C: Send + Sync + 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,640	C::Api: RmrkRuntimeApi<641		Block,642		AccountId,643		CollectionInfo,644		NftInfo,645		ResourceInfo,646		PropertyInfo,647		BaseInfo,648		PartType,649		Theme,650	>,651	AccountId: Decode + Encode,652	CollectionInfo: Decode,653	NftInfo: Decode,654	ResourceInfo: Decode,655	PropertyInfo: Decode,656	BaseInfo: Decode,657	PartType: Decode,658	Theme: Decode,659	Block: BlockT,660{661	pass_method!(last_collection_idx() -> RmrkCollectionId, rmrk_api);662	pass_method!(collection_by_id(id: RmrkCollectionId) -> Option<CollectionInfo>, rmrk_api);663	pass_method!(nft_by_id(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Option<NftInfo>, rmrk_api);664	pass_method!(account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Vec<RmrkNftId>, rmrk_api);665	pass_method!(nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<RmrkNftChild>, rmrk_api);666	pass_method!(667		collection_properties(668			collection_id: RmrkCollectionId,669670			#[map(|keys| string_keys_to_bytes_keys(keys))]671			filter_keys: Option<Vec<String>>672		) -> Vec<PropertyInfo>,673		rmrk_api674	);675	pass_method!(676		nft_properties(677			collection_id: RmrkCollectionId,678			nft_id: RmrkNftId,679680			#[map(|keys| string_keys_to_bytes_keys(keys))]681			filter_keys: Option<Vec<String>>682		) -> Vec<PropertyInfo>,683		rmrk_api684	);685	pass_method!(nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<ResourceInfo>, rmrk_api);686	pass_method!(nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Option<u32>, rmrk_api);687	pass_method!(base(base_id: RmrkBaseId) -> Option<BaseInfo>, rmrk_api);688	pass_method!(base_parts(base_id: RmrkBaseId) -> Vec<PartType>, rmrk_api);689	pass_method!(theme_names(base_id: RmrkBaseId) -> Vec<RmrkThemeName>, rmrk_api);690	pass_method!(691		theme(692			base_id: RmrkBaseId,693694			#[map(|n| n.into_bytes())]695			theme_name: String,696697			#[map(|keys| string_keys_to_bytes_keys(keys))]698			filter_keys: Option<Vec<String>>699		) -> Option<Theme>, rmrk_api);700}701702fn string_keys_to_bytes_keys(keys: Option<Vec<String>>) -> Option<Vec<Vec<u8>>> {703	keys.map(|keys| keys.into_iter().map(|key| key.into_bytes()).collect())704}
after · client/rpc/src/lib.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/>.1617// Original License18use std::sync::Arc;1920use codec::{Decode, Encode};21use jsonrpsee::{22	core::{RpcResult as Result},23	proc_macros::rpc,24};25use anyhow::anyhow;26use sp_runtime::traits::{AtLeast32BitUnsigned, Member};27use up_data_structs::{28	RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId, Property,29	PropertyKeyPermission, TokenData, TokenChild,30};31use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};32use sp_blockchain::HeaderBackend;33use up_rpc::UniqueApi as UniqueRuntimeApi;34use app_promotion_rpc::AppPromotionApi as AppPromotionRuntimeApi;3536// RMRK37use rmrk_rpc::RmrkApi as RmrkRuntimeApi;38use up_data_structs::{39	RmrkCollectionId, RmrkNftId, RmrkBaseId, RmrkNftChild, RmrkThemeName, RmrkResourceId,40};4142pub use app_promotion_unique_rpc::AppPromotionApiServer;43pub use rmrk_unique_rpc::RmrkApiServer;4445#[rpc(server)]46#[async_trait]47pub trait UniqueApi<BlockHash, CrossAccountId, AccountId> {48	/// Get tokens owned by account.49	#[method(name = "unique_accountTokens")]50	fn account_tokens(51		&self,52		collection: CollectionId,53		account: CrossAccountId,54		at: Option<BlockHash>,55	) -> Result<Vec<TokenId>>;5657	/// Get tokens contained within a collection.58	#[method(name = "unique_collectionTokens")]59	fn collection_tokens(60		&self,61		collection: CollectionId,62		at: Option<BlockHash>,63	) -> Result<Vec<TokenId>>;6465	/// Check if the token exists.66	#[method(name = "unique_tokenExists")]67	fn token_exists(68		&self,69		collection: CollectionId,70		token: TokenId,71		at: Option<BlockHash>,72	) -> Result<bool>;7374	/// Get the token owner.75	#[method(name = "unique_tokenOwner")]76	fn token_owner(77		&self,78		collection: CollectionId,79		token: TokenId,80		at: Option<BlockHash>,81	) -> Result<Option<CrossAccountId>>;8283	/// Returns 10 tokens owners in no particular order.84	#[method(name = "unique_tokenOwners")]85	fn token_owners(86		&self,87		collection: CollectionId,88		token: TokenId,89		at: Option<BlockHash>,90	) -> Result<Vec<CrossAccountId>>;9192	/// Get the topmost token owner in the hierarchy of a possibly nested token.93	#[method(name = "unique_topmostTokenOwner")]94	fn topmost_token_owner(95		&self,96		collection: CollectionId,97		token: TokenId,98		at: Option<BlockHash>,99	) -> Result<Option<CrossAccountId>>;100101	/// Get tokens nested directly into the token.102	#[method(name = "unique_tokenChildren")]103	fn token_children(104		&self,105		collection: CollectionId,106		token: TokenId,107		at: Option<BlockHash>,108	) -> Result<Vec<TokenChild>>;109110	/// Get collection properties, optionally limited to the provided keys.111	#[method(name = "unique_collectionProperties")]112	fn collection_properties(113		&self,114		collection: CollectionId,115		keys: Option<Vec<String>>,116		at: Option<BlockHash>,117	) -> Result<Vec<Property>>;118119	/// Get token properties, optionally limited to the provided keys.120	#[method(name = "unique_tokenProperties")]121	fn token_properties(122		&self,123		collection: CollectionId,124		token_id: TokenId,125		keys: Option<Vec<String>>,126		at: Option<BlockHash>,127	) -> Result<Vec<Property>>;128129	/// Get property permissions, optionally limited to the provided keys.130	#[method(name = "unique_propertyPermissions")]131	fn property_permissions(132		&self,133		collection: CollectionId,134		keys: Option<Vec<String>>,135		at: Option<BlockHash>,136	) -> Result<Vec<PropertyKeyPermission>>;137138	/// Get token data, including properties, optionally limited to the provided keys, and total pieces for an RFT.139	#[method(name = "unique_tokenData")]140	fn token_data(141		&self,142		collection: CollectionId,143		token_id: TokenId,144		keys: Option<Vec<String>>,145		at: Option<BlockHash>,146	) -> Result<TokenData<CrossAccountId>>;147148	/// Get the amount of distinctive tokens present in a collection.149	#[method(name = "unique_totalSupply")]150	fn total_supply(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;151152	/// Get the amount of any user tokens owned by an account.153	#[method(name = "unique_accountBalance")]154	fn account_balance(155		&self,156		collection: CollectionId,157		account: CrossAccountId,158		at: Option<BlockHash>,159	) -> Result<u32>;160161	/// Get the amount of a specific token owned by an account.162	#[method(name = "unique_balance")]163	fn balance(164		&self,165		collection: CollectionId,166		account: CrossAccountId,167		token: TokenId,168		at: Option<BlockHash>,169	) -> Result<String>;170171	/// Get the amount of currently possible sponsored transactions on a token for the fee to be taken off a sponsor.172	#[method(name = "unique_allowance")]173	fn allowance(174		&self,175		collection: CollectionId,176		sender: CrossAccountId,177		spender: CrossAccountId,178		token: TokenId,179		at: Option<BlockHash>,180	) -> Result<String>;181182	/// Get the list of admin accounts of a collection.183	#[method(name = "unique_adminlist")]184	fn adminlist(185		&self,186		collection: CollectionId,187		at: Option<BlockHash>,188	) -> Result<Vec<CrossAccountId>>;189190	/// Get the list of accounts allowed to operate within a collection.191	#[method(name = "unique_allowlist")]192	fn allowlist(193		&self,194		collection: CollectionId,195		at: Option<BlockHash>,196	) -> Result<Vec<CrossAccountId>>;197198	/// Check if a user is allowed to operate within a collection.199	#[method(name = "unique_allowed")]200	fn allowed(201		&self,202		collection: CollectionId,203		user: CrossAccountId,204		at: Option<BlockHash>,205	) -> Result<bool>;206207	/// Get the last token ID created in a collection.208	#[method(name = "unique_lastTokenId")]209	fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;210211	/// Get collection info by the specified ID.212	#[method(name = "unique_collectionById")]213	fn collection_by_id(214		&self,215		collection: CollectionId,216		at: Option<BlockHash>,217	) -> Result<Option<RpcCollection<AccountId>>>;218219	/// Get chain stats about collections.220	#[method(name = "unique_collectionStats")]221	fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;222223	/// Get the number of blocks until sponsoring a transaction is available.224	#[method(name = "unique_nextSponsored")]225	fn next_sponsored(226		&self,227		collection: CollectionId,228		account: CrossAccountId,229		token: TokenId,230		at: Option<BlockHash>,231	) -> Result<Option<u64>>;232233	/// Get effective collection limits. If not explicitly set, get the chain defaults.234	#[method(name = "unique_effectiveCollectionLimits")]235	fn effective_collection_limits(236		&self,237		collection_id: CollectionId,238		at: Option<BlockHash>,239	) -> Result<Option<CollectionLimits>>;240241	/// Get the total amount of pieces of an RFT.242	#[method(name = "unique_totalPieces")]243	fn total_pieces(244		&self,245		collection_id: CollectionId,246		token_id: TokenId,247		at: Option<BlockHash>,248	) -> Result<Option<String>>;249250	/// Get whether an operator is approved by a given owner.251	#[method(name = "unique_allowanceForAll")]252	fn allowance_for_all(253		&self,254		collection: CollectionId,255		owner: CrossAccountId,256		operator: CrossAccountId,257		at: Option<BlockHash>,258	) -> Result<bool>;259}260261mod app_promotion_unique_rpc {262	use super::*;263264	#[rpc(server)]265	#[async_trait]266	pub trait AppPromotionApi<BlockHash, BlockNumber, CrossAccountId, AccountId> {267		/// Returns the total amount of staked tokens.268		#[method(name = "appPromotion_totalStaked")]269		fn total_staked(270			&self,271			staker: Option<CrossAccountId>,272			at: Option<BlockHash>,273		) -> Result<String>;274275		///Returns the total amount of staked tokens per block when staked.276		#[method(name = "appPromotion_totalStakedPerBlock")]277		fn total_staked_per_block(278			&self,279			staker: CrossAccountId,280			at: Option<BlockHash>,281		) -> Result<Vec<(BlockNumber, String)>>;282283		/// Returns the total amount of tokens pending withdrawal from staking.284		#[method(name = "appPromotion_pendingUnstake")]285		fn pending_unstake(286			&self,287			staker: Option<CrossAccountId>,288			at: Option<BlockHash>,289		) -> Result<String>;290291		/// Returns the total amount of tokens pending withdrawal from staking per block.292		#[method(name = "appPromotion_pendingUnstakePerBlock")]293		fn pending_unstake_per_block(294			&self,295			staker: CrossAccountId,296			at: Option<BlockHash>,297		) -> Result<Vec<(BlockNumber, String)>>;298	}299}300301mod rmrk_unique_rpc {302	use super::*;303304	#[rpc(server)]305	#[async_trait]306	pub trait RmrkApi<307		BlockHash,308		AccountId,309		CollectionInfo,310		NftInfo,311		ResourceInfo,312		PropertyInfo,313		BaseInfo,314		PartType,315		Theme,316	>317	{318		/// Get the latest created collection ID.319		#[method(name = "rmrk_lastCollectionIdx")]320		fn last_collection_idx(&self, at: Option<BlockHash>) -> Result<RmrkCollectionId>;321322		/// Get collection info by ID.323		#[method(name = "rmrk_collectionById")]324		fn collection_by_id(325			&self,326			id: RmrkCollectionId,327			at: Option<BlockHash>,328		) -> Result<Option<CollectionInfo>>;329330		/// Get NFT info by collection and NFT IDs.331		#[method(name = "rmrk_nftById")]332		fn nft_by_id(333			&self,334			collection_id: RmrkCollectionId,335			nft_id: RmrkNftId,336			at: Option<BlockHash>,337		) -> Result<Option<NftInfo>>;338339		/// Get tokens owned by an account in a collection.340		#[method(name = "rmrk_accountTokens")]341		fn account_tokens(342			&self,343			account_id: AccountId,344			collection_id: RmrkCollectionId,345			at: Option<BlockHash>,346		) -> Result<Vec<RmrkNftId>>;347348		/// Get tokens nested in an NFT - its direct children (not the children's children).349		#[method(name = "rmrk_nftChildren")]350		fn nft_children(351			&self,352			collection_id: RmrkCollectionId,353			nft_id: RmrkNftId,354			at: Option<BlockHash>,355		) -> Result<Vec<RmrkNftChild>>;356357		/// Get collection properties, created by the user - not the proxy-specific properties.358		#[method(name = "rmrk_collectionProperties")]359		fn collection_properties(360			&self,361			collection_id: RmrkCollectionId,362			filter_keys: Option<Vec<String>>,363			at: Option<BlockHash>,364		) -> Result<Vec<PropertyInfo>>;365366		/// Get NFT properties, created by the user - not the proxy-specific properties.367		#[method(name = "rmrk_nftProperties")]368		fn nft_properties(369			&self,370			collection_id: RmrkCollectionId,371			nft_id: RmrkNftId,372			filter_keys: Option<Vec<String>>,373			at: Option<BlockHash>,374		) -> Result<Vec<PropertyInfo>>;375376		/// Get data of resources of an NFT.377		#[method(name = "rmrk_nftResources")]378		fn nft_resources(379			&self,380			collection_id: RmrkCollectionId,381			nft_id: RmrkNftId,382			at: Option<BlockHash>,383		) -> Result<Vec<ResourceInfo>>;384385		/// Get the priority of a resource in an NFT.386		#[method(name = "rmrk_nftResourcePriority")]387		fn nft_resource_priority(388			&self,389			collection_id: RmrkCollectionId,390			nft_id: RmrkNftId,391			resource_id: RmrkResourceId,392			at: Option<BlockHash>,393		) -> Result<Option<u32>>;394395		/// Get base info by its ID.396		#[method(name = "rmrk_base")]397		fn base(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Option<BaseInfo>>;398399		/// Get all parts of a base.400		#[method(name = "rmrk_baseParts")]401		fn base_parts(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Vec<PartType>>;402403		/// Get the theme names belonging to a base.404		#[method(name = "rmrk_themeNames")]405		fn theme_names(406			&self,407			base_id: RmrkBaseId,408			at: Option<BlockHash>,409		) -> Result<Vec<RmrkThemeName>>;410411		/// Get theme info, including properties, optionally limited to the provided keys.412		#[method(name = "rmrk_themes")]413		fn theme(414			&self,415			base_id: RmrkBaseId,416			theme_name: String,417			filter_keys: Option<Vec<String>>,418			at: Option<BlockHash>,419		) -> Result<Option<Theme>>;420	}421}422423macro_rules! define_struct_for_server_api {424	($name:ident) => {425		pub struct $name<C, P> {426			client: Arc<C>,427			_marker: std::marker::PhantomData<P>,428		}429430		impl<C, P> $name<C, P> {431			pub fn new(client: Arc<C>) -> Self {432				Self {433					client,434					_marker: Default::default(),435				}436			}437		}438	};439}440441define_struct_for_server_api!(Unique);442define_struct_for_server_api!(AppPromotion);443define_struct_for_server_api!(Rmrk);444445macro_rules! pass_method {446	(447		$method_name:ident(448			$($(#[map(|$map_arg:ident| $map:expr)])? $name:ident: $ty:ty),* $(,)?449		) -> $result:ty $(=> $mapper:expr)?,450		//$runtime_name:ident $(<$($lt: tt),+>)*451		$runtime_api_macro:ident452		$(; changed_in $ver:expr, $changed_method_name:ident ($($changed_name:expr), * $(,)?) => $fixer:expr)*453	) => {454		fn $method_name(455			&self,456			$(457				$name: $ty,458			)*459			at: Option<<Block as BlockT>::Hash>,460		) -> Result<$result> {461			let api = self.client.runtime_api();462			let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));463			let _api_version = if let Ok(Some(api_version)) =464				api.api_version::<$runtime_api_macro!()>(&at)465			{466				api_version467			} else {468				// unreachable for our runtime469				return Err(anyhow!("api is not available").into())470			};471472			let result = $(if _api_version < $ver {473				api.$changed_method_name(&at, $($changed_name),*).map(|r| r.map($fixer))474			} else)*475			{ api.$method_name(&at, $($((|$map_arg: $ty| $map))? ($name)),*) };476477			Ok(result478				.map_err(|e| anyhow!("unable to query: {e}"))?479				.map_err(|e| anyhow!("runtime error: {e:?}"))$(.map($mapper))??)480		}481	};482}483484macro_rules! unique_api {485	() => {486		dyn UniqueRuntimeApi<Block, CrossAccountId, AccountId>487	};488}489490macro_rules! app_promotion_api {491	() => {492		dyn AppPromotionRuntimeApi<Block, BlockNumber, CrossAccountId, AccountId>493	};494}495496macro_rules! rmrk_api {497	() => {498		dyn RmrkRuntimeApi<Block, AccountId, CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme>499	};500}501502#[allow(deprecated)]503impl<C, Block, CrossAccountId, AccountId>504	UniqueApiServer<<Block as BlockT>::Hash, CrossAccountId, AccountId> for Unique<C, Block>505where506	Block: BlockT,507	AccountId: Decode,508	C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,509	C::Api: UniqueRuntimeApi<Block, CrossAccountId, AccountId>,510	CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,511{512	pass_method!(513		account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>, unique_api514	);515	pass_method!(516		collection_tokens(collection: CollectionId) -> Vec<TokenId>, unique_api517	);518	pass_method!(519		token_exists(collection: CollectionId, token: TokenId) -> bool, unique_api520	);521	pass_method!(522		token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>, unique_api523	);524	pass_method!(525		topmost_token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>, unique_api526	);527	pass_method!(token_children(collection: CollectionId, token: TokenId) -> Vec<TokenChild>, unique_api);528	pass_method!(total_supply(collection: CollectionId) -> u32, unique_api);529	pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32, unique_api);530	pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string(), unique_api);531	pass_method!(532		allowance(collection: CollectionId, sender: CrossAccountId, spender: CrossAccountId, token: TokenId) -> String => |v| v.to_string(),533		unique_api534	);535536	pass_method!(collection_properties(537		collection: CollectionId,538539		#[map(|keys| string_keys_to_bytes_keys(keys))]540		keys: Option<Vec<String>>541	) -> Vec<Property>, unique_api);542543	pass_method!(token_properties(544		collection: CollectionId,545		token_id: TokenId,546547		#[map(|keys| string_keys_to_bytes_keys(keys))]548		keys: Option<Vec<String>>549	) -> Vec<Property>, unique_api);550551	pass_method!(property_permissions(552		collection: CollectionId,553554		#[map(|keys| string_keys_to_bytes_keys(keys))]555		keys: Option<Vec<String>>556	) -> Vec<PropertyKeyPermission>, unique_api);557558	pass_method!(559		token_data(560			collection: CollectionId,561			token_id: TokenId,562563			#[map(|keys| string_keys_to_bytes_keys(keys))]564			keys: Option<Vec<String>>,565		) -> TokenData<CrossAccountId>, unique_api;566		changed_in 3, token_data_before_version_3(collection, token_id, string_keys_to_bytes_keys(keys)) => |value| value.into()567	);568569	pass_method!(adminlist(collection: CollectionId) -> Vec<CrossAccountId>, unique_api);570	pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>, unique_api);571	pass_method!(allowed(collection: CollectionId, user: CrossAccountId) -> bool, unique_api);572	pass_method!(last_token_id(collection: CollectionId) -> TokenId, unique_api);573	pass_method!(574		collection_by_id(collection: CollectionId) -> Option<RpcCollection<AccountId>>, unique_api;575		changed_in 3, collection_by_id_before_version_3(collection) => |value| value.map(|coll| coll.into())576	);577	pass_method!(collection_stats() -> CollectionStats, unique_api);578	pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>, unique_api);579	pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);580	pass_method!(total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<String> => |o| o.map(|number| number.to_string()) , unique_api);581	pass_method!(token_owners(collection: CollectionId, token: TokenId) -> Vec<CrossAccountId>, unique_api);582	pass_method!(allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> bool, unique_api);583}584585impl<C, Block, BlockNumber, CrossAccountId, AccountId>586	app_promotion_unique_rpc::AppPromotionApiServer<587		<Block as BlockT>::Hash,588		BlockNumber,589		CrossAccountId,590		AccountId,591	> for AppPromotion<C, Block>592where593	Block: BlockT,594	BlockNumber: Decode + Member + AtLeast32BitUnsigned,595	AccountId: Decode,596	C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,597	CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,598	C::Api: AppPromotionRuntimeApi<Block, BlockNumber, CrossAccountId, AccountId>,599{600	pass_method!(total_staked(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), app_promotion_api);601	pass_method!(total_staked_per_block(staker: CrossAccountId) -> Vec<(BlockNumber, String)> =>602		|v| v603		.into_iter()604		.map(|(b, a)| (b, a.to_string()))605		.collect::<Vec<_>>(), app_promotion_api);606	pass_method!(pending_unstake(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), app_promotion_api);607	pass_method!(pending_unstake_per_block(staker: CrossAccountId) -> Vec<(BlockNumber, String)> =>608		|v| v609		.into_iter()610		.map(|(b, a)| (b, a.to_string()))611		.collect::<Vec<_>>(), app_promotion_api);612}613614#[allow(deprecated)]615impl<616		C,617		Block,618		AccountId,619		CollectionInfo,620		NftInfo,621		ResourceInfo,622		PropertyInfo,623		BaseInfo,624		PartType,625		Theme,626	>627	rmrk_unique_rpc::RmrkApiServer<628		<Block as BlockT>::Hash,629		AccountId,630		CollectionInfo,631		NftInfo,632		ResourceInfo,633		PropertyInfo,634		BaseInfo,635		PartType,636		Theme,637	> for Rmrk<C, Block>638where639	C: Send + Sync + 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,640	C::Api: RmrkRuntimeApi<641		Block,642		AccountId,643		CollectionInfo,644		NftInfo,645		ResourceInfo,646		PropertyInfo,647		BaseInfo,648		PartType,649		Theme,650	>,651	AccountId: Decode + Encode,652	CollectionInfo: Decode,653	NftInfo: Decode,654	ResourceInfo: Decode,655	PropertyInfo: Decode,656	BaseInfo: Decode,657	PartType: Decode,658	Theme: Decode,659	Block: BlockT,660{661	pass_method!(last_collection_idx() -> RmrkCollectionId, rmrk_api);662	pass_method!(collection_by_id(id: RmrkCollectionId) -> Option<CollectionInfo>, rmrk_api);663	pass_method!(nft_by_id(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Option<NftInfo>, rmrk_api);664	pass_method!(account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Vec<RmrkNftId>, rmrk_api);665	pass_method!(nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<RmrkNftChild>, rmrk_api);666	pass_method!(667		collection_properties(668			collection_id: RmrkCollectionId,669670			#[map(|keys| string_keys_to_bytes_keys(keys))]671			filter_keys: Option<Vec<String>>672		) -> Vec<PropertyInfo>,673		rmrk_api674	);675	pass_method!(676		nft_properties(677			collection_id: RmrkCollectionId,678			nft_id: RmrkNftId,679680			#[map(|keys| string_keys_to_bytes_keys(keys))]681			filter_keys: Option<Vec<String>>682		) -> Vec<PropertyInfo>,683		rmrk_api684	);685	pass_method!(nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Vec<ResourceInfo>, rmrk_api);686	pass_method!(nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Option<u32>, rmrk_api);687	pass_method!(base(base_id: RmrkBaseId) -> Option<BaseInfo>, rmrk_api);688	pass_method!(base_parts(base_id: RmrkBaseId) -> Vec<PartType>, rmrk_api);689	pass_method!(theme_names(base_id: RmrkBaseId) -> Vec<RmrkThemeName>, rmrk_api);690	pass_method!(691		theme(692			base_id: RmrkBaseId,693694			#[map(|n| n.into_bytes())]695			theme_name: String,696697			#[map(|keys| string_keys_to_bytes_keys(keys))]698			filter_keys: Option<Vec<String>>699		) -> Option<Theme>, rmrk_api);700}701702fn string_keys_to_bytes_keys(keys: Option<Vec<String>>) -> Option<Vec<Vec<u8>>> {703	keys.map(|keys| keys.into_iter().map(|key| key.into_bytes()).collect())704}
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -1535,7 +1535,7 @@
 	fn token_owner() -> Weight;
 
 	/// The price of setting approval for all
-	fn set_approval_for_all() -> Weight;
+	fn set_allowance_for_all() -> Weight;
 }
 
 /// Weight info extension trait for refungible pallet.
@@ -1844,11 +1844,11 @@
 	/// Get extension for RFT collection.
 	fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>>;
 
-	/// An operator is allowed to transfer all tokens of the sender on their behalf.
+	/// The `operator` is allowed to transfer all tokens of the `owner` on their behalf.
 	/// * `owner` - Token owner
 	/// * `operator` - Operator
 	/// * `approve` - Should operator status be granted or revoked?
-	fn set_approval_for_all(
+	fn set_allowance_for_all(
 		&self,
 		owner: T::CrossAccountId,
 		operator: T::CrossAccountId,
@@ -1856,7 +1856,7 @@
 	) -> DispatchResultWithPostInfo;
 
 	/// Tells whether the given `owner` approves the `operator`.
-	fn is_approved_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool;
+	fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool;
 }
 
 /// Extension for RFT collection.
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -108,7 +108,7 @@
 		Weight::zero()
 	}
 
-	fn set_approval_for_all() -> Weight {
+	fn set_allowance_for_all() -> Weight {
 		Weight::zero()
 	}
 }
@@ -429,7 +429,7 @@
 		<TotalSupply<T>>::try_get(self.id).ok()
 	}
 
-	fn set_approval_for_all(
+	fn set_allowance_for_all(
 		&self,
 		_owner: T::CrossAccountId,
 		_operator: T::CrossAccountId,
@@ -438,7 +438,7 @@
 		fail!(<Error<T>>::SettingApprovalForAllNotAllowed)
 	}
 
-	fn is_approved_for_all(&self, _owner: T::CrossAccountId, _operator: T::CrossAccountId) -> bool {
+	fn allowance_for_all(&self, _owner: T::CrossAccountId, _operator: T::CrossAccountId) -> bool {
 		false
 	}
 }
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -223,17 +223,17 @@
 
 	}: {collection.token_owner(item)}
 
-	set_approval_for_all {
+	set_allowance_for_all {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			operator: cross_from_sub(owner); owner: cross_sub;
 		};
-	}: {<Pallet<T>>::set_approval_for_all(&collection, &owner, &operator, true)}
+	}: {<Pallet<T>>::set_allowance_for_all(&collection, &owner, &operator, true)}
 
-	is_approved_for_all {
+	allowance_for_all {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			operator: cross_from_sub(owner); owner: cross_sub;
 		};
-	}: {<Pallet<T>>::is_approved_for_all(&collection, &owner, &operator)}
+	}: {<Pallet<T>>::allowance_for_all(&collection, &owner, &operator)}
 }
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -123,8 +123,8 @@
 		<SelfWeightOf<T>>::token_owner()
 	}
 
-	fn set_approval_for_all() -> Weight {
-		<SelfWeightOf<T>>::set_approval_for_all()
+	fn set_allowance_for_all() -> Weight {
+		<SelfWeightOf<T>>::set_allowance_for_all()
 	}
 }
 
@@ -517,19 +517,19 @@
 		}
 	}
 
-	fn set_approval_for_all(
+	fn set_allowance_for_all(
 		&self,
 		owner: T::CrossAccountId,
 		operator: T::CrossAccountId,
 		approve: bool,
 	) -> DispatchResultWithPostInfo {
 		with_weight(
-			<Pallet<T>>::set_approval_for_all(self, &owner, &operator, approve),
-			<CommonWeights<T>>::set_approval_for_all(),
+			<Pallet<T>>::set_allowance_for_all(self, &owner, &operator, approve),
+			<CommonWeights<T>>::set_allowance_for_all(),
 		)
 	}
 
-	fn is_approved_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {
-		<Pallet<T>>::is_approved_for_all(self, &owner, &operator)
+	fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {
+		<Pallet<T>>::allowance_for_all(self, &owner, &operator)
 	}
 }
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -472,8 +472,8 @@
 	/// @notice Sets or unsets the approval of a given operator.
 	/// The `operator` is allowed to transfer all tokens of the `caller` on their behalf.
 	/// @param operator Operator
-	/// @param approved Is operator enabled or disabled
-	#[weight(<SelfWeightOf<T>>::set_approval_for_all())]
+	/// @param approved Should operator status be granted or revoked?
+	#[weight(<SelfWeightOf<T>>::set_allowance_for_all())]
 	fn set_approval_for_all(
 		&mut self,
 		caller: caller,
@@ -483,7 +483,7 @@
 		let caller = T::CrossAccountId::from_eth(caller);
 		let operator = T::CrossAccountId::from_eth(operator);
 
-		<Pallet<T>>::set_approval_for_all(self, &caller, &operator, approved)
+		<Pallet<T>>::set_allowance_for_all(self, &caller, &operator, approved)
 			.map_err(dispatch_to_evm::<T>)?;
 		Ok(())
 	}
@@ -494,13 +494,13 @@
 		Err("not implemented".into())
 	}
 
-	/// @notice Tells whether an operator is approved by a given owner.
-	#[weight(<SelfWeightOf<T>>::is_approved_for_all())]
+	/// @notice Tells whether the given `owner` approves the `operator`.
+	#[weight(<SelfWeightOf<T>>::allowance_for_all())]
 	fn is_approved_for_all(&self, owner: address, operator: address) -> Result<bool> {
 		let owner = T::CrossAccountId::from_eth(owner);
 		let operator = T::CrossAccountId::from_eth(operator);
 
-		Ok(<Pallet<T>>::is_approved_for_all(self, &owner, &operator))
+		Ok(<Pallet<T>>::allowance_for_all(self, &owner, &operator))
 	}
 
 	/// @notice Returns collection helper contract address
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -274,7 +274,7 @@
 
 	/// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.
 	#[pallet::storage]
-	pub type WalletOperator<T: Config> = StorageNMap<
+	pub type CollectionAllowance<T: Config> = StorageNMap<
 		Key = (
 			Key<Twox64Concat, CollectionId>,
 			Key<Blake2_128Concat, T::CrossAccountId>,
@@ -450,7 +450,7 @@
 		<TokensBurnt<T>>::remove(id);
 		let _ = <Allowance<T>>::clear_prefix((id,), u32::MAX, None);
 		let _ = <AccountBalance<T>>::clear_prefix((id,), u32::MAX, None);
-		let _ = <WalletOperator<T>>::clear_prefix((id,), u32::MAX, None);
+		let _ = <CollectionAllowance<T>>::clear_prefix((id,), u32::MAX, None);
 		Ok(())
 	}
 
@@ -1206,7 +1206,7 @@
 		if <Allowance<T>>::get((collection.id, token)).as_ref() == Some(spender) {
 			return Ok(());
 		}
-		if <WalletOperator<T>>::get((collection.id, from, spender)) == Some(true) {
+		if <CollectionAllowance<T>>::get((collection.id, from, spender)) {
 			return Ok(());
 		}
 		ensure!(
@@ -1345,11 +1345,11 @@
 
 	/// Sets or unsets the approval of a given operator.
 	///
-	/// An operator is allowed to transfer all token pieces of the sender on their behalf.
+	/// The `operator` is allowed to transfer all token pieces of the `owner` on their behalf.
 	/// - `owner`: Token owner
 	/// - `operator`: Operator
-	/// - `approve`: Is operator enabled or disabled
-	pub fn set_approval_for_all(
+	/// - `approve`: Should operator status be granted or revoked?
+	pub fn set_allowance_for_all(
 		collection: &NonfungibleHandle<T>,
 		owner: &T::CrossAccountId,
 		operator: &T::CrossAccountId,
@@ -1364,7 +1364,7 @@
 
 		// =========
 
-		<WalletOperator<T>>::insert((collection.id, owner, operator), approve);
+		<CollectionAllowance<T>>::insert((collection.id, owner, operator), approve);
 		<PalletEvm<T>>::deposit_log(
 			ERC721Events::ApprovalForAll {
 				owner: *owner.as_eth(),
@@ -1382,12 +1382,12 @@
 		Ok(())
 	}
 
-	/// Tells whether an operator is approved by a given owner.
-	pub fn is_approved_for_all(
+	/// Tells whether the given `owner` approves the `operator`.
+	pub fn allowance_for_all(
 		collection: &NonfungibleHandle<T>,
 		owner: &T::CrossAccountId,
 		operator: &T::CrossAccountId,
 	) -> bool {
-		<WalletOperator<T>>::get((collection.id, owner, operator)).unwrap_or(false)
+		<CollectionAllowance<T>>::get((collection.id, owner, operator))
 	}
 }
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -1021,9 +1021,9 @@
 	}
 
 	/// @notice Sets or unsets the approval of a given operator.
-	///  An operator is allowed to transfer all tokens of the sender on their behalf.
+	/// The `operator` is allowed to transfer all tokens of the `caller` on their behalf.
 	/// @param operator Operator
-	/// @param approved Is operator enabled or disabled
+	/// @param approved Should operator status be granted or revoked?
 	/// @dev EVM selector for this function is: 0xa22cb465,
 	///  or in textual repr: setApprovalForAll(address,bool)
 	function setApprovalForAll(address operator, bool approved) public {
@@ -1043,7 +1043,7 @@
 		return 0x0000000000000000000000000000000000000000;
 	}
 
-	/// @notice Tells whether an operator is approved by a given owner.
+	/// @notice Tells whether the given `owner` approves the `operator`.
 	/// @dev EVM selector for this function is: 0xe985e9c5,
 	///  or in textual repr: isApprovedForAll(address,address)
 	function isApprovedForAll(address owner, address operator) public view returns (bool) {
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -48,8 +48,8 @@
 	fn set_token_properties(b: u32, ) -> Weight;
 	fn delete_token_properties(b: u32, ) -> Weight;
 	fn token_owner() -> Weight;
-	fn set_approval_for_all() -> Weight;
-	fn is_approved_for_all() -> Weight;
+	fn set_allowance_for_all() -> Weight;
+	fn allowance_for_all() -> Weight;
 }
 
 /// Weights for pallet_nonfungible using the Substrate node and recommended hardware.
@@ -199,12 +199,12 @@
 			.saturating_add(T::DbWeight::get().reads(1 as u64))
 	}
 	// Storage: Nonfungible WalletOperator (r:0 w:1)
-	fn set_approval_for_all() -> Weight {
+	fn set_allowance_for_all() -> Weight {
 		Weight::from_ref_time(16_231_000 as u64)
 			.saturating_add(T::DbWeight::get().writes(1 as u64))
 	}
 	// Storage: Nonfungible WalletOperator (r:1 w:0)
-	fn is_approved_for_all() -> Weight {
+	fn allowance_for_all() -> Weight {
 		Weight::from_ref_time(6_161_000 as u64)
 			.saturating_add(T::DbWeight::get().reads(1 as u64))
 	}
@@ -356,12 +356,12 @@
 			.saturating_add(RocksDbWeight::get().reads(1 as u64))
 	}
 	// Storage: Nonfungible WalletOperator (r:0 w:1)
-	fn set_approval_for_all() -> Weight {
+	fn set_allowance_for_all() -> Weight {
 		Weight::from_ref_time(16_231_000 as u64)
 			.saturating_add(RocksDbWeight::get().writes(1 as u64))
 	}
 	// Storage: Nonfungible WalletOperator (r:1 w:0)
-	fn is_approved_for_all() -> Weight {
+	fn allowance_for_all() -> Weight {
 		Weight::from_ref_time(6_161_000 as u64)
 			.saturating_add(RocksDbWeight::get().reads(1 as u64))
 	}
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -291,17 +291,17 @@
 		let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;
 	}: {<Pallet<T>>::token_owner(collection.id, item)}
 
-	set_approval_for_all {
+	set_allowance_for_all {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			operator: cross_from_sub(owner); owner: cross_sub;
 		};
-	}: {<Pallet<T>>::set_approval_for_all(&collection, &owner, &operator, true)}
+	}: {<Pallet<T>>::set_allowance_for_all(&collection, &owner, &operator, true)}
 
-	is_approved_for_all {
+	allowance_for_all {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			operator: cross_from_sub(owner); owner: cross_sub;
 		};
-	}: {<Pallet<T>>::is_approved_for_all(&collection, &owner, &operator)}
+	}: {<Pallet<T>>::allowance_for_all(&collection, &owner, &operator)}
 }
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -153,8 +153,8 @@
 		<SelfWeightOf<T>>::token_owner()
 	}
 
-	fn set_approval_for_all() -> Weight {
-		<SelfWeightOf<T>>::set_approval_for_all()
+	fn set_allowance_for_all() -> Weight {
+		<SelfWeightOf<T>>::set_allowance_for_all()
 	}
 }
 
@@ -521,20 +521,20 @@
 		<Pallet<T>>::total_pieces(self.id, token)
 	}
 
-	fn set_approval_for_all(
+	fn set_allowance_for_all(
 		&self,
 		owner: T::CrossAccountId,
 		operator: T::CrossAccountId,
 		approve: bool,
 	) -> DispatchResultWithPostInfo {
 		with_weight(
-			<Pallet<T>>::set_approval_for_all(self, &owner, &operator, approve),
-			<CommonWeights<T>>::set_approval_for_all(),
+			<Pallet<T>>::set_allowance_for_all(self, &owner, &operator, approve),
+			<CommonWeights<T>>::set_allowance_for_all(),
 		)
 	}
 
-	fn is_approved_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {
-		<Pallet<T>>::is_approved_for_all(self, &owner, &operator)
+	fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {
+		<Pallet<T>>::allowance_for_all(self, &owner, &operator)
 	}
 }
 
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -462,10 +462,10 @@
 	}
 
 	/// @notice Sets or unsets the approval of a given operator.
-	///  An operator is allowed to transfer all tokens of the sender on their behalf.
+	///  The `operator` is allowed to transfer all token pieces of the `caller` on their behalf.
 	/// @param operator Operator
-	/// @param approved Is operator enabled or disabled
-	#[weight(<SelfWeightOf<T>>::set_approval_for_all())]
+	/// @param approved Should operator status be granted or revoked?
+	#[weight(<SelfWeightOf<T>>::set_allowance_for_all())]
 	fn set_approval_for_all(
 		&mut self,
 		caller: caller,
@@ -475,7 +475,7 @@
 		let caller = T::CrossAccountId::from_eth(caller);
 		let operator = T::CrossAccountId::from_eth(operator);
 
-		<Pallet<T>>::set_approval_for_all(self, &caller, &operator, approved)
+		<Pallet<T>>::set_allowance_for_all(self, &caller, &operator, approved)
 			.map_err(dispatch_to_evm::<T>)?;
 		Ok(())
 	}
@@ -486,13 +486,13 @@
 		Err("not implemented".into())
 	}
 
-	/// @notice Tells whether an operator is approved by a given owner.
-	#[weight(<SelfWeightOf<T>>::is_approved_for_all())]
+	/// @notice Tells whether the given `owner` approves the `operator`.
+	#[weight(<SelfWeightOf<T>>::allowance_for_all())]
 	fn is_approved_for_all(&self, owner: address, operator: address) -> Result<bool> {
 		let owner = T::CrossAccountId::from_eth(owner);
 		let operator = T::CrossAccountId::from_eth(operator);
 
-		Ok(<Pallet<T>>::is_approved_for_all(self, &owner, &operator))
+		Ok(<Pallet<T>>::allowance_for_all(self, &owner, &operator))
 	}
 
 	/// @notice Returns collection helper contract address
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -275,14 +275,14 @@
 
 	/// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.
 	#[pallet::storage]
-	pub type WalletOperator<T: Config> = StorageNMap<
+	pub type CollectionAllowance<T: Config> = StorageNMap<
 		Key = (
 			Key<Twox64Concat, CollectionId>,
 			Key<Blake2_128Concat, T::CrossAccountId>,
 			Key<Blake2_128Concat, T::CrossAccountId>,
 		),
 		Value = bool,
-		QueryKind = OptionQuery,
+		QueryKind = ValueQuery,
 	>;
 
 	#[pallet::hooks]
@@ -1174,8 +1174,8 @@
 		let allowance =
 			<Allowance<T>>::get((collection.id, token, from, &spender)).checked_sub(amount);
 
-		// Allowance if any would be reduced if spender is also wallet operator
-		if <WalletOperator<T>>::get((collection.id, from, spender)) == Some(true) {
+		// Allowance (if any) would be reduced if spender is also wallet operator
+		if <CollectionAllowance<T>>::get((collection.id, from, spender)) {
 			return Ok(allowance);
 		}
 
@@ -1408,11 +1408,11 @@
 
 	/// Sets or unsets the approval of a given operator.
 	///
-	/// An operator is allowed to transfer all tokens of the sender on their behalf.
+	/// The `operator` is allowed to transfer all token pieces of the `owner` on their behalf.
 	/// - `owner`: Token owner
 	/// - `operator`: Operator
-	/// - `approve`: Is operator enabled or disabled
-	pub fn set_approval_for_all(
+	/// - `approve`: Should operator status be granted or revoked?
+	pub fn set_allowance_for_all(
 		collection: &RefungibleHandle<T>,
 		owner: &T::CrossAccountId,
 		operator: &T::CrossAccountId,
@@ -1427,7 +1427,7 @@
 
 		// =========
 
-		<WalletOperator<T>>::insert((collection.id, owner, operator), approve);
+		<CollectionAllowance<T>>::insert((collection.id, owner, operator), approve);
 		<PalletEvm<T>>::deposit_log(
 			ERC721Events::ApprovalForAll {
 				owner: *owner.as_eth(),
@@ -1445,12 +1445,12 @@
 		Ok(())
 	}
 
-	/// Tells whether an operator is approved by a given owner.
-	pub fn is_approved_for_all(
+	/// Tells whether the given `owner` approves the `operator`.
+	pub fn allowance_for_all(
 		collection: &RefungibleHandle<T>,
 		owner: &T::CrossAccountId,
 		operator: &T::CrossAccountId,
 	) -> bool {
-		<WalletOperator<T>>::get((collection.id, owner, operator)).unwrap_or(false)
+		<CollectionAllowance<T>>::get((collection.id, owner, operator))
 	}
 }
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -1018,9 +1018,9 @@
 	}
 
 	/// @notice Sets or unsets the approval of a given operator.
-	///  An operator is allowed to transfer all tokens of the sender on their behalf.
+	///  The `operator` is allowed to transfer all token pieces of the `caller` on their behalf.
 	/// @param operator Operator
-	/// @param approved Is operator enabled or disabled
+	/// @param approved Should operator status be granted or revoked?
 	/// @dev EVM selector for this function is: 0xa22cb465,
 	///  or in textual repr: setApprovalForAll(address,bool)
 	function setApprovalForAll(address operator, bool approved) public {
@@ -1040,7 +1040,7 @@
 		return 0x0000000000000000000000000000000000000000;
 	}
 
-	/// @notice Tells whether an operator is approved by a given owner.
+	/// @notice Tells whether the given `owner` approves the `operator`.
 	/// @dev EVM selector for this function is: 0xe985e9c5,
 	///  or in textual repr: isApprovedForAll(address,address)
 	function isApprovedForAll(address owner, address operator) public view returns (bool) {
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -55,8 +55,8 @@
 	fn delete_token_properties(b: u32, ) -> Weight;
 	fn repartition_item() -> Weight;
 	fn token_owner() -> Weight;
-	fn set_approval_for_all() -> Weight;
-	fn is_approved_for_all() -> Weight;
+	fn set_allowance_for_all() -> Weight;
+	fn allowance_for_all() -> Weight;
 }
 
 /// Weights for pallet_refungible using the Substrate node and recommended hardware.
@@ -263,12 +263,12 @@
 			.saturating_add(T::DbWeight::get().reads(2 as u64))
 	}
 	// Storage: Refungible WalletOperator (r:0 w:1)
-	fn set_approval_for_all() -> Weight {
+	fn set_allowance_for_all() -> Weight {
 		Weight::from_ref_time(16_150_000 as u64)
 			.saturating_add(T::DbWeight::get().writes(1 as u64))
 	}
 	// Storage: Refungible WalletOperator (r:1 w:0)
-	fn is_approved_for_all() -> Weight {
+	fn allowance_for_all() -> Weight {
 		Weight::from_ref_time(5_901_000 as u64)
 			.saturating_add(T::DbWeight::get().reads(1 as u64))
 	}
@@ -477,12 +477,12 @@
 			.saturating_add(RocksDbWeight::get().reads(2 as u64))
 	}
 	// Storage: Refungible WalletOperator (r:0 w:1)
-	fn set_approval_for_all() -> Weight {
+	fn set_allowance_for_all() -> Weight {
 		Weight::from_ref_time(16_150_000 as u64)
 			.saturating_add(RocksDbWeight::get().writes(1 as u64))
 	}
 	// Storage: Refungible WalletOperator (r:1 w:0)
-	fn is_approved_for_all() -> Weight {
+	fn allowance_for_all() -> Weight {
 		Weight::from_ref_time(5_901_000 as u64)
 			.saturating_add(RocksDbWeight::get().reads(1 as u64))
 	}
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -36,7 +36,7 @@
 use sp_std::vec;
 use up_data_structs::{
 	CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,
-	CreateCollectionData, CollectionId,
+	CreateCollectionData,
 };
 
 use crate::{weights::WeightInfo, Config, SelfWeightOf};
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -1129,15 +1129,15 @@
 
 		/// Sets or unsets the approval of a given operator.
 		///
-		/// An operator is allowed to transfer all tokens of the sender on their behalf.
+		/// The `operator` is allowed to transfer all tokens of the `owner` on their behalf.
 		///
 		/// # Arguments
 		///
 		/// * `owner`: Token owner
 		/// * `operator`: Operator
-		/// * `approve`: Is operator enabled or disabled
-		#[weight = T::CommonWeightInfo::set_approval_for_all()]
-		pub fn set_approval_for_all(
+		/// * `approve`: Should operator status be granted or revoked?
+		#[weight = T::CommonWeightInfo::set_allowance_for_all()]
+		pub fn set_allowance_for_all(
 			origin,
 			collection_id: CollectionId,
 			operator: T::CrossAccountId,
@@ -1145,7 +1145,7 @@
 		) -> DispatchResultWithPostInfo {
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
 			dispatch_tx::<T, _>(collection_id, |d| {
-				d.set_approval_for_all(sender, operator, approve)
+				d.set_allowance_for_all(sender, operator, approve)
 			})
 		}
 	}
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -134,6 +134,6 @@
 		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;
 
 		/// Get whether an operator is approved by a given owner.
-		fn is_approved_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool>;
+		fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool>;
 	}
 }
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -188,8 +188,8 @@
                     dispatch_unique_runtime!(collection.total_pieces(token_id))
                 }
 
-		        fn is_approved_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool, DispatchError> {
-                    dispatch_unique_runtime!(collection.is_approved_for_all(owner, operator))
+		        fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool, DispatchError> {
+                    dispatch_unique_runtime!(collection.allowance_for_all(owner, operator))
                 }
             }
 
modifiedruntime/common/weights.rsdiffbeforeafterboth
--- a/runtime/common/weights.rs
+++ b/runtime/common/weights.rs
@@ -121,8 +121,8 @@
 		max_weight_of!(token_owner())
 	}
 
-	fn set_approval_for_all() -> Weight {
-		max_weight_of!(set_approval_for_all())
+	fn set_allowance_for_all() -> Weight {
+		max_weight_of!(set_allowance_for_all())
 	}
 }
 
modifiedtests/src/approve.test.tsdiffbeforeafterboth
--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -617,26 +617,31 @@
 
   itSub('[nft] Enable and disable approval', async ({helper}) => {
     const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
-    const checkBeforeApproval = await helper.nft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+
+    const checkBeforeApproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
     expect(checkBeforeApproval).to.be.false;
-    await helper.nft.setApprovalForAll(alice, collectionId, {Substrate: bob.address}, true);
-    const checkAfterApproval = await helper.nft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+
+    await helper.nft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, true);
+    const checkAfterApproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
     expect(checkAfterApproval).to.be.true;
-    await helper.nft.setApprovalForAll(alice, collectionId, {Substrate: bob.address}, false);
-    const checkAfterDisapproval = await helper.nft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+
+    await helper.nft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, false);
+    const checkAfterDisapproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
     expect(checkAfterDisapproval).to.be.false;
   });
 
   itSub.ifWithPallets('[rft] Enable and disable approval', [Pallets.ReFungible], async ({helper}) => {
     const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    const checkBeforeApproval = await helper.rft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+
+    const checkBeforeApproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
     expect(checkBeforeApproval).to.be.false;
-    await helper.rft.setApprovalForAll(alice, collectionId, {Substrate: bob.address}, true);
-    const checkAfterApproval = await helper.rft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+
+    await helper.rft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, true);
+    const checkAfterApproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
     expect(checkAfterApproval).to.be.true;
-    await helper.rft.setApprovalForAll(alice, collectionId, {Substrate: bob.address}, false);
-    const checkAfterDisapproval = await helper.rft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+    
+    await helper.rft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, false);
+    const checkAfterDisapproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
     expect(checkAfterDisapproval).to.be.false;
   });
 });
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -672,9 +672,9 @@
 	function approve(address approved, uint256 tokenId) external;
 
 	/// @notice Sets or unsets the approval of a given operator.
-	///  An operator is allowed to transfer all tokens of the sender on their behalf.
+	/// The `operator` is allowed to transfer all tokens of the `caller` on their behalf.
 	/// @param operator Operator
-	/// @param approved Is operator enabled or disabled
+	/// @param approved Should operator status be granted or revoked?
 	/// @dev EVM selector for this function is: 0xa22cb465,
 	///  or in textual repr: setApprovalForAll(address,bool)
 	function setApprovalForAll(address operator, bool approved) external;
@@ -684,7 +684,7 @@
 	///  or in textual repr: getApproved(uint256)
 	function getApproved(uint256 tokenId) external view returns (address);
 
-	/// @notice Tells whether an operator is approved by a given owner.
+	/// @notice Tells whether the given `owner` approves the `operator`.
 	/// @dev EVM selector for this function is: 0xe985e9c5,
 	///  or in textual repr: isApprovedForAll(address,address)
 	function isApprovedForAll(address owner, address operator) external view returns (bool);
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -669,9 +669,9 @@
 	function approve(address approved, uint256 tokenId) external;
 
 	/// @notice Sets or unsets the approval of a given operator.
-	///  An operator is allowed to transfer all tokens of the sender on their behalf.
+	///  The `operator` is allowed to transfer all token pieces of the `caller` on their behalf.
 	/// @param operator Operator
-	/// @param approved Is operator enabled or disabled
+	/// @param approved Should operator status be granted or revoked?
 	/// @dev EVM selector for this function is: 0xa22cb465,
 	///  or in textual repr: setApprovalForAll(address,bool)
 	function setApprovalForAll(address operator, bool approved) external;
@@ -681,7 +681,7 @@
 	///  or in textual repr: getApproved(uint256)
 	function getApproved(uint256 tokenId) external view returns (address);
 
-	/// @notice Tells whether an operator is approved by a given owner.
+	/// @notice Tells whether the given `owner` approves the `operator`.
 	/// @dev EVM selector for this function is: 0xe985e9c5,
 	///  or in textual repr: isApprovedForAll(address,address)
 	function isApprovedForAll(address owner, address operator) external view returns (bool);
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -935,48 +935,54 @@
   let donor: IKeyringPair;
   let minter: IKeyringPair;
   let alice: IKeyringPair;
-  let bob: IKeyringPair;
 
   before(async function() {
     await usingEthPlaygrounds(async (helper, privateKey) => {
       donor = await privateKey({filename: __filename});
-      [minter, alice, bob] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+      [minter, alice] = await helper.arrange.createAccounts([100n, 100n], donor);
     });
   });
 
   itEth('[negative] Cant perform burn without approval', async ({helper}) => {
     const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
 
-    const owner = bob;
+    const owner = await helper.eth.createAccountWithBalance(donor, 100n);
     const spender = await helper.eth.createAccountWithBalance(donor, 100n);
 
-    const token = await collection.mintToken(minter, {Substrate: owner.address});
+    const token = await collection.mintToken(minter, {Ethereum: owner});
 
     const address = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(address, 'nft');
 
-    {
-      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);
-      await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;
-    }
+    const ownerCross = helper.ethCrossAccount.fromAddress(owner);
+    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;
+
+    await contract.methods.setApprovalForAll(spender, true).send({from: owner});
+    await contract.methods.setApprovalForAll(spender, false).send({from: owner});
+
+    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;
   });
 
   itEth('[negative] Cant perform transfer without approval', async ({helper}) => {
     const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
-    const owner = bob;
     const receiver = alice;
 
+    const owner = await helper.eth.createAccountWithBalance(donor, 100n);
     const spender = await helper.eth.createAccountWithBalance(donor, 100n);
 
-    const token = await collection.mintToken(minter, {Substrate: owner.address});
+    const token = await collection.mintToken(minter, {Ethereum: owner});
 
     const address = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(address, 'nft');
 
-    {
-      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);
-      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);
-      await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;
-    }
+    const ownerCross = helper.ethCrossAccount.fromAddress(owner);
+    const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);
+
+    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;
+
+    await contract.methods.setApprovalForAll(spender, true).send({from: owner});
+    await contract.methods.setApprovalForAll(spender, false).send({from: owner});
+    
+    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;
   });
 });
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -750,10 +750,14 @@
     const address = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(address, 'rft');
 
-    {
-      const ownerCross = helper.ethCrossAccount.fromAddress(owner);
-      await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;
-    }
+    const ownerCross = helper.ethCrossAccount.fromAddress(owner);
+
+    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;
+
+    await contract.methods.setApprovalForAll(spender, true).send({from: owner});
+    await contract.methods.setApprovalForAll(spender, false).send({from: owner});
+
+    await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;
   });
 
   itEth('[negative] Cant perform transfer without approval', async ({helper}) => {
@@ -768,10 +772,14 @@
     const address = helper.ethAddress.fromCollectionId(collection.collectionId);
     const contract = helper.ethNativeContract.collection(address, 'rft');
 
-    {
-      const ownerCross = helper.ethCrossAccount.fromAddress(owner);
-      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);
-      await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;
-    }
+    const ownerCross = helper.ethCrossAccount.fromAddress(owner);
+    const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);
+    
+    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;
+
+    await contract.methods.setApprovalForAll(spender, true).send({from: owner});
+    await contract.methods.setApprovalForAll(spender, false).send({from: owner});
+    
+    await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;
   });
 });
modifiedtests/src/interfaces/augment-api-events.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-events.ts
+++ b/tests/src/interfaces/augment-api-events.ts
@@ -107,7 +107,7 @@
        **/
       Approved: AugmentedEvent<ApiType, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr, u128]>;
       /**
-       * Amount pieces of token owned by `sender` was approved for `spender`.
+       * A `sender` approves operations on all owned tokens for `spender`.
        **/
       ApprovedForAll: AugmentedEvent<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr, bool]>;
       /**
modifiedtests/src/interfaces/augment-api-query.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-query.ts
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -406,6 +406,10 @@
        **/
       allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
       /**
+       * Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.
+       **/
+      collectionAllowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;
+      /**
        * Used to enumerate tokens owned by account.
        **/
       owned: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: u32 | AnyNumber | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]>;
@@ -441,10 +445,6 @@
        * Total amount of minted tokens in a collection.
        **/
       tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
-      /**
-       * Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.
-       **/
-      walletOperator: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<Option<bool>>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;
       /**
        * Generic query
        **/
@@ -625,6 +625,10 @@
        **/
       balance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
       /**
+       * Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.
+       **/
+      collectionAllowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;
+      /**
        * Used to enumerate tokens owned by account.
        **/
       owned: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: u32 | AnyNumber | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]>;
@@ -648,10 +652,6 @@
        * Total amount of pieces for token
        **/
       totalSupply: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u128>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
-      /**
-       * Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.
-       **/
-      walletOperator: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<Option<bool>>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;
       /**
        * Generic query
        **/
modifiedtests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-rpc.ts
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -684,6 +684,10 @@
        **/
       allowance: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, sender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, spender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
       /**
+       * Tells whether the given `owner` approves the `operator`.
+       **/
+      allowanceForAll: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, owner: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, operator: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<bool>>>;
+      /**
        * Check if a user is allowed to operate within a collection
        **/
       allowed: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<bool>>;
@@ -719,10 +723,6 @@
        * Get effective collection limits
        **/
       effectiveCollectionLimits: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<UpDataStructsCollectionLimits>>>;
-      /**
-       * Tells whether an operator is approved by a given owner.
-       **/
-      isApprovedForAll: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, owner: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, operator: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<bool>>>;
       /**
        * Get the last token ID created in a collection
        **/
modifiedtests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -1547,15 +1547,15 @@
       /**
        * Sets or unsets the approval of a given operator.
        * 
-       * An operator is allowed to transfer all tokens of the sender on their behalf.
+       * The `operator` is allowed to transfer all tokens of the `owner` on their behalf.
        * 
        * # Arguments
        * 
        * * `owner`: Token owner
        * * `operator`: Operator
-       * * `approve`: Is operator enabled or disabled
+       * * `approve`: Should operator status be granted or revoked?
        **/
-      setApprovalForAll: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, operator: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, bool]>;
+      setAllowanceForAll: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, operator: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, bool]>;
       /**
        * Set specific limits of a collection. Empty, or None fields mean chain default.
        * 
modifiedtests/src/interfaces/default/types.tsdiffbeforeafterboth
--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -2312,13 +2312,13 @@
     readonly tokenId: u32;
     readonly amount: u128;
   } & Struct;
-  readonly isSetApprovalForAll: boolean;
-  readonly asSetApprovalForAll: {
+  readonly isSetAllowanceForAll: boolean;
+  readonly asSetAllowanceForAll: {
     readonly collectionId: u32;
     readonly operator: PalletEvmAccountBasicCrossAccountIdRepr;
     readonly approve: bool;
   } & Struct;
-  readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetApprovalForAll';
+  readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetAllowanceForAll';
 }
 
 /** @name PalletUniqueError */
modifiedtests/src/interfaces/lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -2305,7 +2305,7 @@
         tokenId: 'u32',
         amount: 'u128',
       },
-      set_approval_for_all: {
+      set_allowance_for_all: {
         collectionId: 'u32',
         operator: 'PalletEvmAccountBasicCrossAccountIdRepr',
         approve: 'bool'
modifiedtests/src/interfaces/types-lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -2541,13 +2541,13 @@
       readonly tokenId: u32;
       readonly amount: u128;
     } & Struct;
-    readonly isSetApprovalForAll: boolean;
-    readonly asSetApprovalForAll: {
+    readonly isSetAllowanceForAll: boolean;
+    readonly asSetAllowanceForAll: {
       readonly collectionId: u32;
       readonly operator: PalletEvmAccountBasicCrossAccountIdRepr;
       readonly approve: bool;
     } & Struct;
-    readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetApprovalForAll';
+    readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetAllowanceForAll';
   }
 
   /** @name UpDataStructsCollectionMode (240) */
modifiedtests/src/interfaces/unique/definitions.tsdiffbeforeafterboth
--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -175,8 +175,8 @@
       [collectionParam, tokenParam], 
       'Option<u128>',
     ),
-    isApprovedForAll: fun(
-      'Tells whether an operator is approved by a given owner.', 
+    allowanceForAll: fun(
+      'Tells whether the given `owner` approves the `operator`.', 
       [collectionParam, crossAccountParam('owner'), crossAccountParam('operator')], 
       'Option<bool>',
     ),
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1415,26 +1415,26 @@
   }
 
   /**
-   * Tells whether an operator is approved by a given owner.
+   * Tells whether the given `owner` approves the `operator`.
    * @param collectionId ID of collection
    * @param owner owner address
-	 * @param operator operator addrees
+   * @param operator operator addrees
    * @returns true if operator is enabled
    */
-  async isApprovedForAll(collectionId: number, owner: ICrossAccountId, operator: ICrossAccountId): Promise<boolean> {
-    return (await this.helper.callRpc('api.rpc.unique.isApprovedForAll', [collectionId, owner, operator])).toJSON();
+  async allowanceForAll(collectionId: number, owner: ICrossAccountId, operator: ICrossAccountId): Promise<boolean> {
+    return (await this.helper.callRpc('api.rpc.unique.allowanceForAll', [collectionId, owner, operator])).toJSON();
   }
 
   /** Sets or unsets the approval of a given operator.
-	 *  An operator is allowed to transfer all tokens of the sender on their behalf.
-	 *  @param operator Operator
-	 *  @param approved Is operator enabled or disabled
+   *  The `operator` is allowed to transfer all tokens of the `caller` on their behalf.
+   *  @param operator Operator
+   *  @param approved Should operator status be granted or revoked?
    *  @returns ```true``` if extrinsic success, otherwise ```false```
    */
-  async setApprovalForAll(signer: TSigner, collectionId: number, operator: ICrossAccountId, approved: boolean): Promise<boolean> {
+  async setAllowanceForAll(signer: TSigner, collectionId: number, operator: ICrossAccountId, approved: boolean): Promise<boolean> {
     const result = await this.helper.executeExtrinsic(
       signer,
-      'api.tx.unique.setApprovalForAll', [collectionId, operator, approved],
+      'api.tx.unique.setAllowanceForAll', [collectionId, operator, approved],
       true,
     );
     return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'ApprovedForAll');