mirror of
https://github.com/pezkuwichain/pez-minimal-template.git
synced 2026-04-22 04:27:57 +00:00
Update the minimal template to stable2412 (#21)
This synchronizes the template to the stable2412 branch. --------- Signed-off-by: Iulian Barbu <iulian.barbu@parity.io> Co-authored-by: iulianbarbu <14218860+iulianbarbu@users.noreply.github.com> Co-authored-by: Iulian Barbu <iulian.barbu@parity.io>
This commit is contained in:
committed by
GitHub
parent
3004222b11
commit
a76e4bf0ed
+3
-1
@@ -12,7 +12,8 @@ publish = false
|
||||
[dependencies]
|
||||
codec = { workspace = true }
|
||||
scale-info = { workspace = true }
|
||||
polkadot-sdk = { workspace = true, features = ["experimental", "pallet-balances", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "runtime"] }
|
||||
polkadot-sdk = { workspace = true, features = ["pallet-balances", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "runtime"] }
|
||||
serde_json = { workspace = true, default-features = false, features = ["alloc"] }
|
||||
pallet-minimal-template.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
@@ -25,4 +26,5 @@ std = [
|
||||
"pallet-minimal-template/std",
|
||||
"polkadot-sdk/std",
|
||||
"scale-info/std",
|
||||
"serde_json/std",
|
||||
]
|
||||
|
||||
+1
-1
@@ -12,4 +12,4 @@ responsible for validating blocks and executing the state changes they define.
|
||||
|
||||
## Release
|
||||
|
||||
Polkadot SDK stable2409
|
||||
Polkadot SDK Stable 2412
|
||||
|
||||
+60
-13
@@ -25,28 +25,75 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::{vec, vec::Vec};
|
||||
use alloc::vec::Vec;
|
||||
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
|
||||
use polkadot_sdk::{
|
||||
polkadot_sdk_frame::{
|
||||
self as frame,
|
||||
prelude::*,
|
||||
deps::sp_genesis_builder,
|
||||
runtime::{apis, prelude::*},
|
||||
},
|
||||
*,
|
||||
};
|
||||
|
||||
/// Provides getters for genesis configuration presets.
|
||||
pub mod genesis_config_presets {
|
||||
use super::*;
|
||||
use crate::{
|
||||
interface::{Balance, MinimumBalance},
|
||||
sp_keyring::AccountKeyring,
|
||||
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;
|
||||
let config = RuntimeGenesisConfig {
|
||||
balances: BalancesConfig {
|
||||
balances: AccountKeyring::iter()
|
||||
.map(|a| (a.to_account_id(), endowment))
|
||||
.collect::<Vec<_>>(),
|
||||
},
|
||||
sudo: SudoConfig { key: Some(AccountKeyring::Alice.to_account_id()) },
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
serde_json::to_value(config).expect("Could not build genesis config.")
|
||||
}
|
||||
|
||||
/// 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(),
|
||||
_ => return None,
|
||||
};
|
||||
Some(
|
||||
serde_json::to_string(&patch)
|
||||
.expect("serialization to json is expected to work. qed.")
|
||||
.into_bytes(),
|
||||
)
|
||||
}
|
||||
|
||||
/// List of supported presets.
|
||||
pub fn preset_names() -> Vec<PresetId> {
|
||||
vec![PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET)]
|
||||
}
|
||||
}
|
||||
|
||||
/// The runtime version.
|
||||
#[runtime_version]
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("minimal-template-runtime"),
|
||||
impl_name: create_runtime_str!("minimal-template-runtime"),
|
||||
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,
|
||||
state_version: 1,
|
||||
system_version: 1,
|
||||
};
|
||||
|
||||
/// The version information used to identify this runtime when compiled natively.
|
||||
@@ -55,8 +102,8 @@ pub fn native_version() -> NativeVersion {
|
||||
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
||||
}
|
||||
|
||||
/// The signed extensions that are added to the runtime.
|
||||
type SignedExtra = (
|
||||
/// 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.
|
||||
@@ -159,7 +206,7 @@ impl pallet_transaction_payment::Config for Runtime {
|
||||
// Implements the types required for the template pallet.
|
||||
impl pallet_minimal_template::Config for Runtime {}
|
||||
|
||||
type Block = frame::runtime::types_common::BlockOf<Runtime, SignedExtra>;
|
||||
type Block = frame::runtime::types_common::BlockOf<Runtime, TxExtension>;
|
||||
type Header = HeaderFor<Runtime>;
|
||||
|
||||
type RuntimeExecutive =
|
||||
@@ -266,17 +313,17 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
|
||||
impl apis::GenesisBuilder<Block> for Runtime {
|
||||
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
|
||||
build_state::<RuntimeGenesisConfig>(config)
|
||||
}
|
||||
|
||||
fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
|
||||
get_preset::<RuntimeGenesisConfig>(id, |_| None)
|
||||
fn get_preset(id: &Option<PresetId>) -> Option<Vec<u8>> {
|
||||
get_preset::<RuntimeGenesisConfig>(id, self::genesis_config_presets::get_preset)
|
||||
}
|
||||
|
||||
fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
|
||||
vec![]
|
||||
fn preset_names() -> Vec<PresetId> {
|
||||
self::genesis_config_presets::preset_names()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user