mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 02:37:58 +00:00
Get workspace compiling via 'cargo check'
This commit is contained in:
@@ -144,7 +144,7 @@ pub async fn run(opts: Opts, output: &mut impl std::io::Write) -> color_eyre::Re
|
||||
// get the metadata
|
||||
let file_or_url = opts.file_or_url;
|
||||
let bytes = file_or_url.fetch().await?;
|
||||
let metadata = Metadata::decode(&mut &bytes[..])?;
|
||||
let metadata = Metadata::decode(&mut &bytes[..])?.arc();
|
||||
|
||||
let pallet_placeholder = "<PALLET>".blue();
|
||||
let runtime_api_placeholder = "<RUNTIME_API>".blue();
|
||||
@@ -185,7 +185,14 @@ pub async fn run(opts: Opts, output: &mut impl std::io::Write) -> color_eyre::Re
|
||||
.pallets()
|
||||
.find(|e| e.name().eq_ignore_ascii_case(&name))
|
||||
{
|
||||
pallets::run(opts.subcommand, pallet, &metadata, file_or_url, output).await
|
||||
pallets::run(
|
||||
opts.subcommand,
|
||||
pallet,
|
||||
metadata.clone(),
|
||||
file_or_url,
|
||||
output,
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
Err(eyre!(
|
||||
"pallet \"{name}\" not found in metadata!\n{}",
|
||||
|
||||
@@ -5,14 +5,11 @@ use indoc::{formatdoc, writedoc};
|
||||
use scale_info::form::PortableForm;
|
||||
use scale_info::{PortableRegistry, Type, TypeDef, TypeDefVariant};
|
||||
use scale_value::{Composite, ValueDef};
|
||||
use std::str::FromStr;
|
||||
|
||||
use subxt::tx;
|
||||
use subxt::utils::H256;
|
||||
use subxt::{
|
||||
OfflineClient,
|
||||
OfflineClient, OfflineClientAtBlock,
|
||||
config::SubstrateConfig,
|
||||
metadata::{Metadata, PalletMetadata},
|
||||
metadata::{ArcMetadata, PalletMetadata},
|
||||
tx,
|
||||
};
|
||||
|
||||
use crate::utils::{
|
||||
@@ -30,7 +27,7 @@ pub struct CallsSubcommand {
|
||||
pub fn explore_calls(
|
||||
command: CallsSubcommand,
|
||||
pallet_metadata: PalletMetadata,
|
||||
metadata: &Metadata,
|
||||
metadata: ArcMetadata,
|
||||
output: &mut impl std::io::Write,
|
||||
) -> color_eyre::Result<()> {
|
||||
let pallet_name = pallet_metadata.name();
|
||||
@@ -148,18 +145,20 @@ fn get_calls_enum_type<'a>(
|
||||
Ok((calls_enum_type_def, calls_enum_type))
|
||||
}
|
||||
|
||||
/// The specific values used for construction do not matter too much, we just need any OfflineClient to create unsigned extrinsics
|
||||
fn mocked_offline_client(metadata: Metadata) -> OfflineClient<SubstrateConfig> {
|
||||
let genesis_hash =
|
||||
H256::from_str("91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3")
|
||||
.expect("Valid hash; qed");
|
||||
/// We don't care about any specific genesis hash etc; we just need any OfflineClient to create unsigned extrinsics
|
||||
fn mocked_offline_client(metadata: ArcMetadata) -> OfflineClientAtBlock<SubstrateConfig> {
|
||||
let config = SubstrateConfig::builder()
|
||||
.set_spec_version_for_block_ranges([subxt::config::substrate::SpecVersionForRange {
|
||||
block_range: 0..1,
|
||||
spec_version: 1,
|
||||
transaction_version: 1,
|
||||
}])
|
||||
.set_metadata_for_spec_versions([(1, metadata)])
|
||||
.build();
|
||||
|
||||
let runtime_version = subxt::client::RuntimeVersion {
|
||||
spec_version: 9370,
|
||||
transaction_version: 20,
|
||||
};
|
||||
|
||||
OfflineClient::<SubstrateConfig>::new(genesis_hash, runtime_version, metadata)
|
||||
OfflineClient::<SubstrateConfig>::new(config)
|
||||
.at_block(0u64)
|
||||
.expect("Should not fail since we plugged consistent data into the config")
|
||||
}
|
||||
|
||||
/// composites stay composites, all other types are converted into a 1-fielded unnamed composite
|
||||
|
||||
@@ -2,7 +2,7 @@ use clap::Args;
|
||||
use color_eyre::eyre::eyre;
|
||||
use indoc::{formatdoc, writedoc};
|
||||
use scale_typegen_description::type_description;
|
||||
use subxt::metadata::{Metadata, PalletMetadata};
|
||||
use subxt::metadata::{ArcMetadata, PalletMetadata};
|
||||
|
||||
use crate::utils::{Indent, SyntaxHighlight, first_paragraph_of_docs, format_scale_value};
|
||||
|
||||
@@ -14,7 +14,7 @@ pub struct ConstantsSubcommand {
|
||||
pub fn explore_constants(
|
||||
command: ConstantsSubcommand,
|
||||
pallet_metadata: PalletMetadata,
|
||||
metadata: &Metadata,
|
||||
metadata: ArcMetadata,
|
||||
output: &mut impl std::io::Write,
|
||||
) -> color_eyre::Result<()> {
|
||||
let pallet_name = pallet_metadata.name();
|
||||
|
||||
@@ -2,7 +2,7 @@ use clap::Args;
|
||||
use color_eyre::eyre::eyre;
|
||||
use indoc::{formatdoc, writedoc};
|
||||
use scale_info::{Variant, form::PortableForm};
|
||||
use subxt::metadata::{Metadata, PalletMetadata};
|
||||
use subxt::metadata::{ArcMetadata, PalletMetadata};
|
||||
|
||||
use crate::utils::{Indent, fields_description, first_paragraph_of_docs};
|
||||
|
||||
@@ -14,7 +14,7 @@ pub struct EventsSubcommand {
|
||||
pub fn explore_events(
|
||||
command: EventsSubcommand,
|
||||
pallet_metadata: PalletMetadata,
|
||||
metadata: &Metadata,
|
||||
metadata: ArcMetadata,
|
||||
output: &mut impl std::io::Write,
|
||||
) -> color_eyre::Result<()> {
|
||||
let pallet_name = pallet_metadata.name();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use clap::Subcommand;
|
||||
|
||||
use indoc::writedoc;
|
||||
use subxt::Metadata;
|
||||
use subxt::ArcMetadata;
|
||||
use subxt_metadata::PalletMetadata;
|
||||
|
||||
use crate::utils::{FileOrUrl, Indent, first_paragraph_of_docs};
|
||||
@@ -33,7 +33,7 @@ pub enum PalletSubcommand {
|
||||
pub async fn run<'a>(
|
||||
subcommand: Option<PalletSubcommand>,
|
||||
pallet_metadata: PalletMetadata<'a>,
|
||||
metadata: &'a Metadata,
|
||||
metadata: ArcMetadata,
|
||||
file_or_url: FileOrUrl,
|
||||
output: &mut impl std::io::Write,
|
||||
) -> color_eyre::Result<()> {
|
||||
|
||||
@@ -5,7 +5,7 @@ use scale_typegen_description::type_description;
|
||||
use scale_value::Value;
|
||||
use std::fmt::Write;
|
||||
use std::write;
|
||||
use subxt::metadata::{Metadata, PalletMetadata, StorageMetadata};
|
||||
use subxt::metadata::{ArcMetadata, PalletMetadata, StorageMetadata};
|
||||
|
||||
use crate::utils::{
|
||||
FileOrUrl, Indent, SyntaxHighlight, create_client, first_paragraph_of_docs,
|
||||
@@ -24,7 +24,7 @@ pub struct StorageSubcommand {
|
||||
pub async fn explore_storage(
|
||||
command: StorageSubcommand,
|
||||
pallet_metadata: PalletMetadata<'_>,
|
||||
metadata: &Metadata,
|
||||
metadata: ArcMetadata,
|
||||
file_or_url: FileOrUrl,
|
||||
output: &mut impl std::io::Write,
|
||||
) -> color_eyre::Result<()> {
|
||||
@@ -197,9 +197,9 @@ pub async fn explore_storage(
|
||||
|
||||
// Fetch the value:
|
||||
let storage_value = client
|
||||
.storage()
|
||||
.at_latest()
|
||||
.at_current_block()
|
||||
.await?
|
||||
.storage()
|
||||
.fetch((pallet_name, storage.name()), storage_entry_keys)
|
||||
.await?
|
||||
.decode()?;
|
||||
|
||||
@@ -172,9 +172,9 @@ pub async fn run<'a>(
|
||||
subxt::dynamic::runtime_api_call::<_, Value>(api_name, method.name(), args_data);
|
||||
let client = create_client(&file_or_url).await?;
|
||||
let output_value = client
|
||||
.runtime_api()
|
||||
.at_latest()
|
||||
.at_current_block()
|
||||
.await?
|
||||
.runtime_apis()
|
||||
.call(method_call)
|
||||
.await?;
|
||||
|
||||
|
||||
+4
-3
@@ -232,9 +232,10 @@ impl<T: Display> Indent for T {}
|
||||
pub async fn create_client(
|
||||
file_or_url: &FileOrUrl,
|
||||
) -> color_eyre::Result<OnlineClient<PolkadotConfig>> {
|
||||
let config = PolkadotConfig::new();
|
||||
let client = match &file_or_url.url {
|
||||
Some(url) => OnlineClient::<PolkadotConfig>::from_url(url).await?,
|
||||
None => OnlineClient::<PolkadotConfig>::new().await?,
|
||||
Some(url) => OnlineClient::<PolkadotConfig>::from_url(config, url).await?,
|
||||
None => OnlineClient::<PolkadotConfig>::new(config).await?,
|
||||
};
|
||||
Ok(client)
|
||||
}
|
||||
@@ -326,7 +327,7 @@ pub fn validate_url_security(url: Option<&Url>, allow_insecure: bool) -> color_e
|
||||
let Some(url) = url else {
|
||||
return Ok(());
|
||||
};
|
||||
match subxt::utils::url_is_secure(url.as_str()) {
|
||||
match subxt::ext::subxt_rpcs::utils::url_is_secure(url.as_str()) {
|
||||
Ok(is_secure) => {
|
||||
if !allow_insecure && !is_secure {
|
||||
bail!(
|
||||
|
||||
Reference in New Issue
Block a user