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,60 @@
|
||||
[package]
|
||||
name = "pezpallet-example-view-functions"
|
||||
version = "1.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "Pallet to demonstrate the usage of view functions to query pallet state"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { default-features = false, workspace = true }
|
||||
frame-metadata = { features = ["current"], workspace = true }
|
||||
log = { workspace = true }
|
||||
scale-info = { default-features = false, features = [
|
||||
"derive",
|
||||
], workspace = true }
|
||||
|
||||
pezframe-support = { default-features = false, workspace = true }
|
||||
pezframe-system = { default-features = false, workspace = true }
|
||||
|
||||
pezsp-core = { default-features = false, workspace = true }
|
||||
pezsp-io = { default-features = false, workspace = true }
|
||||
pezsp-metadata-ir = { default-features = false, workspace = true }
|
||||
pezsp-runtime = { default-features = false, workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"frame-metadata/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"log/std",
|
||||
"scale-info/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-io/std",
|
||||
"pezsp-metadata-ir/std",
|
||||
"pezsp-runtime/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezsp-io/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"pezframe-support/try-runtime",
|
||||
"pezframe-system/try-runtime",
|
||||
"pezsp-runtime/try-runtime",
|
||||
]
|
||||
@@ -0,0 +1,114 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// 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.
|
||||
|
||||
//! This pallet demonstrates the use of the `pallet::view_functions` api for service
|
||||
//! work.
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub mod tests;
|
||||
|
||||
use pezframe_support::Parameter;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
pub struct SomeType1;
|
||||
impl From<SomeType1> for u64 {
|
||||
fn from(_t: SomeType1) -> Self {
|
||||
0u64
|
||||
}
|
||||
}
|
||||
|
||||
pub trait SomeAssociation1 {
|
||||
type _1: Parameter + codec::MaxEncodedLen + TypeInfo;
|
||||
}
|
||||
impl SomeAssociation1 for u64 {
|
||||
type _1 = u64;
|
||||
}
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T> {}
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: pezframe_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
#[pallet::storage]
|
||||
pub type SomeValue<T: Config> = StorageValue<_, u32>;
|
||||
|
||||
#[pallet::storage]
|
||||
pub type SomeMap<T: Config> = StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
|
||||
|
||||
#[pallet::view_functions]
|
||||
impl<T: Config> Pallet<T>
|
||||
where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
/// Query value with no input args.
|
||||
pub fn get_value() -> Option<u32> {
|
||||
SomeValue::<T>::get()
|
||||
}
|
||||
|
||||
/// Query value with input args.
|
||||
pub fn get_value_with_arg(key: u32) -> Option<u32> {
|
||||
SomeMap::<T>::get(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet2 {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T, I = ()> {}
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config<I: 'static = ()>: pezframe_system::Config {}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||
|
||||
#[pallet::storage]
|
||||
pub type SomeValue<T: Config<I>, I: 'static = ()> = StorageValue<_, u32>;
|
||||
|
||||
#[pallet::storage]
|
||||
pub type SomeMap<T: Config<I>, I: 'static = ()> =
|
||||
StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
|
||||
|
||||
#[pallet::view_functions]
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I>
|
||||
where
|
||||
T::AccountId: From<SomeType1> + SomeAssociation1,
|
||||
{
|
||||
/// Query value with no input args.
|
||||
pub fn get_value() -> Option<u32> {
|
||||
SomeValue::<T, I>::get()
|
||||
}
|
||||
|
||||
/// Query value with input args.
|
||||
pub fn get_value_with_arg(key: u32) -> Option<u32> {
|
||||
SomeMap::<T, I>::get(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// 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.
|
||||
|
||||
//! Tests for `pezpallet-example-view-functions`.
|
||||
#![cfg(test)]
|
||||
|
||||
use crate::{
|
||||
pallet::{self, Pallet},
|
||||
pallet2,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::meta_type;
|
||||
|
||||
use pezframe_support::{derive_impl, pezpallet_prelude::PalletInfoAccess, view_functions::ViewFunction};
|
||||
use pezsp_io::hashing::twox_128;
|
||||
use pezsp_metadata_ir::{
|
||||
ItemDeprecationInfoIR, PalletViewFunctionMetadataIR, PalletViewFunctionParamMetadataIR,
|
||||
};
|
||||
use pezsp_runtime::testing::TestXt;
|
||||
|
||||
pub type AccountId = u32;
|
||||
pub type Balance = u32;
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Runtime>;
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Runtime {
|
||||
System: pezframe_system,
|
||||
ViewFunctionsExample: pallet,
|
||||
ViewFunctionsInstance: pallet2,
|
||||
ViewFunctionsInstance1: pallet2::<Instance1>,
|
||||
}
|
||||
);
|
||||
|
||||
pub type Extrinsic = TestXt<RuntimeCall, ()>;
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Runtime {
|
||||
type Block = Block;
|
||||
}
|
||||
|
||||
impl pallet::Config for Runtime {}
|
||||
impl pallet2::Config<pallet2::Instance1> for Runtime {}
|
||||
|
||||
impl pallet2::Config for Runtime {}
|
||||
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
use pezsp_runtime::BuildStorage;
|
||||
|
||||
let t = RuntimeGenesisConfig { system: Default::default() }.build_storage().unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pezpallet_get_value_query() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let some_value = Some(99);
|
||||
pallet::SomeValue::<Runtime>::set(some_value);
|
||||
assert_eq!(some_value, Pallet::<Runtime>::get_value());
|
||||
|
||||
let query = pallet::GetValueViewFunction::<Runtime>::new();
|
||||
test_dispatch_view_function(&query, some_value);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pezpallet_get_value_with_arg_query() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let some_key = 1u32;
|
||||
let some_value = Some(123);
|
||||
pallet::SomeMap::<Runtime>::set(some_key, some_value);
|
||||
assert_eq!(some_value, Pallet::<Runtime>::get_value_with_arg(some_key));
|
||||
|
||||
let query = pallet::GetValueWithArgViewFunction::<Runtime>::new(some_key);
|
||||
test_dispatch_view_function(&query, some_value);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pezpallet_multiple_instances() {
|
||||
use pallet2::Instance1;
|
||||
|
||||
new_test_ext().execute_with(|| {
|
||||
let instance_value = Some(123);
|
||||
let instance1_value = Some(456);
|
||||
|
||||
pallet2::SomeValue::<Runtime>::set(instance_value);
|
||||
pallet2::SomeValue::<Runtime, Instance1>::set(instance1_value);
|
||||
|
||||
let query = pallet2::GetValueViewFunction::<Runtime>::new();
|
||||
test_dispatch_view_function(&query, instance_value);
|
||||
|
||||
let query_instance1 = pallet2::GetValueViewFunction::<Runtime, Instance1>::new();
|
||||
test_dispatch_view_function(&query_instance1, instance1_value);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn metadata_ir_definitions() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let metadata_ir = Runtime::metadata_ir();
|
||||
let pallet1 = metadata_ir
|
||||
.pallets
|
||||
.iter()
|
||||
.find(|pallet| pallet.name == "ViewFunctionsExample")
|
||||
.unwrap();
|
||||
|
||||
fn view_fn_id(preifx_hash: [u8; 16], view_fn_signature: &str) -> [u8; 32] {
|
||||
let mut id = [0u8; 32];
|
||||
id[..16].copy_from_slice(&preifx_hash);
|
||||
id[16..].copy_from_slice(&twox_128(view_fn_signature.as_bytes()));
|
||||
id
|
||||
}
|
||||
|
||||
let get_value_id = view_fn_id(
|
||||
<ViewFunctionsExample as PalletInfoAccess>::name_hash(),
|
||||
"get_value() -> Option<u32>",
|
||||
);
|
||||
|
||||
let get_value_with_arg_id = view_fn_id(
|
||||
<ViewFunctionsExample as PalletInfoAccess>::name_hash(),
|
||||
"get_value_with_arg(u32) -> Option<u32>",
|
||||
);
|
||||
|
||||
pretty_assertions::assert_eq!(
|
||||
pallet1.view_functions,
|
||||
vec![
|
||||
PalletViewFunctionMetadataIR {
|
||||
name: "get_value",
|
||||
id: get_value_id,
|
||||
inputs: vec![],
|
||||
output: meta_type::<Option<u32>>(),
|
||||
docs: vec![" Query value with no input args."],
|
||||
deprecation_info: ItemDeprecationInfoIR::NotDeprecated,
|
||||
},
|
||||
PalletViewFunctionMetadataIR {
|
||||
name: "get_value_with_arg",
|
||||
id: get_value_with_arg_id,
|
||||
inputs: vec![PalletViewFunctionParamMetadataIR {
|
||||
name: "key",
|
||||
ty: meta_type::<u32>()
|
||||
},],
|
||||
output: meta_type::<Option<u32>>(),
|
||||
docs: vec![" Query value with input args."],
|
||||
deprecation_info: ItemDeprecationInfoIR::NotDeprecated,
|
||||
},
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
fn test_dispatch_view_function<Q, V>(query: &Q, expected: V)
|
||||
where
|
||||
Q: ViewFunction + Encode,
|
||||
V: Decode + Eq + PartialEq + std::fmt::Debug,
|
||||
{
|
||||
let input = query.encode();
|
||||
let output = Runtime::execute_view_function(Q::id(), input).unwrap();
|
||||
let query_result = V::decode(&mut &output[..]).unwrap();
|
||||
|
||||
assert_eq!(expected, query_result,);
|
||||
}
|
||||
Reference in New Issue
Block a user