git.delta.rocks / unique-network / refs/commits / 7a2dbeac9ec6

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

PraetorP2022-08-01parent: #0d95470.patch.diff
in: master

27 files changed

modifiedruntime/common/Cargo.tomldiffbeforeafterboth
32 'frame-support/runtime-benchmarks',32 'frame-support/runtime-benchmarks',
33 'frame-system/runtime-benchmarks',33 'frame-system/runtime-benchmarks',
34]34]
35unique-runtime = ['std']
36quartz-runtime = ['std']
3537
36[dependencies.sp-core]38[dependencies.sp-core]
37default-features = false39default-features = false
modifiedruntime/common/src/dispatch.rsdiffbeforeafterboth
64 );64 );
65 <PalletFungible<T>>::init_collection(sender, data)?65 <PalletFungible<T>>::init_collection(sender, data)?
66 }66 }
67 #[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
67 CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,68 CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,
69
70 CollectionMode::ReFungible => {
71 return Err(DispatchError::Other("Refunginle pallet is not supported"))
72 }
68 };73 };
69 Ok(id)74 Ok(id)
70 }75 }
modifiedruntime/common/src/weights.rsdiffbeforeafterboth
25};25};
26use up_data_structs::{CreateItemExData, CreateItemData};26use up_data_structs::{CreateItemExData, CreateItemData};
2727
28#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
28macro_rules! max_weight_of {29macro_rules! max_weight_of {
29 ($method:ident ( $($args:tt)* )) => {30 ($method:ident ( $($args:tt)* )) => {
30 <FungibleWeights<T>>::$method($($args)*)31 <FungibleWeights<T>>::$method($($args)*)
33 };34 };
34}35}
3536
37#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
38macro_rules! max_weight_of {
39 ($method:ident ( $($args:tt)* )) => {
40 <FungibleWeights<T>>::$method($($args)*)
41 .max(<NonfungibleWeights<T>>::$method($($args)*))
42
43 };
44}
45
46#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
36pub struct CommonWeights<T>(PhantomData<T>)47pub struct CommonWeights<T>(PhantomData<T>)
37where48where
38 T: FungibleConfig + NonfungibleConfig + RefungibleConfig;49 T: FungibleConfig + NonfungibleConfig + RefungibleConfig;
50
51#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
39impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>52impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>
40where53where
41 T: FungibleConfig + NonfungibleConfig + RefungibleConfig,54 T: FungibleConfig + NonfungibleConfig + RefungibleConfig,
101 }114 }
102}115}
103116
117#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]
104impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>118impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>
105where119where
106 T: FungibleConfig + NonfungibleConfig + RefungibleConfig,120 T: FungibleConfig + NonfungibleConfig + RefungibleConfig,
110 }124 }
111}125}
126
127#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
128pub struct CommonWeights<T>(PhantomData<T>)
129where
130 T: FungibleConfig + NonfungibleConfig;
131
132#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
133impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>
134where
135 T: FungibleConfig + NonfungibleConfig,
136{
137 fn create_item() -> Weight {
138 dispatch_weight::<T>() + max_weight_of!(create_item())
139 }
140
141 fn create_multiple_items(data: &[CreateItemData]) -> Weight {
142 dispatch_weight::<T>() + max_weight_of!(create_multiple_items(data))
143 }
144
145 fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
146 dispatch_weight::<T>() + max_weight_of!(create_multiple_items_ex(data))
147 }
148
149 fn burn_item() -> Weight {
150 dispatch_weight::<T>() + max_weight_of!(burn_item())
151 }
152
153 fn set_collection_properties(amount: u32) -> Weight {
154 dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))
155 }
156
157 fn delete_collection_properties(amount: u32) -> Weight {
158 dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))
159 }
160
161 fn set_token_properties(amount: u32) -> Weight {
162 dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))
163 }
164
165 fn delete_token_properties(amount: u32) -> Weight {
166 dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))
167 }
168
169 fn set_token_property_permissions(amount: u32) -> Weight {
170 dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))
171 }
172
173 fn transfer() -> Weight {
174 dispatch_weight::<T>() + max_weight_of!(transfer())
175 }
176
177 fn approve() -> Weight {
178 dispatch_weight::<T>() + max_weight_of!(approve())
179 }
180
181 fn transfer_from() -> Weight {
182 dispatch_weight::<T>() + max_weight_of!(transfer_from())
183 }
184
185 fn burn_from() -> Weight {
186 dispatch_weight::<T>() + max_weight_of!(burn_from())
187 }
188
189 fn burn_recursively_self_raw() -> Weight {
190 max_weight_of!(burn_recursively_self_raw())
191 }
192
193 fn burn_recursively_breadth_raw(amount: u32) -> Weight {
194 max_weight_of!(burn_recursively_breadth_raw(amount))
195 }
196}
197
198#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]
199impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>
200where
201 T: FungibleConfig + NonfungibleConfig,
202{
203 fn repartition() -> Weight {
204 dispatch_weight::<T>()
205 }
206}
112207
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
909 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;909 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
910}910}
911911
912impl pallet_proxy_rmrk_core::Config for Runtime {912// impl pallet_proxy_rmrk_core::Config for Runtime {
913 type WeightInfo = pallet_proxy_rmrk_core::weights::SubstrateWeight<Self>;913// type WeightInfo = pallet_proxy_rmrk_core::weights::SubstrateWeight<Self>;
914 type Event = Event;914// type Event = Event;
915}915// }
916916
917impl pallet_proxy_rmrk_equip::Config for Runtime {917// impl pallet_proxy_rmrk_equip::Config for Runtime {
918 type WeightInfo = pallet_proxy_rmrk_equip::weights::SubstrateWeight<Self>;918// type WeightInfo = pallet_proxy_rmrk_equip::weights::SubstrateWeight<Self>;
919 type Event = Event;919// type Event = Event;
920}920// }
921921
922impl pallet_unique::Config for Runtime {922impl pallet_unique::Config for Runtime {
923 type Event = Event;923 type Event = Event;
961 )961 )
962}962}
963963
964pub struct SchedulerPaymentExecutor;964// pub struct SchedulerPaymentExecutor;
965impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>965// impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>
966 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor966// DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
967where967// where
968 <T as frame_system::Config>::Call: Member968// <T as frame_system::Config>::Call: Member
969 + Dispatchable<Origin = Origin, Info = DispatchInfo>969// + Dispatchable<Origin = Origin, Info = DispatchInfo>
970 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>970// + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
971 + GetDispatchInfo971// + GetDispatchInfo
972 + From<frame_system::Call<Runtime>>,972// + From<frame_system::Call<Runtime>>,
973 SelfContainedSignedInfo: Send + Sync + 'static,973// SelfContainedSignedInfo: Send + Sync + 'static,
974 Call: From<<T as frame_system::Config>::Call>974// Call: From<<T as frame_system::Config>::Call>
975 + From<<T as pallet_unique_scheduler::Config>::Call>975// + From<<T as pallet_unique_scheduler::Config>::Call>
976 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,976// + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,
977 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,977// sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,
978{978// {
979 fn dispatch_call(979// fn dispatch_call(
980 signer: <T as frame_system::Config>::AccountId,980// signer: <T as frame_system::Config>::AccountId,
981 call: <T as pallet_unique_scheduler::Config>::Call,981// call: <T as pallet_unique_scheduler::Config>::Call,
982 ) -> Result<982// ) -> Result<
983 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,983// Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,
984 TransactionValidityError,984// TransactionValidityError,
985 > {985// > {
986 let dispatch_info = call.get_dispatch_info();986// let dispatch_info = call.get_dispatch_info();
987 let extrinsic = fp_self_contained::CheckedExtrinsic::<987// let extrinsic = fp_self_contained::CheckedExtrinsic::<
988 AccountId,988// AccountId,
989 Call,989// Call,
990 SignedExtraScheduler,990// SignedExtraScheduler,
991 SelfContainedSignedInfo,991// SelfContainedSignedInfo,
992 > {992// > {
993 signed:993// signed:
994 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(994// CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(
995 signer.clone().into(),995// signer.clone().into(),
996 get_signed_extras(signer.into()),996// get_signed_extras(signer.into()),
997 ),997// ),
998 function: call.into(),998// function: call.into(),
999 };999// };
10001000
1001 extrinsic.apply::<Runtime>(&dispatch_info, 0)1001// extrinsic.apply::<Runtime>(&dispatch_info, 0)
1002 }1002// }
10031003
1004 fn reserve_balance(1004// fn reserve_balance(
1005 id: [u8; 16],1005// id: [u8; 16],
1006 sponsor: <T as frame_system::Config>::AccountId,1006// sponsor: <T as frame_system::Config>::AccountId,
1007 call: <T as pallet_unique_scheduler::Config>::Call,1007// call: <T as pallet_unique_scheduler::Config>::Call,
1008 count: u32,1008// count: u32,
1009 ) -> Result<(), DispatchError> {1009// ) -> Result<(), DispatchError> {
1010 let dispatch_info = call.get_dispatch_info();1010// let dispatch_info = call.get_dispatch_info();
1011 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1011// let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)
1012 .saturating_mul(count.into());1012// .saturating_mul(count.into());
10131013
1014 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1014// <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
1015 &id,1015// &id,
1016 &(sponsor.into()),1016// &(sponsor.into()),
1017 weight.into(),1017// weight.into(),
1018 )1018// )
1019 }1019// }
10201020
1021 fn pay_for_call(1021// fn pay_for_call(
1022 id: [u8; 16],1022// id: [u8; 16],
1023 sponsor: <T as frame_system::Config>::AccountId,1023// sponsor: <T as frame_system::Config>::AccountId,
1024 call: <T as pallet_unique_scheduler::Config>::Call,1024// call: <T as pallet_unique_scheduler::Config>::Call,
1025 ) -> Result<u128, DispatchError> {1025// ) -> Result<u128, DispatchError> {
1026 let dispatch_info = call.get_dispatch_info();1026// let dispatch_info = call.get_dispatch_info();
1027 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1027// let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);
1028 Ok(1028// Ok(
1029 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1029// <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
1030 &id,1030// &id,
1031 &(sponsor.into()),1031// &(sponsor.into()),
1032 weight.into(),1032// weight.into(),
1033 ),1033// ),
1034 )1034// )
1035 }1035// }
10361036
1037 fn cancel_reserve(1037// fn cancel_reserve(
1038 id: [u8; 16],1038// id: [u8; 16],
1039 sponsor: <T as frame_system::Config>::AccountId,1039// sponsor: <T as frame_system::Config>::AccountId,
1040 ) -> Result<u128, DispatchError> {1040// ) -> Result<u128, DispatchError> {
1041 Ok(1041// Ok(
1042 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1042// <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
1043 &id,1043// &id,
1044 &(sponsor.into()),1044// &(sponsor.into()),
1045 u128::MAX,1045// u128::MAX,
1046 ),1046// ),
1047 )1047// )
1048 }1048// }
1049}1049// }
10501050
1051parameter_types! {1051parameter_types! {
1052 pub const NoPreimagePostponement: Option<u32> = Some(10);1052 pub const NoPreimagePostponement: Option<u32> = Some(10);
1062 }1062 }
1063}1063}
10641064
1065impl pallet_unique_scheduler::Config for Runtime {1065// impl pallet_unique_scheduler::Config for Runtime {
1066 type Event = Event;1066// type Event = Event;
1067 type Origin = Origin;1067// type Origin = Origin;
1068 type Currency = Balances;1068// type Currency = Balances;
1069 type PalletsOrigin = OriginCaller;1069// type PalletsOrigin = OriginCaller;
1070 type Call = Call;1070// type Call = Call;
1071 type MaximumWeight = MaximumSchedulerWeight;1071// type MaximumWeight = MaximumSchedulerWeight;
1072 type ScheduleOrigin = EnsureSigned<AccountId>;1072// type ScheduleOrigin = EnsureSigned<AccountId>;
1073 type MaxScheduledPerBlock = MaxScheduledPerBlock;1073// type MaxScheduledPerBlock = MaxScheduledPerBlock;
1074 type WeightInfo = ();1074// type WeightInfo = ();
1075 type CallExecutor = SchedulerPaymentExecutor;1075// type CallExecutor = SchedulerPaymentExecutor;
1076 type OriginPrivilegeCmp = OriginPrivilegeCmp;1076// type OriginPrivilegeCmp = OriginPrivilegeCmp;
1077 type PreimageProvider = ();1077// type PreimageProvider = ();
1078 type NoPreimagePostponement = NoPreimagePostponement;1078// type NoPreimagePostponement = NoPreimagePostponement;
1079}1079// }
10801080
1081type EvmSponsorshipHandler = (1081type EvmSponsorshipHandler = (
1082 UniqueEthSponsorshipHandler<Runtime>,1082 UniqueEthSponsorshipHandler<Runtime>,
1150 // Unique Pallets1150 // Unique Pallets
1151 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1151 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
1152 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1152 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
1153 Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1153 // Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
1154 // free = 631154 // free = 63
1155 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1155 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
1156 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1156 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
1157 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1157 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
1158 Fungible: pallet_fungible::{Pallet, Storage} = 67,1158 Fungible: pallet_fungible::{Pallet, Storage} = 67,
1159 Refungible: pallet_refungible::{Pallet, Storage} = 68,1159 // Refungible: pallet_refungible::{Pallet, Storage} = 68,
1160 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1160 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
1161 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1161 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
1162 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1162 // RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1163 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,1163 // RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
11641164
1165 // Frontier1165 // Frontier
1166 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1166 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
1324 RmrkTheme1324 RmrkTheme
1325 > for Runtime {1325 > for Runtime {
1326
1327 // fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {
1328 // pallet_proxy_rmrk_core::rpc::last_collection_idx::<Runtime>()
1329 // }
1330
1331 // fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {
1332 // pallet_proxy_rmrk_core::rpc::collection_by_id::<Runtime>(collection_id)
1333 // }
1334
1335 // fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {
1336 // pallet_proxy_rmrk_core::rpc::nft_by_id::<Runtime>(collection_id, nft_by_id)
1337 // }
1338
1339 // fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {
1340 // pallet_proxy_rmrk_core::rpc::account_tokens::<Runtime>(account_id, collection_id)
1341 // }
1342
1343 // fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {
1344 // pallet_proxy_rmrk_core::rpc::nft_children::<Runtime>(collection_id, nft_id)
1345 // }
1346
1347 // fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
1348 // pallet_proxy_rmrk_core::rpc::collection_properties::<Runtime>(collection_id, filter_keys)
1349 // }
1350
1351 // fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
1352 // pallet_proxy_rmrk_core::rpc::nft_properties::<Runtime>(collection_id, nft_id, filter_keys)
1353 // }
1354
1355 // fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {
1356 // pallet_proxy_rmrk_core::rpc::nft_resources::<Runtime>(collection_id, nft_id)
1357 // }
1358
1359 // fn nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {
1360 // pallet_proxy_rmrk_core::rpc::nft_resource_priority::<Runtime>(collection_id, nft_id, resource_id)
1361 // }
1362
1363 // fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {
1364 // pallet_proxy_rmrk_equip::rpc::base::<Runtime>(base_id)
1365 // }
1366
1367 // fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
1368 // pallet_proxy_rmrk_equip::rpc::base_parts::<Runtime>(base_id)
1369 // }
1370
1371 // fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {
1372 // pallet_proxy_rmrk_equip::rpc::theme_names::<Runtime>(base_id)
1373 // }
1374
1375 // fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {
1376 // pallet_proxy_rmrk_equip::rpc::theme::<Runtime>(base_id, theme_name, filter_keys)
1377 // }
1378
1326 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {1379 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {
1327 pallet_proxy_rmrk_core::rpc::last_collection_idx::<Runtime>()1380 Ok(Default::default())
1328 }1381 }
13291382
1330 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {1383 fn collection_by_id(_collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {
1331 pallet_proxy_rmrk_core::rpc::collection_by_id::<Runtime>(collection_id)1384 Ok(Default::default())
1332 }1385 }
13331386
1334 fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {1387 fn nft_by_id(_collection_id: RmrkCollectionId, _nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {
1335 pallet_proxy_rmrk_core::rpc::nft_by_id::<Runtime>(collection_id, nft_by_id)1388 Ok(Default::default())
1336 }1389 }
13371390
1338 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {1391 fn account_tokens(_account_id: AccountId, _collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {
1339 pallet_proxy_rmrk_core::rpc::account_tokens::<Runtime>(account_id, collection_id)1392 Ok(Default::default())
1340 }1393 }
13411394
1342 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {1395 fn nft_children(_collection_id: RmrkCollectionId, _nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {
1343 pallet_proxy_rmrk_core::rpc::nft_children::<Runtime>(collection_id, nft_id)1396 Ok(Default::default())
1344 }1397 }
13451398
1346 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {1399 fn collection_properties(_collection_id: RmrkCollectionId, _filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
1347 pallet_proxy_rmrk_core::rpc::collection_properties::<Runtime>(collection_id, filter_keys)1400 Ok(Default::default())
1348 }1401 }
13491402
1350 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {1403 fn nft_properties(_collection_id: RmrkCollectionId, _nft_id: RmrkNftId, _filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
1351 pallet_proxy_rmrk_core::rpc::nft_properties::<Runtime>(collection_id, nft_id, filter_keys)1404 Ok(Default::default())
1352 }1405 }
13531406
1354 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {1407 fn nft_resources(_collection_id: RmrkCollectionId, _nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {
1355 pallet_proxy_rmrk_core::rpc::nft_resources::<Runtime>(collection_id, nft_id)1408 Ok(Default::default())
1356 }1409 }
13571410
1358 fn nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {1411 fn nft_resource_priority(_collection_id: RmrkCollectionId, _nft_id: RmrkNftId, _resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {
1359 pallet_proxy_rmrk_core::rpc::nft_resource_priority::<Runtime>(collection_id, nft_id, resource_id)1412 Ok(Default::default())
1360 }1413 }
13611414
1362 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {1415 fn base(_base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {
1363 pallet_proxy_rmrk_equip::rpc::base::<Runtime>(base_id)1416 Ok(Default::default())
1364 }1417 }
13651418
1366 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {1419 fn base_parts(_base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
1367 pallet_proxy_rmrk_equip::rpc::base_parts::<Runtime>(base_id)1420 Ok(Default::default())
1368 }1421 }
13691422
1370 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {1423 fn theme_names(_base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {
1371 pallet_proxy_rmrk_equip::rpc::theme_names::<Runtime>(base_id)1424 Ok(Default::default())
1372 }1425 }
13731426
1374 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {1427 fn theme(_base_id: RmrkBaseId, _theme_name: RmrkThemeName, _filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {
1375 pallet_proxy_rmrk_equip::rpc::theme::<Runtime>(base_id, theme_name, filter_keys)1428 Ok(Default::default())
1376 }1429 }
1430
1431
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
950 )952 )
951}953}
952954
953pub struct SchedulerPaymentExecutor;955// pub struct SchedulerPaymentExecutor;
954impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>956// impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>
955 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor957// DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
956where958// where
957 <T as frame_system::Config>::Call: Member959// <T as frame_system::Config>::Call: Member
958 + Dispatchable<Origin = Origin, Info = DispatchInfo>960// + Dispatchable<Origin = Origin, Info = DispatchInfo>
959 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>961// + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
960 + GetDispatchInfo962// + GetDispatchInfo
961 + From<frame_system::Call<Runtime>>,963// + From<frame_system::Call<Runtime>>,
962 SelfContainedSignedInfo: Send + Sync + 'static,964// SelfContainedSignedInfo: Send + Sync + 'static,
963 Call: From<<T as frame_system::Config>::Call>965// Call: From<<T as frame_system::Config>::Call>
964 + From<<T as pallet_unique_scheduler::Config>::Call>966// + From<<T as pallet_unique_scheduler::Config>::Call>
965 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,967// + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,
966 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,968// sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,
967{969// {
968 fn dispatch_call(970// fn dispatch_call(
969 signer: <T as frame_system::Config>::AccountId,971// signer: <T as frame_system::Config>::AccountId,
970 call: <T as pallet_unique_scheduler::Config>::Call,972// call: <T as pallet_unique_scheduler::Config>::Call,
971 ) -> Result<973// ) -> Result<
972 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,974// Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,
973 TransactionValidityError,975// TransactionValidityError,
974 > {976// > {
975 let dispatch_info = call.get_dispatch_info();977// let dispatch_info = call.get_dispatch_info();
976 let extrinsic = fp_self_contained::CheckedExtrinsic::<978// let extrinsic = fp_self_contained::CheckedExtrinsic::<
977 AccountId,979// AccountId,
978 Call,980// Call,
979 SignedExtraScheduler,981// SignedExtraScheduler,
980 SelfContainedSignedInfo,982// SelfContainedSignedInfo,
981 > {983// > {
982 signed:984// signed:
983 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(985// CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(
984 signer.clone().into(),986// signer.clone().into(),
985 get_signed_extras(signer.into()),987// get_signed_extras(signer.into()),
986 ),988// ),
987 function: call.into(),989// function: call.into(),
988 };990// };
989991
990 extrinsic.apply::<Runtime>(&dispatch_info, 0)992// extrinsic.apply::<Runtime>(&dispatch_info, 0)
991 }993// }
992994
993 fn reserve_balance(995// fn reserve_balance(
994 id: [u8; 16],996// id: [u8; 16],
995 sponsor: <T as frame_system::Config>::AccountId,997// sponsor: <T as frame_system::Config>::AccountId,
996 call: <T as pallet_unique_scheduler::Config>::Call,998// call: <T as pallet_unique_scheduler::Config>::Call,
997 count: u32,999// count: u32,
998 ) -> Result<(), DispatchError> {1000// ) -> Result<(), DispatchError> {
999 let dispatch_info = call.get_dispatch_info();1001// let dispatch_info = call.get_dispatch_info();
1000 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1002// let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)
1001 .saturating_mul(count.into());1003// .saturating_mul(count.into());
10021004
1003 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1005// <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
1004 &id,1006// &id,
1005 &(sponsor.into()),1007// &(sponsor.into()),
1006 weight,1008// weight,
1007 )1009// )
1008 }1010// }
10091011
1010 fn pay_for_call(1012// fn pay_for_call(
1011 id: [u8; 16],1013// id: [u8; 16],
1012 sponsor: <T as frame_system::Config>::AccountId,1014// sponsor: <T as frame_system::Config>::AccountId,
1013 call: <T as pallet_unique_scheduler::Config>::Call,1015// call: <T as pallet_unique_scheduler::Config>::Call,
1014 ) -> Result<u128, DispatchError> {1016// ) -> Result<u128, DispatchError> {
1015 let dispatch_info = call.get_dispatch_info();1017// let dispatch_info = call.get_dispatch_info();
1016 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1018// let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);
1017 Ok(1019// Ok(
1018 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1020// <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
1019 &id,1021// &id,
1020 &(sponsor.into()),1022// &(sponsor.into()),
1021 weight,1023// weight,
1022 ),1024// ),
1023 )1025// )
1024 }1026// }
10251027
1026 fn cancel_reserve(1028// fn cancel_reserve(
1027 id: [u8; 16],1029// id: [u8; 16],
1028 sponsor: <T as frame_system::Config>::AccountId,1030// sponsor: <T as frame_system::Config>::AccountId,
1029 ) -> Result<u128, DispatchError> {1031// ) -> Result<u128, DispatchError> {
1030 Ok(1032// Ok(
1031 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1033// <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(
1032 &id,1034// &id,
1033 &(sponsor.into()),1035// &(sponsor.into()),
1034 u128::MAX,1036// u128::MAX,
1035 ),1037// ),
1036 )1038// )
1037 }1039// }
1038}1040// }
10391041
1040parameter_types! {1042parameter_types! {
1041 pub const NoPreimagePostponement: Option<u32> = Some(10);1043 pub const NoPreimagePostponement: Option<u32> = Some(10);
1051 }1053 }
1052}1054}
10531055
1054impl pallet_unique_scheduler::Config for Runtime {1056// impl pallet_unique_scheduler::Config for Runtime {
1055 type Event = Event;1057// type Event = Event;
1056 type Origin = Origin;1058// type Origin = Origin;
1057 type Currency = Balances;1059// type Currency = Balances;
1058 type PalletsOrigin = OriginCaller;1060// type PalletsOrigin = OriginCaller;
1059 type Call = Call;1061// type Call = Call;
1060 type MaximumWeight = MaximumSchedulerWeight;1062// type MaximumWeight = MaximumSchedulerWeight;
1061 type ScheduleOrigin = EnsureSigned<AccountId>;1063// type ScheduleOrigin = EnsureSigned<AccountId>;
1062 type MaxScheduledPerBlock = MaxScheduledPerBlock;1064// type MaxScheduledPerBlock = MaxScheduledPerBlock;
1063 type WeightInfo = ();1065// type WeightInfo = ();
1064 type CallExecutor = SchedulerPaymentExecutor;1066// type CallExecutor = SchedulerPaymentExecutor;
1065 type OriginPrivilegeCmp = OriginPrivilegeCmp;1067// type OriginPrivilegeCmp = OriginPrivilegeCmp;
1066 type PreimageProvider = ();1068// type PreimageProvider = ();
1067 type NoPreimagePostponement = NoPreimagePostponement;1069// type NoPreimagePostponement = NoPreimagePostponement;
1068}1070// }
10691071
1070type EvmSponsorshipHandler = (1072type EvmSponsorshipHandler = (
1071 UniqueEthSponsorshipHandler<Runtime>,1073 UniqueEthSponsorshipHandler<Runtime>,
1139 // Unique Pallets1141 // Unique Pallets
1140 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1142 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
1141 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1143 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
1142 Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1144 // Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
1143 // free = 631145 // free = 63
1144 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1146 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
1145 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1147 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
1146 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1148 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
1147 Fungible: pallet_fungible::{Pallet, Storage} = 67,1149 Fungible: pallet_fungible::{Pallet, Storage} = 67,
1148 Refungible: pallet_refungible::{Pallet, Storage} = 68,1150 // Refungible: pallet_refungible::{Pallet, Storage} = 68,
1149 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1151 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
1150 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1152 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
11511153
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
36 CrossAccountId,36 CrossAccountId,
37 getCreateItemsResult,37 getCreateItemsResult,
38 getDestroyItemsResult,38 getDestroyItemsResult,
39 getModuleNames,
40 Pallets,
39} from './util/helpers';41} from './util/helpers';
4042
41import chai from 'chai';43import chai from 'chai';
46let alice: IKeyringPair;48let alice: IKeyringPair;
47let bob: IKeyringPair;49let bob: IKeyringPair;
4850
51
52
49describe('integration test: Refungible functionality:', () => {53describe('integration test: Refungible functionality:', async () => {
50 before(async () => {54 before(async function() {
51 await usingApi(async (api, privateKeyWrapper) => {55 await usingApi(async (api, privateKeyWrapper) => {
52 alice = privateKeyWrapper('//Alice');56 alice = privateKeyWrapper('//Alice');
53 bob = privateKeyWrapper('//Bob');57 bob = privateKeyWrapper('//Bob');
58 if (!getModuleNames(api).includes(Pallets.ReFungible)) this.skip();
54 });59 });
60
55 });61 });
5662
57 it('Create refungible collection and token', async () => {63 it('Create refungible collection and token', async () => {
58 await usingApi(async api => {64 await usingApi(async api => {
59 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});65 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});
268 ]);274 ]);
269 });275 });
270 });276 });
271});
272
273describe('Test Refungible properties:', () => {
274 before(async () => {
275 await usingApi(async (api, privateKeyWrapper) => {
276 alice = privateKeyWrapper('//Alice');
277 bob = privateKeyWrapper('//Bob');
278 });
279 });
280 277
281 it('Сreate new collection with properties', async () => {278 it('Сreate new collection with properties', async () => {
282 await usingApi(async api => {279 await usingApi(async api => {
292 });289 });
293 });290 });
294});291});
292
295293
modifiedtests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth
8} from './util/tx';8} from './util/tx';
9import {NftIdTuple} from './util/fetch';9import {NftIdTuple} from './util/fetch';
10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
11import { getModuleNames, Pallets } from '../util/helpers';
1112
12describe('integration test: accept NFT', () => {13describe('integration test: accept NFT', () => {
13 let api: any;14 let api: any;
14 before(async () => { api = await getApiConnection(); });15 before(async function() {
1516 api = await getApiConnection();
17 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
18 });
19
20
modifiedtests/src/rmrk/addResource.test.tsdiffbeforeafterboth
12 addNftComposableResource,12 addNftComposableResource,
13} from './util/tx';13} from './util/tx';
14import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';14import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';
15import { getModuleNames, Pallets } from '../util/helpers';
1516
16describe('integration test: add NFT resource', () => {17describe('integration test: add NFT resource', () => {
17 const Alice = '//Alice';18 const Alice = '//Alice';
24 const nonexistentId = 99999;25 const nonexistentId = 99999;
2526
26 let api: any;27 let api: any;
27 before(async () => {28 before(async function() {
28 api = await getApiConnection();29 api = await getApiConnection();
30 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
29 });31 });
3032
31 it('add resource', async () => {33 it('add resource', async () => {
modifiedtests/src/rmrk/addTheme.test.tsdiffbeforeafterboth
3import {createBase, addTheme} from './util/tx';3import {createBase, addTheme} from './util/tx';
4import {expectTxFailure} from './util/helpers';4import {expectTxFailure} from './util/helpers';
5import {getThemeNames} from './util/fetch';5import {getThemeNames} from './util/fetch';
6import { getModuleNames, Pallets } from '../util/helpers';
67
7describe('integration test: add Theme to Base', () => {8describe('integration test: add Theme to Base', () => {
8 let api: any;9 let api: any;
9 before(async () => { api = await getApiConnection(); });10 before(async function() {
11 api = await getApiConnection();
12 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
13 });
1014
11 const alice = '//Alice';15 const alice = '//Alice';
modifiedtests/src/rmrk/burnNft.test.tsdiffbeforeafterboth
55
6import chai from 'chai';6import chai from 'chai';
7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';
8import { getModuleNames, Pallets } from '../util/helpers';
89
9chai.use(chaiAsPromised);10chai.use(chaiAsPromised);
10const expect = chai.expect;11const expect = chai.expect;
14 const Bob = '//Bob';15 const Bob = '//Bob';
1516
16 let api: any;17 let api: any;
17 before(async () => {18 before(async function() {
18 api = await getApiConnection();19 api = await getApiConnection();
20 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
19 });21 });
22
2023
modifiedtests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';
2import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
3import {4import {
4 changeIssuer,5 changeIssuer,
10 const Bob = '//Bob';11 const Bob = '//Bob';
1112
12 let api: any;13 let api: any;
13 before(async () => {14 before(async function() {
14 api = await getApiConnection();15 api = await getApiConnection();
16 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
15 });17 });
18
19
modifiedtests/src/rmrk/createBase.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';
2import {createCollection, createBase} from './util/tx';3import {createCollection, createBase} from './util/tx';
34
4describe('integration test: create new Base', () => {5describe('integration test: create new Base', () => {
5 let api: any;6 let api: any;
6 before(async () => { api = await getApiConnection(); });7 before(async function() {
8 api = await getApiConnection();
9 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
10 });
711
8 const alice = '//Alice';12 const alice = '//Alice';
modifiedtests/src/rmrk/createCollection.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {getModuleNames, Pallets} from '../util/helpers';
2import {createCollection} from './util/tx';3import {createCollection} from './util/tx';
34
4describe('Integration test: create new collection', () => {5describe('Integration test: create new collection', () => {
5 let api: any;6 let api: any;
6 before(async () => { api = await getApiConnection(); });7 before(async function () {
8 api = await getApiConnection();
9 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
10 });
11
12
modifiedtests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';
2import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
3import {createCollection, deleteCollection} from './util/tx';4import {createCollection, deleteCollection} from './util/tx';
45
5describe('integration test: delete collection', () => {6describe('integration test: delete collection', () => {
6 let api: any;7 let api: any;
7 before(async () => {8 before(async function () {
8 api = await getApiConnection();9 api = await getApiConnection();
10 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
9 });11 });
1012
11 const Alice = '//Alice';13 const Alice = '//Alice';
modifiedtests/src/rmrk/equipNft.test.tsdiffbeforeafterboth
1import {ApiPromise} from '@polkadot/api';1import {ApiPromise} from '@polkadot/api';
2import {expect} from 'chai';2import {expect} from 'chai';
3import {getApiConnection} from '../substrate/substrate-api';3import {getApiConnection} from '../substrate/substrate-api';
4import {getModuleNames, Pallets} from '../util/helpers';
4import {getNft, getParts, NftIdTuple} from './util/fetch';5import {getNft, getParts, NftIdTuple} from './util/fetch';
5import {expectTxFailure} from './util/helpers';6import {expectTxFailure} from './util/helpers';
6import {7import {
123124
124 let api: any;125 let api: any;
126
125 before(async () => {127 before(async function () {
126 api = await getApiConnection();128 api = await getApiConnection();
129 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
127 });130 });
128131
129 it('equip nft', async () => {132 it('equip nft', async () => {
modifiedtests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import {getApiConnection} from '../substrate/substrate-api';2import {getApiConnection} from '../substrate/substrate-api';
3import { getModuleNames, Pallets } from '../util/helpers';
3import {getOwnedNfts} from './util/fetch';4import {getOwnedNfts} from './util/fetch';
4import {mintNft, createCollection} from './util/tx';5import {mintNft, createCollection} from './util/tx';
56
6describe('integration test: get owned NFTs', () => {7describe('integration test: get owned NFTs', () => {
7 let api: any;8 let api: any;
9
8 before(async () => { api = await getApiConnection(); });10 before(async function () {
11 api = await getApiConnection();
12 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
13 });
14
915
modifiedtests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';
2import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
3import {createCollection, lockCollection, mintNft} from './util/tx';4import {createCollection, lockCollection, mintNft} from './util/tx';
45
8 const Max = 5;9 const Max = 5;
910
10 let api: any;11 let api: any;
11 before(async () => {12 before(async function () {
12 api = await getApiConnection();13 api = await getApiConnection();
14 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
13 });15 });
1416
15 it('lock collection', async () => {17 it('lock collection', async () => {
modifiedtests/src/rmrk/mintNft.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import {getApiConnection} from '../substrate/substrate-api';2import {getApiConnection} from '../substrate/substrate-api';
3import { getModuleNames, Pallets } from '../util/helpers';
3import {getNft} from './util/fetch';4import {getNft} from './util/fetch';
4import {expectTxFailure} from './util/helpers';5import {expectTxFailure} from './util/helpers';
5import {createCollection, mintNft} from './util/tx';6import {createCollection, mintNft} from './util/tx';
67
7describe('integration test: mint new NFT', () => {8describe('integration test: mint new NFT', () => {
8 let api: any;9 let api: any;
10
9 before(async () => { api = await getApiConnection(); });11 before(async function () {
12 api = await getApiConnection();
13 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
14 });
15
1016
modifiedtests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth
8} from './util/tx';8} from './util/tx';
9import {getChildren, NftIdTuple} from './util/fetch';9import {getChildren, NftIdTuple} from './util/fetch';
10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
11import { getModuleNames, Pallets } from '../util/helpers';
1112
12describe('integration test: reject NFT', () => {13describe('integration test: reject NFT', () => {
13 let api: any;14 let api: any;
14 before(async () => { api = await getApiConnection(); });15 before(async function () {
16 api = await getApiConnection();
17 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
18 });
19
20
modifiedtests/src/rmrk/removeResource.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import privateKey from '../substrate/privateKey';2import privateKey from '../substrate/privateKey';
3import {executeTransaction, getApiConnection} from '../substrate/substrate-api';3import {executeTransaction, getApiConnection} from '../substrate/substrate-api';
4import { getModuleNames, Pallets } from '../util/helpers';
4import {getNft, NftIdTuple} from './util/fetch';5import {getNft, NftIdTuple} from './util/fetch';
5import {expectTxFailure} from './util/helpers';6import {expectTxFailure} from './util/helpers';
6import {7import {
16describe('Integration test: remove nft resource', () => {17describe('Integration test: remove nft resource', () => {
17 let api: any;18 let api: any;
18 let ss58Format: string;19 let ss58Format: string;
19 before(async () => {20 before(async function() {
20 api = await getApiConnection();21 api = await getApiConnection();
21 ss58Format = api.registry.getChainProperties()!.toJSON().ss58Format;22 ss58Format = api.registry.getChainProperties()!.toJSON().ss58Format;
23 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
22 });24 });
2325
24 const Alice = '//Alice';26 const Alice = '//Alice';
modifiedtests/src/rmrk/rmrkIsolation.test.tsdiffbeforeafterboth
6 getCreateCollectionResult,6 getCreateCollectionResult,
7 getDetailedCollectionInfo,7 getDetailedCollectionInfo,
8 getGenericResult,8 getGenericResult,
9 getModuleNames,
9 normalizeAccountId,10 normalizeAccountId,
11 Pallets,
10} from '../util/helpers';12} from '../util/helpers';
11import {IKeyringPair} from '@polkadot/types/types';13import {IKeyringPair} from '@polkadot/types/types';
12import {ApiPromise} from '@polkadot/api';14import {ApiPromise} from '@polkadot/api';
59describe('RMRK External Integration Test', async () => {61describe('RMRK External Integration Test', async () => {
60 const it_rmrk = (await isUnique() ? it : it.skip);62 const it_rmrk = (await isUnique() ? it : it.skip);
6163
62 before(async () => {64 before(async function() {
63 await usingApi(async (api, privateKeyWrapper) => {65 await usingApi(async (api, privateKeyWrapper) => {
64 alice = privateKeyWrapper('//Alice');66 alice = privateKeyWrapper('//Alice');
6567 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
66
67 });68 });
68 });69 });
modifiedtests/src/rmrk/sendNft.test.tsdiffbeforeafterboth
3import {createCollection, mintNft, sendNft} from './util/tx';3import {createCollection, mintNft, sendNft} from './util/tx';
4import {NftIdTuple} from './util/fetch';4import {NftIdTuple} from './util/fetch';
5import {isNftChildOfAnother, expectTxFailure} from './util/helpers';5import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
6import { getModuleNames, Pallets } from '../util/helpers';
67
7describe('integration test: send NFT', () => {8describe('integration test: send NFT', () => {
8 let api: any;9 let api: any;
9 before(async () => { api = await getApiConnection(); });10 before(async function () {
11 api = await getApiConnection();
12 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
13 });
1014
11 const maxNftId = 0xFFFFFFFF;15 const maxNftId = 0xFFFFFFFF;
modifiedtests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';
2import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
3import {createCollection, setPropertyCollection} from './util/tx';4import {createCollection, setPropertyCollection} from './util/tx';
45
7 const Bob = '//Bob';8 const Bob = '//Bob';
89
9 let api: any;10 let api: any;
10 before(async () => {11 before(async function () {
11 api = await getApiConnection();12 api = await getApiConnection();
13 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
12 });14 });
1315
14 it('set collection property', async () => {16 it('set collection property', async () => {
modifiedtests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';
2import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
3import {createCollection, createBase, setEquippableList} from './util/tx';4import {createCollection, createBase, setEquippableList} from './util/tx';
45
5describe("integration test: set slot's Equippable List", () => {6describe("integration test: set slot's Equippable List", () => {
6 let api: any;7 let api: any;
7 before(async () => { api = await getApiConnection(); });8 before(async function () {
9 api = await getApiConnection();
10 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
11 });
812
9 const alice = '//Alice';13 const alice = '//Alice';
modifiedtests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';
2import {NftIdTuple} from './util/fetch';3import {NftIdTuple} from './util/fetch';
3import {expectTxFailure} from './util/helpers';4import {expectTxFailure} from './util/helpers';
4import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';5import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';
56
6describe('integration test: set NFT property', () => {7describe('integration test: set NFT property', () => {
7 let api: any;8 let api: any;
8 before(async () => { api = await getApiConnection(); });9 before(async function () {
10 api = await getApiConnection();
11 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
12 });
913
10 const alice = '//Alice';14 const alice = '//Alice';
modifiedtests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';
2import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
3import {mintNft, createCollection, setResourcePriorities} from './util/tx';4import {mintNft, createCollection, setResourcePriorities} from './util/tx';
45
5describe('integration test: set NFT resource priorities', () => {6describe('integration test: set NFT resource priorities', () => {
6 let api: any;7 let api: any;
7 before(async () => { api = await getApiConnection(); });8 before(async function () {
9 api = await getApiConnection();
10 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
11 });
812
9 const alice = '//Alice';13 const alice = '//Alice';
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
39};39};
40
41
42export enum Pallets {
43 Inflation = 'inflation',
44 RmrkCore = 'rmrkcore',
45 ReFungible = 'refungible',
46 Fungible = 'fungible',
47 NFT = 'nonfungible',
48}
49
50export async function isUnique(): Promise<boolean> {
51 return usingApi(async api => {
52 const chain = await api.rpc.system.chain();
53
54 return chain.eq('UNIQUE');
55 });
56}
57
58export async function isQuartz(): Promise<boolean> {
59 return usingApi(async api => {
60 const chain = await api.rpc.system.chain();
61
62 return chain.eq('QUARTZ');
63 });
64}
65
66let modulesNames: any;
67export function getModuleNames(api: ApiPromise): string[] {
68 if (typeof modulesNames === 'undefined')
69 modulesNames = api.runtimeMetadata.asLatest.pallets.map(m => m.name.toString().toLowerCase());
70 return modulesNames;
71}
4072
41export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {73export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {
42 if (typeof input === 'string') {74 if (typeof input === 'string') {