ac_primitives/config/
mod.rsuse codec::{Decode, Encode, FullCodec};
use core::{fmt::Debug, marker::PhantomData};
use serde::{de::DeserializeOwned, Serialize};
use sp_core::Pair;
use sp_runtime::traits::{
AtLeast32Bit, AtLeast32BitUnsigned, Block, Hash as HashTrait, Header as HeaderTrait,
MaybeSerializeDeserialize,
};
use crate::{extrinsic_params, ExtrinsicSigner, SignExtrinsic};
pub use asset_runtime_config::*;
pub use default_runtime_config::*;
pub use rococo_runtime_config::*;
pub mod asset_runtime_config;
pub mod default_runtime_config;
pub mod rococo_runtime_config;
pub trait Config {
type Index: Default + Debug + Copy + DeserializeOwned + AtLeast32Bit + Decode;
type BlockNumber: Debug
+ Copy
+ Encode
+ Default
+ Serialize
+ DeserializeOwned
+ core::hash::Hash
+ core::str::FromStr
+ Into<u64>
+ AtLeast32BitUnsigned;
type Hash: Debug
+ Copy
+ Send
+ Sync
+ Decode
+ Default
+ AsRef<[u8]>
+ Serialize
+ DeserializeOwned
+ Encode
+ PartialEq;
type AccountId: Debug
+ Clone
+ Encode
+ MaybeSerializeDeserialize
+ From<<Self::CryptoKey as Pair>::Public>;
type Address: Debug + Clone + Encode + From<Self::AccountId>; type Signature: Debug + Encode + From<<Self::CryptoKey as Pair>::Signature>;
type Hasher: Debug + HashTrait<Output = Self::Hash>;
type Header: Debug
+ HeaderTrait<Number = Self::BlockNumber, Hashing = Self::Hasher>
+ Send
+ DeserializeOwned;
type AccountData: Debug + Clone + FullCodec;
type ExtrinsicParams: extrinsic_params::ExtrinsicParams<Self::Index, Self::Hash>;
type CryptoKey: Pair;
type ExtrinsicSigner: SignExtrinsic<Self::AccountId>;
type Block: Block + DeserializeOwned;
type Balance: Debug
+ Decode
+ Encode
+ AtLeast32BitUnsigned
+ Default
+ Copy
+ Serialize
+ DeserializeOwned;
type ContractCurrency: Debug
+ Decode
+ Encode
+ AtLeast32BitUnsigned
+ Default
+ Copy
+ Serialize
+ DeserializeOwned;
type StakingBalance: Debug
+ Decode
+ Encode
+ AtLeast32BitUnsigned
+ Default
+ Copy
+ Serialize
+ DeserializeOwned;
}
#[derive(Decode, Encode, Clone, Eq, PartialEq, Debug)]
pub struct WithExtrinsicParams<T: Config, E: extrinsic_params::ExtrinsicParams<T::Index, T::Hash>> {
_marker: PhantomData<(T, E)>,
}
impl<T: Config, E: extrinsic_params::ExtrinsicParams<T::Index, T::Hash>> Config
for WithExtrinsicParams<T, E>
{
type Index = T::Index;
type BlockNumber = T::BlockNumber;
type Hash = T::Hash;
type AccountId = T::AccountId;
type Address = T::Address;
type Signature = T::Signature;
type Hasher = T::Hasher;
type Header = T::Header;
type AccountData = T::AccountData;
type ExtrinsicParams = E;
type CryptoKey = T::CryptoKey;
type ExtrinsicSigner = ExtrinsicSigner<Self>;
type Block = T::Block;
type Balance = T::Balance;
type ContractCurrency = T::ContractCurrency;
type StakingBalance = T::StakingBalance;
}
#[derive(Decode, Encode, Clone, Eq, PartialEq, Debug)]
pub struct WithAddress<T, A>
where
T: Config,
A: Debug + Clone + Encode + From<T::AccountId>,
{
_marker: PhantomData<(T, A)>,
}
impl<T, A> Config for WithAddress<T, A>
where
T: Config,
A: Debug + Clone + Encode + From<T::AccountId>,
{
type Index = T::Index;
type BlockNumber = T::BlockNumber;
type Hash = T::Hash;
type AccountId = T::AccountId;
type Address = A;
type Signature = T::Signature;
type Hasher = T::Hasher;
type Header = T::Header;
type AccountData = T::AccountData;
type ExtrinsicParams = T::ExtrinsicParams;
type CryptoKey = T::CryptoKey;
type ExtrinsicSigner = ExtrinsicSigner<Self>;
type Block = T::Block;
type Balance = T::Balance;
type ContractCurrency = T::ContractCurrency;
type StakingBalance = T::StakingBalance;
}