#![doc = include_str ! ("../examples/config_assethub.rs")]
#![doc = include_str ! ("../examples/config_eth.rs")]
mod default_transaction_extensions;
mod transaction_extension_traits;
pub mod polkadot;
pub mod substrate;
pub mod transaction_extensions;
use crate::metadata::{ArcMetadata, Metadata};
use codec::{Decode, Encode};
use core::fmt::Debug;
use scale_decode::DecodeAsType;
use scale_encode::EncodeAsType;
use scale_info_legacy::TypeRegistrySet;
use serde::{Serialize, de::DeserializeOwned};
use std::{fmt::Display, marker::PhantomData};
use subxt_rpcs::RpcConfig;
pub use default_transaction_extensions::{
DefaultExtrinsicParamsBuilder, DefaultTransactionExtensions,
};
pub use polkadot::{PolkadotConfig, PolkadotExtrinsicParams, PolkadotExtrinsicParamsBuilder};
pub use substrate::{SubstrateConfig, SubstrateExtrinsicParams, SubstrateExtrinsicParamsBuilder};
pub use transaction_extension_traits::{ClientState, TransactionExtension, TransactionExtensions};
pub trait Config: Clone + Debug + Sized + Send + Sync + 'static {
type AccountId: Debug + Clone + Encode + EncodeAsType + DecodeAsType + Serialize + Send;
type Address: Debug + EncodeAsType + From<Self::AccountId>;
type Signature: Debug + Clone + EncodeAsType + DecodeAsType + Send;
type Header: Header;
type TransactionExtensions: TransactionExtensions<Self>;
type AssetId: AssetId;
type Hasher: Hasher;
fn genesis_hash(&self) -> Option<HashFor<Self>> {
None
}
fn spec_and_transaction_version_for_block_number(
&self,
_block_number: u64,
) -> Option<(u32, u32)> {
None
}
fn metadata_for_spec_version(&self, _spec_version: u32) -> Option<ArcMetadata> {
None
}
fn set_metadata_for_spec_version(&self, _spec_version: u32, _metadata: ArcMetadata) {}
fn legacy_types_for_spec_version<'this>(
&'this self,
_spec_version: u32,
) -> Option<TypeRegistrySet<'this>> {
None
}
}
pub struct RpcConfigFor<T> {
marker: PhantomData<T>,
}
impl<T: Config> RpcConfig for RpcConfigFor<T> {
type Hash = HashFor<T>;
type Header = T::Header;
type AccountId = T::AccountId;
}
pub type HashFor<T> = <<T as Config>::Hasher as Hasher>::Hash;
pub type ParamsFor<T> = <<T as Config>::TransactionExtensions as TransactionExtensions<T>>::Params;
pub trait AssetId: Debug + Clone + Encode + DecodeAsType + EncodeAsType + Send {}
impl<T> AssetId for T where T: Debug + Clone + Encode + DecodeAsType + EncodeAsType + Send {}
pub trait Hash:
Debug
+ Display
+ Copy
+ Send
+ Sync
+ Decode
+ AsRef<[u8]>
+ Serialize
+ DeserializeOwned
+ Encode
+ PartialEq
+ Eq
+ core::hash::Hash
{
}
impl<T> Hash for T where
T: Debug
+ Display
+ Copy
+ Send
+ Sync
+ Decode
+ AsRef<[u8]>
+ Serialize
+ DeserializeOwned
+ Encode
+ PartialEq
+ Eq
+ core::hash::Hash
{
}
pub trait Hasher: Debug + Clone + Send + Sync + 'static {
type Hash: Hash;
fn new(metadata: &Metadata) -> Self;
fn hash(&self, s: &[u8]) -> Self::Hash;
}
pub trait Header: Sized + Encode + Decode + Debug + Sync + Send + DeserializeOwned + Clone {
fn number(&self) -> u64;
}