mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
Add Transaction Fee RPC to Statemint/Statemine (#559)
* add payment rpc to parachains * connect payment rpc to parachains clients * fix the rumtime_api bound/ add separate start node implementation for shell * use cumulus/parachain specific primitives * Update polkadot-parachains/src/rpc.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * rename txpool dependency * fix the package name * move parachain primitives to separate module * Refactor Shared Primitves for Payment Info (#577) * rename to parachains-common * refactor shared opaque * remove primitives * Update service.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -24,7 +24,8 @@ use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
|
||||
use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||
|
||||
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||
pub type ChainSpec = sc_service::GenericChainSpec<rococo_parachain_runtime::GenesisConfig, Extensions>;
|
||||
pub type ChainSpec =
|
||||
sc_service::GenericChainSpec<rococo_parachain_runtime::GenesisConfig, Extensions>;
|
||||
|
||||
/// Specialized `ChainSpec` for the shell parachain runtime.
|
||||
pub type ShellChainSpec = sc_service::GenericChainSpec<shell_runtime::GenesisConfig, Extensions>;
|
||||
@@ -56,7 +57,8 @@ impl Extensions {
|
||||
type AccountPublic = <Signature as Verify>::Signer;
|
||||
|
||||
/// Helper function to generate an account ID from seed
|
||||
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId where
|
||||
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
|
||||
where
|
||||
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
||||
{
|
||||
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
||||
@@ -195,12 +197,15 @@ fn shell_testnet_genesis(parachain_id: ParaId) -> shell_runtime::GenesisConfig {
|
||||
}
|
||||
}
|
||||
|
||||
use statemint_common::Balance as StatemintBalance;
|
||||
use parachains_common::Balance as StatemintBalance;
|
||||
|
||||
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||
pub type StatemintChainSpec = sc_service::GenericChainSpec<statemint_runtime::GenesisConfig, Extensions>;
|
||||
pub type StatemineChainSpec = sc_service::GenericChainSpec<statemine_runtime::GenesisConfig, Extensions>;
|
||||
pub type WestmintChainSpec = sc_service::GenericChainSpec<westmint_runtime::GenesisConfig, Extensions>;
|
||||
pub type StatemintChainSpec =
|
||||
sc_service::GenericChainSpec<statemint_runtime::GenesisConfig, Extensions>;
|
||||
pub type StatemineChainSpec =
|
||||
sc_service::GenericChainSpec<statemine_runtime::GenesisConfig, Extensions>;
|
||||
pub type WestmintChainSpec =
|
||||
sc_service::GenericChainSpec<westmint_runtime::GenesisConfig, Extensions>;
|
||||
|
||||
const STATEMINT_ED: StatemintBalance = statemint_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||
const STATEMINE_ED: StatemintBalance = statemine_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||
@@ -223,22 +228,22 @@ pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
|
||||
/// Generate the session keys from individual elements.
|
||||
///
|
||||
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
|
||||
pub fn statemint_session_keys(keys: AuraId) -> statemint_runtime::opaque::SessionKeys {
|
||||
statemint_runtime::opaque::SessionKeys { aura: keys }
|
||||
pub fn statemint_session_keys(keys: AuraId) -> statemint_runtime::SessionKeys {
|
||||
statemint_runtime::SessionKeys { aura: keys }
|
||||
}
|
||||
|
||||
/// Generate the session keys from individual elements.
|
||||
///
|
||||
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
|
||||
pub fn statemine_session_keys(keys: AuraId) -> statemine_runtime::opaque::SessionKeys {
|
||||
statemine_runtime::opaque::SessionKeys { aura: keys }
|
||||
pub fn statemine_session_keys(keys: AuraId) -> statemine_runtime::SessionKeys {
|
||||
statemine_runtime::SessionKeys { aura: keys }
|
||||
}
|
||||
|
||||
/// Generate the session keys from individual elements.
|
||||
///
|
||||
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
|
||||
pub fn westmint_session_keys(keys: AuraId) -> westmint_runtime::opaque::SessionKeys {
|
||||
westmint_runtime::opaque::SessionKeys { aura: keys }
|
||||
pub fn westmint_session_keys(keys: AuraId) -> westmint_runtime::SessionKeys {
|
||||
westmint_runtime::SessionKeys { aura: keys }
|
||||
}
|
||||
|
||||
pub fn statemint_development_config(id: ParaId) -> StatemintChainSpec {
|
||||
@@ -255,12 +260,10 @@ pub fn statemint_development_config(id: ParaId) -> StatemintChainSpec {
|
||||
move || {
|
||||
statemint_genesis(
|
||||
// initial collators.
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice"),
|
||||
)
|
||||
],
|
||||
vec![(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice"),
|
||||
)],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
@@ -295,14 +298,15 @@ pub fn statemint_local_config(id: ParaId) -> StatemintChainSpec {
|
||||
move || {
|
||||
statemint_genesis(
|
||||
// initial collators.
|
||||
vec![(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice")
|
||||
),
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_collator_keys_from_seed("Bob")
|
||||
),
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice"),
|
||||
),
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_collator_keys_from_seed("Bob"),
|
||||
),
|
||||
],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
@@ -358,11 +362,17 @@ fn statemint_genesis(
|
||||
..Default::default()
|
||||
},
|
||||
session: statemint_runtime::SessionConfig {
|
||||
keys: invulnerables.iter().cloned().map(|(acc, aura)| (
|
||||
acc.clone(), // account id
|
||||
acc.clone(), // validator id
|
||||
statemint_session_keys(aura), // session keys
|
||||
)).collect()
|
||||
keys: invulnerables
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc.clone(), // validator id
|
||||
statemint_session_keys(aura), // session keys
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
|
||||
// of this.
|
||||
@@ -386,12 +396,10 @@ pub fn statemine_development_config(id: ParaId) -> StatemineChainSpec {
|
||||
move || {
|
||||
statemine_genesis(
|
||||
// initial collators.
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice"),
|
||||
)
|
||||
],
|
||||
vec![(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice"),
|
||||
)],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
@@ -426,14 +434,15 @@ pub fn statemine_local_config(id: ParaId) -> StatemineChainSpec {
|
||||
move || {
|
||||
statemine_genesis(
|
||||
// initial collators.
|
||||
vec![(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice")
|
||||
),
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_collator_keys_from_seed("Bob")
|
||||
),
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice"),
|
||||
),
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_collator_keys_from_seed("Bob"),
|
||||
),
|
||||
],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
@@ -477,22 +486,31 @@ pub fn statemine_config(id: ParaId) -> StatemineChainSpec {
|
||||
move || {
|
||||
statemine_genesis(
|
||||
// initial collators.
|
||||
vec![(
|
||||
hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730").into(),
|
||||
hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730").unchecked_into()
|
||||
),
|
||||
(
|
||||
hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a").into(),
|
||||
hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a").unchecked_into()
|
||||
),
|
||||
(
|
||||
hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a").into(),
|
||||
hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a").unchecked_into()
|
||||
),
|
||||
(
|
||||
hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415").into(),
|
||||
hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415").unchecked_into()
|
||||
),
|
||||
vec![
|
||||
(
|
||||
hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730")
|
||||
.into(),
|
||||
hex!("50673d59020488a4ffc9d8c6de3062a65977046e6990915617f85fef6d349730")
|
||||
.unchecked_into(),
|
||||
),
|
||||
(
|
||||
hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a")
|
||||
.into(),
|
||||
hex!("fe8102dbc244e7ea2babd9f53236d67403b046154370da5c3ea99def0bd0747a")
|
||||
.unchecked_into(),
|
||||
),
|
||||
(
|
||||
hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a")
|
||||
.into(),
|
||||
hex!("38144b5398e5d0da5ec936a3af23f5a96e782f676ab19d45f29075ee92eca76a")
|
||||
.unchecked_into(),
|
||||
),
|
||||
(
|
||||
hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415")
|
||||
.into(),
|
||||
hex!("3253947640e309120ae70fa458dcacb915e2ddd78f930f52bd3679ec63fc4415")
|
||||
.unchecked_into(),
|
||||
),
|
||||
],
|
||||
vec![],
|
||||
id,
|
||||
@@ -535,11 +553,17 @@ fn statemine_genesis(
|
||||
..Default::default()
|
||||
},
|
||||
session: statemine_runtime::SessionConfig {
|
||||
keys: invulnerables.iter().cloned().map(|(acc, aura)| (
|
||||
acc.clone(), // account id
|
||||
acc.clone(), // validator id
|
||||
statemine_session_keys(aura), // session keys
|
||||
)).collect()
|
||||
keys: invulnerables
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc.clone(), // validator id
|
||||
statemine_session_keys(aura), // session keys
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
@@ -561,12 +585,10 @@ pub fn westmint_development_config(id: ParaId) -> WestmintChainSpec {
|
||||
move || {
|
||||
westmint_genesis(
|
||||
// initial collators.
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice"),
|
||||
)
|
||||
],
|
||||
vec![(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice"),
|
||||
)],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
@@ -602,14 +624,15 @@ pub fn westmint_local_config(id: ParaId) -> WestmintChainSpec {
|
||||
move || {
|
||||
westmint_genesis(
|
||||
// initial collators.
|
||||
vec![(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice")
|
||||
),
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_collator_keys_from_seed("Bob")
|
||||
),
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed("Alice"),
|
||||
),
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_collator_keys_from_seed("Bob"),
|
||||
),
|
||||
],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
@@ -654,22 +677,31 @@ pub fn westmint_config(id: ParaId) -> WestmintChainSpec {
|
||||
move || {
|
||||
westmint_genesis(
|
||||
// initial collators.
|
||||
vec![(
|
||||
hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325").into(),
|
||||
hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325").unchecked_into()
|
||||
),
|
||||
(
|
||||
hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876").into(),
|
||||
hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876").unchecked_into()
|
||||
),
|
||||
(
|
||||
hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f").into(),
|
||||
hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f").unchecked_into()
|
||||
),
|
||||
(
|
||||
hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322").into(),
|
||||
hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322").unchecked_into()
|
||||
),
|
||||
vec![
|
||||
(
|
||||
hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325")
|
||||
.into(),
|
||||
hex!("9cfd429fa002114f33c1d3e211501d62830c9868228eb3b4b8ae15a83de04325")
|
||||
.unchecked_into(),
|
||||
),
|
||||
(
|
||||
hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876")
|
||||
.into(),
|
||||
hex!("12a03fb4e7bda6c9a07ec0a11d03c24746943e054ff0bb04938970104c783876")
|
||||
.unchecked_into(),
|
||||
),
|
||||
(
|
||||
hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f")
|
||||
.into(),
|
||||
hex!("1256436307dfde969324e95b8c62cb9101f520a39435e6af0f7ac07b34e1931f")
|
||||
.unchecked_into(),
|
||||
),
|
||||
(
|
||||
hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322")
|
||||
.into(),
|
||||
hex!("98102b7bca3f070f9aa19f58feed2c0a4e107d203396028ec17a47e1ed80e322")
|
||||
.unchecked_into(),
|
||||
),
|
||||
],
|
||||
vec![],
|
||||
// re-use the Westend sudo key
|
||||
@@ -716,11 +748,17 @@ fn westmint_genesis(
|
||||
..Default::default()
|
||||
},
|
||||
session: westmint_runtime::SessionConfig {
|
||||
keys: invulnerables.iter().cloned().map(|(acc, aura)| (
|
||||
acc.clone(), // account id
|
||||
acc.clone(), // validator id
|
||||
westmint_session_keys(aura), // session keys
|
||||
)).collect()
|
||||
keys: invulnerables
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc.clone(), // validator id
|
||||
westmint_session_keys(aura), // session keys
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
|
||||
// of this.
|
||||
|
||||
Reference in New Issue
Block a user