mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 11:51:12 +00:00
cargo +nightly fmt
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::utils::FileOrUrl;
|
||||
use clap::Parser as ClapParser;
|
||||
use color_eyre::eyre;
|
||||
use subxt_codegen::{DerivesRegistry, TypeSubstitutes, TypeSubstitutionError};
|
||||
|
||||
use crate::utils::FileOrUrl;
|
||||
|
||||
/// Generate runtime API client code from metadata.
|
||||
///
|
||||
/// # Example (with code formatting)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use clap::Parser as ClapParser;
|
||||
use codec::Decode;
|
||||
use color_eyre::eyre::{self, WrapErr};
|
||||
@@ -10,7 +12,6 @@ use frame_metadata::{
|
||||
};
|
||||
use jsonrpsee::client_transport::ws::Uri;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use subxt_codegen::utils::MetadataVersion;
|
||||
use subxt_metadata::{get_metadata_hash, get_pallet_hash, metadata_v14_to_latest};
|
||||
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::utils::FileOrUrl;
|
||||
use std::io::{self, Write};
|
||||
|
||||
use clap::Parser as ClapParser;
|
||||
use codec::{Decode, Encode};
|
||||
use color_eyre::eyre;
|
||||
use frame_metadata::{RuntimeMetadata, RuntimeMetadataPrefixed};
|
||||
use std::io::{self, Write};
|
||||
use subxt_metadata::{metadata_v14_to_latest, retain_metadata_pallets};
|
||||
|
||||
use crate::utils::FileOrUrl;
|
||||
|
||||
/// Download metadata from a substrate node, for use with `subxt` codegen.
|
||||
#[derive(Debug, ClapParser)]
|
||||
pub struct Opts {
|
||||
|
||||
+2
-1
@@ -2,9 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::{fs, io::Read, path::PathBuf};
|
||||
|
||||
use clap::Args;
|
||||
use color_eyre::eyre;
|
||||
use std::{fs, io::Read, path::PathBuf};
|
||||
use subxt_codegen::utils::{MetadataVersion, Uri};
|
||||
|
||||
/// The source of the metadata.
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use frame_metadata::v15::{PalletMetadata, RuntimeMetadataV15};
|
||||
use heck::{ToSnakeCase as _, ToUpperCamelCase as _};
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use scale_info::form::PortableForm;
|
||||
|
||||
use super::CodegenError;
|
||||
use crate::{
|
||||
types::{CompositeDefFields, TypeGenerator},
|
||||
CratePath,
|
||||
};
|
||||
use frame_metadata::v15::{PalletMetadata, RuntimeMetadataV15};
|
||||
use heck::{ToSnakeCase as _, ToUpperCamelCase as _};
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use scale_info::form::PortableForm;
|
||||
|
||||
/// Generate calls from the provided pallet's metadata. Each call returns a `StaticTxPayload`
|
||||
/// that can be passed to the subxt client to submit/sign/encode.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{types::TypeGenerator, CratePath};
|
||||
use frame_metadata::v15::{PalletMetadata, RuntimeMetadataV15};
|
||||
use heck::ToSnakeCase as _;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
@@ -10,6 +9,7 @@ use quote::{format_ident, quote};
|
||||
use scale_info::form::PortableForm;
|
||||
|
||||
use super::CodegenError;
|
||||
use crate::{types::TypeGenerator, CratePath};
|
||||
|
||||
/// Generate constants from the provided pallet's metadata.
|
||||
///
|
||||
|
||||
@@ -7,9 +7,8 @@ use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::quote;
|
||||
use scale_info::form::PortableForm;
|
||||
|
||||
use crate::types::TypeGenerator;
|
||||
|
||||
use super::CodegenError;
|
||||
use crate::types::TypeGenerator;
|
||||
|
||||
/// Generate error type alias from the provided pallet metadata.
|
||||
pub fn generate_error_type_alias(
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{types::TypeGenerator, CratePath};
|
||||
use frame_metadata::v15::PalletMetadata;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::quote;
|
||||
use scale_info::form::PortableForm;
|
||||
|
||||
use super::CodegenError;
|
||||
use crate::{types::TypeGenerator, CratePath};
|
||||
|
||||
/// Generate events from the provided pallet metadata.
|
||||
///
|
||||
|
||||
@@ -11,24 +11,24 @@ mod events;
|
||||
mod runtime_apis;
|
||||
mod storage;
|
||||
|
||||
use frame_metadata::v15::RuntimeMetadataV15;
|
||||
use std::{fs, io::Read, path, string::ToString};
|
||||
|
||||
use codec::Decode;
|
||||
use frame_metadata::{v15::RuntimeMetadataV15, RuntimeMetadata, RuntimeMetadataPrefixed};
|
||||
use heck::ToSnakeCase as _;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use subxt_metadata::{get_metadata_per_pallet_hash, metadata_v14_to_latest};
|
||||
use syn::parse_quote;
|
||||
|
||||
use super::DerivesRegistry;
|
||||
use crate::error::CodegenError;
|
||||
use crate::{
|
||||
error::CodegenError,
|
||||
ir,
|
||||
types::{CompositeDef, CompositeDefFields, TypeGenerator, TypeSubstitutes},
|
||||
utils::{fetch_metadata_bytes_blocking, MetadataVersion, Uri},
|
||||
CratePath,
|
||||
};
|
||||
use codec::Decode;
|
||||
use frame_metadata::{RuntimeMetadata, RuntimeMetadataPrefixed};
|
||||
use heck::ToSnakeCase as _;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use std::{fs, io::Read, path, string::ToString};
|
||||
use syn::parse_quote;
|
||||
|
||||
/// Generates the API for interacting with a Substrate runtime.
|
||||
///
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{types::TypeGenerator, CodegenError, CratePath};
|
||||
use frame_metadata::v15::{RuntimeApiMetadata, RuntimeMetadataV15};
|
||||
use heck::ToSnakeCase as _;
|
||||
use heck::ToUpperCamelCase as _;
|
||||
|
||||
use heck::{ToSnakeCase as _, ToUpperCamelCase as _};
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use scale_info::form::PortableForm;
|
||||
|
||||
use crate::{types::TypeGenerator, CodegenError, CratePath};
|
||||
|
||||
/// Generates runtime functions for the given API metadata.
|
||||
fn generate_runtime_api(
|
||||
metadata: &RuntimeMetadataV15,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{types::TypeGenerator, CratePath};
|
||||
use frame_metadata::v15::{
|
||||
PalletMetadata, RuntimeMetadataV15, StorageEntryMetadata, StorageEntryModifier,
|
||||
StorageEntryType,
|
||||
@@ -13,6 +12,7 @@ use quote::{format_ident, quote};
|
||||
use scale_info::{form::PortableForm, TypeDef};
|
||||
|
||||
use super::CodegenError;
|
||||
use crate::{types::TypeGenerator, CratePath};
|
||||
|
||||
/// Generate functions which create storage addresses from the provided pallet's metadata.
|
||||
/// These addresses can be used to access and iterate over storage values.
|
||||
|
||||
+2
-1
@@ -2,9 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::error::CodegenError;
|
||||
use syn::token;
|
||||
|
||||
use crate::error::CodegenError;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct ItemMod {
|
||||
vis: syn::Visibility,
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::error::CodegenError;
|
||||
|
||||
use super::{CratePath, Derives, Field, TypeDefParameters, TypeGenerator, TypeParameter, TypePath};
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::{format_ident, quote};
|
||||
use scale_info::{form::PortableForm, Type, TypeDef, TypeDefPrimitive};
|
||||
|
||||
use super::{CratePath, Derives, Field, TypeDefParameters, TypeGenerator, TypeParameter, TypePath};
|
||||
use crate::error::CodegenError;
|
||||
|
||||
/// Representation of a type which consists of a set of fields. Used to generate Rust code for
|
||||
/// either a standalone `struct` definition, or an `enum` variant.
|
||||
///
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::CratePath;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use syn::{parse_quote, Path};
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use crate::CratePath;
|
||||
|
||||
/// A struct containing the derives that we'll be applying to types;
|
||||
/// a combination of some common derives for all types, plus type
|
||||
|
||||
@@ -11,12 +11,11 @@ mod type_def;
|
||||
mod type_def_params;
|
||||
mod type_path;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use proc_macro2::{Ident, Span, TokenStream};
|
||||
use quote::{quote, ToTokens};
|
||||
use scale_info::{form::PortableForm, PortableRegistry, Type, TypeDef};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::error::CodegenError;
|
||||
|
||||
pub use self::{
|
||||
composite_def::{CompositeDef, CompositeDefFieldType, CompositeDefFields},
|
||||
@@ -26,6 +25,7 @@ pub use self::{
|
||||
type_def_params::TypeDefParameters,
|
||||
type_path::{TypeParameter, TypePath, TypePathType},
|
||||
};
|
||||
use crate::error::CodegenError;
|
||||
|
||||
pub type Field = scale_info::Field<PortableForm>;
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{error::TypeSubstitutionError, CratePath};
|
||||
use std::{borrow::Borrow, collections::HashMap};
|
||||
|
||||
use syn::{parse_quote, spanned::Spanned as _};
|
||||
|
||||
use super::{TypePath, TypePathType};
|
||||
use crate::{error::TypeSubstitutionError, CratePath};
|
||||
|
||||
/// A map of type substitutes. We match on the paths to generated types in order
|
||||
/// to figure out when to swap said type with some provided substitute.
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use scale_info::{meta_type, scale, Registry, TypeInfo};
|
||||
use syn::parse_quote;
|
||||
|
||||
use super::*;
|
||||
|
||||
const MOD_PATH: &[&str] = &["subxt_codegen", "types", "tests"];
|
||||
|
||||
fn get_mod<'a>(module: &'a Module, path_segs: &[&'static str]) -> Option<&'a Module> {
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::error::CodegenError;
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::{format_ident, quote};
|
||||
use scale_info::{form::PortableForm, Type, TypeDef};
|
||||
use syn::parse_quote;
|
||||
|
||||
use super::{
|
||||
CompositeDef, CompositeDefFields, CratePath, Derives, TypeDefParameters, TypeGenerator,
|
||||
TypeParameter,
|
||||
};
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::{format_ident, quote};
|
||||
use scale_info::{form::PortableForm, Type, TypeDef};
|
||||
use syn::parse_quote;
|
||||
use crate::error::CodegenError;
|
||||
|
||||
/// Generates a Rust `struct` or `enum` definition based on the supplied [`scale-info::Type`].
|
||||
///
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use quote::quote;
|
||||
|
||||
use super::TypeParameter;
|
||||
use crate::types::CompositeDefFieldType;
|
||||
use quote::quote;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
/// Represents the set of generic type parameters for generating a type definition e.g. the `T` in
|
||||
/// `Foo<T>`.
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::CratePath;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use proc_macro2::{Ident, TokenStream};
|
||||
use quote::format_ident;
|
||||
use scale_info::{form::PortableForm, Path, TypeDefPrimitive};
|
||||
use std::collections::BTreeSet;
|
||||
use syn::parse_quote;
|
||||
|
||||
use crate::CratePath;
|
||||
|
||||
/// An opaque struct representing a type path. The main usage of this is
|
||||
/// to spit out as tokens in some `quote!{ ... }` macro; the inner structure
|
||||
/// should be unimportant.
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::error::FetchMetadataError;
|
||||
use std::time::Duration;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use jsonrpsee::{
|
||||
async_client::ClientBuilder,
|
||||
@@ -11,7 +12,8 @@ use jsonrpsee::{
|
||||
http_client::HttpClientBuilder,
|
||||
rpc_params,
|
||||
};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::error::FetchMetadataError;
|
||||
|
||||
/// The metadata version that is fetched from the node.
|
||||
#[derive(Default, Debug, Clone, Copy)]
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
mod fetch_metadata;
|
||||
|
||||
// easy access to this type needed for fetching metadata:
|
||||
pub use jsonrpsee::client_transport::ws::Uri;
|
||||
|
||||
pub use fetch_metadata::{
|
||||
fetch_metadata_bytes, fetch_metadata_bytes_blocking, fetch_metadata_hex,
|
||||
fetch_metadata_hex_blocking, MetadataVersion,
|
||||
};
|
||||
pub use jsonrpsee::client_transport::ws::Uri;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::config::polkadot::{Era, PlainTip, PolkadotExtrinsicParamsBuilder as Params};
|
||||
use subxt::{tx::PairSigner, OnlineClient, PolkadotConfig};
|
||||
use subxt::{
|
||||
config::polkadot::{Era, PlainTip, PolkadotExtrinsicParamsBuilder as Params},
|
||||
tx::PairSigner,
|
||||
OnlineClient, PolkadotConfig,
|
||||
};
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
|
||||
pub mod polkadot {}
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
//! polkadot --dev --tmp
|
||||
//! ```
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use futures::StreamExt;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use std::time::Duration;
|
||||
use subxt::{tx::PairSigner, OnlineClient, PolkadotConfig};
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::dynamic::Value;
|
||||
use subxt::{config::PolkadotConfig, OnlineClient};
|
||||
use subxt::{config::PolkadotConfig, dynamic::Value, OnlineClient};
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
|
||||
pub mod polkadot {}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use subxt::ext::codec::Compact;
|
||||
use subxt::ext::frame_metadata::RuntimeMetadataPrefixed;
|
||||
use subxt::{OnlineClient, PolkadotConfig};
|
||||
use subxt::{
|
||||
ext::{codec::Compact, frame_metadata::RuntimeMetadataPrefixed},
|
||||
OnlineClient, PolkadotConfig,
|
||||
};
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
|
||||
pub mod polkadot {}
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::{
|
||||
pin::Pin,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use subxt::{
|
||||
rpc::{RawValue, RpcClientT, RpcFuture, RpcSubscription},
|
||||
OnlineClient, PolkadotConfig,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use subxt::ext::codec::Decode;
|
||||
use subxt::ext::frame_metadata::RuntimeMetadataPrefixed;
|
||||
use subxt::metadata::Metadata;
|
||||
use subxt::utils::H256;
|
||||
use subxt::{config::PolkadotConfig, OfflineClient};
|
||||
use subxt::{
|
||||
config::PolkadotConfig,
|
||||
ext::{codec::Decode, frame_metadata::RuntimeMetadataPrefixed},
|
||||
metadata::Metadata,
|
||||
utils::H256,
|
||||
OfflineClient,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::dynamic::{At, Value};
|
||||
use subxt::{OnlineClient, PolkadotConfig};
|
||||
use subxt::{
|
||||
dynamic::{At, Value},
|
||||
OnlineClient, PolkadotConfig,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use codec::Decode;
|
||||
use criterion::*;
|
||||
use frame_metadata::{v15::RuntimeMetadataV15, RuntimeMetadata, RuntimeMetadataPrefixed};
|
||||
use scale_info::{form::PortableForm, TypeDef, TypeDefVariant};
|
||||
use std::{fs, path::Path};
|
||||
use subxt_metadata::{
|
||||
get_call_hash, get_constant_hash, get_metadata_hash, get_pallet_hash, get_storage_hash,
|
||||
metadata_v14_to_latest,
|
||||
|
||||
@@ -6,7 +6,6 @@ mod retain;
|
||||
mod validation;
|
||||
|
||||
use frame_metadata::{v14::RuntimeMetadataV14, v15::RuntimeMetadataV15};
|
||||
|
||||
pub use retain::retain_metadata_pallets;
|
||||
pub use validation::{
|
||||
get_call_hash, get_constant_hash, get_metadata_hash, get_metadata_per_pallet_hash,
|
||||
|
||||
+10
-7
@@ -4,15 +4,16 @@
|
||||
|
||||
//! Utility functions to generate a subset of the metadata.
|
||||
|
||||
use frame_metadata::v15::{
|
||||
ExtrinsicMetadata, PalletMetadata, RuntimeApiMetadata, RuntimeMetadataV15, StorageEntryType,
|
||||
};
|
||||
use scale_info::{form::PortableForm, interner::UntrackedSymbol, TypeDef};
|
||||
use std::{
|
||||
any::TypeId,
|
||||
collections::{BTreeMap, HashSet},
|
||||
};
|
||||
|
||||
use frame_metadata::v15::{
|
||||
ExtrinsicMetadata, PalletMetadata, RuntimeApiMetadata, RuntimeMetadataV15, StorageEntryType,
|
||||
};
|
||||
use scale_info::{form::PortableForm, interner::UntrackedSymbol, TypeDef};
|
||||
|
||||
/// Collect all type IDs needed to represent the provided pallet.
|
||||
fn collect_pallet_types(pallet: &PalletMetadata<PortableForm>, type_ids: &mut HashSet<u32>) {
|
||||
if let Some(storage) = &pallet.storage {
|
||||
@@ -249,11 +250,13 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::metadata_v14_to_latest;
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use codec::Decode;
|
||||
use frame_metadata::{v15::RuntimeMetadataV15, RuntimeMetadata, RuntimeMetadataPrefixed};
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use super::*;
|
||||
use crate::metadata_v14_to_latest;
|
||||
|
||||
fn load_metadata() -> RuntimeMetadataV15 {
|
||||
let bytes = fs::read(Path::new("../artifacts/polkadot_metadata.scale"))
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
|
||||
//! Utility functions for metadata validation.
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use frame_metadata::v15::{
|
||||
ExtrinsicMetadata, PalletMetadata, RuntimeApiMetadata, RuntimeApiMethodMetadata,
|
||||
RuntimeMetadataV15, StorageEntryMetadata, StorageEntryType,
|
||||
};
|
||||
use scale_info::{form::PortableForm, Field, PortableRegistry, TypeDef, Variant};
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// Start with a predefined hashing value for the pallets.
|
||||
const MAGIC_PALLET_VALUE: &[u8] = &[19];
|
||||
@@ -576,7 +577,6 @@ pub enum NotFound {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bitvec::{order::Lsb0, vec::BitVec};
|
||||
use frame_metadata::v15::{
|
||||
ExtrinsicMetadata, PalletCallMetadata, PalletConstantMetadata, PalletErrorMetadata,
|
||||
@@ -585,6 +585,8 @@ mod tests {
|
||||
};
|
||||
use scale_info::meta_type;
|
||||
|
||||
use super::*;
|
||||
|
||||
// Define recursive types.
|
||||
#[allow(dead_code)]
|
||||
#[derive(scale_info::TypeInfo)]
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::lock::Mutex as AsyncMutex;
|
||||
|
||||
use crate::{
|
||||
blocks::{extrinsic_types::ExtrinsicPartTypeIds, Extrinsics},
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
@@ -13,9 +17,6 @@ use crate::{
|
||||
storage::Storage,
|
||||
};
|
||||
|
||||
use futures::lock::Mutex as AsyncMutex;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A representation of a block.
|
||||
pub struct Block<T: Config, C> {
|
||||
header: T::Header,
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::{future::Future, pin::Pin};
|
||||
|
||||
use derivative::Derivative;
|
||||
use futures::{future::Either, stream, Stream, StreamExt};
|
||||
|
||||
use super::Block;
|
||||
use crate::{
|
||||
client::OnlineClientT,
|
||||
@@ -9,9 +14,6 @@ use crate::{
|
||||
error::{BlockError, Error},
|
||||
utils::PhantomDataSendSync,
|
||||
};
|
||||
use derivative::Derivative;
|
||||
use futures::{future::Either, stream, Stream, StreamExt};
|
||||
use std::{future::Future, pin::Pin};
|
||||
|
||||
type BlockStream<T> = Pin<Box<dyn Stream<Item = Result<T, Error>> + Send>>;
|
||||
type BlockStreamRes<T> = Result<BlockStream<T>, Error>;
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use codec::Decode;
|
||||
use derivative::Derivative;
|
||||
use frame_metadata::v15::RuntimeMetadataV15;
|
||||
use scale_decode::DecodeAsFields;
|
||||
|
||||
use crate::{
|
||||
blocks::block_types::{get_events, CachedEvents},
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
@@ -13,12 +20,6 @@ use crate::{
|
||||
Metadata,
|
||||
};
|
||||
|
||||
use codec::Decode;
|
||||
use derivative::Derivative;
|
||||
use frame_metadata::v15::RuntimeMetadataV15;
|
||||
use scale_decode::DecodeAsFields;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
/// Trait to uniquely identify the extrinsic's identity from the runtime metadata.
|
||||
///
|
||||
/// Generated API structures that represent an extrinsic implement this trait.
|
||||
@@ -622,8 +623,6 @@ impl<T: Config> ExtrinsicEvents<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{rpc::types::RuntimeVersion, OfflineClient, PolkadotConfig};
|
||||
use assert_matches::assert_matches;
|
||||
use codec::{Decode, Encode};
|
||||
use frame_metadata::{
|
||||
@@ -634,6 +633,9 @@ mod tests {
|
||||
use scale_info::{meta_type, TypeInfo};
|
||||
use scale_value::Value;
|
||||
|
||||
use super::*;
|
||||
use crate::{rpc::types::RuntimeVersion, OfflineClient, PolkadotConfig};
|
||||
|
||||
// Extrinsic needs to contain at least the generic type parameter "Call"
|
||||
// for the metadata to be valid.
|
||||
// The "Call" type from the metadata is used to decode extrinsics.
|
||||
|
||||
@@ -12,12 +12,11 @@ mod offline_client;
|
||||
mod online_client;
|
||||
|
||||
pub use offline_client::{OfflineClient, OfflineClientT};
|
||||
pub use online_client::{
|
||||
ClientRuntimeUpdater, OnlineClient, OnlineClientT, RuntimeUpdaterStream, Update, UpgradeError,
|
||||
};
|
||||
|
||||
#[cfg(any(
|
||||
feature = "jsonrpsee-ws",
|
||||
all(feature = "jsonrpsee-web", target_arch = "wasm32")
|
||||
))]
|
||||
pub use online_client::default_rpc_client;
|
||||
pub use online_client::{
|
||||
ClientRuntimeUpdater, OnlineClient, OnlineClientT, RuntimeUpdaterStream, Update, UpgradeError,
|
||||
};
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use derivative::Derivative;
|
||||
|
||||
use crate::{
|
||||
blocks::BlocksClient, constants::ConstantsClient, events::EventsClient,
|
||||
rpc::types::RuntimeVersion, runtime_api::RuntimeApiClient, storage::StorageClient,
|
||||
tx::TxClient, Config, Metadata,
|
||||
};
|
||||
use derivative::Derivative;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A trait representing a client that can perform
|
||||
/// offline-only actions.
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use derivative::Derivative;
|
||||
use futures::future;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use super::{OfflineClient, OfflineClientT};
|
||||
use crate::{
|
||||
blocks::BlocksClient,
|
||||
@@ -17,10 +23,6 @@ use crate::{
|
||||
tx::TxClient,
|
||||
Config, Metadata,
|
||||
};
|
||||
use derivative::Derivative;
|
||||
use futures::future;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A trait representing a client that can perform
|
||||
/// online actions.
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
//! implementation of the trait is provided ([`BaseExtrinsicParams`]) which is
|
||||
//! used by the provided Substrate and Polkadot configuration.
|
||||
|
||||
use crate::{utils::Encoded, Config};
|
||||
use codec::{Compact, Decode, Encode};
|
||||
use core::fmt::Debug;
|
||||
|
||||
use codec::{Compact, Decode, Encode};
|
||||
use derivative::Derivative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{utils::Encoded, Config};
|
||||
|
||||
/// This trait allows you to configure the "signed extra" and
|
||||
/// "additional" parameters that are signed and used in transactions.
|
||||
/// see [`BaseExtrinsicParams`] for an implementation that is compatible with
|
||||
|
||||
@@ -12,12 +12,12 @@ pub mod extrinsic_params;
|
||||
pub mod polkadot;
|
||||
pub mod substrate;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use core::fmt::Debug;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
pub use extrinsic_params::ExtrinsicParams;
|
||||
pub use polkadot::PolkadotConfig;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
pub use substrate::SubstrateConfig;
|
||||
|
||||
/// Runtime types.
|
||||
@@ -115,9 +115,10 @@ impl<T: Config, E: extrinsic_params::ExtrinsicParams<T::Index, T::Hash>> Config
|
||||
/// implement subxt's Hasher and Header traits for some substrate structs
|
||||
#[cfg(feature = "substrate-compat")]
|
||||
mod substrate_impls {
|
||||
use super::*;
|
||||
use primitive_types::{H256, U256};
|
||||
|
||||
use super::*;
|
||||
|
||||
impl<N, H> Header for sp_runtime::generic::Header<N, H>
|
||||
where
|
||||
Self: Encode,
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
|
||||
//! Polkadot specific configuration
|
||||
|
||||
use codec::Encode;
|
||||
pub use primitive_types::{H256, U256};
|
||||
|
||||
use super::{
|
||||
extrinsic_params::{BaseExtrinsicParams, BaseExtrinsicParamsBuilder},
|
||||
Config,
|
||||
};
|
||||
use codec::Encode;
|
||||
|
||||
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
use crate::SubstrateConfig;
|
||||
pub use primitive_types::{H256, U256};
|
||||
|
||||
/// Default set of commonly used types by Polkadot nodes.
|
||||
pub enum PolkadotConfig {}
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
|
||||
//! Substrate specific configuration
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
pub use primitive_types::{H256, U256};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{
|
||||
extrinsic_params::{BaseExtrinsicParams, BaseExtrinsicParamsBuilder},
|
||||
Config, Hasher, Header,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
pub use primitive_types::{H256, U256};
|
||||
|
||||
/// Default set of commonly used types by Substrate runtimes.
|
||||
// Note: We only use this at the type level, so it should be impossible to
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{dynamic::DecodedValueThunk, metadata::DecodeWithMetadata};
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::{dynamic::DecodedValueThunk, metadata::DecodeWithMetadata};
|
||||
|
||||
/// This represents a constant address. Anything implementing this trait
|
||||
/// can be used to fetch constants.
|
||||
pub trait ConstantAddress {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use derivative::Derivative;
|
||||
|
||||
use super::ConstantAddress;
|
||||
use crate::{
|
||||
client::OfflineClientT,
|
||||
@@ -9,7 +11,6 @@ use crate::{
|
||||
metadata::{DecodeWithMetadata, MetadataError},
|
||||
Config,
|
||||
};
|
||||
use derivative::Derivative;
|
||||
|
||||
/// A client for accessing constants.
|
||||
#[derive(Derivative)]
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
//! This module provides the entry points to create dynamic
|
||||
//! transactions, storage and constant lookups.
|
||||
|
||||
use scale_decode::DecodeAsType;
|
||||
pub use scale_value::{At, Value};
|
||||
|
||||
use crate::{
|
||||
error::Error,
|
||||
metadata::{DecodeWithMetadata, Metadata},
|
||||
};
|
||||
use scale_decode::DecodeAsType;
|
||||
|
||||
pub use scale_value::{At, Value};
|
||||
|
||||
/// A [`scale_value::Value`] type endowed with contextual information
|
||||
/// regarding what type was used to decode each part of it. This implements
|
||||
@@ -20,16 +20,13 @@ pub use scale_value::{At, Value};
|
||||
pub type DecodedValue = scale_value::Value<scale_value::scale::TypeId>;
|
||||
|
||||
// Submit dynamic transactions.
|
||||
pub use crate::tx::dynamic as tx;
|
||||
|
||||
// Lookup constants dynamically.
|
||||
pub use crate::constants::dynamic as constant;
|
||||
|
||||
// Lookup storage values dynamically.
|
||||
pub use crate::storage::{dynamic as storage, dynamic_root as storage_root};
|
||||
|
||||
// Execute runtime API function call dynamically.
|
||||
pub use crate::runtime_api::dynamic as runtime_api_call;
|
||||
// Lookup storage values dynamically.
|
||||
pub use crate::storage::{dynamic as storage, dynamic_root as storage_root};
|
||||
pub use crate::tx::dynamic as tx;
|
||||
|
||||
/// This is the result of making a dynamic request to a node. From this,
|
||||
/// we can return the raw SCALE bytes that we were handed back, or we can
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
//! A representation of the dispatch error; an error returned when
|
||||
//! something fails in trying to submit/execute a transaction.
|
||||
|
||||
use crate::metadata::{DecodeWithMetadata, Metadata};
|
||||
use core::fmt::Debug;
|
||||
use scale_decode::visitor::DecodeAsTypeResult;
|
||||
use std::borrow::Cow;
|
||||
|
||||
use scale_decode::visitor::DecodeAsTypeResult;
|
||||
|
||||
use super::Error;
|
||||
use crate::error::RootError;
|
||||
use crate::{
|
||||
error::RootError,
|
||||
metadata::{DecodeWithMetadata, Metadata},
|
||||
};
|
||||
|
||||
/// An error dispatching a transaction.
|
||||
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
|
||||
|
||||
@@ -12,11 +12,11 @@ use core::fmt::Debug;
|
||||
pub use dispatch_error::{
|
||||
ArithmeticError, DispatchError, ModuleError, RawModuleError, TokenError, TransactionalError,
|
||||
};
|
||||
pub use scale_decode::Error as DecodeError;
|
||||
pub use scale_encode::Error as EncodeError;
|
||||
|
||||
// Re-expose the errors we use from other crates here:
|
||||
pub use crate::metadata::{InvalidMetadataError, Metadata, MetadataError};
|
||||
pub use scale_decode::Error as DecodeError;
|
||||
pub use scale_encode::Error as EncodeError;
|
||||
|
||||
/// The underlying error enum, generic over the type held by the `Runtime`
|
||||
/// variant. Prefer to use the [`Error<E>`] and [`Error`] aliases over
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{client::OnlineClientT, error::Error, events::Events, rpc::types::StorageKey, Config};
|
||||
use derivative::Derivative;
|
||||
use std::future::Future;
|
||||
|
||||
use derivative::Derivative;
|
||||
|
||||
use crate::{client::OnlineClientT, error::Error, events::Events, rpc::types::StorageKey, Config};
|
||||
|
||||
/// A client for working with events.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Clone(bound = "Client: Clone"))]
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
//! A representation of a block of events.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use codec::{Compact, Decode};
|
||||
use derivative::Derivative;
|
||||
|
||||
use super::{Phase, StaticEvent};
|
||||
use crate::{
|
||||
client::OnlineClientT,
|
||||
@@ -12,9 +17,6 @@ use crate::{
|
||||
metadata::{DecodeWithMetadata, EventMetadata},
|
||||
Config, Metadata,
|
||||
};
|
||||
use codec::{Compact, Decode};
|
||||
use derivative::Derivative;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A collection of events obtained from a block, bundled with the necessary
|
||||
/// information needed to decode and iterate over them.
|
||||
@@ -426,15 +428,17 @@ pub trait RootEvent: Sized {
|
||||
/// Event related test utilities used outside this module.
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test_utils {
|
||||
use super::*;
|
||||
use crate::{Config, SubstrateConfig};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use codec::Encode;
|
||||
use frame_metadata::{
|
||||
v15::{ExtrinsicMetadata, PalletEventMetadata, PalletMetadata, RuntimeMetadataV15},
|
||||
RuntimeMetadataPrefixed,
|
||||
};
|
||||
use scale_info::{meta_type, TypeInfo};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use super::*;
|
||||
use crate::{Config, SubstrateConfig};
|
||||
|
||||
/// An "outer" events enum containing exactly one event.
|
||||
#[derive(
|
||||
@@ -576,13 +580,14 @@ pub(crate) mod test_utils {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use codec::Encode;
|
||||
use scale_info::TypeInfo;
|
||||
use scale_value::Value;
|
||||
|
||||
use super::{
|
||||
test_utils::{event_record, events, events_raw, AllEvents},
|
||||
*,
|
||||
};
|
||||
use codec::Encode;
|
||||
use scale_info::TypeInfo;
|
||||
use scale_value::Value;
|
||||
|
||||
/// Build a fake wrapped metadata.
|
||||
fn metadata<E: TypeInfo + 'static>() -> Metadata {
|
||||
|
||||
+2
-3
@@ -38,12 +38,11 @@ pub mod book;
|
||||
|
||||
// Suppress an unused dependency warning because tokio is
|
||||
// only used in example code snippets at the time of writing.
|
||||
#[cfg(test)]
|
||||
use tokio as _;
|
||||
|
||||
// Used to enable the js feature for wasm.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub use getrandom as _;
|
||||
#[cfg(test)]
|
||||
use tokio as _;
|
||||
|
||||
#[cfg(all(feature = "jsonrpsee-ws", feature = "jsonrpsee-web"))]
|
||||
std::compile_error!(
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use parking_lot::RwLock;
|
||||
use std::{borrow::Cow, collections::HashMap};
|
||||
|
||||
use parking_lot::RwLock;
|
||||
|
||||
/// A cache with the simple goal of storing 32 byte hashes against root+item keys
|
||||
#[derive(Default, Debug)]
|
||||
pub struct HashCache {
|
||||
|
||||
@@ -2,15 +2,17 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::hash_cache::HashCache;
|
||||
use std::{collections::HashMap, convert::TryFrom, sync::Arc};
|
||||
|
||||
use codec::Error as CodecError;
|
||||
use frame_metadata::{
|
||||
v15::PalletConstantMetadata, v15::RuntimeMetadataV15, v15::StorageEntryMetadata,
|
||||
v15::{PalletConstantMetadata, RuntimeMetadataV15, StorageEntryMetadata},
|
||||
RuntimeMetadata, RuntimeMetadataPrefixed, META_RESERVED,
|
||||
};
|
||||
use parking_lot::RwLock;
|
||||
use scale_info::{form::PortableForm, PortableRegistry, Type};
|
||||
use std::{collections::HashMap, convert::TryFrom, sync::Arc};
|
||||
|
||||
use super::hash_cache::HashCache;
|
||||
|
||||
/// Metadata error originated from inspecting the internal representation of the runtime metadata.
|
||||
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
|
||||
@@ -723,13 +725,14 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use frame_metadata::v15::{
|
||||
ExtrinsicMetadata, PalletCallMetadata, PalletMetadata, PalletStorageMetadata,
|
||||
StorageEntryModifier, StorageEntryType,
|
||||
};
|
||||
use scale_info::{meta_type, TypeInfo};
|
||||
|
||||
use super::*;
|
||||
|
||||
fn load_metadata() -> Metadata {
|
||||
// Extrinsic needs to contain at least the generic type parameter "Call"
|
||||
// for the metadata to be valid.
|
||||
|
||||
@@ -9,11 +9,9 @@ mod hash_cache;
|
||||
mod metadata_location;
|
||||
mod metadata_type;
|
||||
|
||||
pub use decode_encode_traits::{DecodeWithMetadata, EncodeWithMetadata};
|
||||
pub use metadata_location::MetadataLocation;
|
||||
|
||||
pub use metadata_type::{
|
||||
ErrorMetadata, EventMetadata, ExtrinsicMetadata, InvalidMetadataError, Metadata, MetadataError,
|
||||
PalletMetadata, RuntimeFnMetadata,
|
||||
};
|
||||
|
||||
pub use decode_encode_traits::{DecodeWithMetadata, EncodeWithMetadata};
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::{RpcClientT, RpcFuture, RpcSubscription};
|
||||
use crate::error::RpcError;
|
||||
use futures::stream::{StreamExt, TryStreamExt};
|
||||
use jsonrpsee::{
|
||||
core::{
|
||||
@@ -15,6 +13,9 @@ use jsonrpsee::{
|
||||
};
|
||||
use serde_json::value::RawValue;
|
||||
|
||||
use super::{RpcClientT, RpcFuture, RpcSubscription};
|
||||
use crate::error::RpcError;
|
||||
|
||||
struct Params(Option<Box<RawValue>>);
|
||||
|
||||
impl ToRpcParams for Params {
|
||||
|
||||
@@ -56,9 +56,7 @@ pub mod types;
|
||||
|
||||
// Expose the `Rpc` struct.
|
||||
pub use rpc::*;
|
||||
|
||||
pub use rpc_client::{rpc_params, RpcClient, RpcParams, Subscription};
|
||||
pub use rpc_client_t::{
|
||||
RawValue, RpcClientT, RpcFuture, RpcSubscription, RpcSubscriptionId, RpcSubscriptionStream,
|
||||
};
|
||||
|
||||
pub use rpc_client::{rpc_params, RpcClient, RpcParams, Subscription};
|
||||
|
||||
@@ -37,13 +37,12 @@ use codec::{Decode, Encode};
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{error::Error, utils::PhantomDataSendSync, Config, Metadata};
|
||||
|
||||
use super::{
|
||||
rpc_params,
|
||||
types::{self, ChainHeadEvent, FollowEvent},
|
||||
RpcClient, RpcClientT, Subscription,
|
||||
};
|
||||
use crate::{error::Error, utils::PhantomDataSendSync, Config, Metadata};
|
||||
|
||||
/// Client for substrate rpc interfaces
|
||||
pub struct Rpc<T: Config> {
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::{RpcClientT, RpcSubscription, RpcSubscriptionId};
|
||||
use crate::error::Error;
|
||||
use std::{pin::Pin, sync::Arc, task::Poll};
|
||||
|
||||
use futures::{Stream, StreamExt};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use serde_json::value::RawValue;
|
||||
use std::{pin::Pin, sync::Arc, task::Poll};
|
||||
|
||||
use super::{RpcClientT, RpcSubscription, RpcSubscriptionId};
|
||||
use crate::error::Error;
|
||||
|
||||
/// A concrete wrapper around an [`RpcClientT`] which exposes the udnerlying interface via some
|
||||
/// higher level methods that make it a little easier to work with.
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::error::RpcError;
|
||||
use futures::Stream;
|
||||
use std::{future::Future, pin::Pin};
|
||||
|
||||
use futures::Stream;
|
||||
// Re-exporting for simplicity since it's used a bunch in the trait definition.
|
||||
pub use serde_json::value::RawValue;
|
||||
|
||||
use crate::error::RpcError;
|
||||
|
||||
/// Any RPC client which implements this can be used in our [`super::Rpc`] type
|
||||
/// to talk to a node.
|
||||
///
|
||||
|
||||
@@ -4,14 +4,15 @@
|
||||
|
||||
//! Types sent to/from the Substrate RPC interface.
|
||||
|
||||
use crate::{metadata::Metadata, Config};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use primitive_types::U256;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
// Subscription types are returned from some calls, so expose it with the rest of the returned types.
|
||||
pub use super::rpc_client::Subscription;
|
||||
use crate::{metadata::Metadata, Config};
|
||||
|
||||
/// An error dry running an extrinsic.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
@@ -730,9 +731,10 @@ impl<Hash> From<TransactionEventIR<Hash>> for TransactionEvent<Hash> {
|
||||
|
||||
/// Serialize and deserialize helper as string.
|
||||
mod as_string {
|
||||
use super::*;
|
||||
use serde::Deserializer;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<usize, D::Error> {
|
||||
String::deserialize(deserializer)?
|
||||
.parse()
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::runtime_types::RuntimeApi;
|
||||
|
||||
use crate::{client::OnlineClientT, error::Error, Config};
|
||||
use derivative::Derivative;
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
use derivative::Derivative;
|
||||
|
||||
use super::runtime_types::RuntimeApi;
|
||||
use crate::{client::OnlineClientT, error::Error, Config};
|
||||
|
||||
/// Execute runtime API calls.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Clone(bound = "Client: Clone"))]
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use core::marker::PhantomData;
|
||||
use scale_encode::EncodeAsFields;
|
||||
use scale_value::Composite;
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::dynamic::DecodedValueThunk;
|
||||
use crate::{metadata::DecodeWithMetadata, Error, Metadata};
|
||||
use scale_encode::EncodeAsFields;
|
||||
use scale_value::Composite;
|
||||
|
||||
use crate::{dynamic::DecodedValueThunk, metadata::DecodeWithMetadata, Error, Metadata};
|
||||
|
||||
/// This represents a runtime API payload that can call into the runtime of node.
|
||||
///
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{client::OnlineClientT, error::Error, metadata::DecodeWithMetadata, Config};
|
||||
use codec::Decode;
|
||||
use derivative::Derivative;
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
use codec::Decode;
|
||||
use derivative::Derivative;
|
||||
|
||||
use super::RuntimeApiPayload;
|
||||
use crate::{client::OnlineClientT, error::Error, metadata::DecodeWithMetadata, Config};
|
||||
|
||||
/// Execute runtime API calls.
|
||||
#[derive(Derivative)]
|
||||
|
||||
@@ -11,7 +11,6 @@ mod storage_type;
|
||||
pub mod utils;
|
||||
|
||||
pub use storage_client::StorageClient;
|
||||
|
||||
pub use storage_type::{KeyIter, Storage};
|
||||
|
||||
// Re-export as this is used in the public API in this module:
|
||||
|
||||
@@ -2,15 +2,17 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use frame_metadata::v15::{StorageEntryType, StorageHasher};
|
||||
use scale_info::TypeDef;
|
||||
|
||||
use crate::{
|
||||
dynamic::{DecodedValueThunk, Value},
|
||||
error::{Error, StorageAddressError},
|
||||
metadata::{DecodeWithMetadata, EncodeWithMetadata, Metadata},
|
||||
utils::{Encoded, Static},
|
||||
};
|
||||
use frame_metadata::v15::{StorageEntryType, StorageHasher};
|
||||
use scale_info::TypeDef;
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// This represents a storage address. Anything implementing this trait
|
||||
/// can be used to fetch and iterate over storage entries.
|
||||
|
||||
@@ -2,18 +2,19 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
use derivative::Derivative;
|
||||
|
||||
use super::{
|
||||
storage_type::{validate_storage_address, Storage},
|
||||
utils, StorageAddress,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
error::Error,
|
||||
Config,
|
||||
};
|
||||
use derivative::Derivative;
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
/// Query the runtime storage.
|
||||
#[derive(Derivative)]
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
use derivative::Derivative;
|
||||
use frame_metadata::v15::StorageEntryType;
|
||||
use scale_info::form::PortableForm;
|
||||
|
||||
use super::storage_address::{StorageAddress, Yes};
|
||||
use crate::{
|
||||
client::OnlineClientT,
|
||||
@@ -10,10 +16,6 @@ use crate::{
|
||||
rpc::types::{StorageData, StorageKey},
|
||||
Config,
|
||||
};
|
||||
use derivative::Derivative;
|
||||
use frame_metadata::v15::StorageEntryType;
|
||||
use scale_info::form::PortableForm;
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
/// Query the runtime storage.
|
||||
#[derive(Derivative)]
|
||||
|
||||
@@ -18,7 +18,6 @@ mod tx_progress;
|
||||
// feature if we want to avoid needing sp_core and sp_runtime.
|
||||
#[cfg(feature = "substrate-compat")]
|
||||
pub use self::signer::PairSigner;
|
||||
|
||||
pub use self::{
|
||||
signer::Signer,
|
||||
tx_client::{SubmittableExtrinsic, TxClient},
|
||||
|
||||
@@ -31,14 +31,15 @@ pub use pair_signer::PairSigner;
|
||||
// packages like sp_keyring and such, and so relies on sp_core and sp_runtime to be included.
|
||||
#[cfg(feature = "substrate-compat")]
|
||||
mod pair_signer {
|
||||
use super::Signer;
|
||||
use crate::Config;
|
||||
use sp_core::Pair as PairT;
|
||||
use sp_runtime::{
|
||||
traits::{IdentifyAccount, Verify},
|
||||
AccountId32 as SpAccountId32, MultiSignature as SpMultiSignature,
|
||||
};
|
||||
|
||||
use super::Signer;
|
||||
use crate::Config;
|
||||
|
||||
/// A [`Signer`] implementation that can be constructed from an [`sp_core::Pair`].
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PairSigner<T: Config, Pair> {
|
||||
|
||||
@@ -8,6 +8,8 @@ use codec::{Compact, Encode};
|
||||
use derivative::Derivative;
|
||||
use sp_core_hashing::blake2_256;
|
||||
|
||||
// This is returned from an API below, so expose it here.
|
||||
pub use crate::rpc::types::DryRunResult;
|
||||
use crate::{
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
config::{Config, ExtrinsicParams, Hasher},
|
||||
@@ -16,9 +18,6 @@ use crate::{
|
||||
utils::{Encoded, PhantomDataSendSync},
|
||||
};
|
||||
|
||||
// This is returned from an API below, so expose it here.
|
||||
pub use crate::rpc::types::DryRunResult;
|
||||
|
||||
/// A client for working with transactions.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Clone(bound = "Client: Clone"))]
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
//! This module contains the trait and types used to represent
|
||||
//! transactions that can be submitted.
|
||||
|
||||
use crate::{dynamic::Value, error::Error, metadata::Metadata};
|
||||
use std::{borrow::Cow, sync::Arc};
|
||||
|
||||
use codec::Encode;
|
||||
use scale_encode::EncodeAsFields;
|
||||
use scale_value::{Composite, ValueDef, Variant};
|
||||
use std::{borrow::Cow, sync::Arc};
|
||||
|
||||
use crate::{dynamic::Value, error::Error, metadata::Metadata};
|
||||
|
||||
/// This represents a transaction payload that can be submitted
|
||||
/// to a node.
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
use std::task::Poll;
|
||||
|
||||
use derivative::Derivative;
|
||||
use futures::{Stream, StreamExt};
|
||||
|
||||
use crate::{
|
||||
client::OnlineClientT,
|
||||
error::{DispatchError, Error, RpcError, TransactionError},
|
||||
@@ -13,8 +16,6 @@ use crate::{
|
||||
rpc::types::{Subscription, SubstrateTxStatus},
|
||||
Config,
|
||||
};
|
||||
use derivative::Derivative;
|
||||
use futures::{Stream, StreamExt};
|
||||
|
||||
/// This struct represents a subscription to the progress of some transaction.
|
||||
#[derive(Derivative)]
|
||||
@@ -413,6 +414,7 @@ mod test {
|
||||
use std::pin::Pin;
|
||||
|
||||
use futures::Stream;
|
||||
use serde_json::value::RawValue;
|
||||
|
||||
use crate::{
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
@@ -423,8 +425,6 @@ mod test {
|
||||
Config, Error, SubstrateConfig,
|
||||
};
|
||||
|
||||
use serde_json::value::RawValue;
|
||||
|
||||
type MockTxProgress = TxProgress<SubstrateConfig, MockClient>;
|
||||
type MockHash = <WithExtrinsicParams<
|
||||
SubstrateConfig,
|
||||
|
||||
@@ -180,11 +180,11 @@ mod substrate_impls {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use sp_core::crypto::Ss58Codec;
|
||||
use sp_keyring::AccountKeyring;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn ss58_is_compatible_with_substrate_impl() {
|
||||
let keyrings = vec![
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
|
||||
//! Generic `scale_bits` over `bitvec`-like `BitOrder` and `BitFormat` types.
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use codec::{Compact, Input};
|
||||
use scale_bits::{
|
||||
scale::format::{Format, OrderFormat, StoreFormat},
|
||||
Bits,
|
||||
};
|
||||
use scale_decode::IntoVisitor;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
/// Associates `bitvec::store::BitStore` trait with corresponding, type-erased `scale_bits::StoreFormat` enum.
|
||||
///
|
||||
@@ -191,13 +192,13 @@ impl<Store, Order> scale_encode::EncodeAsType for DecodedBits<Store, Order> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use core::fmt::Debug;
|
||||
|
||||
use bitvec::vec::BitVec;
|
||||
use codec::Decode as _;
|
||||
|
||||
use super::*;
|
||||
|
||||
// NOTE: We don't use `bitvec::order` types in our implementation, since we
|
||||
// don't want to depend on `bitvec`. Rather than reimplementing the unsafe
|
||||
// trait on our types here for testing purposes, we simply convert and
|
||||
|
||||
@@ -11,18 +11,16 @@ mod multi_signature;
|
||||
mod static_type;
|
||||
mod wrapper_opaque;
|
||||
|
||||
pub use account_id::AccountId32;
|
||||
use codec::{Decode, Encode};
|
||||
use derivative::Derivative;
|
||||
|
||||
pub use account_id::AccountId32;
|
||||
pub use multi_address::MultiAddress;
|
||||
pub use multi_signature::MultiSignature;
|
||||
pub use static_type::Static;
|
||||
pub use wrapper_opaque::WrapperKeepOpaque;
|
||||
|
||||
// Used in codegen
|
||||
#[doc(hidden)]
|
||||
pub use primitive_types::{H160, H256, H512};
|
||||
pub use static_type::Static;
|
||||
pub use wrapper_opaque::WrapperKeepOpaque;
|
||||
|
||||
/// Wraps an already encoded byte vector, prevents being encoded as a raw byte vector as part of
|
||||
/// the transaction payload
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::PhantomDataSendSync;
|
||||
use codec::{Compact, Decode, DecodeAll, Encode};
|
||||
use derivative::Derivative;
|
||||
use scale_decode::{IntoVisitor, Visitor};
|
||||
use scale_encode::EncodeAsType;
|
||||
|
||||
use super::PhantomDataSendSync;
|
||||
|
||||
/// A wrapper for any type `T` which implement encode/decode in a way compatible with `Vec<u8>`.
|
||||
/// [`WrapperKeepOpaque`] stores the type only in its opaque format, aka as a `Vec<u8>`. To
|
||||
/// access the real type `T` [`Self::try_decode`] needs to be used.
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{pair_signer, test_context, utils::node_runtime};
|
||||
use codec::Compact;
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
use futures::StreamExt;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::blocks::BlocksClient;
|
||||
|
||||
use crate::{pair_signer, test_context, utils::node_runtime};
|
||||
|
||||
// Check that we can subscribe to non-finalized blocks.
|
||||
#[tokio::test]
|
||||
async fn non_finalized_headers_subscription() -> Result<(), subxt::Error> {
|
||||
|
||||
@@ -2,15 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{
|
||||
pair_signer, test_context, test_context_with,
|
||||
utils::{node_runtime, wait_for_blocks},
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use codec::{Compact, Decode, Encode};
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
use sp_core::storage::well_known_keys;
|
||||
use sp_core::{sr25519::Pair as Sr25519Pair, Pair};
|
||||
use sp_core::{sr25519::Pair as Sr25519Pair, storage::well_known_keys, Pair};
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::{
|
||||
error::{DispatchError, Error, TokenError},
|
||||
@@ -22,6 +17,11 @@ use subxt::{
|
||||
utils::AccountId32,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
pair_signer, test_context, test_context_with,
|
||||
utils::{node_runtime, wait_for_blocks},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn insert_key() {
|
||||
let ctx = test_context_with(AccountKeyring::Bob).await;
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{
|
||||
node_runtime::{self, balances, runtime_types, system},
|
||||
pair_signer, test_context,
|
||||
};
|
||||
use codec::Decode;
|
||||
use sp_core::Pair;
|
||||
use sp_keyring::AccountKeyring;
|
||||
@@ -14,6 +10,11 @@ use subxt::{
|
||||
utils::{AccountId32, MultiAddress},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
node_runtime::{self, balances, runtime_types, system},
|
||||
pair_signer, test_context,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn tx_basic_transfer() -> Result<(), subxt::Error> {
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use sp_core::sr25519::Pair;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::{
|
||||
tx::{PairSigner, TxProgress},
|
||||
utils::MultiAddress,
|
||||
Config, Error, OnlineClient, SubstrateConfig,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
node_runtime::{
|
||||
@@ -13,12 +19,6 @@ use crate::{
|
||||
},
|
||||
test_context, TestContext,
|
||||
};
|
||||
use sp_core::sr25519::Pair;
|
||||
use subxt::{
|
||||
tx::{PairSigner, TxProgress},
|
||||
utils::MultiAddress,
|
||||
Config, Error, OnlineClient, SubstrateConfig,
|
||||
};
|
||||
|
||||
struct ContractsTestContext {
|
||||
cxt: TestContext,
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use assert_matches::assert_matches;
|
||||
use sp_core::{sr25519, Pair};
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::error::{DispatchError, Error};
|
||||
|
||||
use crate::{
|
||||
node_runtime::{
|
||||
self,
|
||||
@@ -13,10 +18,6 @@ use crate::{
|
||||
},
|
||||
pair_signer, test_context,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use sp_core::{sr25519, Pair};
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::error::{DispatchError, Error};
|
||||
|
||||
/// Helper function to generate a crypto pair from seed
|
||||
fn get_from_seed(seed: &str) -> sr25519::Pair {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use sp_keyring::AccountKeyring;
|
||||
|
||||
use crate::{
|
||||
node_runtime::{
|
||||
self,
|
||||
@@ -10,7 +12,6 @@ use crate::{
|
||||
},
|
||||
pair_signer, test_context,
|
||||
};
|
||||
use sp_keyring::AccountKeyring;
|
||||
|
||||
type Call = runtime_types::kitchensink_runtime::RuntimeCall;
|
||||
type BalancesCall = runtime_types::pallet_balances::pallet::Call;
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use assert_matches::assert_matches;
|
||||
use sp_keyring::AccountKeyring;
|
||||
|
||||
use crate::{
|
||||
node_runtime::{self, system},
|
||||
pair_signer, test_context,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use sp_keyring::AccountKeyring;
|
||||
|
||||
#[tokio::test]
|
||||
async fn storage_account() -> Result<(), subxt::Error> {
|
||||
|
||||
@@ -24,9 +24,6 @@ mod storage;
|
||||
|
||||
#[cfg(test)]
|
||||
use test_runtime::node_runtime;
|
||||
#[cfg(test)]
|
||||
use utils::*;
|
||||
|
||||
// We don't use this dependency, but it's here so that we
|
||||
// can enable logging easily if need be. Add this to a test
|
||||
// to enable tracing for it:
|
||||
@@ -34,3 +31,5 @@ use utils::*;
|
||||
// tracing_subscriber::fmt::init();
|
||||
#[cfg(test)]
|
||||
use tracing_subscriber as _;
|
||||
#[cfg(test)]
|
||||
use utils::*;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{node_runtime, test_context, TestContext};
|
||||
use frame_metadata::{
|
||||
v15::{
|
||||
ExtrinsicMetadata, PalletCallMetadata, PalletMetadata, PalletStorageMetadata,
|
||||
@@ -16,6 +15,8 @@ use scale_info::{
|
||||
};
|
||||
use subxt::{Metadata, OfflineClient, SubstrateConfig};
|
||||
|
||||
use crate::{node_runtime, test_context, TestContext};
|
||||
|
||||
async fn metadata_to_api(
|
||||
metadata: RuntimeMetadataV15,
|
||||
ctx: &TestContext,
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{node_runtime, pair_signer, test_context};
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::utils::AccountId32;
|
||||
|
||||
use crate::{node_runtime, pair_signer, test_context};
|
||||
|
||||
#[tokio::test]
|
||||
async fn account_nonce() -> Result<(), subxt::Error> {
|
||||
let ctx = test_context().await;
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{node_runtime, pair_signer, test_context, utils::wait_for_blocks};
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::utils::AccountId32;
|
||||
|
||||
use crate::{node_runtime, pair_signer, test_context, utils::wait_for_blocks};
|
||||
|
||||
#[tokio::test]
|
||||
async fn storage_plain_lookup() -> Result<(), subxt::Error> {
|
||||
let ctx = test_context().await;
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
pub(crate) use crate::{node_runtime, TestNodeProcess};
|
||||
|
||||
use sp_core::sr25519::Pair;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::{tx::PairSigner, SubstrateConfig};
|
||||
|
||||
pub(crate) use crate::{node_runtime, TestNodeProcess};
|
||||
|
||||
/// substrate node should be installed on the $PATH
|
||||
const SUBSTRATE_NODE_PATH: &str = "substrate";
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use sp_keyring::AccountKeyring;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
|
||||
use sp_keyring::AccountKeyring;
|
||||
use substrate_runner::SubstrateNode;
|
||||
use subxt::{Config, OnlineClient};
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
mod error;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
use std::io::{BufRead, BufReader, Read};
|
||||
use std::process::{self, Command};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::HashMap,
|
||||
ffi::OsString,
|
||||
io::{BufRead, BufReader, Read},
|
||||
process::{self, Command},
|
||||
};
|
||||
|
||||
pub use error::Error;
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use std::{env, fs, path::Path};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use substrate_runner::{Error as SubstrateNodeError, SubstrateNode};
|
||||
|
||||
static SUBSTRATE_BIN_ENV_VAR: &str = "SUBSTRATE_NODE_PATH";
|
||||
@@ -100,13 +101,11 @@ mod client {
|
||||
pub use jsonrpsee::{
|
||||
client_transport::ws::{InvalidUri, Receiver, Sender, Uri, WsTransportClientBuilder},
|
||||
core::{
|
||||
client::{Client, ClientBuilder},
|
||||
Error,
|
||||
client::{Client, ClientBuilder, ClientT},
|
||||
rpc_params, Error,
|
||||
},
|
||||
};
|
||||
|
||||
pub use jsonrpsee::core::{client::ClientT, rpc_params};
|
||||
|
||||
/// Build WS RPC client from URL
|
||||
pub async fn build(url: &str) -> Result<Client, Error> {
|
||||
let (sender, receiver) = ws_transport(url).await?;
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
|
||||
use crate::utils::{
|
||||
dispatch_error::{ArrayDispatchError, LegacyDispatchError, NamedFieldDispatchError},
|
||||
generate_metadata_from_pallets_custom_dispatch_error,
|
||||
};
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
|
||||
pub fn metadata_array_dispatch_error() -> RuntimeMetadataPrefixed {
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<ArrayDispatchError>(vec![])
|
||||
|
||||
@@ -13,10 +13,9 @@ use frame_metadata::{
|
||||
},
|
||||
RuntimeMetadataPrefixed,
|
||||
};
|
||||
use scale_info::{meta_type, IntoPortable, TypeInfo};
|
||||
|
||||
pub use metadata_test_runner::MetadataTestRunner;
|
||||
pub use pallet_metadata_test_runner::PalletMetadataTestRunner;
|
||||
use scale_info::{meta_type, IntoPortable, TypeInfo};
|
||||
|
||||
/// Given some pallet metadata, generate a [`RuntimeMetadataPrefixed`] struct.
|
||||
/// We default to a useless extrinsic type, and register a fake `DispatchError`
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use frame_metadata::{v15::RuntimeMetadataV15, RuntimeMetadataPrefixed};
|
||||
use std::io::Read;
|
||||
use subxt_metadata::{metadata_v14_to_latest, retain_metadata_pallets};
|
||||
|
||||
static TEST_DIR_PREFIX: &str = "subxt_generated_pallets_ui_tests_";
|
||||
|
||||
Reference in New Issue
Block a user