Skip to content

Commit 771f3c4

Browse files
committed
add new datatypes
1 parent 3c6b02b commit 771f3c4

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

pallets/fruniques/src/lib.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ mod functions;
1717
#[frame_support::pallet]
1818
pub mod pallet {
1919
use super::*;
20-
use frame_support::{pallet_prelude::*, traits::tokens::nonfungibles::Inspect, BoundedVec, transactional};
20+
use frame_support::{pallet_prelude::*, BoundedVec, transactional};
2121
use frame_system::pallet_prelude::*;
2222
use scale_info::prelude::vec::Vec;
23-
use sp_runtime::{traits::StaticLookup, Permill};
23+
use sp_runtime::{Permill};
2424
use crate::types::*;
2525
/// Configure the pallet by specifying the parameters and types on which it depends.
2626
#[pallet::config]
@@ -112,6 +112,19 @@ pub mod pallet {
112112
ValueQuery
113113
>;
114114

115+
#[pallet::storage]
116+
#[pallet::getter(fn frunique_child)]
117+
/// Keeps track of hierarchical information for a frunique.
118+
pub(super) type FruniqueChild<T: Config> = StorageDoubleMap<
119+
_,
120+
Blake2_128Concat,
121+
CollectionId,
122+
Blake2_128Concat,
123+
ItemId, // FruniqueId
124+
Option<HierarchicalInfo>, // ParentId and flag if it inherit attributes
125+
ValueQuery
126+
>;
127+
115128

116129
#[pallet::call]
117130
impl<T: Config> Pallet<T>

pallets/fruniques/src/types.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,19 @@ pub type CollectionId = u32;
1212
pub type ItemId = u32;
1313

1414
pub type HierarchicalInfo = (ItemId, bool);
15+
16+
#[derive(CloneNoBound, Encode, Decode, RuntimeDebugNoBound, Default, TypeInfo, MaxEncodedLen)]
17+
pub struct FruniqueChild {
18+
pub child_id: ItemId,
19+
pub collection_id: CollectionId,
20+
pub is_hierarchical: bool,
21+
pub weight: u32,
22+
}
23+
24+
#[derive(CloneNoBound, Encode, Decode, RuntimeDebugNoBound, TypeInfo, MaxEncodedLen,)]
25+
#[scale_info(skip_type_params(T))]
26+
#[codec(mel_bound())]
27+
pub struct FruniqueInheritance<T: pallet_uniques::Config> {
28+
pub parent: Option<(CollectionId, ItemId)>,
29+
pub children: Vec<(CollectionId, ItemId)>,
30+
}

0 commit comments

Comments
 (0)