Skip to content
Snippets Groups Projects
Unverified Commit 09454c67 authored by bgallois's avatar bgallois
Browse files

move offchain config to common

parent b44a3345
No related branches found
No related tags found
1 merge request!312Upgrade polkadot v1.17.0
Pipeline #39714 passed
...@@ -22,6 +22,7 @@ pub mod constants; ...@@ -22,6 +22,7 @@ pub mod constants;
pub mod entities; pub mod entities;
pub mod fees; pub mod fees;
pub mod handlers; pub mod handlers;
mod offchain;
mod pallets_config; mod pallets_config;
pub mod providers; pub mod providers;
......
// Copyright 2021 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
#[macro_export]
macro_rules! offchain_config {
() => {
impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
type Extension = TxExtension;
fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_transaction(call, extension)
}
}
impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_bare(call)
}
}
impl<LocalCall> frame_system::offchain::CreateTransactionBase<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
type Extrinsic = UncheckedExtrinsic;
type RuntimeCall = RuntimeCall;
}
};
}
...@@ -73,8 +73,6 @@ pub use frame_support::{ ...@@ -73,8 +73,6 @@ pub use frame_support::{
StorageValue, StorageValue,
}; };
common_runtime::declare_session_keys! {}
// To learn more about runtime versioning and what each of the following value means: // To learn more about runtime versioning and what each of the following value means:
// https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning // https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning
#[sp_version::runtime_version] #[sp_version::runtime_version]
...@@ -131,8 +129,6 @@ pub type Executive = frame_executive::Executive< ...@@ -131,8 +129,6 @@ pub type Executive = frame_executive::Executive<
pub type TechnicalCommitteeInstance = Instance2; pub type TechnicalCommitteeInstance = Instance2;
common_runtime::benchmarks_config!();
pub struct BaseCallFilter; pub struct BaseCallFilter;
impl Contains<RuntimeCall> for BaseCallFilter { impl Contains<RuntimeCall> for BaseCallFilter {
fn contains(call: &RuntimeCall) -> bool { fn contains(call: &RuntimeCall) -> bool {
...@@ -193,9 +189,6 @@ impl frame_support::traits::InstanceFilter<RuntimeCall> for ProxyType { ...@@ -193,9 +189,6 @@ impl frame_support::traits::InstanceFilter<RuntimeCall> for ProxyType {
} }
} }
// Configure pallets to include in runtime.
common_runtime::pallets_config!();
// Create the runtime by composing the pallets that were previously configured. // Create the runtime by composing the pallets that were previously configured.
construct_runtime!( construct_runtime!(
pub enum Runtime pub enum Runtime
...@@ -252,42 +245,11 @@ construct_runtime!( ...@@ -252,42 +245,11 @@ construct_runtime!(
} }
); );
impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
type Extension = TxExtension;
fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_transaction(call, extension)
}
}
impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_bare(call)
}
}
impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
where
RuntimeCall: From<C>,
{
type Extrinsic = UncheckedExtrinsic;
type RuntimeCall = RuntimeCall;
}
// All of our runtimes share most of their Runtime API implementations. // All of our runtimes share most of their Runtime API implementations.
// We use a macro to implement this common part and add runtime-specific additional implementations. // We use a macro to implement this common part and add runtime-specific additional implementations.
// This macro expands to : common_runtime::pallets_config!();
// ``` common_runtime::declare_session_keys! {}
// impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")]
// // All impl blocks shared between all runtimes. common_runtime::benchmarks_config!();
// common_runtime::offchain_config! {}
// // Specific impls provided to the `runtime_apis!` macro.
// }
// ```
common_runtime::runtime_apis! {} common_runtime::runtime_apis! {}
...@@ -73,8 +73,6 @@ pub use frame_support::{ ...@@ -73,8 +73,6 @@ pub use frame_support::{
StorageValue, StorageValue,
}; };
common_runtime::declare_session_keys! {}
// To learn more about runtime versioning and what each of the following value means: // To learn more about runtime versioning and what each of the following value means:
// https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning // https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning
#[sp_version::runtime_version] #[sp_version::runtime_version]
...@@ -132,8 +130,6 @@ pub type Executive = frame_executive::Executive< ...@@ -132,8 +130,6 @@ pub type Executive = frame_executive::Executive<
pub type TechnicalCommitteeInstance = Instance2; pub type TechnicalCommitteeInstance = Instance2;
common_runtime::benchmarks_config!();
pub struct BaseCallFilter; pub struct BaseCallFilter;
impl Contains<RuntimeCall> for BaseCallFilter { impl Contains<RuntimeCall> for BaseCallFilter {
fn contains(call: &RuntimeCall) -> bool { fn contains(call: &RuntimeCall) -> bool {
...@@ -235,7 +231,6 @@ impl pallet_duniter_test_parameters::Config for Runtime { ...@@ -235,7 +231,6 @@ impl pallet_duniter_test_parameters::Config for Runtime {
type PeriodCount = Balance; type PeriodCount = Balance;
type SessionCount = u32; type SessionCount = u32;
} }
common_runtime::pallets_config!();
// Create the runtime by composing the pallets that were previously configured. // Create the runtime by composing the pallets that were previously configured.
construct_runtime!( construct_runtime!(
...@@ -295,42 +290,11 @@ construct_runtime!( ...@@ -295,42 +290,11 @@ construct_runtime!(
} }
); );
impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
type Extension = TxExtension;
fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_transaction(call, extension)
}
}
impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_bare(call)
}
}
impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
where
RuntimeCall: From<C>,
{
type Extrinsic = UncheckedExtrinsic;
type RuntimeCall = RuntimeCall;
}
// All of our runtimes share most of their Runtime API implementations. // All of our runtimes share most of their Runtime API implementations.
// We use a macro to implement this common part and add runtime-specific additional implementations. // We use a macro to implement this common part and add runtime-specific additional implementations.
// This macro expands to : common_runtime::pallets_config!();
// ``` common_runtime::declare_session_keys! {}
// impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")]
// // All impl blocks shared between all runtimes. common_runtime::benchmarks_config!();
// common_runtime::offchain_config! {}
// // Specific impls provided to the `runtime_apis!` macro.
// }
// ```
common_runtime::runtime_apis! {} common_runtime::runtime_apis! {}
...@@ -72,8 +72,6 @@ pub use frame_support::{ ...@@ -72,8 +72,6 @@ pub use frame_support::{
StorageValue, StorageValue,
}; };
common_runtime::declare_session_keys! {}
// To learn more about runtime versioning and what each of the following value means: // To learn more about runtime versioning and what each of the following value means:
// https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning // https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning
#[sp_version::runtime_version] #[sp_version::runtime_version]
...@@ -131,8 +129,6 @@ pub type Executive = frame_executive::Executive< ...@@ -131,8 +129,6 @@ pub type Executive = frame_executive::Executive<
pub type TechnicalCommitteeInstance = Instance2; pub type TechnicalCommitteeInstance = Instance2;
common_runtime::benchmarks_config!();
pub struct BaseCallFilter; pub struct BaseCallFilter;
impl Contains<RuntimeCall> for BaseCallFilter { impl Contains<RuntimeCall> for BaseCallFilter {
fn contains(call: &RuntimeCall) -> bool { fn contains(call: &RuntimeCall) -> bool {
...@@ -200,9 +196,6 @@ impl frame_support::traits::InstanceFilter<RuntimeCall> for ProxyType { ...@@ -200,9 +196,6 @@ impl frame_support::traits::InstanceFilter<RuntimeCall> for ProxyType {
} }
} }
// Configure pallets to include in runtime.
common_runtime::pallets_config!();
// Create the runtime by composing the pallets that were previously configured. // Create the runtime by composing the pallets that were previously configured.
construct_runtime!( construct_runtime!(
pub enum Runtime pub enum Runtime
...@@ -259,42 +252,11 @@ construct_runtime!( ...@@ -259,42 +252,11 @@ construct_runtime!(
} }
); );
impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
type Extension = TxExtension;
fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_transaction(call, extension)
}
}
impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_bare(call)
}
}
impl<C> frame_system::offchain::CreateTransactionBase<C> for Runtime
where
RuntimeCall: From<C>,
{
type Extrinsic = UncheckedExtrinsic;
type RuntimeCall = RuntimeCall;
}
// All of our runtimes share most of their Runtime API implementations. // All of our runtimes share most of their Runtime API implementations.
// We use a macro to implement this common part and add runtime-specific additional implementations. // We use a macro to implement this common part and add runtime-specific additional implementations.
// This macro expands to : common_runtime::pallets_config!();
// ``` common_runtime::declare_session_keys! {}
// impl_runtime_apis! { #[cfg(feature = "runtime-benchmarks")]
// // All impl blocks shared between all runtimes. common_runtime::benchmarks_config!();
// common_runtime::offchain_config! {}
// // Specific impls provided to the `runtime_apis!` macro.
// }
// ```
common_runtime::runtime_apis! {} common_runtime::runtime_apis! {}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment