Files
pezkuwi-subxt/subxt/src/config.rs
T
Andrew Jones 31f8c37164 Replace log with tracing and record extrinsic info (#535)
* Replace log with tracing for integration tests

* Replace log with tracing

* Use correct tracing lib

* Log extrinsic hash and signature

* Debug extrinsic params

* Replace env_logger

* Replace more env_logger init

* Replace new logs with tracing

* Fix final env_logger
2022-05-12 14:54:53 +01:00

113 lines
3.6 KiB
Rust

// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// subxt is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// subxt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use codec::{
Codec,
Encode,
EncodeLike,
};
use core::fmt::Debug;
use sp_runtime::traits::{
AtLeast32Bit,
Extrinsic,
Hash,
Header,
MaybeSerializeDeserialize,
Member,
Verify,
};
/// Runtime types.
// Note: the 'static bound isn't strictly required, but currently deriving TypeInfo
// automatically applies a 'static bound to all generic types (including this one),
// and so until that is resolved, we'll keep the (easy to satisfy) constraint here.
pub trait Config: Debug + 'static {
/// Account index (aka nonce) type. This stores the number of previous
/// transactions associated with a sender account.
type Index: Parameter
+ Member
+ serde::de::DeserializeOwned
+ Default
+ AtLeast32Bit
+ Copy
+ scale_info::TypeInfo
+ Into<u64>;
/// The block number type used by the runtime.
type BlockNumber: Parameter
+ Member
+ Default
+ Copy
+ core::hash::Hash
+ core::str::FromStr
+ Into<u64>;
/// The output of the `Hashing` function.
type Hash: Parameter
+ Member
+ MaybeSerializeDeserialize
+ Ord
+ Default
+ Copy
+ std::hash::Hash
+ AsRef<[u8]>
+ AsMut<[u8]>
+ scale_info::TypeInfo;
/// The hashing system (algorithm) being used in the runtime (e.g. Blake2).
type Hashing: Hash<Output = Self::Hash>;
/// The user account identifier type for the runtime.
type AccountId: Parameter + Member + serde::Serialize;
/// The address type. This instead of `<frame_system::Trait::Lookup as StaticLookup>::Source`.
type Address: Codec + Clone + PartialEq;
/// The block header.
type Header: Parameter
+ Header<Number = Self::BlockNumber, Hash = Self::Hash>
+ serde::de::DeserializeOwned;
/// Signature type.
type Signature: Verify + Encode + Send + Sync + 'static;
/// Extrinsic type within blocks.
type Extrinsic: Parameter + Extrinsic + Debug + MaybeSerializeDeserialize;
}
/// Parameter trait copied from `substrate::frame_support`
pub trait Parameter: Codec + EncodeLike + Clone + Eq + Debug {}
impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + Debug {}
/// Default set of commonly used types by Substrate runtimes.
// Note: We only use this at the type level, so it should be impossible to
// create an instance of it.
#[derive(Debug)]
pub enum DefaultConfig {}
impl Config for DefaultConfig {
type Index = u32;
type BlockNumber = u32;
type Hash = sp_core::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
type AccountId = sp_runtime::AccountId32;
type Address = sp_runtime::MultiAddress<Self::AccountId, u32>;
type Header =
sp_runtime::generic::Header<Self::BlockNumber, sp_runtime::traits::BlakeTwo256>;
type Signature = sp_runtime::MultiSignature;
type Extrinsic = sp_runtime::OpaqueExtrinsic;
}