difftreelog
refactor unsupported! macro
in: master
4 files changed
pallets/common/src/lib.rsdiffbeforeafterboth535535536 /// Can't transfer tokens to ethereum zero address536 /// Can't transfer tokens to ethereum zero address537 AddressIsZero,537 AddressIsZero,538 /// Target collection doesn't support this operation538539 /// The oprtation is not supported539 UnsupportedOperation,540 UnsupportedOperation,540541541 /// Insufficient funds to perform an action542 /// Insufficient funds to perform an action570 /// Tried to access an internal collection with an external API571 /// Tried to access an internal collection with an external API571 CollectionIsInternal,572 CollectionIsInternal,572573 /// A method of an unsupported API was called574 UnsupportedRuntimeApi,575 }573 }576574577 /// Storage of the count of created collections. Essentially contains the last collection ID.575 /// Storage of the count of created collections. Essentially contains the last collection ID.1356/// Indicates unsupported methods by returning [Error::UnsupportedOperation].1354/// Indicates unsupported methods by returning [Error::UnsupportedOperation].1357#[macro_export]1355#[macro_export]1358macro_rules! unsupported {1356macro_rules! unsupported {1359 () => {1357 ($runtime:path) => {1360 Err(<Error<T>>::UnsupportedOperation.into())1358 Err($crate::Error::<$runtime>::UnsupportedOperation.into())1361 };1359 };1362}1360}13631361runtime/common/dispatch.rsdiffbeforeafterboth34 CollectionId,34 CollectionId,35};35};3637#[cfg(not(feature = "refungible"))]38use pallet_common::unsupported;363937pub enum CollectionDispatchT<T>40pub enum CollectionDispatchT<T>38where41where68 CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,72 CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,697370 #[cfg(not(feature = "refungible"))]74 #[cfg(not(feature = "refungible"))]71 CollectionMode::ReFungible => {75 CollectionMode::ReFungible => return unsupported!(T)72 return Err(DispatchError::Other("Refunginle pallet is not supported"))73 }74 };76 };75 Ok(id)77 Ok(id)76 }78 }runtime/common/mod.rsdiffbeforeafterboth43};43};44use common_types::{AccountId, BlockNumber};44use common_types::{AccountId, BlockNumber};454546#[macro_export]47macro_rules! unsupported {48 () => {46pub type CommonError = pallet_common::Error<Runtime>;49 pallet_common::unsupported!($crate::Runtime)50 }51}475248/// The address format for describing accounts.53/// The address format for describing accounts.49pub type Address = sp_runtime::MultiAddress<AccountId, ()>;54pub type Address = sp_runtime::MultiAddress<AccountId, ()>;runtime/common/runtime_apis.rsdiffbeforeafterboth205 return pallet_proxy_rmrk_core::rpc::last_collection_idx::<Runtime>();205 return pallet_proxy_rmrk_core::rpc::last_collection_idx::<Runtime>();206206207 #[cfg(not(feature = "rmrk"))]207 #[cfg(not(feature = "rmrk"))]208 return Err(CommonError::UnsupportedRuntimeApi.into());208 return unsupported!();209 }209 }210210211 #[allow(unused_variables)]211 #[allow(unused_variables)]214 return pallet_proxy_rmrk_core::rpc::collection_by_id::<Runtime>(collection_id);214 return pallet_proxy_rmrk_core::rpc::collection_by_id::<Runtime>(collection_id);215215216 #[cfg(not(feature = "rmrk"))]216 #[cfg(not(feature = "rmrk"))]217 return Err(CommonError::UnsupportedRuntimeApi.into());217 return unsupported!();218 }218 }219219220 #[allow(unused_variables)]220 #[allow(unused_variables)]223 return pallet_proxy_rmrk_core::rpc::nft_by_id::<Runtime>(collection_id, nft_by_id);223 return pallet_proxy_rmrk_core::rpc::nft_by_id::<Runtime>(collection_id, nft_by_id);224224225 #[cfg(not(feature = "rmrk"))]225 #[cfg(not(feature = "rmrk"))]226 return Err(CommonError::UnsupportedRuntimeApi.into());226 return unsupported!();227 }227 }228228229 #[allow(unused_variables)]229 #[allow(unused_variables)]232 return pallet_proxy_rmrk_core::rpc::account_tokens::<Runtime>(account_id, collection_id);232 return pallet_proxy_rmrk_core::rpc::account_tokens::<Runtime>(account_id, collection_id);233233234 #[cfg(not(feature = "rmrk"))]234 #[cfg(not(feature = "rmrk"))]235 return Err(CommonError::UnsupportedRuntimeApi.into());235 return unsupported!();236 }236 }237237238 #[allow(unused_variables)]238 #[allow(unused_variables)]241 return pallet_proxy_rmrk_core::rpc::nft_children::<Runtime>(collection_id, nft_id);241 return pallet_proxy_rmrk_core::rpc::nft_children::<Runtime>(collection_id, nft_id);242242243 #[cfg(not(feature = "rmrk"))]243 #[cfg(not(feature = "rmrk"))]244 return Err(CommonError::UnsupportedRuntimeApi.into());244 return unsupported!();245 }245 }246246247 #[allow(unused_variables)]247 #[allow(unused_variables)]253 return pallet_proxy_rmrk_core::rpc::collection_properties::<Runtime>(collection_id, filter_keys);253 return pallet_proxy_rmrk_core::rpc::collection_properties::<Runtime>(collection_id, filter_keys);254254255 #[cfg(not(feature = "rmrk"))]255 #[cfg(not(feature = "rmrk"))]256 return Err(CommonError::UnsupportedRuntimeApi.into());256 return unsupported!();257 }257 }258258259 #[allow(unused_variables)]259 #[allow(unused_variables)]266 return pallet_proxy_rmrk_core::rpc::nft_properties::<Runtime>(collection_id, nft_id, filter_keys);266 return pallet_proxy_rmrk_core::rpc::nft_properties::<Runtime>(collection_id, nft_id, filter_keys);267267268 #[cfg(not(feature = "rmrk"))]268 #[cfg(not(feature = "rmrk"))]269 return Err(CommonError::UnsupportedRuntimeApi.into());269 return unsupported!();270 }270 }271271272 #[allow(unused_variables)]272 #[allow(unused_variables)]275 return pallet_proxy_rmrk_core::rpc::nft_resources::<Runtime>(collection_id, nft_id);275 return pallet_proxy_rmrk_core::rpc::nft_resources::<Runtime>(collection_id, nft_id);276276277 #[cfg(not(feature = "rmrk"))]277 #[cfg(not(feature = "rmrk"))]278 return Err(CommonError::UnsupportedRuntimeApi.into());278 return unsupported!();279 }279 }280280281 #[allow(unused_variables)]281 #[allow(unused_variables)]288 return pallet_proxy_rmrk_core::rpc::nft_resource_priority::<Runtime>(collection_id, nft_id, resource_id);288 return pallet_proxy_rmrk_core::rpc::nft_resource_priority::<Runtime>(collection_id, nft_id, resource_id);289289290 #[cfg(not(feature = "rmrk"))]290 #[cfg(not(feature = "rmrk"))]291 return Err(CommonError::UnsupportedRuntimeApi.into());291 return unsupported!();292 }292 }293293294 #[allow(unused_variables)]294 #[allow(unused_variables)]297 return pallet_proxy_rmrk_equip::rpc::base::<Runtime>(base_id);297 return pallet_proxy_rmrk_equip::rpc::base::<Runtime>(base_id);298298299 #[cfg(not(feature = "rmrk"))]299 #[cfg(not(feature = "rmrk"))]300 return Err(CommonError::UnsupportedRuntimeApi.into());300 return unsupported!();301 }301 }302302303 #[allow(unused_variables)]303 #[allow(unused_variables)]306 return pallet_proxy_rmrk_equip::rpc::base_parts::<Runtime>(base_id);306 return pallet_proxy_rmrk_equip::rpc::base_parts::<Runtime>(base_id);307307308 #[cfg(not(feature = "rmrk"))]308 #[cfg(not(feature = "rmrk"))]309 return Err(CommonError::UnsupportedRuntimeApi.into());309 return unsupported!();310 }310 }311311312 #[allow(unused_variables)]312 #[allow(unused_variables)]315 return pallet_proxy_rmrk_equip::rpc::theme_names::<Runtime>(base_id);315 return pallet_proxy_rmrk_equip::rpc::theme_names::<Runtime>(base_id);316316317 #[cfg(not(feature = "rmrk"))]317 #[cfg(not(feature = "rmrk"))]318 return Err(CommonError::UnsupportedRuntimeApi.into());318 return unsupported!();319 }319 }320320321 #[allow(unused_variables)]321 #[allow(unused_variables)]328 return pallet_proxy_rmrk_equip::rpc::theme::<Runtime>(base_id, theme_name, filter_keys);328 return pallet_proxy_rmrk_equip::rpc::theme::<Runtime>(base_id, theme_name, filter_keys);329329330 #[cfg(not(feature = "rmrk"))]330 #[cfg(not(feature = "rmrk"))]331 return Err(CommonError::UnsupportedRuntimeApi.into());331 return unsupported!();332 }332 }333 }333 }334334