-
Notifications
You must be signed in to change notification settings - Fork 36
/
collection.rs
60 lines (53 loc) · 1.73 KB
/
collection.rs
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
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-substrate.
// License: Apache 2.0 modified by RMRK, see LICENSE.md
use codec::{Decode, Encode};
use frame_support::pallet_prelude::MaxEncodedLen;
use scale_info::TypeInfo;
use sp_runtime::{DispatchError, DispatchResult};
#[cfg(feature = "std")]
use serde::Serialize;
use crate::serialize;
use sp_std::result::Result;
/// Collection info.
#[cfg_attr(feature = "std", derive(PartialEq, Eq, Serialize))]
#[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
#[cfg_attr(
feature = "std",
serde(bound = r#"
AccountId: Serialize,
BoundedString: AsRef<[u8]>,
BoundedSymbol: AsRef<[u8]>
"#)
)]
pub struct CollectionInfo<BoundedString, BoundedSymbol, AccountId> {
/// Current bidder and bid price.
pub issuer: AccountId,
#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]
pub metadata: BoundedString,
pub max: Option<u32>,
#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]
pub symbol: BoundedSymbol,
pub nfts_count: u32,
}
/// Abstraction over a Collection system.
#[allow(clippy::upper_case_acronyms)]
pub trait Collection<BoundedString, BoundedSymbol, AccountId, CollectionId> {
fn issuer(collection_id: CollectionId) -> Option<AccountId>;
fn collection_create(
issuer: AccountId,
collection_id: CollectionId,
metadata: BoundedString,
max: Option<u32>,
symbol: BoundedSymbol,
) -> Result<(), DispatchError>;
fn collection_burn(issuer: AccountId, collection_id: CollectionId) -> DispatchResult;
fn collection_change_issuer(
collection_id: CollectionId,
new_issuer: AccountId,
) -> Result<(AccountId, CollectionId), DispatchError>;
fn collection_lock(
sender: AccountId,
collection_id: CollectionId,
) -> Result<CollectionId, DispatchError>;
}