git.delta.rocks / unique-network / refs/commits / 4186437dc1bc

difftreelog

feat add rmrk proxy create_base

Daniel Shiposha2022-05-25parent: #e8a3a23.patch.diff
in: master

12 files changed

modifiedCargo.lockdiffbeforeafterboth
5513 "pallet-randomness-collective-flip",5513 "pallet-randomness-collective-flip",
5514 "pallet-refungible",5514 "pallet-refungible",
5515 "pallet-rmrk-core",5515 "pallet-rmrk-core",
5516 "pallet-rmrk-equip",
5516 "pallet-structure",5517 "pallet-structure",
5517 "pallet-sudo",5518 "pallet-sudo",
5518 "pallet-template-transaction-payment",5519 "pallet-template-transaction-payment",
6532 "up-data-structs",6533 "up-data-structs",
6533]6534]
6535
6536[[package]]
6537name = "pallet-rmrk-equip"
6538version = "0.1.0"
6539dependencies = [
6540 "frame-benchmarking",
6541 "frame-support",
6542 "frame-system",
6543 "pallet-common",
6544 "pallet-evm",
6545 "pallet-nonfungible",
6546 "pallet-rmrk-core",
6547 "parity-scale-codec 3.1.2",
6548 "scale-info",
6549 "sp-core",
6550 "sp-runtime",
6551 "sp-std",
6552 "up-data-structs",
6553]
65346554
6535[[package]]6555[[package]]
6536name = "pallet-scheduler"6556name = "pallet-scheduler"
modifiedpallets/proxy-rmrk-core/Cargo.tomldiffbeforeafterboth
18sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }18sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
19pallet-common = { default-features = false, path = '../common' }19pallet-common = { default-features = false, path = '../common' }
20pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }20pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
21# pallet-structure = { default-features = false, path = '../structure' }
22up-data-structs = { default-features = false, path = '../../primitives/data-structs' }21up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
23# evm-coder = { default-features = false, path = '../../crates/evm-coder' }
24# pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
25pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }22pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" }
26frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }23frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" }
27scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }24scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
37 "pallet-common/std",34 "pallet-common/std",
38 "pallet-nonfungible/std",35 "pallet-nonfungible/std",
39 "pallet-evm/std",36 "pallet-evm/std",
40 # "pallet-structure/std",
41 # "evm-coder/std",
42 # "pallet-evm-coder-substrate/std",
43 'frame-benchmarking/std',37 'frame-benchmarking/std',
44]38]
45runtime-benchmarks = [39runtime-benchmarks = [
modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
254 });254 });
255255
256 let nft_id = Self::create_nft(256 let nft_id = Self::create_nft(
257 sender,257 &sender,
258 cross_owner,258 &cross_owner,
259 collection_id.into(),259 collection_id.into(),
260 CollectionType::Regular,260 CollectionType::Regular,
261 NftType::Regular,261 NftType::Regular,
302}302}
303303
304impl<T: Config> Pallet<T> {304impl<T: Config> Pallet<T> {
305 fn create_nft(305 pub fn create_nft(
306 sender: T::CrossAccountId,306 sender: &T::CrossAccountId,
307 owner: T::CrossAccountId,307 owner: &T::CrossAccountId,
308 collection_id: CollectionId,308 collection_id: CollectionId,
309 collection_type: CollectionType,309 collection_type: CollectionType,
310 nft_type: NftType,310 nft_type: NftType,
320 .try_into()320 .try_into()
321 .map_err(|_| <Error<T>>::NftTypeEncodeError)?,321 .map_err(|_| <Error<T>>::NftTypeEncodeError)?,
322 properties: BoundedVec::default(),322 properties: BoundedVec::default(),
323 owner,323 owner: owner.clone(),
324 };324 };
325325
326 let budget = budget::Value::new(2);326 let budget = budget::Value::new(2);
327327
328 <PalletNft<T>>::create_item(328 <PalletNft<T>>::create_item(
329 &collection,329 &collection,
330 &sender,330 sender,
331 data,331 data,
332 &budget,332 &budget,
333 ).map_err(Self::map_common_err_to_proxy)?;333 ).map_err(Self::map_common_err_to_proxy)?;
modifiedpallets/proxy-rmrk-core/src/property.rsdiffbeforeafterboth
19 Thumb,19 Thumb,
20 EquippedNft,20 EquippedNft,
21 BaseType,21 BaseType,
22 // // RmrkPartId(/* Id type? */)22 ExternalPartId,
23 EquippableList,23 EquippableList,
24 ZIndex,24 ZIndex,
25 ThemeName,25 ThemeName,
62 Self::Thumb => key!("thumb"),62 Self::Thumb => key!("thumb"),
63 Self::EquippedNft => key!("equipped-nft"),63 Self::EquippedNft => key!("equipped-nft"),
64 Self::BaseType => key!("base-type"),64 Self::BaseType => key!("base-type"),
65 // RmrkResourceId(/* Id type? */)65 Self::ExternalPartId => key!("ext-part-id"),
66 // RmrkPartId(/* Id type? */)
67 Self::EquippableList => key!("equippable-list"),66 Self::EquippableList => key!("equippable-list"),
68 Self::ZIndex => key!("z-index"),67 Self::ZIndex => key!("z-index"),
69 Self::ThemeName => key!("theme-name"),68 Self::ThemeName => key!("theme-name"),
addedpallets/proxy-rmrk-equip/Cargo.tomldiffbeforeafterboth

no changes

addedpallets/proxy-rmrk-equip/src/lib.rsdiffbeforeafterboth

no changes

modifiedprimitives/data-structs/src/rmrk.rsdiffbeforeafterboth
416 SlotPart(SlotPart<BoundedString, BoundedCollectionList>),416 SlotPart(SlotPart<BoundedString, BoundedCollectionList>),
417}417}
418
419impl<BoundedString, BoundedCollectionList> PartType<BoundedString, BoundedCollectionList> {
420 pub fn id(&self) -> PartId {
421 match self {
422 Self::FixedPart(part) => part.id,
423 Self::SlotPart(part) => part.id
424 }
425 }
426
427 pub fn src(&self) -> &BoundedString {
428 match self {
429 Self::FixedPart(part) => &part.src,
430 Self::SlotPart(part) => &part.src
431 }
432 }
433
434 pub fn z_index(&self) -> ZIndex {
435 match self {
436 Self::FixedPart(part) => part.z,
437 Self::SlotPart(part) => part.z
438 }
439 }
440}
418441
419#[cfg_attr(feature = "std", derive(Eq, Serialize))]442#[cfg_attr(feature = "std", derive(Eq, Serialize))]
420#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]443#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
347347
348 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {348 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
349 use frame_support::BoundedVec;349 use frame_support::BoundedVec;
350 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, RmrkNft, RmrkDecode}};350 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, RmrkNft, RmrkDecode}};
351351
352 let collection_id = CollectionId(base_id);352 let collection_id = CollectionId(base_id);
353 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() { return Ok(Vec::new()); }353 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Base).is_err() { return Ok(Vec::new()); }
354354
355 let parts = (dispatch_unique_runtime!(collection_id.collection_tokens()) as Result<Vec<TokenId>, DispatchError>)?355 let parts = (dispatch_unique_runtime!(collection_id.collection_tokens()))?
356 .iter()356 .into_iter()
357 .filter_map(|token_id| {357 .filter_map(|token_id| {
358 let nft_type = RmrkCore::get_nft_type(collection_id, *token_id).unwrap();358 let nft_type = RmrkCore::get_nft_type(collection_id, token_id).ok()?;
359359
360 match nft_type {360 match nft_type {
361 FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {361 NftType::FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {
362 id: token_id.0,362 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),
363 src: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::Src).unwrap().decode_or_default(),363 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),
364 z: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::ZIndex).unwrap().decode_or_default(),364 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),
365 })),365 })),
366 SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {366 NftType::SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {
367 id: token_id.0,367 id: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?.decode_or_default(),
368 src: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::Src).unwrap().decode_or_default(),368 src: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::Src).ok()?.decode_or_default(),
369 z: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::ZIndex).unwrap().decode_or_default(),369 z: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::ZIndex).ok()?.decode_or_default(),
370 equippable: RmrkCore::get_nft_property(collection_id, *token_id, RmrkProperty::EquippableList).unwrap().decode_or_default(),370 equippable: RmrkCore::get_nft_property(collection_id, token_id, RmrkProperty::EquippableList).ok()?.decode_or_default(),
371 })),371 })),
372 _ => None372 _ => None
373 }373 }
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
91 'pallet-refungible/std',91 'pallet-refungible/std',
92 'pallet-nonfungible/std',92 'pallet-nonfungible/std',
93 'pallet-proxy-rmrk-core/std',93 'pallet-proxy-rmrk-core/std',
94 'pallet-proxy-rmrk-equip/std',
94 'pallet-unique/std',95 'pallet-unique/std',
95 'pallet-unq-scheduler/std',96 'pallet-unq-scheduler/std',
96 'pallet-charge-transaction/std',97 'pallet-charge-transaction/std',
410pallet-refungible = { default-features = false, path = "../../pallets/refungible" }411pallet-refungible = { default-features = false, path = "../../pallets/refungible" }
411pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }412pallet-nonfungible = { default-features = false, path = "../../pallets/nonfungible" }
412pallet-proxy-rmrk-core = { default-features = false, path = "../../pallets/proxy-rmrk-core", package = "pallet-rmrk-core" }413pallet-proxy-rmrk-core = { default-features = false, path = "../../pallets/proxy-rmrk-core", package = "pallet-rmrk-core" }
414pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }
413pallet-unq-scheduler = { path = '../../pallets/scheduler', default-features = false }415pallet-unq-scheduler = { path = '../../pallets/scheduler', default-features = false }
414# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }416# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
415pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }417pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
906 type Event = Event;906 type Event = Event;
907}907}
908
909impl pallet_proxy_rmrk_equip::Config for Runtime {
910 type Event = Event;
911}
908912
909impl pallet_unique::Config for Runtime {913impl pallet_unique::Config for Runtime {
910 type Event = Event;914 type Event = Event;
1019 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1023 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
1020 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1024 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
1021 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1025 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1026 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
10221027
1023 // Frontier1028 // Frontier
1024 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1029 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
880 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;880 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
881}881}
882
883impl pallet_proxy_rmrk_core::Config for Runtime {
884 type Event = Event;
885}
886
887impl pallet_proxy_rmrk_equip::Config for Runtime {
888 type Event = Event;
889}
882890
883impl pallet_unique::Config for Runtime {891impl pallet_unique::Config for Runtime {
884 type Event = Event;892 type Event = Event;
992 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1000 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
993 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1001 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
994 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1002 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1003 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
9951004
996 // Frontier1005 // Frontier
997 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1006 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
884 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;884 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
885}885}
886
887impl pallet_proxy_rmrk_core::Config for Runtime {
888 type Event = Event;
889}
890
891impl pallet_proxy_rmrk_equip::Config for Runtime {
892 type Event = Event;
893}
886894
887impl pallet_unique::Config for Runtime {895impl pallet_unique::Config for Runtime {
888 type Event = Event;896 type Event = Event;
997 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1005 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
998 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1006 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
999 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1007 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
1008 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
10001009
1001 // Frontier1010 // Frontier
1002 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1011 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,