fix: Resolve cargo clippy errors and add CI workflow plan
## Changes
### Clippy Fixes
- Fixed deprecated `cargo_bin` usage in 27 test files (added #![allow(deprecated)])
- Fixed uninlined_format_args in zombienet-sdk-tests
- Fixed subxt API changes in revive/rpc/tests.rs (fetch signature, StorageValue)
- Fixed dead_code warnings in validator-pool and identity-kyc mocks
- Fixed field name `i` -> `_i` in tasks example
### CI Infrastructure
- Added .claude/WORKFLOW_PLAN.md for tracking CI fix progress
- Updated lychee.toml and taplo.toml configs
### Files Modified
- 27 test files with deprecated cargo_bin fix
- bizinikiwi/pezframe/revive/rpc/src/tests.rs (subxt API)
- pezkuwi/pezpallets/validator-pool/src/{mock,tests}.rs
- pezcumulus/teyrchains/pezpallets/identity-kyc/src/mock.rs
- bizinikiwi/pezframe/examples/tasks/src/tests.rs
## Status
- cargo clippy: PASSING
- Next: cargo fmt, zepter, workspace checks
This commit is contained in:
@@ -15,28 +15,28 @@ path = "bin/main.rs"
|
||||
|
||||
[dependencies]
|
||||
async-trait = { workspace = true }
|
||||
average = "0.15.1"
|
||||
chrono = { workspace = true }
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
clap_derive = "4.0.0-rc.1"
|
||||
codec = { workspace = true }
|
||||
ctrlc = "3.4.4"
|
||||
futures = { workspace = true }
|
||||
futures-util = { workspace = true }
|
||||
hex = { workspace = true, default-features = true }
|
||||
jsonrpsee = { workspace = true, features = [
|
||||
"async-client",
|
||||
"client-web-transport",
|
||||
"jsonrpsee-types",
|
||||
] }
|
||||
average = "0.15.1"
|
||||
chrono = { workspace = true }
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
clap_derive = "4.0.0-rc.1"
|
||||
ctrlc = "3.4.4"
|
||||
hex = { workspace = true, default-features = true }
|
||||
codec = { workspace = true }
|
||||
parking_lot = { workspace = true, default-features = true }
|
||||
rand = { workspace = true, default-features = true }
|
||||
serde = { workspace = true, default-features = true }
|
||||
serde_json = { workspace = true, features = ["arbitrary_precision"] }
|
||||
subxt = { workspace = true, default-features = true }
|
||||
subxt-core = { workspace = true, default-features = true }
|
||||
subxt-rpcs = { workspace = true, default-features = true }
|
||||
subxt-signer = { workspace = true, features = ["unstable-eth"] }
|
||||
pezkuwi-subxt = { workspace = true, default-features = true }
|
||||
pezkuwi-subxt-core = { workspace = true, default-features = true }
|
||||
pezkuwi-subxt-rpcs = { workspace = true, default-features = true }
|
||||
pezkuwi-subxt-signer = { workspace = true, features = ["unstable-eth", "sr25519", "subxt"] }
|
||||
termplot = "0.1.1"
|
||||
thiserror = { workspace = true }
|
||||
time = { version = "0.3.36", features = [
|
||||
|
||||
@@ -14,13 +14,13 @@ use bizinikiwi_txtesttool::{
|
||||
scenario::{AccountsDescription, ChainType, ScenarioBuilder, ScenarioType},
|
||||
subxt_transaction::{
|
||||
self, generate_ecdsa_keypair, generate_sr25519_keypair, EthRuntimeConfig, EthTransaction,
|
||||
EthTransactionsSink, SubstrateTransaction, SubstrateTransactionsSink, SENDER_SEED,
|
||||
EthTransactionsSink, BizinikiwTransaction, BizinikiwTransactionsSink, SENDER_SEED,
|
||||
},
|
||||
};
|
||||
use clap::Parser;
|
||||
use codec::Compact;
|
||||
use std::{fs, fs::File, io::BufReader, time::Duration};
|
||||
use subxt::{ext::frame_metadata::RuntimeMetadataPrefixed, PolkadotConfig};
|
||||
use pezkuwi_subxt::{ext::frame_metadata::RuntimeMetadataPrefixed, PezkuwiConfig};
|
||||
use tracing::info;
|
||||
|
||||
macro_rules! populate_scenario_builder {
|
||||
@@ -143,7 +143,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
} else {
|
||||
AccountsDescription::Keyring(account.clone())
|
||||
};
|
||||
let sink = SubstrateTransactionsSink::new_with_uri_with_accounts_description(
|
||||
let sink = BizinikiwTransactionsSink::new_with_uri_with_accounts_description(
|
||||
ws,
|
||||
desc,
|
||||
generate_sr25519_keypair,
|
||||
@@ -161,7 +161,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
CliCommand::Metadata { ws } => {
|
||||
// Handle metadata command
|
||||
use codec::Decode;
|
||||
let api = subxt::OnlineClient::<EthRuntimeConfig>::from_insecure_url(ws).await?;
|
||||
let api = pezkuwi_subxt::OnlineClient::<EthRuntimeConfig>::from_insecure_url(ws).await?;
|
||||
let runtime_apis = api.runtime_api().at_latest().await?;
|
||||
let raw_bytes: Vec<u8> = runtime_apis.call_raw("Metadata_metadata", None).await?;
|
||||
let (_, meta): (Compact<u32>, RuntimeMetadataPrefixed) =
|
||||
@@ -172,7 +172,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
match chain {
|
||||
ChainType::Sub => {
|
||||
let block_monitor =
|
||||
BlockMonitor::<PolkadotConfig>::new_with_options(ws, *display).await;
|
||||
BlockMonitor::<PezkuwiConfig>::new_with_options(ws, *display).await;
|
||||
async {
|
||||
loop {
|
||||
tokio::time::sleep(Duration::from_secs(10)).await
|
||||
@@ -197,7 +197,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
},
|
||||
CliCommand::LoadLog { chain, log_file, show_graphs, out_csv_filename, .. } => match chain {
|
||||
ChainType::Sub => {
|
||||
let logs = Journal::<DefaultTxTask<SubstrateTransaction>>::load_logs(
|
||||
let logs = Journal::<DefaultTxTask<BizinikiwTransaction>>::load_logs(
|
||||
log_file,
|
||||
out_csv_filename,
|
||||
);
|
||||
@@ -223,7 +223,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let accounts_description = AccountsDescription::Derived(*start_id..last_id + 1);
|
||||
let funded_accounts = match chain {
|
||||
ChainType::Sub => {
|
||||
let accounts = subxt_transaction::derive_accounts::<PolkadotConfig, _, _>(
|
||||
let accounts = subxt_transaction::derive_accounts::<PezkuwiConfig, _, _>(
|
||||
accounts_description.clone(),
|
||||
SENDER_SEED,
|
||||
generate_sr25519_keypair,
|
||||
@@ -232,7 +232,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.values()
|
||||
.map(|keypair| {
|
||||
serde_json::json!((
|
||||
<PolkadotConfig as subxt::Config>::AccountId::from(
|
||||
<PezkuwiConfig as pezkuwi_subxt::Config>::AccountId::from(
|
||||
keypair.0.clone().public_key()
|
||||
),
|
||||
balance,
|
||||
|
||||
@@ -11,8 +11,8 @@ use crate::{error::Error, transaction::TransactionMonitor};
|
||||
use async_trait::async_trait;
|
||||
use clap::ValueEnum;
|
||||
use futures::Future;
|
||||
use subxt::{blocks::Block, OnlineClient};
|
||||
use subxt_core::config::Header;
|
||||
use pezkuwi_subxt::{blocks::Block, OnlineClient};
|
||||
use pezkuwi_subxt_core::config::Header;
|
||||
use tokio::{
|
||||
select,
|
||||
sync::{mpsc, oneshot},
|
||||
@@ -38,7 +38,7 @@ type TxSubmissionListener<C> = mpsc::Receiver<ListenerInfo<C>>;
|
||||
/// Sending end of a channel used by the runner to submit to the block monitor a listener for
|
||||
/// unwatched transactions finalization.
|
||||
type TxSubmissionSender<C> = mpsc::Sender<ListenerInfo<C>>;
|
||||
type HashOf<C> = <<C as subxt::Config>::Hasher as subxt::config::Hasher>::Output;
|
||||
type HashOf<C> = <<C as pezkuwi_subxt::Config>::Hasher as pezkuwi_subxt::config::Hasher>::Output;
|
||||
|
||||
#[derive(ValueEnum, Copy, Clone, Debug)]
|
||||
pub enum BlockMonitorDisplayOptions {
|
||||
@@ -57,12 +57,12 @@ impl BlockMonitorDisplayOptions {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct BlockMonitor<C: subxt::Config> {
|
||||
pub struct BlockMonitor<C: pezkuwi_subxt::Config> {
|
||||
listener_request_tx: TxSubmissionSender<C>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<C: subxt::Config> TransactionMonitor<HashOf<C>> for BlockMonitor<C> {
|
||||
impl<C: pezkuwi_subxt::Config> TransactionMonitor<HashOf<C>> for BlockMonitor<C> {
|
||||
async fn wait(&self, tx_hash: HashOf<C>, until: Option<u64>) -> Result<HashOf<C>, Error> {
|
||||
let listener = self.register_listener(tx_hash, until).await;
|
||||
listener.await.map_err(|err| {
|
||||
@@ -71,7 +71,7 @@ impl<C: subxt::Config> TransactionMonitor<HashOf<C>> for BlockMonitor<C> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: subxt::Config> BlockMonitor<C> {
|
||||
impl<C: pezkuwi_subxt::Config> BlockMonitor<C> {
|
||||
/// Instantiates a [`BlockMonitor`].
|
||||
pub async fn new(uri: &str) -> Self {
|
||||
trace!(uri, "BlockNumber::new");
|
||||
|
||||
@@ -9,7 +9,7 @@ pub enum Error {
|
||||
/// Subxt error.
|
||||
#[serde(skip)]
|
||||
#[error("subxt error: {0}")]
|
||||
Subxt(#[from] subxt::Error),
|
||||
Subxt(#[from] Box<pezkuwi_subxt::Error>),
|
||||
/// Other error.
|
||||
#[error("Other error: {0}")]
|
||||
Other(String),
|
||||
@@ -18,8 +18,14 @@ pub enum Error {
|
||||
MortalLifetimeSurpassed(u64),
|
||||
}
|
||||
|
||||
impl From<subxt::error::ExtrinsicError> for Error {
|
||||
fn from(err: subxt::error::ExtrinsicError) -> Self {
|
||||
Error::Subxt(subxt::Error::from(err))
|
||||
impl From<pezkuwi_subxt::Error> for Error {
|
||||
fn from(err: pezkuwi_subxt::Error) -> Self {
|
||||
Error::Subxt(Box::new(err))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<pezkuwi_subxt::error::ExtrinsicError> for Error {
|
||||
fn from(err: pezkuwi_subxt::error::ExtrinsicError) -> Self {
|
||||
Error::Subxt(Box::new(pezkuwi_subxt::Error::from(err)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::{
|
||||
},
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
use subxt_core::config::Hash as BlockHash;
|
||||
use pezkuwi_subxt_core::config::Hash as BlockHash;
|
||||
use tracing::{debug, info, trace};
|
||||
|
||||
pub const STAT_TARGET: &str = "stat";
|
||||
|
||||
@@ -17,7 +17,7 @@ use std::{
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
time::Duration,
|
||||
};
|
||||
use subxt::ext::codec::{Decode, Encode};
|
||||
use pezkuwi_subxt::ext::codec::{Decode, Encode};
|
||||
use tokio::task::yield_now;
|
||||
use tracing::trace;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::{
|
||||
sync::Arc,
|
||||
time::{Duration, Instant, SystemTime},
|
||||
};
|
||||
use subxt_core::config::Hash as BlockHash;
|
||||
use pezkuwi_subxt_core::config::Hash as BlockHash;
|
||||
use tokio::{
|
||||
select,
|
||||
sync::mpsc::{channel, Receiver, Sender},
|
||||
@@ -433,10 +433,10 @@ mod tests {
|
||||
subxt_transaction::{EthRuntimeConfig, EthTransaction, EthTransactionsSink},
|
||||
transaction::AccountMetadata,
|
||||
};
|
||||
use subxt::{
|
||||
config::substrate::SubstrateExtrinsicParamsBuilder as Params, dynamic::Value, OnlineClient,
|
||||
use pezkuwi_subxt::{
|
||||
config::DefaultExtrinsicParamsBuilder as Params, dynamic::Value, OnlineClient,
|
||||
};
|
||||
use subxt_signer::eth::dev;
|
||||
use pezkuwi_subxt_signer::eth::dev;
|
||||
use tracing::trace;
|
||||
|
||||
pub type FakeTxTask = DefaultTxTask<FakeTransaction>;
|
||||
@@ -484,10 +484,10 @@ mod tests {
|
||||
}
|
||||
|
||||
let tx_params = tx_params.build();
|
||||
// let tx_call = subxt::dynamic::tx("System", "remark",
|
||||
// let tx_call = pezkuwi_subxt::dynamic::tx("System", "remark",
|
||||
// vec![Value::from_bytes("heeelooo")]);
|
||||
|
||||
let tx_call = subxt::dynamic::tx(
|
||||
let tx_call = pezkuwi_subxt::dynamic::tx(
|
||||
"Balances",
|
||||
"transfer_keep_alive",
|
||||
vec![
|
||||
|
||||
@@ -8,8 +8,8 @@ use std::{collections::HashMap, ops::Range, sync::Arc, time::Duration};
|
||||
|
||||
use clap::{Subcommand, ValueEnum};
|
||||
use futures::executor::block_on;
|
||||
use subxt::utils::H256;
|
||||
use subxt_core::config::Hash as BlockHash;
|
||||
use pezkuwi_subxt::utils::H256;
|
||||
use pezkuwi_subxt_core::config::Hash as BlockHash;
|
||||
use tokio::sync::mpsc::Sender;
|
||||
|
||||
use crate::{
|
||||
@@ -20,14 +20,14 @@ use crate::{
|
||||
eth_transfer_payload_builder, generate_ecdsa_keypair, generate_sr25519_keypair,
|
||||
remark_payload_builder, sub_transfer_payload_builder, EthPayloadBuilderFn, EthTransaction,
|
||||
EthTransactionsSink, EthTxBuildContext, SubPayloadBuilderFn, SubTxBuildContext,
|
||||
SubstrateTransaction, SubstrateTransactionsSink,
|
||||
BizinikiwTransaction, BizinikiwTransactionsSink,
|
||||
},
|
||||
transaction::{
|
||||
BuildTransactionParams, EthTransactionBuilder, SubstrateTransactionBuilder, Transaction,
|
||||
BuildTransactionParams, EthTransactionBuilder, BizinikiwTransactionBuilder, Transaction,
|
||||
TransactionBuilder, TransactionCall, TransactionRecipe, TransactionsSink,
|
||||
},
|
||||
};
|
||||
use subxt::tx::DynamicPayload;
|
||||
use pezkuwi_subxt::tx::DynamicPayload;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
/// Holds information relevant for transaction generation.
|
||||
@@ -107,16 +107,16 @@ pub struct EthScenarioExecutor {
|
||||
runner: EthScenarioRunner,
|
||||
}
|
||||
|
||||
pub type SubstrateScenarioRunner =
|
||||
Runner<DefaultTxTask<SubstrateTransaction>, SubstrateTransactionsSink>;
|
||||
pub struct SubstrateScenarioExecutor {
|
||||
pub type BizinikiwScenarioRunner =
|
||||
Runner<DefaultTxTask<BizinikiwTransaction>, BizinikiwTransactionsSink>;
|
||||
pub struct BizinikiwScenarioExecutor {
|
||||
stop_sender: Sender<()>,
|
||||
runner: SubstrateScenarioRunner,
|
||||
runner: BizinikiwScenarioRunner,
|
||||
}
|
||||
|
||||
impl SubstrateScenarioExecutor {
|
||||
pub(crate) fn new(stop_sender: Sender<()>, runner: SubstrateScenarioRunner) -> Self {
|
||||
SubstrateScenarioExecutor { stop_sender, runner }
|
||||
impl BizinikiwScenarioExecutor {
|
||||
pub(crate) fn new(stop_sender: Sender<()>, runner: BizinikiwScenarioRunner) -> Self {
|
||||
BizinikiwScenarioExecutor { stop_sender, runner }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ impl EthScenarioExecutor {
|
||||
/// Multi-chain scenario executor.
|
||||
pub enum ScenarioExecutor {
|
||||
Eth(EthScenarioExecutor),
|
||||
Substrate(SubstrateScenarioExecutor),
|
||||
Substrate(BizinikiwScenarioExecutor),
|
||||
}
|
||||
|
||||
impl ScenarioExecutor {
|
||||
@@ -616,8 +616,8 @@ impl ScenarioBuilder {
|
||||
.expect("No payload source configured")
|
||||
.into_sub_builder();
|
||||
|
||||
let builder = SubstrateTransactionBuilder::default();
|
||||
let sink = SubstrateTransactionsSink::new_with_uri_with_accounts_description(
|
||||
let builder = BizinikiwTransactionBuilder::default();
|
||||
let sink = BizinikiwTransactionsSink::new_with_uri_with_accounts_description(
|
||||
rpc_uri.as_str(),
|
||||
accounts_description,
|
||||
generate_sr25519_keypair,
|
||||
@@ -632,7 +632,7 @@ impl ScenarioBuilder {
|
||||
let txs =
|
||||
self.build_transactions(builder, sink.clone(), tip, payload_builder).await;
|
||||
let (stop_sender, runner) =
|
||||
Runner::<DefaultTxTask<SubstrateTransaction>, SubstrateTransactionsSink>::new(
|
||||
Runner::<DefaultTxTask<BizinikiwTransaction>, BizinikiwTransactionsSink>::new(
|
||||
send_threshold,
|
||||
sink,
|
||||
txs.into_iter().rev().collect(),
|
||||
@@ -642,7 +642,7 @@ impl ScenarioBuilder {
|
||||
self.timeout,
|
||||
);
|
||||
|
||||
let executor = ScenarioExecutor::Substrate(SubstrateScenarioExecutor::new(
|
||||
let executor = ScenarioExecutor::Substrate(BizinikiwScenarioExecutor::new(
|
||||
stop_sender,
|
||||
runner,
|
||||
));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::{error::Error, sync::Arc, time::Duration};
|
||||
use subxt::OnlineClient;
|
||||
use pezkuwi_subxt::OnlineClient;
|
||||
use tracing::info;
|
||||
|
||||
use crate::helpers;
|
||||
@@ -13,23 +13,23 @@ const MAX_ATTEMPTS: usize = 10;
|
||||
const RETRY_DELAY: Duration = Duration::from_secs(1);
|
||||
|
||||
/// Connect to a RPC node.
|
||||
pub(crate) async fn connect<C: subxt::Config>(
|
||||
pub(crate) async fn connect<C: pezkuwi_subxt::Config>(
|
||||
url: &str,
|
||||
use_legacy_backend: bool,
|
||||
) -> Result<OnlineClient<C>, Box<dyn Error>> {
|
||||
for i in 0..MAX_ATTEMPTS {
|
||||
info!("Attempt #{}: Connecting to {}", i, url);
|
||||
let maybe_client = if use_legacy_backend {
|
||||
let backend = subxt::backend::legacy::LegacyBackend::builder()
|
||||
.build(subxt::backend::rpc::RpcClient::new(helpers::client(url).await?));
|
||||
let backend = pezkuwi_subxt::backend::legacy::LegacyBackend::builder()
|
||||
.build(pezkuwi_subxt::backend::rpc::RpcClient::new(helpers::client(url).await?));
|
||||
OnlineClient::from_backend(Arc::new(backend)).await
|
||||
} else {
|
||||
let backend = subxt::backend::chain_head::ChainHeadBackend::builder()
|
||||
let backend = pezkuwi_subxt::backend::chain_head::ChainHeadBackend::builder()
|
||||
.transaction_timeout(6 * 3600)
|
||||
//note: This required new subxt release
|
||||
// subxt 0.42.1:
|
||||
// .submit_transactions_ignoring_follow_events()
|
||||
.build_with_background_driver(subxt::backend::rpc::RpcClient::new(
|
||||
.build_with_background_driver(pezkuwi_subxt::backend::rpc::RpcClient::new(
|
||||
helpers::client(url).await?,
|
||||
));
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ use std::{
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
pub use subxt::dynamic;
|
||||
use subxt::{
|
||||
pub use pezkuwi_subxt::dynamic;
|
||||
use pezkuwi_subxt::{
|
||||
backend::rpc::RpcClient,
|
||||
config::{
|
||||
transaction_extensions::{
|
||||
@@ -29,10 +29,10 @@ use subxt::{
|
||||
dynamic::{At, Value},
|
||||
ext::scale_value::value,
|
||||
tx::{DynamicPayload, PartialTransaction, Signer, SubmittableTransaction},
|
||||
OnlineClient, PolkadotConfig,
|
||||
OnlineClient, PezkuwiConfig,
|
||||
};
|
||||
use subxt_core::{config::SubstrateExtrinsicParamsBuilder, utils::AccountId20};
|
||||
use subxt_signer::{
|
||||
use pezkuwi_subxt_core::{config::DefaultExtrinsicParamsBuilder, utils::AccountId20};
|
||||
use pezkuwi_subxt_signer::{
|
||||
eth::{dev as eth_dev, Keypair as EthKeypair, Signature},
|
||||
sr25519::{dev as sr25519_dev, Keypair as SrPair},
|
||||
};
|
||||
@@ -44,25 +44,25 @@ const DEFAULT_RETRIES_FOR_PARTIAL_TX_CREATION: usize = 10;
|
||||
#[derive(Clone)]
|
||||
/// Ethereum runtime config definition for subxt usage purposes.
|
||||
pub enum EthRuntimeConfig {}
|
||||
impl subxt::Config for EthRuntimeConfig {
|
||||
impl pezkuwi_subxt::Config for EthRuntimeConfig {
|
||||
type AccountId = AccountId20;
|
||||
type Address = AccountId20;
|
||||
type Signature = Signature;
|
||||
type Hasher = subxt::config::substrate::BlakeTwo256;
|
||||
type Hasher = pezkuwi_subxt::config::bizinikiwi::BlakeTwo256;
|
||||
type Header =
|
||||
subxt::config::substrate::SubstrateHeader<u32, subxt::config::substrate::BlakeTwo256>;
|
||||
type ExtrinsicParams = subxt::config::SubstrateExtrinsicParams<Self>;
|
||||
pezkuwi_subxt::config::bizinikiwi::BizinikiwiHeader<u32, pezkuwi_subxt::config::bizinikiwi::BlakeTwo256>;
|
||||
type ExtrinsicParams = pezkuwi_subxt::config::DefaultExtrinsicParams<Self>;
|
||||
type AssetId = u32;
|
||||
}
|
||||
|
||||
/// Type alias for subxt config hash (Output of Hasher).
|
||||
pub(crate) type HashOf<C> = <<C as subxt::Config>::Hasher as subxt::config::Hasher>::Output;
|
||||
pub(crate) type HashOf<C> = <<C as pezkuwi_subxt::Config>::Hasher as pezkuwi_subxt::config::Hasher>::Output;
|
||||
/// Type alias for subxt account id.
|
||||
pub(crate) type AccountIdOf<C> = <C as subxt::Config>::AccountId;
|
||||
pub(crate) type AccountIdOf<C> = <C as pezkuwi_subxt::Config>::AccountId;
|
||||
|
||||
/// A subxt transaction abstraction.
|
||||
#[derive(Clone)]
|
||||
pub struct SubxtTransaction<C: subxt::Config> {
|
||||
pub struct SubxtTransaction<C: pezkuwi_subxt::Config> {
|
||||
transaction: Arc<SubmittableTransaction<C, OnlineClient<C>>>,
|
||||
nonce: u128,
|
||||
valid_until: Option<u64>,
|
||||
@@ -73,10 +73,10 @@ pub struct SubxtTransaction<C: subxt::Config> {
|
||||
pub type EthTransaction = SubxtTransaction<EthRuntimeConfig>;
|
||||
/// Holds the RPC API connection for transaction execution.
|
||||
pub type EthTransactionsSink = SubxtTransactionsSink<EthRuntimeConfig, EthKeypair>;
|
||||
/// Transaction type that runs on `substrate` compatible chains.
|
||||
pub type SubstrateTransaction = SubxtTransaction<PolkadotConfig>;
|
||||
/// Transaction type that runs on `bizinikiwi` compatible chains.
|
||||
pub type BizinikiwTransaction = SubxtTransaction<PezkuwiConfig>;
|
||||
/// Holds the RPC API connection for transaction execution.
|
||||
pub type SubstrateTransactionsSink = SubxtTransactionsSink<PolkadotConfig, SrPair>;
|
||||
pub type BizinikiwTransactionsSink = SubxtTransactionsSink<PezkuwiConfig, SrPair>;
|
||||
|
||||
/// Context for building transaction payloads.
|
||||
/// Generic over account type `A` to support both Substrate and Ethereum chains.
|
||||
@@ -91,16 +91,16 @@ pub struct TxPayloadBuildContext<'a, A> {
|
||||
pub nonce: u128,
|
||||
}
|
||||
|
||||
/// Context type alias for Substrate chains.
|
||||
pub type SubTxBuildContext<'a> = TxPayloadBuildContext<'a, AccountIdOf<PolkadotConfig>>;
|
||||
/// Context type alias for Bizinikiwi chains.
|
||||
pub type SubTxBuildContext<'a> = TxPayloadBuildContext<'a, AccountIdOf<PezkuwiConfig>>;
|
||||
/// Context type alias for Ethereum chains.
|
||||
pub type EthTxBuildContext<'a> = TxPayloadBuildContext<'a, AccountId20>;
|
||||
|
||||
/// Generic payload builder function type.
|
||||
pub type PayloadBuilderFn<A> =
|
||||
Arc<dyn Fn(&TxPayloadBuildContext<A>) -> DynamicPayload + Send + Sync>;
|
||||
/// Payload builder type alias for Substrate chains.
|
||||
pub type SubPayloadBuilderFn = PayloadBuilderFn<AccountIdOf<PolkadotConfig>>;
|
||||
/// Payload builder type alias for Bizinikiwi chains.
|
||||
pub type SubPayloadBuilderFn = PayloadBuilderFn<AccountIdOf<PezkuwiConfig>>;
|
||||
/// Payload builder type alias for Ethereum chains.
|
||||
pub type EthPayloadBuilderFn = PayloadBuilderFn<AccountId20>;
|
||||
|
||||
@@ -114,14 +114,14 @@ where
|
||||
Arc::new(move |ctx| {
|
||||
let i = hex::encode(ctx.to_account_id.as_ref()).as_bytes().last().copied().unwrap();
|
||||
let data = vec![i; size_kb as usize * 1024];
|
||||
subxt::dynamic::tx("System", "remark", vec![data])
|
||||
pezkuwi_subxt::dynamic::tx("System", "remark", vec![data])
|
||||
})
|
||||
}
|
||||
|
||||
/// Creates a transfer payload builder for Substrate chains.
|
||||
pub fn sub_transfer_payload_builder() -> SubPayloadBuilderFn {
|
||||
Arc::new(|ctx| {
|
||||
subxt::dynamic::tx(
|
||||
pezkuwi_subxt::dynamic::tx(
|
||||
"Balances",
|
||||
"transfer_keep_alive",
|
||||
vec![
|
||||
@@ -135,7 +135,7 @@ pub fn sub_transfer_payload_builder() -> SubPayloadBuilderFn {
|
||||
/// Creates a transfer payload builder for Ethereum chains.
|
||||
pub fn eth_transfer_payload_builder() -> EthPayloadBuilderFn {
|
||||
Arc::new(|ctx| {
|
||||
subxt::dynamic::tx(
|
||||
pezkuwi_subxt::dynamic::tx(
|
||||
"Balances",
|
||||
"transfer_keep_alive",
|
||||
vec![
|
||||
@@ -146,7 +146,7 @@ pub fn eth_transfer_payload_builder() -> EthPayloadBuilderFn {
|
||||
})
|
||||
}
|
||||
|
||||
impl<C: subxt::Config> SubxtTransaction<C> {
|
||||
impl<C: pezkuwi_subxt::Config> SubxtTransaction<C> {
|
||||
pub fn new(
|
||||
transaction: SubmittableTransaction<C, OnlineClient<C>>,
|
||||
nonce: u128,
|
||||
@@ -157,9 +157,9 @@ impl<C: subxt::Config> SubxtTransaction<C> {
|
||||
}
|
||||
}
|
||||
|
||||
// type TransactionSubxt2 = subxt::tx::DynamicPayload;
|
||||
// type TransactionSubxt2 = pezkuwi_subxt::tx::DynamicPayload;
|
||||
|
||||
impl<C: subxt::Config> Transaction for SubxtTransaction<C> {
|
||||
impl<C: pezkuwi_subxt::Config> Transaction for SubxtTransaction<C> {
|
||||
type HashType = HashOf<C>;
|
||||
fn hash(&self) -> Self::HashType {
|
||||
self.transaction.hash()
|
||||
@@ -179,7 +179,7 @@ impl<C: subxt::Config> Transaction for SubxtTransaction<C> {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubxtTransactionsSink<C: subxt::Config, KP: Signer<C>> {
|
||||
pub struct SubxtTransactionsSink<C: pezkuwi_subxt::Config, KP: Signer<C>> {
|
||||
api: OnlineClient<C>,
|
||||
from_accounts: Arc<RwLock<HashMap<String, (KP, AccountMetadata)>>>,
|
||||
to_accounts: Arc<RwLock<HashMap<String, (KP, AccountMetadata)>>>,
|
||||
@@ -195,7 +195,7 @@ impl<C, KP> SubxtTransactionsSink<C, KP>
|
||||
where
|
||||
AccountIdOf<C>: Send + Sync + AsRef<[u8]>,
|
||||
KP: Signer<C> + Clone + Send + Sync + 'static,
|
||||
C: subxt::Config,
|
||||
C: pezkuwi_subxt::Config,
|
||||
{
|
||||
pub async fn new() -> Self {
|
||||
Self {
|
||||
@@ -300,7 +300,7 @@ where
|
||||
.rpc_client
|
||||
.request::<Vec<serde_json::Value>>(
|
||||
"author_pendingExtrinsics",
|
||||
subxt_rpcs::rpc_params!(),
|
||||
pezkuwi_subxt_rpcs::rpc_params!(),
|
||||
)
|
||||
.await
|
||||
.expect("author_pendingExtrinsics should not fail")
|
||||
@@ -310,22 +310,24 @@ where
|
||||
}
|
||||
|
||||
/// Fetches an account storage and returns its nonce.
|
||||
pub async fn check_account_nonce<C: subxt::Config>(
|
||||
pub async fn check_account_nonce<C: pezkuwi_subxt::Config>(
|
||||
api: OnlineClient<C>,
|
||||
account: AccountIdOf<C>,
|
||||
) -> Result<u128, Box<dyn std::error::Error>>
|
||||
where
|
||||
AccountIdOf<C>: Send + Sync + AsRef<[u8]>,
|
||||
{
|
||||
let storage_query = subxt::dynamic::storage("System", "Account");
|
||||
let storage_query = pezkuwi_subxt::dynamic::storage("System", "Account");
|
||||
let storage_at = api.storage().at_latest().await?;
|
||||
let storage_value = storage_at
|
||||
.try_fetch(storage_query, (Value::from_bytes(account.clone()),))
|
||||
.await?
|
||||
.ok_or_else(|| format!("Sender account {:?} does not exist", hex::encode(account.clone())))?;
|
||||
let value: subxt::dynamic::Value = storage_value
|
||||
.ok_or_else(|| {
|
||||
format!("Sender account {:?} does not exist", hex::encode(account.clone()))
|
||||
})?;
|
||||
let value: pezkuwi_subxt::dynamic::Value = storage_value
|
||||
.decode()
|
||||
.map_err(|e| format!("Failed to decode storage: {:?}", e))?;
|
||||
.map_err(|e| format!("Failed to decode storage: {e:?}"))?;
|
||||
|
||||
debug!(target:LOG_TARGET,"account has free balance: {:?}", value.at("data").at("free"));
|
||||
debug!(target:LOG_TARGET,"account has nonce: {:?}", value.at("nonce"));
|
||||
@@ -343,7 +345,7 @@ where
|
||||
impl<C, KP> TransactionsSink<HashOf<C>> for SubxtTransactionsSink<C, KP>
|
||||
where
|
||||
AccountIdOf<C>: Send + Sync + AsRef<[u8]>,
|
||||
C: subxt::Config,
|
||||
C: pezkuwi_subxt::Config,
|
||||
KP: Signer<C> + Clone + Send + Sync + 'static,
|
||||
{
|
||||
async fn submit_and_watch(
|
||||
@@ -413,8 +415,8 @@ pub fn generate_ecdsa_keypair(description: AccountGenerateRequest) -> EthKeypair
|
||||
AccountGenerateRequest::Derived(seed, i) => {
|
||||
use std::str::FromStr;
|
||||
let derivation = format!("{seed}//{i}");
|
||||
let u = subxt_signer::SecretUri::from_str(&derivation).unwrap();
|
||||
<subxt_signer::ecdsa::Keypair>::from_uri(&u).unwrap().into()
|
||||
let u = pezkuwi_subxt_signer::SecretUri::from_str(&derivation).unwrap();
|
||||
<pezkuwi_subxt_signer::ecdsa::Keypair>::from_uri(&u).unwrap().into()
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -434,8 +436,8 @@ pub fn generate_sr25519_keypair(description: AccountGenerateRequest) -> SrPair {
|
||||
AccountGenerateRequest::Derived(seed, i) => {
|
||||
use std::str::FromStr;
|
||||
let derivation = format!("{seed}//{i}");
|
||||
let u = subxt_signer::SecretUri::from_str(&derivation).unwrap();
|
||||
<subxt_signer::sr25519::Keypair>::from_uri(&u).unwrap()
|
||||
let u = pezkuwi_subxt_signer::SecretUri::from_str(&derivation).unwrap();
|
||||
<pezkuwi_subxt_signer::sr25519::Keypair>::from_uri(&u).unwrap()
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -458,7 +460,7 @@ pub fn derive_accounts<C, KP, G>(
|
||||
generate: G,
|
||||
) -> HashMap<String, (KP, AccountMetadata)>
|
||||
where
|
||||
C: subxt::Config,
|
||||
C: pezkuwi_subxt::Config,
|
||||
KP: Signer<C> + Send + Sync + 'static,
|
||||
G: GenerateKeyPairFunction<KP>,
|
||||
{
|
||||
@@ -514,21 +516,21 @@ where
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn create_online_transaction<C: subxt::Config, KP, B>(
|
||||
async fn create_online_transaction<C: pezkuwi_subxt::Config, KP, B>(
|
||||
from_keypair: &KP,
|
||||
nonce: u128,
|
||||
mortality: &Option<u64>,
|
||||
account: &str,
|
||||
sink: &SubxtTransactionsSink<C, KP>,
|
||||
from_account_id: &<C as subxt::Config>::AccountId,
|
||||
to_account_id: &<C as subxt::Config>::AccountId,
|
||||
from_account_id: &<C as pezkuwi_subxt::Config>::AccountId,
|
||||
to_account_id: &<C as pezkuwi_subxt::Config>::AccountId,
|
||||
tip: u128,
|
||||
payload_builder: &B,
|
||||
) -> Result<SubxtTransaction<C>, Error>
|
||||
where
|
||||
AccountIdOf<C>: Send + Sync + AsRef<[u8]>,
|
||||
KP: Signer<C> + Clone + Send + Sync + 'static,
|
||||
<<C as subxt::Config>::ExtrinsicParams as subxt::config::ExtrinsicParams<C>>::Params: From<(
|
||||
<<C as pezkuwi_subxt::Config>::ExtrinsicParams as pezkuwi_subxt::config::ExtrinsicParams<C>>::Params: From<(
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
@@ -547,12 +549,12 @@ where
|
||||
// handle an error which happens when trying to create a partial tx that is based on a
|
||||
// certain finalized block returned by the RPC, which is then reported as not found).
|
||||
// Retrying seems to fix the issue.
|
||||
fn tx_params<CC: subxt::Config>(
|
||||
fn tx_params<CC: pezkuwi_subxt::Config>(
|
||||
mortality: &Option<u64>,
|
||||
nonce: u64,
|
||||
tip: u128,
|
||||
) -> <DefaultExtrinsicParams<CC> as ExtrinsicParams<CC>>::Params {
|
||||
let mut params = <SubstrateExtrinsicParamsBuilder<CC>>::new().nonce(nonce).tip(tip);
|
||||
let mut params = <DefaultExtrinsicParamsBuilder<CC>>::new().nonce(nonce).tip(tip);
|
||||
if let Some(mortal) = mortality {
|
||||
params = params.mortal(*mortal);
|
||||
}
|
||||
@@ -564,7 +566,7 @@ where
|
||||
// The mortality of the transaction involves setting up a block until the transaction is valid,
|
||||
// which needs fetching the last finalized block number on chain similarly to subxt:
|
||||
// https://github.com/paritytech/subxt/blob/77b6abccbacf194f3889610024e2f4024e8c2822/subxt/src/tx/tx_client.rs#L600
|
||||
async fn subxt_transaction<CC: subxt::Config, KEYP>(
|
||||
async fn subxt_transaction<CC: pezkuwi_subxt::Config, KEYP>(
|
||||
sink: &SubxtTransactionsSink<CC, KEYP>,
|
||||
mut partial_tx: PartialTransaction<CC, OnlineClient<CC>>,
|
||||
from_keypair: &KEYP,
|
||||
@@ -628,9 +630,9 @@ pub(crate) async fn build_subxt_tx<C, KP, B>(
|
||||
) -> SubxtTransaction<C>
|
||||
where
|
||||
AccountIdOf<C>: Send + Sync + AsRef<[u8]>,
|
||||
C: subxt::Config,
|
||||
C: pezkuwi_subxt::Config,
|
||||
KP: Signer<C> + Clone + Send + Sync + 'static,
|
||||
<<C as subxt::Config>::ExtrinsicParams as subxt::config::ExtrinsicParams<C>>::Params: From<(
|
||||
<<C as pezkuwi_subxt::Config>::ExtrinsicParams as pezkuwi_subxt::config::ExtrinsicParams<C>>::Params: From<(
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
@@ -684,7 +686,7 @@ where
|
||||
.await
|
||||
.expect("failed to create mortal transaction")
|
||||
} else {
|
||||
let tx_params = <SubstrateExtrinsicParamsBuilder<C>>::new()
|
||||
let tx_params = <DefaultExtrinsicParamsBuilder<C>>::new()
|
||||
.nonce(nonce as u64)
|
||||
.tip(tip)
|
||||
.build()
|
||||
@@ -713,7 +715,7 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use subxt::SubstrateConfig;
|
||||
use pezkuwi_subxt::BizinikiwConfig;
|
||||
|
||||
use crate::{
|
||||
subxt_transaction::{
|
||||
@@ -724,7 +726,7 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_derive_accounts_len() {
|
||||
let accounts = derive_accounts::<SubstrateConfig, subxt_signer::sr25519::Keypair, _>(
|
||||
let accounts = derive_accounts::<BizinikiwConfig, pezkuwi_subxt_signer::sr25519::Keypair, _>(
|
||||
crate::scenario::AccountsDescription::Derived(0..11),
|
||||
SENDER_SEED,
|
||||
generate_sr25519_keypair,
|
||||
@@ -744,7 +746,7 @@ mod tests {
|
||||
assert_eq!(AccountMetadata::Derived(id), meta);
|
||||
}
|
||||
|
||||
let accounts = derive_accounts::<SubstrateConfig, subxt_signer::sr25519::Keypair, _>(
|
||||
let accounts = derive_accounts::<BizinikiwConfig, pezkuwi_subxt_signer::sr25519::Keypair, _>(
|
||||
crate::scenario::AccountsDescription::Keyring("alice".to_string()),
|
||||
SENDER_SEED,
|
||||
generate_sr25519_keypair,
|
||||
|
||||
@@ -10,14 +10,14 @@ use crate::{
|
||||
runner::DefaultTxTask,
|
||||
subxt_transaction::{
|
||||
build_subxt_tx, EthPayloadBuilderFn, EthRuntimeConfig, EthTransaction, EthTransactionsSink,
|
||||
HashOf, SubPayloadBuilderFn, SubstrateTransaction, SubstrateTransactionsSink,
|
||||
HashOf, SubPayloadBuilderFn, BizinikiwTransaction, BizinikiwTransactionsSink,
|
||||
},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::any::Any;
|
||||
use subxt::{tx::TxStatus, OnlineClient, PolkadotConfig};
|
||||
use subxt_core::config::Hash as BlockHash;
|
||||
use pezkuwi_subxt::{tx::TxStatus, OnlineClient, PezkuwiConfig};
|
||||
use pezkuwi_subxt_core::config::Hash as BlockHash;
|
||||
|
||||
/// Parameters for building a transaction.
|
||||
pub(crate) struct BuildTransactionParams<'a> {
|
||||
@@ -46,13 +46,13 @@ pub(crate) trait TransactionBuilder {
|
||||
|
||||
/// Substrate transactions builder.
|
||||
#[derive(Default)]
|
||||
pub(crate) struct SubstrateTransactionBuilder {}
|
||||
pub(crate) struct BizinikiwTransactionBuilder {}
|
||||
|
||||
#[async_trait]
|
||||
impl TransactionBuilder for SubstrateTransactionBuilder {
|
||||
type HashType = HashOf<PolkadotConfig>;
|
||||
type Transaction = SubstrateTransaction;
|
||||
type Sink = SubstrateTransactionsSink;
|
||||
impl TransactionBuilder for BizinikiwTransactionBuilder {
|
||||
type HashType = HashOf<PezkuwiConfig>;
|
||||
type Transaction = BizinikiwTransaction;
|
||||
type Sink = BizinikiwTransactionsSink;
|
||||
type PayloadBuilder = SubPayloadBuilderFn;
|
||||
|
||||
async fn build_transaction<'a>(
|
||||
@@ -215,7 +215,7 @@ impl<H> TransactionStatus<H> {
|
||||
|
||||
impl<H: BlockHash + std::fmt::Debug> TransactionStatus<H> {}
|
||||
|
||||
impl<C: subxt::Config> From<TxStatus<C, OnlineClient<C>>> for TransactionStatus<HashOf<C>> {
|
||||
impl<C: pezkuwi_subxt::Config> From<TxStatus<C, OnlineClient<C>>> for TransactionStatus<HashOf<C>> {
|
||||
fn from(value: TxStatus<C, OnlineClient<C>>) -> Self {
|
||||
match value {
|
||||
TxStatus::Validated => TransactionStatus::Validated,
|
||||
|
||||
Reference in New Issue
Block a user