mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 14:41:02 +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:
+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 {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
use futures::StreamExt;
|
||||
use pezkuwi_subxt::{
|
||||
OnlineClient, PolkadotConfig,
|
||||
OnlineClient, PezkuwiConfig,
|
||||
backend::{
|
||||
chain_head::{ChainHeadBackend, ChainHeadBackendBuilder},
|
||||
rpc::RpcClient,
|
||||
@@ -12,15 +12,15 @@ use pezkuwi_subxt::{
|
||||
};
|
||||
|
||||
// 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>> {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let rpc = RpcClient::from_url("ws://localhost:9944".to_string()).await?;
|
||||
let backend: ChainHeadBackend<PolkadotConfig> =
|
||||
let backend: ChainHeadBackend<PezkuwiConfig> =
|
||||
ChainHeadBackendBuilder::default().build_with_background_driver(rpc.clone());
|
||||
let api = OnlineClient::from_backend(std::sync::Arc::new(backend)).await?;
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
// 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>> {
|
||||
// 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 account = dev::alice().public_key().into();
|
||||
|
||||
// Build a storage query to access account information.
|
||||
let storage_query = polkadot::storage().system().account();
|
||||
let storage_query = pezkuwi::storage().system().account();
|
||||
|
||||
// Use that query to access a storage entry, fetch a result and decode the value.
|
||||
// The static address knows that fetching requires a tuple of one value, an
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{
|
||||
OnlineClient, PolkadotConfig,
|
||||
OnlineClient, PezkuwiConfig,
|
||||
dynamic::{At, Value},
|
||||
utils::AccountId32,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// 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?;
|
||||
|
||||
// Build a dynamic storage query to access account information.
|
||||
// here, we assume that there is one value to provide at this entry
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig, ext::futures::StreamExt};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig, ext::futures::StreamExt};
|
||||
|
||||
// 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>> {
|
||||
// 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?;
|
||||
|
||||
// Build a storage query to access account information. Same as if we were
|
||||
// fetching a single value from this entry.
|
||||
let storage_query = polkadot::storage().system().account();
|
||||
let storage_query = pezkuwi::storage().system().account();
|
||||
|
||||
// Use that query to access a storage entry, iterate over it and decode values.
|
||||
let client_at = api.storage().at_latest().await?;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt::{
|
||||
OnlineClient, PolkadotConfig,
|
||||
OnlineClient, PezkuwiConfig,
|
||||
dynamic::{At, Value},
|
||||
ext::futures::StreamExt,
|
||||
utils::AccountId32,
|
||||
@@ -8,8 +8,8 @@ use pezkuwi_subxt::{
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// 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?;
|
||||
|
||||
// Build a dynamic storage query to access account information.
|
||||
// here, we assume that there is one value to provide at this entry
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
// 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>> {
|
||||
// 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?;
|
||||
|
||||
// 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.
|
||||
@@ -26,7 +26,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,4 +1,4 @@
|
||||
//! Example to use subxt to talk to substrate-based nodes with ethereum accounts
|
||||
//! Example to use subxt to talk to bizinikiwi-based nodes with ethereum accounts
|
||||
//! which is not the default for subxt which is why we need to provide a custom config.
|
||||
//!
|
||||
//! This example requires to run a local frontier/moonbeam node to work.
|
||||
@@ -18,10 +18,10 @@ impl pezkuwi_subxt::Config for EthRuntimeConfig {
|
||||
type AccountId = AccountId20;
|
||||
type Address = AccountId20;
|
||||
type Signature = Signature;
|
||||
type Hasher = pezkuwi_subxt::config::substrate::BlakeTwo256;
|
||||
type Hasher = pezkuwi_subxt::config::bizinikiwi::BlakeTwo256;
|
||||
type Header =
|
||||
pezkuwi_subxt::config::substrate::SubstrateHeader<u32, pezkuwi_subxt::config::substrate::BlakeTwo256>;
|
||||
type ExtrinsicParams = pezkuwi_subxt::config::SubstrateExtrinsicParams<Self>;
|
||||
pezkuwi_subxt::config::bizinikiwi::BizinikiwiHeader<u32, pezkuwi_subxt::config::bizinikiwi::BlakeTwo256>;
|
||||
type ExtrinsicParams = pezkuwi_subxt::config::BizinikiwiExtrinsicParams<Self>;
|
||||
type AssetId = u32;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
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>> {
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
|
||||
// Prepare some extrinsics. These are boxed so that they can live alongside each other.
|
||||
let txs = [dynamic_remark(), balance_transfer(), remark()];
|
||||
@@ -28,11 +28,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
fn balance_transfer() -> Box<dyn pezkuwi_subxt::tx::Payload> {
|
||||
let dest = dev::bob().public_key().into();
|
||||
Box::new(polkadot::tx().balances().transfer_allow_death(dest, 10_000))
|
||||
Box::new(pezkuwi::tx().balances().transfer_allow_death(dest, 10_000))
|
||||
}
|
||||
|
||||
fn remark() -> Box<dyn pezkuwi_subxt::tx::Payload> {
|
||||
Box::new(polkadot::tx().system().remark(vec![1, 2, 3, 4, 5]))
|
||||
Box::new(pezkuwi::tx().system().remark(vec![1, 2, 3, 4, 5]))
|
||||
}
|
||||
|
||||
fn dynamic_remark() -> Box<dyn pezkuwi_subxt::tx::Payload> {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
|
||||
type BoxedError = Box<dyn std::error::Error + Send + Sync + 'static>;
|
||||
|
||||
#[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<(), BoxedError> {
|
||||
@@ -16,11 +16,11 @@ async fn main() -> Result<(), BoxedError> {
|
||||
}
|
||||
|
||||
async fn signing_example() -> Result<(), BoxedError> {
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
let api = OnlineClient::<PezkuwiConfig>::new().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);
|
||||
|
||||
let alice = dev::alice();
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{OnlineClient, PolkadotConfig, tx::TxStatus};
|
||||
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig, tx::TxStatus};
|
||||
|
||||
// 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>> {
|
||||
// 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?;
|
||||
|
||||
// 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 then monitor the
|
||||
// progress of it.
|
||||
@@ -35,7 +35,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let events = in_block.wait_for_success().await?;
|
||||
// We can look for events (this uses the static interface; we can also iterate
|
||||
// over them and dynamically decode them):
|
||||
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,20 +1,20 @@
|
||||
#![allow(missing_docs)]
|
||||
use pezkuwi_subxt_signer::sr25519::dev;
|
||||
use pezkuwi_subxt::{
|
||||
OnlineClient, PolkadotConfig, config::polkadot::PolkadotExtrinsicParamsBuilder as Params,
|
||||
OnlineClient, PezkuwiConfig, config::pezkuwi::PezkuwiExtrinsicParamsBuilder 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>> {
|
||||
// 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?;
|
||||
|
||||
// Build a balance transfer extrinsic.
|
||||
let dest = dev::bob().public_key().into();
|
||||
let tx = polkadot::tx().balances().transfer_allow_death(dest, 10_000);
|
||||
let tx = pezkuwi::tx().balances().transfer_allow_death(dest, 10_000);
|
||||
|
||||
// Configure the transaction parameters; we give a small tip and set the
|
||||
// transaction to live for 32 blocks from the `latest_block` above.
|
||||
|
||||
@@ -222,7 +222,7 @@ impl<Hash> Stream for FollowStream<Hash> {
|
||||
#[cfg(test)]
|
||||
pub(super) mod test_utils {
|
||||
use super::*;
|
||||
use crate::config::substrate::H256;
|
||||
use crate::config::bizinikiwi::H256;
|
||||
use pezkuwi_subxt_rpcs::methods::chain_head::{
|
||||
BestBlockChanged, Finalized, Initialized, NewBlock,
|
||||
};
|
||||
|
||||
@@ -463,7 +463,7 @@ pub(super) mod test_utils {
|
||||
super::follow_stream::{FollowStream, test_utils::test_stream_getter},
|
||||
*,
|
||||
};
|
||||
use crate::config::substrate::H256;
|
||||
use crate::config::bizinikiwi::H256;
|
||||
|
||||
pub type UnpinRx<H> = std::sync::mpsc::Receiver<(H, Arc<str>)>;
|
||||
|
||||
@@ -552,7 +552,7 @@ mod test {
|
||||
test_utils::{assert_from_unpin_rx, ev_new_block_ref, test_unpin_stream_getter},
|
||||
*,
|
||||
};
|
||||
use crate::config::substrate::H256;
|
||||
use crate::config::bizinikiwi::H256;
|
||||
|
||||
#[tokio::test]
|
||||
async fn hands_back_blocks() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! This module will expose a backend implementation based on the new APIs
|
||||
//! described at <https://github.com/paritytech/json-rpc-interface-spec/>. See
|
||||
//! described at <https://github.com/pezkuwichain/json-rpc-interface-spec/>. See
|
||||
//! [`rpc_methods`] for the raw API calls.
|
||||
//!
|
||||
//! # Warning
|
||||
@@ -539,7 +539,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
||||
&self,
|
||||
_hasher: T::Hasher,
|
||||
) -> Result<StreamOfResults<(T::Header, BlockRef<HashFor<T>>)>, BackendError> {
|
||||
// TODO: https://github.com/paritytech/subxt/issues/1568
|
||||
// TODO: https://github.com/pezkuwichain/subxt/issues/1568
|
||||
//
|
||||
// It's possible that blocks may be silently missed if
|
||||
// a reconnection occurs because it's restarted by the unstable backend.
|
||||
@@ -557,7 +557,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
||||
&self,
|
||||
_hasher: T::Hasher,
|
||||
) -> Result<StreamOfResults<(T::Header, BlockRef<HashFor<T>>)>, BackendError> {
|
||||
// TODO: https://github.com/paritytech/subxt/issues/1568
|
||||
// TODO: https://github.com/pezkuwichain/subxt/issues/1568
|
||||
//
|
||||
// It's possible that blocks may be silently missed if
|
||||
// a reconnection occurs because it's restarted by the unstable backend.
|
||||
|
||||
@@ -508,11 +508,11 @@ impl<T: Config> Stream for StorageFetchDescendantKeysStream<T> {
|
||||
keys.first() == this.pagination_start_key.as_ref()
|
||||
{
|
||||
// Currently, Smoldot returns the "start key" as the first key in the
|
||||
// input (see https://github.com/smol-dot/smoldot/issues/1692), whereas Substrate doesn't.
|
||||
// input (see https://github.com/smol-dot/smoldot/issues/1692), whereas Bizinikiwi doesn't.
|
||||
// We don't expect the start key to be returned either (since it was the
|
||||
// last key of prev iteration), so remove it if we see it. This
|
||||
// `remove()` method isn't very efficient but this will be a non
|
||||
// issue with the RPC V2 APIs or if Smoldot aligns with Substrate
|
||||
// issue with the RPC V2 APIs or if Smoldot aligns with Bizinikiwi
|
||||
// anyway.
|
||||
keys.remove(0);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ pub mod rpc {
|
||||
/// use std::time::Duration;
|
||||
/// use futures::StreamExt;
|
||||
/// use pezkuwi_subxt::backend::rpc::reconnecting_rpc_client::{RpcClient, ExponentialBackoff};
|
||||
/// use pezkuwi_subxt::{OnlineClient, PolkadotConfig};
|
||||
/// use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// async fn main() {
|
||||
@@ -49,7 +49,7 @@ pub mod rpc {
|
||||
/// .await
|
||||
/// .unwrap();
|
||||
///
|
||||
/// let subxt_client: OnlineClient<PolkadotConfig> = OnlineClient::from_rpc_client(rpc.clone()).await.unwrap();
|
||||
/// let subxt_client: OnlineClient<PezkuwiConfig> = OnlineClient::from_rpc_client(rpc.clone()).await.unwrap();
|
||||
/// let mut blocks_sub = subxt_client.blocks().subscribe_finalized().await.unwrap();
|
||||
///
|
||||
/// while let Some(block) = blocks_sub.next().await {
|
||||
@@ -420,8 +420,8 @@ mod test {
|
||||
type AccountId = crate::utils::AccountId32;
|
||||
type Address = crate::utils::MultiAddress<Self::AccountId, ()>;
|
||||
type Signature = crate::utils::MultiSignature;
|
||||
type Hasher = crate::config::substrate::BlakeTwo256;
|
||||
type Header = crate::config::substrate::SubstrateHeader<u32, Self::Hasher>;
|
||||
type Hasher = crate::config::bizinikiwi::BlakeTwo256;
|
||||
type Header = crate::config::bizinikiwi::BizinikiwiHeader<u32, Self::Hasher>;
|
||||
type ExtrinsicParams = DefaultExtrinsicParams<Self>;
|
||||
type AssetId = u32;
|
||||
}
|
||||
@@ -645,8 +645,8 @@ mod test {
|
||||
|
||||
fn runtime_spec() -> RuntimeSpec {
|
||||
let spec = serde_json::json!({
|
||||
"specName": "westend",
|
||||
"implName": "parity-westend",
|
||||
"specName": "zagros",
|
||||
"implName": "parity-zagros",
|
||||
"specVersion": 9122,
|
||||
"implVersion": 0,
|
||||
"transactionVersion": 7,
|
||||
@@ -968,7 +968,7 @@ mod test {
|
||||
}
|
||||
|
||||
// Check that the backend will resubscribe on Stop, and handle a change in subscription ID.
|
||||
// see https://github.com/paritytech/subxt/issues/1567
|
||||
// see https://github.com/pezkuwichain/subxt/issues/1567
|
||||
#[tokio::test]
|
||||
async fn stale_subscription_id_failure() {
|
||||
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
|
||||
@@ -117,7 +117,7 @@ where
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: https://github.com/paritytech/subxt/issues/1567
|
||||
// TODO: https://github.com/pezkuwichain/subxt/issues/1567
|
||||
// This is a hack because, in the event of a disconnection,
|
||||
// we may not get the correct subscription ID back on reconnecting.
|
||||
//
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
//! # The Subxt Guide
|
||||
//!
|
||||
//! Subxt is a library for interacting with Substrate based nodes. It has a focus on **sub**mitting
|
||||
//! Subxt is a library for interacting with Bizinikiwi based nodes. It has a focus on **sub**mitting
|
||||
//! e**xt**rinsics, hence the name, however it's also capable of reading blocks, storage, events and
|
||||
//! constants from a node. The aim of this guide is to explain key concepts and get you started with
|
||||
//! using Subxt.
|
||||
@@ -68,8 +68,8 @@
|
||||
#![doc = include_str!("../../examples/tx_basic.rs")]
|
||||
//! ```
|
||||
//!
|
||||
//! This example assumes that a Polkadot node is running locally (Subxt endeavors to support all
|
||||
//! recent releases). Typically, to use Subxt to talk to some custom Substrate node (for example a
|
||||
//! This example assumes that a Pezkuwi node is running locally (Subxt endeavors to support all
|
||||
//! recent releases). Typically, to use Subxt to talk to some custom Bizinikiwi node (for example a
|
||||
//! parachain node), you'll want to:
|
||||
//!
|
||||
//! 1. [Generate an interface](setup::codegen)
|
||||
@@ -100,9 +100,9 @@
|
||||
//!
|
||||
//! Some complete, self contained examples which are not a part of this guide:
|
||||
//!
|
||||
//! - [`parachain-example`](https://github.com/paritytech/subxt/tree/master/examples/parachain-example) is an example
|
||||
//! - [`parachain-example`](https://github.com/pezkuwichain/subxt/tree/master/examples/parachain-example) is an example
|
||||
//! which uses Zombienet to spawn a parachain locally, and then connects to it using Subxt.
|
||||
//! - [`wasm-example`](https://github.com/paritytech/subxt/tree/master/examples/wasm-example) is an example of writing
|
||||
//! - [`wasm-example`](https://github.com/pezkuwichain/subxt/tree/master/examples/wasm-example) is an example of writing
|
||||
//! a Rust app that contains a Yew based UI, uses Subxt to interact with a chain, and compiles to WASM in order to
|
||||
//! run entirely in the browser.
|
||||
pub mod setup;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
//! Using this macro looks something like:
|
||||
//!
|
||||
//! ```rust,no_run,standalone_crate
|
||||
//! #[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_tiny.scale")]
|
||||
//! pub mod polkadot {}
|
||||
//! #[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_tiny.scale")]
|
||||
//! pub mod pezkuwi {}
|
||||
//! ```
|
||||
//!
|
||||
//! The macro takes a path to some node metadata, and uses that to generate the interface you'll use
|
||||
|
||||
@@ -5,29 +5,29 @@
|
||||
//! `frame_system::Config` trait. For most use cases, you can just use one of the following Configs
|
||||
//! shipped with Subxt:
|
||||
//!
|
||||
//! - [`PolkadotConfig`](crate::config::PolkadotConfig) for talking to Polkadot nodes, and
|
||||
//! - [`SubstrateConfig`](crate::config::SubstrateConfig) for talking to generic nodes built with
|
||||
//! Substrate.
|
||||
//! - [`PezkuwiConfig`](crate::config::PezkuwiConfig) for talking to Pezkuwi nodes, and
|
||||
//! - [`BizinikiwConfig`](crate::config::BizinikiwConfig) for talking to generic nodes built with
|
||||
//! Bizinikiwi.
|
||||
//!
|
||||
//! # How to create a Config for a custom chain?
|
||||
//!
|
||||
//! Some chains may use config that is not compatible with our
|
||||
//! [`PolkadotConfig`](crate::config::PolkadotConfig) or
|
||||
//! [`SubstrateConfig`](crate::config::SubstrateConfig).
|
||||
//! [`PezkuwiConfig`](crate::config::PezkuwiConfig) or
|
||||
//! [`BizinikiwConfig`](crate::config::BizinikiwConfig).
|
||||
//!
|
||||
//! We now walk through creating a custom [`crate::config::Config`] for a parachain, using the
|
||||
//! ["Statemint"](https://parachains.info/details/statemint) parachain, also known as "Asset Hub", as an example. It
|
||||
//! is currently (as of 2023-06-26) deployed on Polkadot and [Kusama (as "Statemine")](https://parachains.info/details/statemine).
|
||||
//! is currently (as of 2023-06-26) deployed on Pezkuwi and [Kusama (as "Statemine")](https://parachains.info/details/statemine).
|
||||
//!
|
||||
//! To construct a valid [`crate::config::Config`] implementation, we need to find out which types
|
||||
//! to use for `AccountId`, `Hasher`, etc. For this, we need to take a look at the source code of Statemint, which is currently a part of the [Cumulus Github repository](https://github.com/paritytech/cumulus).
|
||||
//! The crate defining the asset hub runtime can be found [here](https://github.com/paritytech/cumulus/tree/master/parachains/runtimes/assets/asset-hub-polkadot).
|
||||
//! to use for `AccountId`, `Hasher`, etc. For this, we need to take a look at the source code of Statemint, which is currently a part of the [Pezpezcumulus Github repository](https://github.com/pezkuwichain/pezcumulus).
|
||||
//! The crate defining the asset hub runtime can be found [here](https://github.com/pezkuwichain/pezcumulus/tree/master/parachains/runtimes/assets/asset-hub-pezkuwi).
|
||||
//!
|
||||
//! ## `AccountId`, `Hash`, `Hasher` and `Header`
|
||||
//!
|
||||
//! For these config types, we need to find out where the parachain runtime implements the
|
||||
//! `frame_system::Config` trait. Look for a code fragment like `impl frame_system::Config for
|
||||
//! Runtime { ... }` In the source code. For Statemint it looks like [this](https://github.com/paritytech/cumulus/blob/e2b7ad2061824f490c08df27a922c64f50accd6b/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs#L179)
|
||||
//! Runtime { ... }` In the source code. For Statemint it looks like [this](https://github.com/pezkuwichain/pezcumulus/blob/e2b7ad2061824f490c08df27a922c64f50accd6b/parachains/runtimes/assets/asset-hub-pezkuwi/src/lib.rs#L179)
|
||||
//! at the time of writing. The `AccountId`, `Hash` and `Header` types of the [frame_system::pallet::Config](https://docs.rs/frame-system/latest/frame_system/pallet/trait.Config.html)
|
||||
//! correspond to the ones we want to use in our Subxt [crate::Config]. In the Case of Statemint
|
||||
//! (Asset Hub) they are:
|
||||
@@ -38,36 +38,36 @@
|
||||
//! `sp_runtime::traits::BlakeTwo256`
|
||||
//! - Header: `sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>`
|
||||
//!
|
||||
//! Subxt has its own versions of some of these types in order to avoid needing to pull in Substrate
|
||||
//! Subxt has its own versions of some of these types in order to avoid needing to pull in Bizinikiwi
|
||||
//! dependencies:
|
||||
//!
|
||||
//! - `sp_core::crypto::AccountId32` can be swapped with [`crate::utils::AccountId32`].
|
||||
//! - `sp_core::H256` is a re-export which subxt also provides as
|
||||
//! [`crate::config::substrate::H256`].
|
||||
//! [`crate::config::bizinikiwi::H256`].
|
||||
//! - `sp_runtime::traits::BlakeTwo256` can be swapped with
|
||||
//! [`crate::config::substrate::BlakeTwo256`].
|
||||
//! [`crate::config::bizinikiwi::BlakeTwo256`].
|
||||
//! - `sp_runtime::generic::Header` can be swapped with
|
||||
//! [`crate::config::substrate::SubstrateHeader`].
|
||||
//! [`crate::config::bizinikiwi::BizinikiwiHeader`].
|
||||
//!
|
||||
//! Having a look at how those types are implemented can give some clues as to how to implement
|
||||
//! other custom types that you may need to use as part of your config.
|
||||
//!
|
||||
//! ## `Address`, `Signature`
|
||||
//!
|
||||
//! A Substrate runtime is typically constructed by using the [frame_support::construct_runtime](https://docs.rs/frame-support/latest/frame_support/macro.construct_runtime.html) macro.
|
||||
//! A Bizinikiwi runtime is typically constructed by using the [frame_support::construct_runtime](https://docs.rs/frame-support/latest/frame_support/macro.construct_runtime.html) macro.
|
||||
//! In this macro, we need to specify the type of an `UncheckedExtrinsic`. Most of the time, the
|
||||
//! `UncheckedExtrinsic` will be of the type `sp_runtime::generic::UncheckedExtrinsic<Address,
|
||||
//! RuntimeCall, Signature, SignedExtra>`. The generic parameters `Address` and `Signature`
|
||||
//! specified when declaring the `UncheckedExtrinsic` type are the types for `Address` and
|
||||
//! `Signature` we should use with our [crate::Config] implementation. This information can
|
||||
//! also be obtained from the metadata (see [`frame_metadata::v15::ExtrinsicMetadata`]). In case of
|
||||
//! Statemint (Polkadot Asset Hub) we see the following types being used in `UncheckedExtrinsic`:
|
||||
//! Statemint (Pezkuwi Asset Hub) we see the following types being used in `UncheckedExtrinsic`:
|
||||
//!
|
||||
//! - Address: `sp_runtime::MultiAddress<Self::AccountId, ()>`
|
||||
//! - Signature: `sp_runtime::MultiSignature`
|
||||
//!
|
||||
//! As above, Subxt has its own versions of these types that can be used instead to avoid pulling in
|
||||
//! Substrate dependencies. Using the Subxt versions also makes interacting with generated code
|
||||
//! Bizinikiwi dependencies. Using the Subxt versions also makes interacting with generated code
|
||||
//! (which uses them in some places) a little nicer:
|
||||
//!
|
||||
//! - `sp_runtime::MultiAddress` can be swapped with [`crate::utils::MultiAddress`].
|
||||
@@ -111,7 +111,7 @@
|
||||
//! metadata (see [`frame_metadata::v15::SignedExtensionMetadata`]).
|
||||
//!
|
||||
//! For statemint, the transaction extensions look like
|
||||
//! [this](https://github.com/paritytech/cumulus/blob/d4bb2215bb28ee05159c4c7df1b3435177b5bf4e/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs#L786):
|
||||
//! [this](https://github.com/pezkuwichain/pezcumulus/blob/d4bb2215bb28ee05159c4c7df1b3435177b5bf4e/parachains/runtimes/assets/asset-hub-pezkuwi/src/lib.rs#L786):
|
||||
//!
|
||||
//! ```rust,ignore
|
||||
//! pub type SignedExtra = (
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
//! If you are only interested in finding specific extrinsics in a block, you can also [iterate over all of them](crate::blocks::Extrinsics::find),
|
||||
//! get only [the first one](crate::blocks::Extrinsics::find_first), or [the last one](crate::blocks::Extrinsics::find_last).
|
||||
//!
|
||||
//! The following example monitors `TransferKeepAlive` extrinsics on the Polkadot network.
|
||||
//! The following example monitors `TransferKeepAlive` extrinsics on the Pezkuwi network.
|
||||
//! We statically decode them and access the [tip](crate::blocks::ExtrinsicTransactionExtensions::tip()) and
|
||||
//! [account nonce](crate::blocks::ExtrinsicTransactionExtensions::nonce()) transaction extensions.
|
||||
//! ```rust,ignore
|
||||
@@ -80,9 +80,9 @@
|
||||
//! have access to a statically generated interface module that contains the relevant Rust types. You can
|
||||
//! [decode ExtrinsicDetails dynamically](crate::blocks::ExtrinsicDetails::decode_as_fields()), which gives
|
||||
//! you access to it's fields as a [scale value composite](scale_value::Composite). The following example
|
||||
//! looks for signed extrinsics on the Polkadot network and retrieves their pallet name, variant name, data
|
||||
//! looks for signed extrinsics on the Pezkuwi network and retrieves their pallet name, variant name, data
|
||||
//! fields and transaction extensions dynamically. Notice how we do not need to use code generation via the
|
||||
//! subxt macro. The only fixed component we provide is the [PolkadotConfig](crate::config::PolkadotConfig).
|
||||
//! subxt macro. The only fixed component we provide is the [PezkuwiConfig](crate::config::PezkuwiConfig).
|
||||
//! Other than that it works in a chain-agnostic way:
|
||||
//! ```rust,ignore
|
||||
#![doc = include_str!("../../../examples/block_decoding_dynamic.rs")]
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
//! We can use the statically generated interface to build constant queries:
|
||||
//!
|
||||
//! ```rust,no_run,standalone_crate
|
||||
//! #[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
|
||||
//! pub mod polkadot {}
|
||||
//! #[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale")]
|
||||
//! pub mod pezkuwi {}
|
||||
//!
|
||||
//! let constant_query = polkadot::constants().system().block_length();
|
||||
//! let constant_query = pezkuwi::constants().system().block_length();
|
||||
//! ```
|
||||
//!
|
||||
//! Alternately, we can dynamically construct a constant query. A dynamic query needs the return
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
//! # Custom Values
|
||||
//!
|
||||
//! Substrate-based chains can expose custom values in their metadata.
|
||||
//! Bizinikiwi-based chains can expose custom values in their metadata.
|
||||
//! Each of these values:
|
||||
//!
|
||||
//! - can be accessed by a unique __name__.
|
||||
@@ -29,10 +29,10 @@
|
||||
//! Dynamically accessing a custom value using a [`str`] to select which one:
|
||||
//!
|
||||
//! ```rust,ignore
|
||||
//! use pezkuwi_subxt::{OnlineClient, PolkadotConfig, ext::scale_decode::DecodeAsType};
|
||||
//! use pezkuwi_subxt::{OnlineClient, PezkuwiConfig, ext::scale_decode::DecodeAsType};
|
||||
//! use pezkuwi_subxt::dynamic::Value;
|
||||
//!
|
||||
//! let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
//! let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
//! let custom_value_client = api.custom_values();
|
||||
//! let foo: Value = custom_value_client.at("foo")?;
|
||||
//! ```
|
||||
@@ -40,7 +40,7 @@
|
||||
//! Use the [`dynamic`](crate::custom_values::dynamic) function to select the return type:
|
||||
//!
|
||||
//! ```rust,ignore
|
||||
//! use pezkuwi_subxt::{OnlineClient, PolkadotConfig, ext::scale_decode::DecodeAsType};
|
||||
//! use pezkuwi_subxt::{OnlineClient, PezkuwiConfig, ext::scale_decode::DecodeAsType};
|
||||
//!
|
||||
//! #[derive(Decode, DecodeAsType, Debug)]
|
||||
//! struct Foo {
|
||||
@@ -48,7 +48,7 @@
|
||||
//! b: bool,
|
||||
//! }
|
||||
//!
|
||||
//! let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
//! let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
//! let custom_value_client = api.custom_values();
|
||||
//! let custom_value_addr = pezkuwi_subxt::custom_values::dynamic::<Foo>("foo");
|
||||
//! let foo: Foo = custom_value_client.at(&custom_value_addr)?;
|
||||
@@ -62,7 +62,7 @@
|
||||
//!
|
||||
//! let static_address = interface::custom().foo();
|
||||
//!
|
||||
//! let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
//! let api = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
//! let custom_value_client = api.custom_values();
|
||||
//!
|
||||
//! // Now the `at()` function already decodes the value into the Foo type:
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
//! # #[tokio::main]
|
||||
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
//! use pezkuwi_subxt::client::OnlineClient;
|
||||
//! use pezkuwi_subxt::config::PolkadotConfig;
|
||||
//! use pezkuwi_subxt::config::PezkuwiConfig;
|
||||
//!
|
||||
//! // Create client:
|
||||
//! let client = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
//! let client = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
//!
|
||||
//! // Get events from the latest block (use .at() to specify a block hash):
|
||||
//! let events = client.blocks().at_latest().await?.events().await?;
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
//! ### Connecting to a local node
|
||||
//!
|
||||
//! This example connects to a local chain and submits a transaction. To run this, you first need
|
||||
//! to have a local polkadot node running using the following command:
|
||||
//! to have a local pezkuwi node running using the following command:
|
||||
//! ```text
|
||||
//! polkadot --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001
|
||||
//! pezkuwi --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001
|
||||
//! ```
|
||||
//!
|
||||
//! Then, the following code will download a chain spec from this local node, alter the bootnodes
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
//! We can use the statically generated interface to build runtime calls:
|
||||
//!
|
||||
//! ```rust,no_run,standalone_crate
|
||||
//! #[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 {}
|
||||
//!
|
||||
//! let runtime_call = polkadot::apis().metadata().metadata_versions();
|
||||
//! let runtime_call = pezkuwi::apis().metadata().metadata_versions();
|
||||
//! ```
|
||||
//!
|
||||
//! Alternately, we can dynamically construct a runtime call. The input type can be a tuple or
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
//! # Storage
|
||||
//!
|
||||
//! A Substrate based chain can be seen as a key/value database which starts off at some initial
|
||||
//! A Bizinikiwi based chain can be seen as a key/value database which starts off at some initial
|
||||
//! state, and is modified by the extrinsics in each block. This database is referred to as the
|
||||
//! node storage. With Subxt, you can query this key/value storage with the following steps:
|
||||
//!
|
||||
@@ -18,10 +18,10 @@
|
||||
//! We can use the statically generated interface to build storage queries:
|
||||
//!
|
||||
//! ```rust,no_run,standalone_crate
|
||||
//! #[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 {}
|
||||
//!
|
||||
//! let storage_query = polkadot::storage().system().account();
|
||||
//! let storage_query = pezkuwi::storage().system().account();
|
||||
//! ```
|
||||
//!
|
||||
//! Alternately, we can dynamically construct a storage query. A dynamic query needs the input
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
//! We can use the statically generated interface to build transaction payloads:
|
||||
//!
|
||||
//! ```rust,no_run,standalone_crate
|
||||
//! #[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 {}
|
||||
//!
|
||||
//! let remark = "Hello there".as_bytes().to_vec();
|
||||
//! let tx_payload = polkadot::tx().system().remark(remark);
|
||||
//! let tx_payload = pezkuwi::tx().system().remark(remark);
|
||||
//! ```
|
||||
//!
|
||||
//! > If you're not sure what types to import and use to build a given payload, you can use the
|
||||
@@ -73,18 +73,18 @@
|
||||
//! pattern.
|
||||
//!
|
||||
//! Going for 1 leads to fewer dependencies being imported and WASM compatibility out of the box via
|
||||
//! the `web` feature flag. Going for 2 is useful if you're already using the Substrate dependencies
|
||||
//! the `web` feature flag. Going for 2 is useful if you're already using the Bizinikiwi dependencies
|
||||
//! or need additional signing algorithms that `pezkuwi_subxt_signer` doesn't support, and don't
|
||||
//! care about WASM compatibility.
|
||||
//!
|
||||
//! Because 2 is more complex and require more code, we'll focus on 1 here.
|
||||
//! For 2, see the example in `subxt/examples/substrate_compat_signer.rs` how
|
||||
//! For 2, see the example in `subxt/examples/bizinikiwi_compat_signer.rs` how
|
||||
//! you can integrate things like sp_core's signer in subxt.
|
||||
//!
|
||||
//! Let's go through how to create a signer using the `pezkuwi_subxt_signer` crate:
|
||||
//!
|
||||
//! ```rust,standalone_crate
|
||||
//! use pezkuwi_subxt::config::PolkadotConfig;
|
||||
//! use pezkuwi_subxt::config::PezkuwiConfig;
|
||||
//! use std::str::FromStr;
|
||||
//!
|
||||
//! use pezkuwi_subxt_signer::{SecretUri, sr25519};
|
||||
@@ -105,11 +105,11 @@
|
||||
//! # #[tokio::main]
|
||||
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
//! use pezkuwi_subxt::client::OnlineClient;
|
||||
//! use pezkuwi_subxt::config::PolkadotConfig;
|
||||
//! use pezkuwi_subxt::config::PezkuwiConfig;
|
||||
//! use pezkuwi_subxt::dynamic::Value;
|
||||
//!
|
||||
//! // Create client:
|
||||
//! let client = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
//! let client = OnlineClient::<PezkuwiConfig>::new().await?;
|
||||
//!
|
||||
//! // Create a dummy tx payload to sign:
|
||||
//! let payload = pezkuwi_subxt::dynamic::tx("System", "remark", vec![
|
||||
|
||||
@@ -170,7 +170,7 @@ impl<T: Config> OnlineClient<T> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Fetch the metadata from substrate using the runtime API.
|
||||
/// Fetch the metadata from bizinikiwi using the runtime API.
|
||||
async fn fetch_metadata(
|
||||
backend: &dyn Backend<T>,
|
||||
block_hash: HashFor<T>,
|
||||
@@ -219,9 +219,9 @@ impl<T: Config> OnlineClient<T> {
|
||||
/// ```rust,no_run,standalone_crate
|
||||
/// # #[tokio::main]
|
||||
/// # async fn main() {
|
||||
/// use pezkuwi_subxt::{ OnlineClient, PolkadotConfig };
|
||||
/// use pezkuwi_subxt::{ OnlineClient, PezkuwiConfig };
|
||||
///
|
||||
/// let client = OnlineClient::<PolkadotConfig>::new().await.unwrap();
|
||||
/// let client = OnlineClient::<PezkuwiConfig>::new().await.unwrap();
|
||||
///
|
||||
/// // high level API.
|
||||
///
|
||||
@@ -437,7 +437,7 @@ impl<T: Config> ClientRuntimeUpdater<T> {
|
||||
let update = runtime_version_stream.next().await?;
|
||||
|
||||
// This only fails if received the runtime version is the same the current runtime
|
||||
// version which might occur because that runtime subscriptions in substrate sends
|
||||
// version which might occur because that runtime subscriptions in bizinikiwi sends
|
||||
// out the initial value when they created and not only when runtime upgrades occurs.
|
||||
// Thus, fine to ignore here as it strictly speaking isn't really an error
|
||||
let _ = self.apply_update(update);
|
||||
@@ -532,7 +532,7 @@ async fn wait_runtime_upgrade_in_finalized_block<T: Config>(
|
||||
let value = client_at
|
||||
.entry(addr)
|
||||
// The storage `system::lastRuntimeUpgrade` should always exist.
|
||||
// <https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/system/src/lib.rs#L958>
|
||||
// <https://github.com/pezkuwichain/pezkuwi-sdk/blob/master/bizinikiwi/frame/system/src/lib.rs#L958>
|
||||
.map_err(|_| RuntimeUpdaterError::CantFindSystemLastRuntimeUpgrade)?
|
||||
.fetch(())
|
||||
.await
|
||||
|
||||
@@ -45,7 +45,7 @@ impl<T: Config, Client: OfflineClientT<T>> CustomValuesClient<T, Client> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
Metadata, OfflineClient, SubstrateConfig,
|
||||
Metadata, OfflineClient, BizinikiwConfig,
|
||||
custom_values::{self, CustomValuesClient},
|
||||
};
|
||||
use codec::Encode;
|
||||
@@ -102,7 +102,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_decoding() {
|
||||
let client = OfflineClient::<SubstrateConfig>::new(
|
||||
let client = OfflineClient::<BizinikiwConfig>::new(
|
||||
Default::default(),
|
||||
RuntimeVersion { spec_version: 0, transaction_version: 0 },
|
||||
mock_metadata(),
|
||||
|
||||
+36
-36
@@ -2,7 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! Subxt is a library for interacting with Substrate based nodes. Using it looks something like
|
||||
//! Subxt is a library for interacting with Bizinikiwi based nodes. Using it looks something like
|
||||
//! this:
|
||||
//!
|
||||
//! ```rust,ignore
|
||||
@@ -54,16 +54,16 @@ pub mod view_functions;
|
||||
|
||||
/// 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.
|
||||
pub mod config {
|
||||
pub use pezkuwi_subxt_core::{
|
||||
config::{
|
||||
Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, ExtrinsicParams,
|
||||
ExtrinsicParamsEncoder, Hash, HashFor, Hasher, Header, PolkadotConfig,
|
||||
PolkadotExtrinsicParams, SubstrateConfig, SubstrateExtrinsicParams,
|
||||
TransactionExtension, polkadot, substrate, transaction_extensions,
|
||||
ExtrinsicParamsEncoder, Hash, HashFor, Hasher, Header, PezkuwiConfig,
|
||||
PezkuwiExtrinsicParams, BizinikiwConfig, BizinikiwiExtrinsicParams,
|
||||
TransactionExtension, pezkuwi, bizinikiwi, transaction_extensions,
|
||||
},
|
||||
error::ExtrinsicParamsError,
|
||||
};
|
||||
@@ -88,7 +88,7 @@ cfg_unstable_light_client! {
|
||||
// but leave most types behind their respective modules.
|
||||
pub use crate::{
|
||||
client::{OfflineClient, OnlineClient},
|
||||
config::{Config, PolkadotConfig, SubstrateConfig},
|
||||
config::{Config, PezkuwiConfig, BizinikiwConfig},
|
||||
error::Error,
|
||||
metadata::Metadata,
|
||||
};
|
||||
@@ -110,7 +110,7 @@ pub mod ext {
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a strongly typed API for interacting with a Substrate runtime from its metadata of
|
||||
/// Generate a strongly typed API for interacting with a Bizinikiwi runtime from its metadata of
|
||||
/// WASM.
|
||||
///
|
||||
/// # Metadata
|
||||
@@ -122,7 +122,7 @@ pub mod ext {
|
||||
/// # Install the CLI tool:
|
||||
/// cargo install subxt-cli
|
||||
/// # Use it to download metadata (in this case, from a node running locally)
|
||||
/// subxt metadata > polkadot_metadata.scale
|
||||
/// subxt metadata > pezkuwi_metadata.scale
|
||||
/// ```
|
||||
///
|
||||
/// Run `subxt metadata --help` for more options.
|
||||
@@ -146,9 +146,9 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,no_run,standalone_crate
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
/// runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// You can use the `$OUT_DIR` placeholder in the path to reference metadata generated at build
|
||||
@@ -158,7 +158,7 @@ pub mod ext {
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "$OUT_DIR/metadata.scale",
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// ## Using a WASM runtime via `runtime_path = "..."`
|
||||
@@ -169,9 +169,9 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_path = "../artifacts/westend_runtime.wasm",
|
||||
/// runtime_path = "../artifacts/zagros_runtime.wasm",
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// You can also use the `$OUT_DIR` placeholder in the path to reference WASM files generated
|
||||
@@ -181,7 +181,7 @@ pub mod ext {
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_path = "$OUT_DIR/runtime.wasm",
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// ## Connecting to a node to download metadata via `runtime_metadata_insecure_url = "..."`
|
||||
@@ -199,9 +199,9 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443"
|
||||
/// runtime_metadata_insecure_url = "wss://rpc.pezkuwi.io:443"
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// # Configuration
|
||||
@@ -217,10 +217,10 @@ pub mod ext {
|
||||
/// # pub mod path { pub mod to { pub use pezkuwi_subxt_core; } }
|
||||
/// # fn main() {}
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
/// runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
/// crate = "crate::path::to::pezkuwi_subxt_core"
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// This is useful if you write a library which uses this macro, but don't want to force users
|
||||
@@ -233,10 +233,10 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,standalone_crate
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
/// runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
/// substitute_type(path = "sp_arithmetic::per_things::Perbill", with = "crate::Foo")
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
///
|
||||
/// # #[derive(
|
||||
/// # scale_encode::EncodeAsType,
|
||||
@@ -271,13 +271,13 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,no_run,standalone_crate
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
/// runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
/// substitute_type(
|
||||
/// path = "sp_runtime::multiaddress::MultiAddress<A, B>",
|
||||
/// with = "::pezkuwi_subxt::utils::Static<sp_runtime::MultiAddress<A, B>>"
|
||||
/// )
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// The above is also an example of using the [`crate::utils::Static`] type to wrap some type
|
||||
@@ -292,10 +292,10 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,no_run,standalone_crate
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
/// runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
/// derive_for_all_types = "Eq, PartialEq"
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// Any substituted types (including the default substitutes) must also implement these traits
|
||||
@@ -309,12 +309,12 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,no_run,standalone_crate
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
/// runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
/// derive_for_all_types = "Eq, PartialEq",
|
||||
/// derive_for_type(path = "frame_support::PalletId", derive = "Ord, PartialOrd"),
|
||||
/// derive_for_type(path = "sp_runtime::ModuleError", derive = "Hash"),
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// ## `generate_docs`
|
||||
@@ -324,10 +324,10 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,no_run,standalone_crate
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
/// runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
/// generate_docs
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// ## `runtime_types_only`
|
||||
@@ -338,10 +338,10 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,no_run,standalone_crate
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
/// runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
/// runtime_types_only
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// ## `no_default_derives`
|
||||
@@ -351,12 +351,12 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,no_run,standalone_crate
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
|
||||
/// runtime_metadata_path = "../artifacts/pezkuwi_metadata_full.scale",
|
||||
/// runtime_types_only,
|
||||
/// no_default_derives,
|
||||
/// derive_for_all_types="codec::Encode, codec::Decode"
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
///
|
||||
/// **Note**: At the moment, you must derive at least one of `codec::Encode` or `codec::Decode`
|
||||
@@ -375,9 +375,9 @@ pub mod ext {
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// #[pezkuwi_subxt::subxt(
|
||||
/// runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443",
|
||||
/// runtime_metadata_insecure_url = "wss://rpc.pezkuwi.io:443",
|
||||
/// unstable_metadata
|
||||
/// )]
|
||||
/// mod polkadot {}
|
||||
/// mod pezkuwi {}
|
||||
/// ```
|
||||
pub use pezkuwi_subxt_macro::subxt;
|
||||
|
||||
@@ -557,7 +557,7 @@ where
|
||||
) -> Result<ValidationResult, ExtrinsicError> {
|
||||
let block_hash = at.into().hash();
|
||||
|
||||
// Approach taken from https://github.com/paritytech/json-rpc-interface-spec/issues/55.
|
||||
// Approach taken from https://github.com/pezkuwichain/json-rpc-interface-spec/issues/55.
|
||||
let mut params = Vec::with_capacity(8 + self.encoded().len() + 8);
|
||||
2u8.encode_to(&mut params);
|
||||
params.extend(self.encoded().iter());
|
||||
@@ -586,7 +586,7 @@ where
|
||||
.await
|
||||
.map_err(ExtrinsicError::CannotGetLatestFinalizedBlock)?;
|
||||
|
||||
// destructuring RuntimeDispatchInfo, see type information <https://paritytech.github.io/substrate/master/pallet_transaction_payment_rpc_runtime_api/struct.RuntimeDispatchInfo.html>
|
||||
// destructuring RuntimeDispatchInfo, see type information <https://pezkuwichain.github.io/bizinikiwi/master/pallet_transaction_payment_rpc_runtime_api/struct.RuntimeDispatchInfo.html>
|
||||
// data layout: {weight_ref_time: Compact<u64>, weight_proof_size: Compact<u64>, class: u8,
|
||||
// partial_fee: u128}
|
||||
let (_, _, _, partial_fee) = self
|
||||
@@ -648,7 +648,7 @@ impl ValidationResult {
|
||||
#[allow(clippy::get_first)]
|
||||
fn try_from_bytes(bytes: Vec<u8>) -> Result<ValidationResult, ExtrinsicError> {
|
||||
// TaggedTransactionQueue_validate_transaction returns this:
|
||||
// https://github.com/paritytech/substrate/blob/0cdf7029017b70b7c83c21a4dc0aa1020e7914f6/primitives/runtime/src/transaction_validity.rs#L210
|
||||
// https://github.com/pezkuwichain/bizinikiwi/blob/0cdf7029017b70b7c83c21a4dc0aa1020e7914f6/primitives/runtime/src/transaction_validity.rs#L210
|
||||
// We copy some of the inner types and put the three states (valid, invalid, unknown) into
|
||||
// one enum, because from our perspective, the call was successful regardless.
|
||||
if bytes.get(0) == Some(&0) {
|
||||
@@ -708,7 +708,7 @@ pub struct TransactionValid {
|
||||
///
|
||||
/// A list of tags this transaction provides. Successfully importing the transaction
|
||||
/// will enable other transactions that depend on (require) those tags to be included as well.
|
||||
/// Provided and required tags allow Substrate to build a dependency graph of transactions
|
||||
/// Provided and required tags allow Bizinikiwi to build a dependency graph of transactions
|
||||
/// and import them in the right (linear) order.
|
||||
pub provides: Vec<Vec<u8>>,
|
||||
/// Transaction longevity
|
||||
@@ -761,7 +761,7 @@ pub enum TransactionInvalid {
|
||||
/// # Possible causes
|
||||
///
|
||||
/// For `FRAME`-based runtimes this would be caused by `current block number`
|
||||
/// - Era::birth block number > BlockHashCount`. (e.g. in Polkadot `BlockHashCount` = 2400, so a
|
||||
/// - Era::birth block number > BlockHashCount`. (e.g. in Pezkuwi `BlockHashCount` = 2400, so a
|
||||
/// transaction with birth block number 1337 would be valid up until block number 1337 + 2400,
|
||||
/// after which point the transaction would be considered to have an ancient birth block.)
|
||||
AncientBirthBlock,
|
||||
|
||||
+21
-21
@@ -347,22 +347,22 @@ mod test {
|
||||
use pezkuwi_subxt_core::client::RuntimeVersion;
|
||||
|
||||
use crate::{
|
||||
SubstrateConfig,
|
||||
BizinikiwConfig,
|
||||
backend::{StreamOfResults, TransactionStatus},
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
config::{Config, HashFor},
|
||||
tx::TxProgress,
|
||||
};
|
||||
|
||||
type MockTxProgress = TxProgress<SubstrateConfig, MockClient>;
|
||||
type MockHash = HashFor<SubstrateConfig>;
|
||||
type MockSubstrateTxStatus = TransactionStatus<MockHash>;
|
||||
type MockTxProgress = TxProgress<BizinikiwConfig, MockClient>;
|
||||
type MockHash = HashFor<BizinikiwConfig>;
|
||||
type MockBizinikiwiTxStatus = TransactionStatus<MockHash>;
|
||||
|
||||
/// a mock client to satisfy trait bounds in tests
|
||||
#[derive(Clone, Debug)]
|
||||
struct MockClient;
|
||||
|
||||
impl OfflineClientT<SubstrateConfig> for MockClient {
|
||||
impl OfflineClientT<BizinikiwConfig> for MockClient {
|
||||
fn metadata(&self) -> crate::Metadata {
|
||||
unimplemented!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
@@ -375,17 +375,17 @@ mod test {
|
||||
unimplemented!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
|
||||
fn hasher(&self) -> <SubstrateConfig as Config>::Hasher {
|
||||
fn hasher(&self) -> <BizinikiwConfig as Config>::Hasher {
|
||||
unimplemented!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
|
||||
fn client_state(&self) -> pezkuwi_subxt_core::client::ClientState<SubstrateConfig> {
|
||||
fn client_state(&self) -> pezkuwi_subxt_core::client::ClientState<BizinikiwConfig> {
|
||||
unimplemented!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
}
|
||||
|
||||
impl OnlineClientT<SubstrateConfig> for MockClient {
|
||||
fn backend(&self) -> &dyn crate::backend::Backend<SubstrateConfig> {
|
||||
impl OnlineClientT<BizinikiwConfig> for MockClient {
|
||||
fn backend(&self) -> &dyn crate::backend::Backend<BizinikiwConfig> {
|
||||
unimplemented!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
}
|
||||
@@ -393,8 +393,8 @@ mod test {
|
||||
#[tokio::test]
|
||||
async fn wait_for_finalized_returns_err_when_error() {
|
||||
let tx_progress = mock_tx_progress(vec![
|
||||
MockSubstrateTxStatus::Broadcasted,
|
||||
MockSubstrateTxStatus::Error { message: "err".into() },
|
||||
MockBizinikiwiTxStatus::Broadcasted,
|
||||
MockBizinikiwiTxStatus::Error { message: "err".into() },
|
||||
]);
|
||||
let finalized_result = tx_progress.wait_for_finalized().await;
|
||||
assert!(matches!(
|
||||
@@ -406,8 +406,8 @@ mod test {
|
||||
#[tokio::test]
|
||||
async fn wait_for_finalized_returns_err_when_invalid() {
|
||||
let tx_progress = mock_tx_progress(vec![
|
||||
MockSubstrateTxStatus::Broadcasted,
|
||||
MockSubstrateTxStatus::Invalid { message: "err".into() },
|
||||
MockBizinikiwiTxStatus::Broadcasted,
|
||||
MockBizinikiwiTxStatus::Invalid { message: "err".into() },
|
||||
]);
|
||||
let finalized_result = tx_progress.wait_for_finalized().await;
|
||||
assert!(matches!(
|
||||
@@ -419,8 +419,8 @@ mod test {
|
||||
#[tokio::test]
|
||||
async fn wait_for_finalized_returns_err_when_dropped() {
|
||||
let tx_progress = mock_tx_progress(vec![
|
||||
MockSubstrateTxStatus::Broadcasted,
|
||||
MockSubstrateTxStatus::Dropped { message: "err".into() },
|
||||
MockBizinikiwiTxStatus::Broadcasted,
|
||||
MockBizinikiwiTxStatus::Dropped { message: "err".into() },
|
||||
]);
|
||||
let finalized_result = tx_progress.wait_for_finalized().await;
|
||||
assert!(matches!(
|
||||
@@ -429,17 +429,17 @@ mod test {
|
||||
));
|
||||
}
|
||||
|
||||
fn mock_tx_progress(statuses: Vec<MockSubstrateTxStatus>) -> MockTxProgress {
|
||||
let sub = create_substrate_tx_status_subscription(statuses);
|
||||
fn mock_tx_progress(statuses: Vec<MockBizinikiwiTxStatus>) -> MockTxProgress {
|
||||
let sub = create_bizinikiwi_tx_status_subscription(statuses);
|
||||
TxProgress::new(sub, MockClient, Default::default())
|
||||
}
|
||||
|
||||
fn create_substrate_tx_status_subscription(
|
||||
elements: Vec<MockSubstrateTxStatus>,
|
||||
) -> StreamOfResults<MockSubstrateTxStatus> {
|
||||
fn create_bizinikiwi_tx_status_subscription(
|
||||
elements: Vec<MockBizinikiwiTxStatus>,
|
||||
) -> StreamOfResults<MockBizinikiwiTxStatus> {
|
||||
let results = elements.into_iter().map(Ok);
|
||||
let stream = Box::pin(futures::stream::iter(results));
|
||||
let sub: StreamOfResults<MockSubstrateTxStatus> = StreamOfResults::new(stream);
|
||||
let sub: StreamOfResults<MockBizinikiwiTxStatus> = StreamOfResults::new(stream);
|
||||
sub
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user