Small fixes in subxt-core and remove metadata mod

This commit is contained in:
James Wilson
2025-10-02 15:06:07 +01:00
parent 8257e28c57
commit ee2bf5f3d9
11 changed files with 16 additions and 20 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
use crate::{
config::{Config, HashFor},
metadata::Metadata,
Metadata,
};
use derive_where::derive_where;
+1 -1
View File
@@ -85,7 +85,7 @@ impl<Target: DecodeAsType, IsDecodable: NoMaybe> Address for StaticAddress<Targe
}
// Support plain strings for looking up custom values (but prefer `dynamic` if you want to pick the return type)
impl Address for &str {
impl Address for str {
type Target = scale_value::Value;
type IsDecodable = Maybe;
+5 -4
View File
@@ -32,7 +32,7 @@
pub mod address;
use crate::utils::Yes;
use crate::utils::Maybe;
use crate::{Metadata, error::CustomValueError};
use address::Address;
use alloc::vec::Vec;
@@ -58,7 +58,7 @@ pub fn validate<Addr: Address + ?Sized>(address: &Addr, metadata: &Metadata) ->
/// Access a custom value by the address it is registered under. This can be just a [str] to get back a dynamic value,
/// or a static address from the generated static interface to get a value of a static type returned.
pub fn get<Addr: Address<IsDecodable = Yes> + ?Sized>(
pub fn get<Addr: Address<IsDecodable = Maybe> + ?Sized>(
address: &Addr,
metadata: &Metadata,
) -> Result<Addr::Target, CustomValueError> {
@@ -163,8 +163,9 @@ mod tests {
let metadata = mock_metadata();
assert!(custom_values::get("Invalid Address", &metadata).is_err());
let person_decoded_value_thunk = custom_values::get("Mr. Robot", &metadata).unwrap();
let person: Person = person_decoded_value_thunk.as_type().unwrap();
let person_addr = custom_values::address::dynamic::<Person>("Mr. Robot");
let person = custom_values::get(&person_addr, &metadata).unwrap();
assert_eq!(
person,
Person {
+1 -1
View File
@@ -653,7 +653,7 @@ mod tests {
expected: TestRawEventDetails,
) {
let actual_fields_no_context: Vec<_> = actual
.field_values()
.decode_fields_as::<scale_value::Composite<()>>()
.expect("can decode field values (2)")
.into_values()
.map(|value| value.remove_context())
+1 -6
View File
@@ -39,7 +39,7 @@ pub mod view_functions;
pub use config::Config;
pub use error::Error;
pub use metadata::Metadata;
pub use subxt_metadata::Metadata;
/// Re-exports of some of the key external crates.
pub mod ext {
@@ -48,8 +48,3 @@ pub mod ext {
pub use scale_encode;
pub use scale_value;
}
/// Re-exports the [`subxt_metadata::Metadata`] type.
pub mod metadata {
pub use subxt_metadata::Metadata;
}
+1 -1
View File
@@ -44,7 +44,7 @@
pub mod payload;
use crate::error::RuntimeApiError;
use crate::metadata::Metadata;
use crate::Metadata;
use alloc::format;
use alloc::string::String;
use alloc::vec::Vec;
+1 -1
View File
@@ -61,7 +61,7 @@ pub mod signer;
use crate::config::{Config, ExtrinsicParams, ExtrinsicParamsEncoder, HashFor, Hasher};
use crate::error::ExtrinsicError;
use crate::metadata::Metadata;
use crate::Metadata;
use crate::utils::Encoded;
use alloc::borrow::Cow;
use alloc::vec::Vec;
+2 -2
View File
@@ -6,7 +6,7 @@
//! transactions that can be submitted.
use crate::error::ExtrinsicError;
use crate::metadata::Metadata;
use crate::Metadata;
use alloc::borrow::Cow;
use alloc::boxed::Box;
use alloc::string::String;
@@ -212,7 +212,7 @@ pub fn dynamic(
#[cfg(test)]
mod tests {
use super::*;
use crate::metadata::Metadata;
use crate::Metadata;
use codec::Decode;
use scale_value::Composite;
+1 -1
View File
@@ -8,7 +8,7 @@
pub mod payload;
use crate::error::ViewFunctionError;
use crate::metadata::Metadata;
use crate::Metadata;
use alloc::vec::Vec;
use payload::Payload;
use scale_decode::IntoVisitor;
+1 -1
View File
@@ -12,7 +12,7 @@ pub mod utils;
use crate::config::{Config, HashFor};
use crate::error::Error;
use crate::metadata::Metadata;
use crate::Metadata;
use async_trait::async_trait;
use codec::{Decode, Encode};
use futures::{Stream, StreamExt};
+1 -1
View File
@@ -18,7 +18,7 @@ pub use dispatch_error::{
};
// Re-expose the errors we use from other crates here:
pub use crate::metadata::Metadata;
pub use crate::Metadata;
pub use scale_decode::Error as DecodeError;
pub use scale_encode::Error as EncodeError;
pub use subxt_core::error::{ExtrinsicError, MetadataError, StorageError};