difftreelog
fix disbaled pallets Rmrk, RFT, Scheduler for Quartz RFT, Scheduler for Unique Added the logic of checking the availability of pallets necessary for their execution in tests
in: master
27 files changed
runtime/common/Cargo.tomldiffbeforeafterboth--- a/runtime/common/Cargo.toml
+++ b/runtime/common/Cargo.toml
@@ -32,6 +32,8 @@
'frame-support/runtime-benchmarks',
'frame-system/runtime-benchmarks',
]
+unique-runtime = ['std']
+quartz-runtime = ['std']
[dependencies.sp-core]
default-features = false
runtime/common/src/dispatch.rsdiffbeforeafterboth--- a/runtime/common/src/dispatch.rs
+++ b/runtime/common/src/dispatch.rs
@@ -64,7 +64,12 @@
);
<PalletFungible<T>>::init_collection(sender, data)?
}
+ #[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,
+
+ CollectionMode::ReFungible => {
+ return Err(DispatchError::Other("Refunginle pallet is not supported"))
+ }
};
Ok(id)
}
runtime/common/src/weights.rsdiffbeforeafterboth--- a/runtime/common/src/weights.rs
+++ b/runtime/common/src/weights.rs
@@ -25,6 +25,7 @@
};
use up_data_structs::{CreateItemExData, CreateItemData};
+#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
macro_rules! max_weight_of {
($method:ident ( $($args:tt)* )) => {
<FungibleWeights<T>>::$method($($args)*)
@@ -33,9 +34,21 @@
};
}
+#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
+macro_rules! max_weight_of {
+ ($method:ident ( $($args:tt)* )) => {
+ <FungibleWeights<T>>::$method($($args)*)
+ .max(<NonfungibleWeights<T>>::$method($($args)*))
+
+ };
+}
+
+#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
pub struct CommonWeights<T>(PhantomData<T>)
where
T: FungibleConfig + NonfungibleConfig + RefungibleConfig;
+
+#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>
where
T: FungibleConfig + NonfungibleConfig + RefungibleConfig,
@@ -101,6 +114,7 @@
}
}
+#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>
where
T: FungibleConfig + NonfungibleConfig + RefungibleConfig,
@@ -109,3 +123,84 @@
dispatch_weight::<T>() + <<T as RefungibleConfig>::WeightInfo>::repartition_item()
}
}
+
+#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
+pub struct CommonWeights<T>(PhantomData<T>)
+where
+ T: FungibleConfig + NonfungibleConfig;
+
+#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
+impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>
+where
+ T: FungibleConfig + NonfungibleConfig,
+{
+ fn create_item() -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(create_item())
+ }
+
+ fn create_multiple_items(data: &[CreateItemData]) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(create_multiple_items(data))
+ }
+
+ fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(create_multiple_items_ex(data))
+ }
+
+ fn burn_item() -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(burn_item())
+ }
+
+ fn set_collection_properties(amount: u32) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))
+ }
+
+ fn delete_collection_properties(amount: u32) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))
+ }
+
+ fn set_token_properties(amount: u32) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))
+ }
+
+ fn delete_token_properties(amount: u32) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))
+ }
+
+ fn set_token_property_permissions(amount: u32) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))
+ }
+
+ fn transfer() -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(transfer())
+ }
+
+ fn approve() -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(approve())
+ }
+
+ fn transfer_from() -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(transfer_from())
+ }
+
+ fn burn_from() -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(burn_from())
+ }
+
+ fn burn_recursively_self_raw() -> Weight {
+ max_weight_of!(burn_recursively_self_raw())
+ }
+
+ fn burn_recursively_breadth_raw(amount: u32) -> Weight {
+ max_weight_of!(burn_recursively_breadth_raw(amount))
+ }
+}
+
+#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
+impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>
+where
+ T: FungibleConfig + NonfungibleConfig,
+{
+ fn repartition() -> Weight {
+ dispatch_weight::<T>()
+ }
+}
runtime/quartz/src/lib.rsdiffbeforeafterboth--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -909,15 +909,15 @@
type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
}
-impl pallet_proxy_rmrk_core::Config for Runtime {
- type WeightInfo = pallet_proxy_rmrk_core::weights::SubstrateWeight<Self>;
- type Event = Event;
-}
+// impl pallet_proxy_rmrk_core::Config for Runtime {
+// type WeightInfo = pallet_proxy_rmrk_core::weights::SubstrateWeight<Self>;
+// type Event = Event;
+// }
-impl pallet_proxy_rmrk_equip::Config for Runtime {
- type WeightInfo = pallet_proxy_rmrk_equip::weights::SubstrateWeight<Self>;
- type Event = Event;
-}
+// impl pallet_proxy_rmrk_equip::Config for Runtime {
+// type WeightInfo = pallet_proxy_rmrk_equip::weights::SubstrateWeight<Self>;
+// type Event = Event;
+// }
impl pallet_unique::Config for Runtime {
type Event = Event;
@@ -961,92 +961,92 @@
)
}
-pub struct SchedulerPaymentExecutor;
-impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>
- DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
-where
- <T as frame_system::Config>::Call: Member
- + Dispatchable<Origin = Origin, Info = DispatchInfo>
- + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
- + GetDispatchInfo
- + From<frame_system::Call<Runtime>>,
- SelfContainedSignedInfo: Send + Sync + 'static,
- Call: From<<T as frame_system::Config>::Call>
- + From<<T as pallet_unique_scheduler::Config>::Call>
- + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,
- sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,
-{
- fn dispatch_call(
- signer: <T as frame_system::Config>::AccountId,
- call: <T as pallet_unique_scheduler::Config>::Call,
- ) -> Result<
- Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,
- TransactionValidityError,
- > {
- let dispatch_info = call.get_dispatch_info();
- let extrinsic = fp_self_contained::CheckedExtrinsic::<
- AccountId,
- Call,
- SignedExtraScheduler,
- SelfContainedSignedInfo,
- > {
- signed:
- CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(
- signer.clone().into(),
- get_signed_extras(signer.into()),
- ),
- function: call.into(),
- };
+// pub struct SchedulerPaymentExecutor;
+// impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>
+// DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
+// where
+// <T as frame_system::Config>::Call: Member
+// + Dispatchable<Origin = Origin, Info = DispatchInfo>
+// + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
+// + GetDispatchInfo
+// + From<frame_system::Call<Runtime>>,
+// SelfContainedSignedInfo: Send + Sync + 'static,
+// Call: From<<T as frame_system::Config>::Call>
+// + From<<T as pallet_unique_scheduler::Config>::Call>
+// + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,
+// sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,
+// {
+// fn dispatch_call(
+// signer: <T as frame_system::Config>::AccountId,
+// call: <T as pallet_unique_scheduler::Config>::Call,
+// ) -> Result<
+// Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,
+// TransactionValidityError,
+// > {
+// let dispatch_info = call.get_dispatch_info();
+// let extrinsic = fp_self_contained::CheckedExtrinsic::<
+// AccountId,
+// Call,
+// SignedExtraScheduler,
+// SelfContainedSignedInfo,
+// > {
+// signed:
+// CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(
+// signer.clone().into(),
+// get_signed_extras(signer.into()),
+// ),
+// function: call.into(),
+// };
- extrinsic.apply::<Runtime>(&dispatch_info, 0)
- }
+// extrinsic.apply::<Runtime>(&dispatch_info, 0)
+// }
- fn reserve_balance(
- id: [u8; 16],
- sponsor: <T as frame_system::Config>::AccountId,
- call: <T as pallet_unique_scheduler::Config>::Call,
- count: u32,
- ) -> Result<(), DispatchError> {
- let dispatch_info = call.get_dispatch_info();
- let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)
- .saturating_mul(count.into());
+// fn reserve_balance(
+// id: [u8; 16],
+// sponsor: <T as frame_system::Config>::AccountId,
+// call: <T as pallet_unique_scheduler::Config>::Call,
+// count: u32,
+// ) -> Result<(), DispatchError> {
+// let dispatch_info = call.get_dispatch_info();
+// let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)
+// .saturating_mul(count.into());
- <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
- &id,
- &(sponsor.into()),
- weight.into(),
- )
- }
+// <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
+// &id,
+// &(sponsor.into()),
+// weight.into(),
+// )
+// }
- fn pay_for_call(
- id: [u8; 16],
- sponsor: <T as frame_system::Config>::AccountId,
- call: <T as pallet_unique_scheduler::Config>::Call,
- ) -> Result<u128, DispatchError> {
- let dispatch_info = call.get_dispatch_info();
- let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);
- Ok(
- <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
- &id,
- &(sponsor.into()),
- weight.into(),
- ),
- )
- }
+// fn pay_for_call(
+// id: [u8; 16],
+// sponsor: <T as frame_system::Config>::AccountId,
+// call: <T as pallet_unique_scheduler::Config>::Call,
+// ) -> Result<u128, DispatchError> {
+// let dispatch_info = call.get_dispatch_info();
+// let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);
+// Ok(
+// <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
+// &id,
+// &(sponsor.into()),
+// weight.into(),
+// ),
+// )
+// }
- fn cancel_reserve(
- id: [u8; 16],
- sponsor: <T as frame_system::Config>::AccountId,
- ) -> Result<u128, DispatchError> {
- Ok(
- <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
- &id,
- &(sponsor.into()),
- u128::MAX,
- ),
- )
- }
-}
+// fn cancel_reserve(
+// id: [u8; 16],
+// sponsor: <T as frame_system::Config>::AccountId,
+// ) -> Result<u128, DispatchError> {
+// Ok(
+// <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
+// &id,
+// &(sponsor.into()),
+// u128::MAX,
+// ),
+// )
+// }
+// }
parameter_types! {
pub const NoPreimagePostponement: Option<u32> = Some(10);
@@ -1062,21 +1062,21 @@
}
}
-impl pallet_unique_scheduler::Config for Runtime {
- type Event = Event;
- type Origin = Origin;
- type Currency = Balances;
- type PalletsOrigin = OriginCaller;
- type Call = Call;
- type MaximumWeight = MaximumSchedulerWeight;
- type ScheduleOrigin = EnsureSigned<AccountId>;
- type MaxScheduledPerBlock = MaxScheduledPerBlock;
- type WeightInfo = ();
- type CallExecutor = SchedulerPaymentExecutor;
- type OriginPrivilegeCmp = OriginPrivilegeCmp;
- type PreimageProvider = ();
- type NoPreimagePostponement = NoPreimagePostponement;
-}
+// impl pallet_unique_scheduler::Config for Runtime {
+// type Event = Event;
+// type Origin = Origin;
+// type Currency = Balances;
+// type PalletsOrigin = OriginCaller;
+// type Call = Call;
+// type MaximumWeight = MaximumSchedulerWeight;
+// type ScheduleOrigin = EnsureSigned<AccountId>;
+// type MaxScheduledPerBlock = MaxScheduledPerBlock;
+// type WeightInfo = ();
+// type CallExecutor = SchedulerPaymentExecutor;
+// type OriginPrivilegeCmp = OriginPrivilegeCmp;
+// type PreimageProvider = ();
+// type NoPreimagePostponement = NoPreimagePostponement;
+// }
type EvmSponsorshipHandler = (
UniqueEthSponsorshipHandler<Runtime>,
@@ -1150,17 +1150,17 @@
// Unique Pallets
Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
- Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
+ // Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
// free = 63
Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
Fungible: pallet_fungible::{Pallet, Storage} = 67,
- Refungible: pallet_refungible::{Pallet, Storage} = 68,
+ // Refungible: pallet_refungible::{Pallet, Storage} = 68,
Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
- RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
- RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
+ // RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
+ // RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
// Frontier
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
@@ -1323,57 +1323,112 @@
RmrkPartType,
RmrkTheme
> for Runtime {
+
+ // fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {
+ // pallet_proxy_rmrk_core::rpc::last_collection_idx::<Runtime>()
+ // }
+
+ // fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {
+ // pallet_proxy_rmrk_core::rpc::collection_by_id::<Runtime>(collection_id)
+ // }
+
+ // fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {
+ // pallet_proxy_rmrk_core::rpc::nft_by_id::<Runtime>(collection_id, nft_by_id)
+ // }
+
+ // fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {
+ // pallet_proxy_rmrk_core::rpc::account_tokens::<Runtime>(account_id, collection_id)
+ // }
+
+ // fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {
+ // pallet_proxy_rmrk_core::rpc::nft_children::<Runtime>(collection_id, nft_id)
+ // }
+
+ // fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
+ // pallet_proxy_rmrk_core::rpc::collection_properties::<Runtime>(collection_id, filter_keys)
+ // }
+
+ // fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
+ // pallet_proxy_rmrk_core::rpc::nft_properties::<Runtime>(collection_id, nft_id, filter_keys)
+ // }
+
+ // fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {
+ // pallet_proxy_rmrk_core::rpc::nft_resources::<Runtime>(collection_id, nft_id)
+ // }
+
+ // fn nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {
+ // pallet_proxy_rmrk_core::rpc::nft_resource_priority::<Runtime>(collection_id, nft_id, resource_id)
+ // }
+
+ // fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {
+ // pallet_proxy_rmrk_equip::rpc::base::<Runtime>(base_id)
+ // }
+
+ // fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
+ // pallet_proxy_rmrk_equip::rpc::base_parts::<Runtime>(base_id)
+ // }
+
+ // fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {
+ // pallet_proxy_rmrk_equip::rpc::theme_names::<Runtime>(base_id)
+ // }
+
+ // fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {
+ // pallet_proxy_rmrk_equip::rpc::theme::<Runtime>(base_id, theme_name, filter_keys)
+ // }
+
fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {
- pallet_proxy_rmrk_core::rpc::last_collection_idx::<Runtime>()
+ Ok(Default::default())
}
- fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {
- pallet_proxy_rmrk_core::rpc::collection_by_id::<Runtime>(collection_id)
+ fn collection_by_id(_collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {
+ Ok(Default::default())
}
- fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {
- pallet_proxy_rmrk_core::rpc::nft_by_id::<Runtime>(collection_id, nft_by_id)
+ fn nft_by_id(_collection_id: RmrkCollectionId, _nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {
+ Ok(Default::default())
}
- fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {
- pallet_proxy_rmrk_core::rpc::account_tokens::<Runtime>(account_id, collection_id)
+ fn account_tokens(_account_id: AccountId, _collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {
+ Ok(Default::default())
}
- fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {
- pallet_proxy_rmrk_core::rpc::nft_children::<Runtime>(collection_id, nft_id)
+ fn nft_children(_collection_id: RmrkCollectionId, _nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {
+ Ok(Default::default())
}
- fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
- pallet_proxy_rmrk_core::rpc::collection_properties::<Runtime>(collection_id, filter_keys)
+ fn collection_properties(_collection_id: RmrkCollectionId, _filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
+ Ok(Default::default())
}
- fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
- pallet_proxy_rmrk_core::rpc::nft_properties::<Runtime>(collection_id, nft_id, filter_keys)
+ fn nft_properties(_collection_id: RmrkCollectionId, _nft_id: RmrkNftId, _filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
+ Ok(Default::default())
}
- fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {
- pallet_proxy_rmrk_core::rpc::nft_resources::<Runtime>(collection_id, nft_id)
+ fn nft_resources(_collection_id: RmrkCollectionId, _nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {
+ Ok(Default::default())
}
- fn nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {
- pallet_proxy_rmrk_core::rpc::nft_resource_priority::<Runtime>(collection_id, nft_id, resource_id)
+ fn nft_resource_priority(_collection_id: RmrkCollectionId, _nft_id: RmrkNftId, _resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {
+ Ok(Default::default())
}
- fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {
- pallet_proxy_rmrk_equip::rpc::base::<Runtime>(base_id)
+ fn base(_base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {
+ Ok(Default::default())
}
- fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
- pallet_proxy_rmrk_equip::rpc::base_parts::<Runtime>(base_id)
+ fn base_parts(_base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
+ Ok(Default::default())
}
- fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {
- pallet_proxy_rmrk_equip::rpc::theme_names::<Runtime>(base_id)
+ fn theme_names(_base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {
+ Ok(Default::default())
}
- fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {
- pallet_proxy_rmrk_equip::rpc::theme::<Runtime>(base_id, theme_name, filter_keys)
+ fn theme(_base_id: RmrkBaseId, _theme_name: RmrkThemeName, _filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {
+ Ok(Default::default())
}
+
+
}
}
runtime/unique/src/lib.rsdiffbeforeafterboth--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -901,9 +901,11 @@
impl pallet_fungible::Config for Runtime {
type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;
}
+
impl pallet_refungible::Config for Runtime {
type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;
}
+
impl pallet_nonfungible::Config for Runtime {
type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
}
@@ -950,92 +952,92 @@
)
}
-pub struct SchedulerPaymentExecutor;
-impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>
- DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
-where
- <T as frame_system::Config>::Call: Member
- + Dispatchable<Origin = Origin, Info = DispatchInfo>
- + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
- + GetDispatchInfo
- + From<frame_system::Call<Runtime>>,
- SelfContainedSignedInfo: Send + Sync + 'static,
- Call: From<<T as frame_system::Config>::Call>
- + From<<T as pallet_unique_scheduler::Config>::Call>
- + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,
- sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,
-{
- fn dispatch_call(
- signer: <T as frame_system::Config>::AccountId,
- call: <T as pallet_unique_scheduler::Config>::Call,
- ) -> Result<
- Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,
- TransactionValidityError,
- > {
- let dispatch_info = call.get_dispatch_info();
- let extrinsic = fp_self_contained::CheckedExtrinsic::<
- AccountId,
- Call,
- SignedExtraScheduler,
- SelfContainedSignedInfo,
- > {
- signed:
- CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(
- signer.clone().into(),
- get_signed_extras(signer.into()),
- ),
- function: call.into(),
- };
+// pub struct SchedulerPaymentExecutor;
+// impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>
+// DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
+// where
+// <T as frame_system::Config>::Call: Member
+// + Dispatchable<Origin = Origin, Info = DispatchInfo>
+// + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
+// + GetDispatchInfo
+// + From<frame_system::Call<Runtime>>,
+// SelfContainedSignedInfo: Send + Sync + 'static,
+// Call: From<<T as frame_system::Config>::Call>
+// + From<<T as pallet_unique_scheduler::Config>::Call>
+// + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,
+// sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,
+// {
+// fn dispatch_call(
+// signer: <T as frame_system::Config>::AccountId,
+// call: <T as pallet_unique_scheduler::Config>::Call,
+// ) -> Result<
+// Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,
+// TransactionValidityError,
+// > {
+// let dispatch_info = call.get_dispatch_info();
+// let extrinsic = fp_self_contained::CheckedExtrinsic::<
+// AccountId,
+// Call,
+// SignedExtraScheduler,
+// SelfContainedSignedInfo,
+// > {
+// signed:
+// CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(
+// signer.clone().into(),
+// get_signed_extras(signer.into()),
+// ),
+// function: call.into(),
+// };
- extrinsic.apply::<Runtime>(&dispatch_info, 0)
- }
+// extrinsic.apply::<Runtime>(&dispatch_info, 0)
+// }
- fn reserve_balance(
- id: [u8; 16],
- sponsor: <T as frame_system::Config>::AccountId,
- call: <T as pallet_unique_scheduler::Config>::Call,
- count: u32,
- ) -> Result<(), DispatchError> {
- let dispatch_info = call.get_dispatch_info();
- let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)
- .saturating_mul(count.into());
+// fn reserve_balance(
+// id: [u8; 16],
+// sponsor: <T as frame_system::Config>::AccountId,
+// call: <T as pallet_unique_scheduler::Config>::Call,
+// count: u32,
+// ) -> Result<(), DispatchError> {
+// let dispatch_info = call.get_dispatch_info();
+// let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)
+// .saturating_mul(count.into());
- <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
- &id,
- &(sponsor.into()),
- weight,
- )
- }
+// <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
+// &id,
+// &(sponsor.into()),
+// weight,
+// )
+// }
- fn pay_for_call(
- id: [u8; 16],
- sponsor: <T as frame_system::Config>::AccountId,
- call: <T as pallet_unique_scheduler::Config>::Call,
- ) -> Result<u128, DispatchError> {
- let dispatch_info = call.get_dispatch_info();
- let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);
- Ok(
- <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
- &id,
- &(sponsor.into()),
- weight,
- ),
- )
- }
+// fn pay_for_call(
+// id: [u8; 16],
+// sponsor: <T as frame_system::Config>::AccountId,
+// call: <T as pallet_unique_scheduler::Config>::Call,
+// ) -> Result<u128, DispatchError> {
+// let dispatch_info = call.get_dispatch_info();
+// let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);
+// Ok(
+// <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
+// &id,
+// &(sponsor.into()),
+// weight,
+// ),
+// )
+// }
- fn cancel_reserve(
- id: [u8; 16],
- sponsor: <T as frame_system::Config>::AccountId,
- ) -> Result<u128, DispatchError> {
- Ok(
- <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
- &id,
- &(sponsor.into()),
- u128::MAX,
- ),
- )
- }
-}
+// fn cancel_reserve(
+// id: [u8; 16],
+// sponsor: <T as frame_system::Config>::AccountId,
+// ) -> Result<u128, DispatchError> {
+// Ok(
+// <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
+// &id,
+// &(sponsor.into()),
+// u128::MAX,
+// ),
+// )
+// }
+// }
parameter_types! {
pub const NoPreimagePostponement: Option<u32> = Some(10);
@@ -1051,21 +1053,21 @@
}
}
-impl pallet_unique_scheduler::Config for Runtime {
- type Event = Event;
- type Origin = Origin;
- type Currency = Balances;
- type PalletsOrigin = OriginCaller;
- type Call = Call;
- type MaximumWeight = MaximumSchedulerWeight;
- type ScheduleOrigin = EnsureSigned<AccountId>;
- type MaxScheduledPerBlock = MaxScheduledPerBlock;
- type WeightInfo = ();
- type CallExecutor = SchedulerPaymentExecutor;
- type OriginPrivilegeCmp = OriginPrivilegeCmp;
- type PreimageProvider = ();
- type NoPreimagePostponement = NoPreimagePostponement;
-}
+// impl pallet_unique_scheduler::Config for Runtime {
+// type Event = Event;
+// type Origin = Origin;
+// type Currency = Balances;
+// type PalletsOrigin = OriginCaller;
+// type Call = Call;
+// type MaximumWeight = MaximumSchedulerWeight;
+// type ScheduleOrigin = EnsureSigned<AccountId>;
+// type MaxScheduledPerBlock = MaxScheduledPerBlock;
+// type WeightInfo = ();
+// type CallExecutor = SchedulerPaymentExecutor;
+// type OriginPrivilegeCmp = OriginPrivilegeCmp;
+// type PreimageProvider = ();
+// type NoPreimagePostponement = NoPreimagePostponement;
+// }
type EvmSponsorshipHandler = (
UniqueEthSponsorshipHandler<Runtime>,
@@ -1139,13 +1141,13 @@
// Unique Pallets
Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
- Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
+ // Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
// free = 63
Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
Fungible: pallet_fungible::{Pallet, Storage} = 67,
- Refungible: pallet_refungible::{Pallet, Storage} = 68,
+ // Refungible: pallet_refungible::{Pallet, Storage} = 68,
Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
tests/src/refungible.test.tsdiffbeforeafterboth--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -36,6 +36,8 @@
CrossAccountId,
getCreateItemsResult,
getDestroyItemsResult,
+ getModuleNames,
+ Pallets,
} from './util/helpers';
import chai from 'chai';
@@ -46,14 +48,18 @@
let alice: IKeyringPair;
let bob: IKeyringPair;
-describe('integration test: Refungible functionality:', () => {
- before(async () => {
+
+
+describe('integration test: Refungible functionality:', async () => {
+ before(async function() {
await usingApi(async (api, privateKeyWrapper) => {
alice = privateKeyWrapper('//Alice');
bob = privateKeyWrapper('//Bob');
+ if (!getModuleNames(api).includes(Pallets.ReFungible)) this.skip();
});
+
});
-
+
it('Create refungible collection and token', async () => {
await usingApi(async api => {
const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});
@@ -268,15 +274,6 @@
]);
});
});
-});
-
-describe('Test Refungible properties:', () => {
- before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
- alice = privateKeyWrapper('//Alice');
- bob = privateKeyWrapper('//Bob');
- });
- });
it('Сreate new collection with properties', async () => {
await usingApi(async api => {
@@ -292,3 +289,4 @@
});
});
});
+
tests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/acceptNft.test.ts
+++ b/tests/src/rmrk/acceptNft.test.ts
@@ -8,14 +8,19 @@
} from './util/tx';
import {NftIdTuple} from './util/fetch';
import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
+import { getModuleNames, Pallets } from '../util/helpers';
describe('integration test: accept NFT', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
-
+ before(async function() {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
+
+
const alice = '//Alice';
const bob = '//Bob';
-
+
const createTestCollection = async (issuerUri: string) => {
return await createCollection(
api,
tests/src/rmrk/addResource.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/addResource.test.ts
+++ b/tests/src/rmrk/addResource.test.ts
@@ -12,6 +12,7 @@
addNftComposableResource,
} from './util/tx';
import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';
+import { getModuleNames, Pallets } from '../util/helpers';
describe('integration test: add NFT resource', () => {
const Alice = '//Alice';
@@ -24,8 +25,9 @@
const nonexistentId = 99999;
let api: any;
- before(async () => {
+ before(async function() {
api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
});
it('add resource', async () => {
tests/src/rmrk/addTheme.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/addTheme.test.ts
+++ b/tests/src/rmrk/addTheme.test.ts
@@ -3,10 +3,14 @@
import {createBase, addTheme} from './util/tx';
import {expectTxFailure} from './util/helpers';
import {getThemeNames} from './util/fetch';
+import { getModuleNames, Pallets } from '../util/helpers';
describe('integration test: add Theme to Base', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+ before(async function() {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
const alice = '//Alice';
const bob = '//Bob';
tests/src/rmrk/burnNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/burnNft.test.ts
+++ b/tests/src/rmrk/burnNft.test.ts
@@ -5,6 +5,7 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
+import { getModuleNames, Pallets } from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -14,10 +15,12 @@
const Bob = '//Bob';
let api: any;
- before(async () => {
+ before(async function() {
api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
});
+
it('burn nft', async () => {
await createCollection(
api,
tests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/changeCollectionIssuer.test.ts
+++ b/tests/src/rmrk/changeCollectionIssuer.test.ts
@@ -1,4 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {
changeIssuer,
@@ -10,10 +11,13 @@
const Bob = '//Bob';
let api: any;
- before(async () => {
+ before(async function() {
api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
});
+
+
it('change collection issuer', async () => {
await createCollection(
api,
tests/src/rmrk/createBase.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/createBase.test.ts
+++ b/tests/src/rmrk/createBase.test.ts
@@ -1,9 +1,13 @@
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {createCollection, createBase} from './util/tx';
describe('integration test: create new Base', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+ before(async function() {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
const alice = '//Alice';
tests/src/rmrk/createCollection.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/createCollection.test.ts
+++ b/tests/src/rmrk/createCollection.test.ts
@@ -1,9 +1,15 @@
import {getApiConnection} from '../substrate/substrate-api';
+import {getModuleNames, Pallets} from '../util/helpers';
import {createCollection} from './util/tx';
describe('Integration test: create new collection', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+ before(async function () {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
+
+
const alice = '//Alice';
tests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/deleteCollection.test.ts
+++ b/tests/src/rmrk/deleteCollection.test.ts
@@ -1,11 +1,13 @@
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, deleteCollection} from './util/tx';
describe('integration test: delete collection', () => {
let api: any;
- before(async () => {
+ before(async function () {
api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
});
const Alice = '//Alice';
tests/src/rmrk/equipNft.test.tsdiffbeforeafterboth1import {ApiPromise} from '@polkadot/api';2import {expect} from 'chai';3import {getApiConnection} from '../substrate/substrate-api';4import {getNft, getParts, NftIdTuple} from './util/fetch';5import {expectTxFailure} from './util/helpers';6import {7 addNftComposableResource,8 addNftSlotResource,9 createBase,10 createCollection,11 equipNft,12 mintNft,13 sendNft,14 unequipNft,15} from './util/tx';1617const Alice = '//Alice';18const Bob = '//Bob';1920const composableParts: number[] = [5, 2, 7];21const composableSrc = 'test-cmp-src';22const composableMetadata = 'test-cmp-metadata';23const composableLicense = 'test-comp-license';24const composableThumb = 'test-comp-thumb';2526const slotSrc = 'test-slot-src';27const slotLicense = 'test-slot-license';28const slotMetadata = 'test-slot-metadata';29const slotThumb = 'test-slot-thumb';3031const slotId = 1;3233async function createTestCollection(api: ApiPromise): Promise<number> {34 return createCollection(35 api,36 Alice,37 'test-metadata',38 null,39 'test-symbol',40 );41}4243async function mintTestNft(api: ApiPromise, collectionId: number): Promise<number> {44 return await mintNft(45 api,46 Alice,47 Alice,48 collectionId,49 'nft-metadata',50 );51}5253async function mintChildNft(api: ApiPromise, collectionId: number, parentNftId: number): Promise<number> {54 const nftChildId = await mintTestNft(api, collectionId);5556 const parentNFT: NftIdTuple = [collectionId, parentNftId];5758 await sendNft(api, 'sent', Alice, collectionId, nftChildId, parentNFT);5960 return nftChildId;61}6263async function createTestBase(api: ApiPromise): Promise<number> {64 return createBase(api, Alice, 'test-base', 'DTBase', [65 {66 SlotPart: {67 id: slotId,68 equippable: 'All',69 z: 1,70 src: slotSrc,71 },72 },73 ]);74}7576async function addTestComposable(api: ApiPromise, collectionId: number, nftId: number, baseId: number) {77 await addNftComposableResource(78 api,79 Alice,80 'added',81 collectionId,82 nftId,83 composableParts,84 baseId,85 composableSrc,86 composableMetadata,87 composableLicense,88 composableThumb,89 );90}9192async function addTestSlot(api: ApiPromise, collectionId: number, nftId: number, baseId: number, slotId: number): Promise<number> {93 return await addNftSlotResource(94 api,95 Alice,96 'added',97 collectionId,98 nftId,99 baseId,100 slotId,101 slotSrc,102 slotMetadata,103 slotLicense,104 slotThumb,105 );106}107108async function checkEquipStatus(109 api: ApiPromise,110 expectedStatus: 'equipped' | 'unequipped',111 collectionId: number,112 nftId: number,113) {114 const itemNftDataOpt = await getNft(api, collectionId, nftId);115 expect(itemNftDataOpt.isSome, 'Error: unable to fetch item NFT data');116117 const itemNftData = itemNftDataOpt.unwrap();118 expect(itemNftData.equipped.isTrue, `Error: item NFT should be ${expectedStatus}`)119 .to.be.equal(expectedStatus === 'equipped');120}121122describe.skip('integration test: Equip NFT', () => {123124 let api: any;125 before(async () => {126 api = await getApiConnection();127 });128129 it('equip nft', async () => {130 const collectionId = await createTestCollection(api);131 const nftParentId = await mintTestNft(api, collectionId);132 const nftChildId = await mintChildNft(api, collectionId, nftParentId);133134 const baseId = await createTestBase(api);135136 await addTestComposable(api, collectionId, nftParentId, baseId);137 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);138139 const equipperNFT: NftIdTuple = [collectionId, nftParentId];140 const itemNFT: NftIdTuple = [collectionId, nftChildId];141142 await equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);143144 await checkEquipStatus(api, 'equipped', collectionId, nftChildId);145 });146147 it('unequip nft', async () => {148 const collectionId = await createTestCollection(api);149 const nftParentId = await mintTestNft(api, collectionId);150 const nftChildId = await mintChildNft(api, collectionId, nftParentId);151152 const baseId = await createTestBase(api);153154 await addTestComposable(api, collectionId, nftParentId, baseId);155 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);156157 const equipperNFT: NftIdTuple = [collectionId, nftParentId];158 const itemNFT: NftIdTuple = [collectionId, nftChildId];159160 await equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);161162 await checkEquipStatus(api, 'equipped', collectionId, nftChildId);163164 await unequipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);165 await checkEquipStatus(api, 'unequipped', collectionId, nftChildId);166 });167168 it('[negative] equip NFT onto non-existing NFT', async () => {169 const collectionId = await createTestCollection(api);170171 const nftChildId = await mintNft(172 api,173 Alice,174 Alice,175 collectionId,176 'nft-metadata',177 );178179 const itemNFT: NftIdTuple = [collectionId, nftChildId];180 const invalidEquipperNFT: NftIdTuple = [collectionId, 9999999];181182 const baseId = 0;183 const resourceId = 0;184185 const tx = equipNft(api, Alice, itemNFT, invalidEquipperNFT, resourceId, baseId, slotId);186 await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);187 });188189 it('[negative] equip non-existing NFT', async () => {190 const collectionId = await createTestCollection(api);191 const nftParentId = await mintNft(192 api,193 Alice,194 Alice,195 collectionId,196 'nft-metadata',197 );198199 const baseId = await createTestBase(api);200201 await addTestComposable(api, collectionId, nftParentId, baseId);202203 const equipperNFT: NftIdTuple = [collectionId, nftParentId];204 const invalidItemNFT: NftIdTuple = [collectionId, 99999999];205206 const resourceId = 0;207208 const tx = equipNft(api, Alice, invalidItemNFT, equipperNFT, resourceId, baseId, slotId);209 await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);210 });211212 it('[negative] equip NFT by a not-an-owner user', async () => {213 const collectionId = await createTestCollection(api);214 const nftParentId = await mintTestNft(api, collectionId);215 const nftChildId = await mintChildNft(api, collectionId, nftParentId);216217 const baseId = await createTestBase(api);218219 await addTestComposable(api, collectionId, nftParentId, baseId);220221 const equipperNFT: NftIdTuple = [collectionId, nftParentId];222 const itemNFT: NftIdTuple = [collectionId, nftChildId];223224 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);225226 const tx = equipNft(api, Bob, itemNFT, equipperNFT, resourceId, baseId, slotId);227 await expectTxFailure(/rmrkEquip\.PermissionError/, tx);228 });229230 it('[negative] unable to equip NFT onto indirect parent NFT', async () => {231 const collectionId = await createTestCollection(api);232 const nftParentId = await mintTestNft(api, collectionId);233 const nftChildId = await mintChildNft(api, collectionId, nftParentId);234 const nftGrandchildId = await mintChildNft(api, collectionId, nftChildId);235236 const baseId = await createTestBase(api);237238 await addTestComposable(api, collectionId, nftParentId, baseId);239 const resourceId = await addTestSlot(api, collectionId, nftGrandchildId, baseId, slotId);240241 const equipperNFT: NftIdTuple = [collectionId, nftParentId];242 const itemNFT: NftIdTuple = [collectionId, nftGrandchildId];243244 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);245 await expectTxFailure(/rmrkEquip\.MustBeDirectParent/, tx);246 });247248 it('[negative] unable to equip NFT onto parent NFT with another base', async () => {249 const collectionId = await createTestCollection(api);250 const nftParentId = await mintTestNft(api, collectionId);251 const nftChildId = await mintChildNft(api, collectionId, nftParentId);252253 const baseId = await createTestBase(api);254255 await addTestComposable(api, collectionId, nftParentId, baseId);256 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);257258 const equipperNFT: NftIdTuple = [collectionId, nftParentId];259 const itemNFT: NftIdTuple = [collectionId, nftChildId];260261 const invalidBaseId = 99999;262263 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, invalidBaseId, slotId);264 await expectTxFailure(/rmrkEquip\.NoResourceForThisBaseFoundOnNft/, tx);265 });266267 it('[negative] unable to equip NFT into slot with another id', async () => {268 const collectionId = await createTestCollection(api);269 const nftParentId = await mintTestNft(api, collectionId);270 const nftChildId = await mintChildNft(api, collectionId, nftParentId);271272 const baseId = await createTestBase(api);273274 await addTestComposable(api, collectionId, nftParentId, baseId);275 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);276277 const equipperNFT: NftIdTuple = [collectionId, nftParentId];278 const itemNFT: NftIdTuple = [collectionId, nftChildId];279280 const incorrectSlotId = slotId + 1;281 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, incorrectSlotId);282 await expectTxFailure(/rmrkEquip\.ItemHasNoResourceToEquipThere/, tx);283 });284285 it('[negative] unable to equip NFT with incorrect slot (fixed part)', async () => {286 const collectionId = await createTestCollection(api);287 const nftParentId = await mintTestNft(api, collectionId);288 const nftChildId = await mintChildNft(api, collectionId, nftParentId);289290 const baseId = await createBase(api, Alice, 'test-base', 'DTBase', [291 {292 FixedPart: {293 id: slotId,294 equippable: 'All',295 z: 1,296 src: slotSrc,297 },298 },299 ]);300301 await addTestComposable(api, collectionId, nftParentId, baseId);302 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);303304 const equipperNFT: NftIdTuple = [collectionId, nftParentId];305 const itemNFT: NftIdTuple = [collectionId, nftChildId];306307 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);308 await expectTxFailure(/rmrkEquip\.CantEquipFixedPart/, tx);309 });310311 it('[negative] unable to equip NFT from a collection that is not allowed by the slot', async () => {312 const collectionId = await createTestCollection(api);313 const nftParentId = await mintTestNft(api, collectionId);314 const nftChildId = await mintChildNft(api, collectionId, nftParentId);315316 const baseId = await createBase(api, Alice, 'test-base', 'DTBase', [317 {318 SlotPart: {319 id: 1,320 z: 1,321 equippable: 'Empty',322 src: slotSrc,323 },324 },325 ]);326327 await addTestComposable(api, collectionId, nftParentId, baseId);328 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);329330 const equipperNFT: NftIdTuple = [collectionId, nftParentId];331 const itemNFT: NftIdTuple = [collectionId, nftChildId];332333 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);334 await expectTxFailure(/rmrkEquip\.CollectionNotEquippable/, tx);335 });336337 after(() => {338 api.disconnect();339 });340});1import {ApiPromise} from '@polkadot/api';2import {expect} from 'chai';3import {getApiConnection} from '../substrate/substrate-api';4import {getModuleNames, Pallets} from '../util/helpers';5import {getNft, getParts, NftIdTuple} from './util/fetch';6import {expectTxFailure} from './util/helpers';7import {8 addNftComposableResource,9 addNftSlotResource,10 createBase,11 createCollection,12 equipNft,13 mintNft,14 sendNft,15 unequipNft,16} from './util/tx';1718const Alice = '//Alice';19const Bob = '//Bob';2021const composableParts: number[] = [5, 2, 7];22const composableSrc = 'test-cmp-src';23const composableMetadata = 'test-cmp-metadata';24const composableLicense = 'test-comp-license';25const composableThumb = 'test-comp-thumb';2627const slotSrc = 'test-slot-src';28const slotLicense = 'test-slot-license';29const slotMetadata = 'test-slot-metadata';30const slotThumb = 'test-slot-thumb';3132const slotId = 1;3334async function createTestCollection(api: ApiPromise): Promise<number> {35 return createCollection(36 api,37 Alice,38 'test-metadata',39 null,40 'test-symbol',41 );42}4344async function mintTestNft(api: ApiPromise, collectionId: number): Promise<number> {45 return await mintNft(46 api,47 Alice,48 Alice,49 collectionId,50 'nft-metadata',51 );52}5354async function mintChildNft(api: ApiPromise, collectionId: number, parentNftId: number): Promise<number> {55 const nftChildId = await mintTestNft(api, collectionId);5657 const parentNFT: NftIdTuple = [collectionId, parentNftId];5859 await sendNft(api, 'sent', Alice, collectionId, nftChildId, parentNFT);6061 return nftChildId;62}6364async function createTestBase(api: ApiPromise): Promise<number> {65 return createBase(api, Alice, 'test-base', 'DTBase', [66 {67 SlotPart: {68 id: slotId,69 equippable: 'All',70 z: 1,71 src: slotSrc,72 },73 },74 ]);75}7677async function addTestComposable(api: ApiPromise, collectionId: number, nftId: number, baseId: number) {78 await addNftComposableResource(79 api,80 Alice,81 'added',82 collectionId,83 nftId,84 composableParts,85 baseId,86 composableSrc,87 composableMetadata,88 composableLicense,89 composableThumb,90 );91}9293async function addTestSlot(api: ApiPromise, collectionId: number, nftId: number, baseId: number, slotId: number): Promise<number> {94 return await addNftSlotResource(95 api,96 Alice,97 'added',98 collectionId,99 nftId,100 baseId,101 slotId,102 slotSrc,103 slotMetadata,104 slotLicense,105 slotThumb,106 );107}108109async function checkEquipStatus(110 api: ApiPromise,111 expectedStatus: 'equipped' | 'unequipped',112 collectionId: number,113 nftId: number,114) {115 const itemNftDataOpt = await getNft(api, collectionId, nftId);116 expect(itemNftDataOpt.isSome, 'Error: unable to fetch item NFT data');117118 const itemNftData = itemNftDataOpt.unwrap();119 expect(itemNftData.equipped.isTrue, `Error: item NFT should be ${expectedStatus}`)120 .to.be.equal(expectedStatus === 'equipped');121}122123describe.skip('integration test: Equip NFT', () => {124125 let api: any;126 127 before(async function () {128 api = await getApiConnection();129 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();130 });131132 it('equip nft', async () => {133 const collectionId = await createTestCollection(api);134 const nftParentId = await mintTestNft(api, collectionId);135 const nftChildId = await mintChildNft(api, collectionId, nftParentId);136137 const baseId = await createTestBase(api);138139 await addTestComposable(api, collectionId, nftParentId, baseId);140 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);141142 const equipperNFT: NftIdTuple = [collectionId, nftParentId];143 const itemNFT: NftIdTuple = [collectionId, nftChildId];144145 await equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);146147 await checkEquipStatus(api, 'equipped', collectionId, nftChildId);148 });149150 it('unequip nft', async () => {151 const collectionId = await createTestCollection(api);152 const nftParentId = await mintTestNft(api, collectionId);153 const nftChildId = await mintChildNft(api, collectionId, nftParentId);154155 const baseId = await createTestBase(api);156157 await addTestComposable(api, collectionId, nftParentId, baseId);158 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);159160 const equipperNFT: NftIdTuple = [collectionId, nftParentId];161 const itemNFT: NftIdTuple = [collectionId, nftChildId];162163 await equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);164165 await checkEquipStatus(api, 'equipped', collectionId, nftChildId);166167 await unequipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);168 await checkEquipStatus(api, 'unequipped', collectionId, nftChildId);169 });170171 it('[negative] equip NFT onto non-existing NFT', async () => {172 const collectionId = await createTestCollection(api);173174 const nftChildId = await mintNft(175 api,176 Alice,177 Alice,178 collectionId,179 'nft-metadata',180 );181182 const itemNFT: NftIdTuple = [collectionId, nftChildId];183 const invalidEquipperNFT: NftIdTuple = [collectionId, 9999999];184185 const baseId = 0;186 const resourceId = 0;187188 const tx = equipNft(api, Alice, itemNFT, invalidEquipperNFT, resourceId, baseId, slotId);189 await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);190 });191192 it('[negative] equip non-existing NFT', async () => {193 const collectionId = await createTestCollection(api);194 const nftParentId = await mintNft(195 api,196 Alice,197 Alice,198 collectionId,199 'nft-metadata',200 );201202 const baseId = await createTestBase(api);203204 await addTestComposable(api, collectionId, nftParentId, baseId);205206 const equipperNFT: NftIdTuple = [collectionId, nftParentId];207 const invalidItemNFT: NftIdTuple = [collectionId, 99999999];208209 const resourceId = 0;210211 const tx = equipNft(api, Alice, invalidItemNFT, equipperNFT, resourceId, baseId, slotId);212 await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);213 });214215 it('[negative] equip NFT by a not-an-owner user', async () => {216 const collectionId = await createTestCollection(api);217 const nftParentId = await mintTestNft(api, collectionId);218 const nftChildId = await mintChildNft(api, collectionId, nftParentId);219220 const baseId = await createTestBase(api);221222 await addTestComposable(api, collectionId, nftParentId, baseId);223224 const equipperNFT: NftIdTuple = [collectionId, nftParentId];225 const itemNFT: NftIdTuple = [collectionId, nftChildId];226227 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);228229 const tx = equipNft(api, Bob, itemNFT, equipperNFT, resourceId, baseId, slotId);230 await expectTxFailure(/rmrkEquip\.PermissionError/, tx);231 });232233 it('[negative] unable to equip NFT onto indirect parent NFT', async () => {234 const collectionId = await createTestCollection(api);235 const nftParentId = await mintTestNft(api, collectionId);236 const nftChildId = await mintChildNft(api, collectionId, nftParentId);237 const nftGrandchildId = await mintChildNft(api, collectionId, nftChildId);238239 const baseId = await createTestBase(api);240241 await addTestComposable(api, collectionId, nftParentId, baseId);242 const resourceId = await addTestSlot(api, collectionId, nftGrandchildId, baseId, slotId);243244 const equipperNFT: NftIdTuple = [collectionId, nftParentId];245 const itemNFT: NftIdTuple = [collectionId, nftGrandchildId];246247 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);248 await expectTxFailure(/rmrkEquip\.MustBeDirectParent/, tx);249 });250251 it('[negative] unable to equip NFT onto parent NFT with another base', async () => {252 const collectionId = await createTestCollection(api);253 const nftParentId = await mintTestNft(api, collectionId);254 const nftChildId = await mintChildNft(api, collectionId, nftParentId);255256 const baseId = await createTestBase(api);257258 await addTestComposable(api, collectionId, nftParentId, baseId);259 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);260261 const equipperNFT: NftIdTuple = [collectionId, nftParentId];262 const itemNFT: NftIdTuple = [collectionId, nftChildId];263264 const invalidBaseId = 99999;265266 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, invalidBaseId, slotId);267 await expectTxFailure(/rmrkEquip\.NoResourceForThisBaseFoundOnNft/, tx);268 });269270 it('[negative] unable to equip NFT into slot with another id', async () => {271 const collectionId = await createTestCollection(api);272 const nftParentId = await mintTestNft(api, collectionId);273 const nftChildId = await mintChildNft(api, collectionId, nftParentId);274275 const baseId = await createTestBase(api);276277 await addTestComposable(api, collectionId, nftParentId, baseId);278 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);279280 const equipperNFT: NftIdTuple = [collectionId, nftParentId];281 const itemNFT: NftIdTuple = [collectionId, nftChildId];282283 const incorrectSlotId = slotId + 1;284 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, incorrectSlotId);285 await expectTxFailure(/rmrkEquip\.ItemHasNoResourceToEquipThere/, tx);286 });287288 it('[negative] unable to equip NFT with incorrect slot (fixed part)', async () => {289 const collectionId = await createTestCollection(api);290 const nftParentId = await mintTestNft(api, collectionId);291 const nftChildId = await mintChildNft(api, collectionId, nftParentId);292293 const baseId = await createBase(api, Alice, 'test-base', 'DTBase', [294 {295 FixedPart: {296 id: slotId,297 equippable: 'All',298 z: 1,299 src: slotSrc,300 },301 },302 ]);303304 await addTestComposable(api, collectionId, nftParentId, baseId);305 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);306307 const equipperNFT: NftIdTuple = [collectionId, nftParentId];308 const itemNFT: NftIdTuple = [collectionId, nftChildId];309310 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);311 await expectTxFailure(/rmrkEquip\.CantEquipFixedPart/, tx);312 });313314 it('[negative] unable to equip NFT from a collection that is not allowed by the slot', async () => {315 const collectionId = await createTestCollection(api);316 const nftParentId = await mintTestNft(api, collectionId);317 const nftChildId = await mintChildNft(api, collectionId, nftParentId);318319 const baseId = await createBase(api, Alice, 'test-base', 'DTBase', [320 {321 SlotPart: {322 id: 1,323 z: 1,324 equippable: 'Empty',325 src: slotSrc,326 },327 },328 ]);329330 await addTestComposable(api, collectionId, nftParentId, baseId);331 const resourceId = await addTestSlot(api, collectionId, nftChildId, baseId, slotId);332333 const equipperNFT: NftIdTuple = [collectionId, nftParentId];334 const itemNFT: NftIdTuple = [collectionId, nftChildId];335336 const tx = equipNft(api, Alice, itemNFT, equipperNFT, resourceId, baseId, slotId);337 await expectTxFailure(/rmrkEquip\.CollectionNotEquippable/, tx);338 });339340 after(() => {341 api.disconnect();342 });343});tests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/getOwnedNfts.test.ts
+++ b/tests/src/rmrk/getOwnedNfts.test.ts
@@ -1,11 +1,17 @@
import {expect} from 'chai';
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {getOwnedNfts} from './util/fetch';
import {mintNft, createCollection} from './util/tx';
describe('integration test: get owned NFTs', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+
+ before(async function () {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
+
const alice = '//Alice';
tests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/lockCollection.test.ts
+++ b/tests/src/rmrk/lockCollection.test.ts
@@ -1,4 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, lockCollection, mintNft} from './util/tx';
@@ -8,8 +9,9 @@
const Max = 5;
let api: any;
- before(async () => {
+ before(async function () {
api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
});
it('lock collection', async () => {
tests/src/rmrk/mintNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/mintNft.test.ts
+++ b/tests/src/rmrk/mintNft.test.ts
@@ -1,12 +1,18 @@
import {expect} from 'chai';
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {getNft} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {createCollection, mintNft} from './util/tx';
describe('integration test: mint new NFT', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+
+ before(async function () {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
+
const alice = '//Alice';
const bob = '//Bob';
tests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/rejectNft.test.ts
+++ b/tests/src/rmrk/rejectNft.test.ts
@@ -8,10 +8,16 @@
} from './util/tx';
import {getChildren, NftIdTuple} from './util/fetch';
import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
+import { getModuleNames, Pallets } from '../util/helpers';
describe('integration test: reject NFT', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+ before(async function () {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
+
+
const alice = '//Alice';
const bob = '//Bob';
tests/src/rmrk/removeResource.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/removeResource.test.ts
+++ b/tests/src/rmrk/removeResource.test.ts
@@ -1,6 +1,7 @@
import {expect} from 'chai';
import privateKey from '../substrate/privateKey';
import {executeTransaction, getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {getNft, NftIdTuple} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {
@@ -16,9 +17,10 @@
describe('Integration test: remove nft resource', () => {
let api: any;
let ss58Format: string;
- before(async () => {
+ before(async function() {
api = await getApiConnection();
ss58Format = api.registry.getChainProperties()!.toJSON().ss58Format;
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
});
const Alice = '//Alice';
tests/src/rmrk/rmrkIsolation.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/rmrkIsolation.test.ts
+++ b/tests/src/rmrk/rmrkIsolation.test.ts
@@ -6,7 +6,9 @@
getCreateCollectionResult,
getDetailedCollectionInfo,
getGenericResult,
+ getModuleNames,
normalizeAccountId,
+ Pallets,
} from '../util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
import {ApiPromise} from '@polkadot/api';
@@ -59,11 +61,10 @@
describe('RMRK External Integration Test', async () => {
const it_rmrk = (await isUnique() ? it : it.skip);
- before(async () => {
+ before(async function() {
await usingApi(async (api, privateKeyWrapper) => {
alice = privateKeyWrapper('//Alice');
-
-
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
});
});
tests/src/rmrk/sendNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/sendNft.test.ts
+++ b/tests/src/rmrk/sendNft.test.ts
@@ -3,10 +3,14 @@
import {createCollection, mintNft, sendNft} from './util/tx';
import {NftIdTuple} from './util/fetch';
import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
+import { getModuleNames, Pallets } from '../util/helpers';
describe('integration test: send NFT', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+ before(async function () {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
const maxNftId = 0xFFFFFFFF;
tests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setCollectionProperty.test.ts
+++ b/tests/src/rmrk/setCollectionProperty.test.ts
@@ -1,4 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, setPropertyCollection} from './util/tx';
@@ -7,8 +8,9 @@
const Bob = '//Bob';
let api: any;
- before(async () => {
+ before(async function () {
api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
});
it('set collection property', async () => {
tests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setEquippableList.test.ts
+++ b/tests/src/rmrk/setEquippableList.test.ts
@@ -1,10 +1,14 @@
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, createBase, setEquippableList} from './util/tx';
describe("integration test: set slot's Equippable List", () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+ before(async function () {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
const alice = '//Alice';
const bob = '//Bob';
tests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setNftProperty.test.ts
+++ b/tests/src/rmrk/setNftProperty.test.ts
@@ -1,11 +1,15 @@
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {NftIdTuple} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';
describe('integration test: set NFT property', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+ before(async function () {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
const alice = '//Alice';
const bob = '//Bob';
tests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setResourcePriorities.test.ts
+++ b/tests/src/rmrk/setResourcePriorities.test.ts
@@ -1,10 +1,14 @@
import {getApiConnection} from '../substrate/substrate-api';
+import { getModuleNames, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {mintNft, createCollection, setResourcePriorities} from './util/tx';
describe('integration test: set NFT resource priorities', () => {
let api: any;
- before(async () => { api = await getApiConnection(); });
+ before(async function () {
+ api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ });
const alice = '//Alice';
const bob = '//Bob';
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -38,6 +38,38 @@
Ethereum: string,
};
+
+export enum Pallets {
+ Inflation = 'inflation',
+ RmrkCore = 'rmrkcore',
+ ReFungible = 'refungible',
+ Fungible = 'fungible',
+ NFT = 'nonfungible',
+}
+
+export async function isUnique(): Promise<boolean> {
+ return usingApi(async api => {
+ const chain = await api.rpc.system.chain();
+
+ return chain.eq('UNIQUE');
+ });
+}
+
+export async function isQuartz(): Promise<boolean> {
+ return usingApi(async api => {
+ const chain = await api.rpc.system.chain();
+
+ return chain.eq('QUARTZ');
+ });
+}
+
+let modulesNames: any;
+export function getModuleNames(api: ApiPromise): string[] {
+ if (typeof modulesNames === 'undefined')
+ modulesNames = api.runtimeMetadata.asLatest.pallets.map(m => m.name.toString().toLowerCase());
+ return modulesNames;
+}
+
export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {
if (typeof input === 'string') {
if (input.length >= 47) {