diff --git a/Cargo.lock b/Cargo.lock
index adff9e8b77..502b9e4ba8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -975,7 +975,6 @@ dependencies = [
"cumulus-primitives-core",
"cumulus-primitives-timestamp",
"cumulus-primitives-utility",
- "did-rpc-runtime-api",
"frame-benchmarking",
"frame-executive",
"frame-support",
@@ -984,6 +983,8 @@ dependencies = [
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal",
+ "kilt-runtime-api-did",
+ "kilt-runtime-api-public-credentials",
"log",
"pallet-aura",
"pallet-authorship",
@@ -1000,7 +1001,6 @@ dependencies = [
"parachain-info",
"parity-scale-codec",
"public-credentials",
- "public-credentials-runtime-api",
"runtime-common",
"scale-info",
"sp-api",
@@ -1999,18 +1999,6 @@ dependencies = [
"substrate-wasm-builder",
]
-[[package]]
-name = "did-rpc-runtime-api"
-version = "1.8.0"
-dependencies = [
- "did",
- "kilt-support",
- "parity-scale-codec",
- "scale-info",
- "sp-api",
- "sp-std",
-]
-
[[package]]
name = "digest"
version = "0.8.1"
@@ -3671,6 +3659,38 @@ dependencies = [
"xcm",
]
+[[package]]
+name = "kilt-runtime-api-did"
+version = "1.8.0"
+dependencies = [
+ "did",
+ "kilt-support",
+ "parity-scale-codec",
+ "scale-info",
+ "sp-api",
+ "sp-std",
+]
+
+[[package]]
+name = "kilt-runtime-api-public-credentials"
+version = "1.8.0"
+dependencies = [
+ "kilt-support",
+ "parity-scale-codec",
+ "sp-api",
+ "sp-std",
+]
+
+[[package]]
+name = "kilt-runtime-api-staking"
+version = "1.8.0"
+dependencies = [
+ "parity-scale-codec",
+ "scale-info",
+ "sp-api",
+ "sp-runtime",
+]
+
[[package]]
name = "kilt-support"
version = "1.8.0"
@@ -4633,7 +4653,6 @@ dependencies = [
"ctype",
"delegation",
"did",
- "did-rpc-runtime-api",
"frame-benchmarking",
"frame-executive",
"frame-support",
@@ -4642,6 +4661,8 @@ dependencies = [
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal",
+ "kilt-runtime-api-did",
+ "kilt-runtime-api-public-credentials",
"kilt-support",
"log",
"pallet-aura",
@@ -4661,7 +4682,6 @@ dependencies = [
"pallet-web3-names",
"parity-scale-codec",
"public-credentials",
- "public-credentials-runtime-api",
"runtime-common",
"scale-info",
"sp-api",
@@ -6191,6 +6211,7 @@ dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
+ "kilt-runtime-api-staking",
"log",
"pallet-aura",
"pallet-authorship",
@@ -6200,7 +6221,6 @@ dependencies = [
"parity-scale-codec",
"scale-info",
"serde",
- "sp-api",
"sp-consensus-aura",
"sp-core",
"sp-io",
@@ -6410,7 +6430,6 @@ dependencies = [
"cumulus-primitives-utility",
"delegation",
"did",
- "did-rpc-runtime-api",
"frame-benchmarking",
"frame-executive",
"frame-support",
@@ -6419,6 +6438,9 @@ dependencies = [
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal",
+ "kilt-runtime-api-did",
+ "kilt-runtime-api-public-credentials",
+ "kilt-runtime-api-staking",
"kilt-support",
"log",
"pallet-aura",
@@ -6449,7 +6471,6 @@ dependencies = [
"parachain-staking",
"parity-scale-codec",
"public-credentials",
- "public-credentials-runtime-api",
"runtime-common",
"scale-info",
"sp-api",
@@ -7945,16 +7966,6 @@ dependencies = [
"sp-std",
]
-[[package]]
-name = "public-credentials-runtime-api"
-version = "1.8.0"
-dependencies = [
- "kilt-support",
- "parity-scale-codec",
- "sp-api",
- "sp-std",
-]
-
[[package]]
name = "quick-error"
version = "1.2.3"
@@ -10761,7 +10772,6 @@ dependencies = [
"cumulus-primitives-utility",
"delegation",
"did",
- "did-rpc-runtime-api",
"frame-benchmarking",
"frame-executive",
"frame-support",
@@ -10770,6 +10780,9 @@ dependencies = [
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal",
+ "kilt-runtime-api-did",
+ "kilt-runtime-api-public-credentials",
+ "kilt-runtime-api-staking",
"kilt-support",
"log",
"pallet-aura",
@@ -10799,7 +10812,6 @@ dependencies = [
"parachain-staking",
"parity-scale-codec",
"public-credentials",
- "public-credentials-runtime-api",
"runtime-common",
"scale-info",
"sp-api",
@@ -11512,7 +11524,7 @@ version = "1.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if 0.1.10",
"digest 0.10.3",
"rand 0.8.5",
"static_assertions",
diff --git a/Cargo.toml b/Cargo.toml
index 1a0328249c..5f09411eb6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,8 +5,7 @@ panic = "unwind"
members = [
"nodes/*",
"pallets/*",
- "rpc/did/runtime-api",
- "rpc/public-credentials/runtime-api",
+ "runtime-api/*",
"runtimes/*",
"support",
"crates/*",
diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml
index 69bb2699ed..29fea9ea73 100644
--- a/pallets/parachain-staking/Cargo.toml
+++ b/pallets/parachain-staking/Cargo.toml
@@ -13,6 +13,8 @@ sp-core = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v
sp-io = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29"}
[dependencies]
+kilt-runtime-api-staking = {path = "../../runtime-api/staking", default-features = false}
+
log = "0.4.17"
parity-scale-codec = {version = "3.1.5", default-features = false, features = ["derive"]}
scale-info = {version = "2.1.1", default-features = false, features = ["derive", "serde"]}
@@ -24,7 +26,6 @@ pallet-authorship = {git = "https://github.com/paritytech/substrate", branch = "
pallet-balances = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29", default-features = false}
pallet-session = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29", default-features = false}
sp-runtime = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29", default-features = false}
-sp-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29", default-features = false}
sp-staking = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29", default-features = false}
sp-std = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29", default-features = false}
@@ -41,6 +42,7 @@ runtime-benchmarks = [
std = [
"frame-support/std",
"frame-system/std",
+ "kilt-runtime-api-staking/std",
"log/std",
"pallet-authorship/std",
"pallet-balances/std",
@@ -48,7 +50,6 @@ std = [
"parity-scale-codec/std",
"scale-info/std",
"serde",
- "sp-api/std",
"sp-runtime/std",
"sp-staking/std",
"sp-std/std",
diff --git a/pallets/parachain-staking/src/api.rs b/pallets/parachain-staking/src/api.rs
new file mode 100644
index 0000000000..082e68e9f7
--- /dev/null
+++ b/pallets/parachain-staking/src/api.rs
@@ -0,0 +1,89 @@
+// KILT Blockchain – https://botlabs.org
+// Copyright (C) 2019-2022 BOTLabs GmbH
+
+// The KILT Blockchain is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// The KILT Blockchain is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+// If you feel like getting in touch with us, you can do so at info@botlabs.org
+
+use crate::{
+ types::BalanceOf, BlocksAuthored, BlocksRewarded, CandidatePool, Config, DelegatorState, InflationConfig, Pallet,
+ Rewards, TotalCollatorStake,
+};
+use frame_support::traits::Currency;
+use sp_runtime::{
+ traits::{Saturating, Zero},
+ Perquintill,
+};
+
+impl Pallet {
+ /// Calculates the staking rewards for a given account address.
+ ///
+ /// Subtracts the number of rewarded blocks from the number of authored
+ /// blocks by the collator and multiplies that with the current stake
+ /// as well as reward rate.
+ ///
+ /// At least used in Runtime API.
+ pub fn get_unclaimed_staking_rewards(acc: &T::AccountId) -> BalanceOf {
+ let count_rewarded = BlocksRewarded::::get(acc);
+ let rewards = Rewards::::get(acc);
+
+ // delegators and collators need to be handled differently
+ if let Some(delegator_state) = DelegatorState::::get(acc) {
+ // #blocks for unclaimed staking rewards equals
+ // #blocks_authored_by_collator - #blocks_claimed_by_delegator
+ let count_unclaimed = BlocksAuthored::::get(&delegator_state.owner).saturating_sub(count_rewarded);
+ let stake = delegator_state.amount;
+ // rewards += stake * reward_count * delegator_reward_rate
+ rewards.saturating_add(Self::calc_block_rewards_delegator(stake, count_unclaimed.into()))
+ } else if Self::is_active_candidate(acc).is_some() {
+ // #blocks for unclaimed staking rewards equals
+ // #blocks_authored_by_collator - #blocks_claimed_by_collator
+ let count_unclaimed = BlocksAuthored::::get(acc).saturating_sub(count_rewarded);
+ let stake = CandidatePool::::get(acc)
+ .map(|state| state.stake)
+ .unwrap_or_else(BalanceOf::::zero);
+ // rewards += stake * self_count * collator_reward_rate
+ rewards.saturating_add(Self::calc_block_rewards_collator(stake, count_unclaimed.into()))
+ } else {
+ BalanceOf::::zero()
+ }
+ }
+
+ /// Calculates the current staking and reward rates for collators and
+ /// delegators.
+ ///
+ /// At least used in Runtime API.
+ pub fn get_staking_rates() -> kilt_runtime_api_staking::StakingRates {
+ let total_issuance = T::Currency::total_issuance();
+ let total_stake = TotalCollatorStake::::get();
+ let inflation_config = InflationConfig::::get();
+ let collator_staking_rate = Perquintill::from_rational(total_stake.collators, total_issuance);
+ let delegator_staking_rate = Perquintill::from_rational(total_stake.delegators, total_issuance);
+ let collator_reward_rate = Perquintill::from_rational(
+ inflation_config.collator.max_rate.deconstruct(),
+ collator_staking_rate.deconstruct(),
+ ) * inflation_config.collator.reward_rate.annual;
+ let delegator_reward_rate = Perquintill::from_rational(
+ inflation_config.delegator.max_rate.deconstruct(),
+ delegator_staking_rate.deconstruct(),
+ ) * inflation_config.delegator.reward_rate.annual;
+
+ kilt_runtime_api_staking::StakingRates {
+ collator_staking_rate,
+ collator_reward_rate,
+ delegator_staking_rate,
+ delegator_reward_rate,
+ }
+ }
+}
diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs
index f8b82500ae..c899bcedb7 100644
--- a/pallets/parachain-staking/src/lib.rs
+++ b/pallets/parachain-staking/src/lib.rs
@@ -118,7 +118,6 @@
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;
pub mod default_weights;
-pub mod runtime_api;
pub mod migration;
#[cfg(test)]
@@ -126,6 +125,7 @@ pub(crate) mod mock;
#[cfg(test)]
pub(crate) mod tests;
+pub mod api;
mod inflation;
mod set;
mod types;
@@ -2379,7 +2379,7 @@ pub mod pallet {
///
/// Depends on the current total issuance and staking reward
/// configuration for collators.
- fn calc_block_rewards_collator(stake: BalanceOf, multiplier: BalanceOf) -> BalanceOf {
+ pub(crate) fn calc_block_rewards_collator(stake: BalanceOf, multiplier: BalanceOf) -> BalanceOf {
let total_issuance = T::Currency::total_issuance();
let TotalStake {
collators: total_collators,
@@ -2397,7 +2397,7 @@ pub mod pallet {
///
/// Depends on the current total issuance and staking reward
/// configuration for delegators.
- fn calc_block_rewards_delegator(stake: BalanceOf, multiplier: BalanceOf) -> BalanceOf {
+ pub(crate) fn calc_block_rewards_delegator(stake: BalanceOf, multiplier: BalanceOf) -> BalanceOf {
let total_issuance = T::Currency::total_issuance();
let TotalStake {
delegators: total_delegators,
@@ -2410,39 +2410,6 @@ pub mod pallet {
.compute_reward::(stake, staking_rate, multiplier)
}
- /// Calculates the staking rewards for a given account address.
- ///
- /// Subtracts the number of rewarded blocks from the number of authored
- /// blocks by the collator and multiplies that with the current stake
- /// as well as reward rate.
- ///
- /// At least used in Runtime API.
- pub fn get_unclaimed_staking_rewards(acc: &T::AccountId) -> BalanceOf {
- let count_rewarded = BlocksRewarded::::get(acc);
- let rewards = Rewards::::get(acc);
-
- // delegators and collators need to be handled differently
- if let Some(delegator_state) = DelegatorState::::get(acc) {
- // #blocks for unclaimed staking rewards equals
- // #blocks_authored_by_collator - #blocks_claimed_by_delegator
- let count_unclaimed = BlocksAuthored::::get(&delegator_state.owner).saturating_sub(count_rewarded);
- let stake = delegator_state.amount;
- // rewards += stake * reward_count * delegator_reward_rate
- rewards.saturating_add(Self::calc_block_rewards_delegator(stake, count_unclaimed.into()))
- } else if Self::is_active_candidate(acc).is_some() {
- // #blocks for unclaimed staking rewards equals
- // #blocks_authored_by_collator - #blocks_claimed_by_collator
- let count_unclaimed = BlocksAuthored::::get(acc).saturating_sub(count_rewarded);
- let stake = CandidatePool::::get(acc)
- .map(|state| state.stake)
- .unwrap_or_else(BalanceOf::::zero);
- // rewards += stake * self_count * collator_reward_rate
- rewards.saturating_add(Self::calc_block_rewards_collator(stake, count_unclaimed.into()))
- } else {
- BalanceOf::::zero()
- }
- }
-
/// Increment the accumulated rewards of a collator.
///
/// Updates Rewarded(col) and sets BlocksRewarded(col) to equal
@@ -2481,33 +2448,6 @@ pub mod pallet {
*reward = reward.saturating_add(Self::calc_block_rewards_delegator(stake, unclaimed_blocks.into()))
});
}
-
- /// Calculates the current staking and reward rates for collators and
- /// delegators.
- ///
- /// At least used in Runtime API.
- pub fn get_staking_rates() -> runtime_api::StakingRates {
- let total_issuance = T::Currency::total_issuance();
- let total_stake = TotalCollatorStake::::get();
- let inflation_config = InflationConfig::::get();
- let collator_staking_rate = Perquintill::from_rational(total_stake.collators, total_issuance);
- let delegator_staking_rate = Perquintill::from_rational(total_stake.delegators, total_issuance);
- let collator_reward_rate = Perquintill::from_rational(
- inflation_config.collator.max_rate.deconstruct(),
- collator_staking_rate.deconstruct(),
- ) * inflation_config.collator.reward_rate.annual;
- let delegator_reward_rate = Perquintill::from_rational(
- inflation_config.delegator.max_rate.deconstruct(),
- delegator_staking_rate.deconstruct(),
- ) * inflation_config.delegator.reward_rate.annual;
-
- runtime_api::StakingRates {
- collator_staking_rate,
- collator_reward_rate,
- delegator_staking_rate,
- delegator_reward_rate,
- }
- }
}
impl pallet_authorship::EventHandler for Pallet
diff --git a/pallets/parachain-staking/src/tests.rs b/pallets/parachain-staking/src/tests.rs
index a08805d1a4..bae1722226 100644
--- a/pallets/parachain-staking/src/tests.rs
+++ b/pallets/parachain-staking/src/tests.rs
@@ -24,6 +24,7 @@ use frame_support::{
assert_noop, assert_ok, storage::bounded_btree_map::BoundedBTreeMap, traits::EstimateNextSessionRotation,
BoundedVec,
};
+use kilt_runtime_api_staking::StakingRates;
use pallet_authorship::EventHandler;
use pallet_balances::{BalanceLock, Error as BalancesError, Reasons};
use pallet_session::{SessionManager, ShouldEndSession};
@@ -35,7 +36,6 @@ use crate::{
Event as MetaEvent, ExtBuilder, Origin, Session, StakePallet, System, Test, BLOCKS_PER_ROUND, DECIMALS,
TREASURY_ACC,
},
- runtime_api::StakingRates,
set::OrderedSet,
types::{
BalanceOf, Candidate, CandidateStatus, DelegationCounter, Delegator, RoundInfo, Stake, StakeOf, TotalStake,
diff --git a/rpc/did/runtime-api/Cargo.toml b/runtime-api/did/Cargo.toml
similarity index 75%
rename from rpc/did/runtime-api/Cargo.toml
rename to runtime-api/did/Cargo.toml
index 6740a7e149..bb8b5dee6f 100644
--- a/rpc/did/runtime-api/Cargo.toml
+++ b/runtime-api/did/Cargo.toml
@@ -1,20 +1,23 @@
[package]
edition = "2021"
-name = "did-rpc-runtime-api"
+name = "kilt-runtime-api-did"
version = "1.8.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
+# External dependencies
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
+# Internal dependencies
+did = {path = "../../pallets/did", default-features = false}
+kilt-support = {path = "../../support", default-features = false}
+
+# Substrate dependencies
sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
-did = {path = "../../../pallets/did", default-features = false}
-kilt-support = {path = "../../../support", default-features = false}
-
[features]
default = ["std"]
std = [
diff --git a/rpc/did/runtime-api/src/did_details.rs b/runtime-api/did/src/did_details.rs
similarity index 100%
rename from rpc/did/runtime-api/src/did_details.rs
rename to runtime-api/did/src/did_details.rs
diff --git a/rpc/did/runtime-api/src/lib.rs b/runtime-api/did/src/lib.rs
similarity index 99%
rename from rpc/did/runtime-api/src/lib.rs
rename to runtime-api/did/src/lib.rs
index fb216eb58d..87efc74dcc 100644
--- a/rpc/did/runtime-api/src/lib.rs
+++ b/runtime-api/did/src/lib.rs
@@ -15,6 +15,7 @@
// along with this program. If not, see .
// If you feel like getting in touch with us, you can do so at info@botlabs.org
+
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Codec, Decode, Encode, MaxEncodedLen};
diff --git a/rpc/did/runtime-api/src/service_endpoint.rs b/runtime-api/did/src/service_endpoint.rs
similarity index 99%
rename from rpc/did/runtime-api/src/service_endpoint.rs
rename to runtime-api/did/src/service_endpoint.rs
index 9f2ab6ef2b..446aed5550 100644
--- a/rpc/did/runtime-api/src/service_endpoint.rs
+++ b/runtime-api/did/src/service_endpoint.rs
@@ -15,6 +15,7 @@
// along with this program. If not, see .
// If you feel like getting in touch with us, you can do so at info@botlabs.org
+
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_std::vec::Vec;
diff --git a/rpc/public-credentials/runtime-api/Cargo.toml b/runtime-api/public-credentials/Cargo.toml
similarity index 86%
rename from rpc/public-credentials/runtime-api/Cargo.toml
rename to runtime-api/public-credentials/Cargo.toml
index 0a3c995f31..e7524d9f26 100644
--- a/rpc/public-credentials/runtime-api/Cargo.toml
+++ b/runtime-api/public-credentials/Cargo.toml
@@ -2,7 +2,7 @@
authors = ["KILT "]
description = "Runtime APIs for dealing with public credentials."
edition = "2021"
-name = "public-credentials-runtime-api"
+name = "kilt-runtime-api-public-credentials"
repository = "https://github.com/KILTprotocol/kilt-node"
version = "1.8.0"
@@ -10,13 +10,13 @@ version = "1.8.0"
# External dependencies
codec = {package = "parity-scale-codec", version = "3.1.5", default-features = false}
+# Internal dependencies
+kilt-support = {path = "../../support/", default-features = false}
+
# Substrate dependencies
sp-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29", default-features = false}
sp-std = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29", default-features = false}
-# Internal dependencies
-kilt-support = {path = "../../../support/", default-features = false}
-
[features]
default = ["std"]
std = [
diff --git a/rpc/public-credentials/runtime-api/src/lib.rs b/runtime-api/public-credentials/src/lib.rs
similarity index 99%
rename from rpc/public-credentials/runtime-api/src/lib.rs
rename to runtime-api/public-credentials/src/lib.rs
index 6e4f8d6a08..52fada35d2 100644
--- a/rpc/public-credentials/runtime-api/src/lib.rs
+++ b/runtime-api/public-credentials/src/lib.rs
@@ -19,7 +19,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
use codec::Codec;
-
use sp_std::vec::Vec;
use kilt_support::traits::ItemFilter;
diff --git a/runtime-api/staking/Cargo.toml b/runtime-api/staking/Cargo.toml
new file mode 100644
index 0000000000..c4996b64ef
--- /dev/null
+++ b/runtime-api/staking/Cargo.toml
@@ -0,0 +1,26 @@
+[package]
+edition = "2021"
+description = "Runtime APIs for dealing with parachain staking."
+name = "kilt-runtime-api-staking"
+repository = "https://github.com/KILTprotocol/kilt-node"
+version = "1.8.0"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+# External dependencies
+codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] }
+scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
+
+# External dependencies
+sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
+sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
+
+[features]
+default = ["std"]
+std = [
+ "codec/std",
+ "sp-api/std",
+ "sp-runtime/std",
+ "scale-info/std",
+]
diff --git a/pallets/parachain-staking/src/runtime_api.rs b/runtime-api/staking/src/lib.rs
similarity index 77%
rename from pallets/parachain-staking/src/runtime_api.rs
rename to runtime-api/staking/src/lib.rs
index 26ced2a6b5..a0cebe3b23 100644
--- a/pallets/parachain-staking/src/runtime_api.rs
+++ b/runtime-api/staking/src/lib.rs
@@ -16,8 +16,9 @@
// If you feel like getting in touch with us, you can do so at info@botlabs.org
-use frame_support::dispatch::fmt::Debug;
-use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
+#![cfg_attr(not(feature = "std"), no_std)]
+
+use codec::{Codec, Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::Perquintill;
@@ -30,12 +31,16 @@ pub struct StakingRates {
}
sp_api::decl_runtime_apis! {
- pub trait ParachainStakingApi
+ /// The API to query staking and reward rates.
+ pub trait Staking
where
- AccountId: Eq + PartialEq + Debug + Encode + Decode + Clone,
- Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + PartialEq
+ AccountId: Codec,
+ Balance: Codec
{
+ /// Returns the current staking rewards for a given account address.
fn get_unclaimed_staking_rewards(account: &AccountId) -> Balance;
+ /// Returns the current staking and reward rates for collators and
+ /// delegators.
fn get_staking_rates() -> StakingRates;
}
}
diff --git a/runtimes/clone/Cargo.toml b/runtimes/clone/Cargo.toml
index 88af70eeed..e0d955ffee 100644
--- a/runtimes/clone/Cargo.toml
+++ b/runtimes/clone/Cargo.toml
@@ -15,10 +15,10 @@ scale-info = {version = "2.1.1", default-features = false, features = ["derive"]
hex-literal = {version = "0.3.4", optional = true}
# RPC
-did-rpc-runtime-api = {path = "../../rpc/did/runtime-api", default-features = false}
frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
+kilt-runtime-api-did = {path = "../../runtime-api/did", default-features = false}
+kilt-runtime-api-public-credentials = {path = "../../runtime-api/public-credentials", default-features = false}
pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
-public-credentials-runtime-api = {path = "../../rpc/public-credentials/runtime-api", default-features = false}
# KILT pallets & primitives
pallet-did-lookup = {path = "../../pallets/pallet-did-lookup", default-features = false}
@@ -112,12 +112,13 @@ std = [
"cumulus-primitives-core/std",
"cumulus-primitives-timestamp/std",
"cumulus-primitives-utility/std",
- "did-rpc-runtime-api/std",
"frame-executive/std",
"frame-support/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime/std",
+ "kilt-runtime-api-did/std",
+ "kilt-runtime-api-public-credentials/std",
"log/std",
"pallet-aura/std",
"pallet-authorship/std",
@@ -133,7 +134,6 @@ std = [
"pallet-xcm/std",
"parachain-info/std",
"public-credentials/std",
- "public-credentials-runtime-api/std",
"runtime-common/std",
"scale-info/std",
"sp-api/std",
diff --git a/runtimes/clone/src/lib.rs b/runtimes/clone/src/lib.rs
index e98ea607e2..abbc863049 100644
--- a/runtimes/clone/src/lib.rs
+++ b/runtimes/clone/src/lib.rs
@@ -531,7 +531,7 @@ impl_runtime_apis! {
}
// Solely required from parachain client
- impl did_rpc_runtime_api::Did<
+ impl kilt_runtime_api_did::Did<
Block,
AccountId,
AccountId,
@@ -540,7 +540,7 @@ impl_runtime_apis! {
Hash,
BlockNumber
> for Runtime {
- fn query_by_web3_name(_: Vec) -> Option) -> Option Option<
- did_rpc_runtime_api::RawDidLinkedInfo<
+ kilt_runtime_api_did::RawDidLinkedInfo<
AccountId,
AccountId,
LinkableAccountId,
@@ -566,7 +566,7 @@ impl_runtime_apis! {
}
fn query(_: AccountId) -> Option<
- did_rpc_runtime_api::RawDidLinkedInfo<
+ kilt_runtime_api_did::RawDidLinkedInfo<
AccountId,
AccountId,
LinkableAccountId,
@@ -579,7 +579,7 @@ impl_runtime_apis! {
}
}
- impl public_credentials_runtime_api::PublicCredentials, Hash, public_credentials::CredentialEntry>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime {
+ impl kilt_runtime_api_public_credentials::PublicCredentials, Hash, public_credentials::CredentialEntry>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime {
fn get_credential(_credential_id: Hash) -> Option>> {
None
}
diff --git a/runtimes/common/src/lib.rs b/runtimes/common/src/lib.rs
index c30bad31d4..4d597e8583 100644
--- a/runtimes/common/src/lib.rs
+++ b/runtimes/common/src/lib.rs
@@ -16,8 +16,6 @@
// If you feel like getting in touch with us, you can do so at info@botlabs.org
-//! Primitives used by the Parachains Tick, Trick and Track.
-
#![cfg_attr(not(feature = "std"), no_std)]
use constants::{AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO};
diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml
index 5908d7611e..4c14103e17 100644
--- a/runtimes/peregrine/Cargo.toml
+++ b/runtimes/peregrine/Cargo.toml
@@ -15,10 +15,11 @@ scale-info = {version = "2.1.1", default-features = false, features = ["derive"]
hex-literal = {version = "0.3.4", optional = true}
# RPC
-did-rpc-runtime-api = {path = "../../rpc/did/runtime-api", default-features = false}
frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
+kilt-runtime-api-did = {path = "../../runtime-api/did", default-features = false}
+kilt-runtime-api-public-credentials = {path = "../../runtime-api/public-credentials", default-features = false}
+kilt-runtime-api-staking = {path = "../../runtime-api/staking", default-features = false}
pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
-public-credentials-runtime-api = {path = "../../rpc/public-credentials/runtime-api", default-features = false}
# KILT pallets & primitives
attestation = {path = "../../pallets/attestation", default-features = false}
@@ -150,7 +151,6 @@ std = [
"cumulus-primitives-timestamp/std",
"cumulus-primitives-utility/std",
"delegation/std",
- "did-rpc-runtime-api/std",
"did/std",
"frame-benchmarking/std",
"frame-executive/std",
@@ -158,6 +158,9 @@ std = [
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime/std",
+ "kilt-runtime-api-did/std",
+ "kilt-runtime-api-public-credentials/std",
+ "kilt-runtime-api-staking/std",
"kilt-support/std",
"log/std",
"kilt-support/std",
@@ -188,7 +191,6 @@ std = [
"parachain-info/std",
"parachain-staking/std",
"public-credentials/std",
- "public-credentials-runtime-api/std",
"runtime-common/std",
"scale-info/std",
"sp-api/std",
diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs
index c09213ee15..0413601004 100644
--- a/runtimes/peregrine/src/lib.rs
+++ b/runtimes/peregrine/src/lib.rs
@@ -1149,7 +1149,7 @@ impl_runtime_apis! {
}
}
- impl did_rpc_runtime_api::Did<
+ impl kilt_runtime_api_did::Did<
Block,
DidIdentifier,
AccountId,
@@ -1158,7 +1158,7 @@ impl_runtime_apis! {
Hash,
BlockNumber
> for Runtime {
- fn query_by_web3_name(name: Vec) -> Option) -> Option::iter_prefix(&owner_info.owner).map(|e| From::from(e.1)).collect();
- did_rpc_runtime_api::RawDidLinkedInfo{
+ kilt_runtime_api_did::RawDidLinkedInfo{
identifier: owner_info.owner,
w3n: Some(name.into()),
accounts,
@@ -1189,7 +1189,7 @@ impl_runtime_apis! {
}
fn query_by_account(account: LinkableAccountId) -> Option<
- did_rpc_runtime_api::RawDidLinkedInfo<
+ kilt_runtime_api_did::RawDidLinkedInfo<
DidIdentifier,
AccountId,
LinkableAccountId,
@@ -1207,7 +1207,7 @@ impl_runtime_apis! {
let accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(&connection_record.did).collect();
let service_endpoints = did::ServiceEndpoints::::iter_prefix(&connection_record.did).map(|e| From::from(e.1)).collect();
- did_rpc_runtime_api::RawDidLinkedInfo {
+ kilt_runtime_api_did::RawDidLinkedInfo {
identifier: connection_record.did,
w3n,
accounts,
@@ -1218,7 +1218,7 @@ impl_runtime_apis! {
}
fn query(did: DidIdentifier) -> Option<
- did_rpc_runtime_api::RawDidLinkedInfo<
+ kilt_runtime_api_did::RawDidLinkedInfo<
DidIdentifier,
AccountId,
LinkableAccountId,
@@ -1232,7 +1232,7 @@ impl_runtime_apis! {
let accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(&did).collect();
let service_endpoints = did::ServiceEndpoints::::iter_prefix(&did).map(|e| From::from(e.1)).collect();
- Some(did_rpc_runtime_api::RawDidLinkedInfo {
+ Some(kilt_runtime_api_did::RawDidLinkedInfo {
identifier: did,
w3n,
accounts,
@@ -1242,7 +1242,7 @@ impl_runtime_apis! {
}
}
- impl public_credentials_runtime_api::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime {
+ impl kilt_runtime_api_public_credentials::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime {
fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> {
let subject = public_credentials::CredentialSubjects::::get(&credential_id)?;
public_credentials::Credentials::::get(&subject, &credential_id)
@@ -1259,12 +1259,12 @@ impl_runtime_apis! {
}
}
- impl parachain_staking::runtime_api::ParachainStakingApi for Runtime {
+ impl kilt_runtime_api_staking::Staking for Runtime {
fn get_unclaimed_staking_rewards(account: &AccountId) -> Balance {
ParachainStaking::get_unclaimed_staking_rewards(account)
}
- fn get_staking_rates() -> parachain_staking::runtime_api::StakingRates {
+ fn get_staking_rates() -> kilt_runtime_api_staking::StakingRates {
ParachainStaking::get_staking_rates()
}
}
diff --git a/runtimes/spiritnet/Cargo.toml b/runtimes/spiritnet/Cargo.toml
index 00afde4099..ed055a6d2c 100644
--- a/runtimes/spiritnet/Cargo.toml
+++ b/runtimes/spiritnet/Cargo.toml
@@ -15,10 +15,11 @@ scale-info = {version = "2.1.1", default-features = false, features = ["derive"]
hex-literal = {version = "0.3.4", optional = true}
# RPC
-did-rpc-runtime-api = {path = "../../rpc/did/runtime-api", default-features = false}
frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
+kilt-runtime-api-did = {path = "../../runtime-api/did", default-features = false}
+kilt-runtime-api-public-credentials = {path = "../../runtime-api/public-credentials", default-features = false}
+kilt-runtime-api-staking = {path = "../../runtime-api/staking", default-features = false}
pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"}
-public-credentials-runtime-api = {path = "../../rpc/public-credentials/runtime-api", default-features = false}
# KILT pallets & primitives
attestation = {path = "../../pallets/attestation", default-features = false}
@@ -149,7 +150,6 @@ std = [
"cumulus-primitives-timestamp/std",
"cumulus-primitives-utility/std",
"delegation/std",
- "did-rpc-runtime-api/std",
"did/std",
"frame-benchmarking/std",
"frame-executive/std",
@@ -157,6 +157,9 @@ std = [
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime/std",
+ "kilt-runtime-api-did/std",
+ "kilt-runtime-api-public-credentials/std",
+ "kilt-runtime-api-staking/std",
"kilt-support/std",
"log/std",
"pallet-aura/std",
@@ -185,7 +188,6 @@ std = [
"parachain-info/std",
"parachain-staking/std",
"public-credentials/std",
- "public-credentials-runtime-api/std",
"runtime-common/std",
"scale-info/std",
"sp-api/std",
diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs
index e8cab780c9..560ecfb2fb 100644
--- a/runtimes/spiritnet/src/lib.rs
+++ b/runtimes/spiritnet/src/lib.rs
@@ -1143,7 +1143,7 @@ impl_runtime_apis! {
}
}
- impl did_rpc_runtime_api::Did<
+ impl kilt_runtime_api_did::Did<
Block,
DidIdentifier,
AccountId,
@@ -1152,7 +1152,7 @@ impl_runtime_apis! {
Hash,
BlockNumber
> for Runtime {
- fn query_by_web3_name(name: Vec) -> Option) -> Option::iter_prefix(&owner_info.owner).map(|e| From::from(e.1)).collect();
- did_rpc_runtime_api::RawDidLinkedInfo{
+ kilt_runtime_api_did::RawDidLinkedInfo{
identifier: owner_info.owner,
w3n: Some(name.into()),
accounts,
@@ -1183,7 +1183,7 @@ impl_runtime_apis! {
}
fn query_by_account(account: LinkableAccountId) -> Option<
- did_rpc_runtime_api::RawDidLinkedInfo<
+ kilt_runtime_api_did::RawDidLinkedInfo<
DidIdentifier,
AccountId,
LinkableAccountId,
@@ -1201,7 +1201,7 @@ impl_runtime_apis! {
let accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(&connection_record.did).collect();
let service_endpoints = did::ServiceEndpoints::::iter_prefix(&connection_record.did).map(|e| From::from(e.1)).collect();
- did_rpc_runtime_api::RawDidLinkedInfo {
+ kilt_runtime_api_did::RawDidLinkedInfo {
identifier: connection_record.did,
w3n,
accounts,
@@ -1212,7 +1212,7 @@ impl_runtime_apis! {
}
fn query(did: DidIdentifier) -> Option<
- did_rpc_runtime_api::RawDidLinkedInfo<
+ kilt_runtime_api_did::RawDidLinkedInfo<
DidIdentifier,
AccountId,
LinkableAccountId,
@@ -1226,7 +1226,7 @@ impl_runtime_apis! {
let accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(&did).collect();
let service_endpoints = did::ServiceEndpoints::::iter_prefix(&did).map(|e| From::from(e.1)).collect();
- Some(did_rpc_runtime_api::RawDidLinkedInfo {
+ Some(kilt_runtime_api_did::RawDidLinkedInfo {
identifier: did,
w3n,
accounts,
@@ -1236,7 +1236,7 @@ impl_runtime_apis! {
}
}
- impl public_credentials_runtime_api::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime {
+ impl kilt_runtime_api_public_credentials::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime {
fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> {
let subject = public_credentials::CredentialSubjects::::get(&credential_id)?;
public_credentials::Credentials::::get(&subject, &credential_id)
@@ -1253,12 +1253,12 @@ impl_runtime_apis! {
}
}
- impl parachain_staking::runtime_api::ParachainStakingApi for Runtime {
+ impl kilt_runtime_api_staking::Staking for Runtime {
fn get_unclaimed_staking_rewards(account: &AccountId) -> Balance {
ParachainStaking::get_unclaimed_staking_rewards(account)
}
- fn get_staking_rates() -> parachain_staking::runtime_api::StakingRates {
+ fn get_staking_rates() -> kilt_runtime_api_staking::StakingRates {
ParachainStaking::get_staking_rates()
}
}
diff --git a/runtimes/standalone/Cargo.toml b/runtimes/standalone/Cargo.toml
index b0720fa599..a7106b1531 100644
--- a/runtimes/standalone/Cargo.toml
+++ b/runtimes/standalone/Cargo.toml
@@ -23,12 +23,12 @@ kilt-support = {path = "../../support", default-features = false}
pallet-did-lookup = {default-features = false, path = "../../pallets/pallet-did-lookup"}
pallet-web3-names = {default-features = false, path = "../../pallets/pallet-web3-names"}
public-credentials = {default-features = false, path = "../../pallets/public-credentials"}
-public-credentials-runtime-api = {default-features = false, path = "../../rpc/public-credentials/runtime-api"}
runtime-common = {path = "../../runtimes/common", default-features = false}
# RPC
-did-rpc-runtime-api = {path = "../../rpc/did/runtime-api", default-features = false}
frame-system-rpc-runtime-api = {branch = "polkadot-v0.9.29", default-features = false, git = "https://github.com/paritytech/substrate"}
+kilt-runtime-api-did = {path = "../../runtime-api/did", default-features = false}
+kilt-runtime-api-public-credentials = {path = "../../runtime-api/public-credentials", default-features = false}
pallet-transaction-payment-rpc-runtime-api = {branch = "polkadot-v0.9.29", default-features = false, git = "https://github.com/paritytech/substrate"}
# Benchmarking
@@ -105,8 +105,9 @@ std = [
"frame-support/std",
"frame-system/std",
"frame-system-rpc-runtime-api/std",
- "did-rpc-runtime-api/std",
"frame-try-runtime/std",
+ "kilt-runtime-api-did/std",
+ "kilt-runtime-api-public-credentials/std",
"kilt-support/std",
"log/std",
"pallet-aura/std",
@@ -124,7 +125,6 @@ std = [
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-web3-names/std",
"public-credentials/std",
- "public-credentials-runtime-api/std",
"runtime-common/std",
"scale-info/std",
"sp-api/std",
diff --git a/runtimes/standalone/src/lib.rs b/runtimes/standalone/src/lib.rs
index 6e020bc93f..ba47cb7b9d 100644
--- a/runtimes/standalone/src/lib.rs
+++ b/runtimes/standalone/src/lib.rs
@@ -901,7 +901,7 @@ impl_runtime_apis! {
}
}
- impl did_rpc_runtime_api::Did<
+ impl kilt_runtime_api_did::Did<
Block,
DidIdentifier,
AccountId,
@@ -910,7 +910,7 @@ impl_runtime_apis! {
Hash,
BlockNumber
> for Runtime {
- fn query_by_web3_name(name: Vec) -> Option) -> Option::iter_prefix(&owner_info.owner).map(|e| From::from(e.1)).collect();
- did_rpc_runtime_api::RawDidLinkedInfo{
+ kilt_runtime_api_did::RawDidLinkedInfo{
identifier: owner_info.owner,
w3n: Some(name.into()),
accounts,
@@ -941,7 +941,7 @@ impl_runtime_apis! {
}
fn query_by_account(account: LinkableAccountId) -> Option<
- did_rpc_runtime_api::RawDidLinkedInfo<
+ kilt_runtime_api_did::RawDidLinkedInfo<
DidIdentifier,
AccountId,
LinkableAccountId,
@@ -959,7 +959,7 @@ impl_runtime_apis! {
let accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(&connection_record.did).collect();
let service_endpoints = did::ServiceEndpoints::::iter_prefix(&connection_record.did).map(|e| From::from(e.1)).collect();
- did_rpc_runtime_api::RawDidLinkedInfo {
+ kilt_runtime_api_did::RawDidLinkedInfo {
identifier: connection_record.did,
w3n,
accounts,
@@ -970,7 +970,7 @@ impl_runtime_apis! {
}
fn query(did: DidIdentifier) -> Option<
- did_rpc_runtime_api::RawDidLinkedInfo<
+ kilt_runtime_api_did::RawDidLinkedInfo<
DidIdentifier,
AccountId,
LinkableAccountId,
@@ -984,7 +984,7 @@ impl_runtime_apis! {
let accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(&did).collect();
let service_endpoints = did::ServiceEndpoints::::iter_prefix(&did).map(|e| From::from(e.1)).collect();
- Some(did_rpc_runtime_api::RawDidLinkedInfo {
+ Some(kilt_runtime_api_did::RawDidLinkedInfo {
identifier: did,
w3n,
accounts,
@@ -994,7 +994,7 @@ impl_runtime_apis! {
}
}
- impl public_credentials_runtime_api::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime {
+ impl kilt_runtime_api_public_credentials::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime {
fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> {
let subject = public_credentials::CredentialSubjects::::get(&credential_id)?;
public_credentials::Credentials::::get(&subject, &credential_id)