Refactor project structure: replace template pallet with pezpallets

- Remove template pallet (pallets/template/)
- Add new pezpallets module
- Update Cargo.toml and Cargo.lock with new dependencies
- Update node and runtime configurations
- Update README documentation
This commit is contained in:
2025-12-25 05:33:37 +03:00
parent c6f71c73f6
commit 01258776ab
22 changed files with 11256 additions and 10091 deletions
Generated
+10821 -9662
View File
File diff suppressed because it is too large Load Diff
+20 -9
View File
@@ -1,31 +1,42 @@
[workspace.package]
license = "MIT-0"
authors = ["Parity Technologies <admin@parity.io>"]
homepage = "https://paritytech.github.io/polkadot-sdk/"
repository = "https://github.com/paritytech/polkadot-sdk-minimal-template.git"
authors = ["Pezkuwi <admin@pezkuwihain.io>"]
homepage = "https://github.com/pezkuwichain/"
repository = "https://github.com/pezkuwichain/pezkuwi-sdk-minimal-template.git"
edition = "2021"
[workspace]
default-members = ["pallets/template", "runtime"]
default-members = ["pezpallets/template", "runtime"]
members = [
"node",
"pallets/template",
"pezpallets/template",
"runtime",
]
resolver = "2"
[workspace.dependencies]
minimal-template-runtime = { path = "./runtime", default-features = false }
pallet-minimal-template = { path = "./pallets/template", default-features = false }
pez-minimal-template-runtime = { path = "./runtime", default-features = false }
pezpallet-minimal-template = { path = "./pezpallets/template", default-features = false }
clap = { version = "4.5.13" }
docify = { version = "0.2.9" }
futures = { version = "0.3.31" }
futures-timer = { version = "3.0.2" }
jsonrpsee = { version = "0.24.3" }
polkadot-sdk = { version = "2503.0.1", default-features = false }
codec = { version = "3.7.4", default-features = false, package = "parity-scale-codec" }
codec = { version = "3.7.5", default-features = false, package = "parity-scale-codec" }
scale-info = { version = "2.11.6", default-features = false }
serde_json = { version = "1.0.132", default-features = false }
pezkuwi-sdk = { version = "0.1.0", default-features = false }
pezframe-support = { version = "28.0.0", default-features = false }
pezframe-system = { version = "28.0.0", default-features = false }
pezpallet-balances = { version = "28.0.0", default-features = false }
pezpallet-sudo = { version = "28.0.0", default-features = false }
pezpallet-timestamp = { version = "27.0.0", default-features = false }
pezpallet-transaction-payment = { version = "28.0.0", default-features = false }
pezpallet-transaction-payment-rpc-runtime-api = { version = "28.0.0", default-features = false }
pezsp-api = { version = "26.0.0", default-features = false } # Corrected version
pezsp-keyring = { version = "28.0.0", default-features = false } # Assumed version
pezsp-weights = { version = "28.0.0", default-features = false } # Assumed version
[profile.release]
opt-level = 3
+48 -48
View File
@@ -1,13 +1,13 @@
<div align="center">
# Polkadot SDK's Minimal Template
# Pezkuwi SDK's Minimal Template
<img height="70px" alt="Polkadot SDK Logo" src="https://github.com/paritytech/polkadot-sdk/raw/master/docs/images/Polkadot_Logo_Horizontal_Pink_White.png#gh-dark-mode-only"/>
<img height="70px" alt="Polkadot SDK Logo" src="https://github.com/paritytech/polkadot-sdk/raw/master/docs/images/Polkadot_Logo_Horizontal_Pink_Black.png#gh-light-mode-only"/>
<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/raw/master/docs/images/Pezkuwi_Logo_Horizontal_Pink_Black.png#gh-light-mode-only"/>
> This is a minimal template for creating a blockchain based on Polkadot SDK.
> This is a minimal template for creating a blockchain based on Pezkuwi SDK.
>
> This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).
> This template is automatically updated after releases in the main [Pezkuwi SDK monorepo](https://github.com/pezkuwichain/pezkuwi-sdk).
</div>
@@ -23,9 +23,9 @@
- [Omni Node](#omni-node)
- [Minimal Template Node](#minimal-template-node)
- [Zombienet with Omni Node](#zombienet-with-omni-node)
- [Zombienet with Minimal Template Node](#zombienet-with-minimal-template-node)
- [Connect with the Polkadot-JS Apps Front-End](#connect-with-the-polkadot-js-apps-front-end)
- [Zombienet with Omni Node](#pezkuwi-zombienet-with-omni-node)
- [Zombienet with Minimal Template Node](#pezkuwi-zombienet-with-minimal-template-node)
- [Connect with the Pezkuwi-JS Apps Front-End](#connect-with-the-pezkuwi-js-apps-front-end)
- [Takeaways](#takeaways)
- [Contributing](#contributing)
@@ -37,18 +37,18 @@
- 🤏 This template is a minimal (in terms of complexity and the number of components)
template for building a blockchain node.
- 🔧 Its runtime is configured with a single custom pallet as a starting point, and a handful of ready-made pallets
such as a [Balances pallet](https://paritytech.github.io/polkadot-sdk/master/pallet_balances/index.html).
- 🔧 Its runtime is configured with a single custom pezpallet as a starting point, and a handful of ready-made pezpallets
such as a [Balances pezpallet](https://pezkuwichain.github.io/pezkuwi-sdk/master/pezpallet_balances/index.html).
- 👤 The template has no consensus configured - it is best for experimenting with a single node network.
## Template Structure
A Polkadot SDK based project such as this one consists of:
A Pezkuwi SDK based project such as this one consists of:
- 🧮 the [Runtime](./runtime/README.md) - the core logic of the blockchain.
- 🎨 the [Pallets](./pallets/README.md) - from which the runtime is constructed.
- 🎨 the [Pezpallets](./pezpallets/README.md) - from which the runtime is constructed.
- 💿 a [Node](./node/README.md) - the binary application (which is not part of the cargo default-members list and is not
compiled unless building the entire workspace).
@@ -65,7 +65,7 @@ packages required to compile this template - please take note of the Rust compil
Fetch minimal template code.
```sh
git clone https://github.com/paritytech/polkadot-sdk-minimal-template.git minimal-template
git clone https://github.com/pezkuwichain/pezkuwi-sdk-minimal-template.git minimal-template
cd minimal-template
```
@@ -74,13 +74,13 @@ cd minimal-template
### Omni Node
[Omni Node](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/omni_node/index.html) can
be used to run the minimal template's runtime. `polkadot-omni-node` binary crate usage is described at a high-level
[on crates.io](https://crates.io/crates/polkadot-omni-node).
[Omni Node](https://pezkuwichain.github.io/pezkuwi-sdk/master/pezkuwi_sdk_docs/reference_docs/omni_node/index.html) can
be used to run the minimal template's runtime. `pezkuwi-omni-node` binary crate usage is described at a high-level
[on crates.io](https://crates.io/crates/pezkuwi-omni-node).
#### Install `polkadot-omni-node`
#### Install `pezkuwi-omni-node`
Please see installation section on [crates.io/omni-node](https://crates.io/crates/polkadot-omni-node).
Please see installation section on [crates.io/omni-node](https://crates.io/crates/pezkuwi-omni-node).
#### Build `minimal-template-runtime`
@@ -88,9 +88,9 @@ Please see installation section on [crates.io/omni-node](https://crates.io/crate
cargo build -p minimal-template-runtime --release
```
#### Install `staging-chain-spec-builder`
#### Install `pezstaging-chain-spec-builder`
Please see the installation section at [`crates.io/staging-chain-spec-builder`](https://crates.io/crates/staging-chain-spec-builder).
Please see the installation section at [`crates.io/pezstaging-chain-spec-builder`](https://crates.io/crates/pezstaging-chain-spec-builder).
#### Use chain-spec-builder to generate the chain_spec.json file
@@ -110,7 +110,7 @@ Start Omni Node in development mode (sets up block production and finalization b
sealing a new block every 3 seconds), with a minimal template runtime chain spec.
```sh
polkadot-omni-node --chain <path/to/chain_spec.json> --dev
pezkuwi-omni-node --chain <path/to/chain_spec.json> --dev
```
### Minimal Template Node
@@ -125,7 +125,7 @@ cargo build --workspace --release
and has as entry point the node binary:
```sh
docker build . -t polkadot-sdk-minimal-template
docker build . -t pezkuwi-sdk-minimal-template
```
#### Start the `minimal-template-node`
@@ -138,23 +138,23 @@ depend on a specific runtime, but asks for the chain spec at startup.
```sh
<target/release/path/to/minimal-template-node> --tmp --consensus manual-seal-3000
# or via docker
docker run --rm polkadot-sdk-minimal-template
docker run --rm pezkuwi-sdk-minimal-template
```
### Zombienet with Omni Node
#### Install `zombienet`
#### Install `pezkuwi-zombienet`
We can install `zombienet` as described [here](https://paritytech.github.io/zombienet/install.html#installation),
and `zombienet-omni-node.toml` contains the network specification we want to start.
We can install `pezkuwi-zombienet` as described [here](https://github.com/pezkuwichain/pezkuwi-zombienet-sdk/install.html#installation),
and `pezkuwi-zombienet-omni-node.toml` contains the network specification we want to start.
#### Update `zombienet-omni-node.toml` with a valid chain spec path
#### Update `pezkuwi-zombienet-omni-node.toml` with a valid chain spec path
To simplify the process of starting the minimal template with ZombieNet and Omni Node, we've included a
pre-configured development chain spec (dev_chain_spec.json) in the minimal template. The zombienet-omni-node.toml
pre-configured development chain spec (dev_chain_spec.json) in the minimal template. The pezkuwi-zombienet-omni-node.toml
file in this template points to it, but you can update it to a new path for the chain spec generated on your machine.
To generate a chain spec refer to [staging-chain-spec-builder](https://crates.io/crates/staging-chain-spec-builder)
To generate a chain spec refer to [pezstaging-chain-spec-builder](https://crates.io/crates/pezstaging-chain-spec-builder)
Then make the changes in the network specification like so:
@@ -169,28 +169,28 @@ default_args = ["--dev"]
#### Start the network
```sh
zombienet --provider native spawn zombienet-omni-node.toml
pezkuwi-zombienet --provider native spawn pezkuwi-zombienet-omni-node.toml
```
### Zombienet with `minimal-template-node`
For this one we just need to have `zombienet` installed and run:
For this one we just need to have `pezkuwi-zombienet` installed and run:
```sh
zombienet --provider native spawn zombienet-multi-node.toml
pezkuwi-zombienet --provider native spawn pezkuwi-zombienet-multi-node.toml
```
### Connect with the Polkadot-JS Apps Front-End
### Connect with the Pezkuwi-JS Apps Front-End
- 🌐 You can interact with your local node using the
hosted version of the [Polkadot/Substrate
Portal](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944).
hosted version of the [Pezkuwi/Bizinikiwi
Portal](https://pezkuwi.js.org/apps/#/explorer?rpc=ws://localhost:9944).
- 🪐 A hosted version is also
available on [IPFS](https://dotapps.io/).
available on [IPFS](https://hezapps.io/).
- 🧑‍🔧 You can also find the source code and instructions for hosting your own instance in the
[`polkadot-js/apps`](https://github.com/polkadot-js/apps) repository.
[`pezkuwi-js/apps`](https://github.com/pezkuwi-js/apps) repository.
### Takeaways
@@ -203,22 +203,22 @@ Previously minimal template's development chains:
## Contributing
- 🔄 This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).
- 🔄 This template is automatically updated after releases in the main [Pezkuwi SDK monorepo](https://github.com/pezkuwichain/pezkuwi-sdk).
- ➡️ Any pull requests should be directed to this [source](https://github.com/paritytech/polkadot-sdk/tree/master/templates/minimal).
- ➡️ Any pull requests should be directed to this [source](https://github.com/pezkuwichain/pezkuwi-sdk/tree/master/templates/minimal).
- 😇 Please refer to the monorepo's
[contribution guidelines](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md) and
[Code of Conduct](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CODE_OF_CONDUCT.md).
[contribution guidelines](https://github.com/pezkuwichain/pezkuwi-sdk/blob/master/docs/contributor/CONTRIBUTING.md) and
[Code of Conduct](https://github.com/pezkuwichain/pezkuwi-sdk/blob/master/docs/contributor/CODE_OF_CONDUCT.md).
## Getting Help
- 🧑‍🏫 To learn about Polkadot in general, [docs.Polkadot.com](https://docs.polkadot.com/) website is a good starting point.
- 🧑‍🏫 To learn about Pezkuwi in general, [docs.Pezkuwi.com](https://docs.pezkuwichain.io/) website is a good starting point.
- 🧑‍🔧 For technical introduction, [here](https://github.com/paritytech/polkadot-sdk#-documentation) are
the Polkadot SDK documentation resources.
- 🧑‍🔧 For technical introduction, [here](https://github.com/pezkuwichain/pezkuwi-sdk#-documentation) are
the Pezkuwi SDK documentation resources.
- 👥 Additionally, there are [GitHub issues](https://github.com/paritytech/polkadot-sdk/issues) and
[Substrate StackExchange](https://substrate.stackexchange.com/).
- 👥You can also reach out on the [Official Polkdot discord server](https://polkadot-discord.w3f.tools/)
- 🧑Reach out on [Telegram](https://t.me/substratedevs) for more questions and discussions
- 👥 Additionally, there are [GitHub issues](https://github.com/pezkuwichain/pezkuwi-sdk/issues) and
[Bizinikiwi StackExchange](https://bizinikiwi.stackexchange.com/).
- 👥You can also reach out on the [Official Pezkuwichain discord server](https://pezkuwi-discord.w3f.tools/)
- 🧑Reach out on [Telegram](https://t.me/bizinikiwidevs) for more questions and discussions
+7 -7
View File
@@ -1,6 +1,6 @@
[package]
name = "minimal-template-node"
description = "A minimal Substrate-based Substrate node, ready for hacking."
name = "pez-minimal-template-node"
description = "A minimal bizinikiwi-based bizinikiwi node, ready for hacking."
version = "0.1.0"
license = "Unlicense"
authors.workspace = true
@@ -19,15 +19,15 @@ docify = { workspace = true }
futures = { features = ["thread-pool"], workspace = true }
futures-timer = { workspace = true }
jsonrpsee = { features = ["server"], workspace = true }
minimal-template-runtime.workspace = true
polkadot-sdk = { workspace = true, features = ["experimental", "node"] }
pez-minimal-template-runtime = { workspace = true }
pezkuwi-sdk = { workspace = true, features = ["experimental", "node"] }
[build-dependencies]
polkadot-sdk = { workspace = true, features = ["substrate-build-script-utils"] }
pezkuwi-sdk = { workspace = true, features = ["bizinikiwi-build-script-utils"] }
[features]
default = ["std"]
std = [
"minimal-template-runtime/std",
"polkadot-sdk/std",
"pez-minimal-template-runtime/std",
"pezkuwi-sdk/std",
]
+2 -2
View File
@@ -1,6 +1,6 @@
// This file is part of Substrate.
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// Copyright (C) Parity Technologies (UK) Ltd. and Kurdistan Blockchain Technologies Institute
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
+9 -9
View File
@@ -1,6 +1,6 @@
// This file is part of Substrate.
// This file is part of pezkuwi-sdk.
// Copyright (C) Parity Technologies (UK) Ltd.
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,19 +15,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use minimal_template_runtime::WASM_BINARY;
use polkadot_sdk::{
sc_service::{ChainType, Properties},
use pez_minimal_template_runtime::WASM_BINARY;
use pezkuwi_sdk::{
pezsc_service::{ChainType, Properties},
*,
};
/// This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec;
/// This is a specialization of the general bizinikiwi ChainSpec type.
pub type ChainSpec = pezsc_service::GenericChainSpec;
fn props() -> Properties {
let mut properties = Properties::new();
properties.insert("tokenDecimals".to_string(), 0.into());
properties.insert("tokenSymbol".to_string(), "MINI".into());
properties.insert("tokenSymbol".to_string(), "PEZ".into());
properties
}
@@ -36,7 +36,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> {
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
.with_genesis_config_preset_name(pezsp_genesis_builder::DEV_RUNTIME_PRESET)
.with_properties(props())
.build())
}
+12 -13
View File
@@ -1,8 +1,7 @@
// This file is part of Substrate.
// This file is part of pezkuwi-sdk.
// Copyright (C) Parity Technologies (UK) Ltd.
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
// 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
@@ -15,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use polkadot_sdk::{sc_cli::RunCmd, *};
use pezkuwi_sdk::{pezsc_cli::RunCmd, *};
#[derive(Debug, Clone)]
pub enum Consensus {
@@ -56,29 +55,29 @@ pub struct Cli {
pub enum Subcommand {
/// Key management cli utilities
#[command(subcommand)]
Key(sc_cli::KeySubcommand),
Key(pezsc_cli::KeySubcommand),
/// Build a chain specification.
BuildSpec(sc_cli::BuildSpecCmd),
BuildSpec(pezsc_cli::BuildSpecCmd),
/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),
CheckBlock(pezsc_cli::CheckBlockCmd),
/// Export blocks.
ExportBlocks(sc_cli::ExportBlocksCmd),
ExportBlocks(pezsc_cli::ExportBlocksCmd),
/// Export the state of a given block into a chain spec.
ExportState(sc_cli::ExportStateCmd),
ExportState(pezsc_cli::ExportStateCmd),
/// Import blocks.
ImportBlocks(sc_cli::ImportBlocksCmd),
ImportBlocks(pezsc_cli::ImportBlocksCmd),
/// Remove the whole chain.
PurgeChain(sc_cli::PurgeChainCmd),
PurgeChain(pezsc_cli::PurgeChainCmd),
/// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd),
Revert(pezsc_cli::RevertCmd),
/// Db meta columns information.
ChainInfo(sc_cli::ChainInfoCmd),
ChainInfo(pezsc_cli::ChainInfoCmd),
}
+15 -15
View File
@@ -1,6 +1,6 @@
// This file is part of Substrate.
// This file is part of pezkuwi-sdk.
// Copyright (C) Parity Technologies (UK) Ltd.
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,15 +20,15 @@ use crate::{
cli::{Cli, Subcommand},
service,
};
use polkadot_sdk::{sc_cli::SubstrateCli, sc_service::PartialComponents, *};
use pezkuwi_sdk::{pezsc_cli::BizinikiwiCli, pezsc_service::PartialComponents, *};
impl SubstrateCli for Cli {
impl BizinikiwiCli for Cli {
fn impl_name() -> String {
"Substrate Node".into()
"Bizinikiwi Node".into()
}
fn impl_version() -> String {
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
env!("BIZINIKIWI_CLI_IMPL_VERSION").into()
}
fn description() -> String {
@@ -47,7 +47,7 @@ impl SubstrateCli for Cli {
2017
}
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
fn load_spec(&self, id: &str) -> Result<Box<dyn pezsc_service::ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_chain_spec()?),
path =>
@@ -57,7 +57,7 @@ impl SubstrateCli for Cli {
}
/// Parse and run command line arguments
pub fn run() -> sc_cli::Result<()> {
pub fn run() -> pezsc_cli::Result<()> {
let cli = Cli::from_args();
match &cli.subcommand {
@@ -111,20 +111,20 @@ pub fn run() -> sc_cli::Result<()> {
Some(Subcommand::ChainInfo(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
cmd.run::<minimal_template_runtime::interface::OpaqueBlock>(&config)
cmd.run::<pez_minimal_template_runtime::interface::OpaqueBlock>(&config)
})
},
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| async move {
match config.network.network_backend.unwrap_or_default() {
sc_network::config::NetworkBackendType::Libp2p =>
service::new_full::<sc_network::NetworkWorker<_, _>>(config, cli.consensus)
.map_err(sc_cli::Error::Service),
sc_network::config::NetworkBackendType::Litep2p => service::new_full::<
sc_network::Litep2pNetworkBackend,
pezsc_network::config::NetworkBackendType::Libp2p =>
service::new_full::<pezsc_network::NetworkWorker<_, _>>(config, cli.consensus)
.map_err(pezsc_cli::Error::Service),
pezsc_network::config::NetworkBackendType::Litep2p => service::new_full::<
pezsc_network::Litep2pNetworkBackend,
>(config, cli.consensus)
.map_err(sc_cli::Error::Service),
.map_err(pezsc_cli::Error::Service),
}
})
},
+2 -2
View File
@@ -1,6 +1,6 @@
// This file is part of Polkadot Sdk.
// This file is part of Pezkuwi Sdk.
// Copyright (C) Parity Technologies (UK) Ltd.
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
+4 -4
View File
@@ -1,6 +1,6 @@
// This file is part of Substrate.
// This file is part of pezkuwi-sdk.
// Copyright (C) Parity Technologies (UK) Ltd.
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Substrate Node Template CLI library.
//! Bizinikiwi Node Template CLI library.
#![warn(missing_docs)]
mod chain_spec;
@@ -24,6 +24,6 @@ mod command;
mod rpc;
mod service;
fn main() -> polkadot_sdk::sc_cli::Result<()> {
fn main() -> pezkuwi_sdk::pezsc_cli::Result<()> {
command::run()
}
+12 -12
View File
@@ -1,6 +1,6 @@
// This file is part of Substrate.
// This file is part of pezkuwi-sdk.
// Copyright (C) Parity Technologies (UK) Ltd.
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,17 +16,17 @@
// limitations under the License.
//! A collection of node-specific RPC methods.
//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer
//! used by Substrate nodes. This file extends those RPC definitions with
//! bizinikiwi provides the `pezsc-rpc` crate, which defines the core RPC layer
//! used by bizinikiwi nodes. This file extends those RPC definitions with
//! capabilities that are specific to this project's runtime configuration.
#![warn(missing_docs)]
use jsonrpsee::RpcModule;
use minimal_template_runtime::interface::{AccountId, Nonce, OpaqueBlock};
use polkadot_sdk::{
sc_transaction_pool_api::TransactionPool,
sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata},
use pez_minimal_template_runtime::interface::{AccountId, Nonce, OpaqueBlock};
use pezkuwi_sdk::{
pezsc_transaction_pool_api::TransactionPool,
pezsp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata},
*,
};
use std::sync::Arc;
@@ -48,15 +48,15 @@ where
C: Send
+ Sync
+ 'static
+ sp_api::ProvideRuntimeApi<OpaqueBlock>
+ pezsp_api::ProvideRuntimeApi<OpaqueBlock>
+ HeaderBackend<OpaqueBlock>
+ HeaderMetadata<OpaqueBlock, Error = BlockChainError>
+ 'static,
C::Api: sp_block_builder::BlockBuilder<OpaqueBlock>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
C::Api: pezsp_block_builder::BlockBuilder<OpaqueBlock>,
C::Api: pezframe_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
P: TransactionPool + 'static,
{
use polkadot_sdk::substrate_frame_rpc_system::{System, SystemApiServer};
use pezkuwi_sdk::pezframe_rpc_system::{System, SystemApiServer};
let mut module = RpcModule::new(());
let FullDeps { client, pool } = deps;
+38 -38
View File
@@ -1,6 +1,6 @@
// This file is part of Substrate.
// This file is part of pezkuwi-sdk.
// Copyright (C) Parity Technologies (UK) Ltd.
// Copyright (C) Pezkuwi Foundation. and Kurdistan Blockchain Technologies Institute (KBTI) 2024.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,34 +17,34 @@
use crate::cli::Consensus;
use futures::FutureExt;
use minimal_template_runtime::{interface::OpaqueBlock as Block, RuntimeApi};
use polkadot_sdk::{
sc_client_api::backend::Backend,
sc_executor::WasmExecutor,
sc_service::{error::Error as ServiceError, Configuration, TaskManager},
sc_telemetry::{Telemetry, TelemetryWorker},
sc_transaction_pool_api::OffchainTransactionPoolFactory,
sp_runtime::traits::Block as BlockT,
use pez_minimal_template_runtime::{interface::OpaqueBlock as Block, RuntimeApi};
use pezkuwi_sdk::{
pezsc_client_api::backend::Backend,
pezsc_executor::WasmExecutor,
pezsc_service::{error::Error as ServiceError, Configuration, TaskManager},
pezsc_telemetry::{Telemetry, TelemetryWorker},
pezsc_transaction_pool_api::OffchainTransactionPoolFactory,
pezsp_runtime::traits::Block as BlockT,
*,
};
use std::sync::Arc;
type HostFunctions = sp_io::SubstrateHostFunctions;
type HostFunctions = pezsp_io::BizinikiwiHostFunctions;
#[docify::export]
pub(crate) type FullClient =
sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;
pezsc_service::TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;
type FullBackend = sc_service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
type FullBackend = pezsc_service::TFullBackend<Block>;
type FullSelectChain = pezsc_consensus::LongestChain<FullBackend, Block>;
/// Assembly of PartialComponents (enough to run chain ops subcommands)
pub type Service = sc_service::PartialComponents<
pub type Service = pezsc_service::PartialComponents<
FullClient,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::TransactionPoolHandle<Block, FullClient>,
pezsc_consensus::DefaultImportQueue<Block>,
pezsc_transaction_pool::TransactionPoolHandle<Block, FullClient>,
Option<Telemetry>,
>;
@@ -53,17 +53,17 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
.telemetry_endpoints
.clone()
.filter(|x| !x.is_empty())
.map(|endpoints| -> Result<_, sc_telemetry::Error> {
.map(|endpoints| -> Result<_, pezsc_telemetry::Error> {
let worker = TelemetryWorker::new(16)?;
let telemetry = worker.handle().new_telemetry(endpoints);
Ok((worker, telemetry))
})
.transpose()?;
let executor = sc_service::new_wasm_executor(&config.executor);
let executor = pezsc_service::new_wasm_executor(&config.executor);
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
pezsc_service::new_full_parts::<Block, RuntimeApi, _>(
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
executor,
@@ -75,10 +75,10 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
telemetry
});
let select_chain = sc_consensus::LongestChain::new(backend.clone());
let select_chain = pezsc_consensus::LongestChain::new(backend.clone());
let transaction_pool = Arc::from(
sc_transaction_pool::Builder::new(
pezsc_transaction_pool::Builder::new(
task_manager.spawn_essential_handle(),
client.clone(),
config.role.is_authority().into(),
@@ -88,13 +88,13 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
.build(),
);
let import_queue = sc_consensus_manual_seal::import_queue(
let import_queue = pezsc_consensus_manual_seal::import_queue(
Box::new(client.clone()),
&task_manager.spawn_essential_handle(),
config.prometheus_registry(),
);
Ok(sc_service::PartialComponents {
Ok(pezsc_service::PartialComponents {
client,
backend,
task_manager,
@@ -107,11 +107,11 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
}
/// Builds a new service for a full client.
pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Hash>>(
pub fn new_full<Network: pezsc_network::NetworkBackend<Block, <Block as BlockT>::Hash>>(
config: Configuration,
consensus: Consensus,
) -> Result<TaskManager, ServiceError> {
let sc_service::PartialComponents {
let pezsc_service::PartialComponents {
client,
backend,
mut task_manager,
@@ -122,7 +122,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
other: mut telemetry,
} = new_partial(&config)?;
let net_config = sc_network::config::FullNetworkConfiguration::<
let net_config = pezsc_network::config::FullNetworkConfiguration::<
Block,
<Block as BlockT>::Hash,
Network,
@@ -135,7 +135,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
);
let (network, system_rpc_tx, tx_handler_controller, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
pezsc_service::build_network(pezsc_service::BuildNetworkParams {
config: &config,
net_config,
client: client.clone(),
@@ -150,7 +150,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
if config.offchain_worker.enabled {
let offchain_workers =
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
pezsc_offchain::OffchainWorkers::new(pezsc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
is_validator: config.role.is_authority(),
keystore: Some(keystore_container.keystore()),
@@ -181,7 +181,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
let prometheus_registry = config.prometheus_registry().cloned();
let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
let _rpc_handlers = pezsc_service::spawn_tasks(pezsc_service::SpawnTasksParams {
network,
client: client.clone(),
keystore: keystore_container.keystore(),
@@ -196,7 +196,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
telemetry: telemetry.as_mut(),
})?;
let proposer = sc_basic_authorship::ProposerFactory::new(
let proposer = pezsc_basic_authorship::ProposerFactory::new(
task_manager.spawn_handle(),
client.clone(),
transaction_pool.clone(),
@@ -206,7 +206,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
match consensus {
Consensus::InstantSeal => {
let params = sc_consensus_manual_seal::InstantSealParams {
let params = pezsc_consensus_manual_seal::InstantSealParams {
block_import: client.clone(),
env: proposer,
client,
@@ -214,11 +214,11 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
select_chain,
consensus_data_provider: None,
create_inherent_data_providers: move |_, ()| async move {
Ok(sp_timestamp::InherentDataProvider::from_system_time())
Ok(pezsp_timestamp::InherentDataProvider::from_system_time())
},
};
let authorship_future = sc_consensus_manual_seal::run_instant_seal(params);
let authorship_future = pezsc_consensus_manual_seal::run_instant_seal(params);
task_manager.spawn_essential_handle().spawn_blocking(
"instant-seal",
@@ -231,7 +231,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
task_manager.spawn_handle().spawn("block_authoring", None, async move {
loop {
futures_timer::Delay::new(std::time::Duration::from_millis(block_time)).await;
sink.try_send(sc_consensus_manual_seal::EngineCommand::SealNewBlock {
sink.try_send(pezsc_consensus_manual_seal::EngineCommand::SealNewBlock {
create_empty: true,
finalize: true,
parent_hash: None,
@@ -241,7 +241,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
}
});
let params = sc_consensus_manual_seal::ManualSealParams {
let params = pezsc_consensus_manual_seal::ManualSealParams {
block_import: client.clone(),
env: proposer,
client,
@@ -250,10 +250,10 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
commands_stream: Box::pin(commands_stream),
consensus_data_provider: None,
create_inherent_data_providers: move |_, ()| async move {
Ok(sp_timestamp::InherentDataProvider::from_system_time())
Ok(pezsp_timestamp::InherentDataProvider::from_system_time())
},
};
let authorship_future = sc_consensus_manual_seal::run_manual_seal(params);
let authorship_future = pezsc_consensus_manual_seal::run_manual_seal(params);
task_manager.spawn_essential_handle().spawn_blocking(
"manual-seal",
-13
View File
@@ -1,13 +0,0 @@
# Pallets
️ A pallet is a unit of encapsulated logic, with a clearly defined responsibility. A pallet is analogous to a
module in the runtime.
💁 In this template, there is a simple custom pallet based on the FRAME framework.
👉 Learn more about FRAME
[here](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html).
🧑‍🏫 Please refer to
[this guide](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html)
to learn how to write a basic pallet.
-23
View File
@@ -1,23 +0,0 @@
[package]
name = "pallet-minimal-template"
description = "A minimal pallet built with FRAME, part of Polkadot Sdk."
version = "0.1.0"
license = "Unlicense"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { features = ["derive"], workspace = true }
polkadot-sdk = { workspace = true, features = ["experimental", "runtime"], default-features = false }
scale-info = { features = ["derive"], workspace = true }
[features]
default = ["std"]
std = ["codec/std", "polkadot-sdk/std", "scale-info/std"]
-26
View File
@@ -1,26 +0,0 @@
//! A shell pallet built with [`frame`].
//!
//! To get started with this pallet, try implementing the guide in
//! <https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html>
#![cfg_attr(not(feature = "std"), no_std)]
use frame::prelude::*;
use polkadot_sdk::polkadot_sdk_frame as frame;
// Re-export all pallet parts, this is needed to properly import the pallet into the runtime.
pub use pallet::*;
#[frame::pallet]
pub mod pallet {
use super::*;
#[pallet::config]
pub trait Config: polkadot_sdk::frame_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::storage]
pub type Value<T> = StorageValue<Value = u32>;
}
+13
View File
@@ -0,0 +1,13 @@
# Pallets
️ A pallet is a unit of encapsulated logic, with a clearly defined responsibility. A pezpallet is analogous to a
module in the runtime.
💁 In this template, there is a simple custom pezpallet based on the PEZFRAME framework.
👉 Learn more about FRAME
[here](https://docs.pezkuwichain.io/pezkuwi-sdk/master/pezkuwi_sdk_docs/pezkuwi_sdk/pezframe_runtime/index.html).
🧑‍🏫 Please refer to
[this guide](https://docs.pezkuwichain.io/pezkuwi-sdk/master/pezkuwi_sdk_docs/guides/your_first_pezpallet/index.html)
to learn how to write a basic pallet.
+37
View File
@@ -0,0 +1,37 @@
[package]
name = "pezpallet-minimal-template"
description = "A minimal pezpallet built with PEZFRAME, part of Pezkuwi Sdk."
version = "0.1.0"
license = "Unlicense"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
# Removed `default-features = false` to ensure default features (like `std`) are enabled.
pezframe-support = { workspace = true }
pezframe-system = { workspace = true }
# Keep pezkuwi-sdk with default features disabled, and specify required features.
# This will ensure it resolves correctly through the patch.
pezkuwi-sdk = { workspace = true, features = ["experimental", "runtime"], default-features = false }
[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
# Ensure `std` feature is passed to `pezframe-support` and `pezframe-system`.
"pezframe-support/std",
"pezframe-system/std",
"pezkuwi-sdk/std"
]
+37
View File
@@ -0,0 +1,37 @@
//! A shell pezpallet built with `pezframe`.
#![cfg_attr(not(feature = "std"), no_std)]
// The preludes must be consistently rebranded as you instructed.
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
// We export the inner `pezpallet` module.
pub use self::pezpallet::*;
// The main macro is `pezpallet`, and dev_mode is used to handle weight/index warnings.
#[pezframe_support::pezpallet(dev_mode)]
// The module name is `pezpallet`.
pub mod pezpallet {
use super::*;
// All inner attributes must be consistently `#[pezpallet::...]`
#[pezpallet::config]
pub trait Config: pezkuwi_sdk::pezframe_system::Config {}
#[pezpallet::pezpallet]
// The struct name must be `Pezpallet`.
pub struct Pezpallet<T>(core::marker::PhantomData<T>);
#[pezpallet::storage]
#[pezpallet::getter(fn something)]
pub type Something<T> = StorageValue<_, u32>;
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
ensure_signed(origin)?;
Something::<T>::put(something);
Ok(())
}
}
}
+45 -10
View File
@@ -1,6 +1,6 @@
[package]
name = "minimal-template-runtime"
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk."
name = "pez-minimal-template-runtime"
description = "A solochain runtime template built with bizinikiwi, part of Pezkuwi Sdk."
version = "0.1.0"
license = "Unlicense"
authors.workspace = true
@@ -11,20 +11,55 @@ publish = false
[dependencies]
codec = { workspace = true }
pallet-minimal-template.workspace = true
polkadot-sdk = { workspace = true, features = ["pallet-balances", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "runtime"] }
pezpallet-minimal-template = { workspace = true }
scale-info = { workspace = true }
serde_json = { workspace = true, default-features = false, features = ["alloc"] }
# Explicitly add the dependencies needed for the macros and traits.
# These will be resolved by the [patch] section in the root Cargo.toml.
pezframe-support = { workspace = true, default-features = false }
pezframe-system = { workspace = true, default-features = false }
pezpallet-balances = { workspace = true, default-features = false }
pezpallet-sudo = { workspace = true, default-features = false }
pezpallet-timestamp = { workspace = true, default-features = false }
pezpallet-transaction-payment = { workspace = true, default-features = false }
pezpallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = false }
pezsp-api = { workspace = true, default-features = false }
pezsp-keyring = { workspace = true, default-features = false }
pezsp-weights = { workspace = true, default-features = false }
# Ensure pezkuwi-sdk is resolved and enable required features
pezkuwi-sdk = { workspace = true, default-features = false, features = [
"experimental",
"runtime",
"pezsp-api",
"pezsp-keyring",
"pezpallet-transaction-payment",
"pezpallet-transaction-payment-rpc-runtime-api",
"pezsp-weights",
"pezpallet-balances",
"pezpallet-sudo",
"pezpallet-timestamp",
"pezkuwi-sdk-frame", # CORRECTED to match the actual feature name in pezkuwi-sdk's Cargo.toml, NOT the Rust module path.
] }
[build-dependencies]
polkadot-sdk = { optional = true, workspace = true, features = ["substrate-wasm-builder"] }
pezkuwi-sdk = { optional = true, workspace = true, features = ["bizinikiwi-wasm-builder"] }
[features]
default = ["std"]
std = [
"codec/std",
"pallet-minimal-template/std",
"polkadot-sdk/std",
"scale-info/std",
"serde_json/std",
"codec/std",
"scale-info/std",
"pezframe-support/std",
"pezframe-system/std",
"pezpallet-balances/std",
"pezpallet-sudo/std",
"pezpallet-timestamp/std",
"pezpallet-transaction-payment/std",
"pezpallet-transaction-payment-rpc-runtime-api/std",
"pezsp-api/std",
"pezsp-keyring/std",
"pezsp-weights/std",
"pezkuwi-sdk/std", # Ensure std feature is passed to pezkuwi-sdk
]
+3 -3
View File
@@ -4,7 +4,7 @@
responsible for validating blocks and executing the state changes they define.
💁 The runtime in this template is constructed using ready-made FRAME pallets that ship with
[Polkadot SDK](https://github.com/paritytech/polkadot-sdk), and a [template for a custom pallet](../pallets/README.md).
[Pezkuwi SDK](https://github.com/pezkuwichain/pezkuwi-sdk), and a [template for a custom pallet](../pezpallets/README.md).
👉 Learn more about FRAME
[here](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html).
👉 Learn more about PEZFRAME
[here](https://docs.pezkuwichain.io/pezkuwi-sdk/master/pezkuwi_sdk_docs/pezkuwi_sdk/pezframe_runtime/index.html).
+3 -3
View File
@@ -1,6 +1,6 @@
// This file is part of Substrate.
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// Copyright (C) Parity Technologies (UK) Ltd. and Kurdistan Blockchain Technologies Institute
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +18,6 @@
fn main() {
#[cfg(feature = "std")]
{
polkadot_sdk::substrate_wasm_builder::WasmBuilder::build_using_defaults();
pezkuwi_sdk::bizinikiwi_wasm_builder::WasmBuilder::build_using_defaults();
}
}
+128 -192
View File
@@ -1,23 +1,7 @@
// This file is part of Substrate.
// 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 [`pallet`](`pallet_minimal_template`).
//! A minimal runtime that includes the template [`pezpallet`](`pezpallet_minimal_template`).
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]
// Make the WASM binary available.
#[cfg(feature = "std")]
@@ -26,45 +10,49 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
extern crate alloc;
use alloc::vec::Vec;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use polkadot_sdk::{
polkadot_sdk_frame::{
self as frame,
deps::sp_genesis_builder,
runtime::{apis, prelude::*},
},
// Use statements for external crates (from pezkuwi-sdk, patched via Cargo.toml)
use pezkuwi_sdk::{
pezkuwi_sdk_frame as pezframe, // Keep the rebranded alias
*,
};
use pezframe_support::traits::{FixedFee, Get, NoFee};
use pezpallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use pezsp_keyring::Sr25519Keyring;
use pezframe_support::genesis_builder_helper::{build_state, get_preset};
// Corrected imports for types that were previously unresolved
use pezframe_support::runtime::{ExtrinsicInclusionMode, NativeVersion, RuntimeVersion, RUNTIME_API_VERSIONS};
use pezframe_support::{OpaqueMetadata, ApplyExtrinsicResult, CheckInherentsResult};
use pezframe_support::transaction_validity::{TransactionSource, TransactionValidity};
use pezframe_support::inherent::InherentData;
use pezframe_support::ExtrinsicFor;
use pezsp_weights::Weight;
use pezframe::runtime::apis::PresetId;
/// Provides getters for genesis configuration presets.
pub mod genesis_config_presets {
use super::*;
use crate::{
interface::{Balance, MinimumBalance},
sp_keyring::Sr25519Keyring,
BalancesConfig, RuntimeGenesisConfig, SudoConfig,
};
use alloc::{vec, vec::Vec};
use serde_json::Value;
/// Returns a development genesis config preset.
pub fn development_config_genesis() -> Value {
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
frame_support::build_struct_json_patch!(RuntimeGenesisConfig {
balances: BalancesConfig {
let endowment = <interface::MinimumBalance as Get<interface::Balance>>::get().max(1) * 1000;
pezframe_support::build_struct_json_patch!(runtime::RuntimeGenesisConfig {
balances: runtime::BalancesConfig {
balances: Sr25519Keyring::iter()
.map(|a| (a.to_account_id(), endowment))
.collect::<Vec<_>>(),
},
sudo: SudoConfig { key: Some(Sr25519Keyring::Alice.to_account_id()) },
sudo: runtime::SudoConfig { key: Some(Sr25519Keyring::Alice.to_account_id()) },
})
}
/// Get the set of the available genesis config presets.
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
let patch = match id.as_ref() {
sp_genesis_builder::DEV_RUNTIME_PRESET => development_config_genesis(),
pezframe::deps::pezsp_genesis_builder::DEV_RUNTIME_PRESET => development_config_genesis(),
_ => return None,
};
Some(
@@ -76,154 +64,128 @@ pub mod genesis_config_presets {
/// List of supported presets.
pub fn preset_names() -> Vec<PresetId> {
vec![PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET)]
vec![PresetId::from(pezframe::deps::pezsp_genesis_builder::DEV_RUNTIME_PRESET)]
}
}
/// The runtime version.
#[runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: alloc::borrow::Cow::Borrowed("minimal-template-runtime"),
impl_name: alloc::borrow::Cow::Borrowed("minimal-template-runtime"),
authoring_version: 1,
spec_version: 0,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
system_version: 1,
};
pezframe_support::runtime_version! {
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: alloc::borrow::Cow::Borrowed("pez-minimal-template-runtime"),
impl_name: alloc::borrow::Cow::Borrowed("pez-minimal-template-runtime"),
authoring_version: 1,
spec_version: 0,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
system_version: 1,
};
}
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}
/// The transaction extensions that are added to the runtime.
type TxExtension = (
// Checks that the sender is not the zero address.
frame_system::CheckNonZeroSender<Runtime>,
// Checks that the runtime version is correct.
frame_system::CheckSpecVersion<Runtime>,
// Checks that the transaction version is correct.
frame_system::CheckTxVersion<Runtime>,
// Checks that the genesis hash is correct.
frame_system::CheckGenesis<Runtime>,
// Checks that the era is valid.
frame_system::CheckEra<Runtime>,
// Checks that the nonce is valid.
frame_system::CheckNonce<Runtime>,
// Checks that the weight is valid.
frame_system::CheckWeight<Runtime>,
// Ensures that the sender has enough funds to pay for the transaction
// and deducts the fee from the sender's account.
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
// 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
// extensions
frame_system::WeightReclaim<Runtime>,
pezframe_system::CheckNonZeroSender<runtime::Runtime>,
pezframe_system::CheckSpecVersion<runtime::Runtime>,
pezframe_system::CheckTxVersion<runtime::Runtime>,
pezframe_system::CheckGenesis<runtime::Runtime>,
pezframe_system::CheckEra<runtime::Runtime>,
pezframe_system::CheckNonce<runtime::Runtime>,
pezframe_system::CheckWeight<runtime::Runtime>,
pezpallet_transaction_payment::ChargeTransactionPayment<runtime::Runtime>,
pezframe_system::WeightReclaim<runtime::Runtime>,
);
// Composes the runtime by adding all the used pallets and deriving necessary types.
#[frame_construct_runtime]
mod runtime {
/// The main runtime type.
#[runtime::runtime]
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeFreezeReason,
RuntimeHoldReason,
RuntimeSlashReason,
RuntimeLockId,
RuntimeTask,
RuntimeViewFunction
)]
pub struct Runtime;
/// Mandatory system pallet that should always be included in a FRAME runtime.
#[runtime::pallet_index(0)]
pub type System = frame_system::Pallet<Runtime>;
/// Provides a way for consensus systems to set and check the onchain time.
#[runtime::pallet_index(1)]
pub type Timestamp = pallet_timestamp::Pallet<Runtime>;
/// Provides the ability to keep track of balances.
#[runtime::pallet_index(2)]
pub type Balances = pallet_balances::Pallet<Runtime>;
/// Provides a way to execute privileged functions.
#[runtime::pallet_index(3)]
pub type Sudo = pallet_sudo::Pallet<Runtime>;
/// Provides the ability to charge for extrinsic execution.
#[runtime::pallet_index(4)]
pub type TransactionPayment = pallet_transaction_payment::Pallet<Runtime>;
/// A minimal pallet template.
#[runtime::pallet_index(5)]
pub type Template = pallet_minimal_template::Pallet<Runtime>;
pezframe_support::construct_runtime! {
pub enum Runtime {
System: pezframe_system,
Timestamp: pezpallet_timestamp,
Balances: pezpallet_balances,
Sudo: pezpallet_sudo,
TransactionPayment: pezpallet_transaction_payment,
Template: pezpallet_minimal_template,
}
}
parameter_types! {
pub use runtime::{
Call as RuntimeCall,
Event as RuntimeEvent,
Error as RuntimeError,
Origin as RuntimeOrigin,
Runtime,
AllPalletsWithSystem,
BalancesConfig,
SudoConfig,
System,
Timestamp,
Balances,
Sudo,
TransactionPayment,
Template,
RuntimeGenesisConfig,
};
pezframe_support::parameter_types! {
pub const Version: RuntimeVersion = VERSION;
}
/// Implements the types required for the system pallet.
#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
impl frame_system::Config for Runtime {
type Block = Block;
type Version = Version;
// Use the account data from the balances pallet
type AccountData = pallet_balances::AccountData<<Runtime as pallet_balances::Config>::Balance>;
mod system_config {
use super::*;
#[pezframe_support::derive_impl(pezframe_system::config_preludes::SolochainDefaultConfig)]
impl pezframe_system::Config for Runtime {
type Block = Block;
type Version = Version;
type AccountData = pezpallet_balances::AccountData<<Runtime as pezpallet_balances::Config>::Balance>;
}
}
// Implements the types required for the balances pallet.
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Runtime {
type AccountStore = System;
mod balances_config {
use super::*;
#[pezframe_support::derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Runtime {
type AccountStore = System;
}
}
// Implements the types required for the sudo pallet.
#[derive_impl(pallet_sudo::config_preludes::TestDefaultConfig)]
impl pallet_sudo::Config for Runtime {}
// Implements the types required for the sudo pallet.
#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig)]
impl pallet_timestamp::Config for Runtime {}
// Implements the types required for the transaction payment pallet.
#[derive_impl(pallet_transaction_payment::config_preludes::TestDefaultConfig)]
impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
// Setting fee as independent of the weight of the extrinsic for demo purposes
type WeightToFee = NoFee<<Self as pallet_balances::Config>::Balance>;
// Setting fee as fixed for any length of the call data for demo purposes
type LengthToFee = FixedFee<1, <Self as pallet_balances::Config>::Balance>;
mod sudo_config {
use super::*;
#[pezframe_support::derive_impl(pezpallet_sudo::config_preludes::TestDefaultConfig)]
impl pezpallet_sudo::Config for Runtime {}
}
// Implements the types required for the template pallet.
impl pallet_minimal_template::Config for Runtime {}
mod timestamp_config {
use super::*;
#[pezframe_support::derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)]
impl pezpallet_timestamp::Config for Runtime {}
}
type Block = frame::runtime::types_common::BlockOf<Runtime, TxExtension>;
type Header = HeaderFor<Runtime>;
mod transaction_payment_config {
use super::*;
#[pezframe_support::derive_impl(pezpallet_transaction_payment::config_preludes::TestDefaultConfig)]
impl pezpallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = pezpallet_transaction_payment::FungibleAdapter<Balances, ()>;
type WeightToFee = NoFee<<Self as pezpallet_balances::Config>::Balance>;
type LengthToFee = FixedFee<1, <Self as pezpallet_balances::Config>::Balance>;
}
}
type RuntimeExecutive =
Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllPalletsWithSystem>;
impl pezpallet_minimal_template::Config for Runtime {}
impl_runtime_apis! {
type Block = pezframe::runtime::types_common::BlockOf<Runtime, TxExtension>;
type Header = pezframe::runtime::prelude::HeaderFor<Runtime>;
type RuntimeExecutive = pezframe::runtime::prelude::Executive<Runtime, Block, pezframe_system::ChainContext<Runtime>, Runtime, AllPalletsWithSystem>;
pezsp_api::impl_runtime_apis! {
impl apis::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
}
fn execute_block(block: Block) {
RuntimeExecutive::execute_block(block)
}
fn initialize_block(header: &Header) -> ExtrinsicInclusionMode {
RuntimeExecutive::initialize_block(header)
}
@@ -232,72 +194,55 @@ impl_runtime_apis! {
fn metadata() -> OpaqueMetadata {
OpaqueMetadata::new(Runtime::metadata().into())
}
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
Runtime::metadata_at_version(version)
}
fn metadata_versions() -> Vec<u32> {
Runtime::metadata_versions()
}
}
impl apis::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: ExtrinsicFor<Runtime>) -> ApplyExtrinsicResult {
RuntimeExecutive::apply_extrinsic(extrinsic)
}
fn finalize_block() -> HeaderFor<Runtime> {
RuntimeExecutive::finalize_block()
}
fn inherent_extrinsics(data: InherentData) -> Vec<ExtrinsicFor<Runtime>> {
data.create_extrinsics()
}
fn check_inherents(
block: Block,
data: InherentData,
) -> CheckInherentsResult {
fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
data.check_extrinsics(&block)
}
}
impl apis::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(
source: TransactionSource,
tx: ExtrinsicFor<Runtime>,
block_hash: <Runtime as frame_system::Config>::Hash,
block_hash: <Runtime as pezframe_system::Config>::Hash,
) -> TransactionValidity {
RuntimeExecutive::validate_transaction(source, tx, block_hash)
}
}
impl apis::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(header: &HeaderFor<Runtime>) {
RuntimeExecutive::offchain_worker(header)
}
}
impl apis::SessionKeys<Block> for Runtime {
fn generate_session_keys(_seed: Option<Vec<u8>>) -> Vec<u8> {
Default::default()
}
fn decode_session_keys(
_encoded: Vec<u8>,
) -> Option<Vec<(Vec<u8>, apis::KeyTypeId)>> {
fn decode_session_keys(_encoded: Vec<u8>) -> Option<Vec<(Vec<u8>, pezframe::runtime::apis::KeyTypeId)>> {
Default::default()
}
}
impl apis::AccountNonceApi<Block, interface::AccountId, interface::Nonce> for Runtime {
fn account_nonce(account: interface::AccountId) -> interface::Nonce {
System::account_nonce(account)
}
}
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
impl pezpallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
Block,
interface::Balance,
> for Runtime {
@@ -314,36 +259,27 @@ impl_runtime_apis! {
TransactionPayment::length_to_fee(length)
}
}
impl apis::GenesisBuilder<Block> for Runtime {
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
fn build_state(config: Vec<u8>) -> pezframe::deps::pezsp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
}
fn get_preset(id: &Option<PresetId>) -> Option<Vec<u8>> {
fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, self::genesis_config_presets::get_preset)
}
fn preset_names() -> Vec<PresetId> {
self::genesis_config_presets::preset_names()
}
}
}
/// Some re-exports that the node side code needs to know. Some are useful in this context as well.
///
/// Other types should preferably be private.
// TODO: this should be standardized in some way, see:
// https://github.com/paritytech/substrate/issues/10579#issuecomment-1600537558
pub mod interface {
use super::Runtime;
use polkadot_sdk::{polkadot_sdk_frame as frame, *};
use super::runtime::Runtime;
use pezkuwi_sdk::pezkuwi_sdk_pezframe as pezframe;
pub type Block = super::Block;
pub use frame::runtime::types_common::OpaqueBlock;
pub type AccountId = <Runtime as frame_system::Config>::AccountId;
pub type Nonce = <Runtime as frame_system::Config>::Nonce;
pub type Hash = <Runtime as frame_system::Config>::Hash;
pub type Balance = <Runtime as pallet_balances::Config>::Balance;
pub type MinimumBalance = <Runtime as pallet_balances::Config>::ExistentialDeposit;
pub use pezframe::runtime::types_common::OpaqueBlock;
pub type AccountId = <Runtime as pezframe_system::Config>::AccountId;
pub type Nonce = <Runtime as pezframe_system::Config>::Nonce;
pub type Hash = <Runtime as pezframe_system::Config>::Hash;
pub type Balance = <Runtime as pezpallet_balances::Config>::Balance;
pub type MinimumBalance = <Runtime as pezpallet_balances::Config>::ExistentialDeposit;
}