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
+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;
}