mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-29 13:47:25 +00:00
Remove unneeded Config bounds and BlockNumber associated type (#804)
* remove unneeded Config bounds and BlockNumber associated type * clippy and fmt
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ struct_field_align_threshold = 0
|
||||
enum_discrim_align_threshold = 0
|
||||
match_arm_blocks = true
|
||||
force_multiline_blocks = true # changed
|
||||
fn_args_layout = "Tall"
|
||||
fn_params_layout = "Tall"
|
||||
brace_style = "SameLineWhere"
|
||||
control_brace_style = "AlwaysSameLine"
|
||||
trailing_semicolon = false # changed
|
||||
|
||||
+2
-2
@@ -23,12 +23,12 @@ fn output_git_short_hash() {
|
||||
Cow::from("unknown")
|
||||
}
|
||||
Err(err) => {
|
||||
println!("cargo:warning=Failed to execute git command: {}", err);
|
||||
println!("cargo:warning=Failed to execute git command: {err}");
|
||||
Cow::from("unknown")
|
||||
}
|
||||
};
|
||||
|
||||
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
|
||||
println!("cargo:rustc-env=GIT_HASH={git_hash}");
|
||||
println!("cargo:rerun-if-changed=../.git/HEAD");
|
||||
println!("cargo:rerun-if-changed=../.git/refs");
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
@@ -107,6 +107,6 @@ fn codegen(
|
||||
type_substitutes,
|
||||
crate_path,
|
||||
);
|
||||
println!("{}", runtime_api);
|
||||
println!("{runtime_api}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ async fn handle_pallet_metadata(nodes: &[Uri], name: &str) -> color_eyre::Result
|
||||
Some(pallet_metadata) => {
|
||||
let hash = get_pallet_hash(&metadata.types, pallet_metadata);
|
||||
let hex_hash = hex::encode(hash);
|
||||
println!("Node {:?} has pallet metadata hash {:?}", node, hex_hash);
|
||||
println!("Node {node:?} has pallet metadata hash {hex_hash:?}");
|
||||
|
||||
compatibility
|
||||
.pallet_present
|
||||
@@ -93,7 +93,7 @@ async fn handle_full_metadata(nodes: &[Uri]) -> color_eyre::Result<()> {
|
||||
let metadata = fetch_runtime_metadata(node).await?;
|
||||
let hash = get_metadata_hash(&metadata);
|
||||
let hex_hash = hex::encode(hash);
|
||||
println!("Node {:?} has metadata hash {:?}", node, hex_hash,);
|
||||
println!("Node {node:?} has metadata hash {hex_hash:?}",);
|
||||
|
||||
compatibility_map
|
||||
.entry(hex_hash)
|
||||
|
||||
@@ -37,11 +37,11 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> {
|
||||
let bytes = hex::decode(hex_data.trim_start_matches("0x"))?;
|
||||
let metadata = <RuntimeMetadataPrefixed as Decode>::decode(&mut &bytes[..])?;
|
||||
let json = serde_json::to_string_pretty(&metadata)?;
|
||||
println!("{}", json);
|
||||
println!("{json}");
|
||||
Ok(())
|
||||
}
|
||||
"hex" => {
|
||||
println!("{}", hex_data);
|
||||
println!("{hex_data}");
|
||||
Ok(())
|
||||
}
|
||||
"bytes" => {
|
||||
|
||||
@@ -370,8 +370,8 @@ impl RuntimeGenerator {
|
||||
}
|
||||
|
||||
/// Return a vector of tuples of variant names and corresponding struct definitions.
|
||||
pub fn generate_structs_from_variants<'a, F>(
|
||||
type_gen: &'a TypeGenerator,
|
||||
pub fn generate_structs_from_variants<F>(
|
||||
type_gen: &TypeGenerator,
|
||||
type_id: u32,
|
||||
variant_to_struct_name: F,
|
||||
error_message_type_name: &str,
|
||||
|
||||
@@ -131,7 +131,7 @@ impl<'a> TypeGenerator<'a> {
|
||||
pub fn resolve_type(&self, id: u32) -> Type<PortableForm> {
|
||||
self.type_registry
|
||||
.resolve(id)
|
||||
.unwrap_or_else(|| panic!("No type with id {} found", id))
|
||||
.unwrap_or_else(|| panic!("No type with id {id} found"))
|
||||
.clone()
|
||||
}
|
||||
|
||||
@@ -403,10 +403,7 @@ impl ToTokens for CratePath {
|
||||
impl From<&str> for CratePath {
|
||||
fn from(crate_path: &str) -> Self {
|
||||
Self(syn::Path::from_string(crate_path).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"failed converting {:?} to `syn::Path`: {:?}",
|
||||
crate_path, err
|
||||
);
|
||||
panic!("failed converting {crate_path:?} to `syn::Path`: {err:?}");
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ impl TypePathType {
|
||||
"BTreeSet" => parse_quote!(::std::collections::BTreeSet),
|
||||
"Range" => parse_quote!(::core::ops::Range),
|
||||
"RangeInclusive" => parse_quote!(::core::ops::RangeInclusive),
|
||||
ident => panic!("Unknown prelude type '{}'", ident),
|
||||
ident => panic!("Unknown prelude type '{ident}'"),
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
||||
@@ -38,7 +38,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Submit the transaction with default params:
|
||||
let hash = api.tx().sign_and_submit_default(&tx, &signer).await?;
|
||||
|
||||
println!("Balance transfer extrinsic submitted: {}", hash);
|
||||
println!("Balance transfer extrinsic submitted: {hash}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// submit the transaction:
|
||||
let hash = api.tx().sign_and_submit(&tx, &signer, tx_params).await?;
|
||||
|
||||
println!("Balance transfer extrinsic submitted: {}", hash);
|
||||
println!("Balance transfer extrinsic submitted: {hash}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ impl Config for MyConfig {
|
||||
// polkadot runtime used, so some operations will fail. Normally when using a custom `Config`
|
||||
// impl types MUST match exactly those used in the actual runtime.
|
||||
type Index = u64;
|
||||
type BlockNumber = <SubstrateConfig as Config>::BlockNumber;
|
||||
type Hash = <SubstrateConfig as Config>::Hash;
|
||||
type Hasher = <SubstrateConfig as Config>::Hasher;
|
||||
type Header = <SubstrateConfig as Config>::Header;
|
||||
@@ -58,7 +57,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// submit the transaction with default params:
|
||||
let hash = api.tx().sign_and_submit_default(&tx, &signer).await?;
|
||||
|
||||
println!("Balance transfer extrinsic submitted: {}", hash);
|
||||
println!("Balance transfer extrinsic submitted: {hash}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// submit the transaction with default params:
|
||||
let hash = api.tx().sign_and_submit_default(&tx, &signer).await?;
|
||||
println!("Balance transfer extrinsic submitted: {}", hash);
|
||||
println!("Balance transfer extrinsic submitted: {hash}");
|
||||
|
||||
// 2. Dynamic constant access (the dynamic equivalent to the fetch_constants example).
|
||||
|
||||
let constant_address = subxt::dynamic::constant("Balances", "ExistentialDeposit");
|
||||
let existential_deposit = api.constants().at(&constant_address)?.to_value()?;
|
||||
println!("Existential Deposit: {}", existential_deposit);
|
||||
println!("Existential Deposit: {existential_deposit}");
|
||||
|
||||
// 3. Dynamic storage access
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Look it up:
|
||||
let existential_deposit = api.constants().at(&address)?;
|
||||
|
||||
println!("Existential Deposit: {}", existential_deposit);
|
||||
println!("Existential Deposit: {existential_deposit}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -45,14 +45,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
);
|
||||
|
||||
let alice_id = AccountKeyring::Alice.to_account_id();
|
||||
println!(" Alice account id: {:?}", alice_id);
|
||||
println!(" Alice account id: {alice_id:?}");
|
||||
|
||||
// Get Alice' Stash account ID
|
||||
let alice_stash_id: AccountId32 = sr25519::Pair::from_string("//Alice//stash", None)
|
||||
.expect("Could not obtain stash signer pair")
|
||||
.public()
|
||||
.into();
|
||||
println!(" Alice//stash account id: {:?}", alice_stash_id);
|
||||
println!(" Alice//stash account id: {alice_stash_id:?}");
|
||||
|
||||
// Map from all locked "stash" accounts to the controller account.
|
||||
let controller_acc_addr = polkadot::storage().staking().bonded(&alice_stash_id);
|
||||
@@ -63,7 +63,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.fetch(&controller_acc_addr)
|
||||
.await?
|
||||
.unwrap();
|
||||
println!(" account controlled by: {:?}", controller_acc);
|
||||
println!(" account controlled by: {controller_acc:?}");
|
||||
|
||||
let era_reward_addr = polkadot::storage().staking().eras_reward_points(era.index);
|
||||
let era_result = api
|
||||
@@ -72,7 +72,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await?
|
||||
.fetch(&era_reward_addr)
|
||||
.await?;
|
||||
println!("Era reward points: {:?}", era_result);
|
||||
println!("Era reward points: {era_result:?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("\nExample 1. Obtained keys:");
|
||||
while let Some((key, value)) = iter.next().await? {
|
||||
println!("Key: 0x{}", hex::encode(key));
|
||||
println!(" Value: {}", value);
|
||||
println!(" Value: {value}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// - polkadot.rs generated file under `version_notifiers()` fn
|
||||
// - metadata in json format
|
||||
let value = u64::decode(&mut &*storage_data)?;
|
||||
println!(" Value: {}", value);
|
||||
println!(" Value: {value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// - polkadot.rs generated file under `version_notifiers()` fn
|
||||
// - metadata in json format
|
||||
let value = u64::decode(&mut &storage_data[..])?;
|
||||
println!(" Value: {}", value);
|
||||
println!(" Value: {value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ async fn handle_transfer_events() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
// Report other statuses we see.
|
||||
else {
|
||||
println!("Current transaction status: {:?}", ev);
|
||||
println!("Current transaction status: {ev:?}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let update_client = api.updater();
|
||||
tokio::spawn(async move {
|
||||
let result = update_client.perform_runtime_updates().await;
|
||||
println!("Runtime update failed with result={:?}", result);
|
||||
println!("Runtime update failed with result={result:?}");
|
||||
});
|
||||
|
||||
// If this client is kept in use a while, it'll update its metadata and such
|
||||
|
||||
@@ -57,7 +57,7 @@ where
|
||||
}
|
||||
|
||||
/// Return the block number.
|
||||
pub fn number(&self) -> T::BlockNumber {
|
||||
pub fn number(&self) -> <T::Header as crate::config::Header>::Number {
|
||||
self.header().number()
|
||||
}
|
||||
|
||||
|
||||
+20
-46
@@ -13,12 +13,14 @@ pub mod polkadot;
|
||||
pub mod substrate;
|
||||
|
||||
use codec::{
|
||||
Codec,
|
||||
Decode,
|
||||
Encode,
|
||||
EncodeLike,
|
||||
};
|
||||
use core::fmt::Debug;
|
||||
use serde::Serialize;
|
||||
use serde::{
|
||||
de::DeserializeOwned,
|
||||
Serialize,
|
||||
};
|
||||
|
||||
pub use extrinsic_params::ExtrinsicParams;
|
||||
pub use polkadot::PolkadotConfig;
|
||||
@@ -31,66 +33,39 @@ pub use substrate::SubstrateConfig;
|
||||
pub trait Config: 'static {
|
||||
/// Account index (aka nonce) type. This stores the number of previous
|
||||
/// transactions associated with a sender account.
|
||||
type Index: Parameter
|
||||
+ Member
|
||||
+ serde::de::DeserializeOwned
|
||||
+ Default
|
||||
+ Copy
|
||||
+ scale_info::TypeInfo
|
||||
+ Into<u64>;
|
||||
|
||||
/// The block number type used by the runtime.
|
||||
type BlockNumber: Parameter
|
||||
+ Member
|
||||
+ Default
|
||||
+ Copy
|
||||
+ std::hash::Hash
|
||||
+ std::str::FromStr
|
||||
+ Into<u64>;
|
||||
type Index: Debug + Copy + DeserializeOwned + Into<u64>;
|
||||
|
||||
/// The output of the `Hashing` function.
|
||||
type Hash: Parameter
|
||||
+ Member
|
||||
+ serde::Serialize
|
||||
+ serde::de::DeserializeOwned
|
||||
+ Ord
|
||||
+ Default
|
||||
type Hash: Debug
|
||||
+ Copy
|
||||
+ std::hash::Hash
|
||||
+ Send
|
||||
+ Sync
|
||||
+ Decode
|
||||
+ AsRef<[u8]>
|
||||
+ AsMut<[u8]>
|
||||
+ scale_info::TypeInfo;
|
||||
+ Serialize
|
||||
+ DeserializeOwned
|
||||
+ Encode
|
||||
+ PartialEq;
|
||||
|
||||
/// The account ID type.
|
||||
type AccountId: Clone + Serialize;
|
||||
type AccountId: Debug + Clone + Serialize;
|
||||
|
||||
/// The address type.
|
||||
type Address: Encode + From<Self::AccountId>;
|
||||
type Address: Debug + Encode + From<Self::AccountId>;
|
||||
|
||||
/// The signature type.
|
||||
type Signature: Encode;
|
||||
type Signature: Debug + Encode;
|
||||
|
||||
/// The hashing system (algorithm) being used in the runtime (e.g. Blake2).
|
||||
type Hasher: Hasher<Output = Self::Hash>;
|
||||
type Hasher: Debug + Hasher<Output = Self::Hash>;
|
||||
|
||||
/// The block header.
|
||||
type Header: Parameter
|
||||
+ Header<Number = Self::BlockNumber, Hasher = Self::Hasher>
|
||||
+ Member
|
||||
+ serde::de::DeserializeOwned;
|
||||
type Header: Debug + Header<Hasher = Self::Hasher> + Send + DeserializeOwned;
|
||||
|
||||
/// This type defines the extrinsic extra and additional parameters.
|
||||
type ExtrinsicParams: extrinsic_params::ExtrinsicParams<Self::Index, Self::Hash>;
|
||||
}
|
||||
|
||||
/// Parameter trait copied from `substrate::frame_support`.
|
||||
pub trait Parameter: Codec + EncodeLike + Clone + Eq + Debug {}
|
||||
impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + Debug {}
|
||||
|
||||
/// A type that can be used in runtime structures. Copied from `sp_runtime::traits`.
|
||||
pub trait Member: Send + Sync + Sized + Debug + Eq + PartialEq + Clone + 'static {}
|
||||
impl<T: Send + Sync + Sized + Debug + Eq + PartialEq + Clone + 'static> Member for T {}
|
||||
|
||||
/// This represents the hasher used by a node to hash things like block headers
|
||||
/// and extrinsics.
|
||||
pub trait Hasher {
|
||||
@@ -110,7 +85,7 @@ pub trait Hasher {
|
||||
/// This represents the block header type used by a node.
|
||||
pub trait Header: Sized + Encode {
|
||||
/// The block number type for this header.
|
||||
type Number;
|
||||
type Number: Into<u64>;
|
||||
/// The hasher used to hash this header.
|
||||
type Hasher: Hasher;
|
||||
|
||||
@@ -146,7 +121,6 @@ impl<T: Config, E: extrinsic_params::ExtrinsicParams<T::Index, T::Hash>> Config
|
||||
for WithExtrinsicParams<T, E>
|
||||
{
|
||||
type Index = T::Index;
|
||||
type BlockNumber = T::BlockNumber;
|
||||
type Hash = T::Hash;
|
||||
type AccountId = T::AccountId;
|
||||
type Address = T::Address;
|
||||
|
||||
@@ -39,13 +39,12 @@ pub enum SubstrateConfig {}
|
||||
|
||||
impl Config for SubstrateConfig {
|
||||
type Index = u32;
|
||||
type BlockNumber = u32;
|
||||
type Hash = H256;
|
||||
type AccountId = AccountId32;
|
||||
type Address = MultiAddress<Self::AccountId, u32>;
|
||||
type Signature = MultiSignature;
|
||||
type Hasher = BlakeTwo256;
|
||||
type Header = SubstrateHeader<Self::BlockNumber, BlakeTwo256>;
|
||||
type Header = SubstrateHeader<u32, BlakeTwo256>;
|
||||
type ExtrinsicParams = SubstrateExtrinsicParams<Self>;
|
||||
}
|
||||
|
||||
@@ -124,10 +123,9 @@ pub struct SubstrateHeader<N: Copy + Into<U256> + TryFrom<U256>, H: Hasher> {
|
||||
pub digest: Digest,
|
||||
}
|
||||
|
||||
impl<N: Copy + Into<U256> + TryFrom<U256> + Encode, H: Hasher + Encode> Header
|
||||
for SubstrateHeader<N, H>
|
||||
impl<N, H> Header for SubstrateHeader<N, H>
|
||||
where
|
||||
N: Copy + Into<U256> + TryFrom<U256> + Encode,
|
||||
N: Copy + Into<u64> + Into<U256> + TryFrom<U256> + Encode,
|
||||
H: Hasher + Encode,
|
||||
SubstrateHeader<N, H>: Encode,
|
||||
{
|
||||
@@ -268,14 +266,11 @@ impl<'a> serde::Deserialize<'a> for DigestItem {
|
||||
{
|
||||
let r = impl_serde::serialize::deserialize(de)?;
|
||||
Decode::decode(&mut &r[..])
|
||||
.map_err(|e| serde::de::Error::custom(format!("Decode error: {}", e)))
|
||||
.map_err(|e| serde::de::Error::custom(format!("Decode error: {e}")))
|
||||
}
|
||||
}
|
||||
|
||||
fn serialize_number<S, T: Copy + Into<U256> + TryFrom<U256>>(
|
||||
val: &T,
|
||||
s: S,
|
||||
) -> Result<S::Ok, S::Error>
|
||||
fn serialize_number<S, T: Copy + Into<U256>>(val: &T, s: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
@@ -283,9 +278,7 @@ where
|
||||
serde::Serialize::serialize(&u256, s)
|
||||
}
|
||||
|
||||
fn deserialize_number<'a, D, T: Copy + Into<U256> + TryFrom<U256>>(
|
||||
d: D,
|
||||
) -> Result<T, D::Error>
|
||||
fn deserialize_number<'a, D, T: TryFrom<U256>>(d: D) -> Result<T, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'a>,
|
||||
{
|
||||
|
||||
@@ -124,7 +124,7 @@ impl<'a> ::serde::Deserialize<'a> for ChainBlockExtrinsic {
|
||||
{
|
||||
let r = impl_serde::serialize::deserialize(de)?;
|
||||
let bytes = Decode::decode(&mut &r[..])
|
||||
.map_err(|e| ::serde::de::Error::custom(format!("Decode error: {}", e)))?;
|
||||
.map_err(|e| ::serde::de::Error::custom(format!("Decode error: {e}")))?;
|
||||
Ok(ChainBlockExtrinsic(bytes))
|
||||
}
|
||||
}
|
||||
@@ -778,7 +778,7 @@ mod as_string {
|
||||
) -> Result<usize, D::Error> {
|
||||
String::deserialize(deserializer)?
|
||||
.parse()
|
||||
.map_err(|e| serde::de::Error::custom(format!("Parsing failed: {}", e)))
|
||||
.map_err(|e| serde::de::Error::custom(format!("Parsing failed: {e}")))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ impl<'de> Deserialize<'de> for AccountId32 {
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
AccountId32::from_ss58check(&String::deserialize(deserializer)?)
|
||||
.map_err(|e| serde::de::Error::custom(format!("{:?}", e)))
|
||||
.map_err(|e| serde::de::Error::custom(format!("{e:?}")))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,8 +106,7 @@ fn check_documentation() {
|
||||
for raw in raw_docs.iter() {
|
||||
assert!(
|
||||
runtime_docs.contains(raw),
|
||||
"Documentation not present in runtime API: {}",
|
||||
raw
|
||||
"Documentation not present in runtime API: {raw}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,8 +194,7 @@ async fn tx_instantiate_with_code() {
|
||||
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Error calling instantiate_with_code and receiving CodeStored and Instantiated Events: {:?}",
|
||||
result
|
||||
"Error calling instantiate_with_code and receiving CodeStored and Instantiated Events: {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -208,8 +207,7 @@ async fn tx_instantiate() {
|
||||
|
||||
assert!(
|
||||
instantiated.is_ok(),
|
||||
"Error instantiating contract: {:?}",
|
||||
instantiated
|
||||
"Error instantiating contract: {instantiated:?}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -244,9 +242,9 @@ async fn tx_call() {
|
||||
.iter()
|
||||
.map(|key| hex::encode(&key.0))
|
||||
.collect::<Vec<_>>();
|
||||
println!("keys post: {:?}", keys);
|
||||
println!("keys post: {keys:?}");
|
||||
|
||||
let executed = cxt.call(contract, vec![]).await;
|
||||
|
||||
assert!(executed.is_ok(), "Error calling contract: {:?}", executed);
|
||||
assert!(executed.is_ok(), "Error calling contract: {executed:?}");
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ use subxt::error::{
|
||||
|
||||
/// Helper function to generate a crypto pair from seed
|
||||
fn get_from_seed(seed: &str) -> sr25519::Pair {
|
||||
sr25519::Pair::from_string(&format!("//{}", seed), None)
|
||||
sr25519::Pair::from_string(&format!("//{seed}"), None)
|
||||
.expect("static values are valid; qed")
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ impl TestNodeProcessBuilder {
|
||||
.arg("--ws-port=0");
|
||||
|
||||
if let Some(authority) = self.authority {
|
||||
let authority = format!("{:?}", authority);
|
||||
let authority = format!("{authority:?}");
|
||||
let arg = format!("--{}", authority.as_str().to_lowercase());
|
||||
cmd.arg(arg);
|
||||
}
|
||||
@@ -119,14 +119,14 @@ impl TestNodeProcessBuilder {
|
||||
// Wait for RPC port to be logged (it's logged to stderr):
|
||||
let stderr = proc.stderr.take().unwrap();
|
||||
let ws_port = find_substrate_port_from_output(stderr);
|
||||
let ws_url = format!("ws://127.0.0.1:{}", ws_port);
|
||||
let ws_url = format!("ws://127.0.0.1:{ws_port}");
|
||||
|
||||
// Connect to the node with a subxt client:
|
||||
let client = OnlineClient::from_url(ws_url.clone()).await;
|
||||
match client {
|
||||
Ok(client) => Ok(TestNodeProcess { proc, client }),
|
||||
Err(err) => {
|
||||
let err = format!("Failed to connect to node rpc at {}: {}", ws_url, err);
|
||||
let err = format!("Failed to connect to node rpc at {ws_url}: {err}");
|
||||
tracing::error!("{}", err);
|
||||
proc.kill().map_err(|e| {
|
||||
format!("Error killing substrate process '{}': {}", proc.id(), e)
|
||||
|
||||
@@ -33,7 +33,7 @@ async fn run() {
|
||||
let cmd = Command::new(&substrate_bin)
|
||||
.arg("--dev")
|
||||
.arg("--tmp")
|
||||
.arg(format!("--ws-port={}", port))
|
||||
.arg(format!("--ws-port={port}"))
|
||||
.spawn();
|
||||
let mut cmd = match cmd {
|
||||
Ok(cmd) => KillOnDrop(cmd),
|
||||
@@ -42,7 +42,7 @@ async fn run() {
|
||||
See https://github.com/paritytech/subxt/tree/master#integration-testing")
|
||||
}
|
||||
Err(e) => {
|
||||
panic!("Cannot spawn substrate command '{}': {}", substrate_bin, e)
|
||||
panic!("Cannot spawn substrate command '{substrate_bin}': {e}")
|
||||
}
|
||||
};
|
||||
|
||||
@@ -53,13 +53,13 @@ async fn run() {
|
||||
|
||||
loop {
|
||||
if retries >= MAX_RETRIES {
|
||||
panic!("Cannot connect to substrate node after {} retries", retries);
|
||||
panic!("Cannot connect to substrate node after {retries} retries");
|
||||
}
|
||||
|
||||
// It might take a while for substrate node that spin up the RPC server.
|
||||
// Thus, the connection might get rejected a few times.
|
||||
use client::ClientT;
|
||||
let res = match client::build(&format!("ws://localhost:{}", port)).await {
|
||||
let res = match client::build(&format!("ws://localhost:{port}")).await {
|
||||
Ok(c) => c.request("state_getMetadata", client::rpc_params![]).await,
|
||||
Err(e) => Err(e),
|
||||
};
|
||||
@@ -114,7 +114,7 @@ async fn run() {
|
||||
substrate_path.to_string_lossy()
|
||||
);
|
||||
// Re-build if we point to a different substrate binary:
|
||||
println!("cargo:rerun-if-env-changed={}", SUBSTRATE_BIN_ENV_VAR);
|
||||
println!("cargo:rerun-if-env-changed={SUBSTRATE_BIN_ENV_VAR}");
|
||||
// Re-build if this file changes:
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user