FAZ 1 Complete: Workspace compile fixes, warning cleanup, version bumps
- Fixed is_using_frame_crate() macro to check for pezframe/pezkuwi_sdk - Removed disable_pezframe_system_supertrait_check temporary bypasses - Feature-gated storage-benchmark and teyrchain-benchmarks code - Fixed dead_code warnings with underscore prefix (_Header) - Removed unused imports and shadowing use statements - Version bumps: procedural-tools 10.0.1, benchmarking-cli 32.0.1, docs 0.0.2, minimal-runtime 0.0.1, yet-another-teyrchain 0.6.1, umbrella 0.1.2 - Updated MAINNET_ROADMAP.md with FAZ 1 completion status
This commit is contained in:
+3
-3
@@ -8,7 +8,7 @@ authors.workspace = true
|
||||
edition.workspace = true
|
||||
# This crate is not publish-able to crates.io for now because of docify.
|
||||
publish = false
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
documentation.workspace = true
|
||||
|
||||
[lints]
|
||||
@@ -17,7 +17,7 @@ workspace = true
|
||||
[dependencies]
|
||||
# Needed for all FRAME-based code
|
||||
codec = { workspace = true }
|
||||
frame = { features = [
|
||||
pezframe = { features = [
|
||||
"experimental",
|
||||
"runtime",
|
||||
], workspace = true, default-features = true }
|
||||
@@ -141,7 +141,7 @@ runtime-benchmarks = [
|
||||
"bizinikiwi-wasm-builder/runtime-benchmarks",
|
||||
"chain-spec-builder/runtime-benchmarks",
|
||||
"first-runtime/runtime-benchmarks",
|
||||
"frame/runtime-benchmarks",
|
||||
"pezframe/runtime-benchmarks",
|
||||
"node-cli/runtime-benchmarks",
|
||||
"pez-chain-spec-guide-runtime/runtime-benchmarks",
|
||||
"pez-kitchensink-runtime/runtime-benchmarks",
|
||||
|
||||
@@ -19,10 +19,12 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
[dependencies]
|
||||
codec = { workspace = true }
|
||||
docify = { workspace = true }
|
||||
frame = { workspace = true, features = ["runtime"] }
|
||||
pezframe = { workspace = true, features = ["runtime"] }
|
||||
pezframe-system = { workspace = true }
|
||||
pezframe-support = { workspace = true }
|
||||
scale-info = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["codec/std", "frame/std", "scale-info/std"]
|
||||
runtime-benchmarks = ["frame/runtime-benchmarks"]
|
||||
std = ["codec/std", "pezframe/std", "pezframe-system/std", "pezframe-support/std", "scale-info/std"]
|
||||
runtime-benchmarks = ["pezframe/runtime-benchmarks"]
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod shell_pallet {
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {}
|
||||
@@ -31,9 +31,9 @@ pub mod shell_pallet {
|
||||
pub struct Pezpallet<T>(_);
|
||||
}
|
||||
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet {
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[docify::export]
|
||||
pub type Balance = u128;
|
||||
@@ -137,7 +137,7 @@ pub mod pezpallet {
|
||||
use crate::pezpallet::*;
|
||||
|
||||
#[docify::export(testing_prelude)]
|
||||
use frame::testing_prelude::*;
|
||||
use pezframe::testing_prelude::*;
|
||||
|
||||
pub(crate) const ALICE: u64 = 1;
|
||||
pub(crate) const BOB: u64 = 2;
|
||||
@@ -360,10 +360,10 @@ pub mod pezpallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_v2 {
|
||||
use super::pezpallet::Balance;
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[docify::export(config_v2)]
|
||||
#[pezpallet::config]
|
||||
@@ -429,7 +429,7 @@ pub mod pezpallet_v2 {
|
||||
#[cfg(any(test, doc))]
|
||||
pub mod tests {
|
||||
use super::{super::pezpallet::tests::StateBuilder, *};
|
||||
use frame::testing_prelude::*;
|
||||
use pezframe::testing_prelude::*;
|
||||
const ALICE: u64 = 1;
|
||||
const BOB: u64 = 2;
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ scale-info = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
# this is a frame-based runtime, thus importing `frame` with runtime feature enabled.
|
||||
frame = { workspace = true, features = ["runtime"] }
|
||||
pezframe = { workspace = true, features = ["runtime"] }
|
||||
pezframe-system = { workspace = true }
|
||||
pezframe-support = { workspace = true }
|
||||
|
||||
# pallets that we want to use
|
||||
pezpallet-balances = { workspace = true }
|
||||
@@ -29,7 +31,16 @@ pezpallet-transaction-payment = { workspace = true }
|
||||
pezpallet-transaction-payment-rpc-runtime-api = { workspace = true }
|
||||
|
||||
# other pezkuwi-sdk-deps
|
||||
pezsp-api = { workspace = true }
|
||||
pezsp-block-builder = { workspace = true }
|
||||
pezsp-core = { workspace = true }
|
||||
pezsp-genesis-builder = { workspace = true }
|
||||
pezsp-keyring = { workspace = true }
|
||||
pezsp-offchain = { workspace = true }
|
||||
pezsp-runtime = { workspace = true }
|
||||
pezsp-session = { workspace = true }
|
||||
pezsp-transaction-pool = { workspace = true }
|
||||
pezframe-system-rpc-runtime-api = { workspace = true }
|
||||
|
||||
# local pezpallet templates
|
||||
first-pezpallet = { workspace = true }
|
||||
@@ -46,7 +57,9 @@ std = [
|
||||
"scale-info/std",
|
||||
"serde_json/std",
|
||||
|
||||
"frame/std",
|
||||
"pezframe/std",
|
||||
"pezframe-system/std",
|
||||
"pezframe-support/std",
|
||||
|
||||
"pezpallet-balances/std",
|
||||
"pezpallet-sudo/std",
|
||||
@@ -55,14 +68,23 @@ std = [
|
||||
"pezpallet-transaction-payment/std",
|
||||
|
||||
"first-pezpallet/std",
|
||||
"pezsp-api/std",
|
||||
"pezsp-block-builder/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-genesis-builder/std",
|
||||
"pezsp-keyring/std",
|
||||
"pezsp-offchain/std",
|
||||
"pezsp-runtime/std",
|
||||
"pezsp-session/std",
|
||||
"pezsp-transaction-pool/std",
|
||||
"pezframe-system-rpc-runtime-api/std",
|
||||
|
||||
"bizinikiwi-wasm-builder",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"bizinikiwi-wasm-builder?/runtime-benchmarks",
|
||||
"first-pezpallet/runtime-benchmarks",
|
||||
"frame/runtime-benchmarks",
|
||||
"pezframe/runtime-benchmarks",
|
||||
"pezpallet-balances/runtime-benchmarks",
|
||||
"pezpallet-sudo/runtime-benchmarks",
|
||||
"pezpallet-timestamp/runtime-benchmarks",
|
||||
|
||||
@@ -22,13 +22,18 @@
|
||||
extern crate alloc;
|
||||
use alloc::{vec, vec::Vec};
|
||||
use first_pezpallet::pezpallet_v2 as our_first_pallet;
|
||||
use frame::{
|
||||
use pezframe::{
|
||||
deps::pezsp_genesis_builder::DEV_RUNTIME_PRESET,
|
||||
prelude::*,
|
||||
runtime::{apis, prelude::*},
|
||||
runtime::prelude::*,
|
||||
};
|
||||
use pezpallet_transaction_payment_rpc_runtime_api::{FeeDetails, RuntimeDispatchInfo};
|
||||
use pezsp_keyring::Sr25519Keyring;
|
||||
use pezsp_runtime::{
|
||||
traits::Block as BlockT,
|
||||
transaction_validity::{TransactionSource, TransactionValidity},
|
||||
ApplyExtrinsicResult,
|
||||
};
|
||||
|
||||
#[docify::export]
|
||||
#[runtime_version]
|
||||
@@ -66,12 +71,12 @@ mod runtime_types {
|
||||
pub(super) type SignedExtra = (
|
||||
// `frame` already provides all the signed extensions from `pezframe-system`. We just add
|
||||
// the one related to tx-payment here.
|
||||
frame::runtime::types_common::SystemTransactionExtensionsOf<Runtime>,
|
||||
pezframe::runtime::types_common::SystemTransactionExtensionsOf<Runtime>,
|
||||
pezpallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
);
|
||||
|
||||
pub(super) type Block = frame::runtime::types_common::BlockOf<Runtime, SignedExtra>;
|
||||
pub(super) type Header = HeaderFor<Runtime>;
|
||||
pub(super) type Block = pezframe::runtime::types_common::BlockOf<Runtime, SignedExtra>;
|
||||
pub(super) type _Header = HeaderFor<Runtime>;
|
||||
|
||||
pub(super) type RuntimeExecutive = Executive<
|
||||
Runtime,
|
||||
@@ -132,7 +137,7 @@ pub mod genesis_config_presets {
|
||||
interface::{Balance, MinimumBalance},
|
||||
BalancesConfig, RuntimeGenesisConfig, SudoConfig,
|
||||
};
|
||||
use frame::deps::pezframe_support::build_struct_json_patch;
|
||||
use pezframe::deps::pezframe_support::build_struct_json_patch;
|
||||
use serde_json::Value;
|
||||
|
||||
/// Returns a development genesis config preset.
|
||||
@@ -171,21 +176,21 @@ pub mod genesis_config_presets {
|
||||
}
|
||||
|
||||
impl_runtime_apis! {
|
||||
impl apis::Core<Block> for Runtime {
|
||||
impl pezsp_api::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion {
|
||||
VERSION
|
||||
}
|
||||
|
||||
fn execute_block(block: <Block as frame::traits::Block>::LazyBlock) {
|
||||
fn execute_block(block: <Block as BlockT>::LazyBlock) {
|
||||
RuntimeExecutive::execute_block(block)
|
||||
}
|
||||
|
||||
fn initialize_block(header: &Header) -> ExtrinsicInclusionMode {
|
||||
fn initialize_block(header: &<Block as BlockT>::Header) -> ExtrinsicInclusionMode {
|
||||
RuntimeExecutive::initialize_block(header)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::Metadata<Block> for Runtime {
|
||||
impl pezsp_api::Metadata<Block> for Runtime {
|
||||
fn metadata() -> OpaqueMetadata {
|
||||
OpaqueMetadata::new(Runtime::metadata().into())
|
||||
}
|
||||
@@ -199,62 +204,62 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(extrinsic: ExtrinsicFor<Runtime>) -> ApplyExtrinsicResult {
|
||||
impl pezsp_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
|
||||
RuntimeExecutive::apply_extrinsic(extrinsic)
|
||||
}
|
||||
|
||||
fn finalize_block() -> HeaderFor<Runtime> {
|
||||
fn finalize_block() -> <Block as BlockT>::Header {
|
||||
RuntimeExecutive::finalize_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(data: InherentData) -> Vec<ExtrinsicFor<Runtime>> {
|
||||
fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
data.create_extrinsics()
|
||||
}
|
||||
|
||||
fn check_inherents(
|
||||
block: <Block as frame::traits::Block>::LazyBlock,
|
||||
block: <Block as BlockT>::LazyBlock,
|
||||
data: InherentData,
|
||||
) -> CheckInherentsResult {
|
||||
data.check_extrinsics(&block)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::TaggedTransactionQueue<Block> for Runtime {
|
||||
impl pezsp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||
fn validate_transaction(
|
||||
source: TransactionSource,
|
||||
tx: ExtrinsicFor<Runtime>,
|
||||
block_hash: <Runtime as pezframe_system::Config>::Hash,
|
||||
tx: <Block as BlockT>::Extrinsic,
|
||||
block_hash: <Block as BlockT>::Hash,
|
||||
) -> TransactionValidity {
|
||||
RuntimeExecutive::validate_transaction(source, tx, block_hash)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(header: &HeaderFor<Runtime>) {
|
||||
impl pezsp_offchain::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(header: &<Block as BlockT>::Header) {
|
||||
RuntimeExecutive::offchain_worker(header)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::SessionKeys<Block> for Runtime {
|
||||
impl pezsp_session::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)>> {
|
||||
) -> Option<Vec<(Vec<u8>, pezsp_core::crypto::KeyTypeId)>> {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::AccountNonceApi<Block, interface::AccountId, interface::Nonce> for Runtime {
|
||||
impl pezframe_system_rpc_runtime_api::AccountNonceApi<Block, interface::AccountId, interface::Nonce> for Runtime {
|
||||
fn account_nonce(account: interface::AccountId) -> interface::Nonce {
|
||||
System::account_nonce(account)
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::GenesisBuilder<Block> for Runtime {
|
||||
impl pezsp_genesis_builder::GenesisBuilder<Block> for Runtime {
|
||||
fn build_state(config: Vec<u8>) -> GenesisBuilderResult {
|
||||
build_state::<RuntimeGenesisConfig>(config)
|
||||
}
|
||||
@@ -272,10 +277,10 @@ impl_runtime_apis! {
|
||||
Block,
|
||||
interface::Balance,
|
||||
> for Runtime {
|
||||
fn query_info(uxt: ExtrinsicFor<Runtime>, len: u32) -> RuntimeDispatchInfo<interface::Balance> {
|
||||
fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<interface::Balance> {
|
||||
TransactionPayment::query_info(uxt, len)
|
||||
}
|
||||
fn query_fee_details(uxt: ExtrinsicFor<Runtime>, len: u32) -> FeeDetails<interface::Balance> {
|
||||
fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<interface::Balance> {
|
||||
TransactionPayment::query_fee_details(uxt, len)
|
||||
}
|
||||
fn query_weight_to_fee(weight: Weight) -> interface::Balance {
|
||||
@@ -291,7 +296,7 @@ impl_runtime_apis! {
|
||||
/// configs.
|
||||
pub mod interface {
|
||||
use super::Runtime;
|
||||
use frame::prelude::pezframe_system;
|
||||
use pezframe::prelude::pezframe_system;
|
||||
|
||||
pub type AccountId = <Runtime as pezframe_system::Config>::AccountId;
|
||||
pub type Nonce = <Runtime as pezframe_system::Config>::Nonce;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
//! - [`pezpallet::event`]
|
||||
//! - [`pezpallet::error`]
|
||||
//! - Basics of testing a pezpallet
|
||||
//! - [Constructing a runtime](frame::runtime::prelude::construct_runtime)
|
||||
//! - [Constructing a runtime](pezframe::runtime::prelude::construct_runtime)
|
||||
//!
|
||||
//! ### Shell Pezpallet
|
||||
//!
|
||||
@@ -79,7 +79,7 @@
|
||||
//! details:
|
||||
//!
|
||||
//! - Where do `T::AccountId` and `T::RuntimeOrigin` come from? These are both defined in
|
||||
//! [`frame::prelude::pezframe_system::Config`], therefore we can access them in `T`.
|
||||
//! [`pezframe::prelude::pezframe_system::Config`], therefore we can access them in `T`.
|
||||
//! - What is `ensure_signed`, and what does it do with the aforementioned `T::RuntimeOrigin`? This
|
||||
//! is outside the scope of this guide, and you can learn more about it in the origin reference
|
||||
//! document ([`crate::reference_docs::frame_origin`]). For now, you should only know the
|
||||
@@ -90,31 +90,31 @@
|
||||
//!
|
||||
//! - Where does `mutate`, `get` and `insert` and other storage APIs come from? All of them are
|
||||
//! explained in the corresponding `type`, for example, for `Balances::<T>::insert`, you can look
|
||||
//! into [`frame::prelude::StorageMap::insert`].
|
||||
//! into [`pezframe::prelude::StorageMap::insert`].
|
||||
//!
|
||||
//! - The return type of all dispatchable functions is [`frame::prelude::DispatchResult`]:
|
||||
//! - The return type of all dispatchable functions is [`pezframe::prelude::DispatchResult`]:
|
||||
#![doc = docify::embed!("../../bizinikiwi/pezframe/support/src/dispatch.rs", DispatchResult)]
|
||||
//!
|
||||
//! Which is more or less a normal Rust `Result`, with a custom [`frame::prelude::DispatchError`] as
|
||||
//! Which is more or less a normal Rust `Result`, with a custom [`pezframe::prelude::DispatchError`] as
|
||||
//! the `Err` variant. We won't cover this error in detail here, but importantly you should know
|
||||
//! that there is an `impl From<&'static string> for DispatchError` provided (see
|
||||
//! [here](`frame::prelude::DispatchError#impl-From<%26str>-for-DispatchError`)). Therefore,
|
||||
//! [here](`pezframe::prelude::DispatchError#impl-From<%26str>-for-DispatchError`)). Therefore,
|
||||
//! we can use basic string literals as our error type and `.into()` them into `DispatchError`.
|
||||
//!
|
||||
//! - Why are all `get` and `mutate` functions returning an `Option`? This is the default behavior
|
||||
//! of FRAME storage APIs. You can learn more about how to override this by looking into
|
||||
//! [`pezpallet::storage`], and [`frame::prelude::ValueQuery`]/[`frame::prelude::OptionQuery`]
|
||||
//! [`pezpallet::storage`], and [`pezframe::prelude::ValueQuery`]/[`pezframe::prelude::OptionQuery`]
|
||||
//!
|
||||
//! ### Improving Errors
|
||||
//!
|
||||
//! How we handle error in the above snippets is fairly rudimentary. Let's look at how this can be
|
||||
//! improved. First, we can use [`frame::prelude::ensure`] to express the error slightly better.
|
||||
//! improved. First, we can use [`pezframe::prelude::ensure`] to express the error slightly better.
|
||||
//! This macro will call `.into()` under the hood.
|
||||
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", transfer_better)]
|
||||
//!
|
||||
//! Moreover, you will learn in the [Defensive Programming
|
||||
//! section](crate::reference_docs::defensive_programming) that it is always recommended to use
|
||||
//! safe arithmetic operations in your runtime. By using [`frame::traits::CheckedSub`], we can not
|
||||
//! safe arithmetic operations in your runtime. By using [`pezframe::traits::CheckedSub`], we can not
|
||||
//! only take a step in that direction, but also improve the error handing and make it slightly more
|
||||
//! ergonomic.
|
||||
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", transfer_better_checked)]
|
||||
@@ -134,7 +134,7 @@
|
||||
//! #[cfg(test)]
|
||||
//! mod tests {
|
||||
//! // bring in the testing prelude of frame
|
||||
//! use frame::testing_prelude::*;
|
||||
//! use pezframe::testing_prelude::*;
|
||||
//! // bring in all pezpallet items
|
||||
//! use super::pezpallet::*;
|
||||
//!
|
||||
@@ -144,12 +144,12 @@
|
||||
//!
|
||||
//! Next, we create a "test runtime" in order to test our pezpallet. Recall from
|
||||
//! [`crate::pezkuwi_sdk::frame_runtime`] that a runtime is a collection of pallets, expressed
|
||||
//! through [`frame::runtime::prelude::construct_runtime`]. All runtimes also have to include
|
||||
//! [`frame::prelude::pezframe_system`]. So we expect to see a runtime with two pezpallet,
|
||||
//! through [`pezframe::runtime::prelude::construct_runtime`]. All runtimes also have to include
|
||||
//! [`pezframe::prelude::pezframe_system`]. So we expect to see a runtime with two pezpallet,
|
||||
//! `pezframe_system` and the one we just wrote.
|
||||
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", runtime)]
|
||||
//!
|
||||
//! > [`frame::pezpallet_macros::derive_impl`] is a FRAME feature that enables developers to have
|
||||
//! > [`pezframe::pezpallet_macros::derive_impl`] is a FRAME feature that enables developers to have
|
||||
//! > defaults for associated types.
|
||||
//!
|
||||
//! Recall that within our pezpallet, (almost) all blocks of code are generic over `<T: Config>`.
|
||||
@@ -183,7 +183,7 @@
|
||||
//!
|
||||
//! The above is all you need to execute the dispatchables of your pezpallet. The last thing you
|
||||
//! need to learn is that all of your pezpallet testing code should be wrapped in
|
||||
//! [`frame::testing_prelude::TestState`]. This is a type that provides access to an in-memory state
|
||||
//! [`pezframe::testing_prelude::TestState`]. This is a type that provides access to an in-memory state
|
||||
//! to be used in our tests.
|
||||
#![doc = docify::embed!("./packages/guides/first-pezpallet/src/lib.rs", first_test)]
|
||||
//!
|
||||
@@ -305,7 +305,7 @@
|
||||
//!
|
||||
//! In this snippet, the actual `RuntimeEvent` type (right hand side of `type RuntimeEvent =
|
||||
//! RuntimeEvent`) is generated by
|
||||
//! [`construct_runtime`](frame::runtime::prelude::construct_runtime). An interesting way to inspect
|
||||
//! [`construct_runtime`](pezframe::runtime::prelude::construct_runtime). An interesting way to inspect
|
||||
//! this type is to see its definition in rust-docs:
|
||||
//! [`crate::guides::your_first_pallet::pezpallet_v2::tests::runtime_v2::RuntimeEvent`].
|
||||
//!
|
||||
@@ -321,7 +321,7 @@
|
||||
//! - The pezpallet we wrote in this guide was using `dev_mode`, learn more in
|
||||
//! [`pezpallet::config`].
|
||||
//! - Learn more about the individual pezpallet items/macros, such as event and errors and call, in
|
||||
//! [`frame::pezpallet_macros`].
|
||||
//! [`pezframe::pezpallet_macros`].
|
||||
//!
|
||||
//! [`pezpallet::storage`]: pezframe_support::pezpallet_macros::storage
|
||||
//! [`pezpallet::call`]: pezframe_support::pezpallet_macros::call
|
||||
@@ -332,9 +332,9 @@
|
||||
//! [`pezpallet::generate_deposit`]: pezframe_support::pezpallet_macros::generate_deposit
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod shell_pallet {
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {}
|
||||
@@ -343,9 +343,9 @@ pub mod shell_pallet {
|
||||
pub struct Pezpallet<T>(_);
|
||||
}
|
||||
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet {
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[docify::export]
|
||||
pub type Balance = u128;
|
||||
@@ -449,7 +449,7 @@ pub mod pezpallet {
|
||||
use crate::guides::your_first_pallet::pezpallet::*;
|
||||
|
||||
#[docify::export(testing_prelude)]
|
||||
use frame::testing_prelude::*;
|
||||
use pezframe::testing_prelude::*;
|
||||
|
||||
pub(crate) const ALICE: u64 = 1;
|
||||
pub(crate) const BOB: u64 = 2;
|
||||
@@ -672,10 +672,10 @@ pub mod pezpallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_v2 {
|
||||
use super::pezpallet::Balance;
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[docify::export(config_v2)]
|
||||
#[pezpallet::config]
|
||||
@@ -741,7 +741,7 @@ pub mod pezpallet_v2 {
|
||||
#[cfg(any(test, doc))]
|
||||
pub mod tests {
|
||||
use super::{super::pezpallet::tests::StateBuilder, *};
|
||||
use frame::testing_prelude::*;
|
||||
use pezframe::testing_prelude::*;
|
||||
const ALICE: u64 = 1;
|
||||
const BOB: u64 = 2;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
//! ## Your First Runtime
|
||||
//!
|
||||
//! The first new property of a real runtime that it must define its
|
||||
//! [`frame::runtime::prelude::RuntimeVersion`]:
|
||||
//! [`pezframe::runtime::prelude::RuntimeVersion`]:
|
||||
#![doc = docify::embed!("./packages/guides/first-runtime/src/lib.rs", VERSION)]
|
||||
//!
|
||||
//! The version contains a number of very important fields, such as `spec_version` and `spec_name`
|
||||
@@ -39,7 +39,7 @@
|
||||
//! [`crate::reference_docs::frame_runtime_upgrades_and_migrations`].
|
||||
//!
|
||||
//! Then, a real runtime also contains the `impl` of all individual pallets' `trait Config` for
|
||||
//! `struct Runtime`, and a [`frame::runtime::prelude::construct_runtime`] macro that amalgamates
|
||||
//! `struct Runtime`, and a [`pezframe::runtime::prelude::construct_runtime`] macro that amalgamates
|
||||
//! them all.
|
||||
//!
|
||||
//! In the case of our example:
|
||||
@@ -49,9 +49,9 @@
|
||||
//! their `Config` need to be implemented for `struct Runtime`:
|
||||
#![doc = docify::embed!("./packages/guides/first-runtime/src/lib.rs", config_impls)]
|
||||
//!
|
||||
//! Notice how we use [`frame::pezpallet_macros::derive_impl`] to provide "default" configuration
|
||||
//! Notice how we use [`pezframe::pezpallet_macros::derive_impl`] to provide "default" configuration
|
||||
//! items for each pezpallet. Feel free to dive into the definition of each default prelude (eg.
|
||||
//! [`frame::prelude::pezframe_system::pezpallet::config_preludes`]) to learn more which types are
|
||||
//! [`pezframe::prelude::pezframe_system::pezpallet::config_preludes`]) to learn more which types are
|
||||
//! exactly used.
|
||||
//!
|
||||
//! Recall that in test runtime in [`crate::guides::your_first_pallet`], we provided `type AccountId
|
||||
@@ -66,12 +66,12 @@
|
||||
//! steps of crafting a runtime are related to achieving exactly this.
|
||||
//!
|
||||
//! First, we define a number of types that eventually lead to the creation of an instance of
|
||||
//! [`frame::runtime::prelude::Executive`]. The executive is a handy FRAME utility that, through
|
||||
//! [`pezframe::runtime::prelude::Executive`]. The executive is a handy FRAME utility that, through
|
||||
//! amalgamating all pallets and further types, implements some of the very very core pieces of the
|
||||
//! runtime logic, such as how blocks are executed and other runtime-api implementations.
|
||||
#![doc = docify::embed!("./packages/guides/first-runtime/src/lib.rs", runtime_types)]
|
||||
//!
|
||||
//! Finally, we use [`frame::runtime::prelude::impl_runtime_apis`] to implement all of the runtime
|
||||
//! Finally, we use [`pezframe::runtime::prelude::impl_runtime_apis`] to implement all of the runtime
|
||||
//! APIs that the runtime wishes to expose. As you will see in the code, most of these runtime API
|
||||
//! implementations are merely forwarding calls to `RuntimeExecutive` which handles the actual
|
||||
//! logic. Given that the implementation block is somewhat large, we won't repeat it here. You can
|
||||
@@ -111,7 +111,7 @@
|
||||
//! primary way to run a new chain.
|
||||
//!
|
||||
//! These APIs are defined in [`pezsp_genesis_builder`], and are re-exposed as a part of
|
||||
//! [`frame::runtime::apis`]. Therefore, the implementation blocks can be found inside of
|
||||
//! [`pezframe::runtime::apis`]. Therefore, the implementation blocks can be found inside of
|
||||
//! `impl_runtime_apis!` similar to:
|
||||
//!
|
||||
//! ```ignore
|
||||
@@ -143,7 +143,7 @@
|
||||
//!
|
||||
//! For `build_state` and `get_preset`, we use the helper functions provide by frame:
|
||||
//!
|
||||
//! * [`frame::runtime::prelude::build_state`] and [`frame::runtime::prelude::get_preset`].
|
||||
//! * [`pezframe::runtime::prelude::build_state`] and [`pezframe::runtime::prelude::get_preset`].
|
||||
//!
|
||||
//! Indeed, our runtime needs to specify what its `DEV_RUNTIME_PRESET` genesis state should be like:
|
||||
#![doc = docify::embed!("./packages/guides/first-runtime/src/lib.rs", development_config_genesis)]
|
||||
|
||||
@@ -82,9 +82,9 @@
|
||||
//!
|
||||
//!
|
||||
//! ```
|
||||
//! #[frame::pezpallet(dev_mode)]
|
||||
//! #[pezframe::pezpallet(dev_mode)]
|
||||
//! pub mod pezpallet {
|
||||
//! # use frame::prelude::*;
|
||||
//! # use pezframe::prelude::*;
|
||||
//! # #[pezpallet::config]
|
||||
//! # pub trait Config: pezframe_system::Config {}
|
||||
//! # #[pezpallet::pezpallet]
|
||||
@@ -105,9 +105,9 @@
|
||||
//! explained in [`crate::reference_docs::frame_runtime_types`]. Build on top of this!
|
||||
//! * Then, what is `origin`? Just an account id? [`crate::reference_docs::frame_origin`].
|
||||
//! * Then, what is `DispatchResult`? Why is this called *dispatch*? Probably something that can be
|
||||
//! explained in the documentation of [`frame::prelude::DispatchResult`].
|
||||
//! explained in the documentation of [`pezframe::prelude::DispatchResult`].
|
||||
//! * Why is `"SomeStaticString"` a valid error? Because there is implementation for it that you can
|
||||
//! see [here](frame::prelude::DispatchError#impl-From<%26'static+str>-for-DispatchError).
|
||||
//! see [here](pezframe::prelude::DispatchError#impl-From<%26'static+str>-for-DispatchError).
|
||||
//!
|
||||
//!
|
||||
//! All of these are examples of underlying information that a contributor should:
|
||||
|
||||
@@ -98,8 +98,8 @@
|
||||
//! Bizinikiwi-based project typically contains the following:
|
||||
//!
|
||||
//! * Under `./runtime`, a `./runtime/src/lib.rs` which is the top level runtime amalgamator file.
|
||||
//! This file typically contains the [`frame::runtime::prelude::construct_runtime`] and
|
||||
//! [`frame::runtime::prelude::impl_runtime_apis`] macro calls, which is the final definition of a
|
||||
//! This file typically contains the [`pezframe::runtime::prelude::construct_runtime`] and
|
||||
//! [`pezframe::runtime::prelude::impl_runtime_apis`] macro calls, which is the final definition of a
|
||||
//! runtime.
|
||||
//!
|
||||
//! * Under `./node`, a `main.rs`, which is the starting point, and a `./service.rs`, which contains
|
||||
|
||||
@@ -34,23 +34,23 @@
|
||||
//! about its own responsibilities and make as few assumptions about the general runtime as
|
||||
//! possible. A pezpallet is analogous to a _module_ in the runtime.
|
||||
//!
|
||||
//! A pezpallet is defined as a `mod pezpallet` wrapped by the [`frame::pezpallet`] macro. Within
|
||||
//! A pezpallet is defined as a `mod pezpallet` wrapped by the [`pezframe::pezpallet`] macro. Within
|
||||
//! this macro, pezpallet components/parts can be defined. Most notable of these parts are:
|
||||
//!
|
||||
//! - [Config](frame::pezpallet_macros::config), allowing a pezpallet to make itself configurable
|
||||
//! - [Config](pezframe::pezpallet_macros::config), allowing a pezpallet to make itself configurable
|
||||
//! and generic over types, values and such.
|
||||
//! - [Storage](frame::pezpallet_macros::storage), allowing a pezpallet to define onchain storage.
|
||||
//! - [Dispatchable function](frame::pezpallet_macros::call), allowing a pezpallet to define
|
||||
//! - [Storage](pezframe::pezpallet_macros::storage), allowing a pezpallet to define onchain storage.
|
||||
//! - [Dispatchable function](pezframe::pezpallet_macros::call), allowing a pezpallet to define
|
||||
//! extrinsics that are callable by end users, from the outer world.
|
||||
//! - [Events](frame::pezpallet_macros::event), allowing a pezpallet to emit events.
|
||||
//! - [Errors](frame::pezpallet_macros::error), allowing a pezpallet to emit well-formed errors.
|
||||
//! - [Events](pezframe::pezpallet_macros::event), allowing a pezpallet to emit events.
|
||||
//! - [Errors](pezframe::pezpallet_macros::error), allowing a pezpallet to emit well-formed errors.
|
||||
//!
|
||||
//! Some of these pezpallet components resemble the building blocks of a smart contract. While both
|
||||
//! models are programming state transition functions of blockchains, there are crucial differences
|
||||
//! between the two. See [`crate::reference_docs::runtime_vs_smart_contract`] for more.
|
||||
//!
|
||||
//! Most of these components are defined using macros, the full list of which can be found in
|
||||
//! [`frame::pezpallet_macros`].
|
||||
//! [`pezframe::pezpallet_macros`].
|
||||
//!
|
||||
//! ### Example
|
||||
//!
|
||||
@@ -61,16 +61,16 @@
|
||||
//!
|
||||
//! A runtime is a collection of pallets that are amalgamated together. Each pezpallet typically has
|
||||
//! some configurations (exposed as a `trait Config`) that needs to be *specified* in the runtime.
|
||||
//! This is done with [`frame::runtime::prelude::construct_runtime`].
|
||||
//! This is done with [`pezframe::runtime::prelude::construct_runtime`].
|
||||
//!
|
||||
//! A (real) runtime that actually wishes to compile to WASM needs to also implement a set of
|
||||
//! runtime-apis. These implementation can be specified using the
|
||||
//! [`frame::runtime::prelude::impl_runtime_apis`] macro.
|
||||
//! [`pezframe::runtime::prelude::impl_runtime_apis`] macro.
|
||||
//!
|
||||
//! ### Example
|
||||
//!
|
||||
//! The following example shows a (test) runtime that is composing the pezpallet demonstrated above,
|
||||
//! next to the [`frame::prelude::pezframe_system`] pezpallet, into a runtime.
|
||||
//! next to the [`pezframe::prelude::pezframe_system`] pezpallet, into a runtime.
|
||||
#![doc = docify::embed!("src/pezkuwi_sdk/frame_runtime.rs", runtime)]
|
||||
//!
|
||||
//! ## More Examples
|
||||
@@ -94,9 +94,9 @@
|
||||
/// experimental feature to break these parts into different `mod`s. See [`pezpallet_examples`] for
|
||||
/// more.
|
||||
#[docify::export]
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet {
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
/// The configuration trait of a pezpallet. Mandatory. Allows a pezpallet to receive types at a
|
||||
/// later point from the runtime that wishes to contain it. It allows the pezpallet to be
|
||||
@@ -118,7 +118,7 @@ pub mod pezpallet {
|
||||
}
|
||||
|
||||
/// A mandatory struct in each pezpallet. All functions callable by external users (aka.
|
||||
/// transactions) must be attached to this type (see [`frame::pezpallet_macros::call`]). For
|
||||
/// transactions) must be attached to this type (see [`pezframe::pezpallet_macros::call`]). For
|
||||
/// convenience, internal (private) functions can also be attached to this type.
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(PhantomData<T>);
|
||||
@@ -153,7 +153,7 @@ pub mod pezpallet {
|
||||
#[docify::export]
|
||||
pub mod runtime {
|
||||
use super::pezpallet as pezpallet_example;
|
||||
use frame::{prelude::*, testing_prelude::*};
|
||||
use pezframe::{prelude::*, testing_prelude::*};
|
||||
|
||||
// The major macro that amalgamates pallets into `enum Runtime`
|
||||
construct_runtime!(
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! A teyrchain runtime should use a number of pallets that are provided by Pezcumulus and
|
||||
//! Bizinikiwi. Notably:
|
||||
//!
|
||||
//! - [`pezframe-system`](frame::prelude::pezframe_system), like all FRAME-based runtimes.
|
||||
//! - [`pezframe-system`](pezframe::prelude::pezframe_system), like all FRAME-based runtimes.
|
||||
//! - [`pezcumulus_pezpallet_teyrchain_system`]
|
||||
//! - [`teyrchain_info`]
|
||||
#![doc = docify::embed!("./src/pezkuwi_sdk/pezcumulus.rs", system_pallets)]
|
||||
@@ -32,7 +32,7 @@
|
||||
//!
|
||||
//!
|
||||
//! Finally, a separate macro, similar to
|
||||
//! [`impl_runtime_api`](frame::runtime::prelude::impl_runtime_apis), which creates the default set
|
||||
//! [`impl_runtime_api`](pezframe::runtime::prelude::impl_runtime_apis), which creates the default set
|
||||
//! of runtime APIs, will generate the teyrchain runtime's validation runtime API, also known as
|
||||
//! teyrchain validation function (PVF). Without this API, the relay chain is unable to validate
|
||||
//! blocks produced by our teyrchain.
|
||||
@@ -48,7 +48,7 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
mod runtime {
|
||||
pub use frame::{
|
||||
pub use pezframe::{
|
||||
deps::pezsp_consensus_aura::sr25519::AuthorityId as AuraId, prelude::*,
|
||||
runtime::prelude::*, testing_prelude::*,
|
||||
};
|
||||
@@ -95,7 +95,7 @@ mod tests {
|
||||
1,
|
||||
>;
|
||||
type WeightInfo = ();
|
||||
type DmpQueue = frame::traits::EnqueueWithOrigin<(), pezsp_core::ConstU8<0>>;
|
||||
type DmpQueue = pezframe::traits::EnqueueWithOrigin<(), pezsp_core::ConstU8<0>>;
|
||||
type RelayParentOffset = ConstU32<0>;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
//! pez_chain_spec_guide_runtime::runtime::RuntimeGenesisConfig
|
||||
//! [`FooStruct`]:
|
||||
//! pez_chain_spec_guide_runtime::pallets::FooStruct
|
||||
//! [`impl_runtime_apis`]: frame::runtime::prelude::impl_runtime_apis
|
||||
//! [`impl_runtime_apis`]: pezframe::runtime::prelude::impl_runtime_apis
|
||||
//! [`build_state`]: pezframe_support::genesis_builder_helper::build_state
|
||||
//! [`get_preset`]: pezframe_support::genesis_builder_helper::get_preset
|
||||
//! [`pezpallet::genesis_build`]: pezframe_support::pezpallet_macros::genesis_build
|
||||
|
||||
@@ -14,14 +14,16 @@ documentation.workspace = true
|
||||
codec = { workspace = true }
|
||||
docify = { workspace = true }
|
||||
pezframe-support = { workspace = true }
|
||||
pezframe-system = { workspace = true }
|
||||
scale-info = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
# this is a frame-based runtime, thus importing `frame` with runtime feature enabled.
|
||||
frame = { features = ["experimental", "runtime"], workspace = true }
|
||||
pezframe = { features = ["experimental", "runtime"], workspace = true }
|
||||
|
||||
# genesis builder that allows us to interact with runtime genesis config
|
||||
pezsp-api = { workspace = true }
|
||||
pezsp-application-crypto = { features = ["serde"], workspace = true }
|
||||
pezsp-core = { workspace = true }
|
||||
pezsp-genesis-builder = { workspace = true }
|
||||
@@ -41,9 +43,11 @@ std = [
|
||||
"codec/std",
|
||||
"scale-info/std",
|
||||
|
||||
"frame/std",
|
||||
"pezframe/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
|
||||
"pezsp-api/std",
|
||||
"pezsp-application-crypto/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-genesis-builder/std",
|
||||
@@ -56,7 +60,7 @@ std = [
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"bizinikiwi-wasm-builder?/runtime-benchmarks",
|
||||
"frame/runtime-benchmarks",
|
||||
"pezframe/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezsc-chain-spec/runtime-benchmarks",
|
||||
"pezsp-genesis-builder/runtime-benchmarks",
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
//! Pallets for the chain-spec demo runtime.
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_bar {
|
||||
use super::*;
|
||||
|
||||
@@ -94,7 +94,7 @@ pub enum FooEnum {
|
||||
}
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_foo {
|
||||
use super::*;
|
||||
|
||||
|
||||
@@ -26,15 +26,14 @@ use crate::{
|
||||
presets::*,
|
||||
};
|
||||
use alloc::{vec, vec::Vec};
|
||||
use frame::{
|
||||
deps::pezframe_support::{
|
||||
genesis_builder_helper::{build_state, get_preset},
|
||||
runtime,
|
||||
},
|
||||
use pezframe::{
|
||||
deps::pezframe_support::genesis_builder_helper::{build_state, get_preset},
|
||||
prelude::*,
|
||||
runtime::{apis, prelude::*},
|
||||
runtime::prelude::*,
|
||||
};
|
||||
use pezsp_api::impl_runtime_apis;
|
||||
use pezsp_genesis_builder::PresetId;
|
||||
use pezsp_runtime::traits::Block as BlockT;
|
||||
|
||||
/// The runtime version.
|
||||
#[runtime_version]
|
||||
@@ -53,7 +52,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
type SignedExtra = ();
|
||||
|
||||
// Composes the runtime by adding all the used pallets and deriving necessary types.
|
||||
#[runtime]
|
||||
#[frame_construct_runtime]
|
||||
mod runtime {
|
||||
/// The main runtime type.
|
||||
#[runtime::runtime]
|
||||
@@ -69,15 +68,15 @@ mod runtime {
|
||||
|
||||
/// Mandatory system pezpallet that should always be included in a FRAME runtime.
|
||||
#[runtime::pezpallet_index(0)]
|
||||
pub type System = pezframe_system;
|
||||
pub type System = pezframe_system::Pezpallet<Runtime>;
|
||||
|
||||
/// Sample pezpallet 1
|
||||
#[runtime::pezpallet_index(1)]
|
||||
pub type Bar = pezpallet_bar;
|
||||
pub type Bar = pezpallet_bar::Pezpallet<Runtime>;
|
||||
|
||||
/// Sample pezpallet 2
|
||||
#[runtime::pezpallet_index(2)]
|
||||
pub type Foo = pezpallet_foo;
|
||||
pub type Foo = pezpallet_foo::Pezpallet<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -94,8 +93,8 @@ impl pezframe_system::Config for Runtime {
|
||||
impl pezpallet_bar::Config for Runtime {}
|
||||
impl pezpallet_foo::Config for Runtime {}
|
||||
|
||||
type Block = frame::runtime::types_common::BlockOf<Runtime, SignedExtra>;
|
||||
type Header = HeaderFor<Runtime>;
|
||||
type Block = pezframe::runtime::types_common::BlockOf<Runtime, SignedExtra>;
|
||||
type _Header = HeaderFor<Runtime>;
|
||||
|
||||
#[docify::export(runtime_impl)]
|
||||
impl_runtime_apis! {
|
||||
@@ -119,9 +118,9 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl apis::Core<Block> for Runtime {
|
||||
impl pezsp_api::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion { VERSION }
|
||||
fn execute_block(_: <Block as frame::traits::Block>::LazyBlock) { }
|
||||
fn initialize_block(_: &Header) -> ExtrinsicInclusionMode { ExtrinsicInclusionMode::default() }
|
||||
fn execute_block(_: <Block as BlockT>::LazyBlock) { }
|
||||
fn initialize_block(_: &<Block as BlockT>::Header) -> ExtrinsicInclusionMode { ExtrinsicInclusionMode::default() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,18 +70,18 @@
|
||||
//!
|
||||
//! ### Defensive Traits
|
||||
//!
|
||||
//! The [`Defensive`](frame::traits::Defensive) trait provides a number of functions, all of which
|
||||
//! The [`Defensive`](pezframe::traits::Defensive) trait provides a number of functions, all of which
|
||||
//! provide an alternative to 'vanilla' Rust functions, e.g.:
|
||||
//!
|
||||
//! - [`defensive_unwrap_or()`](frame::traits::Defensive::defensive_unwrap_or) instead of
|
||||
//! - [`defensive_unwrap_or()`](pezframe::traits::Defensive::defensive_unwrap_or) instead of
|
||||
//! `unwrap_or()`
|
||||
//! - [`defensive_ok_or()`](frame::traits::DefensiveOption::defensive_ok_or) instead of `ok_or()`
|
||||
//! - [`defensive_ok_or()`](pezframe::traits::DefensiveOption::defensive_ok_or) instead of `ok_or()`
|
||||
//!
|
||||
//! Defensive methods use [`debug_assertions`](https://doc.rust-lang.org/reference/conditional-compilation.html#debug_assertions), which panic in development, but in
|
||||
//! production/release, they will merely log an error (i.e., `log::error`).
|
||||
//!
|
||||
//! The [`Defensive`](frame::traits::Defensive) trait and its various implementations can be found
|
||||
//! [here](frame::traits::Defensive).
|
||||
//! The [`Defensive`](pezframe::traits::Defensive) trait and its various implementations can be found
|
||||
//! [here](pezframe::traits::Defensive).
|
||||
//!
|
||||
//! ## Integer Overflow
|
||||
//!
|
||||
@@ -188,8 +188,8 @@
|
||||
//! to avoid introducing the notion of any potential-panic or wrapping behavior.
|
||||
//!
|
||||
//! There is also a series of defensive alternatives via
|
||||
//! [`DefensiveSaturating`](frame::traits::DefensiveSaturating), which introduces the same behavior
|
||||
//! of the [`Defensive`](frame::traits::Defensive) trait, only with saturating, mathematical
|
||||
//! [`DefensiveSaturating`](pezframe::traits::DefensiveSaturating), which introduces the same behavior
|
||||
//! of the [`Defensive`](pezframe::traits::Defensive) trait, only with saturating, mathematical
|
||||
//! operations:
|
||||
#![doc = docify::embed!(
|
||||
"./src/reference_docs/defensive_programming.rs",
|
||||
@@ -278,7 +278,7 @@
|
||||
//! actually cause harm to the network, and thus stalling would be the better option.
|
||||
//!
|
||||
//! Take the example of the BABE pezpallet ([`pezpallet_babe`]), which doesn't allow for a validator
|
||||
//! to participate if it is disabled (see: [`frame::traits::DisabledValidators`]):
|
||||
//! to participate if it is disabled (see: [`pezframe::traits::DisabledValidators`]):
|
||||
//!
|
||||
//! ```ignore
|
||||
//! if T::DisabledValidators::is_disabled(authority_index) {
|
||||
@@ -359,7 +359,7 @@ mod fake_runtime_types {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use frame::traits::DefensiveSaturating;
|
||||
use pezframe::traits::DefensiveSaturating;
|
||||
#[docify::export]
|
||||
#[test]
|
||||
fn checked_add_example() {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
//!
|
||||
//! ## compact_encoded_length
|
||||
//!
|
||||
//! This is a [SCALE compact encoded][frame::deps::codec::Compact] integer which is equal to the
|
||||
//! This is a [SCALE compact encoded][pezframe::deps::codec::Compact] integer which is equal to the
|
||||
//! length, in bytes, of the rest of the extrinsic details.
|
||||
//!
|
||||
//! To obtain this value, we must encode and concatenate together the rest of the extrinsic details
|
||||
@@ -90,7 +90,7 @@
|
||||
//!
|
||||
//! #### from_address
|
||||
//!
|
||||
//! This is the [SCALE encoded][frame::deps::codec] address of the sender of the extrinsic. The
|
||||
//! This is the [SCALE encoded][pezframe::deps::codec] address of the sender of the extrinsic. The
|
||||
//! address is the first generic parameter of [`pezsp_runtime::generic::UncheckedExtrinsic`], and so
|
||||
//! can vary from chain to chain.
|
||||
//!
|
||||
@@ -102,7 +102,7 @@
|
||||
//!
|
||||
//! #### signature
|
||||
//!
|
||||
//! This is the [SCALE encoded][frame::deps::codec] signature. The signature type is configured via
|
||||
//! This is the [SCALE encoded][pezframe::deps::codec] signature. The signature type is configured via
|
||||
//! the third generic parameter of [`pezsp_runtime::generic::UncheckedExtrinsic`], which determines
|
||||
//! the shape of the signature and signing algorithm that should be used.
|
||||
//!
|
||||
@@ -121,7 +121,7 @@
|
||||
//!
|
||||
//! ### transaction_extensions_extra
|
||||
//!
|
||||
//! This is the concatenation of the [SCALE encoded][frame::deps::codec] bytes representing first a
|
||||
//! This is the concatenation of the [SCALE encoded][pezframe::deps::codec] bytes representing first a
|
||||
//! single byte describing the extension version (this is bumped whenever a change occurs in the
|
||||
//! transaction extension pipeline) followed by the bytes of each of the [_transaction
|
||||
//! extensions_][pezsp_runtime::traits::TransactionExtension], and are configured by the fourth
|
||||
@@ -142,11 +142,11 @@
|
||||
//! configuration. At the time of writing, Pezkuwi configures them
|
||||
//! [here](https://github.com/polkadot-fellows/runtimes/blob/1dc04eb954eadf8aadb5d83990b89662dbb5a074/relay/polkadot/src/lib.rs#L1432C25-L1432C25).
|
||||
//! Some of the common transaction extensions are defined
|
||||
//! [here][frame::deps::pezframe_system#transaction-extensions].
|
||||
//! [here][pezframe::deps::pezframe_system#transaction-extensions].
|
||||
//!
|
||||
//! Information about exactly which transaction extensions are present on a chain and in what order
|
||||
//! is also a part of the metadata for the chain. For V15 metadata, it can be [found
|
||||
//! here][frame::deps::pezframe_support::__private::metadata::v15::ExtrinsicMetadata].
|
||||
//! here][pezframe::deps::pezframe_support::__private::metadata::v15::ExtrinsicMetadata].
|
||||
//!
|
||||
//! ## call_data
|
||||
//!
|
||||
@@ -154,7 +154,7 @@
|
||||
//! altered. This is defined by the second generic parameter of
|
||||
//! [`pezsp_runtime::generic::UncheckedExtrinsic`].
|
||||
//!
|
||||
//! A call can be anything that implements [`Encode`][frame::deps::codec::Encode]. In FRAME-based
|
||||
//! A call can be anything that implements [`Encode`][pezframe::deps::codec::Encode]. In FRAME-based
|
||||
//! runtimes, a call is represented as an enum of enums, where the outer enum represents the FRAME
|
||||
//! pezpallet being called, and the inner enum represents the call being made within that pezpallet,
|
||||
//! and any arguments to it. Read more about the call enum
|
||||
@@ -183,7 +183,7 @@
|
||||
//! Information about the pallets that exist for a chain (including their indexes), the calls
|
||||
//! available in each pezpallet (including their indexes), and the arguments required for each call
|
||||
//! can be found in the metadata for the chain. For V15 metadata, this information [is
|
||||
//! here][frame::deps::pezframe_support::__private::metadata::v15::PalletMetadata].
|
||||
//! here][pezframe::deps::pezframe_support::__private::metadata::v15::PalletMetadata].
|
||||
//!
|
||||
//! # The Signed Payload Format
|
||||
//!
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
//! ]
|
||||
//! ```
|
||||
//!
|
||||
//! More conveniently, the `frame` umbrella crate re-exports the log crate as [`frame::log`].
|
||||
//! More conveniently, the `frame` umbrella crate re-exports the log crate as [`pezframe::log`].
|
||||
//!
|
||||
//! Then, the pezpallet can use this crate to emit log statements. In this statement, we use the
|
||||
//! info level, and the target is `pezpallet-example`.
|
||||
@@ -68,7 +68,7 @@
|
||||
//!
|
||||
//! impl Pezpallet {
|
||||
//! fn logs() {
|
||||
//! frame::log::info!(target: "pezpallet-example", "Hello, world!");
|
||||
//! pezframe::log::info!(target: "pezpallet-example", "Hello, world!");
|
||||
//! }
|
||||
//! }
|
||||
//! }
|
||||
|
||||
@@ -54,13 +54,13 @@
|
||||
//! ## FRAME's API
|
||||
//!
|
||||
//! [`frame`] provides a simple API through which pallets can define offchain worker functions. This
|
||||
//! is part of [`frame::traits::Hooks`], which is implemented as a part of
|
||||
//! [`frame::pezpallet_macros::hooks`].
|
||||
//! is part of [`pezframe::traits::Hooks`], which is implemented as a part of
|
||||
//! [`pezframe::pezpallet_macros::hooks`].
|
||||
//!
|
||||
//! ```
|
||||
//! #[frame::pezpallet]
|
||||
//! #[pezframe::pezpallet]
|
||||
//! pub mod pezpallet {
|
||||
//! use frame::prelude::*;
|
||||
//! use pezframe::prelude::*;
|
||||
//!
|
||||
//! #[pezpallet::config]
|
||||
//! pub trait Config: pezframe_system::Config {}
|
||||
@@ -95,7 +95,7 @@
|
||||
//! API into the WASM blob are:
|
||||
//!
|
||||
//! * Accessing the state is easier within the `offchain_worker` function, as it is already a part
|
||||
//! of the runtime, and [`frame::pezpallet_macros::storage`] provides all the tools needed to read
|
||||
//! of the runtime, and [`pezframe::pezpallet_macros::storage`] provides all the tools needed to read
|
||||
//! the state. Other client libraries might provide varying degrees of capability here.
|
||||
//! * It will be updated in synchrony with the runtime. A Bizinikiwi's offchain application is part
|
||||
//! of the same WASM blob, and is therefore guaranteed to be up to date.
|
||||
|
||||
@@ -93,13 +93,13 @@
|
||||
//! Then, within the pezpallet, we can simply use this "unknown" origin check type:
|
||||
#![doc = docify::embed!("./src/reference_docs/frame_origin.rs", external_origin_usage)]
|
||||
//!
|
||||
//! Finally, at the runtime, any implementation of [`frame::traits::EnsureOrigin`] can be passed.
|
||||
//! Finally, at the runtime, any implementation of [`pezframe::traits::EnsureOrigin`] can be passed.
|
||||
#![doc = docify::embed!("./src/reference_docs/frame_origin.rs", external_origin_provide)]
|
||||
//!
|
||||
//! Indeed, some of these implementations of [`frame::traits::EnsureOrigin`] are similar to the ones
|
||||
//! that we know about: [`frame::runtime::prelude::EnsureSigned`],
|
||||
//! [`frame::runtime::prelude::EnsureSignedBy`], [`frame::runtime::prelude::EnsureRoot`],
|
||||
//! [`frame::runtime::prelude::EnsureNone`], etc. But, there are also many more that are not known
|
||||
//! Indeed, some of these implementations of [`pezframe::traits::EnsureOrigin`] are similar to the ones
|
||||
//! that we know about: [`pezframe::runtime::prelude::EnsureSigned`],
|
||||
//! [`pezframe::runtime::prelude::EnsureSignedBy`], [`pezframe::runtime::prelude::EnsureRoot`],
|
||||
//! [`pezframe::runtime::prelude::EnsureNone`], etc. But, there are also many more that are not known
|
||||
//! to us, and are defined in other pallets.
|
||||
//!
|
||||
//! For example, [`pezpallet_collective`] defines [`pezpallet_collective::EnsureMember`] and
|
||||
@@ -107,7 +107,7 @@
|
||||
//! alluded to earlier in this document.
|
||||
//!
|
||||
//! Make sure to check the full list of [implementors of
|
||||
//! `EnsureOrigin`](frame::traits::EnsureOrigin#implementors) for more inspiration.
|
||||
//! `EnsureOrigin`](pezframe::traits::EnsureOrigin#implementors) for more inspiration.
|
||||
//!
|
||||
//! ## Obtaining Abstract Origins
|
||||
//!
|
||||
@@ -129,9 +129,9 @@
|
||||
//! [^1]: Inherents are essentially unsigned extrinsics that need an [`pezframe_system::ensure_none`]
|
||||
//! origin check, and through the virtue of being an inherent, are agreed upon by all validators.
|
||||
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_for_origin {
|
||||
use super::*;
|
||||
|
||||
@@ -151,7 +151,7 @@ pub mod pezpallet_for_origin {
|
||||
}
|
||||
}
|
||||
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_with_custom_origin {
|
||||
use super::*;
|
||||
|
||||
@@ -206,7 +206,7 @@ pub mod pezpallet_with_custom_origin {
|
||||
|
||||
pub mod runtime_for_origin {
|
||||
use super::pezpallet_with_custom_origin;
|
||||
use frame::{runtime::prelude::*, testing_prelude::*};
|
||||
use pezframe::{runtime::prelude::*, testing_prelude::*};
|
||||
|
||||
#[docify::export(runtime_exp)]
|
||||
construct_runtime!(
|
||||
@@ -226,7 +226,7 @@ pub mod runtime_for_origin {
|
||||
}
|
||||
}
|
||||
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_with_external_origin {
|
||||
use super::*;
|
||||
#[docify::export(external_origin_def)]
|
||||
@@ -250,7 +250,7 @@ pub mod pezpallet_with_external_origin {
|
||||
|
||||
pub mod runtime_for_external_origin {
|
||||
use super::*;
|
||||
use frame::{runtime::prelude::*, testing_prelude::*};
|
||||
use pezframe::{runtime::prelude::*, testing_prelude::*};
|
||||
|
||||
construct_runtime!(
|
||||
pub struct Runtime {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! This reference document explains how FRAME pallets can be combined to interact together.
|
||||
//!
|
||||
//! It is suggested to re-read [`crate::pezkuwi_sdk::frame_runtime`], notably the information
|
||||
//! around [`frame::pezpallet_macros::config`]. Recall that:
|
||||
//! around [`pezframe::pezpallet_macros::config`]. Recall that:
|
||||
//!
|
||||
//! > Configuration trait of a pezpallet: It allows a pezpallet to receive types at a later
|
||||
//! > point from the runtime that wishes to contain it. It allows the pezpallet to be parameterized
|
||||
@@ -124,8 +124,8 @@
|
||||
//! With the above information in context, we can conclude that **`pezframe_system` is a special
|
||||
//! pezpallet that is tightly coupled with every other pezpallet**. This is because it provides the
|
||||
//! fundamental system functionality that every pezpallet needs, such as some types like
|
||||
//! [`frame::prelude::pezframe_system::Config::AccountId`],
|
||||
//! [`frame::prelude::pezframe_system::Config::Hash`], and some functionality such as block number,
|
||||
//! [`pezframe::prelude::pezframe_system::Config::AccountId`],
|
||||
//! [`pezframe::prelude::pezframe_system::Config::Hash`], and some functionality such as block number,
|
||||
//! etc.
|
||||
//!
|
||||
//! ## Recap
|
||||
@@ -157,10 +157,10 @@
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet]
|
||||
#[pezframe::pezpallet]
|
||||
pub mod pezpallet_foo {
|
||||
use super::*;
|
||||
|
||||
@@ -178,7 +178,7 @@ pub mod pezpallet_foo {
|
||||
}
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet]
|
||||
#[pezframe::pezpallet]
|
||||
pub mod pezpallet_author {
|
||||
use super::*;
|
||||
|
||||
@@ -195,7 +195,7 @@ pub mod pezpallet_author {
|
||||
}
|
||||
}
|
||||
|
||||
#[frame::pezpallet]
|
||||
#[pezframe::pezpallet]
|
||||
pub mod pezpallet_foo_tight {
|
||||
use super::*;
|
||||
|
||||
@@ -224,7 +224,7 @@ pub trait AuthorProvider<AccountId> {
|
||||
fn author() -> AccountId;
|
||||
}
|
||||
|
||||
#[frame::pezpallet]
|
||||
#[pezframe::pezpallet]
|
||||
pub mod pezpallet_foo_loose {
|
||||
use super::*;
|
||||
|
||||
@@ -272,7 +272,7 @@ impl<AccountId> AuthorProvider<AccountId> for () {
|
||||
|
||||
pub mod runtime {
|
||||
use super::*;
|
||||
use frame::{runtime::prelude::*, testing_prelude::*};
|
||||
use pezframe::{runtime::prelude::*, testing_prelude::*};
|
||||
use pezcumulus_pezpallet_aura_ext::pezpallet;
|
||||
|
||||
construct_runtime!(
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! This reference document explains how FRAME pezpallets can be combined to interact together.
|
||||
//!
|
||||
//! It is suggested to re-read [`crate::pezkuwi_sdk::frame_runtime`], notably the information
|
||||
//! around [`frame::pezpallet_macros::config`]. Recall that:
|
||||
//! around [`pezframe::pezpallet_macros::config`]. Recall that:
|
||||
//!
|
||||
//! > Configuration trait of a pezpallet: It allows a pezpallet to receive types at a later
|
||||
//! > point from the runtime that wishes to contain it. It allows the pezpallet to be parameterized
|
||||
@@ -123,8 +123,8 @@
|
||||
//! With the above information in context, we can conclude that **`pezframe_system` is a special pezpallet
|
||||
//! that is tightly coupled with every other pezpallet**. This is because it provides the fundamental
|
||||
//! system functionality that every pezpallet needs, such as some types like
|
||||
//! [`frame::prelude::pezframe_system::Config::AccountId`],
|
||||
//! [`frame::prelude::pezframe_system::Config::Hash`], and some functionality such as block number,
|
||||
//! [`pezframe::prelude::pezframe_system::Config::AccountId`],
|
||||
//! [`pezframe::prelude::pezframe_system::Config::Hash`], and some functionality such as block number,
|
||||
//! etc.
|
||||
//!
|
||||
//! ## Recap
|
||||
@@ -155,10 +155,10 @@
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet]
|
||||
#[pezframe::pezpallet]
|
||||
pub mod pezpallet_foo {
|
||||
use super::*;
|
||||
|
||||
@@ -176,7 +176,7 @@ pub mod pezpallet_foo {
|
||||
}
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet]
|
||||
#[pezframe::pezpallet]
|
||||
pub mod pezpallet_author {
|
||||
use super::*;
|
||||
|
||||
@@ -193,7 +193,7 @@ pub mod pezpallet_author {
|
||||
}
|
||||
}
|
||||
|
||||
#[frame::pezpallet]
|
||||
#[pezframe::pezpallet]
|
||||
pub mod pezpallet_foo_tight {
|
||||
use super::*;
|
||||
|
||||
@@ -221,7 +221,7 @@ pub trait AuthorProvider<AccountId> {
|
||||
fn author() -> AccountId;
|
||||
}
|
||||
|
||||
#[frame::pezpallet]
|
||||
#[pezframe::pezpallet]
|
||||
pub mod pezpallet_foo_loose {
|
||||
use super::*;
|
||||
|
||||
@@ -270,7 +270,7 @@ impl<AccountId> AuthorProvider<AccountId> for () {
|
||||
pub mod runtime {
|
||||
use super::*;
|
||||
use pezcumulus_pezpallet_aura_ext::pezpallet;
|
||||
use frame::{runtime::prelude::*, testing_prelude::*};
|
||||
use pezframe::{runtime::prelude::*, testing_prelude::*};
|
||||
|
||||
construct_runtime!(
|
||||
pub struct Runtime {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
//! pointer to the `Call` type in each pezpallet, for example [`pezpallet_foo::Call`].
|
||||
//!
|
||||
//! [`RuntimeOrigin`]'s [`OriginCaller`] has two variants, one for system, and one for
|
||||
//! `pezpallet_foo` which utilized [`frame::pezpallet_macros::origin`].
|
||||
//! `pezpallet_foo` which utilized [`pezframe::pezpallet_macros::origin`].
|
||||
//!
|
||||
//! Finally, [`RuntimeGenesisConfig`] is composed of `pezframe_system` and a variant for
|
||||
//! `pezpallet_bar`'s [`pezpallet_bar::GenesisConfig`].
|
||||
@@ -80,7 +80,7 @@
|
||||
//! The only way to express this using Rust's associated types is for the pezpallet to **define its
|
||||
//! own associated type `RuntimeCall`, and further specify what it thinks `RuntimeCall` should be**.
|
||||
//!
|
||||
//! In this case, we will want to assert the existence of [`frame::traits::IsSubType`], which is
|
||||
//! In this case, we will want to assert the existence of [`pezframe::traits::IsSubType`], which is
|
||||
//! very similar to [`TryFrom`].
|
||||
#![doc = docify::embed!("./src/reference_docs/frame_runtime_types.rs", custom_runtime_call)]
|
||||
//!
|
||||
@@ -100,7 +100,7 @@
|
||||
//! type that is only known when the runtime is being constructed.
|
||||
//!
|
||||
//! Now, within this pezpallet, this new `RuntimeCall` can be used, and it can use its new trait
|
||||
//! bounds, such as being [`frame::traits::IsSubType`]:
|
||||
//! bounds, such as being [`pezframe::traits::IsSubType`]:
|
||||
#![doc = docify::embed!("./src/reference_docs/frame_runtime_types.rs", custom_runtime_call_usages)]
|
||||
//!
|
||||
//! > Once Rust's "_Associated Type Bounds RFC_" is usable, this syntax can be used to
|
||||
@@ -116,9 +116,9 @@
|
||||
//! the runtime is constructed? The following snippet exactly does that:
|
||||
#![doc = docify::embed!("./src/reference_docs/frame_runtime_types.rs", assert_equality)]
|
||||
//!
|
||||
//! We leave it to the reader to further explore what [`frame::traits::Hooks::integrity_test`] is,
|
||||
//! We leave it to the reader to further explore what [`pezframe::traits::Hooks::integrity_test`] is,
|
||||
//! and what [`core::any::TypeId`] is. Another way to assert this is using
|
||||
//! [`frame::traits::IsType`].
|
||||
//! [`pezframe::traits::IsType`].
|
||||
//!
|
||||
//! ## Type Aliases
|
||||
//!
|
||||
@@ -128,7 +128,7 @@
|
||||
//! `System`
|
||||
//! * [`runtime::AllPalletsWithSystem`] is an alias for a tuple of all of the above. This type is
|
||||
//! important to FRAME internals such as `executive`, as it implements traits such as
|
||||
//! [`frame::traits::Hooks`].
|
||||
//! [`pezframe::traits::Hooks`].
|
||||
//!
|
||||
//! ## Further Details
|
||||
//!
|
||||
@@ -140,7 +140,7 @@
|
||||
//! * See the corresponding lecture in the [PBA Lectures](https://www.youtube.com/watch?v=OCBC1pMYPoc&list=PL-w_i5kwVqbni1Ch2j_RwTIXiB-bwnYqq&index=11).
|
||||
//!
|
||||
//!
|
||||
//! [`construct_runtime`]: frame::runtime::prelude::construct_runtime
|
||||
//! [`construct_runtime`]: pezframe::runtime::prelude::construct_runtime
|
||||
//! [`runtime::PalletFoo`]: crate::reference_docs::frame_runtime_types::runtime::PalletFoo
|
||||
//! [`runtime::AllPalletsWithSystem`]: crate::reference_docs::frame_runtime_types::runtime::AllPalletsWithSystem
|
||||
//! [`runtime`]: crate::reference_docs::frame_runtime_types::runtime
|
||||
@@ -158,10 +158,10 @@
|
||||
//! [`RuntimeCall`]: crate::reference_docs::frame_runtime_types::runtime::RuntimeCall
|
||||
//! [`RuntimeHoldReason`]: crate::reference_docs::frame_runtime_types::runtime::RuntimeHoldReason
|
||||
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_foo {
|
||||
use super::*;
|
||||
|
||||
@@ -201,7 +201,7 @@ pub mod pezpallet_foo {
|
||||
}
|
||||
|
||||
#[docify::export]
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_bar {
|
||||
use super::*;
|
||||
|
||||
@@ -232,7 +232,7 @@ pub mod pezpallet_bar {
|
||||
|
||||
pub mod runtime {
|
||||
use super::{pezpallet_bar, pezpallet_foo};
|
||||
use frame::{runtime::prelude::*, testing_prelude::*};
|
||||
use pezframe::{runtime::prelude::*, testing_prelude::*};
|
||||
|
||||
#[docify::export(runtime_exp)]
|
||||
construct_runtime!(
|
||||
@@ -252,10 +252,10 @@ pub mod runtime {
|
||||
impl pezpallet_bar::Config for Runtime {}
|
||||
}
|
||||
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
pub mod pezpallet_with_specific_runtime_call {
|
||||
use super::*;
|
||||
use frame::traits::IsSubType;
|
||||
use pezframe::traits::IsSubType;
|
||||
|
||||
#[docify::export(custom_runtime_call)]
|
||||
/// A pezpallet that wants to further narrow down what `RuntimeCall` is.
|
||||
@@ -299,7 +299,7 @@ pub mod pezpallet_with_specific_runtime_call {
|
||||
|
||||
pub mod runtime_with_specific_runtime_call {
|
||||
use super::pezpallet_with_specific_runtime_call;
|
||||
use frame::{runtime::prelude::*, testing_prelude::*};
|
||||
use pezframe::{runtime::prelude::*, testing_prelude::*};
|
||||
|
||||
construct_runtime!(
|
||||
pub struct Runtime {
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
//! # Migrations
|
||||
//!
|
||||
//! It is often desirable to define logic to execute immediately after runtime upgrades (see
|
||||
//! [this diagram](frame::traits::Hooks)).
|
||||
//! [this diagram](pezframe::traits::Hooks)).
|
||||
//!
|
||||
//! Self-contained pieces of logic that execute after a runtime upgrade are called "Migrations".
|
||||
//!
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
//! Let's begin by starting to store a `NewType` in a storage item:
|
||||
//!
|
||||
//! ```compile_fail
|
||||
//! #[frame::pezpallet]
|
||||
//! #[pezframe::pezpallet]
|
||||
//! pub mod pezpallet {
|
||||
//! # use frame::prelude::*;
|
||||
//! # use pezframe::prelude::*;
|
||||
//! # #[pezpallet::config]
|
||||
//! # pub trait Config: pezframe_system::Config {}
|
||||
//! # #[pezpallet::pezpallet]
|
||||
@@ -25,16 +25,16 @@
|
||||
//! This raises a number of compiler errors, like:
|
||||
//! ```text
|
||||
//! the trait `MaxEncodedLen` is not implemented for `NewType`, which is required by
|
||||
//! `frame::prelude::StorageValue<_GeneratedPrefixForStorageSomething<T>, NewType>:
|
||||
//! `pezframe::prelude::StorageValue<_GeneratedPrefixForStorageSomething<T>, NewType>:
|
||||
//! StorageInfoTrait`
|
||||
//! ```
|
||||
//!
|
||||
//! This implies the following set of traits that need to be derived for a type to be stored in
|
||||
//! `frame` storage:
|
||||
//! ```rust
|
||||
//! #[frame::pezpallet]
|
||||
//! #[pezframe::pezpallet]
|
||||
//! pub mod pezpallet {
|
||||
//! # use frame::prelude::*;
|
||||
//! # use pezframe::prelude::*;
|
||||
//! # #[pezpallet::config]
|
||||
//! # pub trait Config: pezframe_system::Config {}
|
||||
//! # #[pezpallet::pezpallet]
|
||||
@@ -48,11 +48,11 @@
|
||||
//! ```
|
||||
//!
|
||||
//! Next, let's look at how this will differ if we are to store a type that is derived from `T` in
|
||||
//! storage, such as [`frame::prelude::BlockNumberFor`]:
|
||||
//! storage, such as [`pezframe::prelude::BlockNumberFor`]:
|
||||
//! ```compile_fail
|
||||
//! #[frame::pezpallet]
|
||||
//! #[pezframe::pezpallet]
|
||||
//! pub mod pezpallet {
|
||||
//! # use frame::prelude::*;
|
||||
//! # use pezframe::prelude::*;
|
||||
//! # #[pezpallet::config]
|
||||
//! # pub trait Config: pezframe_system::Config {}
|
||||
//! # #[pezpallet::pezpallet]
|
||||
@@ -84,9 +84,9 @@
|
||||
//! attribute to `NewType`. This additional macro will instruct the `derive` to skip the bound on
|
||||
//! `T`.
|
||||
//! ```rust
|
||||
//! #[frame::pezpallet]
|
||||
//! #[pezframe::pezpallet]
|
||||
//! pub mod pezpallet {
|
||||
//! # use frame::prelude::*;
|
||||
//! # use pezframe::prelude::*;
|
||||
//! # #[pezpallet::config]
|
||||
//! # pub trait Config: pezframe_system::Config {}
|
||||
//! # #[pezpallet::pezpallet]
|
||||
@@ -100,13 +100,13 @@
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! Next, let's say we wish to store `NewType` as [`frame::prelude::ValueQuery`], which means it
|
||||
//! Next, let's say we wish to store `NewType` as [`pezframe::prelude::ValueQuery`], which means it
|
||||
//! must also implement `Default`. This should be as simple as adding `derive(Default)` to it,
|
||||
//! right?
|
||||
//! ```compile_fail
|
||||
//! #[frame::pezpallet]
|
||||
//! #[pezframe::pezpallet]
|
||||
//! pub mod pezpallet {
|
||||
//! # use frame::prelude::*;
|
||||
//! # use pezframe::prelude::*;
|
||||
//! # #[pezpallet::config]
|
||||
//! # pub trait Config: pezframe_system::Config {}
|
||||
//! # #[pezpallet::pezpallet]
|
||||
@@ -129,22 +129,22 @@
|
||||
//! To fix this, frame provides a set of macros that are analogous to normal rust derive macros, but
|
||||
//! work nicely on top of structs that are generic over `T: Config`. These macros are:
|
||||
//!
|
||||
//! - [`frame::prelude::DefaultNoBound`]
|
||||
//! - [`frame::prelude::DebugNoBound`]
|
||||
//! - [`frame::prelude::PartialEqNoBound`]
|
||||
//! - [`frame::prelude::EqNoBound`]
|
||||
//! - [`frame::prelude::CloneNoBound`]
|
||||
//! - [`frame::prelude::PartialOrdNoBound`]
|
||||
//! - [`frame::prelude::OrdNoBound`]
|
||||
//! - [`pezframe::prelude::DefaultNoBound`]
|
||||
//! - [`pezframe::prelude::DebugNoBound`]
|
||||
//! - [`pezframe::prelude::PartialEqNoBound`]
|
||||
//! - [`pezframe::prelude::EqNoBound`]
|
||||
//! - [`pezframe::prelude::CloneNoBound`]
|
||||
//! - [`pezframe::prelude::PartialOrdNoBound`]
|
||||
//! - [`pezframe::prelude::OrdNoBound`]
|
||||
//!
|
||||
//! The above traits are almost certainly needed for your tests - to print your type, assert equality
|
||||
//! or clone it.
|
||||
//!
|
||||
//! We can fix the following example by using [`frame::prelude::DefaultNoBound`].
|
||||
//! We can fix the following example by using [`pezframe::prelude::DefaultNoBound`].
|
||||
//! ```rust
|
||||
//! #[frame::pezpallet]
|
||||
//! #[pezframe::pezpallet]
|
||||
//! pub mod pezpallet {
|
||||
//! # use frame::prelude::*;
|
||||
//! # use pezframe::prelude::*;
|
||||
//! # #[pezpallet::config]
|
||||
//! # pub trait Config: pezframe_system::Config {}
|
||||
//! # #[pezpallet::pezpallet]
|
||||
@@ -167,9 +167,9 @@
|
||||
//! Finally, if a custom type that is provided through `Config` is to be stored in the storage, it
|
||||
//! is subject to the same trait requirements. The following does not work:
|
||||
//! ```compile_fail
|
||||
//! #[frame::pezpallet]
|
||||
//! #[pezframe::pezpallet]
|
||||
//! pub mod pezpallet {
|
||||
//! use frame::prelude::*;
|
||||
//! use pezframe::prelude::*;
|
||||
//! #[pezpallet::config]
|
||||
//! pub trait Config: pezframe_system::Config {
|
||||
//! type CustomType;
|
||||
@@ -183,9 +183,9 @@
|
||||
//!
|
||||
//! But adding the right trait bounds will fix it.
|
||||
//! ```rust
|
||||
//! #[frame::pezpallet]
|
||||
//! #[pezframe::pezpallet]
|
||||
//! pub mod pezpallet {
|
||||
//! use frame::prelude::*;
|
||||
//! use pezframe::prelude::*;
|
||||
//! #[pezpallet::config]
|
||||
//! pub trait Config: pezframe_system::Config {
|
||||
//! type CustomType: codec::FullCodec
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
#![doc = docify::embed!("src/reference_docs/pezframe_benchmarking_weight.rs", WeightInfo)]
|
||||
//!
|
||||
//! Then, individual functions of this trait are the final values that we assigned to the
|
||||
//! [`frame::pezpallet_macros::weight`] attribute:
|
||||
//! [`pezframe::pezpallet_macros::weight`] attribute:
|
||||
#![doc = docify::embed!("./src/reference_docs/pezframe_benchmarking_weight.rs", simple_transfer_2)]
|
||||
//!
|
||||
//! ## Manual Refund
|
||||
@@ -130,10 +130,10 @@
|
||||
//! [PolkaVM]: https://github.com/koute/polkavm
|
||||
//! [JAM]: https://graypaper.com
|
||||
|
||||
#[frame::pezpallet(dev_mode)]
|
||||
#[pezframe::pezpallet(dev_mode)]
|
||||
#[allow(unused_variables, unreachable_code, unused, clippy::diverging_sub_expression)]
|
||||
pub mod pezpallet {
|
||||
use frame::prelude::*;
|
||||
use pezframe::prelude::*;
|
||||
|
||||
#[docify::export]
|
||||
pub trait WeightInfo {
|
||||
@@ -202,7 +202,7 @@ pub mod pezpallet {
|
||||
let actual_weight =
|
||||
todo!("this can likely come from another benchmark that is NOT the worst case");
|
||||
let pays_fee = todo!("You can set this to `Pays::Yes` or `Pays::No` to change if this transaction should pay fees");
|
||||
Ok(frame::deps::pezframe_support::dispatch::PostDispatchInfo {
|
||||
Ok(pezframe::deps::pezframe_support::dispatch::PostDispatchInfo {
|
||||
actual_weight: Some(actual_weight),
|
||||
pays_fee,
|
||||
})
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
//! The rest of this document assumes familiarity with the
|
||||
//! [Rust book's Advanced Traits](https://doc.rust-lang.org/book/ch19-03-advanced-traits.html)
|
||||
//! section.
|
||||
//! Moreover, we use the [`frame::traits::Get`].
|
||||
//! Moreover, we use the [`pezframe::traits::Get`].
|
||||
//!
|
||||
//! First, imagine we are writing a FRAME pezpallet. We represent this pezpallet with a `struct
|
||||
//! Pezpallet`, and this pezpallet wants to implement the functionalities of that pezpallet, for
|
||||
//! example a simple `transfer` function. For the sake of education, we are interested in having a
|
||||
//! `MinTransfer` amount, expressed as a [`frame::traits::Get`], which will dictate what is the
|
||||
//! `MinTransfer` amount, expressed as a [`pezframe::traits::Get`], which will dictate what is the
|
||||
//! minimum amount that can be transferred.
|
||||
//!
|
||||
//! We can foremost write this as simple as the following snippet:
|
||||
@@ -84,7 +84,7 @@
|
||||
//! having individual `trait Configs` declare a shared `trait SystemConfig` as their
|
||||
//! [supertrait](https://doc.rust-lang.org/rust-by-example/trait/supertraits.html).
|
||||
#![doc = docify::embed!("./src/reference_docs/trait_based_programming.rs", with_system)]
|
||||
//! In FRAME, this shared supertrait is [`frame::prelude::pezframe_system`].
|
||||
//! In FRAME, this shared supertrait is [`pezframe::prelude::pezframe_system`].
|
||||
//!
|
||||
//! Notice how this made no difference in the syntax of the rest of the code. `T::AccountId` is
|
||||
//! still a valid type, since `T` implements `Config` and `Config` implies `SystemConfig`, which
|
||||
@@ -103,7 +103,7 @@
|
||||
//! length of fully qualified syntax is a common pattern in FRAME.
|
||||
//!
|
||||
//! The above example is almost identical to the well-known (and somewhat notorious) `type
|
||||
//! BalanceOf` that is often used in the context of [`frame::traits::fungible`].
|
||||
//! BalanceOf` that is often used in the context of [`pezframe::traits::fungible`].
|
||||
#![doc = docify::embed!("../../bizinikiwi/pezframe/fast-unstake/src/types.rs", BalanceOf)]
|
||||
//!
|
||||
//! ## Additional Resources
|
||||
@@ -113,15 +113,15 @@
|
||||
//! - <https://exchange.pezkuwichain.app/questions/2228/type-casting-to-trait-t-as-config>
|
||||
#![allow(unused)]
|
||||
|
||||
use frame::traits::Get;
|
||||
use pezframe::traits::Get;
|
||||
|
||||
#[docify::export]
|
||||
mod basic {
|
||||
struct Pezpallet;
|
||||
|
||||
type AccountId = frame::deps::pezsp_runtime::AccountId32;
|
||||
type AccountId = pezframe::deps::pezsp_runtime::AccountId32;
|
||||
type Balance = u128;
|
||||
type MinTransfer = frame::traits::ConstU128<10>;
|
||||
type MinTransfer = pezframe::traits::ConstU128<10>;
|
||||
|
||||
impl Pezpallet {
|
||||
fn transfer(_from: AccountId, _to: AccountId, _amount: Balance) {
|
||||
@@ -140,8 +140,8 @@ mod generic {
|
||||
|
||||
impl<AccountId, Balance, MinTransfer> Pezpallet<AccountId, Balance, MinTransfer>
|
||||
where
|
||||
Balance: frame::traits::AtLeast32BitUnsigned,
|
||||
MinTransfer: frame::traits::Get<Balance>,
|
||||
Balance: pezframe::traits::AtLeast32BitUnsigned,
|
||||
MinTransfer: pezframe::traits::Get<Balance>,
|
||||
AccountId: From<[u8; 32]>,
|
||||
{
|
||||
fn transfer(_from: AccountId, _to: AccountId, amount: Balance) {
|
||||
@@ -157,8 +157,8 @@ mod trait_based {
|
||||
|
||||
trait Config {
|
||||
type AccountId: From<[u8; 32]>;
|
||||
type Balance: frame::traits::AtLeast32BitUnsigned;
|
||||
type MinTransfer: frame::traits::Get<Self::Balance>;
|
||||
type Balance: pezframe::traits::AtLeast32BitUnsigned;
|
||||
type MinTransfer: pezframe::traits::Get<Self::Balance>;
|
||||
}
|
||||
|
||||
struct Pezpallet<T: Config>(std::marker::PhantomData<T>);
|
||||
@@ -179,8 +179,8 @@ mod with_system {
|
||||
}
|
||||
|
||||
pub trait Config: SystemConfig {
|
||||
type Balance: frame::traits::AtLeast32BitUnsigned;
|
||||
type MinTransfer: frame::traits::Get<Self::Balance>;
|
||||
type Balance: pezframe::traits::AtLeast32BitUnsigned;
|
||||
type MinTransfer: pezframe::traits::Get<Self::Balance>;
|
||||
}
|
||||
|
||||
pub struct Pezpallet<T: Config>(std::marker::PhantomData<T>);
|
||||
@@ -205,7 +205,7 @@ mod fully_qualified_complicated {
|
||||
use super::with_system::*;
|
||||
|
||||
trait CurrencyTrait {
|
||||
type Balance: frame::traits::AtLeast32BitUnsigned;
|
||||
type Balance: pezframe::traits::AtLeast32BitUnsigned;
|
||||
fn more_stuff() {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user