1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use frame_support::pallet_prelude::*;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
use scale_info::TypeInfo;
pub type CollectionId = u128;
pub type ItemId = u128;
#[derive(Encode, Decode, Eq, PartialEq, Clone, RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct CollectionInfo<CollectionType, BoundedVec> {
pub collection_type: CollectionType,
pub metadata: BoundedVec,
}
#[derive(Encode, Decode, Eq, Copy, PartialEq, Clone, RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct ItemInfo<BoundedVec> {
pub metadata: BoundedVec,
}
#[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum CollectionType {
Marketplace = 0_isize,
LiquidityMining = 1_isize,
}
impl Default for CollectionType {
fn default() -> Self {
CollectionType::Marketplace
}
}
pub trait NftPermission<InnerCollectionType> {
fn can_create(collection_type: &InnerCollectionType) -> bool;
fn can_mint(collection_type: &InnerCollectionType) -> bool;
fn can_transfer(collection_type: &InnerCollectionType) -> bool;
fn can_burn(collection_type: &InnerCollectionType) -> bool;
fn can_destroy(collection_type: &InnerCollectionType) -> bool;
fn has_deposit(collection_type: &InnerCollectionType) -> bool;
}
#[derive(Encode, Decode, Eq, Copy, PartialEq, Clone, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct NftPermissions;
impl NftPermission<CollectionType> for NftPermissions {
fn can_create(collection_type: &CollectionType) -> bool {
matches!(*collection_type, CollectionType::Marketplace)
}
fn can_mint(collection_type: &CollectionType) -> bool {
matches!(*collection_type, CollectionType::Marketplace)
}
fn can_transfer(collection_type: &CollectionType) -> bool {
matches!(
*collection_type,
CollectionType::Marketplace | CollectionType::LiquidityMining
)
}
fn can_burn(collection_type: &CollectionType) -> bool {
matches!(*collection_type, CollectionType::Marketplace)
}
fn can_destroy(collection_type: &CollectionType) -> bool {
matches!(*collection_type, CollectionType::Marketplace)
}
fn has_deposit(collection_type: &CollectionType) -> bool {
matches!(*collection_type, CollectionType::Marketplace)
}
}