mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 00:41:03 +00:00
Update to 2024 edition (#2001)
* Update to 2024 edition * Update to 2024 edition; fmt, use<> and remove refs * async functions
This commit is contained in:
+2
-2
@@ -35,9 +35,9 @@ resolver = "2"
|
|||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
version = "0.41.0"
|
version = "0.41.0"
|
||||||
rust-version = "1.81.0"
|
rust-version = "1.86.0"
|
||||||
license = "Apache-2.0 OR GPL-3.0"
|
license = "Apache-2.0 OR GPL-3.0"
|
||||||
repository = "https://github.com/paritytech/subxt"
|
repository = "https://github.com/paritytech/subxt"
|
||||||
documentation = "https://docs.rs/subxt"
|
documentation = "https://docs.rs/subxt"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
use crate::utils::{validate_url_security, FileOrUrl};
|
use crate::utils::{FileOrUrl, validate_url_security};
|
||||||
use clap::Parser as ClapParser;
|
use clap::Parser as ClapParser;
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
use color_eyre::eyre::eyre;
|
use color_eyre::eyre::eyre;
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ use frame_metadata::RuntimeMetadataPrefixed;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
use crate::utils::{validate_url_security, FileOrUrl};
|
use crate::utils::{FileOrUrl, validate_url_security};
|
||||||
use color_eyre::owo_colors::OwoColorize;
|
use color_eyre::owo_colors::OwoColorize;
|
||||||
|
|
||||||
use scale_info::form::PortableForm;
|
|
||||||
use scale_info::Variant;
|
use scale_info::Variant;
|
||||||
|
use scale_info::form::PortableForm;
|
||||||
|
|
||||||
use subxt_metadata::{
|
use subxt_metadata::{
|
||||||
ConstantMetadata, Metadata, PalletMetadata, RuntimeApiMetadata, StorageEntryMetadata,
|
ConstantMetadata, Metadata, PalletMetadata, RuntimeApiMetadata, StorageEntryMetadata,
|
||||||
@@ -441,7 +441,7 @@ fn diff<T, C: PartialEq, I: Hash + PartialEq + Eq + Ord>(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::commands::diff::{diff, Diff};
|
use crate::commands::diff::{Diff, diff};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_diff_fn() {
|
fn test_diff_fn() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::utils::validate_url_security;
|
|
||||||
use crate::utils::FileOrUrl;
|
use crate::utils::FileOrUrl;
|
||||||
use clap::{command, Parser, Subcommand};
|
use crate::utils::validate_url_security;
|
||||||
|
use clap::{Parser, Subcommand, command};
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
use color_eyre::eyre::eyre;
|
use color_eyre::eyre::eyre;
|
||||||
use color_eyre::owo_colors::OwoColorize;
|
use color_eyre::owo_colors::OwoColorize;
|
||||||
@@ -447,18 +447,22 @@ pub mod tests {
|
|||||||
run("--url wss://rpc.polkadot.io:443").await.unwrap();
|
run("--url wss://rpc.polkadot.io:443").await.unwrap();
|
||||||
|
|
||||||
// Errors, because the --allow-insecure is not set:
|
// Errors, because the --allow-insecure is not set:
|
||||||
assert!(run("--url ws://rpc.polkadot.io:443")
|
assert!(
|
||||||
.await
|
run("--url ws://rpc.polkadot.io:443")
|
||||||
.unwrap_err()
|
.await
|
||||||
.to_string()
|
.unwrap_err()
|
||||||
.contains("is not secure"));
|
.to_string()
|
||||||
|
.contains("is not secure")
|
||||||
|
);
|
||||||
|
|
||||||
// This checks, that we never prevent (insecure) requests to localhost, even if the `--allow-insecure` flag is not set.
|
// This checks, that we never prevent (insecure) requests to localhost, even if the `--allow-insecure` flag is not set.
|
||||||
// It errors, because there is no node running locally, which results in the "Request error".
|
// It errors, because there is no node running locally, which results in the "Request error".
|
||||||
assert!(run("--url ws://localhost")
|
assert!(
|
||||||
.await
|
run("--url ws://localhost")
|
||||||
.unwrap_err()
|
.await
|
||||||
.to_string()
|
.unwrap_err()
|
||||||
.contains("Request error"));
|
.to_string()
|
||||||
|
.contains("Request error")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ use std::str::FromStr;
|
|||||||
use subxt::tx;
|
use subxt::tx;
|
||||||
use subxt::utils::H256;
|
use subxt::utils::H256;
|
||||||
use subxt::{
|
use subxt::{
|
||||||
config::SubstrateConfig,
|
|
||||||
metadata::{types::PalletMetadata, Metadata},
|
|
||||||
OfflineClient,
|
OfflineClient,
|
||||||
|
config::SubstrateConfig,
|
||||||
|
metadata::{Metadata, types::PalletMetadata},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
fields_composite_example, fields_description, parse_string_into_scale_value, Indent,
|
Indent, SyntaxHighlight, fields_composite_example, fields_description,
|
||||||
SyntaxHighlight,
|
parse_string_into_scale_value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Args)]
|
#[derive(Debug, Clone, Args)]
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ use clap::Args;
|
|||||||
use color_eyre::eyre::eyre;
|
use color_eyre::eyre::eyre;
|
||||||
use indoc::{formatdoc, writedoc};
|
use indoc::{formatdoc, writedoc};
|
||||||
use scale_typegen_description::type_description;
|
use scale_typegen_description::type_description;
|
||||||
use subxt::metadata::{types::PalletMetadata, Metadata};
|
use subxt::metadata::{Metadata, types::PalletMetadata};
|
||||||
|
|
||||||
use crate::utils::{first_paragraph_of_docs, format_scale_value, Indent, SyntaxHighlight};
|
use crate::utils::{Indent, SyntaxHighlight, first_paragraph_of_docs, format_scale_value};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Args)]
|
#[derive(Debug, Clone, Args)]
|
||||||
pub struct ConstantsSubcommand {
|
pub struct ConstantsSubcommand {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use clap::Args;
|
use clap::Args;
|
||||||
use color_eyre::eyre::eyre;
|
use color_eyre::eyre::eyre;
|
||||||
use indoc::{formatdoc, writedoc};
|
use indoc::{formatdoc, writedoc};
|
||||||
use scale_info::{form::PortableForm, Variant};
|
use scale_info::{Variant, form::PortableForm};
|
||||||
use subxt::metadata::{types::PalletMetadata, Metadata};
|
use subxt::metadata::{Metadata, types::PalletMetadata};
|
||||||
|
|
||||||
use crate::utils::{fields_description, first_paragraph_of_docs, Indent};
|
use crate::utils::{Indent, fields_description, first_paragraph_of_docs};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Args)]
|
#[derive(Debug, Clone, Args)]
|
||||||
pub struct EventsSubcommand {
|
pub struct EventsSubcommand {
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ use indoc::writedoc;
|
|||||||
use subxt::Metadata;
|
use subxt::Metadata;
|
||||||
use subxt_metadata::PalletMetadata;
|
use subxt_metadata::PalletMetadata;
|
||||||
|
|
||||||
use crate::utils::{first_paragraph_of_docs, FileOrUrl, Indent};
|
use crate::utils::{FileOrUrl, Indent, first_paragraph_of_docs};
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
calls::CallsSubcommand,
|
calls::CallsSubcommand,
|
||||||
constants::ConstantsSubcommand,
|
constants::ConstantsSubcommand,
|
||||||
events::{explore_events, EventsSubcommand},
|
events::{EventsSubcommand, explore_events},
|
||||||
storage::StorageSubcommand,
|
storage::StorageSubcommand,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ use std::write;
|
|||||||
use subxt::{
|
use subxt::{
|
||||||
ext::scale_encode::EncodeAsType,
|
ext::scale_encode::EncodeAsType,
|
||||||
metadata::{
|
metadata::{
|
||||||
types::{PalletMetadata, StorageEntryType, StorageMetadata},
|
|
||||||
Metadata,
|
Metadata,
|
||||||
|
types::{PalletMetadata, StorageEntryType, StorageMetadata},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
create_client, first_paragraph_of_docs, parse_string_into_scale_value, type_example, FileOrUrl,
|
FileOrUrl, Indent, SyntaxHighlight, create_client, first_paragraph_of_docs,
|
||||||
Indent, SyntaxHighlight,
|
parse_string_into_scale_value, type_example,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Args)]
|
#[derive(Debug, Clone, Args)]
|
||||||
@@ -151,7 +151,9 @@ pub async fn explore_storage(
|
|||||||
|
|
||||||
let storage_entry_keys: Vec<Value> = match (trailing_args.is_empty(), key_ty_id) {
|
let storage_entry_keys: Vec<Value> = match (trailing_args.is_empty(), key_ty_id) {
|
||||||
(false, None) => {
|
(false, None) => {
|
||||||
let warning = format!("Warning: You submitted a key, but no key is needed: \"{trailing_args}\". To access the storage value, please do not provide any key.");
|
let warning = format!(
|
||||||
|
"Warning: You submitted a key, but no key is needed: \"{trailing_args}\". To access the storage value, please do not provide any key."
|
||||||
|
);
|
||||||
writeln!(output, "{}", warning.yellow())?;
|
writeln!(output, "{}", warning.yellow())?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
create_client, fields_composite_example, fields_description, first_paragraph_of_docs,
|
FileOrUrl, Indent, SyntaxHighlight, create_client, fields_composite_example,
|
||||||
parse_string_into_scale_value, FileOrUrl, Indent, SyntaxHighlight,
|
fields_description, first_paragraph_of_docs, parse_string_into_scale_value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use color_eyre::{
|
use color_eyre::{
|
||||||
@@ -12,8 +12,8 @@ use indoc::{formatdoc, writedoc};
|
|||||||
use scale_typegen_description::type_description;
|
use scale_typegen_description::type_description;
|
||||||
use scale_value::Value;
|
use scale_value::Value;
|
||||||
use subxt::{
|
use subxt::{
|
||||||
ext::{scale_decode::DecodeAsType, scale_encode::EncodeAsType},
|
|
||||||
Metadata,
|
Metadata,
|
||||||
|
ext::{scale_decode::DecodeAsType, scale_encode::EncodeAsType},
|
||||||
};
|
};
|
||||||
use subxt_metadata::RuntimeApiMetadata;
|
use subxt_metadata::RuntimeApiMetadata;
|
||||||
|
|
||||||
@@ -144,7 +144,10 @@ pub async fn run<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if trailing_args.len() != method.inputs().len() {
|
if trailing_args.len() != method.inputs().len() {
|
||||||
bail!("The number of trailing arguments you provided after the `execute` flag does not match the expected number of inputs!\n{}", execute_usage());
|
bail!(
|
||||||
|
"The number of trailing arguments you provided after the `execute` flag does not match the expected number of inputs!\n{}",
|
||||||
|
execute_usage()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// encode each provided input as bytes of the correct type:
|
// encode each provided input as bytes of the correct type:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
use crate::utils::{validate_url_security, FileOrUrl};
|
use crate::utils::{FileOrUrl, validate_url_security};
|
||||||
use clap::Parser as ClapParser;
|
use clap::Parser as ClapParser;
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use color_eyre::eyre::{self, bail};
|
use color_eyre::eyre::{self, bail};
|
||||||
@@ -62,7 +62,9 @@ pub async fn run(opts: Opts, output: &mut impl Write) -> color_eyre::Result<()>
|
|||||||
RuntimeMetadata::V15(md) => md.strip_metadata(keep_pallets_fn, keep_runtime_apis_fn),
|
RuntimeMetadata::V15(md) => md.strip_metadata(keep_pallets_fn, keep_runtime_apis_fn),
|
||||||
RuntimeMetadata::V16(md) => md.strip_metadata(keep_pallets_fn, keep_runtime_apis_fn),
|
RuntimeMetadata::V16(md) => md.strip_metadata(keep_pallets_fn, keep_runtime_apis_fn),
|
||||||
_ => {
|
_ => {
|
||||||
bail!("Unsupported metadata version for stripping pallets/runtime APIs: V14, V15 or V16 metadata is expected.")
|
bail!(
|
||||||
|
"Unsupported metadata version for stripping pallets/runtime APIs: V14, V15 or V16 metadata is expected."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -313,7 +313,9 @@ pub fn validate_url_security(url: Option<&Url>, allow_insecure: bool) -> color_e
|
|||||||
match subxt::utils::url_is_secure(url.as_str()) {
|
match subxt::utils::url_is_secure(url.as_str()) {
|
||||||
Ok(is_secure) => {
|
Ok(is_secure) => {
|
||||||
if !allow_insecure && !is_secure {
|
if !allow_insecure && !is_secure {
|
||||||
bail!("URL {url} is not secure!\nIf you are really want to use this URL, try using --allow-insecure (-a)");
|
bail!(
|
||||||
|
"URL {url} is not secure!\nIf you are really want to use this URL, try using --allow-insecure (-a)"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use heck::{ToSnakeCase as _, ToUpperCamelCase as _};
|
|||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
||||||
use scale_typegen::{typegen::ir::type_ir::CompositeIRKind, TypeGenerator};
|
use scale_typegen::{TypeGenerator, typegen::ir::type_ir::CompositeIRKind};
|
||||||
use subxt_metadata::PalletMetadata;
|
use subxt_metadata::PalletMetadata;
|
||||||
|
|
||||||
/// Generate calls from the provided pallet's metadata. Each call returns a `StaticPayload`
|
/// Generate calls from the provided pallet's metadata. Each call returns a `StaticPayload`
|
||||||
@@ -53,7 +53,7 @@ pub fn generate_calls(
|
|||||||
.unzip(),
|
.unzip(),
|
||||||
CompositeIRKind::NoFields => Default::default(),
|
CompositeIRKind::NoFields => Default::default(),
|
||||||
CompositeIRKind::Unnamed(_) => {
|
CompositeIRKind::Unnamed(_) => {
|
||||||
return Err(CodegenError::InvalidCallVariant(call_ty))
|
return Err(CodegenError::InvalidCallVariant(call_ty));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
use heck::ToSnakeCase as _;
|
use heck::ToSnakeCase as _;
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
|
||||||
use scale_typegen::TypeGenerator;
|
use scale_typegen::TypeGenerator;
|
||||||
|
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
||||||
use subxt_metadata::PalletMetadata;
|
use subxt_metadata::PalletMetadata;
|
||||||
|
|
||||||
use super::CodegenError;
|
use super::CodegenError;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
use heck::ToSnakeCase as _;
|
use heck::ToSnakeCase as _;
|
||||||
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
|
||||||
use scale_typegen::TypeGenerator;
|
use scale_typegen::TypeGenerator;
|
||||||
|
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use subxt_metadata::{CustomValueMetadata, Metadata};
|
use subxt_metadata::{CustomValueMetadata, Metadata};
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
use super::CodegenError;
|
use super::CodegenError;
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
|
||||||
use scale_typegen::TypeGenerator;
|
use scale_typegen::TypeGenerator;
|
||||||
|
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
||||||
use subxt_metadata::PalletMetadata;
|
use subxt_metadata::PalletMetadata;
|
||||||
|
|
||||||
/// Generate events from the provided pallet metadata.
|
/// Generate events from the provided pallet metadata.
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ mod pallet_view_functions;
|
|||||||
mod runtime_apis;
|
mod runtime_apis;
|
||||||
mod storage;
|
mod storage;
|
||||||
|
|
||||||
use scale_typegen::typegen::ir::type_ir::{CompositeFieldIR, CompositeIR, CompositeIRKind};
|
use scale_typegen::TypeGenerator;
|
||||||
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
||||||
|
use scale_typegen::typegen::ir::type_ir::{CompositeFieldIR, CompositeIR, CompositeIRKind};
|
||||||
use scale_typegen::typegen::type_params::TypeParameters;
|
use scale_typegen::typegen::type_params::TypeParameters;
|
||||||
use scale_typegen::typegen::type_path::TypePath;
|
use scale_typegen::typegen::type_path::TypePath;
|
||||||
use scale_typegen::TypeGenerator;
|
|
||||||
use subxt_metadata::Metadata;
|
use subxt_metadata::Metadata;
|
||||||
use syn::{parse_quote, Ident};
|
use syn::{Ident, parse_quote};
|
||||||
|
|
||||||
use crate::error::CodegenError;
|
use crate::error::CodegenError;
|
||||||
use crate::subxt_type_gen_settings;
|
use crate::subxt_type_gen_settings;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use heck::ToUpperCamelCase as _;
|
|||||||
use crate::CodegenError;
|
use crate::CodegenError;
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
|
||||||
use scale_typegen::TypeGenerator;
|
use scale_typegen::TypeGenerator;
|
||||||
|
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use subxt_metadata::{PalletMetadata, ViewFunctionMetadata};
|
use subxt_metadata::{PalletMetadata, ViewFunctionMetadata};
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use std::collections::HashSet;
|
|||||||
use heck::ToSnakeCase as _;
|
use heck::ToSnakeCase as _;
|
||||||
use heck::ToUpperCamelCase as _;
|
use heck::ToUpperCamelCase as _;
|
||||||
|
|
||||||
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
|
||||||
use scale_typegen::TypeGenerator;
|
use scale_typegen::TypeGenerator;
|
||||||
|
use scale_typegen::typegen::ir::ToTokensWithSettings;
|
||||||
use subxt_metadata::{Metadata, RuntimeApiMetadata};
|
use subxt_metadata::{Metadata, RuntimeApiMetadata};
|
||||||
|
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use heck::{ToSnakeCase as _, ToUpperCamelCase};
|
|||||||
use proc_macro2::{Ident, TokenStream as TokenStream2, TokenStream};
|
use proc_macro2::{Ident, TokenStream as TokenStream2, TokenStream};
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use scale_info::TypeDef;
|
use scale_info::TypeDef;
|
||||||
use scale_typegen::{typegen::type_path::TypePath, TypeGenerator};
|
use scale_typegen::{TypeGenerator, typegen::type_path::TypePath};
|
||||||
use subxt_metadata::{
|
use subxt_metadata::{
|
||||||
PalletMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType, StorageHasher,
|
PalletMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType, StorageHasher,
|
||||||
};
|
};
|
||||||
@@ -322,7 +322,7 @@ mod tests {
|
|||||||
use frame_metadata::v15;
|
use frame_metadata::v15;
|
||||||
use heck::ToUpperCamelCase;
|
use heck::ToUpperCamelCase;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use scale_info::{meta_type, MetaType};
|
use scale_info::{MetaType, meta_type};
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
|||||||
+27
-9
@@ -15,34 +15,52 @@ pub enum CodegenError {
|
|||||||
#[error("Could not decode metadata, only V14 and V15 metadata are supported: {0}")]
|
#[error("Could not decode metadata, only V14 and V15 metadata are supported: {0}")]
|
||||||
Decode(#[from] codec::Error),
|
Decode(#[from] codec::Error),
|
||||||
/// Out of line modules are not supported.
|
/// Out of line modules are not supported.
|
||||||
#[error("Out-of-line subxt modules are not supported, make sure you are providing a body to your module: pub mod polkadot {{ ... }}")]
|
#[error(
|
||||||
|
"Out-of-line subxt modules are not supported, make sure you are providing a body to your module: pub mod polkadot {{ ... }}"
|
||||||
|
)]
|
||||||
InvalidModule(Span),
|
InvalidModule(Span),
|
||||||
/// Invalid type path.
|
/// Invalid type path.
|
||||||
#[error("Invalid type path {0}: {1}")]
|
#[error("Invalid type path {0}: {1}")]
|
||||||
InvalidTypePath(String, syn::Error),
|
InvalidTypePath(String, syn::Error),
|
||||||
/// Metadata for constant could not be found.
|
/// Metadata for constant could not be found.
|
||||||
#[error("Metadata for constant entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata")]
|
#[error(
|
||||||
|
"Metadata for constant entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||||
|
)]
|
||||||
MissingConstantMetadata(String, String),
|
MissingConstantMetadata(String, String),
|
||||||
/// Metadata for storage could not be found.
|
/// Metadata for storage could not be found.
|
||||||
#[error("Metadata for storage entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata")]
|
#[error(
|
||||||
|
"Metadata for storage entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||||
|
)]
|
||||||
MissingStorageMetadata(String, String),
|
MissingStorageMetadata(String, String),
|
||||||
/// Metadata for call could not be found.
|
/// Metadata for call could not be found.
|
||||||
#[error("Metadata for call entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata")]
|
#[error(
|
||||||
|
"Metadata for call entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||||
|
)]
|
||||||
MissingCallMetadata(String, String),
|
MissingCallMetadata(String, String),
|
||||||
/// Metadata for call could not be found.
|
/// Metadata for call could not be found.
|
||||||
#[error("Metadata for runtime API entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata")]
|
#[error(
|
||||||
|
"Metadata for runtime API entry {0}_{1} could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||||
|
)]
|
||||||
MissingRuntimeApiMetadata(String, String),
|
MissingRuntimeApiMetadata(String, String),
|
||||||
/// Call variant must have all named fields.
|
/// Call variant must have all named fields.
|
||||||
#[error("Call variant for type {0} must have all named fields. Make sure you are providing a valid substrate-based metadata")]
|
#[error(
|
||||||
|
"Call variant for type {0} must have all named fields. Make sure you are providing a valid substrate-based metadata"
|
||||||
|
)]
|
||||||
InvalidCallVariant(u32),
|
InvalidCallVariant(u32),
|
||||||
/// Type should be an variant/enum.
|
/// Type should be an variant/enum.
|
||||||
#[error("{0} type should be an variant/enum type. Make sure you are providing a valid substrate-based metadata")]
|
#[error(
|
||||||
|
"{0} type should be an variant/enum type. Make sure you are providing a valid substrate-based metadata"
|
||||||
|
)]
|
||||||
InvalidType(String),
|
InvalidType(String),
|
||||||
/// Extrinsic call type could not be found.
|
/// Extrinsic call type could not be found.
|
||||||
#[error("Extrinsic call type could not be found. Make sure you are providing a valid substrate-based metadata")]
|
#[error(
|
||||||
|
"Extrinsic call type could not be found. Make sure you are providing a valid substrate-based metadata"
|
||||||
|
)]
|
||||||
MissingCallType,
|
MissingCallType,
|
||||||
/// There are too many or too few hashers.
|
/// There are too many or too few hashers.
|
||||||
#[error("Could not generate functions for storage entry {storage_entry_name}. There are {key_count} keys, but only {hasher_count} hashers. The number of hashers must equal the number of keys or be exactly 1.")]
|
#[error(
|
||||||
|
"Could not generate functions for storage entry {storage_entry_name}. There are {key_count} keys, but only {hasher_count} hashers. The number of hashers must equal the number of keys or be exactly 1."
|
||||||
|
)]
|
||||||
InvalidStorageHasherCount {
|
InvalidStorageHasherCount {
|
||||||
/// The name of the storage entry
|
/// The name of the storage entry
|
||||||
storage_entry_name: String,
|
storage_entry_name: String,
|
||||||
|
|||||||
+5
-3
@@ -20,8 +20,8 @@ use api::RuntimeGenerator;
|
|||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use scale_typegen::typegen::settings::AllocCratePath;
|
use scale_typegen::typegen::settings::AllocCratePath;
|
||||||
use scale_typegen::{
|
use scale_typegen::{
|
||||||
typegen::settings::substitutes::absolute_path, DerivesRegistry, TypeGeneratorSettings,
|
DerivesRegistry, TypeGeneratorSettings, TypeSubstitutes, TypegenError,
|
||||||
TypeSubstitutes, TypegenError,
|
typegen::settings::substitutes::absolute_path,
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use syn::parse_quote;
|
use syn::parse_quote;
|
||||||
@@ -225,7 +225,9 @@ impl CodegenBuilder {
|
|||||||
if absolute_path(crate_path.clone()).is_err() {
|
if absolute_path(crate_path.clone()).is_err() {
|
||||||
// Throw an error here, because otherwise we end up with a harder to comprehend error when
|
// Throw an error here, because otherwise we end up with a harder to comprehend error when
|
||||||
// substitute types don't begin with an absolute path.
|
// substitute types don't begin with an absolute path.
|
||||||
panic!("The provided crate path must be an absolute path, ie prefixed with '::' or 'crate'");
|
panic!(
|
||||||
|
"The provided crate path must be an absolute path, ie prefixed with '::' or 'crate'"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self.crate_path = crate_path;
|
self.crate_path = crate_path;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
|
use crate::config::TransactionExtension;
|
||||||
use crate::config::transaction_extensions::{
|
use crate::config::transaction_extensions::{
|
||||||
ChargeAssetTxPayment, ChargeTransactionPayment, CheckNonce,
|
ChargeAssetTxPayment, ChargeTransactionPayment, CheckNonce,
|
||||||
};
|
};
|
||||||
use crate::config::TransactionExtension;
|
|
||||||
use crate::dynamic::Value;
|
use crate::dynamic::Value;
|
||||||
use crate::{config::Config, error::Error, Metadata};
|
use crate::{Metadata, config::Config, error::Error};
|
||||||
use frame_decode::extrinsics::ExtrinsicExtensions;
|
use frame_decode::extrinsics::ExtrinsicExtensions;
|
||||||
use scale_decode::DecodeAsType;
|
use scale_decode::DecodeAsType;
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ impl<'a, T: Config> ExtrinsicTransactionExtensions<'a, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over each of the signed extension details of the extrinsic.
|
/// Returns an iterator over each of the signed extension details of the extrinsic.
|
||||||
pub fn iter(&self) -> impl Iterator<Item = ExtrinsicTransactionExtension<T>> {
|
pub fn iter(&self) -> impl Iterator<Item = ExtrinsicTransactionExtension<'a, T>> + use<'a, T> {
|
||||||
self.decoded_info
|
self.decoded_info
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| ExtrinsicTransactionExtension {
|
.map(|s| ExtrinsicTransactionExtension {
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
use super::BlockError;
|
use super::BlockError;
|
||||||
use crate::blocks::extrinsic_transaction_extensions::ExtrinsicTransactionExtensions;
|
use crate::blocks::extrinsic_transaction_extensions::ExtrinsicTransactionExtensions;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Metadata,
|
||||||
config::{Config, HashFor, Hasher},
|
config::{Config, HashFor, Hasher},
|
||||||
error::{Error, MetadataError},
|
error::{Error, MetadataError},
|
||||||
Metadata,
|
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
@@ -106,7 +106,7 @@ impl<T: Config> Extrinsics<T> {
|
|||||||
/// If an error occurs, all subsequent iterations return `None`.
|
/// If an error occurs, all subsequent iterations return `None`.
|
||||||
pub fn find<E: StaticExtrinsic>(
|
pub fn find<E: StaticExtrinsic>(
|
||||||
&self,
|
&self,
|
||||||
) -> impl Iterator<Item = Result<FoundExtrinsic<T, E>, Error>> + '_ {
|
) -> impl Iterator<Item = Result<FoundExtrinsic<T, E>, Error>> {
|
||||||
self.iter().filter_map(|details| {
|
self.iter().filter_map(|details| {
|
||||||
match details.as_extrinsic::<E>() {
|
match details.as_extrinsic::<E>() {
|
||||||
// Failed to decode extrinsic:
|
// Failed to decode extrinsic:
|
||||||
@@ -367,10 +367,10 @@ mod tests {
|
|||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use frame_metadata::v15::{CustomMetadata, OuterEnums};
|
use frame_metadata::v15::{CustomMetadata, OuterEnums};
|
||||||
use frame_metadata::{
|
use frame_metadata::{
|
||||||
v15::{ExtrinsicMetadata, PalletCallMetadata, PalletMetadata, RuntimeMetadataV15},
|
|
||||||
RuntimeMetadataPrefixed,
|
RuntimeMetadataPrefixed,
|
||||||
|
v15::{ExtrinsicMetadata, PalletCallMetadata, PalletMetadata, RuntimeMetadataV15},
|
||||||
};
|
};
|
||||||
use scale_info::{meta_type, TypeInfo};
|
use scale_info::{TypeInfo, meta_type};
|
||||||
use scale_value::Value;
|
use scale_value::Value;
|
||||||
|
|
||||||
// Extrinsic needs to contain at least the generic type parameter "Call"
|
// Extrinsic needs to contain at least the generic type parameter "Call"
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ mod extrinsic_transaction_extensions;
|
|||||||
mod extrinsics;
|
mod extrinsics;
|
||||||
mod static_extrinsic;
|
mod static_extrinsic;
|
||||||
|
|
||||||
|
use crate::Metadata;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::Metadata;
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
pub use crate::error::BlockError;
|
pub use crate::error::BlockError;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
use super::Config;
|
use super::Config;
|
||||||
use super::{transaction_extensions, ExtrinsicParams};
|
use super::{ExtrinsicParams, transaction_extensions};
|
||||||
|
|
||||||
/// The default [`super::ExtrinsicParams`] implementation understands common signed extensions
|
/// The default [`super::ExtrinsicParams`] implementation understands common signed extensions
|
||||||
/// and how to apply them to a given chain.
|
/// and how to apply them to a given chain.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use codec::{Decode, Encode};
|
|||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use scale_decode::DecodeAsType;
|
use scale_decode::DecodeAsType;
|
||||||
use scale_encode::EncodeAsType;
|
use scale_encode::EncodeAsType;
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{Serialize, de::DeserializeOwned};
|
||||||
use subxt_metadata::Metadata;
|
use subxt_metadata::Metadata;
|
||||||
|
|
||||||
pub use default_extrinsic_params::{DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
|
pub use default_extrinsic_params::{DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ pub mod address;
|
|||||||
use address::Address;
|
use address::Address;
|
||||||
use alloc::borrow::ToOwned;
|
use alloc::borrow::ToOwned;
|
||||||
|
|
||||||
use crate::{error::MetadataError, metadata::DecodeWithMetadata, Error, Metadata};
|
use crate::{Error, Metadata, error::MetadataError, metadata::DecodeWithMetadata};
|
||||||
|
|
||||||
/// When the provided `address` is statically generated via the `#[subxt]` macro, this validates
|
/// When the provided `address` is statically generated via the `#[subxt]` macro, this validates
|
||||||
/// that the shape of the constant value is the same as the shape expected by the static address.
|
/// that the shape of the constant value is the same as the shape expected by the static address.
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
pub mod address;
|
pub mod address;
|
||||||
|
|
||||||
use crate::utils::Yes;
|
use crate::utils::Yes;
|
||||||
use crate::{error::MetadataError, metadata::DecodeWithMetadata, Error, Metadata};
|
use crate::{Error, Metadata, error::MetadataError, metadata::DecodeWithMetadata};
|
||||||
use address::Address;
|
use address::Address;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
@@ -96,8 +96,8 @@ mod tests {
|
|||||||
use alloc::collections::BTreeMap;
|
use alloc::collections::BTreeMap;
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use scale_decode::DecodeAsType;
|
use scale_decode::DecodeAsType;
|
||||||
use scale_info::form::PortableForm;
|
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
|
use scale_info::form::PortableForm;
|
||||||
|
|
||||||
use alloc::borrow::ToOwned;
|
use alloc::borrow::ToOwned;
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
|
|||||||
+9
-3
@@ -53,7 +53,9 @@ impl From<codec::Error> for Error {
|
|||||||
#[derive(Debug, DeriveError)]
|
#[derive(Debug, DeriveError)]
|
||||||
pub enum BlockError {
|
pub enum BlockError {
|
||||||
/// Leftover bytes found after decoding the extrinsic.
|
/// Leftover bytes found after decoding the extrinsic.
|
||||||
#[error("After decoding the extrinsic at index {extrinsic_index}, {num_leftover_bytes} bytes were left, suggesting that decoding may have failed")]
|
#[error(
|
||||||
|
"After decoding the extrinsic at index {extrinsic_index}, {num_leftover_bytes} bytes were left, suggesting that decoding may have failed"
|
||||||
|
)]
|
||||||
LeftoverBytes {
|
LeftoverBytes {
|
||||||
/// Index of the extrinsic that failed to decode.
|
/// Index of the extrinsic that failed to decode.
|
||||||
extrinsic_index: usize,
|
extrinsic_index: usize,
|
||||||
@@ -153,10 +155,14 @@ pub enum StorageAddressError {
|
|||||||
#[error("We have leftover bytes after decoding the storage address")]
|
#[error("We have leftover bytes after decoding the storage address")]
|
||||||
TooManyBytes,
|
TooManyBytes,
|
||||||
/// The bytes of a storage address are not the expected address for decoding the storage keys of the address.
|
/// The bytes of a storage address are not the expected address for decoding the storage keys of the address.
|
||||||
#[error("Storage address bytes are not the expected format. Addresses need to be at least 16 bytes (pallet ++ entry) and follow a structure given by the hashers defined in the metadata")]
|
#[error(
|
||||||
|
"Storage address bytes are not the expected format. Addresses need to be at least 16 bytes (pallet ++ entry) and follow a structure given by the hashers defined in the metadata"
|
||||||
|
)]
|
||||||
UnexpectedAddressBytes,
|
UnexpectedAddressBytes,
|
||||||
/// An invalid hasher was used to reconstruct a value from a chunk of bytes that is part of a storage address. Hashers where the hash does not contain the original value are invalid for this purpose.
|
/// An invalid hasher was used to reconstruct a value from a chunk of bytes that is part of a storage address. Hashers where the hash does not contain the original value are invalid for this purpose.
|
||||||
#[error("An invalid hasher was used to reconstruct a value with type ID {ty_id} from a hash formed by a {hasher:?} hasher. This is only possible for concat-style hashers or the identity hasher")]
|
#[error(
|
||||||
|
"An invalid hasher was used to reconstruct a value with type ID {ty_id} from a hash formed by a {hasher:?} hasher. This is only possible for concat-style hashers or the identity hasher"
|
||||||
|
)]
|
||||||
HasherCannotReconstructKey {
|
HasherCannotReconstructKey {
|
||||||
/// Type id of the key's type.
|
/// Type id of the key's type.
|
||||||
ty_id: u32,
|
ty_id: u32,
|
||||||
|
|||||||
+5
-5
@@ -46,9 +46,9 @@ use scale_decode::{DecodeAsFields, DecodeAsType};
|
|||||||
use subxt_metadata::PalletMetadata;
|
use subxt_metadata::PalletMetadata;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Error, Metadata,
|
||||||
config::{Config, HashFor},
|
config::{Config, HashFor},
|
||||||
error::MetadataError,
|
error::MetadataError,
|
||||||
Error, Metadata,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Create a new [`Events`] instance from the given bytes.
|
/// Create a new [`Events`] instance from the given bytes.
|
||||||
@@ -184,7 +184,7 @@ impl<T: Config> Events<T> {
|
|||||||
/// Iterate through the events using metadata to dynamically decode and skip
|
/// Iterate through the events using metadata to dynamically decode and skip
|
||||||
/// them, and return only those which should decode to the provided `Ev` type.
|
/// them, and return only those which should decode to the provided `Ev` type.
|
||||||
/// If an error occurs, all subsequent iterations return `None`.
|
/// If an error occurs, all subsequent iterations return `None`.
|
||||||
pub fn find<Ev: StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> + '_ {
|
pub fn find<Ev: StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> {
|
||||||
self.iter()
|
self.iter()
|
||||||
.filter_map(|ev| ev.and_then(|ev| ev.as_event::<Ev>()).transpose())
|
.filter_map(|ev| ev.and_then(|ev| ev.as_event::<Ev>()).transpose())
|
||||||
}
|
}
|
||||||
@@ -437,13 +437,13 @@ pub(crate) mod test_utils {
|
|||||||
use crate::config::{HashFor, SubstrateConfig};
|
use crate::config::{HashFor, SubstrateConfig};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use frame_metadata::{
|
use frame_metadata::{
|
||||||
|
RuntimeMetadataPrefixed,
|
||||||
v15::{
|
v15::{
|
||||||
CustomMetadata, ExtrinsicMetadata, OuterEnums, PalletEventMetadata, PalletMetadata,
|
CustomMetadata, ExtrinsicMetadata, OuterEnums, PalletEventMetadata, PalletMetadata,
|
||||||
RuntimeMetadataV15,
|
RuntimeMetadataV15,
|
||||||
},
|
},
|
||||||
RuntimeMetadataPrefixed,
|
|
||||||
};
|
};
|
||||||
use scale_info::{meta_type, TypeInfo};
|
use scale_info::{TypeInfo, meta_type};
|
||||||
|
|
||||||
/// An "outer" events enum containing exactly one event.
|
/// An "outer" events enum containing exactly one event.
|
||||||
#[derive(
|
#[derive(
|
||||||
@@ -587,7 +587,7 @@ pub(crate) mod test_utils {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{
|
use super::{
|
||||||
test_utils::{event_record, events, events_raw, AllEvents, EventRecord},
|
test_utils::{AllEvents, EventRecord, event_record, events, events_raw},
|
||||||
*,
|
*,
|
||||||
};
|
};
|
||||||
use crate::config::SubstrateConfig;
|
use crate::config::SubstrateConfig;
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ use derive_where::derive_where;
|
|||||||
use scale_encode::EncodeAsFields;
|
use scale_encode::EncodeAsFields;
|
||||||
use scale_value::Composite;
|
use scale_value::Composite;
|
||||||
|
|
||||||
|
use crate::Error;
|
||||||
use crate::dynamic::DecodedValueThunk;
|
use crate::dynamic::DecodedValueThunk;
|
||||||
use crate::error::MetadataError;
|
use crate::error::MetadataError;
|
||||||
use crate::Error;
|
|
||||||
|
|
||||||
use crate::metadata::{DecodeWithMetadata, Metadata};
|
use crate::metadata::{DecodeWithMetadata, Metadata};
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ mod utils;
|
|||||||
|
|
||||||
pub mod address;
|
pub mod address;
|
||||||
|
|
||||||
use crate::{error::MetadataError, metadata::DecodeWithMetadata, Error, Metadata};
|
use crate::{Error, Metadata, error::MetadataError, metadata::DecodeWithMetadata};
|
||||||
use address::Address;
|
use address::Address;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ impl<K: codec::Decode> StaticStorageKey<K> {
|
|||||||
impl<K: ?Sized> StaticStorageKey<K> {
|
impl<K: ?Sized> StaticStorageKey<K> {
|
||||||
/// Returns the scale-encoded bytes that make up this key
|
/// Returns the scale-encoded bytes that make up this key
|
||||||
pub fn bytes(&self) -> &[u8] {
|
pub fn bytes(&self) -> &[u8] {
|
||||||
&self.bytes.0 .0
|
&self.bytes.0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,7 +361,7 @@ const _: () = {
|
|||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use scale_info::{meta_type, PortableRegistry, Registry, TypeInfo};
|
use scale_info::{PortableRegistry, Registry, TypeInfo, meta_type};
|
||||||
use subxt_metadata::StorageHasher;
|
use subxt_metadata::StorageHasher;
|
||||||
|
|
||||||
use crate::utils::Era;
|
use crate::utils::Era;
|
||||||
@@ -463,15 +463,15 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(keys_a.1.decoded().unwrap(), 13);
|
assert_eq!(keys_a.1.decoded().unwrap(), 13);
|
||||||
assert_eq!(keys_b.1 .0.decoded().unwrap(), 13);
|
assert_eq!(keys_b.1.0.decoded().unwrap(), 13);
|
||||||
assert_eq!(keys_c.0 .1.decoded().unwrap(), 13);
|
assert_eq!(keys_c.0.1.decoded().unwrap(), 13);
|
||||||
|
|
||||||
assert_eq!(keys_a.2.decoded().unwrap(), "Hello");
|
assert_eq!(keys_a.2.decoded().unwrap(), "Hello");
|
||||||
assert_eq!(keys_b.1 .1.decoded().unwrap(), "Hello");
|
assert_eq!(keys_b.1.1.decoded().unwrap(), "Hello");
|
||||||
assert_eq!(keys_c.1 .0.decoded().unwrap(), "Hello");
|
assert_eq!(keys_c.1.0.decoded().unwrap(), "Hello");
|
||||||
assert_eq!(keys_a.3.decoded().unwrap(), era);
|
assert_eq!(keys_a.3.decoded().unwrap(), era);
|
||||||
assert_eq!(keys_b.2.decoded().unwrap(), era);
|
assert_eq!(keys_b.2.decoded().unwrap(), era);
|
||||||
assert_eq!(keys_c.1 .1.decoded().unwrap(), era);
|
assert_eq!(keys_c.1.1.decoded().unwrap(), era);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
//! This module contains the trait and types used to represent
|
//! This module contains the trait and types used to represent
|
||||||
//! transactions that can be submitted.
|
//! transactions that can be submitted.
|
||||||
|
|
||||||
|
use crate::Error;
|
||||||
use crate::error::MetadataError;
|
use crate::error::MetadataError;
|
||||||
use crate::metadata::Metadata;
|
use crate::metadata::Metadata;
|
||||||
use crate::Error;
|
|
||||||
use alloc::borrow::{Cow, ToOwned};
|
use alloc::borrow::{Cow, ToOwned};
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ use alloc::vec::Vec;
|
|||||||
use codec::{Compact, Input};
|
use codec::{Compact, Input};
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use scale_bits::{
|
use scale_bits::{
|
||||||
scale::format::{Format, OrderFormat, StoreFormat},
|
|
||||||
Bits,
|
Bits,
|
||||||
|
scale::format::{Format, OrderFormat, StoreFormat},
|
||||||
};
|
};
|
||||||
use scale_decode::{IntoVisitor, TypeResolver};
|
use scale_decode::{IntoVisitor, TypeResolver};
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use scale_decode::{visitor::DecodeAsTypeResult, IntoVisitor, TypeResolver, Visitor};
|
use scale_decode::{IntoVisitor, TypeResolver, Visitor, visitor::DecodeAsTypeResult};
|
||||||
use scale_encode::EncodeAsType;
|
use scale_encode::EncodeAsType;
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
@@ -44,7 +44,7 @@ impl<T: Decode, R: TypeResolver> Visitor for StaticDecodeAsTypeVisitor<T, R> {
|
|||||||
_type_id: R::TypeId,
|
_type_id: R::TypeId,
|
||||||
_types: &'info R,
|
_types: &'info R,
|
||||||
) -> DecodeAsTypeResult<Self, Result<Self::Value<'scale, 'info>, Self::Error>> {
|
) -> DecodeAsTypeResult<Self, Result<Self::Value<'scale, 'info>, Self::Error>> {
|
||||||
use scale_decode::{visitor::DecodeError, Error};
|
use scale_decode::{Error, visitor::DecodeError};
|
||||||
let decoded = T::decode(input)
|
let decoded = T::decode(input)
|
||||||
.map(Static)
|
.map(Static)
|
||||||
.map_err(|e| Error::new(DecodeError::CodecError(e).into()));
|
.map_err(|e| Error::new(DecodeError::CodecError(e).into()));
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType, IntoVisitor, TypeResolver, Visitor};
|
use scale_decode::{DecodeAsType, IntoVisitor, TypeResolver, Visitor, visitor::DecodeAsTypeResult};
|
||||||
|
|
||||||
use super::{Encoded, Static};
|
use super::{Encoded, Static};
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
@@ -32,7 +32,7 @@ impl<Address, Call, Signature, Extra> UncheckedExtrinsic<Address, Call, Signatur
|
|||||||
|
|
||||||
/// Get the bytes of the encoded extrinsic.
|
/// Get the bytes of the encoded extrinsic.
|
||||||
pub fn bytes(&self) -> &[u8] {
|
pub fn bytes(&self) -> &[u8] {
|
||||||
self.0 .0 .0.as_slice()
|
self.0.0.0.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ impl<Address, Call, Signature, Extra> From<UncheckedExtrinsic<Address, Call, Sig
|
|||||||
for Vec<u8>
|
for Vec<u8>
|
||||||
{
|
{
|
||||||
fn from(bytes: UncheckedExtrinsic<Address, Call, Signature, Extra>) -> Self {
|
fn from(bytes: UncheckedExtrinsic<Address, Call, Signature, Extra>) -> Self {
|
||||||
bytes.0 .0 .0
|
bytes.0.0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +106,8 @@ impl<Address, Call, Signature, Extra> IntoVisitor
|
|||||||
type AnyVisitor<R: TypeResolver> =
|
type AnyVisitor<R: TypeResolver> =
|
||||||
UncheckedExtrinsicDecodeAsTypeVisitor<Address, Call, Signature, Extra, R>;
|
UncheckedExtrinsicDecodeAsTypeVisitor<Address, Call, Signature, Extra, R>;
|
||||||
|
|
||||||
fn into_visitor<R: TypeResolver>(
|
fn into_visitor<R: TypeResolver>()
|
||||||
) -> UncheckedExtrinsicDecodeAsTypeVisitor<Address, Call, Signature, Extra, R> {
|
-> UncheckedExtrinsicDecodeAsTypeVisitor<Address, Call, Signature, Extra, R> {
|
||||||
UncheckedExtrinsicDecodeAsTypeVisitor(PhantomData)
|
UncheckedExtrinsicDecodeAsTypeVisitor(PhantomData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
use super::PhantomDataSendSync;
|
use super::PhantomDataSendSync;
|
||||||
use codec::{Compact, Decode, DecodeAll, Encode};
|
use codec::{Compact, Decode, DecodeAll, Encode};
|
||||||
use derive_where::derive_where;
|
use derive_where::derive_where;
|
||||||
use scale_decode::{ext::scale_type_resolver::visitor, IntoVisitor, TypeResolver, Visitor};
|
use scale_decode::{IntoVisitor, TypeResolver, Visitor, ext::scale_type_resolver::visitor};
|
||||||
use scale_encode::EncodeAsType;
|
use scale_encode::EncodeAsType;
|
||||||
|
|
||||||
use alloc::format;
|
use alloc::format;
|
||||||
@@ -135,7 +135,9 @@ impl<T, R: TypeResolver> Visitor for WrapperKeepOpaqueVisitor<T, R> {
|
|||||||
|
|
||||||
// Sanity check that the compact length we decoded lines up with the number of bytes encoded in the next field.
|
// Sanity check that the compact length we decoded lines up with the number of bytes encoded in the next field.
|
||||||
if field.bytes().len() != len as usize {
|
if field.bytes().len() != len as usize {
|
||||||
return Err(Error::custom_str("WrapperTypeKeepOpaque compact encoded length doesn't line up with encoded byte len"));
|
return Err(Error::custom_str(
|
||||||
|
"WrapperTypeKeepOpaque compact encoded length doesn't line up with encoded byte len",
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(WrapperKeepOpaque {
|
Ok(WrapperKeepOpaque {
|
||||||
@@ -166,7 +168,7 @@ mod test {
|
|||||||
impl<T: scale_info::TypeInfo + 'static> scale_info::TypeInfo for WrapperKeepOpaque<T> {
|
impl<T: scale_info::TypeInfo + 'static> scale_info::TypeInfo for WrapperKeepOpaque<T> {
|
||||||
type Identity = Self;
|
type Identity = Self;
|
||||||
fn type_info() -> scale_info::Type {
|
fn type_info() -> scale_info::Type {
|
||||||
use scale_info::{build::Fields, meta_type, Path, Type, TypeParameter};
|
use scale_info::{Path, Type, TypeParameter, build::Fields, meta_type};
|
||||||
|
|
||||||
Type::builder()
|
Type::builder()
|
||||||
.path(Path::new("WrapperKeepOpaque", module_path!()))
|
.path(Path::new("WrapperKeepOpaque", module_path!()))
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ use derive_where::derive_where;
|
|||||||
use scale_encode::EncodeAsFields;
|
use scale_encode::EncodeAsFields;
|
||||||
use scale_value::Composite;
|
use scale_value::Composite;
|
||||||
|
|
||||||
|
use crate::Error;
|
||||||
use crate::dynamic::DecodedValueThunk;
|
use crate::dynamic::DecodedValueThunk;
|
||||||
use crate::error::MetadataError;
|
use crate::error::MetadataError;
|
||||||
use crate::Error;
|
|
||||||
|
|
||||||
use crate::metadata::{DecodeWithMetadata, Metadata};
|
use crate::metadata::{DecodeWithMetadata, Metadata};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
use crate::rpc::RpcResponse;
|
use crate::rpc::RpcResponse;
|
||||||
use crate::shared_client::SharedClient;
|
use crate::shared_client::SharedClient;
|
||||||
use crate::{JsonRpcError, LightClientRpcError};
|
use crate::{JsonRpcError, LightClientRpcError};
|
||||||
use futures::{stream::StreamExt, FutureExt};
|
use futures::{FutureExt, stream::StreamExt};
|
||||||
use serde_json::value::RawValue;
|
use serde_json::value::RawValue;
|
||||||
use smoldot_light::platform::PlatformRef;
|
use smoldot_light::platform::PlatformRef;
|
||||||
use std::{collections::HashMap, str::FromStr};
|
use std::{collections::HashMap, str::FromStr};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ mod wasm_platform;
|
|||||||
#[cfg(feature = "web")]
|
#[cfg(feature = "web")]
|
||||||
mod wasm_socket;
|
mod wasm_socket;
|
||||||
|
|
||||||
pub use helpers::{build_platform, DefaultPlatform};
|
pub use helpers::{DefaultPlatform, build_platform};
|
||||||
|
|
||||||
#[cfg(feature = "native")]
|
#[cfg(feature = "native")]
|
||||||
mod helpers {
|
mod helpers {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
use super::wasm_socket::WasmSocket;
|
use super::wasm_socket::WasmSocket;
|
||||||
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use futures_util::{future, FutureExt};
|
use futures_util::{FutureExt, future};
|
||||||
|
|
||||||
pub fn now_from_unix_epoch() -> Duration {
|
pub fn now_from_unix_epoch() -> Duration {
|
||||||
web_time::SystemTime::now()
|
web_time::SystemTime::now()
|
||||||
|
|||||||
@@ -141,7 +141,9 @@ impl PlatformRef for SubxtPlatform {
|
|||||||
// The API user of the `PlatformRef` trait is never supposed to open connections of
|
// The API user of the `PlatformRef` trait is never supposed to open connections of
|
||||||
// a type that isn't supported.
|
// a type that isn't supported.
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!("Connecting to an address not supported. This code path indicates a bug in smoldot. Please raise an issue at https://github.com/smol-dot/smoldot/issues")
|
unreachable!(
|
||||||
|
"Connecting to an address not supported. This code path indicates a bug in smoldot. Please raise an issue at https://github.com/smol-dot/smoldot/issues"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -157,7 +159,9 @@ impl PlatformRef for SubxtPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn connect_multistream(&self, _address: MultiStreamAddress) -> Self::MultiStreamConnectFuture {
|
fn connect_multistream(&self, _address: MultiStreamAddress) -> Self::MultiStreamConnectFuture {
|
||||||
panic!("Multistreams are not currently supported. This code path indicates a bug in smoldot. Please raise an issue at https://github.com/smol-dot/smoldot/issues")
|
panic!(
|
||||||
|
"Multistreams are not currently supported. This code path indicates a bug in smoldot. Please raise an issue at https://github.com/smol-dot/smoldot/issues"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_out_substream(&self, c: &mut Self::MultiStream) {
|
fn open_out_substream(&self, c: &mut Self::MultiStream) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use futures::{io, prelude::*};
|
use futures::{io, prelude::*};
|
||||||
use send_wrapper::SendWrapper;
|
use send_wrapper::SendWrapper;
|
||||||
use wasm_bindgen::{prelude::*, JsCast};
|
use wasm_bindgen::{JsCast, prelude::*};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
|
|||||||
+6
-6
@@ -5,7 +5,7 @@
|
|||||||
//! Subxt macro for generating Substrate runtime interfaces.
|
//! Subxt macro for generating Substrate runtime interfaces.
|
||||||
|
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
use darling::{ast::NestedMeta, FromMeta};
|
use darling::{FromMeta, ast::NestedMeta};
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use proc_macro_error2::{abort_call_site, proc_macro_error};
|
use proc_macro_error2::{abort_call_site, proc_macro_error};
|
||||||
use quote::ToTokens;
|
use quote::ToTokens;
|
||||||
@@ -241,7 +241,7 @@ fn fetch_metadata(args: &RuntimeMetadataArgs) -> Result<subxt_codegen::Metadata,
|
|||||||
}
|
}
|
||||||
#[cfg(feature = "runtime-metadata-insecure-url")]
|
#[cfg(feature = "runtime-metadata-insecure-url")]
|
||||||
(None, Some(url_string)) => {
|
(None, Some(url_string)) => {
|
||||||
use subxt_utils_fetchmetadata::{from_url_blocking, MetadataVersion, Url};
|
use subxt_utils_fetchmetadata::{MetadataVersion, Url, from_url_blocking};
|
||||||
|
|
||||||
let url = Url::parse(url_string).unwrap_or_else(|_| {
|
let url = Url::parse(url_string).unwrap_or_else(|_| {
|
||||||
abort_call_site!("Cannot download metadata; invalid url: {}", url_string)
|
abort_call_site!("Cannot download metadata; invalid url: {}", url_string)
|
||||||
@@ -266,8 +266,8 @@ fn fetch_metadata(args: &RuntimeMetadataArgs) -> Result<subxt_codegen::Metadata,
|
|||||||
#[cfg(feature = "runtime-wasm-path")]
|
#[cfg(feature = "runtime-wasm-path")]
|
||||||
(None, None) => {
|
(None, None) => {
|
||||||
abort_call_site!(
|
abort_call_site!(
|
||||||
"At least one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or 'runtime_path` can be provided"
|
"At least one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or 'runtime_path` can be provided"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "runtime-wasm-path"))]
|
#[cfg(not(feature = "runtime-wasm-path"))]
|
||||||
(None, None) => {
|
(None, None) => {
|
||||||
@@ -278,8 +278,8 @@ fn fetch_metadata(args: &RuntimeMetadataArgs) -> Result<subxt_codegen::Metadata,
|
|||||||
#[cfg(feature = "runtime-wasm-path")]
|
#[cfg(feature = "runtime-wasm-path")]
|
||||||
_ => {
|
_ => {
|
||||||
abort_call_site!(
|
abort_call_site!(
|
||||||
"Only one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or 'runtime_path` can be provided"
|
"Only one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or 'runtime_path` can be provided"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "runtime-wasm-path"))]
|
#[cfg(not(feature = "runtime-wasm-path"))]
|
||||||
_ => {
|
_ => {
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ use super::TryFromError;
|
|||||||
|
|
||||||
use crate::utils::variant_index::VariantIndex;
|
use crate::utils::variant_index::VariantIndex;
|
||||||
use crate::{
|
use crate::{
|
||||||
utils::ordered_map::OrderedMap, ArcStr, ConstantMetadata, CustomMetadataInner,
|
ArcStr, ConstantMetadata, CustomMetadataInner, ExtrinsicMetadata, Metadata, OuterEnumsMetadata,
|
||||||
ExtrinsicMetadata, Metadata, OuterEnumsMetadata, PalletMetadataInner, StorageEntryMetadata,
|
PalletMetadataInner, StorageEntryMetadata, StorageEntryModifier, StorageEntryType,
|
||||||
StorageEntryModifier, StorageEntryType, StorageHasher, StorageMetadata,
|
StorageHasher, StorageMetadata, TransactionExtensionMetadataInner,
|
||||||
TransactionExtensionMetadataInner,
|
utils::ordered_map::OrderedMap,
|
||||||
};
|
};
|
||||||
use alloc::borrow::ToOwned;
|
use alloc::borrow::ToOwned;
|
||||||
use alloc::collections::BTreeMap;
|
use alloc::collections::BTreeMap;
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ use super::TryFromError;
|
|||||||
|
|
||||||
use crate::utils::variant_index::VariantIndex;
|
use crate::utils::variant_index::VariantIndex;
|
||||||
use crate::{
|
use crate::{
|
||||||
utils::ordered_map::OrderedMap, ArcStr, ConstantMetadata, ExtrinsicMetadata, Metadata,
|
ArcStr, ConstantMetadata, ExtrinsicMetadata, Metadata, MethodParamMetadata, OuterEnumsMetadata,
|
||||||
MethodParamMetadata, OuterEnumsMetadata, PalletMetadataInner, RuntimeApiMetadataInner,
|
PalletMetadataInner, RuntimeApiMetadataInner, RuntimeApiMethodMetadataInner,
|
||||||
RuntimeApiMethodMetadataInner, StorageEntryMetadata, StorageEntryModifier, StorageEntryType,
|
StorageEntryMetadata, StorageEntryModifier, StorageEntryType, StorageHasher, StorageMetadata,
|
||||||
StorageHasher, StorageMetadata, TransactionExtensionMetadataInner,
|
TransactionExtensionMetadataInner, utils::ordered_map::OrderedMap,
|
||||||
};
|
};
|
||||||
use alloc::collections::BTreeMap;
|
use alloc::collections::BTreeMap;
|
||||||
use alloc::vec;
|
use alloc::vec;
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ use super::TryFromError;
|
|||||||
|
|
||||||
use crate::utils::variant_index::VariantIndex;
|
use crate::utils::variant_index::VariantIndex;
|
||||||
use crate::{
|
use crate::{
|
||||||
utils::ordered_map::OrderedMap, ArcStr, ConstantMetadata, ExtrinsicMetadata, Metadata,
|
ArcStr, ConstantMetadata, ExtrinsicMetadata, Metadata, MethodParamMetadata, OuterEnumsMetadata,
|
||||||
MethodParamMetadata, OuterEnumsMetadata, PalletMetadataInner, RuntimeApiMetadataInner,
|
PalletMetadataInner, RuntimeApiMetadataInner, RuntimeApiMethodMetadataInner,
|
||||||
RuntimeApiMethodMetadataInner, StorageEntryMetadata, StorageEntryModifier, StorageEntryType,
|
StorageEntryMetadata, StorageEntryModifier, StorageEntryType, StorageHasher, StorageMetadata,
|
||||||
StorageHasher, StorageMetadata, TransactionExtensionMetadataInner, ViewFunctionMetadataInner,
|
TransactionExtensionMetadataInner, ViewFunctionMetadataInner, utils::ordered_map::OrderedMap,
|
||||||
};
|
};
|
||||||
use frame_metadata::{v15, v16};
|
use frame_metadata::{v15, v16};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
|
|||||||
+12
-10
@@ -32,17 +32,17 @@ use frame_decode::extrinsics::{
|
|||||||
ExtrinsicSignatureInfo,
|
ExtrinsicSignatureInfo,
|
||||||
};
|
};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use scale_info::{form::PortableForm, PortableRegistry, Variant};
|
use scale_info::{PortableRegistry, Variant, form::PortableForm};
|
||||||
use utils::{
|
use utils::{
|
||||||
ordered_map::OrderedMap,
|
ordered_map::OrderedMap,
|
||||||
validation::{get_custom_value_hash, HASH_LEN},
|
validation::{HASH_LEN, get_custom_value_hash},
|
||||||
variant_index::VariantIndex,
|
variant_index::VariantIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
type ArcStr = Arc<str>;
|
type ArcStr = Arc<str>;
|
||||||
|
|
||||||
pub use from::TryFromError;
|
|
||||||
pub use from::SUPPORTED_METADATA_VERSIONS;
|
pub use from::SUPPORTED_METADATA_VERSIONS;
|
||||||
|
pub use from::TryFromError;
|
||||||
pub use utils::validation::MetadataHasher;
|
pub use utils::validation::MetadataHasher;
|
||||||
|
|
||||||
type CustomMetadataInner = frame_metadata::v15::CustomMetadata<PortableForm>;
|
type CustomMetadataInner = frame_metadata::v15::CustomMetadata<PortableForm>;
|
||||||
@@ -314,7 +314,9 @@ impl<'a> PalletMetadata<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return an iterator over the View Functions in this pallet, if any.
|
/// Return an iterator over the View Functions in this pallet, if any.
|
||||||
pub fn view_functions(&self) -> impl ExactSizeIterator<Item = ViewFunctionMetadata<'a>> {
|
pub fn view_functions(
|
||||||
|
&self,
|
||||||
|
) -> impl ExactSizeIterator<Item = ViewFunctionMetadata<'a>> + use<'a> {
|
||||||
self.inner
|
self.inner
|
||||||
.view_functions
|
.view_functions
|
||||||
.values()
|
.values()
|
||||||
@@ -337,7 +339,7 @@ impl<'a> PalletMetadata<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate (in no particular order) over the associated type names and type IDs for this pallet.
|
/// Iterate (in no particular order) over the associated type names and type IDs for this pallet.
|
||||||
pub fn associated_types(&self) -> impl ExactSizeIterator<Item = (&str, u32)> {
|
pub fn associated_types(&self) -> impl ExactSizeIterator<Item = (&'a str, u32)> + use<'a> {
|
||||||
self.inner
|
self.inner
|
||||||
.associated_types
|
.associated_types
|
||||||
.iter()
|
.iter()
|
||||||
@@ -388,7 +390,7 @@ impl<'a> PalletMetadata<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator over the constants in this pallet.
|
/// An iterator over the constants in this pallet.
|
||||||
pub fn constants(&self) -> impl ExactSizeIterator<Item = &'a ConstantMetadata> {
|
pub fn constants(&self) -> impl ExactSizeIterator<Item = &'a ConstantMetadata> + use<'a> {
|
||||||
self.inner.constants.values().iter()
|
self.inner.constants.values().iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -783,7 +785,7 @@ impl<'a> RuntimeApiMetadata<'a> {
|
|||||||
&self.inner.docs
|
&self.inner.docs
|
||||||
}
|
}
|
||||||
/// An iterator over the trait methods.
|
/// An iterator over the trait methods.
|
||||||
pub fn methods(&self) -> impl ExactSizeIterator<Item = RuntimeApiMethodMetadata<'a>> {
|
pub fn methods(&self) -> impl ExactSizeIterator<Item = RuntimeApiMethodMetadata<'a>> + use<'a> {
|
||||||
self.inner
|
self.inner
|
||||||
.methods
|
.methods
|
||||||
.values()
|
.values()
|
||||||
@@ -839,7 +841,7 @@ impl<'a> RuntimeApiMethodMetadata<'a> {
|
|||||||
&self.inner.docs
|
&self.inner.docs
|
||||||
}
|
}
|
||||||
/// Method inputs.
|
/// Method inputs.
|
||||||
pub fn inputs(&self) -> impl ExactSizeIterator<Item = &MethodParamMetadata> {
|
pub fn inputs(&self) -> impl ExactSizeIterator<Item = &'a MethodParamMetadata> + use<'a> {
|
||||||
self.inner.inputs.iter()
|
self.inner.inputs.iter()
|
||||||
}
|
}
|
||||||
/// Method return type.
|
/// Method return type.
|
||||||
@@ -887,7 +889,7 @@ impl<'a> ViewFunctionMetadata<'a> {
|
|||||||
&self.inner.docs
|
&self.inner.docs
|
||||||
}
|
}
|
||||||
/// Method inputs.
|
/// Method inputs.
|
||||||
pub fn inputs(&self) -> impl ExactSizeIterator<Item = &'a MethodParamMetadata> {
|
pub fn inputs(&self) -> impl ExactSizeIterator<Item = &'a MethodParamMetadata> + use<'a> {
|
||||||
self.inner.inputs.iter()
|
self.inner.inputs.iter()
|
||||||
}
|
}
|
||||||
/// Method return type.
|
/// Method return type.
|
||||||
@@ -947,7 +949,7 @@ impl<'a> CustomMetadata<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Iterates over names (keys) and associated custom values
|
/// Iterates over names (keys) and associated custom values
|
||||||
pub fn iter(&self) -> impl Iterator<Item = CustomValueMetadata> {
|
pub fn iter(&self) -> impl Iterator<Item = CustomValueMetadata<'a>> + use<'a> {
|
||||||
self.inner.map.iter().map(|(name, e)| CustomValueMetadata {
|
self.inner.map.iter().map(|(name, e)| CustomValueMetadata {
|
||||||
types: self.types,
|
types: self.types,
|
||||||
type_id: e.ty.id,
|
type_id: e.ty.id,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use scale_info::{form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefVariant, Variant};
|
use scale_info::{Field, PortableRegistry, TypeDef, TypeDefVariant, Variant, form::PortableForm};
|
||||||
|
|
||||||
// The number of bytes our `hash` function produces.
|
// The number of bytes our `hash` function produces.
|
||||||
pub(crate) const HASH_LEN: usize = 32;
|
pub(crate) const HASH_LEN: usize = 32;
|
||||||
@@ -604,7 +604,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use bitvec::{order::Lsb0, vec::BitVec};
|
use bitvec::{order::Lsb0, vec::BitVec};
|
||||||
use frame_metadata::v15;
|
use frame_metadata::v15;
|
||||||
use scale_info::{meta_type, Registry};
|
use scale_info::{Registry, meta_type};
|
||||||
|
|
||||||
// Define recursive types.
|
// Define recursive types.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
use alloc::borrow::ToOwned;
|
use alloc::borrow::ToOwned;
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use scale_info::{form::PortableForm, PortableRegistry, TypeDef, Variant};
|
use scale_info::{PortableRegistry, TypeDef, Variant, form::PortableForm};
|
||||||
|
|
||||||
/// Given some type ID and type registry, build a couple of
|
/// Given some type ID and type registry, build a couple of
|
||||||
/// indexes to look up variants by index or name. If the ID provided
|
/// indexes to look up variants by index or name. If the ID provided
|
||||||
|
|||||||
@@ -19,12 +19,11 @@
|
|||||||
//! // Define a mock client by providing some functions which intercept
|
//! // Define a mock client by providing some functions which intercept
|
||||||
//! // method and subscription calls and return some response.
|
//! // method and subscription calls and return some response.
|
||||||
//! let mock_client = MockRpcClient::builder()
|
//! let mock_client = MockRpcClient::builder()
|
||||||
//! .method_handler_once("foo", move |params| {
|
//! .method_handler_once("foo", async move |params| {
|
||||||
//! // Return each item from our state, and then null afterwards.
|
//! // Return each item from our state, and then null afterwards.
|
||||||
//! let val = state.pop();
|
//! state.pop()
|
||||||
//! async move { val }
|
|
||||||
//! })
|
//! })
|
||||||
//! .subscription_handler("bar", |params, unsub| async move {
|
//! .subscription_handler("bar", async move |params, unsub| {
|
||||||
//! // Arrays, vecs or an RpcSubscription can be returned here to
|
//! // Arrays, vecs or an RpcSubscription can be returned here to
|
||||||
//! // signal the set of values to be handed back on a subscription.
|
//! // signal the set of values to be handed back on a subscription.
|
||||||
//! vec![Json(1), Json(2), Json(3)]
|
//! vec![Json(1), Json(2), Json(3)]
|
||||||
@@ -477,7 +476,7 @@ mod test {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_method_params() {
|
async fn test_method_params() {
|
||||||
let rpc_client = MockRpcClient::builder()
|
let rpc_client = MockRpcClient::builder()
|
||||||
.method_handler("foo", |params| async {
|
.method_handler("foo", async |params| {
|
||||||
Json(params)
|
Json(params)
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
@@ -495,10 +494,10 @@ mod test {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_method_handler_then_fallback() {
|
async fn test_method_handler_then_fallback() {
|
||||||
let rpc_client = MockRpcClient::builder()
|
let rpc_client = MockRpcClient::builder()
|
||||||
.method_handler("foo", |_params| async {
|
.method_handler("foo", async |_params| {
|
||||||
Json(1)
|
Json(1)
|
||||||
})
|
})
|
||||||
.method_fallback(|name, _params| async {
|
.method_fallback(async |name, _params| {
|
||||||
Json(name)
|
Json(name)
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
@@ -521,10 +520,10 @@ mod test {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_method_once_then_handler() {
|
async fn test_method_once_then_handler() {
|
||||||
let rpc_client = MockRpcClient::builder()
|
let rpc_client = MockRpcClient::builder()
|
||||||
.method_handler_once("foo", |_params| async {
|
.method_handler_once("foo", async |_params| {
|
||||||
Json(1)
|
Json(1)
|
||||||
})
|
})
|
||||||
.method_handler("foo", |_params| async {
|
.method_handler("foo", async |_params| {
|
||||||
Json(2)
|
Json(2)
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
@@ -541,13 +540,13 @@ mod test {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_method_once() {
|
async fn test_method_once() {
|
||||||
let rpc_client = MockRpcClient::builder()
|
let rpc_client = MockRpcClient::builder()
|
||||||
.method_handler_once("foo", |_params| async {
|
.method_handler_once("foo", async |_params| {
|
||||||
Json(1)
|
Json(1)
|
||||||
})
|
})
|
||||||
.method_handler_once("foo", |_params| async {
|
.method_handler_once("foo", async |_params| {
|
||||||
Json(2)
|
Json(2)
|
||||||
})
|
})
|
||||||
.method_handler_once("foo", |_params| async {
|
.method_handler_once("foo", async |_params| {
|
||||||
Json(3)
|
Json(3)
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
@@ -569,13 +568,13 @@ mod test {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_subscription_once_then_handler_then_fallback() {
|
async fn test_subscription_once_then_handler_then_fallback() {
|
||||||
let rpc_client = MockRpcClient::builder()
|
let rpc_client = MockRpcClient::builder()
|
||||||
.subscription_handler_once("foo", |_params, _unsub| async {
|
.subscription_handler_once("foo", async |_params, _unsub| {
|
||||||
vec![Json(0), Json(0)]
|
vec![Json(0), Json(0)]
|
||||||
})
|
})
|
||||||
.subscription_handler("foo", |_params, _unsub| async {
|
.subscription_handler("foo", async |_params, _unsub| {
|
||||||
vec![Json(1), Json(2), Json(3)]
|
vec![Json(1), Json(2), Json(3)]
|
||||||
})
|
})
|
||||||
.subscription_fallback(|_name, _params, _unsub| async {
|
.subscription_fallback(async |_name, _params, _unsub| {
|
||||||
vec![Json(4)]
|
vec![Json(4)]
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
@@ -605,7 +604,7 @@ mod test {
|
|||||||
let (tx, rx) = tokio::sync::mpsc::channel(10);
|
let (tx, rx) = tokio::sync::mpsc::channel(10);
|
||||||
|
|
||||||
let rpc_client = MockRpcClient::builder()
|
let rpc_client = MockRpcClient::builder()
|
||||||
.subscription_handler_once("foo", move |_params, _unsub| async move {
|
.subscription_handler_once("foo", async move |_params, _unsub| {
|
||||||
AndThen(
|
AndThen(
|
||||||
// These should be sent first..
|
// These should be sent first..
|
||||||
vec![Json(1), Json(2), Json(3)],
|
vec![Json(1), Json(2), Json(3)],
|
||||||
|
|||||||
@@ -48,5 +48,5 @@ crate::macros::cfg_mock_rpc_client! {
|
|||||||
mod rpc_client;
|
mod rpc_client;
|
||||||
mod rpc_client_t;
|
mod rpc_client_t;
|
||||||
|
|
||||||
pub use rpc_client::{rpc_params, RpcClient, RpcParams, RpcSubscription};
|
pub use rpc_client::{RpcClient, RpcParams, RpcSubscription, rpc_params};
|
||||||
pub use rpc_client_t::{RawRpcFuture, RawRpcSubscription, RawValue, RpcClientT};
|
pub use rpc_client_t::{RawRpcFuture, RawRpcSubscription, RawValue, RpcClientT};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
use super::{RawRpcSubscription, RpcClientT};
|
use super::{RawRpcSubscription, RpcClientT};
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{Serialize, de::DeserializeOwned};
|
||||||
use serde_json::value::RawValue;
|
use serde_json::value::RawValue;
|
||||||
use std::{pin::Pin, sync::Arc, task::Poll};
|
use std::{pin::Pin, sync::Arc, task::Poll};
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
//! <https://github.com/paritytech/json-rpc-interface-spec/> for details of the API
|
//! <https://github.com/paritytech/json-rpc-interface-spec/> for details of the API
|
||||||
//! methods exposed here.
|
//! methods exposed here.
|
||||||
|
|
||||||
use crate::client::{rpc_params, RpcClient, RpcSubscription};
|
|
||||||
use crate::Hash;
|
use crate::Hash;
|
||||||
|
use crate::client::{RpcClient, RpcSubscription, rpc_params};
|
||||||
use crate::{Error, RpcConfig};
|
use crate::{Error, RpcConfig};
|
||||||
use derive_where::derive_where;
|
use derive_where::derive_where;
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
//! An interface to call the raw legacy RPC methods.
|
//! An interface to call the raw legacy RPC methods.
|
||||||
|
|
||||||
use crate::client::{rpc_params, RpcClient, RpcSubscription};
|
use crate::client::{RpcClient, RpcSubscription, rpc_params};
|
||||||
use crate::{Error, RpcConfig};
|
use crate::{Error, RpcConfig};
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
use derive_where::derive_where;
|
use derive_where::derive_where;
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ fn main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Generate the polkadot chain spec.
|
// Generate the polkadot chain spec.
|
||||||
run_cmd("cargo run --features chain-spec-pruning --bin subxt chain-spec --url wss://rpc.polkadot.io:443 --output-file artifacts/demo_chain_specs/polkadot.json --state-root-hash --remove-substitutes", None);
|
run_cmd(
|
||||||
|
"cargo run --features chain-spec-pruning --bin subxt chain-spec --url wss://rpc.polkadot.io:443 --output-file artifacts/demo_chain_specs/polkadot.json --state-root-hash --remove-substitutes",
|
||||||
|
None,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_cmd(cmd: &str, out_path: Option<&str>) {
|
fn run_cmd(cmd: &str, out_path: Option<&str>) {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ impl DeriveJunction {
|
|||||||
/// Get a reference to the inner junction id.
|
/// Get a reference to the inner junction id.
|
||||||
pub fn inner(&self) -> &[u8; JUNCTION_ID_LEN] {
|
pub fn inner(&self) -> &[u8; JUNCTION_ID_LEN] {
|
||||||
match self {
|
match self {
|
||||||
DeriveJunction::Hard(ref c) | DeriveJunction::Soft(ref c) => c,
|
DeriveJunction::Hard(c) | DeriveJunction::Soft(c) => c,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,10 +97,6 @@ impl<T: AsRef<str>> From<T> for DeriveJunction {
|
|||||||
DeriveJunction::soft(code)
|
DeriveJunction::soft(code)
|
||||||
};
|
};
|
||||||
|
|
||||||
if hard {
|
if hard { res.harden() } else { res }
|
||||||
res.harden()
|
|
||||||
} else {
|
|
||||||
res
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ mod secret_uri;
|
|||||||
mod seed_from_entropy;
|
mod seed_from_entropy;
|
||||||
|
|
||||||
pub use derive_junction::DeriveJunction;
|
pub use derive_junction::DeriveJunction;
|
||||||
pub use secret_uri::{SecretUri, SecretUriError, DEV_PHRASE};
|
pub use secret_uri::{DEV_PHRASE, SecretUri, SecretUriError};
|
||||||
|
|
||||||
#[cfg(any(feature = "sr25519", feature = "ecdsa"))]
|
#[cfg(any(feature = "sr25519", feature = "ecdsa"))]
|
||||||
pub use seed_from_entropy::seed_from_entropy;
|
pub use seed_from_entropy::seed_from_entropy;
|
||||||
|
|||||||
+2
-2
@@ -5,10 +5,10 @@
|
|||||||
//! An ecdsa keypair implementation.
|
//! An ecdsa keypair implementation.
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
|
|
||||||
use crate::crypto::{seed_from_entropy, DeriveJunction, SecretUri};
|
use crate::crypto::{DeriveJunction, SecretUri, seed_from_entropy};
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
use hex::FromHex;
|
use hex::FromHex;
|
||||||
use secp256k1::{ecdsa::RecoverableSignature, Message, Secp256k1, SecretKey};
|
use secp256k1::{Message, Secp256k1, SecretKey, ecdsa::RecoverableSignature};
|
||||||
use secrecy::ExposeSecret;
|
use secrecy::ExposeSecret;
|
||||||
|
|
||||||
use thiserror::Error as DeriveError;
|
use thiserror::Error as DeriveError;
|
||||||
|
|||||||
+3
-3
@@ -105,7 +105,7 @@ impl Keypair {
|
|||||||
|
|
||||||
/// Obtain the [`eth::PublicKey`] of this keypair.
|
/// Obtain the [`eth::PublicKey`] of this keypair.
|
||||||
pub fn public_key(&self) -> PublicKey {
|
pub fn public_key(&self) -> PublicKey {
|
||||||
let uncompressed = self.0 .0.public_key().serialize_uncompressed();
|
let uncompressed = self.0.0.public_key().serialize_uncompressed();
|
||||||
PublicKey(uncompressed)
|
PublicKey(uncompressed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,7 +450,7 @@ mod test {
|
|||||||
|
|
||||||
for (case_idx, (keypair, exp_account_id, exp_priv_key)) in cases.into_iter().enumerate() {
|
for (case_idx, (keypair, exp_account_id, exp_priv_key)) in cases.into_iter().enumerate() {
|
||||||
let act_account_id = keypair.public_key().to_account_id().checksum();
|
let act_account_id = keypair.public_key().to_account_id().checksum();
|
||||||
let act_priv_key = format!("0x{}", &keypair.0 .0.display_secret());
|
let act_priv_key = format!("0x{}", &keypair.0.0.display_secret());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
exp_account_id, act_account_id,
|
exp_account_id, act_account_id,
|
||||||
@@ -563,7 +563,7 @@ mod test {
|
|||||||
(
|
(
|
||||||
"void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold",
|
"void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold",
|
||||||
"01f5bced59dec48e362f2c45b5de68b9fd6c92c6634f44d6d40aab69056506f0e35524a518034ddc1192e1dacd32c1ed3eaa3c3b131c88ed8e7e54c49a5d0998",
|
"01f5bced59dec48e362f2c45b5de68b9fd6c92c6634f44d6d40aab69056506f0e35524a518034ddc1192e1dacd32c1ed3eaa3c3b131c88ed8e7e54c49a5d0998",
|
||||||
)
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (idx, (m, s)) in mnemonics_and_seeds.into_iter().enumerate() {
|
for (idx, (m, s)) in mnemonics_and_seeds.into_iter().enumerate() {
|
||||||
|
|||||||
+1
-1
@@ -52,4 +52,4 @@ pub use secrecy::{ExposeSecret, SecretString};
|
|||||||
|
|
||||||
// SecretUri's can be parsed from strings and used to generate key pairs.
|
// SecretUri's can be parsed from strings and used to generate key pairs.
|
||||||
// DeriveJunctions are the "path" part of these SecretUris.
|
// DeriveJunctions are the "path" part of these SecretUris.
|
||||||
pub use crypto::{DeriveJunction, SecretUri, SecretUriError, DEV_PHRASE};
|
pub use crypto::{DEV_PHRASE, DeriveJunction, SecretUri, SecretUriError};
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use crypto_secretbox::{
|
use crypto_secretbox::{
|
||||||
aead::{Aead, KeyInit},
|
|
||||||
Key, Nonce, XSalsa20Poly1305,
|
Key, Nonce, XSalsa20Poly1305,
|
||||||
|
aead::{Aead, KeyInit},
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use subxt_core::utils::AccountId32;
|
use subxt_core::utils::AccountId32;
|
||||||
|
|||||||
@@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
|
|
||||||
use crate::crypto::{seed_from_entropy, DeriveJunction, SecretUri};
|
use crate::crypto::{DeriveJunction, SecretUri, seed_from_entropy};
|
||||||
|
|
||||||
use hex::FromHex;
|
use hex::FromHex;
|
||||||
use schnorrkel::{
|
use schnorrkel::{
|
||||||
derive::{ChainCode, Derivation},
|
|
||||||
ExpansionMode, MiniSecretKey,
|
ExpansionMode, MiniSecretKey,
|
||||||
|
derive::{ChainCode, Derivation},
|
||||||
};
|
};
|
||||||
use secrecy::ExposeSecret;
|
use secrecy::ExposeSecret;
|
||||||
|
|
||||||
@@ -292,9 +292,9 @@ mod subxt_compat {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use subxt_core::{
|
use subxt_core::{
|
||||||
|
Config,
|
||||||
tx::signer::Signer as SignerT,
|
tx::signer::Signer as SignerT,
|
||||||
utils::{AccountId32, MultiAddress, MultiSignature},
|
utils::{AccountId32, MultiAddress, MultiSignature},
|
||||||
Config,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
impl From<Signature> for MultiSignature {
|
impl From<Signature> for MultiSignature {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
use subxt::{
|
use subxt::{
|
||||||
utils::{AccountId32, MultiAddress},
|
|
||||||
OnlineClient, PolkadotConfig,
|
OnlineClient, PolkadotConfig,
|
||||||
|
utils::{AccountId32, MultiAddress},
|
||||||
};
|
};
|
||||||
|
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
@@ -47,8 +47,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let nonce = extensions.nonce().expect("Should have nonce");
|
let nonce = extensions.nonce().expect("Should have nonce");
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
" Transfer of {value} DOT:\n {sender} (Tip: {tip}, Nonce: {nonce}) ---> {receiver}",
|
" Transfer of {value} DOT:\n {sender} (Tip: {tip}, Nonce: {nonce}) ---> {receiver}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use subxt::{client::OnlineClient, lightclient::LightClient, PolkadotConfig};
|
use subxt::{PolkadotConfig, client::OnlineClient, lightclient::LightClient};
|
||||||
|
|
||||||
// Generate an interface that we can use from the node's metadata.
|
// Generate an interface that we can use from the node's metadata.
|
||||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
use subxt::utils::fetch_chainspec_from_rpc_node;
|
use subxt::utils::fetch_chainspec_from_rpc_node;
|
||||||
use subxt::{
|
use subxt::{
|
||||||
|
PolkadotConfig,
|
||||||
client::OnlineClient,
|
client::OnlineClient,
|
||||||
lightclient::{ChainConfig, LightClient},
|
lightclient::{ChainConfig, LightClient},
|
||||||
PolkadotConfig,
|
|
||||||
};
|
};
|
||||||
use subxt_signer::sr25519::dev;
|
use subxt_signer::sr25519::dev;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
use subxt::dynamic::Value;
|
use subxt::dynamic::Value;
|
||||||
use subxt::{config::PolkadotConfig, OnlineClient};
|
use subxt::{OnlineClient, config::PolkadotConfig};
|
||||||
use subxt_signer::sr25519::dev;
|
use subxt_signer::sr25519::dev;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
use subxt::{config::PolkadotConfig, OnlineClient};
|
use subxt::{OnlineClient, config::PolkadotConfig};
|
||||||
use subxt_signer::sr25519::dev;
|
use subxt_signer::sr25519::dev;
|
||||||
|
|
||||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use std::{
|
|||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
use subxt::{
|
use subxt::{
|
||||||
backend::rpc::{RawRpcFuture, RawRpcSubscription, RawValue, RpcClient, RpcClientT},
|
|
||||||
OnlineClient, PolkadotConfig,
|
OnlineClient, PolkadotConfig,
|
||||||
|
backend::rpc::{RawRpcFuture, RawRpcSubscription, RawValue, RpcClient, RpcClientT},
|
||||||
};
|
};
|
||||||
|
|
||||||
// A dummy RPC client that doesn't actually handle requests properly
|
// A dummy RPC client that doesn't actually handle requests properly
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
use subxt::ext::codec::Decode;
|
use subxt::ext::codec::Decode;
|
||||||
use subxt::metadata::Metadata;
|
use subxt::metadata::Metadata;
|
||||||
use subxt::utils::H256;
|
use subxt::utils::H256;
|
||||||
use subxt::{config::PolkadotConfig, OfflineClient};
|
use subxt::{OfflineClient, config::PolkadotConfig};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use subxt::client::ClientState;
|
use subxt::client::ClientState;
|
||||||
use subxt::config::{
|
use subxt::config::{
|
||||||
transaction_extensions::Params, Config, ExtrinsicParams, ExtrinsicParamsEncoder,
|
Config, ExtrinsicParams, ExtrinsicParamsEncoder, ExtrinsicParamsError, HashFor,
|
||||||
ExtrinsicParamsError, HashFor,
|
transaction_extensions::Params,
|
||||||
};
|
};
|
||||||
use subxt_signer::sr25519::dev;
|
use subxt_signer::sr25519::dev;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
use subxt::{dynamic::Value, OnlineClient, PolkadotConfig};
|
use subxt::{OnlineClient, PolkadotConfig, dynamic::Value};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use polkadot::runtime_types::{
|
|||||||
};
|
};
|
||||||
use subxt::utils::AccountId32;
|
use subxt::utils::AccountId32;
|
||||||
use subxt::{OnlineClient, PolkadotConfig};
|
use subxt::{OnlineClient, PolkadotConfig};
|
||||||
use subxt_signer::sr25519::{dev, Keypair};
|
use subxt_signer::sr25519::{Keypair, dev};
|
||||||
|
|
||||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
|
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
|
||||||
pub mod polkadot {}
|
pub mod polkadot {}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#![allow(missing_docs, unused)]
|
#![allow(missing_docs, unused)]
|
||||||
|
|
||||||
use sp_core::{sr25519, Pair as _};
|
use sp_core::{Pair as _, sr25519};
|
||||||
use subxt::config::substrate::MultiAddress;
|
use subxt::config::substrate::MultiAddress;
|
||||||
use subxt::{Config, OnlineClient, PolkadotConfig};
|
use subxt::{Config, OnlineClient, PolkadotConfig};
|
||||||
|
|
||||||
@@ -18,8 +18,8 @@ pub mod polkadot {}
|
|||||||
mod pair_signer {
|
mod pair_signer {
|
||||||
use super::*;
|
use super::*;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{IdentifyAccount, Verify},
|
|
||||||
MultiSignature as SpMultiSignature,
|
MultiSignature as SpMultiSignature,
|
||||||
|
traits::{IdentifyAccount, Verify},
|
||||||
};
|
};
|
||||||
use subxt::{
|
use subxt::{
|
||||||
config::substrate::{AccountId32, MultiSignature},
|
config::substrate::{AccountId32, MultiSignature},
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
use subxt::OnlineClient;
|
use subxt::OnlineClient;
|
||||||
use subxt_core::utils::AccountId20;
|
use subxt_core::utils::AccountId20;
|
||||||
use subxt_signer::eth::{dev, Signature};
|
use subxt_signer::eth::{Signature, dev};
|
||||||
|
|
||||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/frontier_metadata_small.scale")]
|
#[subxt::subxt(runtime_metadata_path = "../artifacts/frontier_metadata_small.scale")]
|
||||||
mod eth_runtime {}
|
mod eth_runtime {}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ fn remark() -> Box<dyn subxt::tx::Payload> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn dynamic_remark() -> Box<dyn subxt::tx::Payload> {
|
fn dynamic_remark() -> Box<dyn subxt::tx::Payload> {
|
||||||
use subxt::dynamic::{tx, Value};
|
use subxt::dynamic::{Value, tx};
|
||||||
let tx_payload = tx("System", "remark", vec![Value::from_bytes("Hello")]);
|
let tx_payload = tx("System", "remark", vec![Value::from_bytes("Hello")]);
|
||||||
|
|
||||||
Box::new(tx_payload)
|
Box::new(tx_payload)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
use subxt::{tx::TxStatus, OnlineClient, PolkadotConfig};
|
use subxt::{OnlineClient, PolkadotConfig, tx::TxStatus};
|
||||||
use subxt_signer::sr25519::dev;
|
use subxt_signer::sr25519::dev;
|
||||||
|
|
||||||
// Generate an interface that we can use from the node's metadata.
|
// Generate an interface that we can use from the node's metadata.
|
||||||
|
|||||||
@@ -218,8 +218,8 @@ impl<Hash> Stream for FollowStream<Hash> {
|
|||||||
pub(super) mod test_utils {
|
pub(super) mod test_utils {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::config::substrate::H256;
|
use crate::config::substrate::H256;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use subxt_rpcs::methods::chain_head::{BestBlockChanged, Finalized, Initialized, NewBlock};
|
use subxt_rpcs::methods::chain_head::{BestBlockChanged, Finalized, Initialized, NewBlock};
|
||||||
|
|
||||||
/// Given some events, returns a follow stream getter that we can use in
|
/// Given some events, returns a follow stream getter that we can use in
|
||||||
@@ -313,7 +313,7 @@ pub mod test {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let s = FollowStream::new(stream_getter);
|
let s = FollowStream::new(stream_getter);
|
||||||
let out: Vec<_> = s.filter_map(|e| async move { e.ok() }).collect().await;
|
let out: Vec<_> = s.filter_map(async |e| e.ok()).collect().await;
|
||||||
|
|
||||||
// The expected response, given the above.
|
// The expected response, given the above.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
use super::follow_stream::FollowStream;
|
|
||||||
use super::ChainHeadRpcMethods;
|
use super::ChainHeadRpcMethods;
|
||||||
|
use super::follow_stream::FollowStream;
|
||||||
use crate::config::{Config, Hash, HashFor};
|
use crate::config::{Config, Hash, HashFor};
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use futures::stream::{FuturesUnordered, Stream, StreamExt};
|
use futures::stream::{FuturesUnordered, Stream, StreamExt};
|
||||||
@@ -468,7 +468,7 @@ impl<H: Hash> Drop for BlockRef<H> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(super) mod test_utils {
|
pub(super) mod test_utils {
|
||||||
use super::super::follow_stream::{test_utils::test_stream_getter, FollowStream};
|
use super::super::follow_stream::{FollowStream, test_utils::test_stream_getter};
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::config::substrate::H256;
|
use crate::config::substrate::H256;
|
||||||
|
|
||||||
@@ -573,10 +573,7 @@ mod test {
|
|||||||
10,
|
10,
|
||||||
);
|
);
|
||||||
|
|
||||||
let out: Vec<_> = follow_unpin
|
let out: Vec<_> = follow_unpin.filter_map(async |e| e.ok()).collect().await;
|
||||||
.filter_map(|e| async move { e.ok() })
|
|
||||||
.collect()
|
|
||||||
.await;
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out,
|
out,
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ mod storage_items;
|
|||||||
|
|
||||||
use self::follow_stream_driver::FollowStreamFinalizedHeads;
|
use self::follow_stream_driver::FollowStreamFinalizedHeads;
|
||||||
use crate::backend::{
|
use crate::backend::{
|
||||||
utils::retry, Backend, BlockRef, BlockRefT, RuntimeVersion, StorageResponse, StreamOf,
|
Backend, BlockRef, BlockRefT, RuntimeVersion, StorageResponse, StreamOf, StreamOfResults,
|
||||||
StreamOfResults, TransactionStatus,
|
TransactionStatus, utils::retry,
|
||||||
};
|
};
|
||||||
use crate::config::{Config, Hash, HashFor};
|
use crate::config::{Config, Hash, HashFor};
|
||||||
use crate::error::{Error, RpcError};
|
use crate::error::{Error, RpcError};
|
||||||
@@ -30,10 +30,10 @@ use futures::{Stream, StreamExt};
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::task::Poll;
|
use std::task::Poll;
|
||||||
use storage_items::StorageItems;
|
use storage_items::StorageItems;
|
||||||
|
use subxt_rpcs::RpcClient;
|
||||||
use subxt_rpcs::methods::chain_head::{
|
use subxt_rpcs::methods::chain_head::{
|
||||||
FollowEvent, MethodResponse, RuntimeEvent, StorageQuery, StorageQueryType, StorageResultType,
|
FollowEvent, MethodResponse, RuntimeEvent, StorageQuery, StorageQueryType, StorageResultType,
|
||||||
};
|
};
|
||||||
use subxt_rpcs::RpcClient;
|
|
||||||
|
|
||||||
/// Re-export RPC types and methods from [`subxt_rpcs::methods::chain_head`].
|
/// Re-export RPC types and methods from [`subxt_rpcs::methods::chain_head`].
|
||||||
pub mod rpc_methods {
|
pub mod rpc_methods {
|
||||||
@@ -301,7 +301,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
|||||||
StorageItems::from_methods(queries, at, &self.follow_handle, self.methods.clone())
|
StorageItems::from_methods(queries, at, &self.follow_handle, self.methods.clone())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let stream = storage_items.filter_map(|val| async move {
|
let stream = storage_items.filter_map(async |val| {
|
||||||
let val = match val {
|
let val = match val {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(e) => return Some(Err(e)),
|
Err(e) => return Some(Err(e)),
|
||||||
@@ -366,7 +366,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let storage_result_stream = storage_items.filter_map(|val| async move {
|
let storage_result_stream = storage_items.filter_map(async |val| {
|
||||||
let val = match val {
|
let val = match val {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(e) => return Some(Err(e)),
|
Err(e) => return Some(Err(e)),
|
||||||
@@ -686,7 +686,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
|||||||
Poll::Ready(None) => {
|
Poll::Ready(None) => {
|
||||||
return Poll::Ready(err_other(
|
return Poll::Ready(err_other(
|
||||||
"chainHead_follow stream ended unexpectedly",
|
"chainHead_follow stream ended unexpectedly",
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
Poll::Ready(Some(follow_ev)) => Poll::Ready(follow_ev),
|
Poll::Ready(Some(follow_ev)) => Poll::Ready(follow_ev),
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
@@ -722,7 +722,9 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
|||||||
// in which we may lose the finalized block that the TX is in. For now, just error if
|
// in which we may lose the finalized block that the TX is in. For now, just error if
|
||||||
// this happens, to prevent the case in which we never see a finalized block and wait
|
// this happens, to prevent the case in which we never see a finalized block and wait
|
||||||
// forever.
|
// forever.
|
||||||
return Poll::Ready(err_other("chainHead_follow emitted 'stop' event during transaction submission"));
|
return Poll::Ready(err_other(
|
||||||
|
"chainHead_follow emitted 'stop' event during transaction submission",
|
||||||
|
));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -756,7 +758,11 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
|
|||||||
// If we don't have a finalized block yet, we keep polling for tx progress events.
|
// If we don't have a finalized block yet, we keep polling for tx progress events.
|
||||||
let tx_progress_ev = match tx_progress.poll_next_unpin(cx) {
|
let tx_progress_ev = match tx_progress.poll_next_unpin(cx) {
|
||||||
Poll::Pending => return Poll::Pending,
|
Poll::Pending => return Poll::Pending,
|
||||||
Poll::Ready(None) => return Poll::Ready(err_other("No more transaction progress events, but we haven't seen a Finalized one yet")),
|
Poll::Ready(None) => {
|
||||||
|
return Poll::Ready(err_other(
|
||||||
|
"No more transaction progress events, but we haven't seen a Finalized one yet",
|
||||||
|
));
|
||||||
|
}
|
||||||
Poll::Ready(Some(Err(e))) => return Poll::Ready(Some(Err(e.into()))),
|
Poll::Ready(Some(Err(e))) => return Poll::Ready(Some(Err(e.into()))),
|
||||||
Poll::Ready(Some(Ok(ev))) => ev,
|
Poll::Ready(Some(Ok(ev))) => ev,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ use crate::backend::{
|
|||||||
TransactionStatus,
|
TransactionStatus,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{Config, HashFor, Header},
|
|
||||||
Error,
|
Error,
|
||||||
|
config::{Config, HashFor, Header},
|
||||||
};
|
};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use futures::{future, future::Either, stream, Future, FutureExt, Stream, StreamExt};
|
use futures::{Future, FutureExt, Stream, StreamExt, future, future::Either, stream};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
@@ -473,7 +473,7 @@ where
|
|||||||
Ok::<_, Error>(header)
|
Ok::<_, Error>(header)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(|h| async { h.transpose() });
|
.filter_map(async |h| h.transpose());
|
||||||
|
|
||||||
// On the next iteration, we'll get details starting just after this end block.
|
// On the next iteration, we'll get details starting just after this end block.
|
||||||
last_block_num = Some(end_block_num);
|
last_block_num = Some(end_block_num);
|
||||||
|
|||||||
+22
-20
@@ -388,10 +388,10 @@ mod test {
|
|||||||
use primitive_types::H256;
|
use primitive_types::H256;
|
||||||
use rpc::RpcClientT;
|
use rpc::RpcClientT;
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
use subxt_core::{config::DefaultExtrinsicParams, Config};
|
use subxt_core::{Config, config::DefaultExtrinsicParams};
|
||||||
use subxt_rpcs::client::{
|
use subxt_rpcs::client::{
|
||||||
mock_rpc_client::{Json, MockRpcClientBuilder},
|
|
||||||
MockRpcClient,
|
MockRpcClient,
|
||||||
|
mock_rpc_client::{Json, MockRpcClientBuilder},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn random_hash() -> H256 {
|
fn random_hash() -> H256 {
|
||||||
@@ -427,7 +427,7 @@ mod test {
|
|||||||
mod legacy {
|
mod legacy {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::legacy::{rpc_methods::RuntimeVersion, LegacyBackend},
|
backend::legacy::{LegacyBackend, rpc_methods::RuntimeVersion},
|
||||||
error::RpcError,
|
error::RpcError,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -511,11 +511,11 @@ mod test {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn storage_fetch_value() {
|
async fn storage_fetch_value() {
|
||||||
let rpc_client = MockRpcClient::builder()
|
let rpc_client = MockRpcClient::builder()
|
||||||
.method_handler_once("state_getStorage", move |_params| async move {
|
.method_handler_once("state_getStorage", async move |_params| {
|
||||||
// Return "disconnected" error on first call
|
// Return "disconnected" error on first call
|
||||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||||
})
|
})
|
||||||
.method_handler_once("state_getStorage", move |_param| async move {
|
.method_handler_once("state_getStorage", async move |_param| {
|
||||||
// Return some hex encoded storage value on the next one
|
// Return some hex encoded storage value on the next one
|
||||||
Json(hex::encode("Data1"))
|
Json(hex::encode("Data1"))
|
||||||
})
|
})
|
||||||
@@ -550,11 +550,11 @@ mod test {
|
|||||||
async fn simple_fetch() {
|
async fn simple_fetch() {
|
||||||
let hash = random_hash();
|
let hash = random_hash();
|
||||||
let rpc_client = MockRpcClient::builder()
|
let rpc_client = MockRpcClient::builder()
|
||||||
.method_handler_once("chain_getBlockHash", move |_params| async move {
|
.method_handler_once("chain_getBlockHash", async move |_params| {
|
||||||
// Return "disconnected" error on first call
|
// Return "disconnected" error on first call
|
||||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||||
})
|
})
|
||||||
.method_handler_once("chain_getBlockHash", move |_params| async move {
|
.method_handler_once("chain_getBlockHash", async move |_params| {
|
||||||
// Return the blockhash on next call
|
// Return the blockhash on next call
|
||||||
Json(hash)
|
Json(hash)
|
||||||
})
|
})
|
||||||
@@ -854,11 +854,13 @@ mod test {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert!(response
|
assert!(
|
||||||
.next()
|
response
|
||||||
.await
|
.next()
|
||||||
.unwrap()
|
.await
|
||||||
.is_err_and(|e| matches!(e, Error::Other(e) if e == "error")));
|
.unwrap()
|
||||||
|
.is_err_and(|e| matches!(e, Error::Other(e) if e == "error"))
|
||||||
|
);
|
||||||
assert!(response.next().await.is_none());
|
assert!(response.next().await.is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,11 +870,11 @@ mod test {
|
|||||||
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
|
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
|
||||||
|
|
||||||
let rpc_client = mock_client_builder(rx)
|
let rpc_client = mock_client_builder(rx)
|
||||||
.method_handler_once("chainHead_v1_storage", move |_params| async move {
|
.method_handler_once("chainHead_v1_storage", async move |_params| {
|
||||||
// First call; return DisconnectedWillReconnect
|
// First call; return DisconnectedWillReconnect
|
||||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||||
})
|
})
|
||||||
.method_handler_once("chainHead_v1_storage", move |_params| async move {
|
.method_handler_once("chainHead_v1_storage", async move |_params| {
|
||||||
// Otherwise, return that we'll start sending a response, and spawn
|
// Otherwise, return that we'll start sending a response, and spawn
|
||||||
// task to send the relevant response via chainHead_follow.
|
// task to send the relevant response via chainHead_follow.
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
@@ -925,11 +927,11 @@ mod test {
|
|||||||
let tx2 = tx.clone();
|
let tx2 = tx.clone();
|
||||||
|
|
||||||
let rpc_client = mock_client_builder(rx)
|
let rpc_client = mock_client_builder(rx)
|
||||||
.method_handler_once("chainHead_v1_storage", move |_params| async move {
|
.method_handler_once("chainHead_v1_storage", async move |_params| {
|
||||||
// First call; return DisconnectedWillReconnect
|
// First call; return DisconnectedWillReconnect
|
||||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||||
})
|
})
|
||||||
.method_handler_once("chainHead_v1_storage", move |_params| async move {
|
.method_handler_once("chainHead_v1_storage", async move |_params| {
|
||||||
// Next call, return a storage item and then a "waiting for continue".
|
// Next call, return a storage item and then a "waiting for continue".
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
tx.send(storage_items("Id1", &[storage_result("ID1", "Data1")]))
|
tx.send(storage_items("Id1", &[storage_result("ID1", "Data1")]))
|
||||||
@@ -938,11 +940,11 @@ mod test {
|
|||||||
});
|
});
|
||||||
Ok(Json(response_started("Id1")))
|
Ok(Json(response_started("Id1")))
|
||||||
})
|
})
|
||||||
.method_handler_once("chainHead_v1_continue", move |_params| async move {
|
.method_handler_once("chainHead_v1_continue", async move |_params| {
|
||||||
// First call; return DisconnectedWillReconnect
|
// First call; return DisconnectedWillReconnect
|
||||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||||
})
|
})
|
||||||
.method_handler_once("chainHead_v1_continue", move |_params| async move {
|
.method_handler_once("chainHead_v1_continue", async move |_params| {
|
||||||
// Next call; acknowledge the "continue" and return reamining storage items.
|
// Next call; acknowledge the "continue" and return reamining storage items.
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
tx2.send(storage_items("Id1", &[storage_result("ID2", "Data2")]))
|
tx2.send(storage_items("Id1", &[storage_result("ID2", "Data2")]))
|
||||||
@@ -986,11 +988,11 @@ mod test {
|
|||||||
let hash = random_hash();
|
let hash = random_hash();
|
||||||
let (_tx, rx) = tokio::sync::mpsc::unbounded_channel();
|
let (_tx, rx) = tokio::sync::mpsc::unbounded_channel();
|
||||||
let rpc_client = mock_client_builder(rx)
|
let rpc_client = mock_client_builder(rx)
|
||||||
.method_handler_once("chainSpec_v1_genesisHash", move |_params| async move {
|
.method_handler_once("chainSpec_v1_genesisHash", async move |_params| {
|
||||||
// First call, return disconnected error.
|
// First call, return disconnected error.
|
||||||
Err::<Infallible, _>(disconnected_will_reconnect())
|
Err::<Infallible, _>(disconnected_will_reconnect())
|
||||||
})
|
})
|
||||||
.method_handler_once("chainSpec_v1_genesisHash", move |_params| async move {
|
.method_handler_once("chainSpec_v1_genesisHash", async move |_params| {
|
||||||
// Next call, return the hash.
|
// Next call, return the hash.
|
||||||
Ok(Json(hash))
|
Ok(Json(hash))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn retry_sub_err_terminates_stream() {
|
async fn retry_sub_err_terminates_stream() {
|
||||||
let stream = futures::stream::iter([Ok(1)]);
|
let stream = futures::stream::iter([Ok(1)]);
|
||||||
let resubscribe = Box::new(move || async move { Err(custom_err()) }.boxed());
|
let resubscribe = Box::new(|| async move { Err(custom_err()) }.boxed());
|
||||||
|
|
||||||
let retry_stream = RetrySubscription {
|
let retry_stream = RetrySubscription {
|
||||||
state: Some(PendingOrStream::Stream(StreamOf::new(Box::pin(stream)))),
|
state: Some(PendingOrStream::Stream(StreamOf::new(Box::pin(stream)))),
|
||||||
@@ -259,7 +259,7 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn retry_sub_resubscribe_err() {
|
async fn retry_sub_resubscribe_err() {
|
||||||
let stream = futures::stream::iter([Ok(1), Err(disconnect_err())]);
|
let stream = futures::stream::iter([Ok(1), Err(disconnect_err())]);
|
||||||
let resubscribe = Box::new(move || async move { Err(custom_err()) }.boxed());
|
let resubscribe = Box::new(|| async move { Err(custom_err()) }.boxed());
|
||||||
|
|
||||||
let retry_stream = RetrySubscription {
|
let retry_stream = RetrySubscription {
|
||||||
state: Some(PendingOrStream::Stream(StreamOf::new(Box::pin(stream)))),
|
state: Some(PendingOrStream::Stream(StreamOf::new(Box::pin(stream)))),
|
||||||
|
|||||||
@@ -161,7 +161,12 @@ where
|
|||||||
2 => u16::decode(cursor)?.into(),
|
2 => u16::decode(cursor)?.into(),
|
||||||
4 => u32::decode(cursor)?.into(),
|
4 => u32::decode(cursor)?.into(),
|
||||||
8 => u64::decode(cursor)?,
|
8 => u64::decode(cursor)?,
|
||||||
_ => return Err(Error::Decode(DecodeError::custom_string(format!("state call AccountNonceApi_account_nonce returned an unexpected number of bytes: {} (expected 2, 4 or 8)", account_nonce_bytes.len()))))
|
_ => {
|
||||||
|
return Err(Error::Decode(DecodeError::custom_string(format!(
|
||||||
|
"state call AccountNonceApi_account_nonce returned an unexpected number of bytes: {} (expected 2, 4 or 8)",
|
||||||
|
account_nonce_bytes.len()
|
||||||
|
))));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Ok(account_nonce)
|
Ok(account_nonce)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
blocks::block_types::{get_events, CachedEvents},
|
blocks::block_types::{CachedEvents, get_events},
|
||||||
client::{OfflineClientT, OnlineClientT},
|
client::{OfflineClientT, OnlineClientT},
|
||||||
config::{Config, HashFor},
|
config::{Config, HashFor},
|
||||||
error::Error,
|
error::Error,
|
||||||
@@ -81,7 +81,7 @@ where
|
|||||||
/// If an error occurs, all subsequent iterations return `None`.
|
/// If an error occurs, all subsequent iterations return `None`.
|
||||||
pub fn find<E: StaticExtrinsic>(
|
pub fn find<E: StaticExtrinsic>(
|
||||||
&self,
|
&self,
|
||||||
) -> impl Iterator<Item = Result<FoundExtrinsic<T, C, E>, Error>> + '_ {
|
) -> impl Iterator<Item = Result<FoundExtrinsic<T, C, E>, Error>> {
|
||||||
self.inner.find::<E>().map(|res| {
|
self.inner.find::<E>().map(|res| {
|
||||||
match res {
|
match res {
|
||||||
Err(e) => Err(Error::from(e)),
|
Err(e) => Err(Error::from(e)),
|
||||||
@@ -308,7 +308,7 @@ impl<T: Config> ExtrinsicEvents<T> {
|
|||||||
///
|
///
|
||||||
/// This works in the same way that [`events::Events::iter()`] does, with the
|
/// This works in the same way that [`events::Events::iter()`] does, with the
|
||||||
/// exception that it filters out events not related to the submitted extrinsic.
|
/// exception that it filters out events not related to the submitted extrinsic.
|
||||||
pub fn iter(&self) -> impl Iterator<Item = Result<events::EventDetails<T>, Error>> + '_ {
|
pub fn iter(&self) -> impl Iterator<Item = Result<events::EventDetails<T>, Error>> {
|
||||||
self.events.iter().filter(|ev| {
|
self.events.iter().filter(|ev| {
|
||||||
ev.as_ref()
|
ev.as_ref()
|
||||||
.map(|ev| ev.phase() == events::Phase::ApplyExtrinsic(self.idx))
|
.map(|ev| ev.phase() == events::Phase::ApplyExtrinsic(self.idx))
|
||||||
@@ -320,7 +320,7 @@ impl<T: Config> ExtrinsicEvents<T> {
|
|||||||
///
|
///
|
||||||
/// This works in the same way that [`events::Events::find()`] does, with the
|
/// This works in the same way that [`events::Events::find()`] does, with the
|
||||||
/// exception that it filters out events not related to the submitted extrinsic.
|
/// exception that it filters out events not related to the submitted extrinsic.
|
||||||
pub fn find<Ev: events::StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> + '_ {
|
pub fn find<Ev: events::StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> {
|
||||||
self.iter()
|
self.iter()
|
||||||
.filter_map(|ev| ev.and_then(|ev| ev.as_event::<Ev>()).transpose())
|
.filter_map(|ev| ev.and_then(|ev| ev.as_event::<Ev>()).transpose())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use crate::custom_values::CustomValuesClient;
|
use crate::custom_values::CustomValuesClient;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Metadata,
|
||||||
blocks::BlocksClient,
|
blocks::BlocksClient,
|
||||||
config::{Config, HashFor},
|
config::{Config, HashFor},
|
||||||
constants::ConstantsClient,
|
constants::ConstantsClient,
|
||||||
@@ -12,7 +13,6 @@ use crate::{
|
|||||||
storage::StorageClient,
|
storage::StorageClient,
|
||||||
tx::TxClient,
|
tx::TxClient,
|
||||||
view_functions::ViewFunctionsClient,
|
view_functions::ViewFunctionsClient,
|
||||||
Metadata,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use derive_where::derive_where;
|
use derive_where::derive_where;
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
use super::{OfflineClient, OfflineClientT};
|
use super::{OfflineClient, OfflineClientT};
|
||||||
use crate::custom_values::CustomValuesClient;
|
use crate::custom_values::CustomValuesClient;
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::{legacy::LegacyBackend, rpc::RpcClient, Backend, BackendExt, StreamOfResults},
|
Metadata,
|
||||||
|
backend::{Backend, BackendExt, StreamOfResults, legacy::LegacyBackend, rpc::RpcClient},
|
||||||
blocks::{BlockRef, BlocksClient},
|
blocks::{BlockRef, BlocksClient},
|
||||||
config::{Config, HashFor},
|
config::{Config, HashFor},
|
||||||
constants::ConstantsClient,
|
constants::ConstantsClient,
|
||||||
@@ -15,7 +16,6 @@ use crate::{
|
|||||||
storage::StorageClient,
|
storage::StorageClient,
|
||||||
tx::TxClient,
|
tx::TxClient,
|
||||||
view_functions::ViewFunctionsClient,
|
view_functions::ViewFunctionsClient,
|
||||||
Metadata,
|
|
||||||
};
|
};
|
||||||
use derive_where::derive_where;
|
use derive_where::derive_where;
|
||||||
use futures::future;
|
use futures::future;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
use crate::{client::OfflineClientT, error::Error, Config};
|
use crate::{Config, client::OfflineClientT, error::Error};
|
||||||
use derive_where::derive_where;
|
use derive_where::derive_where;
|
||||||
use subxt_core::constants::address::Address;
|
use subxt_core::constants::address::Address;
|
||||||
|
|
||||||
|
|||||||
@@ -8,5 +8,5 @@ mod constants_client;
|
|||||||
|
|
||||||
pub use constants_client::ConstantsClient;
|
pub use constants_client::ConstantsClient;
|
||||||
pub use subxt_core::constants::address::{
|
pub use subxt_core::constants::address::{
|
||||||
dynamic, Address, DefaultAddress, DynamicAddress, StaticAddress,
|
Address, DefaultAddress, DynamicAddress, StaticAddress, dynamic,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ mod tests {
|
|||||||
use crate::{Metadata, OfflineClient, SubstrateConfig};
|
use crate::{Metadata, OfflineClient, SubstrateConfig};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use scale_decode::DecodeAsType;
|
use scale_decode::DecodeAsType;
|
||||||
use scale_info::form::PortableForm;
|
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
|
use scale_info::form::PortableForm;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use subxt_core::client::RuntimeVersion;
|
use subxt_core::client::RuntimeVersion;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
use crate::metadata::{DecodeWithMetadata, Metadata};
|
use crate::metadata::{DecodeWithMetadata, Metadata};
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType, TypeResolver};
|
use scale_decode::{DecodeAsType, TypeResolver, visitor::DecodeAsTypeResult};
|
||||||
|
|
||||||
use std::{borrow::Cow, marker::PhantomData};
|
use std::{borrow::Cow, marker::PhantomData};
|
||||||
|
|
||||||
@@ -73,7 +73,9 @@ pub enum TokenError {
|
|||||||
#[error("Funds are unavailable.")]
|
#[error("Funds are unavailable.")]
|
||||||
FundsUnavailable,
|
FundsUnavailable,
|
||||||
/// Some part of the balance gives the only provider reference to the account and thus cannot be (re)moved.
|
/// Some part of the balance gives the only provider reference to the account and thus cannot be (re)moved.
|
||||||
#[error("Some part of the balance gives the only provider reference to the account and thus cannot be (re)moved.")]
|
#[error(
|
||||||
|
"Some part of the balance gives the only provider reference to the account and thus cannot be (re)moved."
|
||||||
|
)]
|
||||||
OnlyProvider,
|
OnlyProvider,
|
||||||
/// Account cannot exist with the funds that would be given.
|
/// Account cannot exist with the funds that would be given.
|
||||||
#[error("Account cannot exist with the funds that would be given.")]
|
#[error("Account cannot exist with the funds that would be given.")]
|
||||||
@@ -327,7 +329,9 @@ impl DispatchError {
|
|||||||
module_bytes[4],
|
module_bytes[4],
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
tracing::warn!("Can't decode error sp_runtime::DispatchError: bytes do not match known shapes");
|
tracing::warn!(
|
||||||
|
"Can't decode error sp_runtime::DispatchError: bytes do not match known shapes"
|
||||||
|
);
|
||||||
// Return _all_ of the bytes; every "unknown" return should be consistent.
|
// Return _all_ of the bytes; every "unknown" return should be consistent.
|
||||||
return Err(super::Error::Unknown(bytes.to_vec()));
|
return Err(super::Error::Unknown(bytes.to_vec()));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -170,7 +170,9 @@ pub enum BlockError {
|
|||||||
#[error("Could not find a block with hash {0} (perhaps it was on a non-finalized fork?)")]
|
#[error("Could not find a block with hash {0} (perhaps it was on a non-finalized fork?)")]
|
||||||
NotFound(String),
|
NotFound(String),
|
||||||
/// Leftover bytes found after decoding the extrinsic.
|
/// Leftover bytes found after decoding the extrinsic.
|
||||||
#[error("After decoding the exntrinsic at index {extrinsic_index}, {num_leftover_bytes} bytes were left, suggesting that decoding may have failed")]
|
#[error(
|
||||||
|
"After decoding the exntrinsic at index {extrinsic_index}, {num_leftover_bytes} bytes were left, suggesting that decoding may have failed"
|
||||||
|
)]
|
||||||
LeftoverBytes {
|
LeftoverBytes {
|
||||||
/// Index of the extrinsic that failed to decode.
|
/// Index of the extrinsic that failed to decode.
|
||||||
extrinsic_index: usize,
|
extrinsic_index: usize,
|
||||||
@@ -222,7 +224,9 @@ impl BlockError {
|
|||||||
pub enum TransactionError {
|
pub enum TransactionError {
|
||||||
/// The block hash that the transaction was added to could not be found.
|
/// The block hash that the transaction was added to could not be found.
|
||||||
/// This is probably because the block was retracted before being finalized.
|
/// This is probably because the block was retracted before being finalized.
|
||||||
#[error("The block containing the transaction can no longer be found (perhaps it was on a non-finalized fork?)")]
|
#[error(
|
||||||
|
"The block containing the transaction can no longer be found (perhaps it was on a non-finalized fork?)"
|
||||||
|
)]
|
||||||
BlockNotFound,
|
BlockNotFound,
|
||||||
/// An error happened on the node that the transaction was submitted to.
|
/// An error happened on the node that the transaction was submitted to.
|
||||||
#[error("Error handling transaction: {0}")]
|
#[error("Error handling transaction: {0}")]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
config::{Config, HashFor},
|
|
||||||
Error, Metadata,
|
Error, Metadata,
|
||||||
|
config::{Config, HashFor},
|
||||||
};
|
};
|
||||||
use derive_where::derive_where;
|
use derive_where::derive_where;
|
||||||
use scale_decode::DecodeAsType;
|
use scale_decode::DecodeAsType;
|
||||||
@@ -58,7 +58,7 @@ impl<T: Config> Events<T> {
|
|||||||
/// Iterate through the events using metadata to dynamically decode and skip
|
/// Iterate through the events using metadata to dynamically decode and skip
|
||||||
/// them, and return only those which should decode to the provided `Ev` type.
|
/// them, and return only those which should decode to the provided `Ev` type.
|
||||||
/// If an error occurs, all subsequent iterations return `None`.
|
/// If an error occurs, all subsequent iterations return `None`.
|
||||||
pub fn find<Ev: StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> + '_ {
|
pub fn find<Ev: StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> {
|
||||||
self.inner.find::<Ev>().map(|item| item.map_err(Into::into))
|
self.inner.find::<Ev>().map(|item| item.map_err(Into::into))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
mod events_client;
|
mod events_client;
|
||||||
mod events_type;
|
mod events_type;
|
||||||
|
|
||||||
use crate::client::OnlineClientT;
|
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
use crate::client::OnlineClientT;
|
||||||
use subxt_core::{
|
use subxt_core::{
|
||||||
config::{Config, HashFor},
|
|
||||||
Metadata,
|
Metadata,
|
||||||
|
config::{Config, HashFor},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use events_client::EventsClient;
|
pub use events_client::EventsClient;
|
||||||
|
|||||||
+6
-6
@@ -58,10 +58,10 @@ pub mod view_functions;
|
|||||||
/// Polkadot node.
|
/// Polkadot node.
|
||||||
pub mod config {
|
pub mod config {
|
||||||
pub use subxt_core::config::{
|
pub use subxt_core::config::{
|
||||||
polkadot, substrate, transaction_extensions, Config, DefaultExtrinsicParams,
|
Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, ExtrinsicParams,
|
||||||
DefaultExtrinsicParamsBuilder, ExtrinsicParams, ExtrinsicParamsEncoder, Hash, HashFor,
|
ExtrinsicParamsEncoder, Hash, HashFor, Hasher, Header, PolkadotConfig,
|
||||||
Hasher, Header, PolkadotConfig, PolkadotExtrinsicParams, SubstrateConfig,
|
PolkadotExtrinsicParams, SubstrateConfig, SubstrateExtrinsicParams, TransactionExtension,
|
||||||
SubstrateExtrinsicParams, TransactionExtension,
|
polkadot, substrate, transaction_extensions,
|
||||||
};
|
};
|
||||||
pub use subxt_core::error::ExtrinsicParamsError;
|
pub use subxt_core::error::ExtrinsicParamsError;
|
||||||
}
|
}
|
||||||
@@ -76,8 +76,8 @@ pub mod metadata {
|
|||||||
/// Submit dynamic transactions.
|
/// Submit dynamic transactions.
|
||||||
pub mod dynamic {
|
pub mod dynamic {
|
||||||
pub use subxt_core::dynamic::{
|
pub use subxt_core::dynamic::{
|
||||||
constant, runtime_api_call, storage, tx, view_function_call, At, DecodedValue,
|
At, DecodedValue, DecodedValueThunk, Value, constant, runtime_api_call, storage, tx,
|
||||||
DecodedValueThunk, Value,
|
view_function_call,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ mod runtime_types;
|
|||||||
pub use runtime_client::RuntimeApiClient;
|
pub use runtime_client::RuntimeApiClient;
|
||||||
pub use runtime_types::RuntimeApi;
|
pub use runtime_types::RuntimeApi;
|
||||||
pub use subxt_core::runtime_api::payload::{
|
pub use subxt_core::runtime_api::payload::{
|
||||||
dynamic, DefaultPayload, DynamicPayload, Payload, StaticPayload,
|
DefaultPayload, DynamicPayload, Payload, StaticPayload, dynamic,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
function: &'a str,
|
function: &'a str,
|
||||||
call_parameters: Option<&'a [u8]>,
|
call_parameters: Option<&'a [u8]>,
|
||||||
) -> impl Future<Output = Result<Res, Error>> + 'a {
|
) -> impl Future<Output = Result<Res, Error>> + use<'a, Res, Client, T> {
|
||||||
let client = self.client.clone();
|
let client = self.client.clone();
|
||||||
let block_hash = self.block_ref.hash();
|
let block_hash = self.block_ref.hash();
|
||||||
// Ensure that the returned future doesn't have a lifetime tied to api.runtime_api(),
|
// Ensure that the returned future doesn't have a lifetime tied to api.runtime_api(),
|
||||||
@@ -68,7 +68,7 @@ where
|
|||||||
pub fn call<Call: Payload>(
|
pub fn call<Call: Payload>(
|
||||||
&self,
|
&self,
|
||||||
payload: Call,
|
payload: Call,
|
||||||
) -> impl Future<Output = Result<Call::ReturnType, Error>> {
|
) -> impl Future<Output = Result<Call::ReturnType, Error>> + use<Call, Client, T> {
|
||||||
let client = self.client.clone();
|
let client = self.client.clone();
|
||||||
let block_hash = self.block_ref.hash();
|
let block_hash = self.block_ref.hash();
|
||||||
// Ensure that the returned future doesn't have a lifetime tied to api.runtime_api(),
|
// Ensure that the returned future doesn't have a lifetime tied to api.runtime_api(),
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ mod storage_type;
|
|||||||
pub use storage_client::StorageClient;
|
pub use storage_client::StorageClient;
|
||||||
pub use storage_type::{Storage, StorageKeyValuePair};
|
pub use storage_type::{Storage, StorageKeyValuePair};
|
||||||
pub use subxt_core::storage::address::{
|
pub use subxt_core::storage::address::{
|
||||||
dynamic, Address, DefaultAddress, DynamicAddress, StaticAddress, StaticStorageKey, StorageKey,
|
Address, DefaultAddress, DynamicAddress, StaticAddress, StaticStorageKey, StorageKey, dynamic,
|
||||||
};
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user