Rename traits to remove T suffix (#1535)

* Rename traits to renmove T suffix

* Fix doc links

* Fix straggler doc links
This commit is contained in:
James Wilson
2024-04-16 16:35:14 +01:00
committed by GitHub
parent 1e111ea9db
commit ac606cf625
32 changed files with 2426 additions and 2229 deletions
+1 -1
View File
@@ -10,5 +10,5 @@ mod storage_type;
pub use storage_client::StorageClient;
pub use storage_type::{Storage, StorageKeyValuePair};
pub use subxt_core::storage::address::{
dynamic, Address, AddressT, DynamicAddress, StaticStorageKey, StorageKey,
dynamic, Address, DefaultAddress, DynamicAddress, StaticAddress, StaticStorageKey, StorageKey,
};
+5 -5
View File
@@ -11,7 +11,7 @@ use crate::{
};
use derive_where::derive_where;
use std::{future::Future, marker::PhantomData};
use subxt_core::storage::address::AddressT;
use subxt_core::storage::address::Address;
/// Query the runtime storage.
#[derive_where(Clone; Client)]
@@ -39,22 +39,22 @@ where
/// if the address is valid (or if it's not possible to check since the address has no validation hash).
/// Return an error if the address was not valid or something went wrong trying to validate it (ie
/// the pallet or storage entry in question do not exist at all).
pub fn validate<Address: AddressT>(&self, address: &Address) -> Result<(), Error> {
pub fn validate<Addr: Address>(&self, address: &Addr) -> Result<(), Error> {
subxt_core::storage::validate(address, &self.client.metadata()).map_err(Into::into)
}
/// Convert some storage address into the raw bytes that would be submitted to the node in order
/// to retrieve the entries at the root of the associated address.
pub fn address_root_bytes<Address: AddressT>(&self, address: &Address) -> Vec<u8> {
pub fn address_root_bytes<Addr: Address>(&self, address: &Addr) -> Vec<u8> {
subxt_core::storage::get_address_root_bytes(address)
}
/// Convert some storage address into the raw bytes that would be submitted to the node in order
/// to retrieve an entry. This fails if [`AddressT::append_entry_bytes`] does; in the built-in
/// to retrieve an entry. This fails if [`Address::append_entry_bytes`] does; in the built-in
/// implementation this would be if the pallet and storage entry being asked for is not available on the
/// node you're communicating with, or if the metadata is missing some type information (which should not
/// happen).
pub fn address_bytes<Address: AddressT>(&self, address: &Address) -> Result<Vec<u8>, Error> {
pub fn address_bytes<Addr: Address>(&self, address: &Addr) -> Result<Vec<u8>, Error> {
subxt_core::storage::get_address_bytes(address, &self.client.metadata()).map_err(Into::into)
}
}
+18 -18
View File
@@ -13,7 +13,7 @@ use codec::Decode;
use derive_where::derive_where;
use futures::StreamExt;
use std::{future::Future, marker::PhantomData};
use subxt_core::storage::address::{AddressT, StorageHashers, StorageKey};
use subxt_core::storage::address::{Address, StorageHashers, StorageKey};
use subxt_core::utils::Yes;
/// This is returned from a couple of storage functions.
@@ -110,12 +110,12 @@ where
/// println!("Value: {:?}", value);
/// # }
/// ```
pub fn fetch<'address, Address>(
pub fn fetch<'address, Addr>(
&self,
address: &'address Address,
) -> impl Future<Output = Result<Option<Address::Target>, Error>> + 'address
address: &'address Addr,
) -> impl Future<Output = Result<Option<Addr::Target>, Error>> + 'address
where
Address: AddressT<IsFetchable = Yes> + 'address,
Addr: Address<IsFetchable = Yes> + 'address,
{
let client = self.clone();
async move {
@@ -139,12 +139,12 @@ where
}
/// Fetch a StorageKey that has a default value with an optional block hash.
pub fn fetch_or_default<'address, Address>(
pub fn fetch_or_default<'address, Addr>(
&self,
address: &'address Address,
) -> impl Future<Output = Result<Address::Target, Error>> + 'address
address: &'address Addr,
) -> impl Future<Output = Result<Addr::Target, Error>> + 'address
where
Address: AddressT<IsFetchable = Yes, IsDefaultable = Yes> + 'address,
Addr: Address<IsFetchable = Yes, IsDefaultable = Yes> + 'address,
{
let client = self.clone();
async move {
@@ -190,13 +190,13 @@ where
/// }
/// # }
/// ```
pub fn iter<Address>(
pub fn iter<Addr>(
&self,
address: Address,
) -> impl Future<Output = Result<StreamOfResults<StorageKeyValuePair<Address>>, Error>> + 'static
address: Addr,
) -> impl Future<Output = Result<StreamOfResults<StorageKeyValuePair<Addr>>, Error>> + 'static
where
Address: AddressT<IsIterable = Yes> + 'static,
Address::Keys: 'static + Sized,
Addr: Address<IsIterable = Yes> + 'static,
Addr::Keys: 'static + Sized,
{
let client = self.client.clone();
let block_ref = self.block_ref.clone();
@@ -233,7 +233,7 @@ where
Ok(kv) => kv,
Err(e) => return Err(e),
};
let value = Address::Target::decode_with_metadata(
let value = Addr::Target::decode_with_metadata(
&mut &*kv.value,
return_type_id,
&metadata,
@@ -243,13 +243,13 @@ where
let cursor = &mut &key_bytes[..];
strip_storage_address_root_bytes(cursor)?;
let keys = <Address::Keys as StorageKey>::decode_storage_key(
let keys = <Addr::Keys as StorageKey>::decode_storage_key(
cursor,
&mut hashers.iter(),
metadata.types(),
)?;
Ok(StorageKeyValuePair::<Address> {
Ok(StorageKeyValuePair::<Addr> {
keys,
key_bytes,
value,
@@ -313,7 +313,7 @@ fn strip_storage_address_root_bytes(address_bytes: &mut &[u8]) -> Result<(), Sto
/// A pair of keys and values together with all the bytes that make up the storage address.
/// `keys` is `None` if non-concat hashers are used. In this case the keys could not be extracted back from the key_bytes.
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub struct StorageKeyValuePair<T: AddressT> {
pub struct StorageKeyValuePair<T: Address> {
/// The bytes that make up the address of the storage entry.
pub key_bytes: Vec<u8>,
/// The keys that can be used to construct the address of this storage entry.