Skip to main content

pallet_encointer_communities_rpc_runtime_api/
lib.rs

1// Copyright (c) 2019 Alain Brenzikofer
2// This file is part of Encointer
3//
4// Encointer 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// Encointer 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 Encointer.  If not, see <http://www.gnu.org/licenses/>.
16
17//! Runtime API definition required by Communities RPC extensions.
18
19#![cfg_attr(not(feature = "std"), no_std)]
20
21#[cfg(not(feature = "std"))]
22use sp_std::vec::Vec;
23
24use encointer_primitives::{
25	balances::BalanceEntry,
26	common::PalletString,
27	communities::{CommunityIdentifier, Location},
28};
29use parity_scale_codec::{Decode, Encode};
30
31sp_api::decl_runtime_apis! {
32
33	pub trait CommunitiesApi<AccountId, BlockNumber>
34		where AccountId: Encode + Decode,
35		BlockNumber: Encode + Decode{
36
37		fn get_cids() -> Vec<CommunityIdentifier>;
38		fn get_name(cid: &CommunityIdentifier) -> Option<PalletString>;
39		fn get_locations(cid: &CommunityIdentifier) -> Vec<Location>;
40		fn get_all_balances(account: &AccountId) -> Vec<(CommunityIdentifier, BalanceEntry<BlockNumber>)>;
41	}
42}