mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 17:41:08 +00:00
Complete rebrand: Polkadot→Pezkuwi, Substrate→Bizinikiwi
- Replace PolkadotConfig with PezkuwiConfig - Replace SubstrateConfig with BizinikiwConfig - Rename config module files (polkadot.rs→pezkuwi.rs, substrate.rs→bizinikiwi.rs) - Update all documentation and examples - All 165 files updated, cargo check passes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: Subxt integration tests failed against latest Substrate build.
|
||||
title: Subxt integration tests failed against latest Bizinikiwi build.
|
||||
---
|
||||
|
||||
The nightly CI run which downloads the latest version of Substrate ran into test failures, which likely means that there are breaking changes that need fixing in Subxt.
|
||||
The nightly CI run which downloads the latest version of Bizinikiwi ran into test failures, which likely means that there are breaking changes that need fixing in Subxt.
|
||||
|
||||
Go to https://github.com/paritytech/subxt/actions/workflows/nightly.yml to see details about the failure.
|
||||
Go to https://github.com/pezkuwichain/subxt/actions/workflows/nightly.yml to see details about the failure.
|
||||
@@ -1,3 +1,3 @@
|
||||
# use-nodes
|
||||
|
||||
This action downloads the substrate and polkadot binaries produced from the `build-nodes` workflow and puts them into the `$PATH`.
|
||||
This action downloads the bizinikiwi and pezkuwi binaries produced from the `build-nodes` workflow and puts them into the `$PATH`.
|
||||
+728
-728
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -132,7 +132,7 @@ futures-timer = "3"
|
||||
web-time = { version = "1.1", default-features = false }
|
||||
tokio-util = "0.7.12"
|
||||
|
||||
# Pezkuwi SDK crates (rebranded from Substrate) - using git deps:
|
||||
# Pezkuwi SDK crates (rebranded from Bizinikiwi) - using git deps:
|
||||
pezsc-executor = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main", default-features = false }
|
||||
pezsc-executor-common = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main", default-features = false }
|
||||
pezsp-crypto-hashing = { git = "https://github.com/pezkuwichain/pezkuwi-sdk.git", branch = "main", default-features = false }
|
||||
@@ -155,7 +155,7 @@ pezkuwi-subxt-lightclient = { version = "0.44.0", path = "lightclient", default-
|
||||
pezkuwi-subxt-utils-fetchmetadata = { version = "0.44.0", path = "utils/fetch-metadata", default-features = false }
|
||||
pezkuwi-subxt-utils-stripmetadata = { version = "0.44.0", path = "utils/strip-metadata", default-features = false }
|
||||
test-runtime = { path = "testing/test-runtime" }
|
||||
bizinikiwi-runner = { path = "testing/substrate-runner" }
|
||||
bizinikiwi-runner = { path = "testing/bizinikiwi-runner" }
|
||||
|
||||
# subxt-signer deps that I expect aren't useful anywhere else:
|
||||
bip39 = { version = "2.1.0", default-features = false }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# subxt · [](https://github.com/paritytech/subxt/actions/workflows/rust.yml) [](https://crates.io/crates/subxt) [](https://docs.rs/subxt)
|
||||
# subxt · [](https://github.com/pezkuwichain/subxt/actions/workflows/rust.yml) [](https://crates.io/crates/subxt) [](https://docs.rs/subxt)
|
||||
|
||||
Subxt is a library for interacting with [Substrate](https://github.com/paritytech/polkadot-sdk) based nodes in Rust and WebAssembly. It can:
|
||||
Subxt is a library for interacting with [Bizinikiwi](https://github.com/pezkuwichain/pezkuwi-sdk) based nodes in Rust and WebAssembly. It can:
|
||||
|
||||
- Submit Extrinsics (this is where the name comes from).
|
||||
- Subscribe to blocks, reading the extrinsics and associated events from them.
|
||||
@@ -17,7 +17,7 @@ Subxt is a library for interacting with [Substrate](https://github.com/paritytec
|
||||
Take a look in the [examples](./subxt/examples) folder or the [examples](./examples) folder for various smaller or
|
||||
larger `subxt` usage examples, or [read the guide](https://docs.rs/subxt/latest/subxt/book/index.html) to learn more.
|
||||
|
||||
### Downloading metadata from a Substrate node
|
||||
### Downloading metadata from a Bizinikiwi node
|
||||
|
||||
Use the [`subxt-cli`](./cli) tool to download the metadata for your target runtime from a node.
|
||||
|
||||
@@ -42,35 +42,35 @@ For more details regarding utilizing subxt, please visit the [documentation](htt
|
||||
|
||||
## Integration Testing
|
||||
|
||||
Most tests require a running substrate node to communicate with. This is done by spawning an instance of the
|
||||
substrate node per test. It requires an up-to-date `substrate` executable on your path.
|
||||
Most tests require a running bizinikiwi node to communicate with. This is done by spawning an instance of the
|
||||
bizinikiwi node per test. It requires an up-to-date `bizinikiwi` executable on your path.
|
||||
|
||||
This can be installed from source via cargo:
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/paritytech/polkadot-sdk staging-node-cli --force
|
||||
cargo install --git https://github.com/pezkuwichain/pezkuwi-sdk staging-node-cli --force
|
||||
```
|
||||
|
||||
## Real world usage
|
||||
|
||||
Please add your project to this list via a PR.
|
||||
|
||||
- [cargo-contract](https://github.com/paritytech/cargo-contract/) CLI for interacting with Wasm smart contracts.
|
||||
- [cargo-contract](https://github.com/pezkuwichain/cargo-contract/) CLI for interacting with Wasm smart contracts.
|
||||
- [xcm-cli](https://github.com/ascjones/xcm-cli) CLI for submitting XCM messages.
|
||||
- [phala-pherry](https://github.com/Phala-Network/phala-blockchain/tree/master/standalone/pherry) The relayer between Phala blockchain and the off-chain Secure workers.
|
||||
- [crunch](https://github.com/turboflakes/crunch) CLI to claim staking rewards in batch every Era or X hours for substrate-based chains.
|
||||
- [crunch](https://github.com/turboflakes/crunch) CLI to claim staking rewards in batch every Era or X hours for bizinikiwi-based chains.
|
||||
- [interbtc-clients](https://github.com/interlay/interbtc-clients) Client implementations for the interBTC parachain; notably the Vault / Relayer and Oracle.
|
||||
- [tidext](https://github.com/tidelabs/tidext) Tidechain client with Stronghold signer.
|
||||
- [staking-miner-v2](https://github.com/paritytech/staking-miner-v2) Submit NPos election solutions and get rewards.
|
||||
- [polkadot-introspector](https://github.com/paritytech/polkadot-introspector) Tools for monitoring Polkadot nodes.
|
||||
- [ink!](https://github.com/paritytech/ink) Smart contract language that uses `subxt` for allowing developers to conduct [End-to-End testing](https://use.ink/basics/contract-testing/end-to-end-e2e-testing) of their contracts.
|
||||
- [staking-miner-v2](https://github.com/pezkuwichain/staking-miner-v2) Submit NPos election solutions and get rewards.
|
||||
- [pezkuwi-introspector](https://github.com/pezkuwichain/pezkuwi-introspector) Tools for monitoring Pezkuwi nodes.
|
||||
- [ink!](https://github.com/pezkuwichain/ink) Smart contract language that uses `subxt` for allowing developers to conduct [End-to-End testing](https://use.ink/basics/contract-testing/end-to-end-e2e-testing) of their contracts.
|
||||
- [Chainflip](https://github.com/chainflip-io/chainflip-backend) A decentralised exchange for native cross-chain swaps.
|
||||
- [Hyperbridge](https://github.com/polytope-labs/hyperbridge) A hyperscalable coprocessor for verifiable cross-chain interoperability.
|
||||
- [pop CLI](https://github.com/r0gue-io/pop-cli) The all-in-one tool for Polkadot development.
|
||||
- [pop CLI](https://github.com/r0gue-io/pop-cli) The all-in-one tool for Pezkuwi development.
|
||||
|
||||
**Alternatives**
|
||||
|
||||
[substrate-api-client](https://github.com/scs/substrate-api-client) provides similar functionality.
|
||||
[bizinikiwi-api-client](https://github.com/scs/bizinikiwi-api-client) provides similar functionality.
|
||||
|
||||
#### License
|
||||
|
||||
|
||||
+1
-1
@@ -103,6 +103,6 @@ We also assume that ongoing work done is being merged directly to the `master` b
|
||||
git push --tags
|
||||
```
|
||||
|
||||
Once this is pushed, go along to [the releases page on GitHub](https://github.com/paritytech/subxt/releases)
|
||||
Once this is pushed, go along to [the releases page on GitHub](https://github.com/pezkuwichain/subxt/releases)
|
||||
and draft a new release which points to the tag you just pushed to `master` above. Copy the changelog comments
|
||||
for the current release into the release description.
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
# subxt-cli
|
||||
|
||||
Utilities for working with substrate metadata for `subxt`
|
||||
Utilities for working with bizinikiwi metadata for `subxt`
|
||||
|
||||
```
|
||||
USAGE:
|
||||
@@ -17,7 +17,7 @@ Prints help information
|
||||
SUBCOMMANDS:
|
||||
codegen Generate runtime API client code from metadata
|
||||
help Prints this message or the help of the given subcommand(s)
|
||||
metadata Download metadata from a substrate node, for use with `subxt` codegen
|
||||
metadata Download metadata from a bizinikiwi node, for use with `subxt` codegen
|
||||
```
|
||||
|
||||
## Metadata
|
||||
@@ -32,7 +32,7 @@ USAGE:
|
||||
|
||||
OPTIONS:
|
||||
-f, --format <format> the format of the metadata to display: `json`, `hex` or `bytes` [default: json]
|
||||
--url <url> the url of the substrate node to query for metadata [default: http://localhost:9933]
|
||||
--url <url> the url of the bizinikiwi node to query for metadata [default: http://localhost:9933]
|
||||
```
|
||||
|
||||
## Codegen
|
||||
@@ -52,7 +52,7 @@ OPTIONS:
|
||||
the path to the encoded metadata file
|
||||
|
||||
--url <url>
|
||||
the url of the substrate node to query for metadata for codegen
|
||||
the url of the bizinikiwi node to query for metadata for codegen
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ use std::{io::Write, path::PathBuf};
|
||||
|
||||
mod fetch;
|
||||
|
||||
/// Download chainSpec from a substrate node.
|
||||
/// Download chainSpec from a bizinikiwi node.
|
||||
#[derive(Debug, ClapParser)]
|
||||
pub struct Opts {
|
||||
/// The url of the substrate node to query for metadata for codegen.
|
||||
/// The url of the bizinikiwi node to query for metadata for codegen.
|
||||
#[clap(long)]
|
||||
url: Url,
|
||||
/// Write the output of the command to the provided file path.
|
||||
|
||||
@@ -301,7 +301,7 @@ fn codegen(
|
||||
|
||||
// Run this first to ensure type paths are unique (which may result in 1,2,3 suffixes being
|
||||
// added to type paths), so that when we validate derives/substitutions below, they are
|
||||
// allowed for such types. See <https://github.com/paritytech/subxt/issues/2011>.
|
||||
// allowed for such types. See <https://github.com/pezkuwichain/subxt/issues/2011>.
|
||||
scale_typegen::utils::ensure_unique_type_paths(metadata.types_mut())
|
||||
.expect("ensure_unique_type_paths should not fail; please report an issue.");
|
||||
|
||||
@@ -418,7 +418,7 @@ mod tests {
|
||||
}
|
||||
|
||||
async fn run(args_str: &str) -> color_eyre::Result<String> {
|
||||
let mut args = vec!["codegen", "--file=../artifacts/polkadot_metadata_small.scale"];
|
||||
let mut args = vec!["codegen", "--file=../artifacts/pezkuwi_metadata_small.scale"];
|
||||
args.extend(args_str.split(' ').filter(|e| !e.is_empty()));
|
||||
let opts: super::Opts = clap::Parser::try_parse_from(args)?;
|
||||
let mut output: Vec<u8> = Vec::new();
|
||||
|
||||
@@ -13,10 +13,10 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::utils::validate_url_security;
|
||||
|
||||
/// Verify metadata compatibility between substrate nodes.
|
||||
/// Verify metadata compatibility between bizinikiwi nodes.
|
||||
#[derive(Debug, ClapParser)]
|
||||
pub struct Opts {
|
||||
/// Urls of the substrate nodes to verify for metadata compatibility.
|
||||
/// Urls of the bizinikiwi nodes to verify for metadata compatibility.
|
||||
#[clap(name = "nodes", long, use_value_delimiter = true, value_parser)]
|
||||
nodes: Vec<Url>,
|
||||
/// Check the compatibility of metadata for a particular pallet.
|
||||
|
||||
@@ -17,8 +17,8 @@ use pezkuwi_subxt_metadata::{
|
||||
///
|
||||
/// # Example
|
||||
/// ```text
|
||||
/// subxt diff ./artifacts/polkadot_metadata_small.scale ./artifacts/polkadot_metadata_tiny.scale
|
||||
/// subxt diff ./artifacts/polkadot_metadata_small.scale wss://rpc.polkadot.io:443
|
||||
/// subxt diff ./artifacts/pezkuwi_metadata_small.scale ./artifacts/pezkuwi_metadata_tiny.scale
|
||||
/// subxt diff ./artifacts/pezkuwi_metadata_small.scale wss://rpc.pezkuwi.io:443
|
||||
/// ```
|
||||
#[derive(Debug, Args)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
|
||||
@@ -20,7 +20,7 @@ mod runtime_apis;
|
||||
/// Show the pallets and runtime apis that are available:
|
||||
///
|
||||
/// ```text
|
||||
/// subxt explore --file=polkadot_metadata.scale
|
||||
/// subxt explore --file=pezkuwi_metadata.scale
|
||||
/// ```
|
||||
///
|
||||
/// ## Pallets
|
||||
@@ -290,7 +290,7 @@ pub mod tests {
|
||||
}
|
||||
|
||||
async fn run_against_file(cli_command: &str) -> color_eyre::Result<String> {
|
||||
run(&format!("--file=../artifacts/polkadot_metadata_small.scale {cli_command}")).await
|
||||
run(&format!("--file=../artifacts/pezkuwi_metadata_small.scale {cli_command}")).await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -422,11 +422,11 @@ pub mod tests {
|
||||
#[tokio::test]
|
||||
async fn insecure_urls_get_denied() {
|
||||
// Connection should work fine:
|
||||
run("--url wss://rpc.polkadot.io:443").await.unwrap();
|
||||
run("--url wss://rpc.pezkuwi.io:443").await.unwrap();
|
||||
|
||||
// Errors, because the --allow-insecure is not set:
|
||||
assert!(
|
||||
run("--url ws://rpc.polkadot.io:443")
|
||||
run("--url ws://rpc.pezkuwi.io:443")
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::str::FromStr;
|
||||
|
||||
use pezkuwi_subxt::{
|
||||
OfflineClient,
|
||||
config::SubstrateConfig,
|
||||
config::BizinikiwConfig,
|
||||
metadata::{Metadata, PalletMetadata},
|
||||
tx,
|
||||
utils::H256,
|
||||
@@ -146,7 +146,7 @@ fn get_calls_enum_type<'a>(
|
||||
|
||||
/// The specific values used for construction do not matter too much, we just need any OfflineClient
|
||||
/// to create unsigned extrinsics
|
||||
fn mocked_offline_client(metadata: Metadata) -> OfflineClient<SubstrateConfig> {
|
||||
fn mocked_offline_client(metadata: Metadata) -> OfflineClient<BizinikiwConfig> {
|
||||
let genesis_hash =
|
||||
H256::from_str("91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3")
|
||||
.expect("Valid hash; qed");
|
||||
@@ -154,7 +154,7 @@ fn mocked_offline_client(metadata: Metadata) -> OfflineClient<SubstrateConfig> {
|
||||
let runtime_version =
|
||||
pezkuwi_subxt::client::RuntimeVersion { spec_version: 9370, transaction_version: 20 };
|
||||
|
||||
OfflineClient::<SubstrateConfig>::new(genesis_hash, runtime_version, metadata)
|
||||
OfflineClient::<BizinikiwConfig>::new(genesis_hash, runtime_version, metadata)
|
||||
}
|
||||
|
||||
/// composites stay composites, all other types are converted into a 1-fielded unnamed composite
|
||||
|
||||
@@ -10,7 +10,7 @@ use frame_metadata::{RuntimeMetadata, RuntimeMetadataPrefixed};
|
||||
use pezkuwi_subxt_utils_stripmetadata::StripMetadata;
|
||||
use std::{io::Write, path::PathBuf};
|
||||
|
||||
/// Download metadata from a substrate node, for use with `subxt` codegen.
|
||||
/// Download metadata from a bizinikiwi node, for use with `subxt` codegen.
|
||||
#[derive(Debug, ClapParser)]
|
||||
pub struct Opts {
|
||||
#[command(flatten)]
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ mod utils;
|
||||
|
||||
use clap::Parser as ClapParser;
|
||||
|
||||
/// Subxt utilities for interacting with Substrate based nodes.
|
||||
/// Subxt utilities for interacting with Bizinikiwi based nodes.
|
||||
#[derive(Debug, ClapParser)]
|
||||
enum Command {
|
||||
Metadata(commands::metadata::Opts),
|
||||
|
||||
+6
-6
@@ -11,7 +11,7 @@ use heck::ToUpperCamelCase;
|
||||
use scale_info::PortableRegistry;
|
||||
use scale_typegen_description::{format_type_description, type_description};
|
||||
use std::{fmt::Display, fs, io::Read, path::PathBuf, str::FromStr};
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
use pezkuwi_subxt_utils_fetchmetadata::{self as fetch_metadata, MetadataVersion, Url};
|
||||
use scale_value::Value;
|
||||
@@ -19,7 +19,7 @@ use scale_value::Value;
|
||||
/// The source of the metadata.
|
||||
#[derive(Debug, Args, Clone)]
|
||||
pub struct FileOrUrl {
|
||||
/// The url of the substrate node to query for metadata for codegen.
|
||||
/// The url of the bizinikiwi node to query for metadata for codegen.
|
||||
#[clap(long, value_parser)]
|
||||
pub url: Option<Url>,
|
||||
/// The path to the encoded metadata file.
|
||||
@@ -219,10 +219,10 @@ impl<T: Display> Indent for T {}
|
||||
|
||||
pub async fn create_client(
|
||||
file_or_url: &FileOrUrl,
|
||||
) -> color_eyre::Result<OnlineClient<PolkadotConfig>> {
|
||||
) -> color_eyre::Result<OnlineClient<PezkuwiConfig>> {
|
||||
let client = match &file_or_url.url {
|
||||
Some(url) => OnlineClient::<PolkadotConfig>::from_url(url).await?,
|
||||
None => OnlineClient::<PolkadotConfig>::new().await?,
|
||||
Some(url) => OnlineClient::<PezkuwiConfig>::from_url(url).await?,
|
||||
None => OnlineClient::<PezkuwiConfig>::new().await?,
|
||||
};
|
||||
Ok(client)
|
||||
}
|
||||
@@ -368,7 +368,7 @@ mod tests {
|
||||
assert!(FileOrUrl::from_str("./src/i_dont_exist.rs").is_err());
|
||||
|
||||
assert!(matches!(
|
||||
FileOrUrl::from_str("https://github.com/paritytech/subxt"),
|
||||
FileOrUrl::from_str("https://github.com/pezkuwichain/subxt"),
|
||||
Ok(FileOrUrl { url: Some(_), file: None, version: None, at_block: None })
|
||||
));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! Generate code for submitting extrinsics and query storage of a Substrate runtime.
|
||||
//! Generate code for submitting extrinsics and query storage of a Bizinikiwi runtime.
|
||||
|
||||
mod calls;
|
||||
mod constants;
|
||||
@@ -35,7 +35,7 @@ use heck::{ToSnakeCase as _, ToUpperCamelCase};
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
|
||||
/// Create the API for interacting with a Substrate runtime.
|
||||
/// Create the API for interacting with a Bizinikiwi runtime.
|
||||
pub struct RuntimeGenerator {
|
||||
metadata: Metadata,
|
||||
}
|
||||
@@ -57,7 +57,7 @@ impl RuntimeGenerator {
|
||||
RuntimeGenerator { metadata }
|
||||
}
|
||||
|
||||
/// Generate the API for interacting with a Substrate runtime.
|
||||
/// Generate the API for interacting with a Bizinikiwi runtime.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
@@ -107,7 +107,7 @@ impl RuntimeGenerator {
|
||||
})
|
||||
}
|
||||
|
||||
/// Generate the API for interacting with a Substrate runtime.
|
||||
/// Generate the API for interacting with a Bizinikiwi runtime.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
@@ -218,8 +218,8 @@ impl RuntimeGenerator {
|
||||
)?;
|
||||
|
||||
// Fetch the paths of the outer enums.
|
||||
// Substrate exposes those under `kitchensink_runtime`, while Polkadot under
|
||||
// `polkadot_runtime`.
|
||||
// Bizinikiwi exposes those under `kitchensink_runtime`, while Pezkuwi under
|
||||
// `pezkuwi_runtime`.
|
||||
let call_path = type_gen
|
||||
.resolve_type_path(self.metadata.outer_enums().call_enum_ty())?
|
||||
.to_token_stream(type_gen.settings());
|
||||
|
||||
@@ -16,7 +16,7 @@ pub enum CodegenError {
|
||||
Decode(#[from] codec::Error),
|
||||
/// Out of line modules are not supported.
|
||||
#[error(
|
||||
"Out-of-line subxt modules are not supported, make sure you are providing a body to your module: pub mod polkadot {{ ... }}"
|
||||
"Out-of-line subxt modules are not supported, make sure you are providing a body to your module: pub mod pezkuwi {{ ... }}"
|
||||
)]
|
||||
InvalidModule(Span),
|
||||
/// Invalid type path.
|
||||
@@ -24,37 +24,37 @@ pub enum CodegenError {
|
||||
InvalidTypePath(String, syn::Error),
|
||||
/// Metadata for constant could not be found.
|
||||
#[error(
|
||||
"Metadata for constant entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||
"Metadata for constant entry {0}_{1} could not be found. Make sure you are providing a valid bizinikiwi-based metadata"
|
||||
)]
|
||||
MissingConstantMetadata(String, String),
|
||||
/// Metadata for storage could not be found.
|
||||
#[error(
|
||||
"Metadata for storage entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||
"Metadata for storage entry {0}_{1} could not be found. Make sure you are providing a valid bizinikiwi-based metadata"
|
||||
)]
|
||||
MissingStorageMetadata(String, String),
|
||||
/// Metadata for call could not be found.
|
||||
#[error(
|
||||
"Metadata for call entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||
"Metadata for call entry {0}_{1} could not be found. Make sure you are providing a valid bizinikiwi-based metadata"
|
||||
)]
|
||||
MissingCallMetadata(String, String),
|
||||
/// Metadata for call could not be found.
|
||||
#[error(
|
||||
"Metadata for runtime API entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||
"Metadata for runtime API entry {0}_{1} could not be found. Make sure you are providing a valid bizinikiwi-based metadata"
|
||||
)]
|
||||
MissingRuntimeApiMetadata(String, String),
|
||||
/// Call variant must have all named fields.
|
||||
#[error(
|
||||
"Call variant for type {0} must have all named fields. Make sure you are providing a valid substrate-based metadata"
|
||||
"Call variant for type {0} must have all named fields. Make sure you are providing a valid bizinikiwi-based metadata"
|
||||
)]
|
||||
InvalidCallVariant(u32),
|
||||
/// Type should be an variant/enum.
|
||||
#[error(
|
||||
"{0} type should be an variant/enum type. Make sure you are providing a valid substrate-based metadata"
|
||||
"{0} type should be an variant/enum type. Make sure you are providing a valid bizinikiwi-based metadata"
|
||||
)]
|
||||
InvalidType(String),
|
||||
/// Extrinsic call type could not be found.
|
||||
#[error(
|
||||
"Extrinsic call type could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||
"Extrinsic call type could not be found. Make sure you are providing a valid bizinikiwi-based metadata"
|
||||
)]
|
||||
MissingCallType,
|
||||
/// There are too many or too few hashers.
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! Generate a type safe Subxt interface for a Substrate runtime from its metadata.
|
||||
//! Generate a type safe Subxt interface for a Bizinikiwi runtime from its metadata.
|
||||
//! This is used by the `#[subxt]` macro and `subxt codegen` CLI command, but can also
|
||||
//! be used directly if preferable.
|
||||
|
||||
@@ -44,7 +44,7 @@ pub use syn;
|
||||
/// use pezkuwi_subxt_codegen::{ Metadata, CodegenBuilder };
|
||||
///
|
||||
/// // Get hold of and decode some metadata:
|
||||
/// let encoded = std::fs::read("../artifacts/polkadot_metadata_full.scale").unwrap();
|
||||
/// let encoded = std::fs::read("../artifacts/pezkuwi_metadata_full.scale").unwrap();
|
||||
/// let metadata = Metadata::decode(&mut &*encoded).unwrap();
|
||||
///
|
||||
/// // Generate a TokenStream representing the code for the interface.
|
||||
@@ -388,7 +388,7 @@ fn default_substitutes(crate_path: &syn::Path) -> TypeSubstitutes {
|
||||
// `EncodeAsType` the bytes would be re-encoded. This leads to the bytes
|
||||
// being altered by adding the length prefix in front of them.
|
||||
|
||||
// Note: Not sure if this is appropriate or not. The most recent polkadot.rs file does not
|
||||
// Note: Not sure if this is appropriate or not. The most recent pezkuwi.rs file does not
|
||||
// have these.
|
||||
(
|
||||
parse_quote!(pezsp_runtime::generic::unchecked_extrinsic::UncheckedExtrinsic),
|
||||
|
||||
@@ -336,7 +336,7 @@ pub struct FoundExtrinsic<T: Config, E> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::config::SubstrateConfig;
|
||||
use crate::config::BizinikiwConfig;
|
||||
use assert_matches::assert_matches;
|
||||
use codec::{Decode, Encode};
|
||||
use frame_metadata::{
|
||||
@@ -478,7 +478,7 @@ mod tests {
|
||||
let metadata = metadata();
|
||||
|
||||
// Decode with empty bytes.
|
||||
let result = Extrinsics::<SubstrateConfig>::decode_from(vec![vec![]], metadata);
|
||||
let result = Extrinsics::<BizinikiwConfig>::decode_from(vec![vec![]], metadata);
|
||||
assert_matches!(
|
||||
result.err(),
|
||||
Some(crate::error::ExtrinsicDecodeErrorAt { extrinsic_index: 0, error: _ })
|
||||
@@ -492,7 +492,7 @@ mod tests {
|
||||
let metadata = metadata();
|
||||
|
||||
// Decode with invalid version.
|
||||
let result = Extrinsics::<SubstrateConfig>::decode_from(vec![vec![3u8].encode()], metadata);
|
||||
let result = Extrinsics::<BizinikiwConfig>::decode_from(vec![vec![3u8].encode()], metadata);
|
||||
|
||||
assert_matches!(
|
||||
result.err(),
|
||||
@@ -508,7 +508,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tx_hashes_line_up() {
|
||||
let metadata = metadata();
|
||||
let hasher = <SubstrateConfig as Config>::Hasher::new(&metadata);
|
||||
let hasher = <BizinikiwConfig as Config>::Hasher::new(&metadata);
|
||||
|
||||
let tx = crate::dynamic::tx(
|
||||
"Test",
|
||||
@@ -517,11 +517,11 @@ mod tests {
|
||||
);
|
||||
|
||||
// Encoded TX ready to submit.
|
||||
let tx_encoded = crate::tx::create_v4_unsigned::<SubstrateConfig, _>(&tx, &metadata)
|
||||
let tx_encoded = crate::tx::create_v4_unsigned::<BizinikiwConfig, _>(&tx, &metadata)
|
||||
.expect("Valid dynamic parameters are provided");
|
||||
|
||||
// Extrinsic details ready to decode.
|
||||
let extrinsics = Extrinsics::<SubstrateConfig>::decode_from(
|
||||
let extrinsics = Extrinsics::<BizinikiwConfig>::decode_from(
|
||||
vec![tx_encoded.encoded().to_owned()],
|
||||
metadata,
|
||||
)
|
||||
@@ -544,13 +544,13 @@ mod tests {
|
||||
"TestCall",
|
||||
vec![Value::u128(10), Value::bool(true), Value::string("SomeValue")],
|
||||
);
|
||||
let tx_encoded = crate::tx::create_v4_unsigned::<SubstrateConfig, _>(&tx, &metadata)
|
||||
let tx_encoded = crate::tx::create_v4_unsigned::<BizinikiwConfig, _>(&tx, &metadata)
|
||||
.expect("Valid dynamic parameters are provided");
|
||||
|
||||
// Note: `create_unsigned` produces the extrinsic bytes by prefixing the extrinsic length.
|
||||
// The length is handled deserializing `ChainBlockExtrinsic`, therefore the first byte is
|
||||
// not needed.
|
||||
let extrinsics = Extrinsics::<SubstrateConfig>::decode_from(
|
||||
let extrinsics = Extrinsics::<BizinikiwConfig>::decode_from(
|
||||
vec![tx_encoded.encoded().to_owned()],
|
||||
metadata,
|
||||
)
|
||||
|
||||
@@ -16,18 +16,18 @@
|
||||
//! use pezkuwi_subxt_macro::subxt;
|
||||
//! use pezkuwi_subxt_core::blocks;
|
||||
//! use pezkuwi_subxt_core::Metadata;
|
||||
//! use pezkuwi_subxt_core::config::PolkadotConfig;
|
||||
//! use pezkuwi_subxt_core::config::PezkuwiConfig;
|
||||
//! use alloc::vec;
|
||||
//!
|
||||
//! // If we generate types without `subxt`, we need to point to `::pezkuwi_subxt_core`:
|
||||
//! #[subxt(
|
||||
//! crate = "::pezkuwi_subxt_core",
|
||||
//! runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale",
|
||||
//! runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale",
|
||||
//! )]
|
||||
//! pub mod polkadot {}
|
||||
//! pub mod pezkuwi {}
|
||||
//!
|
||||
//! // Some metadata we'd like to use to help us decode extrinsics:
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/polkadot_metadata_small.scale");
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/pezkuwi_metadata_small.scale");
|
||||
//! let metadata = Metadata::decode_from(&metadata_bytes[..]).unwrap();
|
||||
//!
|
||||
//! // Some extrinsics we'd like to decode:
|
||||
@@ -38,7 +38,7 @@
|
||||
//! ];
|
||||
//!
|
||||
//! // Given some chain config and metadata, we know how to decode the bytes.
|
||||
//! let exts = blocks::decode_from::<PolkadotConfig>(ext_bytes, metadata).unwrap();
|
||||
//! let exts = blocks::decode_from::<PezkuwiConfig>(ext_bytes, metadata).unwrap();
|
||||
//!
|
||||
//! // We'll see 3 extrinsics:
|
||||
//! assert_eq!(exts.len(), 3);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! Substrate specific configuration
|
||||
//! Bizinikiwi specific configuration
|
||||
|
||||
use super::{Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, Hasher, Header};
|
||||
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
@@ -12,31 +12,31 @@ use pezkuwi_subxt_metadata::Metadata;
|
||||
pub use primitive_types::{H256, U256};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Default set of commonly used types by Substrate runtimes.
|
||||
/// Default set of commonly used types by Bizinikiwi runtimes.
|
||||
// Note: We only use this at the type level, so it should be impossible to
|
||||
// create an instance of it.
|
||||
// The trait implementations exist just to make life easier,
|
||||
// but shouldn't strictly be necessary since users can't instantiate this type.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
|
||||
pub enum SubstrateConfig {}
|
||||
pub enum BizinikiwConfig {}
|
||||
|
||||
impl Config for SubstrateConfig {
|
||||
impl Config for BizinikiwConfig {
|
||||
type AccountId = AccountId32;
|
||||
type Address = MultiAddress<Self::AccountId, u32>;
|
||||
type Signature = MultiSignature;
|
||||
type Hasher = DynamicHasher256;
|
||||
type Header = SubstrateHeader<u32, DynamicHasher256>;
|
||||
type ExtrinsicParams = SubstrateExtrinsicParams<Self>;
|
||||
type Header = BizinikiwiHeader<u32, DynamicHasher256>;
|
||||
type ExtrinsicParams = BizinikiwiExtrinsicParams<Self>;
|
||||
type AssetId = u32;
|
||||
}
|
||||
|
||||
/// A struct representing the signed extra and additional parameters required
|
||||
/// to construct a transaction for the default substrate node.
|
||||
pub type SubstrateExtrinsicParams<T> = DefaultExtrinsicParams<T>;
|
||||
/// to construct a transaction for the default bizinikiwi node.
|
||||
pub type BizinikiwiExtrinsicParams<T> = DefaultExtrinsicParams<T>;
|
||||
|
||||
/// A builder which leads to [`SubstrateExtrinsicParams`] being constructed.
|
||||
/// A builder which leads to [`BizinikiwiExtrinsicParams`] being constructed.
|
||||
/// This is what you provide to methods like `sign_and_submit()`.
|
||||
pub type SubstrateExtrinsicParamsBuilder<T> = DefaultExtrinsicParamsBuilder<T>;
|
||||
pub type BizinikiwiExtrinsicParamsBuilder<T> = DefaultExtrinsicParamsBuilder<T>;
|
||||
|
||||
/// A hasher (ie implements [`Hasher`]) which hashes values using the blaks2_256 algorithm.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -105,11 +105,11 @@ impl Hasher for DynamicHasher256 {
|
||||
}
|
||||
}
|
||||
|
||||
/// A generic Substrate header type, adapted from `sp_runtime::generic::Header`.
|
||||
/// A generic Bizinikiwi header type, adapted from `sp_runtime::generic::Header`.
|
||||
/// The block number and hasher can be configured to adapt this for other nodes.
|
||||
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SubstrateHeader<N: Copy + Into<U256> + TryFrom<U256>, H: Hasher> {
|
||||
pub struct BizinikiwiHeader<N: Copy + Into<U256> + TryFrom<U256>, H: Hasher> {
|
||||
/// The parent hash.
|
||||
pub parent_hash: H::Output,
|
||||
/// The block number.
|
||||
@@ -124,11 +124,11 @@ pub struct SubstrateHeader<N: Copy + Into<U256> + TryFrom<U256>, H: Hasher> {
|
||||
pub digest: Digest,
|
||||
}
|
||||
|
||||
impl<N, H> Header for SubstrateHeader<N, H>
|
||||
impl<N, H> Header for BizinikiwiHeader<N, H>
|
||||
where
|
||||
N: Copy + Into<u64> + Into<U256> + TryFrom<U256> + Encode,
|
||||
H: Hasher,
|
||||
SubstrateHeader<N, H>: Encode + Decode,
|
||||
BizinikiwiHeader<N, H>: Encode + Decode,
|
||||
{
|
||||
type Number = N;
|
||||
type Hasher = H;
|
||||
@@ -365,12 +365,12 @@ mod test {
|
||||
}
|
||||
"#;
|
||||
|
||||
let header: SubstrateHeader<u32, BlakeTwo256> =
|
||||
let header: BizinikiwiHeader<u32, BlakeTwo256> =
|
||||
serde_json::from_str(numeric_block_number_json).expect("valid block header");
|
||||
assert_eq!(header.number(), 4);
|
||||
}
|
||||
|
||||
// Substrate returns hex block numbers; ensure we can also deserialize those OK.
|
||||
// Bizinikiwi returns hex block numbers; ensure we can also deserialize those OK.
|
||||
#[test]
|
||||
fn can_deserialize_hex_block_number() {
|
||||
let numeric_block_number_json = r#"
|
||||
@@ -385,7 +385,7 @@ mod test {
|
||||
}
|
||||
"#;
|
||||
|
||||
let header: SubstrateHeader<u32, BlakeTwo256> =
|
||||
let header: BizinikiwiHeader<u32, BlakeTwo256> =
|
||||
serde_json::from_str(numeric_block_number_json).expect("valid block header");
|
||||
assert_eq!(header.number(), 4);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn params_are_default() {
|
||||
let params = DefaultExtrinsicParamsBuilder::<crate::config::PolkadotConfig>::new().build();
|
||||
let params = DefaultExtrinsicParamsBuilder::<crate::config::PezkuwiConfig>::new().build();
|
||||
assert_default(params)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
|
||||
//! This module provides a [`Config`] type, which is used to define various
|
||||
//! types that are important in order to speak to a particular chain.
|
||||
//! [`SubstrateConfig`] provides a default set of these types suitable for the
|
||||
//! default Substrate node implementation, and [`PolkadotConfig`] for a
|
||||
//! Polkadot node.
|
||||
//! [`BizinikiwConfig`] provides a default set of these types suitable for the
|
||||
//! default Bizinikiwi node implementation, and [`PezkuwiConfig`] for a
|
||||
//! Pezkuwi node.
|
||||
|
||||
mod default_extrinsic_params;
|
||||
mod extrinsic_params;
|
||||
|
||||
pub mod polkadot;
|
||||
pub mod substrate;
|
||||
pub mod pezkuwi;
|
||||
pub mod bizinikiwi;
|
||||
pub mod transaction_extensions;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
@@ -24,8 +24,8 @@ use serde::{Serialize, de::DeserializeOwned};
|
||||
|
||||
pub use default_extrinsic_params::{DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
|
||||
pub use extrinsic_params::{ExtrinsicParams, ExtrinsicParamsEncoder};
|
||||
pub use polkadot::{PolkadotConfig, PolkadotExtrinsicParams, PolkadotExtrinsicParamsBuilder};
|
||||
pub use substrate::{SubstrateConfig, SubstrateExtrinsicParams, SubstrateExtrinsicParamsBuilder};
|
||||
pub use pezkuwi::{PezkuwiConfig, PezkuwiExtrinsicParams, PezkuwiExtrinsicParamsBuilder};
|
||||
pub use bizinikiwi::{BizinikiwConfig, BizinikiwiExtrinsicParams, BizinikiwiExtrinsicParamsBuilder};
|
||||
pub use transaction_extensions::TransactionExtension;
|
||||
|
||||
/// Runtime types.
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2019-2024 Parity Technologies (UK) Ltd.
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! Pezkuwi specific configuration
|
||||
|
||||
use super::{Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
|
||||
|
||||
use crate::config::BizinikiwConfig;
|
||||
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
pub use primitive_types::{H256, U256};
|
||||
|
||||
/// Default set of commonly used types by Pezkuwi nodes.
|
||||
// Note: The trait implementations exist just to make life easier,
|
||||
// but shouldn't strictly be necessary since users can't instantiate this type.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
|
||||
pub enum PezkuwiConfig {}
|
||||
|
||||
impl Config for PezkuwiConfig {
|
||||
type AccountId = <BizinikiwConfig as Config>::AccountId;
|
||||
type Signature = <BizinikiwConfig as Config>::Signature;
|
||||
type Hasher = <BizinikiwConfig as Config>::Hasher;
|
||||
type Header = <BizinikiwConfig as Config>::Header;
|
||||
type AssetId = <BizinikiwConfig as Config>::AssetId;
|
||||
|
||||
// Address on Pezkuwi has no account index, whereas it's u32 on
|
||||
// the default bizinikiwi dev node.
|
||||
type Address = MultiAddress<Self::AccountId, ()>;
|
||||
|
||||
// These are the same as the default bizinikiwi node, but redefined
|
||||
// because we need to pass the PezkuwiConfig trait as a param.
|
||||
type ExtrinsicParams = PezkuwiExtrinsicParams<Self>;
|
||||
}
|
||||
|
||||
/// A struct representing the signed extra and additional parameters required
|
||||
/// to construct a transaction for a pezkuwi node.
|
||||
pub type PezkuwiExtrinsicParams<T> = DefaultExtrinsicParams<T>;
|
||||
|
||||
/// A builder which leads to [`PezkuwiExtrinsicParams`] being constructed.
|
||||
/// This is what you provide to methods like `sign_and_submit()`.
|
||||
pub type PezkuwiExtrinsicParamsBuilder<T> = DefaultExtrinsicParamsBuilder<T>;
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright 2019-2024 Parity Technologies (UK) Ltd.
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! Polkadot specific configuration
|
||||
|
||||
use super::{Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
|
||||
|
||||
use crate::config::SubstrateConfig;
|
||||
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
pub use primitive_types::{H256, U256};
|
||||
|
||||
/// Default set of commonly used types by Polkadot nodes.
|
||||
// Note: The trait implementations exist just to make life easier,
|
||||
// but shouldn't strictly be necessary since users can't instantiate this type.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
|
||||
pub enum PolkadotConfig {}
|
||||
|
||||
impl Config for PolkadotConfig {
|
||||
type AccountId = <SubstrateConfig as Config>::AccountId;
|
||||
type Signature = <SubstrateConfig as Config>::Signature;
|
||||
type Hasher = <SubstrateConfig as Config>::Hasher;
|
||||
type Header = <SubstrateConfig as Config>::Header;
|
||||
type AssetId = <SubstrateConfig as Config>::AssetId;
|
||||
|
||||
// Address on Polkadot has no account index, whereas it's u32 on
|
||||
// the default substrate dev node.
|
||||
type Address = MultiAddress<Self::AccountId, ()>;
|
||||
|
||||
// These are the same as the default substrate node, but redefined
|
||||
// because we need to pass the PolkadotConfig trait as a param.
|
||||
type ExtrinsicParams = PolkadotExtrinsicParams<Self>;
|
||||
}
|
||||
|
||||
/// A struct representing the signed extra and additional parameters required
|
||||
/// to construct a transaction for a polkadot node.
|
||||
pub type PolkadotExtrinsicParams<T> = DefaultExtrinsicParams<T>;
|
||||
|
||||
/// A builder which leads to [`PolkadotExtrinsicParams`] being constructed.
|
||||
/// This is what you provide to methods like `sign_and_submit()`.
|
||||
pub type PolkadotExtrinsicParamsBuilder<T> = DefaultExtrinsicParamsBuilder<T>;
|
||||
@@ -96,7 +96,7 @@ impl<T: Config> TransactionExtension<T> for VerifySignature<T> {
|
||||
}
|
||||
|
||||
/// This allows a signature to be provided to the [`VerifySignature`] transaction extension.
|
||||
// Dev note: this must encode identically to https://github.com/paritytech/polkadot-sdk/blob/fd72d58313c297a10600037ce1bb88ec958d722e/substrate/frame/verify-signature/src/extension.rs#L43
|
||||
// Dev note: this must encode identically to https://github.com/pezkuwichain/pezkuwi-sdk/blob/fd72d58313c297a10600037ce1bb88ec958d722e/bizinikiwi/frame/verify-signature/src/extension.rs#L43
|
||||
#[derive(codec::Encode, codec::Decode)]
|
||||
pub enum VerifySignatureDetails<T: Config> {
|
||||
/// A signature has been provided.
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
//! // If we generate types without `subxt`, we need to point to `::pezkuwi_subxt_core`:
|
||||
//! #[subxt(
|
||||
//! crate = "::pezkuwi_subxt_core",
|
||||
//! runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale",
|
||||
//! runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale",
|
||||
//! )]
|
||||
//! pub mod polkadot {}
|
||||
//! pub mod pezkuwi {}
|
||||
//!
|
||||
//! // Some metadata we'd like to access constants in:
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/polkadot_metadata_small.scale");
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/pezkuwi_metadata_small.scale");
|
||||
//! let metadata = Metadata::decode_from(&metadata_bytes[..]).unwrap();
|
||||
//!
|
||||
//! // We can use a static address to obtain some constant:
|
||||
//! let address = polkadot::constants().balances().existential_deposit();
|
||||
//! let address = pezkuwi::constants().balances().existential_deposit();
|
||||
//!
|
||||
//! // This validates that the address given is in line with the metadata
|
||||
//! // we're trying to access the constant in:
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
//! // If we generate types without `subxt`, we need to point to `::pezkuwi_subxt_core`:
|
||||
//! #[subxt(
|
||||
//! crate = "::pezkuwi_subxt_core",
|
||||
//! runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale",
|
||||
//! runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale",
|
||||
//! )]
|
||||
//! pub mod polkadot {}
|
||||
//! pub mod pezkuwi {}
|
||||
//!
|
||||
//! // Some metadata we'd like to access custom values in:
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/polkadot_metadata_small.scale");
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/pezkuwi_metadata_small.scale");
|
||||
//! let metadata = Metadata::decode_from(&metadata_bytes[..]).unwrap();
|
||||
//!
|
||||
//! // At the moment, we don't expect to see any custom values in the metadata
|
||||
//! // for Polkadot, so this will return an error:
|
||||
//! // for Pezkuwi, so this will return an error:
|
||||
//! let err = custom_values::get("Foo", &metadata);
|
||||
//! ```
|
||||
|
||||
|
||||
+12
-12
@@ -8,7 +8,7 @@
|
||||
//!
|
||||
//! ```rust
|
||||
//! use pezkuwi_subxt_macro::subxt;
|
||||
//! use pezkuwi_subxt_core::config::PolkadotConfig;
|
||||
//! use pezkuwi_subxt_core::config::PezkuwiConfig;
|
||||
//! use pezkuwi_subxt_core::events;
|
||||
//! use pezkuwi_subxt_core::Metadata;
|
||||
//! use pezkuwi_subxt_core::dynamic::Value;
|
||||
@@ -16,19 +16,19 @@
|
||||
//! // If we generate types without `subxt`, we need to point to `::pezkuwi_subxt_core`:
|
||||
//! #[subxt(
|
||||
//! crate = "::pezkuwi_subxt_core",
|
||||
//! runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
//! runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
//! )]
|
||||
//! pub mod polkadot {}
|
||||
//! pub mod pezkuwi {}
|
||||
//!
|
||||
//! // Some metadata we'll use to work with storage entries:
|
||||
//! let metadata_bytes = include_bytes!("../../artifacts/polkadot_metadata_full.scale");
|
||||
//! let metadata_bytes = include_bytes!("../../artifacts/pezkuwi_metadata_full.scale");
|
||||
//! let metadata = Metadata::decode_from(&metadata_bytes[..]).unwrap();
|
||||
//!
|
||||
//! // Some bytes representing events (located in System.Events storage):
|
||||
//! let event_bytes = hex::decode("1c00000000000000a2e9b53d5517020000000100000000000310c96d901d0102000000020000000408d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27dbeea5a030000000000000000000000000000020000000402d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48102700000000000000000000000000000000020000000407be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25fbeea5a030000000000000000000000000000020000002100d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27dbeea5a03000000000000000000000000000000000000000000000000000000000000020000000000426df03e00000000").unwrap();
|
||||
//!
|
||||
//! // We can decode these bytes like so:
|
||||
//! let evs = events::decode_from::<PolkadotConfig>(event_bytes, metadata);
|
||||
//! let evs = events::decode_from::<PezkuwiConfig>(event_bytes, metadata);
|
||||
//!
|
||||
//! // And then do things like iterate over them and inspect details:
|
||||
//! for ev in evs.iter() {
|
||||
@@ -461,7 +461,7 @@ pub struct EventMetadataDetails<'a> {
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test_utils {
|
||||
use super::*;
|
||||
use crate::config::{HashFor, SubstrateConfig};
|
||||
use crate::config::{HashFor, BizinikiwConfig};
|
||||
use codec::Encode;
|
||||
use frame_metadata::{
|
||||
RuntimeMetadataPrefixed,
|
||||
@@ -494,12 +494,12 @@ pub(crate) mod test_utils {
|
||||
pub struct EventRecord<E: Encode> {
|
||||
phase: Phase,
|
||||
event: AllEvents<E>,
|
||||
topics: Vec<HashFor<SubstrateConfig>>,
|
||||
topics: Vec<HashFor<BizinikiwConfig>>,
|
||||
}
|
||||
|
||||
impl<E: Encode> EventRecord<E> {
|
||||
/// Create a new event record with the given phase, event, and topics.
|
||||
pub fn new(phase: Phase, event: E, topics: Vec<HashFor<SubstrateConfig>>) -> Self {
|
||||
pub fn new(phase: Phase, event: E, topics: Vec<HashFor<BizinikiwConfig>>) -> Self {
|
||||
Self { phase, event: AllEvents::Test(event), topics }
|
||||
}
|
||||
}
|
||||
@@ -580,7 +580,7 @@ pub(crate) mod test_utils {
|
||||
pub fn events<E: Decode + Encode>(
|
||||
metadata: Metadata,
|
||||
event_records: Vec<EventRecord<E>>,
|
||||
) -> Events<SubstrateConfig> {
|
||||
) -> Events<BizinikiwConfig> {
|
||||
let num_events = event_records.len() as u32;
|
||||
let mut event_bytes = Vec::new();
|
||||
for ev in event_records {
|
||||
@@ -595,7 +595,7 @@ pub(crate) mod test_utils {
|
||||
metadata: Metadata,
|
||||
event_bytes: Vec<u8>,
|
||||
num_events: u32,
|
||||
) -> Events<SubstrateConfig> {
|
||||
) -> Events<BizinikiwConfig> {
|
||||
// Prepend compact encoded length to event bytes:
|
||||
let mut all_event_bytes = Compact(num_events).encode();
|
||||
all_event_bytes.extend(event_bytes);
|
||||
@@ -609,7 +609,7 @@ mod tests {
|
||||
test_utils::{AllEvents, EventRecord, event_record, events, events_raw},
|
||||
*,
|
||||
};
|
||||
use crate::{config::SubstrateConfig, events::Phase};
|
||||
use crate::{config::BizinikiwConfig, events::Phase};
|
||||
use codec::Encode;
|
||||
use primitive_types::H256;
|
||||
use scale_info::TypeInfo;
|
||||
@@ -637,7 +637,7 @@ mod tests {
|
||||
/// Compare some actual [`RawEventDetails`] with a hand-constructed
|
||||
/// (probably) [`TestRawEventDetails`].
|
||||
pub fn assert_raw_events_match(
|
||||
actual: EventDetails<SubstrateConfig>,
|
||||
actual: EventDetails<BizinikiwConfig>,
|
||||
expected: TestRawEventDetails,
|
||||
) {
|
||||
let actual_fields_no_context: Vec<_> = actual
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
//! // If we generate types without `subxt`, we need to point to `::pezkuwi_subxt_core`:
|
||||
//! #[subxt(
|
||||
//! crate = "::pezkuwi_subxt_core",
|
||||
//! runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale",
|
||||
//! runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale",
|
||||
//! )]
|
||||
//! pub mod polkadot {}
|
||||
//! pub mod pezkuwi {}
|
||||
//!
|
||||
//! // Some metadata we'll use to work with storage entries:
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/polkadot_metadata_small.scale");
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/pezkuwi_metadata_small.scale");
|
||||
//! let metadata = Metadata::decode_from(&metadata_bytes[..]).unwrap();
|
||||
//!
|
||||
//! // Build a storage query to access account information.
|
||||
//! let payload = polkadot::apis().metadata().metadata_versions();
|
||||
//! let payload = pezkuwi::apis().metadata().metadata_versions();
|
||||
//!
|
||||
//! // We can validate that the payload is compatible with the given metadata.
|
||||
//! runtime_api::validate(&payload, &metadata).unwrap();
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
//! // If we generate types without `subxt`, we need to point to `::pezkuwi_subxt_core`:
|
||||
//! #[subxt(
|
||||
//! crate = "::pezkuwi_subxt_core",
|
||||
//! runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale",
|
||||
//! runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale",
|
||||
//! )]
|
||||
//! pub mod polkadot {}
|
||||
//! pub mod pezkuwi {}
|
||||
//!
|
||||
//! // Some metadata we'll use to work with storage entries:
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/polkadot_metadata_small.scale");
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/pezkuwi_metadata_small.scale");
|
||||
//! let metadata = Metadata::decode_from(&metadata_bytes[..]).unwrap();
|
||||
//!
|
||||
//! // Build a storage query to access account information.
|
||||
//! let address = polkadot::storage().system().account();
|
||||
//! let address = pezkuwi::storage().system().account();
|
||||
//!
|
||||
//! // We can validate that the address is compatible with the given metadata.
|
||||
//! storage::validate(&address, &metadata).unwrap();
|
||||
|
||||
+6
-6
@@ -9,7 +9,7 @@
|
||||
//! ```rust
|
||||
//! use pezkuwi_subxt_signer::sr25519::dev;
|
||||
//! use pezkuwi_subxt_macro::subxt;
|
||||
//! use pezkuwi_subxt_core::config::{PolkadotConfig, HashFor};
|
||||
//! use pezkuwi_subxt_core::config::{PezkuwiConfig, HashFor};
|
||||
//! use pezkuwi_subxt_core::config::DefaultExtrinsicParamsBuilder as Params;
|
||||
//! use pezkuwi_subxt_core::tx;
|
||||
//! use pezkuwi_subxt_core::utils::H256;
|
||||
@@ -18,14 +18,14 @@
|
||||
//! // If we generate types without `subxt`, we need to point to `::pezkuwi_subxt_core`:
|
||||
//! #[subxt(
|
||||
//! crate = "::pezkuwi_subxt_core",
|
||||
//! runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale",
|
||||
//! runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale",
|
||||
//! )]
|
||||
//! pub mod polkadot {}
|
||||
//! pub mod pezkuwi {}
|
||||
//!
|
||||
//! // Gather some other information about the chain that we'll need to construct valid extrinsics:
|
||||
//! let state = tx::ClientState::<PolkadotConfig> {
|
||||
//! let state = tx::ClientState::<PezkuwiConfig> {
|
||||
//! metadata: {
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/polkadot_metadata_small.scale");
|
||||
//! let metadata_bytes = include_bytes!("../../../artifacts/pezkuwi_metadata_small.scale");
|
||||
//! Metadata::decode_from(&metadata_bytes[..]).unwrap()
|
||||
//! },
|
||||
//! genesis_hash: {
|
||||
@@ -41,7 +41,7 @@
|
||||
//!
|
||||
//! // Now we can build a balance transfer extrinsic.
|
||||
//! let dest = dev::bob().public_key().into();
|
||||
//! let call = polkadot::tx().balances().transfer_allow_death(dest, 10_000);
|
||||
//! let call = pezkuwi::tx().balances().transfer_allow_death(dest, 10_000);
|
||||
//! let params = Params::new().tip(1_000).nonce(0).build();
|
||||
//!
|
||||
//! // We can validate that this lines up with the given metadata:
|
||||
|
||||
@@ -222,7 +222,7 @@ mod tests {
|
||||
use scale_value::Composite;
|
||||
|
||||
fn test_metadata() -> Metadata {
|
||||
let metadata_bytes = include_bytes!("../../../artifacts/polkadot_metadata_small.scale");
|
||||
let metadata_bytes = include_bytes!("../../../artifacts/pezkuwi_metadata_small.scale");
|
||||
Metadata::decode(&mut &metadata_bytes[..]).expect("Valid metadata")
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! A library to **sub**mit e**xt**rinsics to a
|
||||
//! [substrate](https://github.com/paritytech/substrate) node via RPC.
|
||||
//! [bizinikiwi](https://github.com/pezkuwichain/bizinikiwi) node via RPC.
|
||||
|
||||
use crate::Config;
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! The "default" Substrate/Polkadot AccountId. This is used in codegen, as well as signing related
|
||||
//! The "default" Bizinikiwi/Pezkuwi AccountId. This is used in codegen, as well as signing related
|
||||
//! bits. This doesn't contain much functionality itself, but is easy to convert to/from an
|
||||
//! `sp_core::AccountId32` for instance, to gain functionality without forcing a dependency on
|
||||
//! Substrate crates here.
|
||||
//! Bizinikiwi crates here.
|
||||
|
||||
use alloc::{format, string::String, vec, vec::Vec};
|
||||
use codec::{Decode, Encode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error as DeriveError;
|
||||
|
||||
/// A 32-byte cryptographic identifier. This is a simplified version of Substrate's
|
||||
/// A 32-byte cryptographic identifier. This is a simplified version of Bizinikiwi's
|
||||
/// `sp_core::crypto::AccountId32`. To obtain more functionality, convert this into
|
||||
/// that type.
|
||||
#[derive(
|
||||
@@ -52,7 +52,7 @@ impl AccountId32 {
|
||||
// Return the ss58-check string for this key. Adapted from `sp_core::crypto`. We need this to
|
||||
// serialize our account appropriately but otherwise don't care.
|
||||
fn to_ss58check(&self) -> String {
|
||||
// For serializing to a string to obtain the account nonce, we use the default substrate
|
||||
// For serializing to a string to obtain the account nonce, we use the default bizinikiwi
|
||||
// prefix (since we have no way to otherwise pick one). It doesn't really matter, since when
|
||||
// it's deserialized back in system_accountNextIndex, we ignore this (so long as it's
|
||||
// valid).
|
||||
@@ -166,23 +166,23 @@ mod test {
|
||||
use sp_keyring::sr25519::Keyring;
|
||||
|
||||
#[test]
|
||||
fn ss58_is_compatible_with_substrate_impl() {
|
||||
fn ss58_is_compatible_with_bizinikiwi_impl() {
|
||||
let keyrings = vec![Keyring::Alice, Keyring::Bob, Keyring::Charlie];
|
||||
|
||||
for keyring in keyrings {
|
||||
let substrate_account = keyring.to_account_id();
|
||||
let local_account = AccountId32(substrate_account.clone().into());
|
||||
let bizinikiwi_account = keyring.to_account_id();
|
||||
let local_account = AccountId32(bizinikiwi_account.clone().into());
|
||||
|
||||
// Both should encode to ss58 the same way:
|
||||
let substrate_ss58 = substrate_account.to_ss58check();
|
||||
assert_eq!(substrate_ss58, local_account.to_ss58check());
|
||||
let bizinikiwi_ss58 = bizinikiwi_account.to_ss58check();
|
||||
assert_eq!(bizinikiwi_ss58, local_account.to_ss58check());
|
||||
|
||||
// Both should decode from ss58 back to the same:
|
||||
assert_eq!(
|
||||
sp_core::crypto::AccountId32::from_ss58check(&substrate_ss58).unwrap(),
|
||||
substrate_account
|
||||
sp_core::crypto::AccountId32::from_ss58check(&bizinikiwi_ss58).unwrap(),
|
||||
bizinikiwi_account
|
||||
);
|
||||
assert_eq!(AccountId32::from_ss58check(&substrate_ss58).unwrap(), local_account);
|
||||
assert_eq!(AccountId32::from_ss58check(&bizinikiwi_ss58).unwrap(), local_account);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! The "default" Substrate/Polkadot Address type. This is used in codegen, as well as signing
|
||||
//! The "default" Bizinikiwi/Pezkuwi Address type. This is used in codegen, as well as signing
|
||||
//! related bits. This doesn't contain much functionality itself, but is easy to convert to/from an
|
||||
//! `sp_runtime::MultiAddress` for instance, to gain functionality without forcing a dependency on
|
||||
//! Substrate crates here.
|
||||
//! Bizinikiwi crates here.
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
/// A multi-format address wrapper for on-chain accounts. This is a simplified version of
|
||||
/// Substrate's `sp_runtime::MultiAddress`.
|
||||
/// Bizinikiwi's `sp_runtime::MultiAddress`.
|
||||
#[derive(
|
||||
Clone,
|
||||
Eq,
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! The "default" Substrate/Polkadot Signature type. This is used in codegen, as well as signing
|
||||
//! The "default" Bizinikiwi/Pezkuwi Signature type. This is used in codegen, as well as signing
|
||||
//! related bits. This doesn't contain much functionality itself, but is easy to convert to/from an
|
||||
//! `sp_runtime::MultiSignature` for instance, to gain functionality without forcing a dependency on
|
||||
//! Substrate crates here.
|
||||
//! Bizinikiwi crates here.
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! The "default" Substrate/Polkadot UncheckedExtrinsic.
|
||||
//! The "default" Bizinikiwi/Pezkuwi UncheckedExtrinsic.
|
||||
//! This is used in codegen for runtime API calls.
|
||||
//!
|
||||
//! The inner bytes represent the encoded extrinsic expected by the
|
||||
@@ -17,7 +17,7 @@ use scale_decode::{DecodeAsType, IntoVisitor, TypeResolver, Visitor, visitor::De
|
||||
use super::{Encoded, Static};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
/// The unchecked extrinsic from substrate.
|
||||
/// The unchecked extrinsic from bizinikiwi.
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Encode)]
|
||||
pub struct UncheckedExtrinsic<Address, Call, Signature, Extra>(
|
||||
Static<Encoded>,
|
||||
|
||||
@@ -15,7 +15,7 @@ use alloc::{format, vec::Vec};
|
||||
/// access the real type `T` [`Self::try_decode`] needs to be used.
|
||||
// Dev notes:
|
||||
//
|
||||
// - This is adapted from [here](https://github.com/paritytech/substrate/blob/master/frame/support/src/traits/misc.rs).
|
||||
// - This is adapted from [here](https://github.com/pezkuwichain/bizinikiwi/blob/master/frame/support/src/traits/misc.rs).
|
||||
// - The encoded bytes will be a compact encoded length followed by that number of bytes.
|
||||
// - However, the TypeInfo describes the type as a composite with first a compact encoded length and
|
||||
// next the type itself.
|
||||
@@ -153,7 +153,7 @@ mod test {
|
||||
|
||||
use super::*;
|
||||
|
||||
// Copied from https://github.com/paritytech/substrate/blob/master/frame/support/src/traits/misc.rs
|
||||
// Copied from https://github.com/pezkuwichain/bizinikiwi/blob/master/frame/support/src/traits/misc.rs
|
||||
// and used for tests to check that we can work with the expected TypeInfo without needing to
|
||||
// import the frame_support crate, which has quite a lot of dependencies.
|
||||
impl<T: scale_info::TypeInfo + 'static> scale_info::TypeInfo for WrapperKeepOpaque<T> {
|
||||
|
||||
@@ -4,7 +4,7 @@ This example shows how to expose a small piece of Subxt functionality, in our ca
|
||||
|
||||
## Overview
|
||||
|
||||
- We want to let non-Rust clients interact with any Substrate-based node (Polkadot in this example) via a tiny FFI layer.
|
||||
- We want to let non-Rust clients interact with any Bizinikiwi-based node (Pezkuwi in this example) via a tiny FFI layer.
|
||||
- Instead of exposing Subxt’s full, Rust-centric API, we build a thin **facade crate** that:
|
||||
1. Calls Subxt under the hood
|
||||
2. Exposes just the functions we need via `pub extern "C" fn …`
|
||||
@@ -15,7 +15,7 @@ flowchart LR
|
||||
subgraph Rust side
|
||||
subxt[Subxt Public API]
|
||||
facade[Facade crate]
|
||||
node[Substrate node]
|
||||
node[Bizinikiwi node]
|
||||
cabi[C ABI library]
|
||||
subxt --> facade
|
||||
facade --> node
|
||||
@@ -46,14 +46,14 @@ which does a single balance transfer and returns 0 on success, –1 on error.
|
||||
- Rust toolchain (with cargo)
|
||||
- Python 3
|
||||
- Node.js (for the JS example. Version 19 worked on my M2 Mac, but version 22 did not, so YMMV).
|
||||
- A running Substrate node (Polkadot) on ws://127.0.0.1:8000. One can use Chopsticks for a quick local Polkadot node:
|
||||
- A running Bizinikiwi node (Pezkuwi) on ws://127.0.0.1:8000. One can use Chopsticks for a quick local Pezkuwi node:
|
||||
|
||||
```shell
|
||||
npx @acala-network/chopsticks \
|
||||
--config=https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/polkadot.yml
|
||||
--config=https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/pezkuwi.yml
|
||||
```
|
||||
|
||||
Or, if you have a `substrate-node` binary, just run `substrate-node --dev --rpc-port 8000`.
|
||||
Or, if you have a `bizinikiwi-node` binary, just run `bizinikiwi-node --dev --rpc-port 8000`.
|
||||
- In our Python and Javascript files, we introduce a **dest** variable that represents the destination account for the transfer, we gave it a hard coded value (Bob's account public key) from the running Chopsticks node. Feel free to change it to any other account, or better yet, make it generic!
|
||||
|
||||
If you run into any issues running the Node version, I found that I needed to run `brew install python-setuptools` too.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use hex::decode;
|
||||
use std::{ffi::CStr, os::raw::c_char, sync::OnceLock};
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig, dynamic::Value, ext::scale_value::Composite, tx};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig, dynamic::Value, ext::scale_value::Composite, tx};
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
@@ -35,7 +35,7 @@ pub extern "C" fn do_transfer(dest_hex: *const c_char, amount: u64) -> i32 {
|
||||
|
||||
// Spin up (or reuse) our Tokio runtime and connect:
|
||||
let client = tokio_rt().block_on(async {
|
||||
OnlineClient::<PolkadotConfig>::from_url("ws://127.0.0.1:8000")
|
||||
OnlineClient::<PezkuwiConfig>::from_url("ws://127.0.0.1:8000")
|
||||
.await
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
@@ -7,40 +7,40 @@ This example showcases working with Subxt and Zombienet to try out connecting to
|
||||
|
||||
### 1. Install `zombienet`
|
||||
|
||||
[Zombienet](https://github.com/paritytech/zombienet) is a tool for quickly spinning up a (local) blockchain
|
||||
[Zombienet](https://github.com/pezkuwichain/zombienet) is a tool for quickly spinning up a (local) blockchain
|
||||
network. We will use it to start up a local Asset Hub for us.
|
||||
|
||||
Please follow the install guide in the [zombienet github repo](https://github.com/paritytech/zombienet) to
|
||||
Please follow the install guide in the [zombienet github repo](https://github.com/pezkuwichain/zombienet) to
|
||||
install it.
|
||||
|
||||
### 2. `polkadot`
|
||||
### 2. `pezkuwi`
|
||||
|
||||
We need a relay chain. Build the polkadot binary from the [polkadot github repo](https://github.com/paritytech/polkadot)
|
||||
We need a relay chain. Build the pezkuwi binary from the [pezkuwi github repo](https://github.com/pezkuwichain/pezkuwi)
|
||||
and install it in your path:
|
||||
|
||||
```txt
|
||||
git clone https://github.com/paritytech/polkadot.git
|
||||
cd polkadot
|
||||
git clone https://github.com/pezkuwichain/pezkuwi.git
|
||||
cd pezkuwi
|
||||
cargo install --path .
|
||||
```
|
||||
|
||||
### 3. `polkadot-parachain`
|
||||
### 3. `pezkuwi-parachain`
|
||||
|
||||
The Asset Hub is part of the [cumulus github repo](https://github.com/paritytech/cumulus), an SDK for developing
|
||||
parachains. Building the cumulus workspace produces a binary called `polkadot-parachain` which can be used to run
|
||||
The Asset Hub is part of the [pezcumulus github repo](https://github.com/pezkuwichain/pezcumulus), an SDK for developing
|
||||
parachains. Building the pezcumulus workspace produces a binary called `pezkuwi-parachain` which can be used to run
|
||||
Asset Hub nodes.
|
||||
|
||||
```txt
|
||||
git clone https://github.com/paritytech/cumulus.git
|
||||
cd cumulus
|
||||
cargo install --path polkadot-parachain
|
||||
git clone https://github.com/pezkuwichain/pezcumulus.git
|
||||
cd pezcumulus
|
||||
cargo install --path pezkuwi-parachain
|
||||
```
|
||||
|
||||
### 4. Run the parachain locally
|
||||
|
||||
With these binaries installed, Zombienet can now get the parachain running locally from a configuration file, `asset-hub-zombienet.toml`
|
||||
in this case. We need to have at least 2 validator nodes running via the `polkadot` binary, and an Asset Hub node running via the
|
||||
`polkadot-parachain` binary. Zombienet starts these up, and gets the parachain registered with the validator nodes for us. To do that,
|
||||
in this case. We need to have at least 2 validator nodes running via the `pezkuwi` binary, and an Asset Hub node running via the
|
||||
`pezkuwi-parachain` binary. Zombienet starts these up, and gets the parachain registered with the validator nodes for us. To do that,
|
||||
run:
|
||||
|
||||
```txt
|
||||
@@ -49,8 +49,8 @@ zombienet -p native spawn asset-hub-zombienet.toml
|
||||
|
||||
Zombienet uses Kubernetes by default, but we can use it without Kubernetes by providing the `-p native` flag.
|
||||
|
||||
You might have noticed that we use `chain = "rococo-local"` in the `asset-hub-zombienet.toml` file for the relay chain. This is just to
|
||||
make the epoch time shorter and should have no effect on your interactions with the parachain. Polkadot / Kusama / Rococo have different
|
||||
You might have noticed that we use `chain = "pezkuwichain-local"` in the `asset-hub-zombienet.toml` file for the relay chain. This is just to
|
||||
make the epoch time shorter and should have no effect on your interactions with the parachain. Pezkuwi / Kusama / Pezkuwichain have different
|
||||
epoch times of `24h` / `2h` / `2min` respectively.
|
||||
|
||||
### 5. Run the example
|
||||
@@ -69,10 +69,10 @@ To run our example code.
|
||||
We can obtain the metadata for Statemint via the [subxt cli](https://crates.io/crates/subxt-cli) tool, like so:
|
||||
|
||||
```txt
|
||||
subxt metadata --url wss://polkadot-asset-hub-rpc.polkadot.io:443 > statemint_metadata.scale
|
||||
subxt metadata --url wss://pezkuwi-asset-hub-rpc.pezkuwi.io:443 > statemint_metadata.scale
|
||||
```
|
||||
|
||||
It is important to explicitly specify the port as `443`.
|
||||
|
||||
One way to find a suitable URL to obtain this from is by looking through the sidebar on [Polkadot.js](https://polkadot.js.org/apps/)
|
||||
One way to find a suitable URL to obtain this from is by looking through the sidebar on [Pezkuwi.js](https://pezkuwi.js.org/apps/)
|
||||
to find the Asset Hub entry, and seeing which RPC node URLs it uses.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[relaychain]
|
||||
default_image = "docker.io/parity/polkadot:latest"
|
||||
default_command = "polkadot"
|
||||
default_image = "docker.io/parity/pezkuwi:latest"
|
||||
default_command = "pezkuwi"
|
||||
default_args = ["-lparachain=debug"]
|
||||
|
||||
chain = "rococo-local"
|
||||
chain = "pezkuwichain-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
@@ -15,11 +15,11 @@ validator = true
|
||||
|
||||
[[parachains]]
|
||||
id = 100
|
||||
chain = "asset-hub-polkadot-local"
|
||||
chain = "asset-hub-pezkuwi-local"
|
||||
|
||||
[parachains.collator]
|
||||
name = "collator01"
|
||||
image = "docker.io/parity/polkadot-parachain:latest"
|
||||
image = "docker.io/parity/pezkuwi-parachain:latest"
|
||||
ws_port = 42069
|
||||
command = "polkadot-parachain"
|
||||
command = "pezkuwi-parachain"
|
||||
args = ["-lparachain=debug"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use pezkuwi_subxt::{
|
||||
PolkadotConfig,
|
||||
PezkuwiConfig,
|
||||
utils::{AccountId32, MultiAddress},
|
||||
OnlineClient,
|
||||
};
|
||||
@@ -8,9 +8,9 @@ use pezkuwi_subxt_signer::sr25519::dev::{self};
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "statemint_metadata.scale")]
|
||||
pub mod statemint {}
|
||||
|
||||
// PolkadotConfig or SubstrateConfig will suffice for this example at the moment,
|
||||
// but PolkadotConfig is a little more correct, having the right `Address` type.
|
||||
type StatemintConfig = PolkadotConfig;
|
||||
// PezkuwiConfig or BizinikiwConfig will suffice for this example at the moment,
|
||||
// but PezkuwiConfig is a little more correct, having the right `Address` type.
|
||||
type StatemintConfig = PezkuwiConfig;
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn main() {
|
||||
|
||||
@@ -8,11 +8,11 @@ To run the app locally we first install Trunk, a WASM bundler:
|
||||
cargo install --locked trunk
|
||||
```
|
||||
|
||||
You need to have a local polkadot/substrate node with it's JSON-RPC HTTP server running at 127.0.0.1:9933 in order for the examples to be working.
|
||||
If you have a `polkadot` binary already, running this should be sufficient:
|
||||
You need to have a local pezkuwi/bizinikiwi node with it's JSON-RPC HTTP server running at 127.0.0.1:9933 in order for the examples to be working.
|
||||
If you have a `pezkuwi` binary already, running this should be sufficient:
|
||||
|
||||
```
|
||||
polkadot --dev
|
||||
pezkuwi --dev
|
||||
```
|
||||
|
||||
Then, in another terminal, run the app locally with:
|
||||
@@ -23,4 +23,4 @@ trunk serve --open
|
||||
|
||||
# signing example
|
||||
|
||||
For the signing example, we use the `@polkadot/extension-dapp` NPM package to talk to wallets loaded as browser extensions. In order to sign and submit the transaction using the `polkadot --dev` node we spawned above, you'll need to create a dev account in your wallet of choice. Use the recovery phrase `bottom drive obey lake curtain smoke basket hold race lonely fit walk` and the derivation path `//Alice` to create a dev account that can be used.
|
||||
For the signing example, we use the `@pezkuwi/extension-dapp` NPM package to talk to wallets loaded as browser extensions. In order to sign and submit the transaction using the `pezkuwi --dev` node we spawned above, you'll need to create a dev account in your wallet of choice. Use the recovery phrase `bottom drive obey lake curtain smoke basket hold race lonely fit walk` and the derivation path `//Alice` to create a dev account that can be used.
|
||||
@@ -1,7 +1,7 @@
|
||||
use anyhow::anyhow;
|
||||
use futures::FutureExt;
|
||||
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
use pezkuwi_subxt::config::DefaultExtrinsicParamsBuilder;
|
||||
use pezkuwi_subxt::ext::codec::{Decode, Encode};
|
||||
@@ -9,14 +9,14 @@ use pezkuwi_subxt::tx::Payload as _;
|
||||
use pezkuwi_subxt::tx::SubmittableTransaction;
|
||||
use pezkuwi_subxt::utils::{AccountId32, MultiSignature};
|
||||
|
||||
use crate::services::{extension_signature_for_extrinsic, get_accounts, polkadot, Account};
|
||||
use crate::services::{extension_signature_for_extrinsic, get_accounts, pezkuwi, Account};
|
||||
use web_sys::HtmlInputElement;
|
||||
use yew::prelude::*;
|
||||
|
||||
pub struct SigningExamplesComponent {
|
||||
message: String,
|
||||
remark_call_bytes: Vec<u8>,
|
||||
online_client: Option<OnlineClient<PolkadotConfig>>,
|
||||
online_client: Option<OnlineClient<PezkuwiConfig>>,
|
||||
stage: SigningStage,
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ impl SigningExamplesComponent {
|
||||
/// # Panics
|
||||
/// panics if self.online_client is None.
|
||||
fn set_message(&mut self, message: String) {
|
||||
let remark_call = polkadot::tx().system().remark(message.as_bytes().to_vec());
|
||||
let remark_call = pezkuwi::tx().system().remark(message.as_bytes().to_vec());
|
||||
let online_client = self.online_client.as_ref().unwrap();
|
||||
let remark_call_bytes = remark_call
|
||||
.encode_call_data(&online_client.metadata())
|
||||
@@ -51,18 +51,18 @@ pub enum SigningStage {
|
||||
|
||||
pub enum SubmittingStage {
|
||||
Initial {
|
||||
signed_extrinsic: SubmittableTransaction<PolkadotConfig, OnlineClient<PolkadotConfig>>,
|
||||
signed_extrinsic: SubmittableTransaction<PezkuwiConfig, OnlineClient<PezkuwiConfig>>,
|
||||
},
|
||||
Submitting,
|
||||
Success {
|
||||
remark_event: polkadot::system::events::ExtrinsicSuccess,
|
||||
remark_event: pezkuwi::system::events::ExtrinsicSuccess,
|
||||
},
|
||||
Error(anyhow::Error),
|
||||
}
|
||||
|
||||
pub enum Message {
|
||||
Error(anyhow::Error),
|
||||
OnlineClientCreated(OnlineClient<PolkadotConfig>),
|
||||
OnlineClientCreated(OnlineClient<PezkuwiConfig>),
|
||||
ChangeMessage(String),
|
||||
RequestAccounts,
|
||||
ReceivedAccounts(Vec<Account>),
|
||||
@@ -70,11 +70,11 @@ pub enum Message {
|
||||
SignWithAccount(usize),
|
||||
ReceivedSignature(
|
||||
MultiSignature,
|
||||
SubmittableTransaction<PolkadotConfig, OnlineClient<PolkadotConfig>>,
|
||||
SubmittableTransaction<PezkuwiConfig, OnlineClient<PezkuwiConfig>>,
|
||||
),
|
||||
SubmitSigned,
|
||||
ExtrinsicFinalized {
|
||||
remark_event: polkadot::system::events::ExtrinsicSuccess,
|
||||
remark_event: pezkuwi::system::events::ExtrinsicSuccess,
|
||||
},
|
||||
ExtrinsicFailed(anyhow::Error),
|
||||
}
|
||||
@@ -85,7 +85,7 @@ impl Component for SigningExamplesComponent {
|
||||
type Properties = ();
|
||||
|
||||
fn create(ctx: &Context<Self>) -> Self {
|
||||
ctx.link().send_future(OnlineClient::<PolkadotConfig>::new().map(|res| {
|
||||
ctx.link().send_future(OnlineClient::<PezkuwiConfig>::new().map(|res| {
|
||||
match res {
|
||||
Ok(online_client) => Message::OnlineClientCreated(online_client),
|
||||
Err(err) => Message::Error(anyhow!("Online Client could not be created. Make sure you have a local node running:\n{err}")),
|
||||
@@ -131,7 +131,7 @@ impl Component for SigningExamplesComponent {
|
||||
|
||||
self.stage = SigningStage::Signing(account.clone());
|
||||
|
||||
let remark_call = polkadot::tx()
|
||||
let remark_call = pezkuwi::tx()
|
||||
.system()
|
||||
.remark(self.message.as_bytes().to_vec());
|
||||
|
||||
@@ -258,7 +258,7 @@ impl Component for SigningExamplesComponent {
|
||||
| SigningStage::EnterMessage
|
||||
| SigningStage::CreatingOnlineClient => html!(<></>),
|
||||
_ => {
|
||||
let _remark_call = polkadot::tx()
|
||||
let _remark_call = pezkuwi::tx()
|
||||
.system()
|
||||
.remark(self.message.as_bytes().to_vec());
|
||||
html!(
|
||||
@@ -321,7 +321,7 @@ impl Component for SigningExamplesComponent {
|
||||
}
|
||||
SigningStage::SelectAccount(accounts) => {
|
||||
if accounts.is_empty() {
|
||||
html!(<div>{"No Web3 extension accounts found. Install Talisman or the Polkadot.js extension and add an account."}</div>)
|
||||
html!(<div>{"No Web3 extension accounts found. Install Talisman or the Pezkuwi.js extension and add an account."}</div>)
|
||||
} else {
|
||||
html!(
|
||||
<>
|
||||
@@ -394,8 +394,8 @@ impl Component for SigningExamplesComponent {
|
||||
}
|
||||
|
||||
async fn submit_wait_finalized_and_get_extrinsic_success_event(
|
||||
extrinsic: SubmittableTransaction<PolkadotConfig, OnlineClient<PolkadotConfig>>,
|
||||
) -> Result<polkadot::system::events::ExtrinsicSuccess, anyhow::Error> {
|
||||
extrinsic: SubmittableTransaction<PezkuwiConfig, OnlineClient<PezkuwiConfig>>,
|
||||
) -> Result<pezkuwi::system::events::ExtrinsicSuccess, anyhow::Error> {
|
||||
let events = extrinsic
|
||||
.submit_and_watch()
|
||||
.await?
|
||||
@@ -404,10 +404,10 @@ async fn submit_wait_finalized_and_get_extrinsic_success_event(
|
||||
|
||||
let events_str = format!("{:?}", &events);
|
||||
web_sys::console::log_1(&events_str.into());
|
||||
for event in events.find::<polkadot::system::events::ExtrinsicSuccess>() {
|
||||
for event in events.find::<pezkuwi::system::events::ExtrinsicSuccess>() {
|
||||
web_sys::console::log_1(&format!("{:?}", event).into());
|
||||
}
|
||||
|
||||
let success = events.find_first::<polkadot::system::events::ExtrinsicSuccess>()?;
|
||||
let success = events.find_first::<pezkuwi::system::events::ExtrinsicSuccess>()?;
|
||||
success.ok_or(anyhow!("ExtrinsicSuccess not found in events"))
|
||||
}
|
||||
|
||||
@@ -4,24 +4,24 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use std::fmt::Write;
|
||||
use pezkuwi_subxt::ext::codec::{Compact, Encode};
|
||||
use pezkuwi_subxt::{self, OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{self, OnlineClient, PezkuwiConfig};
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
use yew::{AttrValue, Callback};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
pub(crate) async fn fetch_constant_block_length() -> Result<String, pezkuwi_subxt::Error> {
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let constant_query = polkadot::constants().system().block_length();
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
let constant_query = pezkuwi::constants().system().block_length();
|
||||
|
||||
let value = api.constants().at(&constant_query)?;
|
||||
Ok(format!("{value:?}"))
|
||||
}
|
||||
|
||||
pub(crate) async fn fetch_events_dynamically() -> Result<Vec<String>, pezkuwi_subxt::Error> {
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
let events = api.events().at_latest().await?;
|
||||
let mut event_strings = Vec::<String>::new();
|
||||
for event in events.iter() {
|
||||
@@ -38,7 +38,7 @@ pub(crate) async fn fetch_events_dynamically() -> Result<Vec<String>, pezkuwi_su
|
||||
pub(crate) async fn subscribe_to_finalized_blocks(
|
||||
cb: Callback<AttrValue>,
|
||||
) -> Result<(), pezkuwi_subxt::Error> {
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
// Subscribe to all finalized blocks:
|
||||
let mut blocks_sub = api.blocks().subscribe_finalized().await?;
|
||||
while let Some(block) = blocks_sub.next().await {
|
||||
@@ -54,7 +54,7 @@ pub(crate) async fn subscribe_to_finalized_blocks(
|
||||
let bytes_hex = format!("0x{}", hex::encode(ext.bytes()));
|
||||
|
||||
// See the API docs for more ways to decode extrinsics:
|
||||
let decoded_ext = ext.as_root_extrinsic::<polkadot::Call>();
|
||||
let decoded_ext = ext.as_root_extrinsic::<pezkuwi::Call>();
|
||||
|
||||
writeln!(output, " Extrinsic #{idx}:").ok();
|
||||
writeln!(output, " Bytes: {bytes_hex}").ok();
|
||||
@@ -117,12 +117,12 @@ fn encode_then_hex<E: Encode>(input: &E) -> String {
|
||||
format!("0x{}", hex::encode(input.encode()))
|
||||
}
|
||||
|
||||
/// communicates with JavaScript to obtain a signature for the `partial_extrinsic` via a browser extension (e.g. polkadot-js or Talisman)
|
||||
/// communicates with JavaScript to obtain a signature for the `partial_extrinsic` via a browser extension (e.g. pezkuwi-js or Talisman)
|
||||
///
|
||||
/// Some parameters are hard-coded here and not taken from the partial_extrinsic itself (mortality_checkpoint, era, tip).
|
||||
pub async fn extension_signature_for_extrinsic(
|
||||
call_data: &[u8],
|
||||
api: &OnlineClient<PolkadotConfig>,
|
||||
api: &OnlineClient<PezkuwiConfig>,
|
||||
account_nonce: u64,
|
||||
account_source: String,
|
||||
account_address: String,
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ readme = "README.md"
|
||||
repository.workspace = true
|
||||
documentation.workspace = true
|
||||
homepage.workspace = true
|
||||
description = "Download non head-of-chain blocks and state from Substrate based nodes"
|
||||
keywords = ["blockchain", "parity", "substrate"]
|
||||
description = "Download non head-of-chain blocks and state from Bizinikiwi based nodes"
|
||||
keywords = ["blockchain", "parity", "bizinikiwi"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ While `subxt` is a library for working at the head of a chain (submitting transa
|
||||
|
||||
# Examples
|
||||
|
||||
See the [examples](https://github.com/paritytech/subxt/tree/master/historic/examples) folder for examples of how to use `subxt-historic`.
|
||||
See the [examples](https://github.com/pezkuwichain/subxt/tree/master/historic/examples) folder for examples of how to use `subxt-historic`.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#![allow(missing_docs)]
|
||||
use subxt_historic::{OnlineClient, PolkadotConfig};
|
||||
use subxt_historic::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn core::error::Error + Send + Sync + 'static>> {
|
||||
// Configuration for the Polkadot relay chain.
|
||||
let config = PolkadotConfig::new();
|
||||
// Configuration for the Pezkuwi relay chain.
|
||||
let config = PezkuwiConfig::new();
|
||||
|
||||
// Create an online client for the Polkadot relay chain, pointed at a Polkadot archive node.
|
||||
let client = OnlineClient::from_url(config, "wss://rpc.polkadot.io").await?;
|
||||
// Create an online client for the Pezkuwi relay chain, pointed at a Pezkuwi archive node.
|
||||
let client = OnlineClient::from_url(config, "wss://rpc.pezkuwi.io").await?;
|
||||
|
||||
// Iterate through some randomly selected old blocks to show how to fetch and decode extrinsics.
|
||||
for block_number in 1234567.. {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#![allow(missing_docs)]
|
||||
use subxt_historic::{OnlineClient, PolkadotConfig, ext::StreamExt};
|
||||
use subxt_historic::{OnlineClient, PezkuwiConfig, ext::StreamExt};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn core::error::Error + Send + Sync + 'static>> {
|
||||
// Configuration for the Polkadot relay chain.
|
||||
let config = PolkadotConfig::new();
|
||||
// Configuration for the Pezkuwi relay chain.
|
||||
let config = PezkuwiConfig::new();
|
||||
|
||||
// Create an online client for the Polkadot relay chain, pointed at a Polkadot archive node.
|
||||
let client = OnlineClient::from_url(config, "wss://rpc.polkadot.io").await?;
|
||||
// Create an online client for the Pezkuwi relay chain, pointed at a Pezkuwi archive node.
|
||||
let client = OnlineClient::from_url(config, "wss://rpc.pezkuwi.io").await?;
|
||||
|
||||
// Iterate through some randomly selected blocks to show how to fetch and decode storage.
|
||||
for block_number in 12345678.. {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
pub mod polkadot;
|
||||
pub mod substrate;
|
||||
pub mod pezkuwi;
|
||||
pub mod bizinikiwi;
|
||||
|
||||
use scale_info_legacy::TypeRegistrySet;
|
||||
use std::fmt::Display;
|
||||
use std::sync::Arc;
|
||||
use pezkuwi_subxt_rpcs::RpcConfig;
|
||||
|
||||
pub use polkadot::PolkadotConfig;
|
||||
pub use substrate::SubstrateConfig;
|
||||
pub use pezkuwi::PezkuwiConfig;
|
||||
pub use bizinikiwi::BizinikiwConfig;
|
||||
|
||||
/// This represents the configuration needed for a specific chain. This includes
|
||||
/// any hardcoded types we need to know about for that chain, as well as a means to
|
||||
|
||||
@@ -6,30 +6,30 @@ use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
/// Configuration that's suitable for standard Substrate chains (ie those
|
||||
/// Configuration that's suitable for standard Bizinikiwi chains (ie those
|
||||
/// that have not customized the block hash type).
|
||||
pub struct SubstrateConfig {
|
||||
pub struct BizinikiwConfig {
|
||||
legacy_types: ChainTypeRegistry,
|
||||
spec_version_for_block_number: RangeMap<u64, u32>,
|
||||
metadata_for_spec_version: Mutex<HashMap<u32, Arc<frame_metadata::RuntimeMetadata>>>,
|
||||
}
|
||||
|
||||
impl SubstrateConfig {
|
||||
/// Create a new SubstrateConfig with no legacy types.
|
||||
impl BizinikiwConfig {
|
||||
/// Create a new BizinikiwConfig with no legacy types.
|
||||
///
|
||||
/// Without any further configuration, this will only work with
|
||||
/// the [`crate::client::OnlineClient`] for blocks that were produced by Runtimes
|
||||
/// that emit metadata V14 or later.
|
||||
///
|
||||
/// To support working at any block with the [`crate::client::OnlineClient`], you
|
||||
/// must call [`SubstrateConfig::set_legacy_types`] with appropriate legacy type
|
||||
/// must call [`BizinikiwConfig::set_legacy_types`] with appropriate legacy type
|
||||
/// definitions.
|
||||
///
|
||||
/// To support working with the [`crate::client::OfflineClient`] at any block,
|
||||
/// you must also call:
|
||||
/// - [`SubstrateConfig::set_metadata_for_spec_versions`] to set the metadata to
|
||||
/// - [`BizinikiwConfig::set_metadata_for_spec_versions`] to set the metadata to
|
||||
/// use at each spec version we might encounter.
|
||||
/// - [`SubstrateConfig::set_spec_version_for_block_ranges`] to set the spec version
|
||||
/// - [`BizinikiwConfig::set_spec_version_for_block_ranges`] to set the spec version
|
||||
/// to use for each range of blocks we might encounter.
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
@@ -74,13 +74,13 @@ impl SubstrateConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SubstrateConfig {
|
||||
impl Default for BizinikiwConfig {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Config for SubstrateConfig {
|
||||
impl Config for BizinikiwConfig {
|
||||
type Hash = H256;
|
||||
|
||||
fn legacy_types_for_spec_version(&'_ self, spec_version: u32) -> TypeRegistrySet<'_> {
|
||||
@@ -120,7 +120,7 @@ impl Config for SubstrateConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl pezkuwi_subxt_rpcs::RpcConfig for SubstrateConfig {
|
||||
impl pezkuwi_subxt_rpcs::RpcConfig for BizinikiwConfig {
|
||||
type Hash = <Self as Config>::Hash;
|
||||
// We don't use these types in any of the RPC methods we call,
|
||||
// so don't bother setting them up:
|
||||
@@ -1,16 +1,16 @@
|
||||
use super::Config;
|
||||
use super::SubstrateConfig;
|
||||
use super::BizinikiwConfig;
|
||||
use scale_info_legacy::{ChainTypeRegistry, TypeRegistrySet};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Configuration that's suitable for the Polkadot Relay Chain
|
||||
pub struct PolkadotConfig(SubstrateConfig);
|
||||
/// Configuration that's suitable for the Pezkuwi Relay Chain
|
||||
pub struct PezkuwiConfig(BizinikiwConfig);
|
||||
|
||||
impl PolkadotConfig {
|
||||
/// Create a new PolkadotConfig.
|
||||
impl PezkuwiConfig {
|
||||
/// Create a new PezkuwiConfig.
|
||||
pub fn new() -> Self {
|
||||
let config = SubstrateConfig::new()
|
||||
.set_legacy_types(frame_decode::legacy_types::polkadot::relay_chain());
|
||||
let config = BizinikiwConfig::new()
|
||||
.set_legacy_types(frame_decode::legacy_types::pezkuwi::relay_chain());
|
||||
|
||||
// TODO: Set spec versions as well with known spec version changes, to speed
|
||||
// up accessing historic blocks within the known ranges. For now, we just let
|
||||
@@ -39,19 +39,19 @@ impl PolkadotConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// This hands back the legacy types for the Polkadot Relay Chain, which is what [`PolkadotConfig`] uses internally.
|
||||
/// This hands back the legacy types for the Pezkuwi Relay Chain, which is what [`PezkuwiConfig`] uses internally.
|
||||
pub fn legacy_types() -> ChainTypeRegistry {
|
||||
frame_decode::legacy_types::polkadot::relay_chain()
|
||||
frame_decode::legacy_types::pezkuwi::relay_chain()
|
||||
}
|
||||
|
||||
impl Default for PolkadotConfig {
|
||||
impl Default for PezkuwiConfig {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Config for PolkadotConfig {
|
||||
type Hash = <SubstrateConfig as Config>::Hash;
|
||||
impl Config for PezkuwiConfig {
|
||||
type Hash = <BizinikiwConfig as Config>::Hash;
|
||||
|
||||
fn legacy_types_for_spec_version(&'_ self, spec_version: u32) -> TypeRegistrySet<'_> {
|
||||
self.0.legacy_types_for_spec_version(spec_version)
|
||||
@@ -77,12 +77,12 @@ impl Config for PolkadotConfig {
|
||||
}
|
||||
|
||||
fn hash(s: &[u8]) -> <Self as Config>::Hash {
|
||||
SubstrateConfig::hash(s)
|
||||
BizinikiwConfig::hash(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl pezkuwi_subxt_rpcs::RpcConfig for PolkadotConfig {
|
||||
type Hash = <SubstrateConfig as pezkuwi_subxt_rpcs::RpcConfig>::Hash;
|
||||
type Header = <SubstrateConfig as pezkuwi_subxt_rpcs::RpcConfig>::Header;
|
||||
type AccountId = <SubstrateConfig as pezkuwi_subxt_rpcs::RpcConfig>::AccountId;
|
||||
impl pezkuwi_subxt_rpcs::RpcConfig for PezkuwiConfig {
|
||||
type Hash = <BizinikiwConfig as pezkuwi_subxt_rpcs::RpcConfig>::Hash;
|
||||
type Header = <BizinikiwConfig as pezkuwi_subxt_rpcs::RpcConfig>::Header;
|
||||
type AccountId = <BizinikiwConfig as pezkuwi_subxt_rpcs::RpcConfig>::AccountId;
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
//! `subxt-historic` is a library for working with non head-of-chain data on Substrate-based blockchains.
|
||||
//! `subxt-historic` is a library for working with non head-of-chain data on Bizinikiwi-based blockchains.
|
||||
|
||||
// TODO: Remove this when we're ready to release, and document everything!
|
||||
#![allow(missing_docs)]
|
||||
@@ -12,8 +12,8 @@ pub mod extrinsics;
|
||||
pub mod storage;
|
||||
|
||||
pub use client::{OfflineClient, OnlineClient};
|
||||
pub use config::polkadot::PolkadotConfig;
|
||||
pub use config::substrate::SubstrateConfig;
|
||||
pub use config::pezkuwi::PezkuwiConfig;
|
||||
pub use config::bizinikiwi::BizinikiwConfig;
|
||||
pub use error::Error;
|
||||
|
||||
/// External types and crates that may be useful.
|
||||
|
||||
@@ -12,7 +12,7 @@ repository.workspace = true
|
||||
documentation.workspace = true
|
||||
homepage.workspace = true
|
||||
description = "Light Client for chain interaction"
|
||||
keywords = ["blockchain", "parity", "substrate"]
|
||||
keywords = ["blockchain", "parity", "bizinikiwi"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! A wrapper around [`smoldot_light`] which provides an light client capable of connecting
|
||||
//! to Substrate based chains.
|
||||
//! to Bizinikiwi based chains.
|
||||
|
||||
#![deny(missing_docs)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ license.workspace = true
|
||||
repository.workspace = true
|
||||
documentation.workspace = true
|
||||
homepage.workspace = true
|
||||
description = "Generate types and helpers for interacting with Substrate runtimes."
|
||||
description = "Generate types and helpers for interacting with Bizinikiwi runtimes."
|
||||
|
||||
[features]
|
||||
web = ["pezkuwi-subxt-codegen/web"]
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! Subxt macro for generating Substrate runtime interfaces.
|
||||
//! Subxt macro for generating Bizinikiwi runtime interfaces.
|
||||
|
||||
use codec::Decode;
|
||||
use darling::{FromMeta, ast::NestedMeta};
|
||||
@@ -108,7 +108,7 @@ fn subxt_inner(args: TokenStream, item_mod: syn::ItemMod) -> Result<TokenStream,
|
||||
|
||||
// Run this first to ensure type paths are unique (which may result in 1,2,3 suffixes being
|
||||
// added to type paths), so that when we validate derives/substitutions below, they are
|
||||
// allowed for such types. See <https://github.com/paritytech/subxt/issues/2011>.
|
||||
// allowed for such types. See <https://github.com/pezkuwichain/subxt/issues/2011>.
|
||||
scale_typegen::utils::ensure_unique_type_paths(metadata.types_mut())
|
||||
.expect("ensure_unique_type_paths should not fail; please report an issue.");
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ fn maybe_decompress(file_contents: Vec<u8>) -> WasmMetadataResult<Vec<u8>> {
|
||||
|
||||
struct Executor {
|
||||
runtime_blob: RuntimeBlob,
|
||||
executor: WasmExecutor<sp_io::SubstrateHostFunctions>,
|
||||
executor: WasmExecutor<sp_io::BizinikiwiHostFunctions>,
|
||||
externalities: sp_state_machine::BasicExternalities,
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ impl Executor {
|
||||
fn new(wasm_file: &[u8]) -> WasmMetadataResult<Self> {
|
||||
let externalities: sp_state_machine::BasicExternalities = Default::default();
|
||||
|
||||
let executor: WasmExecutor<sp_io::SubstrateHostFunctions> = WasmExecutor::builder()
|
||||
let executor: WasmExecutor<sp_io::BizinikiwiHostFunctions> = WasmExecutor::builder()
|
||||
.with_execution_method(WasmExecutionMethod::default())
|
||||
.with_offchain_heap_alloc_strategy(sc_executor::HeapAllocStrategy::Dynamic {
|
||||
maximum_pages: Some(64),
|
||||
|
||||
@@ -11,7 +11,7 @@ use pezkuwi_subxt_metadata::Metadata;
|
||||
use std::{fs, path::Path};
|
||||
|
||||
fn load_metadata() -> Metadata {
|
||||
let bytes = fs::read(Path::new("../artifacts/polkadot_metadata_full.scale"))
|
||||
let bytes = fs::read(Path::new("../artifacts/pezkuwi_metadata_full.scale"))
|
||||
.expect("Cannot read metadata blob");
|
||||
let meta: RuntimeMetadataPrefixed =
|
||||
Decode::decode(&mut &*bytes).expect("Cannot decode scale metadata");
|
||||
|
||||
@@ -35,7 +35,7 @@ fn legacy_kusama_metadata(version: u8) -> (u64, RuntimeMetadata) {
|
||||
/// Load our kusama types.
|
||||
/// TODO: This is WRONG at the moment; change to point to kusama types when they exist:
|
||||
fn kusama_types() -> scale_info_legacy::ChainTypeRegistry {
|
||||
frame_decode::legacy_types::polkadot::relay_chain()
|
||||
frame_decode::legacy_types::pezkuwi::relay_chain()
|
||||
}
|
||||
|
||||
/// Sanitizing paths changes things between old and new, so disable this in tests by default
|
||||
|
||||
@@ -229,7 +229,7 @@ fn generate_outer_error_enum_type(
|
||||
|
||||
/// The type IDs extracted from the metadata that represent the
|
||||
/// generic type parameters passed to the `UncheckedExtrinsic` from
|
||||
/// the substrate-based chain.
|
||||
/// the bizinikiwi-based chain.
|
||||
#[derive(Clone, Copy)]
|
||||
struct MissingExtrinsicTypeIds {
|
||||
address: u32,
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! A representation of the metadata provided by a substrate based node.
|
||||
//! A representation of the metadata provided by a bizinikiwi based node.
|
||||
//! This representation is optimized to be used by Subxt and related crates,
|
||||
//! and is independent of the different versions of metadata that can be
|
||||
//! provided from a node.
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ readme = "README.md"
|
||||
repository.workspace = true
|
||||
documentation.workspace = true
|
||||
homepage.workspace = true
|
||||
description = "Make RPC calls to Substrate based nodes"
|
||||
description = "Make RPC calls to Bizinikiwi based nodes"
|
||||
keywords = ["parity", "rpcs", "subxt"]
|
||||
|
||||
[features]
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# subxt-rpcs
|
||||
|
||||
This crate provides an interface for interacting with Substrate nodes via the available RPC methods.
|
||||
This crate provides an interface for interacting with Bizinikiwi nodes via the available RPC methods.
|
||||
|
||||
```rust
|
||||
use subxt_rpcs::{RpcClient, ChainHeadRpcMethods};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! RPC types and client for interacting with a substrate node.
|
||||
//! RPC types and client for interacting with a bizinikiwi node.
|
||||
//!
|
||||
//! An RPC client is instantiated and then used to create some methods, for instance
|
||||
//! [`crate::methods::ChainHeadRpcMethods`], which defines the calls that can be made with it.
|
||||
|
||||
+2
-2
@@ -2,13 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! This crate provides a low level RPC interface to Substrate based nodes.
|
||||
//! This crate provides a low level RPC interface to Bizinikiwi based nodes.
|
||||
//!
|
||||
//! See the [`client`] module for a [`client::RpcClient`] which is driven by implementations
|
||||
//! of [`client::RpcClientT`] (several of which are provided behind feature flags).
|
||||
//!
|
||||
//! See the [`methods`] module for structs which implement sets of concrete RPC calls for
|
||||
//! communicating with Substrate based nodes. These structs are all driven by a
|
||||
//! communicating with Bizinikiwi based nodes. These structs are all driven by a
|
||||
//! [`client::RpcClient`].
|
||||
//!
|
||||
//! The RPC clients/methods here are made use of in `subxt`. Enabling the `subxt` feature flag
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! An interface to call the API methods. See
|
||||
//! <https://github.com/paritytech/json-rpc-interface-spec/> for details of the API
|
||||
//! <https://github.com/pezkuwichain/json-rpc-interface-spec/> for details of the API
|
||||
//! methods exposed here.
|
||||
|
||||
use crate::{
|
||||
@@ -298,7 +298,7 @@ impl<T: RpcConfig> ChainHeadRpcMethods<T> {
|
||||
success: bool,
|
||||
value: Option<Bytes>,
|
||||
error: Option<String>,
|
||||
// This was accidentally used instead of value in Substrate,
|
||||
// This was accidentally used instead of value in Bizinikiwi,
|
||||
// so to support those impls we try it here if needed:
|
||||
result: Option<Bytes>,
|
||||
}
|
||||
@@ -409,7 +409,7 @@ impl<T: RpcConfig> ChainHeadRpcMethods<T> {
|
||||
success: bool,
|
||||
value: Option<Bytes>,
|
||||
error: Option<String>,
|
||||
// This was accidentally used instead of value in Substrate,
|
||||
// This was accidentally used instead of value in Bizinikiwi,
|
||||
// so to support those impls we try it here if needed:
|
||||
result: Option<Bytes>,
|
||||
}
|
||||
@@ -655,7 +655,7 @@ pub struct RuntimeSpec {
|
||||
/// making a runtime call (using chainHead_call), you should make sure that this list contains
|
||||
/// the entry point API corresponding to the call and with a known version number.
|
||||
///
|
||||
/// **Note:** In Substrate, the keys in the apis field consists of the hexadecimal-encoded
|
||||
/// **Note:** In Bizinikiwi, the keys in the apis field consists of the hexadecimal-encoded
|
||||
/// 8-bytes blake2 hash of the name of the API. For example, the `TaggedTransactionQueue` API
|
||||
/// is 0xd2bc9897eed08f15.
|
||||
#[serde(with = "hashmap_as_tuple_list")]
|
||||
@@ -1117,7 +1117,7 @@ fn to_hex(bytes: impl AsRef<[u8]>) -> String {
|
||||
}
|
||||
|
||||
/// Attempt to deserialize either a string or integer into an integer.
|
||||
/// See <https://github.com/paritytech/json-rpc-interface-spec/issues/83>
|
||||
/// See <https://github.com/pezkuwichain/json-rpc-interface-spec/issues/83>
|
||||
pub(crate) mod unsigned_number_as_string {
|
||||
use serde::de::{Deserializer, Visitor};
|
||||
use std::fmt;
|
||||
@@ -1263,8 +1263,8 @@ mod test {
|
||||
fn can_deserialize_apis_from_tuple_or_object() {
|
||||
let old_response = serde_json::json!({
|
||||
"authoringVersion": 10,
|
||||
"specName": "westend",
|
||||
"implName": "parity-westend",
|
||||
"specName": "zagros",
|
||||
"implName": "parity-zagros",
|
||||
"specVersion": 9122,
|
||||
"implVersion": 0,
|
||||
"stateVersion": 1,
|
||||
@@ -1289,8 +1289,8 @@ mod test {
|
||||
let old_spec: RuntimeSpec = serde_json::from_value(old_response).unwrap();
|
||||
|
||||
let new_response = serde_json::json!({
|
||||
"specName": "westend",
|
||||
"implName": "parity-westend",
|
||||
"specName": "zagros",
|
||||
"implName": "parity-zagros",
|
||||
"specVersion": 9122,
|
||||
"implVersion": 0,
|
||||
"transactionVersion": 7,
|
||||
|
||||
@@ -468,7 +468,7 @@ pub struct RuntimeVersion {
|
||||
/// # Note
|
||||
///
|
||||
/// This is copied from `sp-transaction-pool` to avoid a dependency on that crate. Therefore it
|
||||
/// must be kept compatible with that type from the target substrate version.
|
||||
/// must be kept compatible with that type from the target bizinikiwi version.
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum TransactionStatus<Hash> {
|
||||
@@ -593,7 +593,7 @@ pub struct BlockStats {
|
||||
/// # Note
|
||||
///
|
||||
/// This is copied from `sc-rpc-api` to avoid a dependency on that crate. Therefore it
|
||||
/// must be kept compatible with that type from the target substrate version.
|
||||
/// must be kept compatible with that type from the target bizinikiwi version.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ReadProof<Hash> {
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
//! RPC methods are defined in this module. At the moment we have:
|
||||
//!
|
||||
//! - [`ChainHeadRpcMethods`] (and the types in [`chain_head`]): these methods
|
||||
//! implement the RPC spec at <https://paritytech.github.io/json-rpc-interface-spec/api/chainHead.html>
|
||||
//! implement the RPC spec at <https://pezkuwichain.github.io/json-rpc-interface-spec/api/chainHead.html>
|
||||
//!
|
||||
//! We also have (although their use is not advised):
|
||||
//!
|
||||
//! - [`LegacyRpcMethods`] (and the types in [`legacy`]): a collection of legacy RPCs. These are not
|
||||
//! well specified and may change in implementations without warning, but for those methods we
|
||||
//! expose, we make a best effort to work against latest Substrate versions.
|
||||
//! expose, we make a best effort to work against latest Bizinikiwi versions.
|
||||
|
||||
pub mod chain_head;
|
||||
pub mod legacy;
|
||||
|
||||
@@ -11,4 +11,4 @@ homepage.workspace = true
|
||||
description = "Internal tool to regenerate artifacts"
|
||||
|
||||
[dependencies]
|
||||
substrate-runner = { workspace = true }
|
||||
bizinikiwi-runner = { workspace = true }
|
||||
|
||||
@@ -3,14 +3,14 @@ use std::{
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
|
||||
use substrate_runner::SubstrateNode;
|
||||
use bizinikiwi_runner::BizinikiwiNode;
|
||||
|
||||
/// A Script to generate artifacts that are used in the integration tests.
|
||||
///
|
||||
/// Run with `cargo run --bin artifacts` from the root of the repository.
|
||||
fn main() {
|
||||
let mut node_builder = SubstrateNode::builder();
|
||||
node_builder.polkadot();
|
||||
let mut node_builder = BizinikiwiNode::builder();
|
||||
node_builder.pezkuwi();
|
||||
|
||||
// Spawn the node and retrieve a ws URL to it:
|
||||
let proc = node_builder
|
||||
@@ -19,32 +19,32 @@ fn main() {
|
||||
.expect("Could not spawn node");
|
||||
let node_url = format!("ws://127.0.0.1:{}", proc.ws_port());
|
||||
|
||||
// Get the full metadata from the spawned substrate node
|
||||
// Get the full metadata from the spawned bizinikiwi node
|
||||
run_cmd(
|
||||
&format!("cargo run --bin subxt metadata --version 15 --url {node_url}"),
|
||||
Some("artifacts/polkadot_metadata_full.scale"),
|
||||
Some("artifacts/pezkuwi_metadata_full.scale"),
|
||||
);
|
||||
|
||||
// Use it to generate polkadot.rs
|
||||
// Use it to generate pezkuwi.rs
|
||||
run_cmd(
|
||||
"cargo run --bin subxt codegen --file artifacts/polkadot_metadata_full.scale",
|
||||
Some("testing/integration-tests/src/full_client/codegen/polkadot.rs"),
|
||||
"cargo run --bin subxt codegen --file artifacts/pezkuwi_metadata_full.scale",
|
||||
Some("testing/integration-tests/src/full_client/codegen/pezkuwi.rs"),
|
||||
);
|
||||
run_cmd(
|
||||
"rustfmt testing/integration-tests/src/full_client/codegen/polkadot.rs",
|
||||
"rustfmt testing/integration-tests/src/full_client/codegen/pezkuwi.rs",
|
||||
None,
|
||||
);
|
||||
|
||||
// Generate a metadata file that only contains a few pallets that we need for our examples.
|
||||
run_cmd(
|
||||
"cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets Balances,Staking,System,Multisig,Timestamp,ParaInherent",
|
||||
Some("artifacts/polkadot_metadata_small.scale"),
|
||||
"cargo run --bin subxt metadata --file artifacts/pezkuwi_metadata_full.scale --pallets Balances,Staking,System,Multisig,Timestamp,ParaInherent",
|
||||
Some("artifacts/pezkuwi_metadata_small.scale"),
|
||||
);
|
||||
|
||||
// Generate a metadata file that contains no pallets
|
||||
run_cmd(
|
||||
"cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets \"\"",
|
||||
Some("artifacts/polkadot_metadata_tiny.scale"),
|
||||
"cargo run --bin subxt metadata --file artifacts/pezkuwi_metadata_full.scale --pallets \"\"",
|
||||
Some("artifacts/pezkuwi_metadata_tiny.scale"),
|
||||
);
|
||||
|
||||
// Generate a metadata file that only contains some custom metadata
|
||||
@@ -53,9 +53,9 @@ fn main() {
|
||||
Some("artifacts/metadata_with_custom_values.scale"),
|
||||
);
|
||||
|
||||
// Generate the polkadot chain spec.
|
||||
// Generate the pezkuwi chain spec.
|
||||
run_cmd(
|
||||
"cargo run --features chain-spec-pruning --bin subxt chain-spec --url wss://rpc.polkadot.io:443 --output-file artifacts/demo_chain_specs/polkadot.json --state-root-hash --remove-substitutes",
|
||||
"cargo run --features chain-spec-pruning --bin subxt chain-spec --url wss://rpc.pezkuwi.io:443 --output-file artifacts/demo_chain_specs/pezkuwi.json --state-root-hash --remove-substitutes",
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
+3
-3
@@ -39,8 +39,8 @@ sr25519 = ["schnorrkel"]
|
||||
ecdsa = ["secp256k1"]
|
||||
unstable-eth = ["bip32", "ecdsa", "keccak-hash", "secp256k1"]
|
||||
|
||||
# Enable support for loading key pairs from polkadot-js json.
|
||||
polkadot-js-compat = [
|
||||
# Enable support for loading key pairs from pezkuwi-js json.
|
||||
pezkuwi-js-compat = [
|
||||
"base64",
|
||||
"crypto_secretbox",
|
||||
"scrypt",
|
||||
@@ -83,7 +83,7 @@ sha2 = { workspace = true }
|
||||
thiserror = { workspace = true, default-features = false }
|
||||
zeroize = { workspace = true }
|
||||
|
||||
# These are used if the polkadot-js-compat feature is enabled
|
||||
# These are used if the pezkuwi-js-compat feature is enabled
|
||||
base64 = { workspace = true, optional = true, features = ["alloc"] }
|
||||
crypto_secretbox = { workspace = true, optional = true, features = ["alloc", "salsa20"] }
|
||||
scrypt = { workspace = true, default-features = false, optional = true }
|
||||
|
||||
@@ -8,7 +8,7 @@ use pbkdf2::pbkdf2;
|
||||
use sha2::Sha512;
|
||||
use zeroize::Zeroize;
|
||||
|
||||
/// This is taken from `substrate-bip39` so that we can keep dependencies in line, and
|
||||
/// This is taken from `bizinikiwi-bip39` so that we can keep dependencies in line, and
|
||||
/// is the same logic that sp-core uses to go from mnemonic entropy to seed. Returns
|
||||
/// `None` if invalid length.
|
||||
#[allow(dead_code)]
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ const SECRET_KEY_LENGTH: usize = 32;
|
||||
pub type SecretKeyBytes = [u8; SECRET_KEY_LENGTH];
|
||||
|
||||
/// A signature generated by [`Keypair::sign()`]. These bytes are equivalent
|
||||
/// to a Substrate `MultiSignature::Ecdsa(bytes)`.
|
||||
/// to a Bizinikiwi `MultiSignature::Ecdsa(bytes)`.
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Signature(pub [u8; 65]);
|
||||
|
||||
@@ -145,7 +145,7 @@ impl Keypair {
|
||||
|
||||
/// Obtain the [`PublicKey`] part of this key pair, which can be used in calls to [`verify()`].
|
||||
/// or otherwise converted into an address. In case of ECDSA, the public key bytes are not
|
||||
/// equivalent to a Substrate `AccountId32`. They have to be hashed to obtain `AccountId32`.
|
||||
/// equivalent to a Bizinikiwi `AccountId32`. They have to be hashed to obtain `AccountId32`.
|
||||
pub fn public_key(&self) -> PublicKey {
|
||||
PublicKey(self.0.public_key().serialize())
|
||||
}
|
||||
@@ -155,7 +155,7 @@ impl Keypair {
|
||||
*self.0.secret_key().as_ref()
|
||||
}
|
||||
|
||||
/// Sign some message. These bytes can be used directly in a Substrate
|
||||
/// Sign some message. These bytes can be used directly in a Bizinikiwi
|
||||
/// `MultiSignature::Ecdsa(..)`.
|
||||
pub fn sign(&self, message: &[u8]) -> Signature {
|
||||
self.sign_prehashed(&pezsp_crypto_hashing::blake2_256(message))
|
||||
|
||||
+3
-3
@@ -376,9 +376,9 @@ mod test {
|
||||
type AccountId = AccountId20;
|
||||
type Address = AccountId20;
|
||||
type Signature = Signature;
|
||||
type Hasher = substrate::BlakeTwo256;
|
||||
type Header = substrate::SubstrateHeader<u32, substrate::BlakeTwo256>;
|
||||
type ExtrinsicParams = SubstrateExtrinsicParams<Self>;
|
||||
type Hasher = bizinikiwi::BlakeTwo256;
|
||||
type Header = bizinikiwi::BizinikiwiHeader<u32, bizinikiwi::BlakeTwo256>;
|
||||
type ExtrinsicParams = BizinikiwiExtrinsicParams<Self>;
|
||||
type AssetId = u32;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -6,7 +6,7 @@
|
||||
//!
|
||||
//! The main output from this crate is the [`sr25519::Keypair`], which can
|
||||
//! be constructed from a bip39 phrase, secret URI or raw seed, and used to
|
||||
//! sign and verify arbitrary messages. This crate is aligned with how Substrate's
|
||||
//! sign and verify arbitrary messages. This crate is aligned with how Bizinikiwi's
|
||||
//! `sp_core` crate constructs and signs keypairs, but is lighter on dependencies
|
||||
//! and can support compilation to WASM with the `web` feature.
|
||||
//!
|
||||
@@ -37,10 +37,10 @@ pub mod ecdsa;
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-eth")))]
|
||||
pub mod eth;
|
||||
|
||||
/// A polkadot-js account json loader.
|
||||
#[cfg(feature = "polkadot-js-compat")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "polkadot-js-compat")))]
|
||||
pub mod polkadot_js_compat;
|
||||
/// A pezkuwi-js account json loader.
|
||||
#[cfg(feature = "pezkuwi-js-compat")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "pezkuwi-js-compat")))]
|
||||
pub mod pezkuwi_js_compat;
|
||||
|
||||
// Re-export useful bits and pieces for generating a Pair from a phrase,
|
||||
// namely the Mnemonic struct.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! A Polkadot-JS account loader.
|
||||
//! A Pezkuwi-JS account loader.
|
||||
|
||||
use base64::Engine;
|
||||
use crypto_secretbox::{
|
||||
@@ -16,7 +16,7 @@ use thiserror::Error as DeriveError;
|
||||
|
||||
use crate::sr25519;
|
||||
|
||||
/// Given a JSON keypair as exported from Polkadot-JS, this returns an [`sr25519::Keypair`]
|
||||
/// Given a JSON keypair as exported from Pezkuwi-JS, this returns an [`sr25519::Keypair`]
|
||||
pub fn decrypt_json(json: &str, password: &str) -> Result<sr25519::Keypair, Error> {
|
||||
let pair_json: KeyringPairJson = serde_json::from_str(json)?;
|
||||
Ok(pair_json.decrypt(password)?)
|
||||
@@ -65,7 +65,7 @@ struct EncryptionMetadata {
|
||||
version: String,
|
||||
}
|
||||
|
||||
/// https://github.com/polkadot-js/common/blob/37fa211fdb141d4f6eb32e8f377a4651ed2d9068/packages/keyring/src/types.ts#L67
|
||||
/// https://github.com/pezkuwi-js/common/blob/37fa211fdb141d4f6eb32e8f377a4651ed2d9068/packages/keyring/src/types.ts#L67
|
||||
#[derive(Deserialize)]
|
||||
struct KeyringPairJson {
|
||||
/// The encoded string
|
||||
@@ -85,7 +85,7 @@ impl KeyringPairJson {
|
||||
/// Decrypt JSON keypair.
|
||||
fn decrypt(self, password: &str) -> Result<sr25519::Keypair, Error> {
|
||||
// Check encoding.
|
||||
// https://github.com/polkadot-js/common/blob/37fa211fdb141d4f6eb32e8f377a4651ed2d9068/packages/keyring/src/keyring.ts#L166
|
||||
// https://github.com/pezkuwi-js/common/blob/37fa211fdb141d4f6eb32e8f377a4651ed2d9068/packages/keyring/src/keyring.ts#L166
|
||||
if self.encoding.version != "3" ||
|
||||
!self.encoding.content.contains(&"pkcs8".to_owned()) ||
|
||||
!self.encoding.content.contains(&"sr25519".to_owned()) ||
|
||||
@@ -100,7 +100,7 @@ impl KeyringPairJson {
|
||||
let params: [u8; 68] = decoded[..68].try_into().map_err(|_| Error::UnsupportedEncoding)?;
|
||||
|
||||
// Extract scrypt parameters.
|
||||
// https://github.com/polkadot-js/common/blob/master/packages/util-crypto/src/scrypt/fromU8a.ts
|
||||
// https://github.com/pezkuwi-js/common/blob/master/packages/util-crypto/src/scrypt/fromU8a.ts
|
||||
let salt = ¶ms[0..32];
|
||||
let n = slice_to_u32(¶ms[32..36]);
|
||||
let p = slice_to_u32(¶ms[36..40]);
|
||||
@@ -123,13 +123,13 @@ impl KeyringPairJson {
|
||||
.expect("Key should be 32 bytes.");
|
||||
|
||||
// Decrypt keys.
|
||||
// https://github.com/polkadot-js/common/blob/master/packages/util-crypto/src/json/decryptData.ts
|
||||
// https://github.com/pezkuwi-js/common/blob/master/packages/util-crypto/src/json/decryptData.ts
|
||||
let cipher = XSalsa20Poly1305::new(&key);
|
||||
let nonce = Nonce::from_slice(¶ms[44..68]);
|
||||
let ciphertext = &decoded[68..];
|
||||
let plaintext = cipher.decrypt(nonce, ciphertext)?;
|
||||
|
||||
// https://github.com/polkadot-js/common/blob/master/packages/keyring/src/pair/decode.ts
|
||||
// https://github.com/pezkuwi-js/common/blob/master/packages/keyring/src/pair/decode.ts
|
||||
if plaintext.len() != 117 {
|
||||
return Err(Error::InvalidKeys);
|
||||
}
|
||||
@@ -22,13 +22,13 @@ use secrecy::ExposeSecret;
|
||||
use thiserror::Error as DeriveError;
|
||||
|
||||
const SECRET_KEY_LENGTH: usize = schnorrkel::keys::MINI_SECRET_KEY_LENGTH;
|
||||
const SIGNING_CTX: &[u8] = b"substrate";
|
||||
const SIGNING_CTX: &[u8] = b"bizinikiwi";
|
||||
|
||||
/// Seed bytes used to generate a key pair.
|
||||
pub type SecretKeyBytes = [u8; SECRET_KEY_LENGTH];
|
||||
|
||||
/// A signature generated by [`Keypair::sign()`]. These bytes are equivalent
|
||||
/// to a Substrate `MultiSignature::sr25519(bytes)`.
|
||||
/// to a Bizinikiwi `MultiSignature::sr25519(bytes)`.
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Signature(pub [u8; 64]);
|
||||
|
||||
@@ -39,7 +39,7 @@ impl AsRef<[u8]> for Signature {
|
||||
}
|
||||
|
||||
/// The public key for an [`Keypair`] key pair. This is equivalent to a
|
||||
/// Substrate `AccountId32`.
|
||||
/// Bizinikiwi `AccountId32`.
|
||||
pub struct PublicKey(pub [u8; 32]);
|
||||
|
||||
impl AsRef<[u8]> for PublicKey {
|
||||
@@ -125,7 +125,7 @@ impl Keypair {
|
||||
|
||||
/// Construct a keypair from a slice of bytes, corresponding to
|
||||
/// an Ed25519 expanded secret key.
|
||||
#[cfg(feature = "polkadot-js-compat")]
|
||||
#[cfg(feature = "pezkuwi-js-compat")]
|
||||
pub(crate) fn from_ed25519_bytes(bytes: &[u8]) -> Result<Self, Error> {
|
||||
let secret_key = schnorrkel::SecretKey::from_ed25519_bytes(bytes)?;
|
||||
|
||||
@@ -162,13 +162,13 @@ impl Keypair {
|
||||
}
|
||||
|
||||
/// Obtain the [`PublicKey`] part of this key pair, which can be used in calls to [`verify()`].
|
||||
/// or otherwise converted into an address. The public key bytes are equivalent to a Substrate
|
||||
/// or otherwise converted into an address. The public key bytes are equivalent to a Bizinikiwi
|
||||
/// `AccountId32`.
|
||||
pub fn public_key(&self) -> PublicKey {
|
||||
PublicKey(self.0.public.to_bytes())
|
||||
}
|
||||
|
||||
/// Sign some message. These bytes can be used directly in a Substrate
|
||||
/// Sign some message. These bytes can be used directly in a Bizinikiwi
|
||||
/// `MultiSignature::sr25519(..)`.
|
||||
pub fn sign(&self, message: &[u8]) -> Signature {
|
||||
let context = schnorrkel::signing_context(SIGNING_CTX);
|
||||
|
||||
+19
-19
@@ -1,19 +1,19 @@
|
||||
//! This example demonstrates how to use to add a custom signer implementation to `subxt`
|
||||
//! by using the signer implementation from polkadot-sdk.
|
||||
//! by using the signer implementation from pezkuwi-sdk.
|
||||
//!
|
||||
//! Similar functionality was provided by the `substrate-compat` feature in the original `subxt`
|
||||
//! Similar functionality was provided by the `bizinikiwi-compat` feature in the original `subxt`
|
||||
//! crate. which is now removed.
|
||||
|
||||
#![allow(missing_docs, unused)]
|
||||
|
||||
use sp_core::{Pair as _, sr25519};
|
||||
use pezkuwi_subxt::{Config, OnlineClient, PolkadotConfig, config::substrate::MultiAddress};
|
||||
use pezkuwi_subxt::{Config, OnlineClient, PezkuwiConfig, config::bizinikiwi::MultiAddress};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
/// A concrete PairSigner implementation which relies on `sr25519::Pair` for signing
|
||||
/// and that PolkadotConfig is the runtime configuration.
|
||||
/// and that PezkuwiConfig is the runtime configuration.
|
||||
mod pair_signer {
|
||||
use super::*;
|
||||
use sp_runtime::{
|
||||
@@ -21,14 +21,14 @@ mod pair_signer {
|
||||
traits::{IdentifyAccount, Verify},
|
||||
};
|
||||
use pezkuwi_subxt::{
|
||||
config::substrate::{AccountId32, MultiSignature},
|
||||
config::bizinikiwi::{AccountId32, MultiSignature},
|
||||
tx::Signer,
|
||||
};
|
||||
|
||||
/// A [`Signer`] implementation for [`sp_core::sr25519::Pair`].
|
||||
#[derive(Clone)]
|
||||
pub struct PairSigner {
|
||||
account_id: <PolkadotConfig as Config>::AccountId,
|
||||
account_id: <PezkuwiConfig as Config>::AccountId,
|
||||
signer: sr25519::Pair,
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ mod pair_signer {
|
||||
let account_id =
|
||||
<SpMultiSignature as Verify>::Signer::from(signer.public()).into_account();
|
||||
Self {
|
||||
// Convert `sp_core::AccountId32` to `pezkuwi_subxt::config::substrate::AccountId32`.
|
||||
// Convert `sp_core::AccountId32` to `pezkuwi_subxt::config::bizinikiwi::AccountId32`.
|
||||
//
|
||||
// This is necessary because we use `pezkuwi_subxt::config::substrate::AccountId32` and no
|
||||
// This is necessary because we use `pezkuwi_subxt::config::bizinikiwi::AccountId32` and no
|
||||
// From/Into impls are provided between `sp_core::AccountId32` because
|
||||
// `polkadot-sdk` isn't a direct dependency in subxt.
|
||||
// `pezkuwi-sdk` isn't a direct dependency in subxt.
|
||||
//
|
||||
// This can also be done by provided a wrapper type around
|
||||
// `pezkuwi_subxt::config::substrate::AccountId32` to implement such conversions but
|
||||
// `pezkuwi_subxt::config::bizinikiwi::AccountId32` to implement such conversions but
|
||||
// that also most likely requires a custom `Config` with a separate `AccountId` type
|
||||
// to work properly without additional hacks.
|
||||
account_id: AccountId32(account_id.into()),
|
||||
@@ -64,12 +64,12 @@ mod pair_signer {
|
||||
}
|
||||
}
|
||||
|
||||
impl Signer<PolkadotConfig> for PairSigner {
|
||||
fn account_id(&self) -> <PolkadotConfig as Config>::AccountId {
|
||||
impl Signer<PezkuwiConfig> for PairSigner {
|
||||
fn account_id(&self) -> <PezkuwiConfig as Config>::AccountId {
|
||||
self.account_id.clone()
|
||||
}
|
||||
|
||||
fn sign(&self, signer_payload: &[u8]) -> <PolkadotConfig as Config>::Signature {
|
||||
fn sign(&self, signer_payload: &[u8]) -> <PezkuwiConfig as Config>::Signature {
|
||||
let signature = self.signer.sign(signer_payload);
|
||||
MultiSignature::Sr25519(signature.0)
|
||||
}
|
||||
@@ -80,8 +80,8 @@ mod pair_signer {
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
// Create a new API client, configured to talk to Polkadot nodes.
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
// Create a new API client, configured to talk to Pezkuwi nodes.
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
|
||||
let signer = {
|
||||
let acc = sr25519::Pair::from_string("//Alice", None)?;
|
||||
@@ -94,7 +94,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
};
|
||||
|
||||
// Build a balance transfer extrinsic.
|
||||
let balance_transfer_tx = polkadot::tx().balances().transfer_allow_death(dest, 100_000);
|
||||
let balance_transfer_tx = pezkuwi::tx().balances().transfer_allow_death(dest, 100_000);
|
||||
|
||||
// Submit the balance transfer extrinsic from Alice, and wait for it to be successful
|
||||
// and in a finalized block. We get back the extrinsic events if all is well.
|
||||
@@ -106,7 +106,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await?;
|
||||
|
||||
// Find a Transfer event and print it.
|
||||
let transfer_event = events.find_first::<polkadot::balances::events::Transfer>()?;
|
||||
let transfer_event = events.find_first::<pezkuwi::balances::events::Transfer>()?;
|
||||
if let Some(event) = transfer_event {
|
||||
println!("Balance transfer success: {event:?}");
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client that subscribes to blocks of the Polkadot network.
|
||||
let api = OnlineClient::<PolkadotConfig>::from_url("wss://rpc.polkadot.io:443").await?;
|
||||
// Create a client that subscribes to blocks of the Pezkuwi network.
|
||||
let api = OnlineClient::<PezkuwiConfig>::from_url("wss://rpc.pezkuwi.io:443").await?;
|
||||
|
||||
// Subscribe to all finalized blocks:
|
||||
let mut blocks_sub = api.blocks().subscribe_finalized().await?;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{
|
||||
OnlineClient, PolkadotConfig,
|
||||
OnlineClient, PezkuwiConfig,
|
||||
utils::{AccountId32, MultiAddress},
|
||||
};
|
||||
|
||||
use codec::Decode;
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
use polkadot::balances::calls::types::TransferKeepAlive;
|
||||
use pezkuwi::balances::calls::types::TransferKeepAlive;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client that subscribes to blocks of the Polkadot network.
|
||||
let api = OnlineClient::<PolkadotConfig>::from_url("wss://rpc.polkadot.io:443").await?;
|
||||
// Create a client that subscribes to blocks of the Pezkuwi network.
|
||||
let api = OnlineClient::<PezkuwiConfig>::from_url("wss://rpc.pezkuwi.io:443").await?;
|
||||
|
||||
// Subscribe to all finalized blocks:
|
||||
let mut blocks_sub = api.blocks().subscribe_finalized().await?;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client to use:
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
|
||||
// Subscribe to all finalized blocks:
|
||||
let mut blocks_sub = api.blocks().subscribe_finalized().await?;
|
||||
@@ -31,7 +31,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let bytes_hex = format!("0x{}", hex::encode(ext.bytes()));
|
||||
|
||||
// See the API docs for more ways to decode extrinsics:
|
||||
let decoded_ext = ext.as_root_extrinsic::<polkadot::Call>();
|
||||
let decoded_ext = ext.as_root_extrinsic::<pezkuwi::Call>();
|
||||
|
||||
println!(" Extrinsic #{idx}:");
|
||||
println!(" Bytes: {bytes_hex}");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig, dynamic::Value};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig, dynamic::Value};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client to use:
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
|
||||
// We can query a constant by providing a tuple of the pallet and constant name. The return type
|
||||
// will be `Value` if we pass this query:
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client to use:
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
|
||||
// A query to obtain some constant:
|
||||
let constant_query = polkadot::constants().system().block_length();
|
||||
let constant_query = pezkuwi::constants().system().block_length();
|
||||
|
||||
// Obtain the value:
|
||||
let value = api.constants().at(&constant_query)?;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client to use:
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
|
||||
// Get events for the latest block:
|
||||
let events = api.events().at_latest().await?;
|
||||
@@ -29,7 +29,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
for event in events.iter() {
|
||||
let event = event?;
|
||||
|
||||
if let Ok(ev) = event.as_root_event::<polkadot::Event>() {
|
||||
if let Ok(ev) = event.as_root_event::<pezkuwi::Event>() {
|
||||
println!("{ev:?}");
|
||||
} else {
|
||||
println!("<Cannot decode event>");
|
||||
@@ -37,7 +37,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
// Or we can look for specific events which match our statically defined ones:
|
||||
let transfer_event = events.find_first::<polkadot::balances::events::Transfer>()?;
|
||||
let transfer_event = events.find_first::<pezkuwi::balances::events::Transfer>()?;
|
||||
if let Some(ev) = transfer_event {
|
||||
println!(" - Balance transfer success: value: {:?}", ev.amount);
|
||||
} else {
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
#![allow(missing_docs)]
|
||||
use futures::StreamExt;
|
||||
use pezkuwi_subxt::{PolkadotConfig, client::OnlineClient, lightclient::LightClient};
|
||||
use pezkuwi_subxt::{PezkuwiConfig, client::OnlineClient, lightclient::LightClient};
|
||||
|
||||
// Generate an interface that we can use from the node's metadata.
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
const POLKADOT_SPEC: &str = include_str!("../../artifacts/demo_chain_specs/polkadot.json");
|
||||
const POLKADOT_SPEC: &str = include_str!("../../artifacts/demo_chain_specs/pezkuwi.json");
|
||||
const ASSET_HUB_SPEC: &str =
|
||||
include_str!("../../artifacts/demo_chain_specs/polkadot_asset_hub.json");
|
||||
include_str!("../../artifacts/demo_chain_specs/pezkuwi_asset_hub.json");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// The lightclient logs are informative:
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
// Instantiate a light client with the Polkadot relay chain,
|
||||
// Instantiate a light client with the Pezkuwi relay chain,
|
||||
// and connect it to Asset Hub, too.
|
||||
let (lightclient, polkadot_rpc) = LightClient::relay_chain(POLKADOT_SPEC)?;
|
||||
let (lightclient, pezkuwi_rpc) = LightClient::relay_chain(POLKADOT_SPEC)?;
|
||||
let asset_hub_rpc = lightclient.parachain(ASSET_HUB_SPEC)?;
|
||||
|
||||
// Create Subxt clients from these Smoldot backed RPC clients.
|
||||
let polkadot_api = OnlineClient::<PolkadotConfig>::from_rpc_client(polkadot_rpc).await?;
|
||||
let asset_hub_api = OnlineClient::<PolkadotConfig>::from_rpc_client(asset_hub_rpc).await?;
|
||||
let pezkuwi_api = OnlineClient::<PezkuwiConfig>::from_rpc_client(pezkuwi_rpc).await?;
|
||||
let asset_hub_api = OnlineClient::<PezkuwiConfig>::from_rpc_client(asset_hub_rpc).await?;
|
||||
|
||||
// Use them!
|
||||
let polkadot_sub = polkadot_api
|
||||
let pezkuwi_sub = pezkuwi_api
|
||||
.blocks()
|
||||
.subscribe_finalized()
|
||||
.await?
|
||||
.map(|block| ("Polkadot", block));
|
||||
.map(|block| ("Pezkuwi", block));
|
||||
let parachain_sub = asset_hub_api
|
||||
.blocks()
|
||||
.subscribe_finalized()
|
||||
.await?
|
||||
.map(|block| ("AssetHub", block));
|
||||
|
||||
let mut stream_combinator = futures::stream::select(polkadot_sub, parachain_sub);
|
||||
let mut stream_combinator = futures::stream::select(pezkuwi_sub, parachain_sub);
|
||||
|
||||
while let Some((chain, block)) = stream_combinator.next().await {
|
||||
let block = block?;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{
|
||||
PolkadotConfig,
|
||||
PezkuwiConfig,
|
||||
client::OnlineClient,
|
||||
lightclient::{ChainConfig, LightClient},
|
||||
utils::fetch_chainspec_from_rpc_node,
|
||||
};
|
||||
|
||||
// Generate an interface that we can use from the node's metadata.
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -24,7 +24,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// to the local node.
|
||||
//
|
||||
// The `12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp` is the P2P address
|
||||
// from a local polkadot node starting with
|
||||
// from a local pezkuwi node starting with
|
||||
// `--node-key 0000000000000000000000000000000000000000000000000000000000000001`
|
||||
let chain_config = ChainConfig::chain_spec(chain_spec.get()).set_bootnodes([
|
||||
"/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp",
|
||||
@@ -32,11 +32,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Start the light client up, establishing a connection to the local node.
|
||||
let (_light_client, chain_rpc) = LightClient::relay_chain(chain_config)?;
|
||||
let api = OnlineClient::<PolkadotConfig>::from_rpc_client(chain_rpc).await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::from_rpc_client(chain_rpc).await?;
|
||||
|
||||
// Build a balance transfer extrinsic.
|
||||
let dest = dev::bob().public_key().into();
|
||||
let balance_transfer_tx = polkadot::tx().balances().transfer_allow_death(dest, 10_000);
|
||||
let balance_transfer_tx = pezkuwi::tx().balances().transfer_allow_death(dest, 10_000);
|
||||
|
||||
// Submit the balance transfer extrinsic from Alice, and wait for it to be successful
|
||||
// and in a finalized block. We get back the extrinsic events if all is well.
|
||||
@@ -49,7 +49,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await?;
|
||||
|
||||
// Find a Transfer event and print it.
|
||||
let transfer_event = events.find_first::<polkadot::balances::events::Transfer>()?;
|
||||
let transfer_event = events.find_first::<pezkuwi::balances::events::Transfer>()?;
|
||||
if let Some(event) = transfer_event {
|
||||
println!("Balance transfer success: {event:?}");
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{
|
||||
OnlineClient, PolkadotConfig,
|
||||
OnlineClient, PezkuwiConfig,
|
||||
backend::{legacy::LegacyRpcMethods, rpc::RpcClient},
|
||||
config::DefaultExtrinsicParamsBuilder as Params,
|
||||
};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -15,10 +15,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let rpc_client = RpcClient::from_url("ws://127.0.0.1:9944").await?;
|
||||
|
||||
// Use this to construct our RPC methods:
|
||||
let rpc = LegacyRpcMethods::<PolkadotConfig>::new(rpc_client.clone());
|
||||
let rpc = LegacyRpcMethods::<PezkuwiConfig>::new(rpc_client.clone());
|
||||
|
||||
// We can use the same client to drive our full Subxt interface too:
|
||||
let api = OnlineClient::<PolkadotConfig>::from_rpc_client(rpc_client.clone()).await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::from_rpc_client(rpc_client.clone()).await?;
|
||||
|
||||
// Now, we can make some RPC calls using some legacy RPC methods.
|
||||
println!(
|
||||
@@ -41,7 +41,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let ext_params = Params::new().mortal(8).nonce(current_nonce).build();
|
||||
|
||||
let balance_transfer = polkadot::tx()
|
||||
let balance_transfer = pezkuwi::tx()
|
||||
.balances()
|
||||
.transfer_allow_death(bob.public_key().into(), 1_000_000);
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{OnlineClient, config::PolkadotConfig, utils::AccountId32};
|
||||
use pezkuwi_subxt::{OnlineClient, config::PezkuwiConfig, utils::AccountId32};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client to use:
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
|
||||
// Create a "dynamic" runtime API payload that calls the
|
||||
// `AccountNonceApi_account_nonce` function. We could use the
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{
|
||||
OnlineClient, PolkadotConfig,
|
||||
OnlineClient, PezkuwiConfig,
|
||||
ext::{
|
||||
codec::{Compact, Decode},
|
||||
frame_metadata::RuntimeMetadataPrefixed,
|
||||
},
|
||||
};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client to use:
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
|
||||
// Use runtime APIs at the latest block:
|
||||
let runtime_apis = api.runtime_api().at_latest().await?;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{OnlineClient, config::PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, config::PezkuwiConfig};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client to use:
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
|
||||
// Create a runtime API payload that calls into
|
||||
// `AccountNonceApi_account_nonce` function.
|
||||
let account = dev::alice().public_key().into();
|
||||
let runtime_api_call = polkadot::apis().account_nonce_api().account_nonce(account);
|
||||
let runtime_api_call = pezkuwi::apis().account_nonce_api().account_nonce(account);
|
||||
|
||||
// Submit the call and get back a result.
|
||||
let nonce = api.runtime_api().at_latest().await?.call(runtime_api_call).await;
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use pezkuwi_subxt::{
|
||||
OnlineClient, PolkadotConfig,
|
||||
OnlineClient, PezkuwiConfig,
|
||||
backend::rpc::{RawRpcFuture, RawRpcSubscription, RawValue, RpcClient, RpcClientT},
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Pass this into our OnlineClient to instantiate it. This will lead to some
|
||||
// RPC calls being made to fetch chain details/metadata, which will immediately
|
||||
// fail..
|
||||
let _ = OnlineClient::<PolkadotConfig>::from_rpc_client(rpc_client).await;
|
||||
let _ = OnlineClient::<PezkuwiConfig>::from_rpc_client(rpc_client).await;
|
||||
|
||||
// But, we can see that the calls were made via our custom RPC client:
|
||||
println!("Log of calls made:\n\n{}", log.lock().unwrap().as_str());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{
|
||||
OfflineClient, config::PolkadotConfig, ext::codec::Decode, metadata::Metadata, utils::H256,
|
||||
OfflineClient, config::PezkuwiConfig, ext::codec::Decode, metadata::Metadata, utils::H256,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -14,19 +14,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
H256::from_slice(&bytes)
|
||||
};
|
||||
|
||||
// 2. A runtime version (system_version constant on a Substrate node has these):
|
||||
// 2. A runtime version (system_version constant on a Bizinikiwi node has these):
|
||||
let runtime_version =
|
||||
pezkuwi_subxt::client::RuntimeVersion { spec_version: 9370, transaction_version: 20 };
|
||||
|
||||
// 3. Metadata (I'll load it from the downloaded metadata, but you can use `subxt metadata >
|
||||
// file.scale` to download it):
|
||||
let metadata = {
|
||||
let bytes = std::fs::read("./artifacts/polkadot_metadata_small.scale").unwrap();
|
||||
let bytes = std::fs::read("./artifacts/pezkuwi_metadata_small.scale").unwrap();
|
||||
Metadata::decode(&mut &*bytes).unwrap()
|
||||
};
|
||||
|
||||
// Create an offline client using the details obtained above:
|
||||
let _api = OfflineClient::<PolkadotConfig>::new(genesis_hash, runtime_version, metadata);
|
||||
let _api = OfflineClient::<PezkuwiConfig>::new(genesis_hash, runtime_version, metadata);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::config::{
|
||||
Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, PolkadotConfig, SubstrateConfig,
|
||||
Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, PezkuwiConfig, BizinikiwConfig,
|
||||
};
|
||||
|
||||
#[pezkuwi_subxt::subxt(
|
||||
runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
derive_for_type(
|
||||
path = "staging_xcm::v3::multilocation::MultiLocation",
|
||||
derive = "Clone, codec::Encode",
|
||||
@@ -21,11 +21,11 @@ use runtime::runtime_types::{
|
||||
pub enum AssetHubConfig {}
|
||||
|
||||
impl Config for AssetHubConfig {
|
||||
type AccountId = <SubstrateConfig as Config>::AccountId;
|
||||
type Address = <PolkadotConfig as Config>::Address;
|
||||
type Signature = <SubstrateConfig as Config>::Signature;
|
||||
type Hasher = <SubstrateConfig as Config>::Hasher;
|
||||
type Header = <SubstrateConfig as Config>::Header;
|
||||
type AccountId = <BizinikiwConfig as Config>::AccountId;
|
||||
type Address = <PezkuwiConfig as Config>::Address;
|
||||
type Signature = <BizinikiwConfig as Config>::Signature;
|
||||
type Hasher = <BizinikiwConfig as Config>::Hasher;
|
||||
type Header = <BizinikiwConfig as Config>::Header;
|
||||
type ExtrinsicParams = DefaultExtrinsicParams<AssetHubConfig>;
|
||||
// Here we use the MultiLocation from the metadata as a part of the config:
|
||||
// The `ChargeAssetTxPayment` signed extension that is part of the ExtrinsicParams above, now
|
||||
|
||||
@@ -9,7 +9,7 @@ use pezkuwi_subxt::{
|
||||
},
|
||||
};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale")]
|
||||
pub mod runtime {}
|
||||
|
||||
// We don't need to construct this at runtime,
|
||||
@@ -20,8 +20,8 @@ impl Config for CustomConfig {
|
||||
type AccountId = pezkuwi_subxt::utils::AccountId32;
|
||||
type Address = pezkuwi_subxt::utils::MultiAddress<Self::AccountId, ()>;
|
||||
type Signature = pezkuwi_subxt::utils::MultiSignature;
|
||||
type Hasher = pezkuwi_subxt::config::substrate::BlakeTwo256;
|
||||
type Header = pezkuwi_subxt::config::substrate::SubstrateHeader<u32, Self::Hasher>;
|
||||
type Hasher = pezkuwi_subxt::config::bizinikiwi::BlakeTwo256;
|
||||
type Header = pezkuwi_subxt::config::bizinikiwi::BizinikiwiHeader<u32, Self::Hasher>;
|
||||
type ExtrinsicParams = CustomExtrinsicParams<Self>;
|
||||
type AssetId = u32;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use pezkuwi_subxt::{
|
||||
},
|
||||
};
|
||||
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod runtime {}
|
||||
|
||||
// We don't need to construct this at runtime,
|
||||
@@ -23,8 +23,8 @@ impl Config for CustomConfig {
|
||||
type AccountId = pezkuwi_subxt::utils::AccountId32;
|
||||
type Address = pezkuwi_subxt::utils::MultiAddress<Self::AccountId, ()>;
|
||||
type Signature = pezkuwi_subxt::utils::MultiSignature;
|
||||
type Hasher = pezkuwi_subxt::config::substrate::BlakeTwo256;
|
||||
type Header = pezkuwi_subxt::config::substrate::SubstrateHeader<u32, Self::Hasher>;
|
||||
type Hasher = pezkuwi_subxt::config::bizinikiwi::BlakeTwo256;
|
||||
type Header = pezkuwi_subxt::config::bizinikiwi::BizinikiwiHeader<u32, Self::Hasher>;
|
||||
type ExtrinsicParams = transaction_extensions::AnyOf<
|
||||
Self,
|
||||
(
|
||||
|
||||
@@ -10,13 +10,13 @@ use std::time::Duration;
|
||||
|
||||
use futures::StreamExt;
|
||||
use pezkuwi_subxt::{
|
||||
OnlineClient, PolkadotConfig,
|
||||
OnlineClient, PezkuwiConfig,
|
||||
backend::rpc::reconnecting_rpc_client::{ExponentialBackoff, RpcClient},
|
||||
};
|
||||
|
||||
// Generate an interface that we can use from the node's metadata.
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_small.scale")]
|
||||
pub mod pezkuwi {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -43,15 +43,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// use pezkuwi_subxt::OnlineClient;
|
||||
//
|
||||
// let backend = ChainHeadBackend::builder().build_with_background_task(RpcClient::new(rpc.clone()));
|
||||
// let api: OnlineClient<PolkadotConfig> = OnlineClient::from_backend(Arc::new(backend)).await?;
|
||||
// let api: OnlineClient<PezkuwiConfig> = OnlineClient::from_backend(Arc::new(backend)).await?;
|
||||
// ```
|
||||
|
||||
let api: OnlineClient<PolkadotConfig> = OnlineClient::from_rpc_client(rpc.clone()).await?;
|
||||
let api: OnlineClient<PezkuwiConfig> = OnlineClient::from_rpc_client(rpc.clone()).await?;
|
||||
|
||||
// Run for at most 100 blocks and print a bunch of information about it.
|
||||
//
|
||||
// The subscription is automatically re-started when the RPC client has reconnected.
|
||||
// You can test that by stopping the polkadot node and restarting it.
|
||||
// You can test that by stopping the pezkuwi node and restarting it.
|
||||
let mut blocks_sub = api.blocks().subscribe_finalized().await?.take(100);
|
||||
|
||||
while let Some(block) = blocks_sub.next().await {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user