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,24 @@
|
||||
[package]
|
||||
name = "pezsp-rpc"
|
||||
version = "26.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "Bizinikiwi RPC primitives and utilities."
|
||||
readme = "README.md"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
rustc-hash = { workspace = true }
|
||||
serde = { features = ["derive"], workspace = true, default-features = true }
|
||||
pezsp-core = { workspace = true, default-features = true }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = { workspace = true, default-features = true }
|
||||
@@ -0,0 +1,3 @@
|
||||
Bizinikiwi RPC primitives and utilities.
|
||||
|
||||
License: Apache-2.0
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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.
|
||||
|
||||
//! Bizinikiwi RPC primitives and utilities.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
pub mod list;
|
||||
pub mod number;
|
||||
pub mod tracing;
|
||||
|
||||
/// A util function to assert the result of serialization and deserialization is the same.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn assert_deser<T>(s: &str, expected: T)
|
||||
where
|
||||
T: std::fmt::Debug + serde::ser::Serialize + serde::de::DeserializeOwned + PartialEq,
|
||||
{
|
||||
assert_eq!(serde_json::from_str::<T>(s).unwrap(), expected);
|
||||
assert_eq!(serde_json::to_string(&expected).unwrap(), s);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// 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.
|
||||
|
||||
//! RPC a lenient list or value type.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// RPC list or value wrapper.
|
||||
///
|
||||
/// For some RPCs it's convenient to call them with either
|
||||
/// a single value or a whole list of values to get a proper response.
|
||||
/// In theory you could do a batch query, but it's:
|
||||
/// 1. Less convenient in client libraries
|
||||
/// 2. If the response value is small, the protocol overhead might be dominant.
|
||||
///
|
||||
/// Also it's nice to be able to maintain backward compatibility for methods that
|
||||
/// were initially taking a value and now we want to expand them to take a list.
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
#[serde(untagged)]
|
||||
pub enum ListOrValue<T> {
|
||||
/// A list of values of given type.
|
||||
List(Vec<T>),
|
||||
/// A single value of given type.
|
||||
Value(T),
|
||||
}
|
||||
|
||||
impl<T> ListOrValue<T> {
|
||||
/// Map every contained value using function `F`.
|
||||
///
|
||||
/// This allows to easily convert all values in any of the variants.
|
||||
pub fn map<F: Fn(T) -> X, X>(self, f: F) -> ListOrValue<X> {
|
||||
match self {
|
||||
ListOrValue::List(v) => ListOrValue::List(v.into_iter().map(f).collect()),
|
||||
ListOrValue::Value(v) => ListOrValue::Value(f(v)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<T> for ListOrValue<T> {
|
||||
fn from(n: T) -> Self {
|
||||
ListOrValue::Value(n)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<Vec<T>> for ListOrValue<T> {
|
||||
fn from(n: Vec<T>) -> Self {
|
||||
ListOrValue::List(n)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::assert_deser;
|
||||
|
||||
#[test]
|
||||
fn should_serialize_and_deserialize() {
|
||||
assert_deser(r#"5"#, ListOrValue::Value(5_u64));
|
||||
assert_deser(r#""str""#, ListOrValue::Value("str".to_string()));
|
||||
assert_deser(r#"[1,2,3]"#, ListOrValue::List(vec![1_u64, 2_u64, 3_u64]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
// 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.
|
||||
|
||||
//! A number type that can be serialized both as a number or a string that encodes a number in a
|
||||
//! string.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use pezsp_core::U256;
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// A number type that can be serialized both as a number or a string that encodes a number in a
|
||||
/// string.
|
||||
///
|
||||
/// We allow two representations of the block number as input. Either we deserialize to the type
|
||||
/// that is specified in the block type or we attempt to parse given hex value.
|
||||
///
|
||||
/// The primary motivation for having this type is to avoid overflows when using big integers in
|
||||
/// JavaScript (which we consider as an important RPC API consumer).
|
||||
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)]
|
||||
#[serde(untagged)]
|
||||
pub enum NumberOrHex {
|
||||
/// The number represented directly.
|
||||
Number(u64),
|
||||
/// Hex representation of the number.
|
||||
Hex(U256),
|
||||
}
|
||||
|
||||
impl Default for NumberOrHex {
|
||||
fn default() -> Self {
|
||||
Self::Number(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl NumberOrHex {
|
||||
/// Converts this number into an U256.
|
||||
pub fn into_u256(self) -> U256 {
|
||||
match self {
|
||||
NumberOrHex::Number(n) => n.into(),
|
||||
NumberOrHex::Hex(h) => h,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for NumberOrHex {
|
||||
fn from(n: u32) -> Self {
|
||||
NumberOrHex::Number(n.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for NumberOrHex {
|
||||
fn from(n: u64) -> Self {
|
||||
NumberOrHex::Number(n)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u128> for NumberOrHex {
|
||||
fn from(n: u128) -> Self {
|
||||
NumberOrHex::Hex(n.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U256> for NumberOrHex {
|
||||
fn from(n: U256) -> Self {
|
||||
NumberOrHex::Hex(n)
|
||||
}
|
||||
}
|
||||
|
||||
/// An error type that signals an out-of-range conversion attempt.
|
||||
pub struct TryFromIntError(pub(crate) ());
|
||||
|
||||
impl TryFrom<NumberOrHex> for u32 {
|
||||
type Error = TryFromIntError;
|
||||
fn try_from(num_or_hex: NumberOrHex) -> Result<u32, Self::Error> {
|
||||
num_or_hex.into_u256().try_into().map_err(|_| TryFromIntError(()))
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<NumberOrHex> for u64 {
|
||||
type Error = TryFromIntError;
|
||||
fn try_from(num_or_hex: NumberOrHex) -> Result<u64, Self::Error> {
|
||||
num_or_hex.into_u256().try_into().map_err(|_| TryFromIntError(()))
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<NumberOrHex> for u128 {
|
||||
type Error = TryFromIntError;
|
||||
fn try_from(num_or_hex: NumberOrHex) -> Result<u128, Self::Error> {
|
||||
num_or_hex.into_u256().try_into().map_err(|_| TryFromIntError(()))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NumberOrHex> for U256 {
|
||||
fn from(num_or_hex: NumberOrHex) -> U256 {
|
||||
num_or_hex.into_u256()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::assert_deser;
|
||||
|
||||
#[test]
|
||||
fn should_serialize_and_deserialize() {
|
||||
assert_deser(r#""0x1234""#, NumberOrHex::Hex(0x1234.into()));
|
||||
assert_deser(r#""0x0""#, NumberOrHex::Hex(0.into()));
|
||||
assert_deser(r#"5"#, NumberOrHex::Number(5));
|
||||
assert_deser(r#"10000"#, NumberOrHex::Number(10000));
|
||||
assert_deser(r#"0"#, NumberOrHex::Number(0));
|
||||
assert_deser(r#"1000000000000"#, NumberOrHex::Number(1000000000000));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
// 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.
|
||||
|
||||
//! Types for working with tracing data
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
/// Container for all related spans and events for the block being traced.
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BlockTrace {
|
||||
/// Hash of the block being traced
|
||||
pub block_hash: String,
|
||||
/// Parent hash
|
||||
pub parent_hash: String,
|
||||
/// Module targets that were recorded by the tracing subscriber.
|
||||
/// Empty string means record all targets.
|
||||
pub tracing_targets: String,
|
||||
/// Storage key targets used to filter out events that do not have one of the storage keys.
|
||||
/// Empty string means do not filter out any events.
|
||||
pub storage_keys: String,
|
||||
/// Method targets used to filter out events that do not have one of the event method.
|
||||
/// Empty string means do not filter out any events.
|
||||
pub methods: String,
|
||||
/// Vec of tracing spans
|
||||
pub spans: Vec<Span>,
|
||||
/// Vec of tracing events
|
||||
pub events: Vec<Event>,
|
||||
}
|
||||
|
||||
/// Represents a tracing event, complete with recorded data.
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Event {
|
||||
/// Event target
|
||||
pub target: String,
|
||||
/// Associated data
|
||||
pub data: Data,
|
||||
/// Parent id, if it exists
|
||||
pub parent_id: Option<u64>,
|
||||
}
|
||||
|
||||
/// Represents a single instance of a tracing span.
|
||||
///
|
||||
/// Exiting a span does not imply that the span will not be re-entered.
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Span {
|
||||
/// id for this span
|
||||
pub id: u64,
|
||||
/// id of the parent span, if any
|
||||
pub parent_id: Option<u64>,
|
||||
/// Name of this span
|
||||
pub name: String,
|
||||
/// Target, typically module
|
||||
pub target: String,
|
||||
/// Indicates if the span is from wasm
|
||||
pub wasm: bool,
|
||||
}
|
||||
|
||||
/// Holds associated values for a tracing span.
|
||||
#[derive(Serialize, Deserialize, Default, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Data {
|
||||
/// HashMap of `String` values recorded while tracing
|
||||
pub string_values: FxHashMap<String, String>,
|
||||
}
|
||||
|
||||
/// Error response for the `state_traceBlock` RPC.
|
||||
#[derive(Serialize, Deserialize, Default, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TraceError {
|
||||
/// Error message
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
/// Response for the `state_traceBlock` RPC.
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum TraceBlockResponse {
|
||||
/// Error block tracing response
|
||||
TraceError(TraceError),
|
||||
/// Successful block tracing response
|
||||
BlockTrace(BlockTrace),
|
||||
}
|
||||
Reference in New Issue
Block a user