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.tsdiffbeforeafterboth1import {expect} from 'chai';2import {getApiConnection} from '../substrate/substrate-api';3import {NftIdTuple} from './util/fetch';4import {expectTxFailure, getResourceById} from './util/helpers';5import {6 addNftBasicResource,7 acceptNftResource,8 createCollection,9 mintNft,10 sendNft,11 addNftSlotResource,12 addNftComposableResource,13} from './util/tx';14import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';1516describe('integration test: add NFT resource', () => {17 const Alice = '//Alice';18 const Bob = '//Bob';19 const src = 'test-res-src';20 const metadata = 'test-res-metadata';21 const license = 'test-res-license';22 const thumb = 'test-res-thumb';2324 const nonexistentId = 99999;2526 let api: any;27 before(async () => {28 api = await getApiConnection();29 });3031 it('add resource', async () => {32 const collectionIdAlice = await createCollection(33 api,34 Alice,35 'test-metadata',36 null,37 'test-symbol',38 );3940 const nftAlice = await mintNft(41 api,42 Alice,43 Alice,44 collectionIdAlice,45 'nft-metadata',46 );4748 await addNftBasicResource(49 api,50 Alice,51 'added',52 collectionIdAlice,53 nftAlice,54 src,55 metadata,56 license,57 thumb,58 );59 });6061 it('add a resource to the nested NFT', async () => {62 const collectionIdAlice = await createCollection(63 api,64 Alice,65 'test-metadata',66 null,67 'test-symbol',68 );6970 const parentNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'parent-nft-metadata');71 const childNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'child-nft-metadata');7273 const newOwnerNFT: NftIdTuple = [collectionIdAlice, parentNftId];7475 await sendNft(api, 'sent', Alice, collectionIdAlice, childNftId, newOwnerNFT);7677 await addNftBasicResource(78 api,79 Alice,80 'added',81 collectionIdAlice,82 childNftId,83 src,84 metadata,85 license,86 thumb,87 );88 });8990 it('add multiple resources', async () => {91 const collectionIdAlice = await createCollection(92 api,93 Alice,94 'test-metadata',95 null,96 'test-symbol',97 );9899 const nftAlice = await mintNft(100 api,101 Alice,102 Alice,103 collectionIdAlice,104 'nft-metadata',105 );106107 const baseId = 42;108 const slotId = 10;109 const parts = [0, 5, 2];110111 const resourcesInfo = [];112 const resourceNum = 4;113114 const checkResource = async (resource: ResourceInfo, resType: string, expectedId: number, expected: {115 src: string,116 metadata: string,117 license: string,118 thumb: string119 }) => {120121 // FIXME A workaround. It seems it is a PolkadotJS bug.122 // All of the following are `false`.123 //124 // console.log('>>> basic:', resource.resource.isBasic);125 // console.log('>>> composable:', resource.resource.isComposable);126 // console.log('>>> slot:', resource.resource.isSlot);127 const resourceJson = (resource.resource.toHuman() as any)[resType];128129 expect(resource.id.toNumber(), 'Error: Invalid resource Id')130 .to.be.eq(expectedId);131132 expect(resourceJson.src, 'Error: Invalid resource src')133 .to.be.eq(expected.src);134 expect(resourceJson.metadata, 'Error: Invalid resource metadata')135 .to.be.eq(expected.metadata);136 expect(resourceJson.license, 'Error: Invalid resource license')137 .to.be.eq(expected.license);138 expect(resourceJson.thumb, 'Error: Invalid resource thumb')139 .to.be.eq(expected.thumb);140 };141142 for (let i = 0; i < resourceNum; i++) {143 resourcesInfo.push({144 src: src + 'r-' + i,145 metadata: metadata + 'r-' + i,146 license: license + 'r-' + i,147 thumb: thumb + 'r-' + i,148 });149 }150151 const firstBasicResourceId = await addNftBasicResource(152 api,153 Alice,154 'added',155 collectionIdAlice,156 nftAlice,157 resourcesInfo[0].src,158 resourcesInfo[0].metadata,159 resourcesInfo[0].license,160 resourcesInfo[0].thumb,161 );162163 const secondBasicResourceId = await addNftBasicResource(164 api,165 Alice,166 'added',167 collectionIdAlice,168 nftAlice,169 resourcesInfo[1].src,170 resourcesInfo[1].metadata,171 resourcesInfo[1].license,172 resourcesInfo[1].thumb,173 );174175 const composableResourceId = await addNftComposableResource(176 api,177 Alice,178 'added',179 collectionIdAlice,180 nftAlice,181 parts,182 baseId,183 resourcesInfo[2].src,184 resourcesInfo[2].metadata,185 resourcesInfo[2].license,186 resourcesInfo[2].thumb,187 );188189 const slotResourceId = await addNftSlotResource(190 api,191 Alice,192 'added',193 collectionIdAlice,194 nftAlice,195 baseId,196 slotId,197 resourcesInfo[3].src,198 resourcesInfo[3].metadata,199 resourcesInfo[3].license,200 resourcesInfo[3].thumb,201 );202203 const firstResource = await getResourceById(api, collectionIdAlice, nftAlice, firstBasicResourceId);204 await checkResource(firstResource, 'Basic', firstBasicResourceId, resourcesInfo[0]);205206 const secondResource = await getResourceById(api, collectionIdAlice, nftAlice, secondBasicResourceId);207 await checkResource(secondResource, 'Basic', secondBasicResourceId, resourcesInfo[1]);208209 const composableResource = await getResourceById(api, collectionIdAlice, nftAlice, composableResourceId);210 await checkResource(composableResource, 'Composable', composableResourceId, resourcesInfo[2]);211212 const slotResource = await getResourceById(api, collectionIdAlice, nftAlice, slotResourceId);213 await checkResource(slotResource, 'Slot', slotResourceId, resourcesInfo[3]);214 });215216 it('[negative]: unable to add a resource to the non-existing NFT', async () => {217 const collectionIdAlice = await createCollection(218 api,219 Alice,220 'test-metadata',221 null,222 'test-symbol',223 );224225 const tx = addNftBasicResource(226 api,227 Alice,228 'added',229 collectionIdAlice,230 nonexistentId,231 src,232 metadata,233 license,234 thumb,235 );236 237 await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);238 });239240 it('[negative]: unable to add a resource by a not-an-owner user', async () => {241 const collectionIdAlice = await createCollection(242 api,243 Alice,244 'test-metadata',245 null,246 'test-symbol',247 );248249 const nftAlice = await mintNft(250 api,251 Alice,252 Alice,253 collectionIdAlice,254 'nft-metadata',255 );256257 const tx = addNftBasicResource(258 api,259 Bob,260 'added',261 collectionIdAlice,262 nftAlice,263 src,264 metadata,265 license,266 thumb,267 );268 269 await expectTxFailure(/rmrkCore\.NoPermission/, tx);270 });271272 it('[negative]: unable to add a resource to the nested NFT if it isnt root owned by the caller', async () => {273 const collectionIdAlice = await createCollection(274 api,275 Alice,276 'test-metadata',277 null,278 'test-symbol',279 );280281 const parentNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'parent-nft-metadata');282 const childNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'child-nft-metadata');283284 const newOwnerNFT: NftIdTuple = [collectionIdAlice, parentNftId];285286 await sendNft(api, 'sent', Alice, collectionIdAlice, childNftId, newOwnerNFT);287288 const tx = addNftBasicResource(289 api,290 Bob,291 'added',292 collectionIdAlice,293 childNftId,294 src,295 metadata,296 license,297 thumb,298 );299 300 await expectTxFailure(/rmrkCore\.NoPermission/, tx);301 });302303 it('accept resource', async () => {304 const collectionIdBob = await createCollection(305 api,306 Bob,307 'test-metadata',308 null,309 'test-symbol',310 );311312 const nftAlice = await mintNft(313 api,314 Bob,315 Alice,316 collectionIdBob,317 'nft-metadata',318 );319320 const resourceId = await addNftBasicResource(321 api,322 Bob,323 'pending',324 collectionIdBob,325 nftAlice,326 src,327 metadata,328 license,329 thumb,330 );331332 await acceptNftResource(api, Alice, collectionIdBob, nftAlice, resourceId);333 });334335 it('[negative]: unable to accept a non-existing resource', async () => {336 const collectionIdBob = await createCollection(337 api,338 Bob,339 'test-metadata',340 null,341 'test-symbol',342 );343344 const nftAlice = await mintNft(345 api,346 Bob,347 Alice,348 collectionIdBob,349 'nft-metadata',350 );351352 const tx = acceptNftResource(api, Alice, collectionIdBob, nftAlice, nonexistentId);353 await expectTxFailure(/rmrkCore\.ResourceDoesntExist/, tx);354 });355356 it('[negative]: unable to accept a resource by a not-an-NFT-owner user', async () => {357 const collectionIdBob = await createCollection(358 api,359 Bob,360 'test-metadata',361 null,362 'test-symbol',363 );364365 const nftAlice = await mintNft(366 api,367 Bob,368 Alice,369 collectionIdBob,370 'nft-metadata',371 );372373 const resourceId = await addNftBasicResource(374 api,375 Bob,376 'pending',377 collectionIdBob,378 nftAlice,379 src,380 metadata,381 license,382 thumb,383 );384385 const tx = acceptNftResource(api, Bob, collectionIdBob, nftAlice, resourceId);386387 await expectTxFailure(/rmrkCore\.NoPermission/, tx);388 });389390 it('[negative]: unable to accept a resource to a non-target NFT', async () => {391 const collectionIdBob = await createCollection(392 api,393 Bob,394 'test-metadata',395 null,396 'test-symbol',397 );398399 const nftAlice = await mintNft(400 api,401 Bob,402 Alice,403 collectionIdBob,404 'nft-metadata',405 );406407 const wrongNft = await mintNft(408 api,409 Bob,410 Alice,411 collectionIdBob,412 'nft-metadata',413 );414 415 const resourceId = await addNftBasicResource(416 api,417 Bob,418 'pending',419 collectionIdBob,420 nftAlice,421 src,422 metadata,423 license,424 thumb,425 );426427 const tx = acceptNftResource(api, Bob, collectionIdBob, wrongNft, resourceId);428429 await expectTxFailure(/rmrkCore\.ResourceDoesntExist/, tx);430 });431432433 after(() => {434 api.disconnect();435 });436});1import {expect} from 'chai';2import {getApiConnection} from '../substrate/substrate-api';3import {NftIdTuple} from './util/fetch';4import {expectTxFailure, getResourceById} from './util/helpers';5import {6 addNftBasicResource,7 acceptNftResource,8 createCollection,9 mintNft,10 sendNft,11 addNftSlotResource,12 addNftComposableResource,13} from './util/tx';14import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';15import { getModuleNames, Pallets } from '../util/helpers';1617describe('integration test: add NFT resource', () => {18 const Alice = '//Alice';19 const Bob = '//Bob';20 const src = 'test-res-src';21 const metadata = 'test-res-metadata';22 const license = 'test-res-license';23 const thumb = 'test-res-thumb';2425 const nonexistentId = 99999;2627 let api: any;28 before(async function() {29 api = await getApiConnection();30 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();31 });3233 it('add resource', async () => {34 const collectionIdAlice = await createCollection(35 api,36 Alice,37 'test-metadata',38 null,39 'test-symbol',40 );4142 const nftAlice = await mintNft(43 api,44 Alice,45 Alice,46 collectionIdAlice,47 'nft-metadata',48 );4950 await addNftBasicResource(51 api,52 Alice,53 'added',54 collectionIdAlice,55 nftAlice,56 src,57 metadata,58 license,59 thumb,60 );61 });6263 it('add a resource to the nested NFT', async () => {64 const collectionIdAlice = await createCollection(65 api,66 Alice,67 'test-metadata',68 null,69 'test-symbol',70 );7172 const parentNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'parent-nft-metadata');73 const childNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'child-nft-metadata');7475 const newOwnerNFT: NftIdTuple = [collectionIdAlice, parentNftId];7677 await sendNft(api, 'sent', Alice, collectionIdAlice, childNftId, newOwnerNFT);7879 await addNftBasicResource(80 api,81 Alice,82 'added',83 collectionIdAlice,84 childNftId,85 src,86 metadata,87 license,88 thumb,89 );90 });9192 it('add multiple resources', async () => {93 const collectionIdAlice = await createCollection(94 api,95 Alice,96 'test-metadata',97 null,98 'test-symbol',99 );100101 const nftAlice = await mintNft(102 api,103 Alice,104 Alice,105 collectionIdAlice,106 'nft-metadata',107 );108109 const baseId = 42;110 const slotId = 10;111 const parts = [0, 5, 2];112113 const resourcesInfo = [];114 const resourceNum = 4;115116 const checkResource = async (resource: ResourceInfo, resType: string, expectedId: number, expected: {117 src: string,118 metadata: string,119 license: string,120 thumb: string121 }) => {122123 // FIXME A workaround. It seems it is a PolkadotJS bug.124 // All of the following are `false`.125 //126 // console.log('>>> basic:', resource.resource.isBasic);127 // console.log('>>> composable:', resource.resource.isComposable);128 // console.log('>>> slot:', resource.resource.isSlot);129 const resourceJson = (resource.resource.toHuman() as any)[resType];130131 expect(resource.id.toNumber(), 'Error: Invalid resource Id')132 .to.be.eq(expectedId);133134 expect(resourceJson.src, 'Error: Invalid resource src')135 .to.be.eq(expected.src);136 expect(resourceJson.metadata, 'Error: Invalid resource metadata')137 .to.be.eq(expected.metadata);138 expect(resourceJson.license, 'Error: Invalid resource license')139 .to.be.eq(expected.license);140 expect(resourceJson.thumb, 'Error: Invalid resource thumb')141 .to.be.eq(expected.thumb);142 };143144 for (let i = 0; i < resourceNum; i++) {145 resourcesInfo.push({146 src: src + 'r-' + i,147 metadata: metadata + 'r-' + i,148 license: license + 'r-' + i,149 thumb: thumb + 'r-' + i,150 });151 }152153 const firstBasicResourceId = await addNftBasicResource(154 api,155 Alice,156 'added',157 collectionIdAlice,158 nftAlice,159 resourcesInfo[0].src,160 resourcesInfo[0].metadata,161 resourcesInfo[0].license,162 resourcesInfo[0].thumb,163 );164165 const secondBasicResourceId = await addNftBasicResource(166 api,167 Alice,168 'added',169 collectionIdAlice,170 nftAlice,171 resourcesInfo[1].src,172 resourcesInfo[1].metadata,173 resourcesInfo[1].license,174 resourcesInfo[1].thumb,175 );176177 const composableResourceId = await addNftComposableResource(178 api,179 Alice,180 'added',181 collectionIdAlice,182 nftAlice,183 parts,184 baseId,185 resourcesInfo[2].src,186 resourcesInfo[2].metadata,187 resourcesInfo[2].license,188 resourcesInfo[2].thumb,189 );190191 const slotResourceId = await addNftSlotResource(192 api,193 Alice,194 'added',195 collectionIdAlice,196 nftAlice,197 baseId,198 slotId,199 resourcesInfo[3].src,200 resourcesInfo[3].metadata,201 resourcesInfo[3].license,202 resourcesInfo[3].thumb,203 );204205 const firstResource = await getResourceById(api, collectionIdAlice, nftAlice, firstBasicResourceId);206 await checkResource(firstResource, 'Basic', firstBasicResourceId, resourcesInfo[0]);207208 const secondResource = await getResourceById(api, collectionIdAlice, nftAlice, secondBasicResourceId);209 await checkResource(secondResource, 'Basic', secondBasicResourceId, resourcesInfo[1]);210211 const composableResource = await getResourceById(api, collectionIdAlice, nftAlice, composableResourceId);212 await checkResource(composableResource, 'Composable', composableResourceId, resourcesInfo[2]);213214 const slotResource = await getResourceById(api, collectionIdAlice, nftAlice, slotResourceId);215 await checkResource(slotResource, 'Slot', slotResourceId, resourcesInfo[3]);216 });217218 it('[negative]: unable to add a resource to the non-existing NFT', async () => {219 const collectionIdAlice = await createCollection(220 api,221 Alice,222 'test-metadata',223 null,224 'test-symbol',225 );226227 const tx = addNftBasicResource(228 api,229 Alice,230 'added',231 collectionIdAlice,232 nonexistentId,233 src,234 metadata,235 license,236 thumb,237 );238 239 await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);240 });241242 it('[negative]: unable to add a resource by a not-an-owner user', async () => {243 const collectionIdAlice = await createCollection(244 api,245 Alice,246 'test-metadata',247 null,248 'test-symbol',249 );250251 const nftAlice = await mintNft(252 api,253 Alice,254 Alice,255 collectionIdAlice,256 'nft-metadata',257 );258259 const tx = addNftBasicResource(260 api,261 Bob,262 'added',263 collectionIdAlice,264 nftAlice,265 src,266 metadata,267 license,268 thumb,269 );270 271 await expectTxFailure(/rmrkCore\.NoPermission/, tx);272 });273274 it('[negative]: unable to add a resource to the nested NFT if it isnt root owned by the caller', async () => {275 const collectionIdAlice = await createCollection(276 api,277 Alice,278 'test-metadata',279 null,280 'test-symbol',281 );282283 const parentNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'parent-nft-metadata');284 const childNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'child-nft-metadata');285286 const newOwnerNFT: NftIdTuple = [collectionIdAlice, parentNftId];287288 await sendNft(api, 'sent', Alice, collectionIdAlice, childNftId, newOwnerNFT);289290 const tx = addNftBasicResource(291 api,292 Bob,293 'added',294 collectionIdAlice,295 childNftId,296 src,297 metadata,298 license,299 thumb,300 );301 302 await expectTxFailure(/rmrkCore\.NoPermission/, tx);303 });304305 it('accept resource', async () => {306 const collectionIdBob = await createCollection(307 api,308 Bob,309 'test-metadata',310 null,311 'test-symbol',312 );313314 const nftAlice = await mintNft(315 api,316 Bob,317 Alice,318 collectionIdBob,319 'nft-metadata',320 );321322 const resourceId = await addNftBasicResource(323 api,324 Bob,325 'pending',326 collectionIdBob,327 nftAlice,328 src,329 metadata,330 license,331 thumb,332 );333334 await acceptNftResource(api, Alice, collectionIdBob, nftAlice, resourceId);335 });336337 it('[negative]: unable to accept a non-existing resource', async () => {338 const collectionIdBob = await createCollection(339 api,340 Bob,341 'test-metadata',342 null,343 'test-symbol',344 );345346 const nftAlice = await mintNft(347 api,348 Bob,349 Alice,350 collectionIdBob,351 'nft-metadata',352 );353354 const tx = acceptNftResource(api, Alice, collectionIdBob, nftAlice, nonexistentId);355 await expectTxFailure(/rmrkCore\.ResourceDoesntExist/, tx);356 });357358 it('[negative]: unable to accept a resource by a not-an-NFT-owner user', async () => {359 const collectionIdBob = await createCollection(360 api,361 Bob,362 'test-metadata',363 null,364 'test-symbol',365 );366367 const nftAlice = await mintNft(368 api,369 Bob,370 Alice,371 collectionIdBob,372 'nft-metadata',373 );374375 const resourceId = await addNftBasicResource(376 api,377 Bob,378 'pending',379 collectionIdBob,380 nftAlice,381 src,382 metadata,383 license,384 thumb,385 );386387 const tx = acceptNftResource(api, Bob, collectionIdBob, nftAlice, resourceId);388389 await expectTxFailure(/rmrkCore\.NoPermission/, tx);390 });391392 it('[negative]: unable to accept a resource to a non-target NFT', async () => {393 const collectionIdBob = await createCollection(394 api,395 Bob,396 'test-metadata',397 null,398 'test-symbol',399 );400401 const nftAlice = await mintNft(402 api,403 Bob,404 Alice,405 collectionIdBob,406 'nft-metadata',407 );408409 const wrongNft = await mintNft(410 api,411 Bob,412 Alice,413 collectionIdBob,414 'nft-metadata',415 );416 417 const resourceId = await addNftBasicResource(418 api,419 Bob,420 'pending',421 collectionIdBob,422 nftAlice,423 src,424 metadata,425 license,426 thumb,427 );428429 const tx = acceptNftResource(api, Bob, collectionIdBob, wrongNft, resourceId);430431 await expectTxFailure(/rmrkCore\.ResourceDoesntExist/, tx);432 });433434435 after(() => {436 api.disconnect();437 });438});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.tsdiffbeforeafterboth--- a/tests/src/rmrk/equipNft.test.ts
+++ b/tests/src/rmrk/equipNft.test.ts
@@ -1,6 +1,7 @@
import {ApiPromise} from '@polkadot/api';
import {expect} from 'chai';
import {getApiConnection} from '../substrate/substrate-api';
+import {getModuleNames, Pallets} from '../util/helpers';
import {getNft, getParts, NftIdTuple} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {
@@ -122,8 +123,10 @@
describe.skip('integration test: Equip NFT', () => {
let api: any;
- before(async () => {
+
+ before(async function () {
api = await getApiConnection();
+ if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
});
it('equip nft', async () => {
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) {