@@ -3,13 +3,14 @@ use super::*;
33use frame_support:: pallet_prelude:: * ;
44
55use frame_support:: sp_io:: hashing:: blake2_256;
6+ use sp_runtime:: Permill ;
67use sp_runtime:: sp_std:: vec:: Vec ;
78
89pub type AttributeKey < T > = BoundedVec < u8 , <T as pallet_uniques:: Config >:: KeyLimit > ;
910pub type AttributeValue < T > = BoundedVec < u8 , <T as pallet_uniques:: Config >:: ValueLimit > ;
1011pub type Attributes < T > = Vec < ( AttributeKey < T > , AttributeValue < T > ) > ;
1112
12- pub type CollectionDescription = [ u8 ; 32 ] ;
13+ pub type CollectionDescription = [ u8 ; 32 ] ;
1314pub type StringLimit < T > = BoundedVec < u8 , <T as pallet_uniques:: Config >:: StringLimit > ;
1415
1516pub type CollectionId = u32 ;
@@ -18,21 +19,19 @@ pub type ItemId = u32;
1819pub type HierarchicalInfo = ( ItemId , bool ) ;
1920
2021#[ derive( CloneNoBound , Encode , Decode , RuntimeDebugNoBound , Default , TypeInfo , MaxEncodedLen ) ]
21- pub struct FruniqueChild {
22- pub child_id : ItemId ,
22+ pub struct ChildInfo {
2323 pub collection_id : CollectionId ,
24+ pub child_id : ItemId ,
2425 pub is_hierarchical : bool ,
25- pub weight : u32 ,
26+ pub weight : Permill ,
2627}
2728
28- pub type ChildrenInfo = BoundedVec < FruniqueChild , T :: ChildMaxLen > ;
29-
3029#[ derive( CloneNoBound , Encode , Decode , RuntimeDebugNoBound , TypeInfo , MaxEncodedLen ) ]
3130#[ scale_info( skip_type_params( T ) ) ]
3231#[ codec( mel_bound( ) ) ]
33- pub struct FruniqueInheritance {
32+ pub struct FruniqueInheritance < T : Config > {
3433 pub parent : ( CollectionId , ItemId ) ,
35- pub children : ChildrenInfo ,
34+ pub children : BoundedVec < ChildInfo , T :: ChildMaxLen > ,
3635}
3736
3837#[ derive(
@@ -84,6 +83,8 @@ pub enum Permission {
8483 Mint ,
8584 /// Authorization required and must be approved by a holder / collector
8685 Transfer ,
86+ /// Allow a user to collaborate on a collection
87+ Collaborate ,
8788}
8889
8990impl Permission {
@@ -93,33 +94,40 @@ impl Permission {
9394 Self :: Required => "Required" . as_bytes ( ) . to_vec ( ) ,
9495 Self :: Mint => "Mint" . as_bytes ( ) . to_vec ( ) ,
9596 Self :: Transfer => "Transfer" . as_bytes ( ) . to_vec ( ) ,
97+ Self :: Collaborate => "Collaborate" . as_bytes ( ) . to_vec ( ) ,
9698 }
9799 }
98100
99101 pub fn id ( & self ) -> [ u8 ; 32 ] {
100102 self . to_vec ( ) . using_encoded ( blake2_256)
101103 }
102104
105+ pub fn owner_permissions ( ) -> Vec < Vec < u8 > > {
106+ use crate :: types:: Permission :: * ;
107+ [ None . to_vec ( ) , Required . to_vec ( ) , Mint . to_vec ( ) , Transfer . to_vec ( ) ] . to_vec ( )
108+ }
109+
103110 pub fn admin_permissions ( ) -> Vec < Vec < u8 > > {
104111 use crate :: types:: Permission :: * ;
105112 let mut admin_permissions = [
106113 None . to_vec ( ) ,
107114 Required . to_vec ( ) ,
108115 Mint . to_vec ( ) ,
109116 Transfer . to_vec ( ) ,
117+ Collaborate . to_vec ( ) ,
110118 ]
111119 . to_vec ( ) ;
112120 admin_permissions. append ( & mut Permission :: holder_permissions ( ) ) ;
113121 admin_permissions
114122 }
115123
124+ pub fn collaborator_permissions ( ) -> Vec < Vec < u8 > > {
125+ use crate :: types:: Permission :: * ;
126+ [ Mint . to_vec ( ) ] . to_vec ( )
127+ }
128+
116129 pub fn holder_permissions ( ) -> Vec < Vec < u8 > > {
117130 use crate :: types:: Permission :: * ;
118- [
119- None . to_vec ( ) ,
120- Required . to_vec ( ) ,
121- Transfer . to_vec ( ) ,
122- ]
123- . to_vec ( )
131+ [ None . to_vec ( ) , Required . to_vec ( ) , Transfer . to_vec ( ) ] . to_vec ( )
124132 }
125133}
0 commit comments