start porting dynamic value stuff

This commit is contained in:
Tadeo hepperle
2024-02-01 14:36:43 +01:00
parent 7b2cfdc7bf
commit aed00e52f8
30 changed files with 122 additions and 351 deletions
+4 -4
View File
@@ -71,9 +71,9 @@ frame-metadata = { version = "16.0.0", default-features = false }
futures = { version = "0.3.30", default-features = false, features = ["std"] }
getrandom = { version = "0.2", default-features = false }
hashbrown = "0.14.3"
hex = "0.4.3"
hex = { version = "0.4.3", default-features = false }
heck = "0.4.1"
impl-serde = { version = "0.4.0" }
impl-serde = { version = "0.4.0", default-features = false }
indoc = "2"
jsonrpsee = { version = "0.21" }
pretty_assertions = "1.4.0"
@@ -87,8 +87,8 @@ scale-value = { version = "0.13.0", default-features = false }
scale-bits = { version = "0.4.0", default-features = false }
scale-decode = { version = "0.10.0", default-features = false }
scale-encode = { version = "0.5.0", default-features = false }
serde = { version = "1.0.196" }
serde_json = { version = "1.0.113" }
serde = { version = "1.0.196", default-features = false, features = ["derive"] }
serde_json = { version = "1.0.113", default-features = false }
syn = { version = "2.0.15", features = ["full", "extra-traits"] }
thiserror = "1.0.53"
tokio = { version = "1.35", default-features = false }
+4 -4
View File
@@ -31,16 +31,16 @@ frame-metadata = { workspace = true, default-features = false }
subxt-metadata = { workspace = true, default-features = false }
derivative = { workspace = true, features = ["use_core"] }
derive_more = { workspace = true }
hex = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["raw_value"] }
hex = { workspace = true, default-features = false, features = ["alloc"] }
serde = { workspace = true, default-features = false, features = ["derive"] }
serde_json = { workspace = true, default-features = false, features = ["raw_value", "alloc"] }
# For ss58 encoding AccountId32 to serialize them properly:
base58 = { workspace = true }
blake2 = { workspace = true }
# Provides some deserialization, types like U256/H256 and hashing impls like twox/blake256:
impl-serde = { workspace = true }
impl-serde = { workspace = true, default-features = false }
primitive-types = { workspace = true, default-features = false, features = ["codec", "serde_no_std", "scale-info"] }
sp-core-hashing = { workspace = true }
+66 -65
View File
@@ -1,20 +1,21 @@
// // Copyright 2019-2023 Parity Technologies (UK) Ltd.
// // This file is dual-licensed as Apache-2.0 or GPL-3.0.
// // see LICENSE for license details.
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
// //! This module provides the entry points to create dynamic
// //! transactions, storage and constant lookups.
//! This module provides the entry points to create dynamic
//! transactions, storage and constant lookups.
// use crate::metadata::{DecodeWithMetadata, Metadata};
// use scale_decode::DecodeAsType;
use crate::metadata::{DecodeWithMetadata, Metadata};
use crate::prelude::*;
use scale_decode::DecodeAsType;
pub use scale_value::{At, Value};
use vec::Vec;
// 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
// /// [`crate::metadata::DecodeWithMetadata`], and is used as a return type
// /// for dynamic requests.
// pub type DecodedValue = scale_value::Value<scale_value::scale::TypeId>;
/// A [`scale_value::Value`] type endowed with contextual information
/// regarding what type was used to decode each part of it. This implements
/// [`subxt_core::metadata::DecodeWithMetadata`], and is used as a return type
/// for dynamic requests.
pub type DecodedValue = scale_value::Value<scale_value::scale::TypeId>;
// // Submit dynamic transactions.
// pub use crate::tx::dynamic as tx;
@@ -28,56 +29,56 @@
// // Execute runtime API function call dynamically.
// pub use crate::runtime_api::dynamic as runtime_api_call;
// /// 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
// /// complete the decoding of the bytes into a [`DecodedValue`] type.
// pub struct DecodedValueThunk {
// type_id: u32,
// metadata: Metadata,
// scale_bytes: Vec<u8>,
// }
/// 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
/// complete the decoding of the bytes into a [`DecodedValue`] type.
pub struct DecodedValueThunk {
type_id: u32,
metadata: Metadata,
scale_bytes: Vec<u8>,
}
// impl DecodeWithMetadata for DecodedValueThunk {
// fn decode_with_metadata(
// bytes: &mut &[u8],
// type_id: u32,
// metadata: &Metadata,
// ) -> Result<Self, Error> {
// let mut v = Vec::with_capacity(bytes.len());
// v.extend_from_slice(bytes);
// *bytes = &[];
// Ok(DecodedValueThunk {
// type_id,
// metadata: metadata.clone(),
// scale_bytes: v,
// })
// }
// }
impl DecodeWithMetadata for DecodedValueThunk {
fn decode_with_metadata(
bytes: &mut &[u8],
type_id: u32,
metadata: &Metadata,
) -> Result<Self, scale_decode::Error> {
let mut v = Vec::with_capacity(bytes.len());
v.extend_from_slice(bytes);
*bytes = &[];
Ok(DecodedValueThunk {
type_id,
metadata: metadata.clone(),
scale_bytes: v,
})
}
}
// impl DecodedValueThunk {
// /// Return the SCALE encoded bytes handed back from the node.
// pub fn into_encoded(self) -> Vec<u8> {
// self.scale_bytes
// }
// /// Return the SCALE encoded bytes handed back from the node without taking ownership of them.
// pub fn encoded(&self) -> &[u8] {
// &self.scale_bytes
// }
// /// Decode the SCALE encoded storage entry into a dynamic [`DecodedValue`] type.
// pub fn to_value(&self) -> Result<DecodedValue, Error> {
// let val = DecodedValue::decode_as_type(
// &mut &*self.scale_bytes,
// self.type_id,
// self.metadata.types(),
// )?;
// Ok(val)
// }
// /// decode the `DecodedValueThunk` into a concrete type.
// pub fn as_type<T: DecodeAsType>(&self) -> Result<T, scale_decode::Error> {
// T::decode_as_type(
// &mut &self.scale_bytes[..],
// self.type_id,
// self.metadata.types(),
// )
// }
// }
impl DecodedValueThunk {
/// Return the SCALE encoded bytes handed back from the node.
pub fn into_encoded(self) -> Vec<u8> {
self.scale_bytes
}
/// Return the SCALE encoded bytes handed back from the node without taking ownership of them.
pub fn encoded(&self) -> &[u8] {
&self.scale_bytes
}
/// Decode the SCALE encoded storage entry into a dynamic [`DecodedValue`] type.
pub fn to_value(&self) -> Result<DecodedValue, scale_decode::Error> {
let val = DecodedValue::decode_as_type(
&mut &*self.scale_bytes,
self.type_id,
self.metadata.types(),
)?;
Ok(val)
}
/// decode the `DecodedValueThunk` into a concrete type.
pub fn as_type<T: DecodeAsType>(&self) -> Result<T, scale_decode::Error> {
T::decode_as_type(
&mut &self.scale_bytes[..],
self.type_id,
self.metadata.types(),
)
}
}
+2
View File
@@ -21,5 +21,7 @@ pub use config::{
PolkadotExtrinsicParams, SubstrateConfig, SubstrateExtrinsicParams,
};
pub use metadata::Metadata;
#[macro_use]
mod macros;
+4 -1
View File
@@ -22,7 +22,7 @@ impl core::ops::Deref for Metadata {
}
impl Metadata {
pub(crate) fn new(md: subxt_metadata::Metadata) -> Self {
pub fn new(md: subxt_metadata::Metadata) -> Self {
Metadata {
inner: Arc::new(md),
}
@@ -125,3 +125,6 @@ pub enum MetadataError {
#[display(fmt = "Custom value with name {_0} not found")]
CustomValueNameNotFound(String),
}
#[cfg(feature = "std")]
impl std::error::Error for MetadataError {}
+1 -1
View File
@@ -8,7 +8,7 @@ mod decode_encode_traits;
mod metadata_type;
pub use decode_encode_traits::{DecodeWithMetadata, EncodeWithMetadata};
pub use metadata_type::Metadata;
pub use metadata_type::{Metadata, MetadataError};
// Expose metadata types under a sub module in case somebody needs to reference them:
pub use subxt_metadata as types;
+2 -2
View File
@@ -5,12 +5,12 @@
//! An interface to call the raw legacy RPC methods.
use crate::backend::rpc::{rpc_params, RpcClient, RpcSubscription};
use crate::metadata::Metadata;
use crate::{Config, Error};
use codec::Decode;
use derivative::Derivative;
use primitive_types::U256;
use serde::{Deserialize, Serialize};
use subxt_core::metadata::Metadata;
/// An interface to call the legacy RPC methods. This interface is instantiated with
/// some `T: Config` trait which determines some of the types that the RPC methods will
@@ -530,7 +530,7 @@ impl DryRunResultBytes {
/// Attempt to decode the error bytes into a [`DryRunResult`] using the provided [`Metadata`].
pub fn into_dry_run_result(
self,
metadata: &crate::metadata::Metadata,
metadata: &subxt_core::metadata::Metadata,
) -> Result<DryRunResult, crate::Error> {
// dryRun returns an ApplyExtrinsicResult, which is basically a
// `Result<Result<(), DispatchError>, TransactionValidityError>`.
+1 -1
View File
@@ -11,13 +11,13 @@ pub mod rpc;
pub mod unstable;
use crate::error::Error;
use crate::metadata::Metadata;
use crate::Config;
use async_trait::async_trait;
use codec::{Decode, Encode};
use futures::{Stream, StreamExt};
use std::pin::Pin;
use std::sync::Arc;
use subxt_core::metadata::Metadata;
/// Prevent the backend trait being implemented externally.
#[doc(hidden)]
+3 -3
View File
@@ -7,11 +7,11 @@ use crate::{
client::{OfflineClientT, OnlineClientT},
config::{Config, Hasher},
error::{BlockError, Error, MetadataError},
events,
metadata::types::PalletMetadata,
Metadata,
events, Metadata,
};
use subxt_core::metadata::types::PalletMetadata;
use crate::config::signed_extensions::{
ChargeAssetTxPayment, ChargeTransactionPayment, CheckNonce,
};
+3 -3
View File
@@ -117,8 +117,8 @@ impl<T: Config> LightClient<T> {
// think about importing the OnlineClientT/OfflineClientT
// traits to use these things:
/// Return the [`crate::Metadata`] used in this client.
fn metadata(&self) -> crate::Metadata {
/// Return the [`subxt_core::metadata`] used in this client.
fn metadata(&self) -> subxt_core::metadata {
self.client.metadata()
}
@@ -180,7 +180,7 @@ impl<T: Config> OnlineClientT<T> for LightClient<T> {
}
impl<T: Config> OfflineClientT<T> for LightClient<T> {
fn metadata(&self) -> crate::Metadata {
fn metadata(&self) -> subxt_core::metadata {
self.metadata()
}
+2 -1
View File
@@ -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 crate::dynamic::DecodedValueThunk;
use derivative::Derivative;
use std::borrow::Cow;
use subxt_core::metadata::DecodeWithMetadata;
/// This represents a constant address. Anything implementing this trait
/// can be used to fetch constants.
+2 -1
View File
@@ -6,10 +6,11 @@ use super::ConstantAddress;
use crate::{
client::OfflineClientT,
error::{Error, MetadataError},
metadata::DecodeWithMetadata,
Config,
};
use derivative::Derivative;
use subxt_core::metadata::DecodeWithMetadata;
/// A client for accessing constants.
#[derive(Derivative)]
@@ -2,7 +2,7 @@ use derivative::Derivative;
use std::marker::PhantomData;
use crate::dynamic::DecodedValueThunk;
use crate::metadata::DecodeWithMetadata;
use subxt_core::metadata::DecodeWithMetadata;
/// This represents the address of a custom value in in the metadata.
/// Anything, that implements the [CustomValueAddress] trait can be used, to fetch
@@ -1,9 +1,9 @@
use crate::client::OfflineClientT;
use crate::custom_values::custom_value_address::{CustomValueAddress, Yes};
use crate::error::MetadataError;
use crate::metadata::DecodeWithMetadata;
use crate::{Config, Error};
use derivative::Derivative;
use subxt_core::metadata::DecodeWithMetadata;
/// A client for accessing custom values stored in the metadata.
#[derive(Derivative)]
+4 -59
View File
@@ -5,17 +5,16 @@
//! This module provides the entry points to create dynamic
//! transactions, storage and constant lookups.
use crate::{
error::Error,
metadata::{DecodeWithMetadata, Metadata},
};
use crate::error::Error;
use scale_decode::DecodeAsType;
use subxt_core::metadata::{DecodeWithMetadata, Metadata};
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
/// [`crate::metadata::DecodeWithMetadata`], and is used as a return type
/// [`subxt_core::metadata::DecodeWithMetadata`], and is used as a return type
/// for dynamic requests.
pub type DecodedValue = scale_value::Value<scale_value::scale::TypeId>;
@@ -30,57 +29,3 @@ pub use crate::storage::dynamic as storage;
// Execute runtime API function call dynamically.
pub use crate::runtime_api::dynamic as runtime_api_call;
/// 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
/// complete the decoding of the bytes into a [`DecodedValue`] type.
pub struct DecodedValueThunk {
type_id: u32,
metadata: Metadata,
scale_bytes: Vec<u8>,
}
impl DecodeWithMetadata for DecodedValueThunk {
fn decode_with_metadata(
bytes: &mut &[u8],
type_id: u32,
metadata: &Metadata,
) -> Result<Self, Error> {
let mut v = Vec::with_capacity(bytes.len());
v.extend_from_slice(bytes);
*bytes = &[];
Ok(DecodedValueThunk {
type_id,
metadata: metadata.clone(),
scale_bytes: v,
})
}
}
impl DecodedValueThunk {
/// Return the SCALE encoded bytes handed back from the node.
pub fn into_encoded(self) -> Vec<u8> {
self.scale_bytes
}
/// Return the SCALE encoded bytes handed back from the node without taking ownership of them.
pub fn encoded(&self) -> &[u8] {
&self.scale_bytes
}
/// Decode the SCALE encoded storage entry into a dynamic [`DecodedValue`] type.
pub fn to_value(&self) -> Result<DecodedValue, Error> {
let val = DecodedValue::decode_as_type(
&mut &*self.scale_bytes,
self.type_id,
self.metadata.types(),
)?;
Ok(val)
}
/// decode the `DecodedValueThunk` into a concrete type.
pub fn as_type<T: DecodeAsType>(&self) -> Result<T, scale_decode::Error> {
T::decode_as_type(
&mut &self.scale_bytes[..],
self.type_id,
self.metadata.types(),
)
}
}
+2 -2
View File
@@ -5,10 +5,10 @@
//! 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, DecodeAsType};
use std::borrow::Cow;
use subxt_core::metadata::{DecodeWithMetadata, Metadata};
use super::{Error, MetadataError};
@@ -214,7 +214,7 @@ impl ModuleError {
/// Details about the module error.
pub struct ModuleErrorDetails<'a> {
/// The pallet that the error is in
pub pallet: crate::metadata::types::PalletMetadata<'a>,
pub pallet: subxt_core::metadata::types::PalletMetadata<'a>,
/// The variant representing the error
pub variant: &'a scale_info::Variant<scale_info::form::PortableForm>,
}
+3 -52
View File
@@ -17,11 +17,13 @@ pub use dispatch_error::{
ArithmeticError, DispatchError, ModuleError, TokenError, TransactionalError,
};
pub use subxt_core::metadata::MetadataError;
// Re-expose the errors we use from other crates here:
pub use crate::config::ExtrinsicParamsError;
pub use crate::metadata::Metadata;
pub use scale_decode::Error as DecodeError;
pub use scale_encode::Error as EncodeError;
pub use subxt_core::metadata::Metadata;
pub use subxt_metadata::TryFromError as MetadataTryFromError;
/// The underlying error enum, generic over the type held by the `Runtime`
@@ -199,54 +201,3 @@ pub enum StorageAddressError {
fields: usize,
},
}
/// Something went wrong trying to access details in the metadata.
#[derive(Clone, Debug, PartialEq, thiserror::Error)]
#[non_exhaustive]
pub enum MetadataError {
/// The DispatchError type isn't available in the metadata
#[error("The DispatchError type isn't available")]
DispatchErrorNotFound,
/// Type not found in metadata.
#[error("Type with ID {0} not found")]
TypeNotFound(u32),
/// Pallet not found (index).
#[error("Pallet with index {0} not found")]
PalletIndexNotFound(u8),
/// Pallet not found (name).
#[error("Pallet with name {0} not found")]
PalletNameNotFound(String),
/// Variant not found.
#[error("Variant with index {0} not found")]
VariantIndexNotFound(u8),
/// Constant not found.
#[error("Constant with name {0} not found")]
ConstantNameNotFound(String),
/// Call not found.
#[error("Call with name {0} not found")]
CallNameNotFound(String),
/// Runtime trait not found.
#[error("Runtime trait with name {0} not found")]
RuntimeTraitNotFound(String),
/// Runtime method not found.
#[error("Runtime method with name {0} not found")]
RuntimeMethodNotFound(String),
/// Call type not found in metadata.
#[error("Call type not found in pallet with index {0}")]
CallTypeNotFoundInPallet(u8),
/// Event type not found in metadata.
#[error("Event type not found in pallet with index {0}")]
EventTypeNotFoundInPallet(u8),
/// Storage details not found in metadata.
#[error("Storage details not found in pallet with name {0}")]
StorageNotFoundInPallet(String),
/// Storage entry not found.
#[error("Storage entry {0} not found")]
StorageEntryNotFound(String),
/// The generated interface used is not compatible with the node.
#[error("The generated code is not compatible with the node")]
IncompatibleCodegen,
/// Custom value not found.
#[error("Custom value with name {0} not found")]
CustomValueNameNotFound(String),
}
+1 -1
View File
@@ -9,13 +9,13 @@ use crate::{
client::OnlineClientT,
error::{Error, MetadataError},
events::events_client::get_event_bytes,
metadata::types::PalletMetadata,
Config, Metadata,
};
use codec::{Compact, Decode};
use derivative::Derivative;
use scale_decode::DecodeAsType;
use std::sync::Arc;
use subxt_core::metadata::types::PalletMetadata;
/// A collection of events obtained from a block, bundled with the necessary
/// information needed to decode and iterate over them.
+2 -2
View File
@@ -51,7 +51,6 @@ pub mod custom_values;
pub mod dynamic;
pub mod error;
pub mod events;
pub mod metadata;
pub mod runtime_api;
pub mod storage;
pub mod tx;
@@ -67,9 +66,10 @@ pub use crate::{
client::{OfflineClient, OnlineClient},
config::{Config, PolkadotConfig, SubstrateConfig},
error::Error,
metadata::Metadata,
};
use subxt_core::metadata::Metadata;
/// Re-export external crates that are made use of in the subxt API.
pub mod ext {
pub use codec;
@@ -1,51 +0,0 @@
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::Metadata;
use crate::error::Error;
/// This trait is implemented for all types that also implement [`scale_decode::DecodeAsType`].
pub trait DecodeWithMetadata: Sized {
/// Given some metadata and a type ID, attempt to SCALE decode the provided bytes into `Self`.
fn decode_with_metadata(
bytes: &mut &[u8],
type_id: u32,
metadata: &Metadata,
) -> Result<Self, Error>;
}
impl<T: scale_decode::DecodeAsType> DecodeWithMetadata for T {
fn decode_with_metadata(
bytes: &mut &[u8],
type_id: u32,
metadata: &Metadata,
) -> Result<T, Error> {
let val = T::decode_as_type(bytes, type_id, metadata.types())?;
Ok(val)
}
}
/// This trait is implemented for all types that also implement [`scale_encode::EncodeAsType`].
pub trait EncodeWithMetadata {
/// SCALE encode this type to bytes, possibly with the help of metadata.
fn encode_with_metadata(
&self,
type_id: u32,
metadata: &Metadata,
bytes: &mut Vec<u8>,
) -> Result<(), Error>;
}
impl<T: scale_encode::EncodeAsType> EncodeWithMetadata for T {
/// SCALE encode this type to bytes, possibly with the help of metadata.
fn encode_with_metadata(
&self,
type_id: u32,
metadata: &Metadata,
bytes: &mut Vec<u8>,
) -> Result<(), Error> {
self.encode_as_type_to(type_id, metadata.types(), bytes)?;
Ok(())
}
}
-74
View File
@@ -1,74 +0,0 @@
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::error::MetadataError;
use std::sync::Arc;
/// A cheaply clone-able representation of the runtime metadata received from a node.
#[derive(Clone, Debug)]
pub struct Metadata {
inner: Arc<subxt_metadata::Metadata>,
}
impl std::ops::Deref for Metadata {
type Target = subxt_metadata::Metadata;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl Metadata {
pub(crate) fn new(md: subxt_metadata::Metadata) -> Self {
Metadata {
inner: Arc::new(md),
}
}
/// Identical to `metadata.pallet_by_name()`, but returns an error if the pallet is not found.
pub fn pallet_by_name_err(
&self,
name: &str,
) -> Result<subxt_metadata::PalletMetadata, MetadataError> {
self.pallet_by_name(name)
.ok_or_else(|| MetadataError::PalletNameNotFound(name.to_owned()))
}
/// Identical to `metadata.pallet_by_index()`, but returns an error if the pallet is not found.
pub fn pallet_by_index_err(
&self,
index: u8,
) -> Result<subxt_metadata::PalletMetadata, MetadataError> {
self.pallet_by_index(index)
.ok_or(MetadataError::PalletIndexNotFound(index))
}
/// Identical to `metadata.runtime_api_trait_by_name()`, but returns an error if the trait is not found.
pub fn runtime_api_trait_by_name_err(
&self,
name: &str,
) -> Result<subxt_metadata::RuntimeApiMetadata, MetadataError> {
self.runtime_api_trait_by_name(name)
.ok_or_else(|| MetadataError::RuntimeTraitNotFound(name.to_owned()))
}
}
impl From<subxt_metadata::Metadata> for Metadata {
fn from(md: subxt_metadata::Metadata) -> Self {
Metadata::new(md)
}
}
impl TryFrom<frame_metadata::RuntimeMetadataPrefixed> for Metadata {
type Error = subxt_metadata::TryFromError;
fn try_from(value: frame_metadata::RuntimeMetadataPrefixed) -> Result<Self, Self::Error> {
subxt_metadata::Metadata::try_from(value).map(Metadata::from)
}
}
impl codec::Decode for Metadata {
fn decode<I: codec::Input>(input: &mut I) -> Result<Self, codec::Error> {
subxt_metadata::Metadata::decode(input).map(Metadata::new)
}
}
-14
View File
@@ -1,14 +0,0 @@
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
//! Types representing the metadata obtained from a node.
mod decode_encode_traits;
mod metadata_type;
pub use decode_encode_traits::{DecodeWithMetadata, EncodeWithMetadata};
pub use metadata_type::Metadata;
// Expose metadata types under a sub module in case somebody needs to reference them:
pub use subxt_metadata as types;
+3 -1
View File
@@ -10,7 +10,9 @@ use std::borrow::Cow;
use crate::dynamic::DecodedValueThunk;
use crate::error::MetadataError;
use crate::{metadata::DecodeWithMetadata, Error, Metadata};
use crate::Error;
use subxt_core::metadata::{DecodeWithMetadata, Metadata};
/// This represents a runtime API payload that can call into the runtime of node.
///
+1 -1
View File
@@ -6,12 +6,12 @@ use crate::{
backend::{BackendExt, BlockRef},
client::OnlineClientT,
error::{Error, MetadataError},
metadata::DecodeWithMetadata,
Config,
};
use codec::Decode;
use derivative::Derivative;
use std::{future::Future, marker::PhantomData};
use subxt_core::metadata::DecodeWithMetadata;
use super::RuntimeApiPayload;
+3 -1
View File
@@ -5,9 +5,11 @@
use crate::{
dynamic::DecodedValueThunk,
error::{Error, MetadataError, StorageAddressError},
metadata::{DecodeWithMetadata, EncodeWithMetadata, Metadata},
utils::{Encoded, Static},
};
use subxt_core::metadata::{DecodeWithMetadata, EncodeWithMetadata, Metadata};
use derivative::Derivative;
use scale_info::TypeDef;
use std::borrow::Cow;
+1 -1
View File
@@ -8,13 +8,13 @@ use crate::{
backend::{BackendExt, BlockRef},
client::OnlineClientT,
error::{Error, MetadataError},
metadata::{DecodeWithMetadata, Metadata},
Config,
};
use codec::Decode;
use derivative::Derivative;
use futures::StreamExt;
use std::{future::Future, marker::PhantomData};
use subxt_core::metadata::{DecodeWithMetadata, Metadata};
use subxt_metadata::{PalletMetadata, StorageEntryMetadata, StorageEntryType};
/// This is returned from a couple of storage functions.
+3 -1
View File
@@ -7,7 +7,9 @@
//! the trait itself.
use super::StorageAddress;
use crate::{error::Error, metadata::Metadata};
use crate::error::Error;
use subxt_core::metadata::Metadata;
/// Return the root of a given [`StorageAddress`]: hash the pallet name and entry name
/// and append those bytes to the output.
+1 -1
View File
@@ -8,12 +8,12 @@
use crate::{
dynamic::Value,
error::{Error, MetadataError},
metadata::Metadata,
};
use codec::Encode;
use scale_encode::EncodeAsFields;
use scale_value::{Composite, ValueDef, Variant};
use std::{borrow::Cow, sync::Arc};
use subxt_core::metadata::Metadata;
/// This represents a transaction payload that can be submitted
/// to a node.
+1 -1
View File
@@ -337,7 +337,7 @@ mod test {
struct MockClient;
impl OfflineClientT<SubstrateConfig> for MockClient {
fn metadata(&self) -> crate::Metadata {
fn metadata(&self) -> subxt_core::metadata {
unimplemented!("just a mock impl to satisfy trait bounds")
}
+1 -1
View File
@@ -49,5 +49,5 @@ fn subxt_metadata_test() {
}
fn subxt_core_test() {
let era = subxt_core::utils::era::Era::Immortal;
let era = subxt_core::utils::Era::Immortal;
}