mirror of
https://github.com/pezkuwichain/pez-minimal-template.git
synced 2026-04-22 05:38:00 +00:00
Merge master into development: Pezkuwi SDK rebrand
This commit is contained in:
Generated
+402
-406
File diff suppressed because it is too large
Load Diff
+33
-13
@@ -1,6 +1,6 @@
|
||||
[workspace.package]
|
||||
license = "MIT-0"
|
||||
authors = ["Pezkuwi <admin@pezkuwihain.io>"]
|
||||
authors = ["Pezkuwi <admin@pezkuwichain.io>"]
|
||||
homepage = "https://github.com/pezkuwichain/"
|
||||
repository = "https://github.com/pezkuwichain/pezkuwi-sdk-minimal-template.git"
|
||||
edition = "2021"
|
||||
@@ -22,21 +22,10 @@ docify = { version = "0.2.9" }
|
||||
futures = { version = "0.3.31" }
|
||||
futures-timer = { version = "3.0.2" }
|
||||
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" }
|
||||
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
|
||||
@@ -47,3 +36,34 @@ codegen-units = 1
|
||||
inherits = "release"
|
||||
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
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
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"
|
||||
license = "Unlicense"
|
||||
authors.workspace = true
|
||||
@@ -19,7 +19,7 @@ docify = { workspace = true }
|
||||
futures = { features = ["thread-pool"], workspace = true }
|
||||
futures-timer = { 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"] }
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// 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() {
|
||||
generate_cargo_keys();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# 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.
|
||||
|
||||
💁 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
|
||||
[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
|
||||
[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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
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"
|
||||
license = "Unlicense"
|
||||
authors.workspace = true
|
||||
@@ -14,24 +14,10 @@ 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 }
|
||||
scale-info = { features = ["derive"], workspace = true }
|
||||
|
||||
|
||||
[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"
|
||||
]
|
||||
std = ["codec/std", "pezkuwi-sdk/std", "scale-info/std"]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
// The preludes must be consistently rebranded as you instructed.
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
use pezkuwi_sdk::pezkuwi_sdk_frame::deps::pezframe_support::pezpallet_prelude::*;
|
||||
|
||||
// We export the inner `pezpallet` module.
|
||||
pub use self::pezpallet::*;
|
||||
// Re-export all pezpallet parts, this is needed to properly import the pezpallet into the runtime.
|
||||
pub use pallet::*;
|
||||
|
||||
// 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 {
|
||||
#[pezkuwi_sdk::pezframe_support::pezpallet]
|
||||
pub mod pallet {
|
||||
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>);
|
||||
pub struct Pezpallet<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(())
|
||||
}
|
||||
}
|
||||
}
|
||||
pub type Value<T> = StorageValue<Value = u32>;
|
||||
}
|
||||
|
||||
+8
-43
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
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"
|
||||
license = "Unlicense"
|
||||
authors.workspace = true
|
||||
@@ -11,55 +11,20 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
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 }
|
||||
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]
|
||||
pezkuwi-sdk = { optional = true, workspace = true, features = ["bizinikiwi-wasm-builder"] }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
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
|
||||
"codec/std",
|
||||
"pezpallet-minimal-template/std",
|
||||
"pezkuwi-sdk/std",
|
||||
"scale-info/std",
|
||||
"serde_json/std",
|
||||
]
|
||||
|
||||
+1
-16
@@ -1,19 +1,4 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// 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.
|
||||
//! Build script for pez-minimal-template-runtime.
|
||||
|
||||
fn main() {
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
+187
-124
@@ -1,7 +1,6 @@
|
||||
//! 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")]
|
||||
@@ -10,49 +9,47 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
|
||||
// Use statements for external crates (from pezkuwi-sdk, patched via Cargo.toml)
|
||||
use pezpallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
|
||||
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.
|
||||
pub mod genesis_config_presets {
|
||||
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 serde_json::Value;
|
||||
|
||||
/// Returns a development genesis config preset.
|
||||
pub fn development_config_genesis() -> Value {
|
||||
let endowment = <interface::MinimumBalance as Get<interface::Balance>>::get().max(1) * 1000;
|
||||
pezframe_support::build_struct_json_patch!(runtime::RuntimeGenesisConfig {
|
||||
balances: runtime::BalancesConfig {
|
||||
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
|
||||
pezframe_support::build_struct_json_patch!(RuntimeGenesisConfig {
|
||||
balances: BalancesConfig {
|
||||
balances: Sr25519Keyring::iter()
|
||||
.map(|a| (a.to_account_id(), endowment))
|
||||
.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.
|
||||
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
|
||||
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,
|
||||
};
|
||||
Some(
|
||||
@@ -64,184 +61,241 @@ pub mod genesis_config_presets {
|
||||
|
||||
/// List of supported presets.
|
||||
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! {
|
||||
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 runtime version.
|
||||
#[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 = (
|
||||
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>,
|
||||
// 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.
|
||||
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! {
|
||||
pub enum Runtime {
|
||||
System: pezframe_system,
|
||||
Timestamp: pezpallet_timestamp,
|
||||
Balances: pezpallet_balances,
|
||||
Sudo: pezpallet_sudo,
|
||||
TransactionPayment: pezpallet_transaction_payment,
|
||||
Template: pezpallet_minimal_template,
|
||||
}
|
||||
// Composes the runtime by adding all the used pezpallets and deriving necessary types.
|
||||
#[frame_construct_runtime]
|
||||
pub mod runtime {
|
||||
use super::*;
|
||||
|
||||
/// The main runtime type.
|
||||
#[runtime::runtime]
|
||||
#[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::{
|
||||
Call as RuntimeCall,
|
||||
Event as RuntimeEvent,
|
||||
Error as RuntimeError,
|
||||
Origin as RuntimeOrigin,
|
||||
Runtime,
|
||||
AllPalletsWithSystem,
|
||||
BalancesConfig,
|
||||
SudoConfig,
|
||||
System,
|
||||
Timestamp,
|
||||
Balances,
|
||||
Sudo,
|
||||
TransactionPayment,
|
||||
Template,
|
||||
RuntimeGenesisConfig,
|
||||
Runtime, System, Timestamp, Balances, Sudo, TransactionPayment, Template,
|
||||
RuntimeCall, RuntimeEvent, RuntimeError, RuntimeOrigin, RuntimeFreezeReason,
|
||||
RuntimeHoldReason, RuntimeSlashReason, RuntimeLockId, RuntimeTask, RuntimeViewFunction,
|
||||
AllPalletsWithSystem, RuntimeGenesisConfig, BalancesConfig, SudoConfig,
|
||||
};
|
||||
|
||||
pezframe_support::parameter_types! {
|
||||
parameter_types! {
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
}
|
||||
|
||||
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 system pezpallet.
|
||||
#[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 pezpallet
|
||||
type AccountData = pezpallet_balances::AccountData<<Runtime as pezpallet_balances::Config>::Balance>;
|
||||
}
|
||||
|
||||
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 balances pezpallet.
|
||||
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_balances::Config for Runtime {
|
||||
type AccountStore = System;
|
||||
}
|
||||
|
||||
mod sudo_config {
|
||||
use super::*;
|
||||
#[pezframe_support::derive_impl(pezpallet_sudo::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_sudo::Config for Runtime {}
|
||||
}
|
||||
|
||||
mod timestamp_config {
|
||||
use super::*;
|
||||
#[pezframe_support::derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_timestamp::Config for 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>;
|
||||
}
|
||||
// Implements the types required for the sudo pezpallet.
|
||||
#[derive_impl(pezpallet_sudo::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_sudo::Config for Runtime {}
|
||||
|
||||
// Implements the types required for the timestamp pezpallet.
|
||||
#[derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_timestamp::Config for Runtime {}
|
||||
|
||||
// Implements the types required for the transaction payment pezpallet.
|
||||
#[derive_impl(pezpallet_transaction_payment::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = pezpallet_transaction_payment::FungibleAdapter<Balances, ()>;
|
||||
// Setting fee as independent of the weight of the extrinsic for demo purposes
|
||||
type WeightToFee = NoFee<<Self as pezpallet_balances::Config>::Balance>;
|
||||
// Setting fee as fixed for any length of the call data for demo purposes
|
||||
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 {}
|
||||
|
||||
type Block = pezframe::runtime::types_common::BlockOf<Runtime, TxExtension>;
|
||||
type Header = pezframe::runtime::prelude::HeaderFor<Runtime>;
|
||||
type Block = frame::runtime::types_common::BlockOf<Runtime, TxExtension>;
|
||||
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 {
|
||||
fn version() -> RuntimeVersion {
|
||||
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 {
|
||||
RuntimeExecutive::initialize_block(header)
|
||||
}
|
||||
}
|
||||
impl apis::Metadata<Block> for Runtime {
|
||||
fn metadata() -> OpaqueMetadata {
|
||||
OpaqueMetadata::new(Runtime::metadata().into())
|
||||
Runtime::metadata()
|
||||
}
|
||||
|
||||
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()
|
||||
// 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 {
|
||||
fn validate_transaction(
|
||||
source: TransactionSource,
|
||||
tx: ExtrinsicFor<Runtime>,
|
||||
block_hash: <Runtime as pezframe_system::Config>::Hash,
|
||||
block_hash: <Runtime as frame_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>, pezframe::runtime::apis::KeyTypeId)>> {
|
||||
|
||||
fn decode_session_keys(
|
||||
_encoded: Vec<u8>,
|
||||
) -> Option<Vec<(Vec<u8>, 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 pezpallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
|
||||
Block,
|
||||
interface::Balance,
|
||||
@@ -259,27 +313,36 @@ pezsp_api::impl_runtime_apis! {
|
||||
TransactionPayment::length_to_fee(length)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
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::Runtime;
|
||||
use pezkuwi_sdk::pezkuwi_sdk_pezframe as pezframe;
|
||||
use super::{Runtime, frame_system};
|
||||
use pezkuwi_sdk::{pezkuwi_sdk_frame as frame, *, pezpallet_balances};
|
||||
|
||||
pub type Block = super::Block;
|
||||
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 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 pezpallet_balances::Config>::Balance;
|
||||
pub type MinimumBalance = <Runtime as pezpallet_balances::Config>::ExistentialDeposit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user