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
@@ -40,7 +40,7 @@
//! );
//! ```
//!
//! All valid runtime calls implement [`crate::runtime_api::PayloadT`], a trait which
//! All valid runtime calls implement [`crate::runtime_api::Payload`], a trait which
//! describes how to encode the runtime call arguments and what return type to decode from the
//! response.
//!
+2 -2
View File
@@ -66,7 +66,7 @@
//! - `runtime::storage().foo().bar_iter3(u8, bool, u16)`: iterate over all of the entries in the "bar" map under
//! a given `u8`, `bool` and `u16` value.
//!
//! All valid storage queries implement [`crate::storage::AddressT`]. As well as describing
//! All valid storage queries implement [`crate::storage::Address`]. As well as describing
//! how to build a valid storage query, this trait also has some associated types that determine the
//! shape of the result you'll get back, and determine what you can do with it (ie, can you iterate
//! over storage entries using it).
@@ -124,7 +124,7 @@
//!
//! For more advanced use cases, have a look at [`crate::storage::Storage::fetch_raw`] and
//! [`crate::storage::Storage::fetch_raw_keys`]. Both of these take raw bytes as arguments, which can be
//! obtained from a [`crate::storage::AddressT`] by using
//! obtained from a [`crate::storage::Address`] by using
//! [`crate::storage::StorageClient::address_bytes()`] or
//! [`crate::storage::StorageClient::address_root_bytes()`].
//!
+1 -1
View File
@@ -53,7 +53,7 @@
//! represents any type of data that can be SCALE encoded or decoded. It can be serialized,
//! deserialized and parsed from/to strings.
//!
//! A valid transaction payload is just something that implements the [`crate::tx::PayloadT`] trait;
//! A valid transaction payload is just something that implements the [`crate::tx::Payload`] trait;
//! you can implement this trait on your own custom types if the built-in ones are not suitable for
//! your needs.
//!
+3 -3
View File
@@ -4,7 +4,7 @@
use crate::{client::OfflineClientT, error::Error, Config};
use derive_where::derive_where;
use subxt_core::constants::address::AddressT;
use subxt_core::constants::address::Address;
/// A client for accessing constants.
#[derive_where(Clone; Client)]
@@ -28,7 +28,7 @@ impl<T: Config, Client: OfflineClientT<T>> ConstantsClient<T, Client> {
/// 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 constant 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> {
let metadata = self.client.metadata();
subxt_core::constants::validate(address, &metadata).map_err(Error::from)
}
@@ -36,7 +36,7 @@ impl<T: Config, Client: OfflineClientT<T>> ConstantsClient<T, Client> {
/// Access the constant at the address given, returning the type defined by this address.
/// This is probably used with addresses given from static codegen, although you can manually
/// construct your own, too.
pub fn at<Address: AddressT>(&self, address: &Address) -> Result<Address::Target, Error> {
pub fn at<Addr: Address>(&self, address: &Addr) -> Result<Addr::Target, Error> {
let metadata = self.client.metadata();
subxt_core::constants::get(address, &metadata).map_err(Error::from)
}
+3 -1
View File
@@ -7,4 +7,6 @@
mod constants_client;
pub use constants_client::ConstantsClient;
pub use subxt_core::constants::address::{dynamic, Address, AddressT, DynamicAddress};
pub use subxt_core::constants::address::{
dynamic, Address, DefaultAddress, DynamicAddress, StaticAddress,
};
@@ -2,7 +2,7 @@ use crate::client::OfflineClientT;
use crate::{Config, Error};
use derive_where::derive_where;
use subxt_core::custom_values::address::{AddressT, Yes};
use subxt_core::custom_values::address::{Address, Yes};
/// A client for accessing custom values stored in the metadata.
#[derive_where(Clone; Client)]
@@ -24,25 +24,22 @@ impl<T, Client> CustomValuesClient<T, Client> {
impl<T: Config, Client: OfflineClientT<T>> CustomValuesClient<T, Client> {
/// 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 at<Address: AddressT<IsDecodable = Yes> + ?Sized>(
pub fn at<Addr: Address<IsDecodable = Yes> + ?Sized>(
&self,
address: &Address,
) -> Result<Address::Target, Error> {
address: &Addr,
) -> Result<Addr::Target, Error> {
subxt_core::custom_values::get(address, &self.client.metadata()).map_err(Into::into)
}
/// Access the bytes of a custom value by the address it is registered under.
pub fn bytes_at<Address: AddressT + ?Sized>(
&self,
address: &Address,
) -> Result<Vec<u8>, Error> {
pub fn bytes_at<Addr: Address + ?Sized>(&self, address: &Addr) -> Result<Vec<u8>, Error> {
subxt_core::custom_values::get_bytes(address, &self.client.metadata()).map_err(Into::into)
}
/// Run the validation logic against some custom value address you'd like to access. Returns `Ok(())`
/// if the address is valid (or if it's not possible to check since the address has no validation hash).
/// Returns an error if the address was not valid (wrong name, type or raw bytes)
pub fn validate<Address: AddressT + ?Sized>(&self, address: &Address) -> Result<(), Error> {
pub fn validate<Addr: Address + ?Sized>(&self, address: &Addr) -> Result<(), Error> {
subxt_core::custom_values::validate(address, &self.client.metadata()).map_err(Into::into)
}
}
+1 -1
View File
@@ -7,4 +7,4 @@
mod custom_values_client;
pub use custom_values_client::CustomValuesClient;
pub use subxt_core::custom_values::address::{AddressT, StaticAddress, Yes};
pub use subxt_core::custom_values::address::{Address, StaticAddress, Yes};
+3 -1
View File
@@ -9,4 +9,6 @@ mod runtime_types;
pub use runtime_client::RuntimeApiClient;
pub use runtime_types::RuntimeApi;
pub use subxt_core::runtime_api::payload::{dynamic, DynamicPayload, Payload, PayloadT};
pub use subxt_core::runtime_api::payload::{
dynamic, DefaultPayload, DynamicPayload, Payload, StaticPayload,
};
+3 -3
View File
@@ -2,7 +2,7 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::PayloadT;
use super::Payload;
use crate::{
backend::{BackendExt, BlockRef},
client::OnlineClientT,
@@ -41,7 +41,7 @@ where
/// if the payload is valid (or if it's not possible to check since the payload has no validation hash).
/// Return an error if the payload was not valid or something went wrong trying to validate it (ie
/// the runtime API in question do not exist at all)
pub fn validate<Call: PayloadT>(&self, payload: &Call) -> Result<(), Error> {
pub fn validate<Call: Payload>(&self, payload: &Call) -> Result<(), Error> {
subxt_core::runtime_api::validate(payload, &self.client.metadata()).map_err(Into::into)
}
@@ -65,7 +65,7 @@ where
}
/// Execute a runtime API call.
pub fn call<Call: PayloadT>(
pub fn call<Call: Payload>(
&self,
payload: Call,
) -> impl Future<Output = Result<Call::ReturnType, Error>> {
+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.
+1 -1
View File
@@ -20,7 +20,7 @@ cfg_substrate_compat! {
pub use subxt_core::tx::signer::PairSigner;
}
pub use subxt_core::tx::payload::{dynamic, DynamicPayload, Payload, PayloadT};
pub use subxt_core::tx::payload::{dynamic, DefaultPayload, DynamicPayload, Payload};
pub use subxt_core::tx::signer::{self, Signer};
pub use tx_client::{
PartialExtrinsic, SubmittableExtrinsic, TransactionInvalid, TransactionUnknown, TxClient,
+12 -12
View File
@@ -7,7 +7,7 @@ use crate::{
client::{OfflineClientT, OnlineClientT},
config::{Config, ExtrinsicParams, Header, RefineParams, RefineParamsData},
error::{BlockError, Error},
tx::{PayloadT, Signer as SignerT, TxProgress},
tx::{Payload, Signer as SignerT, TxProgress},
utils::PhantomDataSendSync,
};
use codec::{Compact, Decode, Encode};
@@ -37,7 +37,7 @@ impl<T: Config, C: OfflineClientT<T>> TxClient<T, C> {
/// the pallet or call in question do not exist at all).
pub fn validate<Call>(&self, call: &Call) -> Result<(), Error>
where
Call: PayloadT,
Call: Payload,
{
subxt_core::tx::validate(call, &self.client.metadata()).map_err(Into::into)
}
@@ -45,7 +45,7 @@ impl<T: Config, C: OfflineClientT<T>> TxClient<T, C> {
/// Return the SCALE encoded bytes representing the call data of the transaction.
pub fn call_data<Call>(&self, call: &Call) -> Result<Vec<u8>, Error>
where
Call: PayloadT,
Call: Payload,
{
subxt_core::tx::call_data(call, &self.client.metadata()).map_err(Into::into)
}
@@ -53,7 +53,7 @@ impl<T: Config, C: OfflineClientT<T>> TxClient<T, C> {
/// Creates an unsigned extrinsic without submitting it.
pub fn create_unsigned<Call>(&self, call: &Call) -> Result<SubmittableExtrinsic<T, C>, Error>
where
Call: PayloadT,
Call: Payload,
{
subxt_core::tx::create_unsigned(call, &self.client.metadata())
.map(|tx| SubmittableExtrinsic {
@@ -73,7 +73,7 @@ impl<T: Config, C: OfflineClientT<T>> TxClient<T, C> {
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<PartialExtrinsic<T, C>, Error>
where
Call: PayloadT,
Call: Payload,
{
subxt_core::tx::create_partial_signed(call, &self.client.client_state(), params)
.map(|tx| PartialExtrinsic {
@@ -94,7 +94,7 @@ impl<T: Config, C: OfflineClientT<T>> TxClient<T, C> {
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<SubmittableExtrinsic<T, C>, Error>
where
Call: PayloadT,
Call: Payload,
Signer: SignerT<T>,
{
subxt_core::tx::create_signed(call, &self.client.client_state(), signer, params)
@@ -149,7 +149,7 @@ where
mut params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<PartialExtrinsic<T, C>, Error>
where
Call: PayloadT,
Call: Payload,
{
// Refine the params by adding account nonce and latest block information:
self.refine_params(account_id, &mut params).await?;
@@ -165,7 +165,7 @@ where
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<SubmittableExtrinsic<T, C>, Error>
where
Call: PayloadT,
Call: Payload,
Signer: SignerT<T>,
{
// 1. Validate this call against the current node metadata if the call comes
@@ -193,7 +193,7 @@ where
signer: &Signer,
) -> Result<TxProgress<T, C>, Error>
where
Call: PayloadT,
Call: Payload,
Signer: SignerT<T>,
<T::ExtrinsicParams as ExtrinsicParams<T>>::Params: Default,
{
@@ -212,7 +212,7 @@ where
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<TxProgress<T, C>, Error>
where
Call: PayloadT,
Call: Payload,
Signer: SignerT<T>,
{
self.create_signed(call, signer, params)
@@ -237,7 +237,7 @@ where
signer: &Signer,
) -> Result<T::Hash, Error>
where
Call: PayloadT,
Call: Payload,
Signer: SignerT<T>,
<T::ExtrinsicParams as ExtrinsicParams<T>>::Params: Default,
{
@@ -259,7 +259,7 @@ where
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<T::Hash, Error>
where
Call: PayloadT,
Call: Payload,
Signer: SignerT<T>,
{
self.create_signed(call, signer, params)