mod default_extrinsic_params;
mod extrinsic_params;
pub mod polkadot;
pub mod substrate;
pub mod transaction_extensions;
use codec::{Decode, Encode};
use core::fmt::Debug;
use scale_decode::DecodeAsType;
use scale_encode::EncodeAsType;
use serde::{Serialize, de::DeserializeOwned};
use subxt_metadata::Metadata;
pub use default_extrinsic_params::{DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
pub use extrinsic_params::{ExtrinsicParams, ExtrinsicParamsEncoder};
pub use polkadot::{PolkadotConfig, PolkadotExtrinsicParams, PolkadotExtrinsicParamsBuilder};
pub use substrate::{SubstrateConfig, SubstrateExtrinsicParams, SubstrateExtrinsicParamsBuilder};
pub use transaction_extensions::TransactionExtension;
pub trait Config: Sized + Send + Sync + 'static {
type AccountId: Debug + Clone + Encode + Decode + Serialize + Send;
type Address: Debug + Encode + From<Self::AccountId>;
type Signature: Debug + Clone + Encode + Decode + Send;
type Hasher: Debug + Clone + Copy + Hasher + Send + Sync;
type Header: Debug + Header<Hasher = Self::Hasher> + Sync + Send + DeserializeOwned + Clone;
type ExtrinsicParams: ExtrinsicParams<Self>;
type AssetId: Debug + Clone + Encode + DecodeAsType + EncodeAsType + Send;
}
pub type HashFor<T> = <<T as Config>::Hasher as Hasher>::Output;
pub type ParamsFor<T> = <<T as Config>::ExtrinsicParams as ExtrinsicParams<T>>::Params;
pub trait Hash:
Debug
+ Copy
+ Send
+ Sync
+ Decode
+ AsRef<[u8]>
+ Serialize
+ DeserializeOwned
+ Encode
+ PartialEq
+ Eq
+ core::hash::Hash
{
}
impl<T> Hash for T where
T: Debug
+ Copy
+ Send
+ Sync
+ Decode
+ AsRef<[u8]>
+ Serialize
+ DeserializeOwned
+ Encode
+ PartialEq
+ Eq
+ core::hash::Hash
{
}
pub trait Hasher {
type Output: Hash;
fn new(metadata: &Metadata) -> Self;
fn hash(&self, s: &[u8]) -> Self::Output;
fn hash_of<S: Encode>(&self, s: &S) -> Self::Output {
let out = s.encode();
self.hash(&out)
}
}
pub trait Header: Sized + Encode + Decode {
type Number: Into<u64>;
type Hasher: Hasher;
fn number(&self) -> Self::Number;
fn hash_with(&self, hasher: Self::Hasher) -> <Self::Hasher as Hasher>::Output {
hasher.hash_of(self)
}
}