dapp_staking_runtime_api/lib.rs
1// This file is part of Astar.
2
3// Copyright (C) Stake Technologies Pte.Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later
5
6// Astar is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// Astar is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with Astar. If not, see <http://www.gnu.org/licenses/>.
18
19#![cfg_attr(not(feature = "std"), no_std)]
20
21#[allow(unused_imports)]
22use astar_primitives::dapp_staking::TierId;
23use astar_primitives::dapp_staking::{DAppId, EraNumber, PeriodNumber, RankedTier};
24use astar_primitives::BlockNumber;
25pub use sp_std::collections::btree_map::BTreeMap;
26
27sp_api::decl_runtime_apis! {
28
29 /// dApp Staking Api.
30 ///
31 /// Used to provide information otherwise not available via RPC.
32 #[api_version(2)]
33 pub trait DappStakingApi {
34
35 /// How many periods are there in one cycle.
36 fn periods_per_cycle() -> PeriodNumber;
37
38 /// For how many standard era lengths does the voting subperiod last.
39 fn eras_per_voting_subperiod() -> EraNumber;
40
41 /// How many standard eras are there in the build&earn subperiod.
42 fn eras_per_build_and_earn_subperiod() -> EraNumber;
43
44 /// How many blocks are there per standard era.
45 fn blocks_per_era() -> BlockNumber;
46
47 /// Get dApp tier assignment for the given dApp.
48 #[changed_in(2)]
49 fn get_dapp_tier_assignment() -> BTreeMap<DAppId, TierId>;
50
51 /// Get dApp ranked tier assignment for the given dApp.
52 fn get_dapp_tier_assignment() -> BTreeMap<DAppId, RankedTier>;
53 }
54}