Merge master into development: Pezkuwi SDK rebrand

This commit is contained in:
2025-12-25 10:14:34 +03:00
10 changed files with 654 additions and 651 deletions
Generated
+402 -406
View File
File diff suppressed because it is too large Load Diff
+33 -13
View File
@@ -1,6 +1,6 @@
[workspace.package] [workspace.package]
license = "MIT-0" license = "MIT-0"
authors = ["Pezkuwi <admin@pezkuwihain.io>"] authors = ["Pezkuwi <admin@pezkuwichain.io>"]
homepage = "https://github.com/pezkuwichain/" homepage = "https://github.com/pezkuwichain/"
repository = "https://github.com/pezkuwichain/pezkuwi-sdk-minimal-template.git" repository = "https://github.com/pezkuwichain/pezkuwi-sdk-minimal-template.git"
edition = "2021" edition = "2021"
@@ -22,21 +22,10 @@ docify = { version = "0.2.9" }
futures = { version = "0.3.31" } futures = { version = "0.3.31" }
futures-timer = { version = "3.0.2" } futures-timer = { version = "3.0.2" }
jsonrpsee = { version = "0.24.3" } jsonrpsee = { version = "0.24.3" }
pezkuwi-sdk = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main", default-features = false }
codec = { version = "3.7.5", 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 } scale-info = { version = "2.11.6", default-features = false }
serde_json = { version = "1.0.132", 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] [profile.release]
opt-level = 3 opt-level = 3
@@ -47,3 +36,34 @@ codegen-units = 1
inherits = "release" inherits = "release"
lto = true lto = true
[patch.crates-io]
# Map rebranded Pezkuwi packages from the forked Pezkuwi SDK repository
pezkuwi-sdk = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezframe-support = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezframe-system = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezpallet-balances = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezpallet-sudo = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezpallet-timestamp = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezpallet-transaction-payment = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezpallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsp-api = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsp-keyring = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsp-weights = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsp-io = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsp-runtime = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsp-genesis-builder = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsp-timestamp = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsp-block-builder = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsp-blockchain = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-cli = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-service = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-client-api = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-executor = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-telemetry = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-transaction-pool-api = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-transaction-pool = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-consensus = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-consensus-manual-seal = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-network = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-offchain = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
pezsc-basic-authorship = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main" }
+2 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "pez-minimal-template-node" name = "pez-minimal-template-node"
description = "A minimal bizinikiwi-based bizinikiwi node, ready for hacking." description = "A minimal Bizinikiwi-based node, ready for hacking."
version = "0.1.0" version = "0.1.0"
license = "Unlicense" license = "Unlicense"
authors.workspace = true authors.workspace = true
@@ -19,7 +19,7 @@ docify = { workspace = true }
futures = { features = ["thread-pool"], workspace = true } futures = { features = ["thread-pool"], workspace = true }
futures-timer = { workspace = true } futures-timer = { workspace = true }
jsonrpsee = { features = ["server"], workspace = true } jsonrpsee = { features = ["server"], workspace = true }
pez-minimal-template-runtime = { workspace = true } pez-minimal-template-runtime.workspace = true
pezkuwi-sdk = { workspace = true, features = ["experimental", "node"] } pezkuwi-sdk = { workspace = true, features = ["experimental", "node"] }
[build-dependencies] [build-dependencies]
+1 -1
View File
@@ -15,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 polkadot_sdk::substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; use pezkuwi_sdk::bizinikiwi_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
fn main() { fn main() {
generate_cargo_keys(); generate_cargo_keys();
+4 -4
View File
@@ -1,13 +1,13 @@
# Pallets # Pallets
️ A pallet is a unit of encapsulated logic, with a clearly defined responsibility. A pezpallet is analogous to a ️ A pallet is a unit of encapsulated logic, with a clearly defined responsibility. A pallet is analogous to a
module in the runtime. module in the runtime.
💁 In this template, there is a simple custom pezpallet based on the PEZFRAME framework. 💁 In this template, there is a simple custom pallet based on the FRAME framework.
👉 Learn more about FRAME 👉 Learn more about FRAME
[here](https://docs.pezkuwichain.io/pezkuwi-sdk/master/pezkuwi_sdk_docs/pezkuwi_sdk/pezframe_runtime/index.html). [here](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html).
🧑‍🏫 Please refer to 🧑‍🏫 Please refer to
[this guide](https://docs.pezkuwichain.io/pezkuwi-sdk/master/pezkuwi_sdk_docs/guides/your_first_pezpallet/index.html) [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. to learn how to write a basic pallet.
+3 -17
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "pezpallet-minimal-template" name = "pezpallet-minimal-template"
description = "A minimal pezpallet built with PEZFRAME, part of Pezkuwi Sdk." description = "A minimal pezpallet built with Pezframe, part of Pezkuwi SDK."
version = "0.1.0" version = "0.1.0"
license = "Unlicense" license = "Unlicense"
authors.workspace = true authors.workspace = true
@@ -14,24 +14,10 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies] [dependencies]
codec = { features = ["derive"], workspace = true } 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 } pezkuwi-sdk = { workspace = true, features = ["experimental", "runtime"], default-features = false }
scale-info = { features = ["derive"], workspace = true }
[features] [features]
default = ["std"] default = ["std"]
std = [ std = ["codec/std", "pezkuwi-sdk/std", "scale-info/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"
]
+13 -25
View File
@@ -1,37 +1,25 @@
//! A shell pezpallet built with `pezframe`. //! A shell pezpallet built with [`pezframe`].
//!
//! To get started with this pezpallet, try implementing the guide in
//! <https://github.com/pezkuwichain/pezkuwi-sdk>
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// The preludes must be consistently rebranded as you instructed. use pezkuwi_sdk::pezkuwi_sdk_frame::deps::pezframe_support::pezpallet_prelude::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
// We export the inner `pezpallet` module. // Re-export all pezpallet parts, this is needed to properly import the pezpallet into the runtime.
pub use self::pezpallet::*; pub use pallet::*;
// The main macro is `pezpallet`, and dev_mode is used to handle weight/index warnings. #[pezkuwi_sdk::pezframe_support::pezpallet]
#[pezframe_support::pezpallet(dev_mode)] pub mod pallet {
// The module name is `pezpallet`.
pub mod pezpallet {
use super::*; use super::*;
// All inner attributes must be consistently `#[pezpallet::...]`
#[pezpallet::config] #[pezpallet::config]
pub trait Config: pezkuwi_sdk::pezframe_system::Config {} pub trait Config: pezkuwi_sdk::pezframe_system::Config {}
#[pezpallet::pezpallet] #[pezpallet::pezpallet]
// The struct name must be `Pezpallet`. pub struct Pezpallet<T>(_);
pub struct Pezpallet<T>(core::marker::PhantomData<T>);
#[pezpallet::storage] #[pezpallet::storage]
#[pezpallet::getter(fn something)] pub type Value<T> = StorageValue<Value = u32>;
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(())
}
}
}
+8 -43
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "pez-minimal-template-runtime" name = "pez-minimal-template-runtime"
description = "A solochain runtime template built with bizinikiwi, part of Pezkuwi Sdk." description = "A solochain runtime template built with Bizinikiwi, part of Pezkuwi SDK."
version = "0.1.0" version = "0.1.0"
license = "Unlicense" license = "Unlicense"
authors.workspace = true authors.workspace = true
@@ -11,55 +11,20 @@ publish = false
[dependencies] [dependencies]
codec = { workspace = true } codec = { workspace = true }
pezpallet-minimal-template = { workspace = true } pezpallet-minimal-template.workspace = true
pezkuwi-sdk = { workspace = true, features = ["pezpallet-balances", "pezpallet-sudo", "pezpallet-timestamp", "pezpallet-transaction-payment", "pezpallet-transaction-payment-rpc-runtime-api", "runtime", "pezsp-api"] }
scale-info = { workspace = true } scale-info = { workspace = true }
serde_json = { workspace = true, default-features = false, features = ["alloc"] } 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] [build-dependencies]
pezkuwi-sdk = { optional = true, workspace = true, features = ["bizinikiwi-wasm-builder"] } pezkuwi-sdk = { optional = true, workspace = true, features = ["bizinikiwi-wasm-builder"] }
[features] [features]
default = ["std"] default = ["std"]
std = [ std = [
"codec/std", "codec/std",
"scale-info/std", "pezpallet-minimal-template/std",
"pezframe-support/std", "pezkuwi-sdk/std",
"pezframe-system/std", "scale-info/std",
"pezpallet-balances/std", "serde_json/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
] ]
+1 -16
View File
@@ -1,19 +1,4 @@
// This file is part of Bizinikiwi. //! Build script for pez-minimal-template-runtime.
// 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");
// 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.
fn main() { fn main() {
#[cfg(feature = "std")] #[cfg(feature = "std")]
+187 -124
View File
@@ -1,7 +1,6 @@
//! 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)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]
// Make the WASM binary available. // Make the WASM binary available.
#[cfg(feature = "std")] #[cfg(feature = "std")]
@@ -10,49 +9,47 @@ 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 statements for external crates (from pezkuwi-sdk, patched via Cargo.toml)
use pezkuwi_sdk::{ use pezkuwi_sdk::{
pezkuwi_sdk_frame as pezframe, // Keep the rebranded alias pezkuwi_sdk_frame::{
self as frame,
deps::pezsp_genesis_builder,
runtime::{apis, prelude::*},
},
pezframe_system as frame_system,
*, *,
}; };
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. /// Provides getters for genesis configuration presets.
pub mod genesis_config_presets { pub mod genesis_config_presets {
use super::*; use super::*;
use crate::{
interface::{Balance, MinimumBalance},
runtime::{BalancesConfig, RuntimeGenesisConfig, SudoConfig},
};
#[cfg(feature = "std")]
use pezkuwi_sdk::pezsp_keyring::Sr25519Keyring;
use alloc::{vec, vec::Vec}; use alloc::{vec, vec::Vec};
use serde_json::Value; use serde_json::Value;
/// Returns a development genesis config preset. /// Returns a development genesis config preset.
pub fn development_config_genesis() -> Value { pub fn development_config_genesis() -> Value {
let endowment = <interface::MinimumBalance as Get<interface::Balance>>::get().max(1) * 1000; let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
pezframe_support::build_struct_json_patch!(runtime::RuntimeGenesisConfig { pezframe_support::build_struct_json_patch!(RuntimeGenesisConfig {
balances: runtime::BalancesConfig { balances: BalancesConfig {
balances: Sr25519Keyring::iter() balances: Sr25519Keyring::iter()
.map(|a| (a.to_account_id(), endowment)) .map(|a| (a.to_account_id(), endowment))
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
}, },
sudo: runtime::SudoConfig { key: Some(Sr25519Keyring::Alice.to_account_id()) }, sudo: SudoConfig { key: Some(Sr25519Keyring::Alice.to_account_id()) },
}) })
} }
/// Get the set of the available genesis config presets. /// Get the set of the available genesis config presets.
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> { pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
let patch = match id.as_ref() { let patch = match id.as_ref() {
pezframe::deps::pezsp_genesis_builder::DEV_RUNTIME_PRESET => development_config_genesis(), pezsp_genesis_builder::DEV_RUNTIME_PRESET => development_config_genesis(),
_ => return None, _ => return None,
}; };
Some( Some(
@@ -64,184 +61,241 @@ pub mod genesis_config_presets {
/// List of supported presets. /// List of supported presets.
pub fn preset_names() -> Vec<PresetId> { pub fn preset_names() -> Vec<PresetId> {
vec![PresetId::from(pezframe::deps::pezsp_genesis_builder::DEV_RUNTIME_PRESET)] vec![PresetId::from(pezsp_genesis_builder::DEV_RUNTIME_PRESET)]
} }
} }
pezframe_support::runtime_version! { /// The runtime version.
pub const VERSION: RuntimeVersion = RuntimeVersion { #[runtime_version]
spec_name: alloc::borrow::Cow::Borrowed("pez-minimal-template-runtime"), pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: alloc::borrow::Cow::Borrowed("pez-minimal-template-runtime"), spec_name: alloc::borrow::Cow::Borrowed("pez-minimal-template-runtime"),
authoring_version: 1, impl_name: alloc::borrow::Cow::Borrowed("pez-minimal-template-runtime"),
spec_version: 0, authoring_version: 1,
impl_version: 1, spec_version: 0,
apis: RUNTIME_API_VERSIONS, impl_version: 1,
transaction_version: 1, apis: RUNTIME_API_VERSIONS,
system_version: 1, transaction_version: 1,
}; system_version: 1,
} };
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub fn native_version() -> NativeVersion { pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
} }
/// The transaction extensions that are added to the runtime.
type TxExtension = ( type TxExtension = (
pezframe_system::CheckNonZeroSender<runtime::Runtime>, // Checks that the sender is not the zero address.
pezframe_system::CheckSpecVersion<runtime::Runtime>, frame_system::CheckNonZeroSender<Runtime>,
pezframe_system::CheckTxVersion<runtime::Runtime>, // Checks that the runtime version is correct.
pezframe_system::CheckGenesis<runtime::Runtime>, frame_system::CheckSpecVersion<Runtime>,
pezframe_system::CheckEra<runtime::Runtime>, // Checks that the transaction version is correct.
pezframe_system::CheckNonce<runtime::Runtime>, frame_system::CheckTxVersion<Runtime>,
pezframe_system::CheckWeight<runtime::Runtime>, // Checks that the genesis hash is correct.
pezpallet_transaction_payment::ChargeTransactionPayment<runtime::Runtime>, frame_system::CheckGenesis<Runtime>,
pezframe_system::WeightReclaim<runtime::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.
pezpallet_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_support::construct_runtime! { // Composes the runtime by adding all the used pezpallets and deriving necessary types.
pub enum Runtime { #[frame_construct_runtime]
System: pezframe_system, pub mod runtime {
Timestamp: pezpallet_timestamp, use super::*;
Balances: pezpallet_balances,
Sudo: pezpallet_sudo, /// The main runtime type.
TransactionPayment: pezpallet_transaction_payment, #[runtime::runtime]
Template: pezpallet_minimal_template, #[runtime::derive(
} RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeFreezeReason,
RuntimeHoldReason,
RuntimeSlashReason,
RuntimeLockId,
RuntimeTask,
RuntimeViewFunction
)]
#[derive(Clone, PartialEq, Eq)]
pub struct Runtime;
/// Mandatory system pezpallet that should always be included in a FRAME runtime.
#[runtime::pezpallet_index(0)]
pub type System = pezframe_system::Pezpallet<Runtime>;
/// Provides a way for consensus systems to set and check the onchain time.
#[runtime::pezpallet_index(1)]
pub type Timestamp = pezpallet_timestamp::Pezpallet<Runtime>;
/// Provides the ability to keep track of balances.
#[runtime::pezpallet_index(2)]
pub type Balances = pezpallet_balances::Pezpallet<Runtime>;
/// Provides a way to execute privileged functions.
#[runtime::pezpallet_index(3)]
pub type Sudo = pezpallet_sudo::Pezpallet<Runtime>;
/// Provides the ability to charge for extrinsic execution.
#[runtime::pezpallet_index(4)]
pub type TransactionPayment = pezpallet_transaction_payment::Pezpallet<Runtime>;
/// A minimal pezpallet template.
#[runtime::pezpallet_index(5)]
pub type Template = pezpallet_minimal_template::Pezpallet<Runtime>;
} }
pub use runtime::{ pub use runtime::{
Call as RuntimeCall, Runtime, System, Timestamp, Balances, Sudo, TransactionPayment, Template,
Event as RuntimeEvent, RuntimeCall, RuntimeEvent, RuntimeError, RuntimeOrigin, RuntimeFreezeReason,
Error as RuntimeError, RuntimeHoldReason, RuntimeSlashReason, RuntimeLockId, RuntimeTask, RuntimeViewFunction,
Origin as RuntimeOrigin, AllPalletsWithSystem, RuntimeGenesisConfig, BalancesConfig, SudoConfig,
Runtime,
AllPalletsWithSystem,
BalancesConfig,
SudoConfig,
System,
Timestamp,
Balances,
Sudo,
TransactionPayment,
Template,
RuntimeGenesisConfig,
}; };
pezframe_support::parameter_types! { parameter_types! {
pub const Version: RuntimeVersion = VERSION; pub const Version: RuntimeVersion = VERSION;
} }
mod system_config { /// Implements the types required for the system pezpallet.
use super::*; #[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
#[pezframe_support::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
type AccountData = pezpallet_balances::AccountData<<Runtime as pezpallet_balances::Config>::Balance>; type AccountData = pezpallet_balances::AccountData<<Runtime as pezpallet_balances::Config>::Balance>;
}
} }
mod balances_config { // Implements the types required for the balances pezpallet.
use super::*; #[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
#[pezframe_support::derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)] impl pezpallet_balances::Config for Runtime {
impl pezpallet_balances::Config for Runtime { type AccountStore = System;
type AccountStore = System;
}
} }
mod sudo_config { // Implements the types required for the sudo pezpallet.
use super::*; #[derive_impl(pezpallet_sudo::config_preludes::TestDefaultConfig)]
#[pezframe_support::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.
#[derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)]
mod timestamp_config { impl pezpallet_timestamp::Config for Runtime {}
use super::*;
#[pezframe_support::derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)] // Implements the types required for the transaction payment pezpallet.
impl pezpallet_timestamp::Config for Runtime {} #[derive_impl(pezpallet_transaction_payment::config_preludes::TestDefaultConfig)]
} impl pezpallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = pezpallet_transaction_payment::FungibleAdapter<Balances, ()>;
mod transaction_payment_config { // Setting fee as independent of the weight of the extrinsic for demo purposes
use super::*; type WeightToFee = NoFee<<Self as pezpallet_balances::Config>::Balance>;
#[pezframe_support::derive_impl(pezpallet_transaction_payment::config_preludes::TestDefaultConfig)] // Setting fee as fixed for any length of the call data for demo purposes
impl pezpallet_transaction_payment::Config for Runtime { type LengthToFee = FixedFee<1, <Self as pezpallet_balances::Config>::Balance>;
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>;
}
} }
// Implements the types required for the template pezpallet.
impl pezpallet_minimal_template::Config for Runtime {} impl pezpallet_minimal_template::Config for Runtime {}
type Block = pezframe::runtime::types_common::BlockOf<Runtime, TxExtension>; type Block = frame::runtime::types_common::BlockOf<Runtime, TxExtension>;
type Header = pezframe::runtime::prelude::HeaderFor<Runtime>; type Header = HeaderFor<Runtime>;
type RuntimeExecutive = pezframe::runtime::prelude::Executive<Runtime, Block, pezframe_system::ChainContext<Runtime>, Runtime, AllPalletsWithSystem>; type RuntimeExecutive =
Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllPalletsWithSystem>;
impl_runtime_apis! {
use pezsp_runtime::traits::BlockT;
pezsp_api::impl_runtime_apis! {
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) {
RuntimeExecutive::execute_block(block) fn execute_block(block: <Block as BlockT>::LazyBlock) {
RuntimeExecutive::execute_block(block.into())
} }
fn initialize_block(header: &Header) -> ExtrinsicInclusionMode { fn initialize_block(header: &Header) -> ExtrinsicInclusionMode {
RuntimeExecutive::initialize_block(header) RuntimeExecutive::initialize_block(header)
} }
} }
impl apis::Metadata<Block> for Runtime { impl apis::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata { fn metadata() -> OpaqueMetadata {
OpaqueMetadata::new(Runtime::metadata().into()) Runtime::metadata()
} }
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> { fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
Runtime::metadata_at_version(version) Runtime::metadata_at_version(version)
} }
fn metadata_versions() -> Vec<u32> { fn metadata_versions() -> Vec<u32> {
Runtime::metadata_versions() Runtime::metadata_versions()
} }
} }
impl apis::BlockBuilder<Block> for Runtime { impl apis::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: ExtrinsicFor<Runtime>) -> ApplyExtrinsicResult { fn apply_extrinsic(extrinsic: ExtrinsicFor<Runtime>) -> ApplyExtrinsicResult {
RuntimeExecutive::apply_extrinsic(extrinsic) RuntimeExecutive::apply_extrinsic(extrinsic)
} }
fn finalize_block() -> HeaderFor<Runtime> { fn finalize_block() -> HeaderFor<Runtime> {
RuntimeExecutive::finalize_block() RuntimeExecutive::finalize_block()
} }
fn inherent_extrinsics(data: InherentData) -> Vec<ExtrinsicFor<Runtime>> { fn inherent_extrinsics(data: InherentData) -> Vec<ExtrinsicFor<Runtime>> {
data.create_extrinsics() // TODO: Implement proper inherent extrinsics creation
Vec::new()
} }
fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
data.check_extrinsics(&block) fn check_inherents(
block: <Block as BlockT>::LazyBlock,
data: InherentData,
) -> CheckInherentsResult {
// TODO: Implement proper inherents checking
CheckInherentsResult::new()
} }
} }
impl apis::TaggedTransactionQueue<Block> for Runtime { impl apis::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction( fn validate_transaction(
source: TransactionSource, source: TransactionSource,
tx: ExtrinsicFor<Runtime>, tx: ExtrinsicFor<Runtime>,
block_hash: <Runtime as pezframe_system::Config>::Hash, block_hash: <Runtime as frame_system::Config>::Hash,
) -> TransactionValidity { ) -> TransactionValidity {
RuntimeExecutive::validate_transaction(source, tx, block_hash) RuntimeExecutive::validate_transaction(source, tx, block_hash)
} }
} }
impl apis::OffchainWorkerApi<Block> for Runtime { impl apis::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(header: &HeaderFor<Runtime>) { fn offchain_worker(header: &HeaderFor<Runtime>) {
RuntimeExecutive::offchain_worker(header) RuntimeExecutive::offchain_worker(header)
} }
} }
impl apis::SessionKeys<Block> for Runtime { impl apis::SessionKeys<Block> for Runtime {
fn generate_session_keys(_seed: Option<Vec<u8>>) -> Vec<u8> { fn generate_session_keys(_seed: Option<Vec<u8>>) -> Vec<u8> {
Default::default() Default::default()
} }
fn decode_session_keys(_encoded: Vec<u8>) -> Option<Vec<(Vec<u8>, pezframe::runtime::apis::KeyTypeId)>> {
fn decode_session_keys(
_encoded: Vec<u8>,
) -> Option<Vec<(Vec<u8>, apis::KeyTypeId)>> {
Default::default() Default::default()
} }
} }
impl apis::AccountNonceApi<Block, interface::AccountId, interface::Nonce> for Runtime { impl apis::AccountNonceApi<Block, interface::AccountId, interface::Nonce> for Runtime {
fn account_nonce(account: interface::AccountId) -> interface::Nonce { fn account_nonce(account: interface::AccountId) -> interface::Nonce {
System::account_nonce(account) System::account_nonce(account)
} }
} }
impl pezpallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< impl pezpallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
Block, Block,
interface::Balance, interface::Balance,
@@ -259,27 +313,36 @@ pezsp_api::impl_runtime_apis! {
TransactionPayment::length_to_fee(length) TransactionPayment::length_to_fee(length)
} }
} }
impl apis::GenesisBuilder<Block> for Runtime { impl apis::GenesisBuilder<Block> for Runtime {
fn build_state(config: Vec<u8>) -> pezframe::deps::pezsp_genesis_builder::Result { fn build_state(config: Vec<u8>) -> pezsp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config) build_state::<RuntimeGenesisConfig>(config)
} }
fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
fn get_preset(id: &Option<PresetId>) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, self::genesis_config_presets::get_preset) get_preset::<RuntimeGenesisConfig>(id, self::genesis_config_presets::get_preset)
} }
fn preset_names() -> Vec<PresetId> { fn preset_names() -> Vec<PresetId> {
self::genesis_config_presets::preset_names() 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 { pub mod interface {
use super::runtime::Runtime; use super::{Runtime, frame_system};
use pezkuwi_sdk::pezkuwi_sdk_pezframe as pezframe; use pezkuwi_sdk::{pezkuwi_sdk_frame as frame, *, pezpallet_balances};
pub type Block = super::Block; pub type Block = super::Block;
pub use pezframe::runtime::types_common::OpaqueBlock; pub use frame::runtime::types_common::OpaqueBlock;
pub type AccountId = <Runtime as pezframe_system::Config>::AccountId; pub type AccountId = <Runtime as frame_system::Config>::AccountId;
pub type Nonce = <Runtime as pezframe_system::Config>::Nonce; pub type Nonce = <Runtime as frame_system::Config>::Nonce;
pub type Hash = <Runtime as pezframe_system::Config>::Hash; pub type Hash = <Runtime as frame_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;
} }