mirror of
https://github.com/pezkuwichain/pez-minimal-template.git
synced 2026-06-14 07:41:01 +00:00
sync: pezkuwi-sdk templates/minimal ile senkronize edildi
- node/src/* guncelendi - runtime/src/lib.rs guncelendi (pezsp_keyring import fix) - pezpallets/template/src/* guncelendi
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
# Pezkuwi SDK's Minimal Template
|
# Pezkuwi SDK's Minimal Template
|
||||||
|
|
||||||
<img height="70px" alt="Pezkuwi SDK Logo" src="https://github.com/pezkuwichain/pezkuwi-sdk/raw/master/docs/images/Pezkuwi_Logo_Horizontal_Pink_White.png#gh-dark-mode-only"/>
|
<img height="70px" alt="Pezkuwi SDK Logo" src="https://github.com/pezkuwichain/pezkuwi-sdk/blob/main/docs/images/Pezkuwi_Logo_Horizontal_Pink_Black.png"/>
|
||||||
<img height="70px" alt="Pezkuwi SDK Logo" src="https://github.com/pezkuwichain/pezkuwi-sdk/raw/master/docs/images/Pezkuwi_Logo_Horizontal_Pink_Black.png#gh-light-mode-only"/>
|
<img height="70px" alt="Pezkuwi SDK Logo" src="https://github.com/pezkuwichain/pezkuwi-sdk/blob/main/docs/images/Pezkuwi_Logo_Horizontal_Pink_Black.png"/>
|
||||||
|
|
||||||
> This is a minimal template for creating a blockchain based on Pezkuwi SDK.
|
> This is a minimal template for creating a blockchain based on Pezkuwi SDK.
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// This file is part of pezkuwi-sdk.
|
// This file is part of Bizinikiwi.
|
||||||
|
|
||||||
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -21,13 +21,13 @@ use pezkuwi_sdk::{
|
|||||||
*,
|
*,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This is a specialization of the general bizinikiwi ChainSpec type.
|
/// This is a specialization of the general Bizinikiwi ChainSpec type.
|
||||||
pub type ChainSpec = pezsc_service::GenericChainSpec;
|
pub type ChainSpec = pezsc_service::GenericChainSpec;
|
||||||
|
|
||||||
fn props() -> Properties {
|
fn props() -> Properties {
|
||||||
let mut properties = Properties::new();
|
let mut properties = Properties::new();
|
||||||
properties.insert("tokenDecimals".to_string(), 0.into());
|
properties.insert("tokenDecimals".to_string(), 0.into());
|
||||||
properties.insert("tokenSymbol".to_string(), "PEZ".into());
|
properties.insert("tokenSymbol".to_string(), "MINI".into());
|
||||||
properties
|
properties
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> {
|
|||||||
.with_name("Development")
|
.with_name("Development")
|
||||||
.with_id("dev")
|
.with_id("dev")
|
||||||
.with_chain_type(ChainType::Development)
|
.with_chain_type(ChainType::Development)
|
||||||
.with_genesis_config_preset_name(pezsp_genesis_builder::DEV_RUNTIME_PRESET)
|
.with_genesis_config_preset_name(pezkuwi_sdk::pezsp_genesis_builder::DEV_RUNTIME_PRESET)
|
||||||
.with_properties(props())
|
.with_properties(props())
|
||||||
.build())
|
.build())
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-4
@@ -1,7 +1,8 @@
|
|||||||
// This file is part of pezkuwi-sdk.
|
// This file is part of Bizinikiwi.
|
||||||
|
|
||||||
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use pezkuwi_sdk::{pezsc_cli::RunCmd, *};
|
use pezkuwi_sdk::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Consensus {
|
pub enum Consensus {
|
||||||
@@ -48,7 +49,7 @@ pub struct Cli {
|
|||||||
pub consensus: Consensus,
|
pub consensus: Consensus,
|
||||||
|
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
pub run: RunCmd,
|
pub run: pezsc_cli::RunCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, clap::Subcommand)]
|
#[derive(Debug, clap::Subcommand)]
|
||||||
@@ -58,8 +59,16 @@ pub enum Subcommand {
|
|||||||
Key(pezsc_cli::KeySubcommand),
|
Key(pezsc_cli::KeySubcommand),
|
||||||
|
|
||||||
/// Build a chain specification.
|
/// Build a chain specification.
|
||||||
|
/// DEPRECATED: `build-spec` command will be removed after 1/04/2026. Use `export-chain-spec`
|
||||||
|
/// command instead.
|
||||||
|
#[deprecated(
|
||||||
|
note = "build-spec command will be removed after 1/04/2026. Use export-chain-spec command instead"
|
||||||
|
)]
|
||||||
BuildSpec(pezsc_cli::BuildSpecCmd),
|
BuildSpec(pezsc_cli::BuildSpecCmd),
|
||||||
|
|
||||||
|
/// Export the chain specification.
|
||||||
|
ExportChainSpec(pezsc_cli::ExportChainSpecCmd),
|
||||||
|
|
||||||
/// Validate blocks.
|
/// Validate blocks.
|
||||||
CheckBlock(pezsc_cli::CheckBlockCmd),
|
CheckBlock(pezsc_cli::CheckBlockCmd),
|
||||||
|
|
||||||
|
|||||||
+20
-9
@@ -1,6 +1,6 @@
|
|||||||
// This file is part of pezkuwi-sdk.
|
// This file is part of Bizinikiwi.
|
||||||
|
|
||||||
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -50,8 +50,9 @@ impl BizinikiwiCli for Cli {
|
|||||||
fn load_spec(&self, id: &str) -> Result<Box<dyn pezsc_service::ChainSpec>, String> {
|
fn load_spec(&self, id: &str) -> Result<Box<dyn pezsc_service::ChainSpec>, String> {
|
||||||
Ok(match id {
|
Ok(match id {
|
||||||
"dev" => Box::new(chain_spec::development_chain_spec()?),
|
"dev" => Box::new(chain_spec::development_chain_spec()?),
|
||||||
path =>
|
path => {
|
||||||
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
|
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,6 +63,7 @@ pub fn run() -> pezsc_cli::Result<()> {
|
|||||||
|
|
||||||
match &cli.subcommand {
|
match &cli.subcommand {
|
||||||
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
||||||
|
#[allow(deprecated)]
|
||||||
Some(Subcommand::BuildSpec(cmd)) => {
|
Some(Subcommand::BuildSpec(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||||
@@ -74,6 +76,10 @@ pub fn run() -> pezsc_cli::Result<()> {
|
|||||||
Ok((cmd.run(client, import_queue), task_manager))
|
Ok((cmd.run(client, import_queue), task_manager))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Some(Subcommand::ExportChainSpec(cmd)) => {
|
||||||
|
let chain_spec = cli.load_spec(&cmd.chain)?;
|
||||||
|
cmd.run(chain_spec)
|
||||||
|
},
|
||||||
Some(Subcommand::ExportBlocks(cmd)) => {
|
Some(Subcommand::ExportBlocks(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.async_run(|config| {
|
runner.async_run(|config| {
|
||||||
@@ -117,13 +123,18 @@ pub fn run() -> pezsc_cli::Result<()> {
|
|||||||
None => {
|
None => {
|
||||||
let runner = cli.create_runner(&cli.run)?;
|
let runner = cli.create_runner(&cli.run)?;
|
||||||
runner.run_node_until_exit(|config| async move {
|
runner.run_node_until_exit(|config| async move {
|
||||||
match config.network.network_backend.unwrap_or_default() {
|
match config.network.network_backend {
|
||||||
pezsc_network::config::NetworkBackendType::Libp2p =>
|
pezsc_network::config::NetworkBackendType::Libp2p => service::new_full::<
|
||||||
service::new_full::<pezsc_network::NetworkWorker<_, _>>(config, cli.consensus)
|
pezsc_network::NetworkWorker<_, _>,
|
||||||
.map_err(pezsc_cli::Error::Service),
|
>(
|
||||||
|
config, cli.consensus
|
||||||
|
)
|
||||||
|
.map_err(pezsc_cli::Error::Service),
|
||||||
pezsc_network::config::NetworkBackendType::Litep2p => service::new_full::<
|
pezsc_network::config::NetworkBackendType::Litep2p => service::new_full::<
|
||||||
pezsc_network::Litep2pNetworkBackend,
|
pezsc_network::Litep2pNetworkBackend,
|
||||||
>(config, cli.consensus)
|
>(
|
||||||
|
config, cli.consensus
|
||||||
|
)
|
||||||
.map_err(pezsc_cli::Error::Service),
|
.map_err(pezsc_cli::Error::Service),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
// This file is part of Pezkuwi Sdk.
|
// This file is part of Pezkuwi Sdk.
|
||||||
|
|
||||||
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
// This file is part of pezkuwi-sdk.
|
// This file is part of Bizinikiwi.
|
||||||
|
|
||||||
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
+8
-8
@@ -1,6 +1,6 @@
|
|||||||
// This file is part of pezkuwi-sdk.
|
// This file is part of Bizinikiwi.
|
||||||
|
|
||||||
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//! A collection of node-specific RPC methods.
|
//! A collection of node-specific RPC methods.
|
||||||
//! bizinikiwi provides the `pezsc-rpc` crate, which defines the core RPC layer
|
//! Bizinikiwi provides the `sc-rpc` crate, which defines the core RPC layer
|
||||||
//! used by bizinikiwi nodes. This file extends those RPC definitions with
|
//! used by Bizinikiwi nodes. This file extends those RPC definitions with
|
||||||
//! capabilities that are specific to this project's runtime configuration.
|
//! capabilities that are specific to this project's runtime configuration.
|
||||||
|
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
@@ -48,15 +48,15 @@ where
|
|||||||
C: Send
|
C: Send
|
||||||
+ Sync
|
+ Sync
|
||||||
+ 'static
|
+ 'static
|
||||||
+ pezsp_api::ProvideRuntimeApi<OpaqueBlock>
|
+ pezkuwi_sdk::pezsp_api::ProvideRuntimeApi<OpaqueBlock>
|
||||||
+ HeaderBackend<OpaqueBlock>
|
+ HeaderBackend<OpaqueBlock>
|
||||||
+ HeaderMetadata<OpaqueBlock, Error = BlockChainError>
|
+ HeaderMetadata<OpaqueBlock, Error = BlockChainError>
|
||||||
+ 'static,
|
+ 'static,
|
||||||
C::Api: pezsp_block_builder::BlockBuilder<OpaqueBlock>,
|
C::Api: pezkuwi_sdk::pezsp_block_builder::BlockBuilder<OpaqueBlock>,
|
||||||
C::Api: pezframe_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
|
C::Api: bizinikiwi_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
|
||||||
P: TransactionPool + 'static,
|
P: TransactionPool + 'static,
|
||||||
{
|
{
|
||||||
use pezkuwi_sdk::pezframe_rpc_system::{System, SystemApiServer};
|
use pezkuwi_sdk::bizinikiwi_frame_rpc_system::{System, SystemApiServer};
|
||||||
let mut module = RpcModule::new(());
|
let mut module = RpcModule::new(());
|
||||||
let FullDeps { client, pool } = deps;
|
let FullDeps { client, pool } = deps;
|
||||||
|
|
||||||
|
|||||||
+7
-6
@@ -1,6 +1,6 @@
|
|||||||
// This file is part of pezkuwi-sdk.
|
// This file is part of Bizinikiwi.
|
||||||
|
|
||||||
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -24,12 +24,12 @@ use pezkuwi_sdk::{
|
|||||||
pezsc_service::{error::Error as ServiceError, Configuration, TaskManager},
|
pezsc_service::{error::Error as ServiceError, Configuration, TaskManager},
|
||||||
pezsc_telemetry::{Telemetry, TelemetryWorker},
|
pezsc_telemetry::{Telemetry, TelemetryWorker},
|
||||||
pezsc_transaction_pool_api::OffchainTransactionPoolFactory,
|
pezsc_transaction_pool_api::OffchainTransactionPoolFactory,
|
||||||
pezsp_runtime::traits::Block as BlockT,
|
|
||||||
*,
|
*,
|
||||||
};
|
};
|
||||||
|
use pezsp_runtime::traits::Block as BlockT;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
type HostFunctions = pezsp_io::BizinikiwiHostFunctions;
|
type HostFunctions = pezkuwi_sdk::pezsp_io::BizinikiwiHostFunctions;
|
||||||
|
|
||||||
#[docify::export]
|
#[docify::export]
|
||||||
pub(crate) type FullClient =
|
pub(crate) type FullClient =
|
||||||
@@ -194,6 +194,7 @@ pub fn new_full<Network: pezsc_network::NetworkBackend<Block, <Block as BlockT>:
|
|||||||
sync_service,
|
sync_service,
|
||||||
config,
|
config,
|
||||||
telemetry: telemetry.as_mut(),
|
telemetry: telemetry.as_mut(),
|
||||||
|
tracing_execute_block: None,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let proposer = pezsc_basic_authorship::ProposerFactory::new(
|
let proposer = pezsc_basic_authorship::ProposerFactory::new(
|
||||||
@@ -214,7 +215,7 @@ pub fn new_full<Network: pezsc_network::NetworkBackend<Block, <Block as BlockT>:
|
|||||||
select_chain,
|
select_chain,
|
||||||
consensus_data_provider: None,
|
consensus_data_provider: None,
|
||||||
create_inherent_data_providers: move |_, ()| async move {
|
create_inherent_data_providers: move |_, ()| async move {
|
||||||
Ok(pezsp_timestamp::InherentDataProvider::from_system_time())
|
Ok(pezkuwi_sdk::pezsp_timestamp::InherentDataProvider::from_system_time())
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -250,7 +251,7 @@ pub fn new_full<Network: pezsc_network::NetworkBackend<Block, <Block as BlockT>:
|
|||||||
commands_stream: Box::pin(commands_stream),
|
commands_stream: Box::pin(commands_stream),
|
||||||
consensus_data_provider: None,
|
consensus_data_provider: None,
|
||||||
create_inherent_data_providers: move |_, ()| async move {
|
create_inherent_data_providers: move |_, ()| async move {
|
||||||
Ok(pezsp_timestamp::InherentDataProvider::from_system_time())
|
Ok(pezkuwi_sdk::pezsp_timestamp::InherentDataProvider::from_system_time())
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let authorship_future = pezsc_consensus_manual_seal::run_manual_seal(params);
|
let authorship_future = pezsc_consensus_manual_seal::run_manual_seal(params);
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
//! A shell pezpallet built with [`pezframe`].
|
//! A shell pezpallet built with [`frame`].
|
||||||
//!
|
//!
|
||||||
//! To get started with this pezpallet, try implementing the guide in
|
//! To get started with this pezpallet, try implementing the guide in
|
||||||
//! <https://github.com/pezkuwichain/pezkuwi-sdk>
|
//! <https://docs.pezkuwichain.io/sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html>
|
||||||
|
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
use pezkuwi_sdk::pezkuwi_sdk_frame::deps::pezframe_support::pezpallet_prelude::*;
|
use frame::prelude::*;
|
||||||
|
use pezkuwi_sdk::pezkuwi_sdk_frame as frame;
|
||||||
|
|
||||||
// Re-export all pezpallet parts, this is needed to properly import the pezpallet into the runtime.
|
// Re-export all pezpallet parts, this is needed to properly import the pezpallet into the runtime.
|
||||||
pub use pallet::*;
|
pub use pezpallet::*;
|
||||||
|
|
||||||
#[pezkuwi_sdk::pezframe_support::pezpallet]
|
#[frame::pezpallet]
|
||||||
pub mod pallet {
|
pub mod pezpallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[pezpallet::config]
|
#[pezpallet::config]
|
||||||
|
|||||||
+57
-48
@@ -1,3 +1,20 @@
|
|||||||
|
// This file is part of Bizinikiwi.
|
||||||
|
|
||||||
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
//! A minimal runtime that includes the template [`pezpallet`](`pezpallet_minimal_template`).
|
//! A minimal runtime that includes the template [`pezpallet`](`pezpallet_minimal_template`).
|
||||||
|
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
@@ -9,26 +26,24 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
|||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use pezpallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
|
|
||||||
use pezkuwi_sdk::{
|
use pezkuwi_sdk::{
|
||||||
pezkuwi_sdk_frame::{
|
pezkuwi_sdk_frame::{
|
||||||
self as frame,
|
self as frame,
|
||||||
deps::pezsp_genesis_builder,
|
deps::pezsp_genesis_builder,
|
||||||
runtime::{apis, prelude::*},
|
runtime::{apis, prelude::*},
|
||||||
},
|
},
|
||||||
pezframe_system as frame_system,
|
|
||||||
*,
|
*,
|
||||||
};
|
};
|
||||||
|
use pezpallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
|
||||||
|
|
||||||
/// Provides getters for genesis configuration presets.
|
/// Provides getters for genesis configuration presets.
|
||||||
pub mod genesis_config_presets {
|
pub mod genesis_config_presets {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
interface::{Balance, MinimumBalance},
|
interface::{Balance, MinimumBalance},
|
||||||
runtime::{BalancesConfig, RuntimeGenesisConfig, SudoConfig},
|
BalancesConfig, RuntimeGenesisConfig, SudoConfig,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "std")]
|
use frame::deps::pezsp_keyring::Sr25519Keyring;
|
||||||
use pezkuwi_sdk::pezsp_keyring::Sr25519Keyring;
|
|
||||||
|
|
||||||
use alloc::{vec, vec::Vec};
|
use alloc::{vec, vec::Vec};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
@@ -86,34 +101,34 @@ pub fn native_version() -> NativeVersion {
|
|||||||
|
|
||||||
/// The transaction extensions that are added to the runtime.
|
/// The transaction extensions that are added to the runtime.
|
||||||
type TxExtension = (
|
type TxExtension = (
|
||||||
|
// Authorize calls that validate themselves.
|
||||||
|
pezframe_system::AuthorizeCall<Runtime>,
|
||||||
// Checks that the sender is not the zero address.
|
// Checks that the sender is not the zero address.
|
||||||
frame_system::CheckNonZeroSender<Runtime>,
|
pezframe_system::CheckNonZeroSender<Runtime>,
|
||||||
// Checks that the runtime version is correct.
|
// Checks that the runtime version is correct.
|
||||||
frame_system::CheckSpecVersion<Runtime>,
|
pezframe_system::CheckSpecVersion<Runtime>,
|
||||||
// Checks that the transaction version is correct.
|
// Checks that the transaction version is correct.
|
||||||
frame_system::CheckTxVersion<Runtime>,
|
pezframe_system::CheckTxVersion<Runtime>,
|
||||||
// Checks that the genesis hash is correct.
|
// Checks that the genesis hash is correct.
|
||||||
frame_system::CheckGenesis<Runtime>,
|
pezframe_system::CheckGenesis<Runtime>,
|
||||||
// Checks that the era is valid.
|
// Checks that the era is valid.
|
||||||
frame_system::CheckEra<Runtime>,
|
pezframe_system::CheckEra<Runtime>,
|
||||||
// Checks that the nonce is valid.
|
// Checks that the nonce is valid.
|
||||||
frame_system::CheckNonce<Runtime>,
|
pezframe_system::CheckNonce<Runtime>,
|
||||||
// Checks that the weight is valid.
|
// Checks that the weight is valid.
|
||||||
frame_system::CheckWeight<Runtime>,
|
pezframe_system::CheckWeight<Runtime>,
|
||||||
// Ensures that the sender has enough funds to pay for the transaction
|
// Ensures that the sender has enough funds to pay for the transaction
|
||||||
// and deducts the fee from the sender's account.
|
// and deducts the fee from the sender's account.
|
||||||
pezpallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
pezpallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||||
// Reclaim the unused weight from the block using post dispatch information.
|
// Reclaim the unused weight from the block using post dispatch information.
|
||||||
// It must be last in the pipeline in order to catch the refund in previous transaction
|
// It must be last in the pipeline in order to catch the refund in previous transaction
|
||||||
// extensions
|
// extensions
|
||||||
frame_system::WeightReclaim<Runtime>,
|
pezframe_system::WeightReclaim<Runtime>,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Composes the runtime by adding all the used pezpallets and deriving necessary types.
|
// Composes the runtime by adding all the used pallets and deriving necessary types.
|
||||||
#[frame_construct_runtime]
|
#[frame_construct_runtime]
|
||||||
pub mod runtime {
|
mod runtime {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
/// The main runtime type.
|
/// The main runtime type.
|
||||||
#[runtime::runtime]
|
#[runtime::runtime]
|
||||||
#[runtime::derive(
|
#[runtime::derive(
|
||||||
@@ -128,7 +143,6 @@ pub mod runtime {
|
|||||||
RuntimeTask,
|
RuntimeTask,
|
||||||
RuntimeViewFunction
|
RuntimeViewFunction
|
||||||
)]
|
)]
|
||||||
#[derive(Clone, PartialEq, Eq)]
|
|
||||||
pub struct Runtime;
|
pub struct Runtime;
|
||||||
|
|
||||||
/// Mandatory system pezpallet that should always be included in a FRAME runtime.
|
/// Mandatory system pezpallet that should always be included in a FRAME runtime.
|
||||||
@@ -156,24 +170,18 @@ pub mod runtime {
|
|||||||
pub type Template = pezpallet_minimal_template::Pezpallet<Runtime>;
|
pub type Template = pezpallet_minimal_template::Pezpallet<Runtime>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use runtime::{
|
|
||||||
Runtime, System, Timestamp, Balances, Sudo, TransactionPayment, Template,
|
|
||||||
RuntimeCall, RuntimeEvent, RuntimeError, RuntimeOrigin, RuntimeFreezeReason,
|
|
||||||
RuntimeHoldReason, RuntimeSlashReason, RuntimeLockId, RuntimeTask, RuntimeViewFunction,
|
|
||||||
AllPalletsWithSystem, RuntimeGenesisConfig, BalancesConfig, SudoConfig,
|
|
||||||
};
|
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const Version: RuntimeVersion = VERSION;
|
pub const Version: RuntimeVersion = VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements the types required for the system pezpallet.
|
/// Implements the types required for the system pezpallet.
|
||||||
#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
|
#[derive_impl(pezframe_system::config_preludes::SolochainDefaultConfig)]
|
||||||
impl frame_system::Config for Runtime {
|
impl pezframe_system::Config for Runtime {
|
||||||
type Block = Block;
|
type Block = Block;
|
||||||
type Version = Version;
|
type Version = Version;
|
||||||
// Use the account data from the balances pezpallet
|
// Use the account data from the balances pezpallet
|
||||||
type AccountData = pezpallet_balances::AccountData<<Runtime as pezpallet_balances::Config>::Balance>;
|
type AccountData =
|
||||||
|
pezpallet_balances::AccountData<<Runtime as pezpallet_balances::Config>::Balance>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements the types required for the balances pezpallet.
|
// Implements the types required for the balances pezpallet.
|
||||||
@@ -186,7 +194,7 @@ impl pezpallet_balances::Config for Runtime {
|
|||||||
#[derive_impl(pezpallet_sudo::config_preludes::TestDefaultConfig)]
|
#[derive_impl(pezpallet_sudo::config_preludes::TestDefaultConfig)]
|
||||||
impl pezpallet_sudo::Config for Runtime {}
|
impl pezpallet_sudo::Config for Runtime {}
|
||||||
|
|
||||||
// Implements the types required for the timestamp pezpallet.
|
// Implements the types required for the sudo pezpallet.
|
||||||
#[derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)]
|
#[derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)]
|
||||||
impl pezpallet_timestamp::Config for Runtime {}
|
impl pezpallet_timestamp::Config for Runtime {}
|
||||||
|
|
||||||
@@ -206,19 +214,22 @@ impl pezpallet_minimal_template::Config for Runtime {}
|
|||||||
type Block = frame::runtime::types_common::BlockOf<Runtime, TxExtension>;
|
type Block = frame::runtime::types_common::BlockOf<Runtime, TxExtension>;
|
||||||
type Header = HeaderFor<Runtime>;
|
type Header = HeaderFor<Runtime>;
|
||||||
|
|
||||||
type RuntimeExecutive =
|
type RuntimeExecutive = Executive<
|
||||||
Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllPalletsWithSystem>;
|
Runtime,
|
||||||
|
Block,
|
||||||
|
pezframe_system::ChainContext<Runtime>,
|
||||||
|
Runtime,
|
||||||
|
AllPalletsWithSystem,
|
||||||
|
>;
|
||||||
|
|
||||||
impl_runtime_apis! {
|
impl_runtime_apis! {
|
||||||
use pezsp_runtime::traits::BlockT;
|
|
||||||
|
|
||||||
impl apis::Core<Block> for Runtime {
|
impl apis::Core<Block> for Runtime {
|
||||||
fn version() -> RuntimeVersion {
|
fn version() -> RuntimeVersion {
|
||||||
VERSION
|
VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_block(block: <Block as BlockT>::LazyBlock) {
|
fn execute_block(block: <Block as frame::traits::Block>::LazyBlock) {
|
||||||
RuntimeExecutive::execute_block(block.into())
|
RuntimeExecutive::execute_block(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize_block(header: &Header) -> ExtrinsicInclusionMode {
|
fn initialize_block(header: &Header) -> ExtrinsicInclusionMode {
|
||||||
@@ -227,7 +238,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
impl apis::Metadata<Block> for Runtime {
|
impl apis::Metadata<Block> for Runtime {
|
||||||
fn metadata() -> OpaqueMetadata {
|
fn metadata() -> OpaqueMetadata {
|
||||||
Runtime::metadata()
|
OpaqueMetadata::new(Runtime::metadata().into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
|
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
|
||||||
@@ -249,16 +260,14 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn inherent_extrinsics(data: InherentData) -> Vec<ExtrinsicFor<Runtime>> {
|
fn inherent_extrinsics(data: InherentData) -> Vec<ExtrinsicFor<Runtime>> {
|
||||||
// TODO: Implement proper inherent extrinsics creation
|
data.create_extrinsics()
|
||||||
Vec::new()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_inherents(
|
fn check_inherents(
|
||||||
block: <Block as BlockT>::LazyBlock,
|
block: <Block as frame::traits::Block>::LazyBlock,
|
||||||
data: InherentData,
|
data: InherentData,
|
||||||
) -> CheckInherentsResult {
|
) -> CheckInherentsResult {
|
||||||
// TODO: Implement proper inherents checking
|
data.check_extrinsics(&block)
|
||||||
CheckInherentsResult::new()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +275,7 @@ impl_runtime_apis! {
|
|||||||
fn validate_transaction(
|
fn validate_transaction(
|
||||||
source: TransactionSource,
|
source: TransactionSource,
|
||||||
tx: ExtrinsicFor<Runtime>,
|
tx: ExtrinsicFor<Runtime>,
|
||||||
block_hash: <Runtime as frame_system::Config>::Hash,
|
block_hash: <Runtime as pezframe_system::Config>::Hash,
|
||||||
) -> TransactionValidity {
|
) -> TransactionValidity {
|
||||||
RuntimeExecutive::validate_transaction(source, tx, block_hash)
|
RuntimeExecutive::validate_transaction(source, tx, block_hash)
|
||||||
}
|
}
|
||||||
@@ -333,16 +342,16 @@ impl_runtime_apis! {
|
|||||||
///
|
///
|
||||||
/// Other types should preferably be private.
|
/// Other types should preferably be private.
|
||||||
// TODO: this should be standardized in some way, see:
|
// TODO: this should be standardized in some way, see:
|
||||||
// https://github.com/paritytech/substrate/issues/10579#issuecomment-1600537558
|
// https://github.com/pezkuwichain/pezkuwi-sdk/issues/3
|
||||||
pub mod interface {
|
pub mod interface {
|
||||||
use super::{Runtime, frame_system};
|
use super::Runtime;
|
||||||
use pezkuwi_sdk::{pezkuwi_sdk_frame as frame, *, pezpallet_balances};
|
use pezkuwi_sdk::{pezkuwi_sdk_frame as frame, *};
|
||||||
|
|
||||||
pub type Block = super::Block;
|
pub type Block = super::Block;
|
||||||
pub use frame::runtime::types_common::OpaqueBlock;
|
pub use frame::runtime::types_common::OpaqueBlock;
|
||||||
pub type AccountId = <Runtime as frame_system::Config>::AccountId;
|
pub type AccountId = <Runtime as pezframe_system::Config>::AccountId;
|
||||||
pub type Nonce = <Runtime as frame_system::Config>::Nonce;
|
pub type Nonce = <Runtime as pezframe_system::Config>::Nonce;
|
||||||
pub type Hash = <Runtime as frame_system::Config>::Hash;
|
pub type Hash = <Runtime as pezframe_system::Config>::Hash;
|
||||||
pub type Balance = <Runtime as pezpallet_balances::Config>::Balance;
|
pub type Balance = <Runtime as pezpallet_balances::Config>::Balance;
|
||||||
pub type MinimumBalance = <Runtime as pezpallet_balances::Config>::ExistentialDeposit;
|
pub type MinimumBalance = <Runtime as pezpallet_balances::Config>::ExistentialDeposit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user