1
// Copyright (C) Moondance Labs Ltd.
2
// This file is part of Tanssi.
3

            
4
// Tanssi is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Tanssi is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Tanssi.  If not, see <http://www.gnu.org/licenses/>
16

            
17
//! Runtime API for DataPreservers pallet
18

            
19
#![cfg_attr(not(feature = "std"), no_std)]
20

            
21
extern crate alloc;
22

            
23
use {
24
    parity_scale_codec::{Decode, Encode},
25
    serde::{Deserialize, Serialize},
26
};
27

            
28
#[derive(
29
1584
    Debug, Copy, Clone, PartialEq, Eq, Encode, Decode, scale_info::TypeInfo, Serialize, Deserialize,
30
)]
31
pub enum Assignment<ParaId> {
32
    /// Profile is not currently assigned.
33
    NotAssigned,
34
    /// Profile is activly assigned to this ParaId.
35
    Active(ParaId),
36
    /// Profile is assigned to this ParaId but is inactive for some reason.
37
    /// It may be causes by conditions defined in the assignement configuration,
38
    /// such as lacking payment.
39
    Inactive(ParaId),
40
}
41

            
42
618
sp_api::decl_runtime_apis! {
43
618
    pub trait DataPreserversApi<ProfileId, ParaId>
44
618
    where
45
618
        ProfileId: parity_scale_codec::Codec,
46
618
        ParaId: parity_scale_codec::Codec,
47
618
    {
48
618
        /// Get the active assignment for this profile id.
49
618
        fn get_active_assignment(
50
618
            profile_id: ProfileId,
51
618
        ) -> Assignment<ParaId>;
52
618
    }
53
618
}