Files
pezkuwi-sdk/pezcumulus/pallets/xcm/src/lib.rs
T
pezkuwichain 379cb741ed 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.
2025-12-14 00:04:10 +03:00

119 lines
3.2 KiB
Rust

// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezcumulus.
// 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.
//! Pallet for stuff specific to teyrchains' usage of XCM. Right now that's just the origin
//! used by teyrchains when receiving `Transact` messages from other teyrchains or the Relay chain
//! which must be natively represented.
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode};
use cumulus_primitives_core::ParaId;
pub use pallet::*;
use scale_info::TypeInfo;
use pezsp_runtime::{traits::BadOrigin, RuntimeDebug};
use xcm::latest::{ExecuteXcm, Outcome};
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
/// The module configuration trait.
#[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>;
type XcmExecutor: ExecuteXcm<Self::RuntimeCall>;
}
#[pallet::event]
pub enum Event<T: Config> {
/// Downward message is invalid XCM.
/// \[ id \]
InvalidFormat([u8; 32]),
/// Downward message is unsupported version of XCM.
/// \[ id \]
UnsupportedVersion([u8; 32]),
/// Downward message executed with the given outcome.
/// \[ id, outcome \]
ExecutedDownward([u8; 32], Outcome),
}
/// Origin for the teyrchains module.
#[derive(
PartialEq,
Eq,
Clone,
Encode,
Decode,
DecodeWithMemTracking,
TypeInfo,
RuntimeDebug,
MaxEncodedLen,
)]
#[pallet::origin]
pub enum Origin {
/// It comes from the (parent) relay chain.
Relay,
/// It comes from a (sibling) teyrchain.
SiblingTeyrchain(ParaId),
}
#[pallet::call]
impl<T: Config> Pallet<T> {}
impl From<ParaId> for Origin {
fn from(id: ParaId) -> Origin {
Origin::SiblingTeyrchain(id)
}
}
impl From<u32> for Origin {
fn from(id: u32) -> Origin {
Origin::SiblingTeyrchain(id.into())
}
}
}
/// Ensure that the origin `o` represents a sibling teyrchain.
/// Returns `Ok` with the teyrchain ID of the sibling or an `Err` otherwise.
pub fn ensure_sibling_para<OuterOrigin>(o: OuterOrigin) -> Result<ParaId, BadOrigin>
where
OuterOrigin: Into<Result<Origin, OuterOrigin>>,
{
match o.into() {
Ok(Origin::SiblingTeyrchain(id)) => Ok(id),
_ => Err(BadOrigin),
}
}
/// Ensure that the origin `o` represents is the relay chain.
/// Returns `Ok` if it does or an `Err` otherwise.
pub fn ensure_relay<OuterOrigin>(o: OuterOrigin) -> Result<(), BadOrigin>
where
OuterOrigin: Into<Result<Origin, OuterOrigin>>,
{
match o.into() {
Ok(Origin::Relay) => Ok(()),
_ => Err(BadOrigin),
}
}