feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
[package]
|
||||
name = "pezpallet-skip-feeless-payment"
|
||||
version = "3.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
description = "Pallet to skip payments for calls annotated with `feeless_if` if the respective conditions are satisfied."
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
# Bizinikiwi dependencies
|
||||
pezsp-runtime = { workspace = true }
|
||||
|
||||
pezframe-support = { workspace = true }
|
||||
pezframe-system = { workspace = true }
|
||||
|
||||
# Other dependencies
|
||||
codec = { features = ["derive"], workspace = true }
|
||||
scale-info = { features = ["derive"], workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"scale-info/std",
|
||||
"pezsp-runtime/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"pezframe-support/try-runtime",
|
||||
"pezframe-system/try-runtime",
|
||||
"pezsp-runtime/try-runtime",
|
||||
]
|
||||
@@ -0,0 +1,206 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//! # Skip Feeless Payment Pallet
|
||||
//!
|
||||
//! This pallet allows runtimes that include it to skip payment of transaction fees for
|
||||
//! dispatchables marked by
|
||||
//! [`#[pallet::feeless_if]`](pezframe_support::pezpallet_prelude::feeless_if).
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! It does this by wrapping an existing [`TransactionExtension`] implementation (e.g.
|
||||
//! [`pezpallet-transaction-payment`]) and checking if the dispatchable is feeless before applying the
|
||||
//! wrapped extension. If the dispatchable is indeed feeless, the extension is skipped and a custom
|
||||
//! event is emitted instead. Otherwise, the extension is applied as usual.
|
||||
//!
|
||||
//!
|
||||
//! ## Integration
|
||||
//!
|
||||
//! This pallet wraps an existing transaction payment pallet. This means you should both pallets
|
||||
//! in your [`construct_runtime`](pezframe_support::construct_runtime) macro and
|
||||
//! include this pallet's [`TransactionExtension`] ([`SkipCheckIfFeeless`]) that would accept the
|
||||
//! existing one as an argument.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode};
|
||||
use pezframe_support::{
|
||||
dispatch::{CheckIfFeeless, DispatchResult},
|
||||
pezpallet_prelude::TransactionSource,
|
||||
traits::{IsType, OriginTrait},
|
||||
weights::Weight,
|
||||
};
|
||||
use scale_info::{StaticTypeInfo, TypeInfo};
|
||||
use pezsp_runtime::{
|
||||
traits::{
|
||||
DispatchInfoOf, DispatchOriginOf, Implication, PostDispatchInfoOf, TransactionExtension,
|
||||
ValidateResult,
|
||||
},
|
||||
transaction_validity::TransactionValidityError,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use pallet::*;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A transaction fee was skipped.
|
||||
FeeSkipped { origin: <T::RuntimeOrigin as OriginTrait>::PalletsOrigin },
|
||||
}
|
||||
}
|
||||
|
||||
/// A [`TransactionExtension`] that skips the wrapped extension if the dispatchable is feeless.
|
||||
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, Eq, PartialEq)]
|
||||
pub struct SkipCheckIfFeeless<T, S>(pub S, core::marker::PhantomData<T>);
|
||||
|
||||
// Make this extension "invisible" from the outside (ie metadata type information)
|
||||
impl<T, S: StaticTypeInfo> TypeInfo for SkipCheckIfFeeless<T, S> {
|
||||
type Identity = S;
|
||||
fn type_info() -> scale_info::Type {
|
||||
S::type_info()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S: Encode> core::fmt::Debug for SkipCheckIfFeeless<T, S> {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
write!(f, "SkipCheckIfFeeless<{:?}>", self.0.encode())
|
||||
}
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S> From<S> for SkipCheckIfFeeless<T, S> {
|
||||
fn from(s: S) -> Self {
|
||||
Self(s, core::marker::PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Intermediate<T, O> {
|
||||
/// The wrapped extension should be applied.
|
||||
Apply(T),
|
||||
/// The wrapped extension should be skipped.
|
||||
Skip(O),
|
||||
}
|
||||
use Intermediate::*;
|
||||
|
||||
impl<T: Config + Send + Sync, S: TransactionExtension<T::RuntimeCall>>
|
||||
TransactionExtension<T::RuntimeCall> for SkipCheckIfFeeless<T, S>
|
||||
where
|
||||
T::RuntimeCall: CheckIfFeeless<Origin = pezframe_system::pezpallet_prelude::OriginFor<T>>,
|
||||
{
|
||||
// From the outside this extension should be "invisible", because it just extends the wrapped
|
||||
// extension with an extra check in `pre_dispatch` and `post_dispatch`. Thus, we should forward
|
||||
// the identifier of the wrapped extension to let wallets see this extension as it would only be
|
||||
// the wrapped extension itself.
|
||||
const IDENTIFIER: &'static str = S::IDENTIFIER;
|
||||
type Implicit = S::Implicit;
|
||||
|
||||
fn metadata() -> alloc::vec::Vec<pezsp_runtime::traits::TransactionExtensionMetadata> {
|
||||
S::metadata()
|
||||
}
|
||||
|
||||
fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> {
|
||||
self.0.implicit()
|
||||
}
|
||||
type Val =
|
||||
Intermediate<S::Val, <DispatchOriginOf<T::RuntimeCall> as OriginTrait>::PalletsOrigin>;
|
||||
type Pre =
|
||||
Intermediate<S::Pre, <DispatchOriginOf<T::RuntimeCall> as OriginTrait>::PalletsOrigin>;
|
||||
|
||||
fn weight(&self, call: &T::RuntimeCall) -> pezframe_support::weights::Weight {
|
||||
self.0.weight(call)
|
||||
}
|
||||
|
||||
fn validate(
|
||||
&self,
|
||||
origin: DispatchOriginOf<T::RuntimeCall>,
|
||||
call: &T::RuntimeCall,
|
||||
info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
len: usize,
|
||||
self_implicit: S::Implicit,
|
||||
inherited_implication: &impl Implication,
|
||||
source: TransactionSource,
|
||||
) -> ValidateResult<Self::Val, T::RuntimeCall> {
|
||||
if call.is_feeless(&origin) {
|
||||
Ok((Default::default(), Skip(origin.caller().clone()), origin))
|
||||
} else {
|
||||
let (x, y, z) = self.0.validate(
|
||||
origin,
|
||||
call,
|
||||
info,
|
||||
len,
|
||||
self_implicit,
|
||||
inherited_implication,
|
||||
source,
|
||||
)?;
|
||||
Ok((x, Apply(y), z))
|
||||
}
|
||||
}
|
||||
|
||||
fn prepare(
|
||||
self,
|
||||
val: Self::Val,
|
||||
origin: &DispatchOriginOf<T::RuntimeCall>,
|
||||
call: &T::RuntimeCall,
|
||||
info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
match val {
|
||||
Apply(val) => self.0.prepare(val, origin, call, info, len).map(Apply),
|
||||
Skip(origin) => Ok(Skip(origin)),
|
||||
}
|
||||
}
|
||||
|
||||
fn post_dispatch_details(
|
||||
pre: Self::Pre,
|
||||
info: &DispatchInfoOf<T::RuntimeCall>,
|
||||
post_info: &PostDispatchInfoOf<T::RuntimeCall>,
|
||||
len: usize,
|
||||
result: &DispatchResult,
|
||||
) -> Result<Weight, TransactionValidityError> {
|
||||
match pre {
|
||||
Apply(pre) => S::post_dispatch_details(pre, info, post_info, len, result),
|
||||
Skip(origin) => {
|
||||
Pallet::<T>::deposit_event(Event::<T>::FeeSkipped { origin });
|
||||
Ok(Weight::zero())
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use super::*;
|
||||
use crate as pezpallet_skip_feeless_payment;
|
||||
|
||||
use pezframe_support::{derive_impl, parameter_types};
|
||||
use pezframe_system as system;
|
||||
use pezsp_runtime::{
|
||||
traits::{DispatchOriginOf, TransactionExtension},
|
||||
transaction_validity::ValidTransaction,
|
||||
};
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Runtime>;
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Runtime {
|
||||
type Block = Block;
|
||||
}
|
||||
|
||||
impl Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub static PrepareCount: u32 = 0;
|
||||
pub static ValidateCount: u32 = 0;
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, DecodeWithMemTracking, TypeInfo)]
|
||||
pub struct DummyExtension;
|
||||
|
||||
impl TransactionExtension<RuntimeCall> for DummyExtension {
|
||||
const IDENTIFIER: &'static str = "DummyExtension";
|
||||
type Implicit = ();
|
||||
type Val = ();
|
||||
type Pre = ();
|
||||
|
||||
fn weight(&self, _: &RuntimeCall) -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
|
||||
fn validate(
|
||||
&self,
|
||||
origin: DispatchOriginOf<RuntimeCall>,
|
||||
_call: &RuntimeCall,
|
||||
_info: &DispatchInfoOf<RuntimeCall>,
|
||||
_len: usize,
|
||||
_self_implicit: Self::Implicit,
|
||||
_inherited_implication: &impl Encode,
|
||||
_source: TransactionSource,
|
||||
) -> ValidateResult<Self::Val, RuntimeCall> {
|
||||
ValidateCount::mutate(|c| *c += 1);
|
||||
Ok((ValidTransaction::default(), (), origin))
|
||||
}
|
||||
|
||||
fn prepare(
|
||||
self,
|
||||
_val: Self::Val,
|
||||
_origin: &DispatchOriginOf<RuntimeCall>,
|
||||
_call: &RuntimeCall,
|
||||
_info: &DispatchInfoOf<RuntimeCall>,
|
||||
_len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
PrepareCount::mutate(|c| *c += 1);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[pezframe_support::pallet(dev_mode)]
|
||||
pub mod pezpallet_dummy {
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: pezframe_system::Config {}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::feeless_if(|_origin: &OriginFor<T>, data: &u32| -> bool {
|
||||
*data == 0
|
||||
})]
|
||||
pub fn aux(_origin: OriginFor<T>, #[pallet::compact] _data: u32) -> DispatchResult {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl pezpallet_dummy::Config for Runtime {}
|
||||
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Runtime {
|
||||
System: system,
|
||||
SkipFeeless: pezpallet_skip_feeless_payment,
|
||||
DummyPallet: pezpallet_dummy,
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,111 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use super::*;
|
||||
use crate::mock::{
|
||||
pezpallet_dummy::Call, DummyExtension, PrepareCount, Runtime, RuntimeCall, ValidateCount,
|
||||
};
|
||||
use pezframe_support::dispatch::DispatchInfo;
|
||||
use pezsp_runtime::{traits::DispatchTransaction, transaction_validity::TransactionSource};
|
||||
|
||||
#[test]
|
||||
fn skip_feeless_payment_works() {
|
||||
let call = RuntimeCall::DummyPallet(Call::<Runtime>::aux { data: 1 });
|
||||
SkipCheckIfFeeless::<Runtime, DummyExtension>::from(DummyExtension)
|
||||
.validate_and_prepare(Some(0).into(), &call, &DispatchInfo::default(), 0, 0)
|
||||
.unwrap();
|
||||
assert_eq!(PrepareCount::get(), 1);
|
||||
|
||||
let call = RuntimeCall::DummyPallet(Call::<Runtime>::aux { data: 0 });
|
||||
SkipCheckIfFeeless::<Runtime, DummyExtension>::from(DummyExtension)
|
||||
.validate_and_prepare(Some(0).into(), &call, &DispatchInfo::default(), 0, 0)
|
||||
.unwrap();
|
||||
assert_eq!(PrepareCount::get(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validate_works() {
|
||||
assert_eq!(ValidateCount::get(), 0);
|
||||
|
||||
let call = RuntimeCall::DummyPallet(Call::<Runtime>::aux { data: 1 });
|
||||
SkipCheckIfFeeless::<Runtime, DummyExtension>::from(DummyExtension)
|
||||
.validate_only(
|
||||
Some(0).into(),
|
||||
&call,
|
||||
&DispatchInfo::default(),
|
||||
0,
|
||||
TransactionSource::External,
|
||||
0,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(ValidateCount::get(), 1);
|
||||
assert_eq!(PrepareCount::get(), 0);
|
||||
|
||||
let call = RuntimeCall::DummyPallet(Call::<Runtime>::aux { data: 0 });
|
||||
SkipCheckIfFeeless::<Runtime, DummyExtension>::from(DummyExtension)
|
||||
.validate_only(
|
||||
Some(0).into(),
|
||||
&call,
|
||||
&DispatchInfo::default(),
|
||||
0,
|
||||
TransactionSource::External,
|
||||
0,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(ValidateCount::get(), 1);
|
||||
assert_eq!(PrepareCount::get(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validate_prepare_works() {
|
||||
assert_eq!(ValidateCount::get(), 0);
|
||||
|
||||
let call = RuntimeCall::DummyPallet(Call::<Runtime>::aux { data: 1 });
|
||||
SkipCheckIfFeeless::<Runtime, DummyExtension>::from(DummyExtension)
|
||||
.validate_and_prepare(Some(0).into(), &call, &DispatchInfo::default(), 0, 0)
|
||||
.unwrap();
|
||||
assert_eq!(ValidateCount::get(), 1);
|
||||
assert_eq!(PrepareCount::get(), 1);
|
||||
|
||||
let call = RuntimeCall::DummyPallet(Call::<Runtime>::aux { data: 0 });
|
||||
SkipCheckIfFeeless::<Runtime, DummyExtension>::from(DummyExtension)
|
||||
.validate_and_prepare(Some(0).into(), &call, &DispatchInfo::default(), 0, 0)
|
||||
.unwrap();
|
||||
assert_eq!(ValidateCount::get(), 1);
|
||||
assert_eq!(PrepareCount::get(), 1);
|
||||
|
||||
// Changes from previous prepare calls persist.
|
||||
let call = RuntimeCall::DummyPallet(Call::<Runtime>::aux { data: 1 });
|
||||
SkipCheckIfFeeless::<Runtime, DummyExtension>::from(DummyExtension)
|
||||
.validate_and_prepare(Some(0).into(), &call, &DispatchInfo::default(), 0, 0)
|
||||
.unwrap();
|
||||
assert_eq!(ValidateCount::get(), 2);
|
||||
assert_eq!(PrepareCount::get(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn metadata_for_wrap_multiple_tx_ext() {
|
||||
let metadata = SkipCheckIfFeeless::<Runtime, (DummyExtension, DummyExtension)>::metadata();
|
||||
let mut expected_metadata = vec![];
|
||||
expected_metadata.extend(DummyExtension::metadata().into_iter());
|
||||
expected_metadata.extend(DummyExtension::metadata().into_iter());
|
||||
|
||||
assert_eq!(metadata.len(), expected_metadata.len());
|
||||
for i in 0..expected_metadata.len() {
|
||||
assert_eq!(metadata[i].identifier, expected_metadata[i].identifier);
|
||||
assert_eq!(metadata[i].ty, expected_metadata[i].ty);
|
||||
assert_eq!(metadata[i].implicit, expected_metadata[i].implicit);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user