Skip to content
Snippets Groups Projects
Commit 251d33cb authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Split off TypeId so as not to pull in sr-io (#3740)

* Add type-id

* Builds with std now.

* Fix for cargo

* Remove unneeded stuff

* Move TypeId.
parent 18fa1d15
No related merge requests found
......@@ -219,3 +219,8 @@ impl codec::Decode for NeverNativeValue {
}
}
/// Provide a simple 4 byte identifier for a type.
pub trait TypeId {
/// Simple 4 byte identifier.
const TYPE_ID: [u8; 4];
}
......@@ -56,7 +56,7 @@ pub mod weights;
pub use generic::{DigestItem, Digest};
/// Re-export this since it's part of the API of this crate.
pub use primitives::crypto::{key_types, KeyTypeId, CryptoType};
pub use primitives::{TypeId, crypto::{key_types, KeyTypeId, CryptoType}};
pub use app_crypto::RuntimeAppPublic;
/// Re-export arithmetic stuff.
......@@ -82,7 +82,7 @@ use traits::{Verify, Lazy};
#[derive(Clone, Copy, Eq, PartialEq, Encode, Decode)]
pub struct ModuleId(pub [u8; 8]);
impl traits::TypeId for ModuleId {
impl TypeId for ModuleId {
const TYPE_ID: [u8; 4] = *b"modl";
}
......
......@@ -23,7 +23,7 @@ use runtime_io;
use std::fmt::{Debug, Display};
#[cfg(feature = "std")]
use serde::{Serialize, Deserialize, de::DeserializeOwned};
use primitives::{self, Hasher, Blake2Hasher};
use primitives::{self, Hasher, Blake2Hasher, TypeId};
use crate::codec::{Codec, Encode, Decode, HasCompact};
use crate::transaction_validity::{
ValidTransaction, TransactionValidity, TransactionValidityError, UnknownTransaction,
......@@ -1123,12 +1123,6 @@ pub trait AccountIdConversion<AccountId>: Sized {
fn try_from_sub_account<S: Decode>(x: &AccountId) -> Option<(Self, S)>;
}
/// Provide a simple 4 byte identifier for a type.
pub trait TypeId {
/// Simple 4 byte identifier.
const TYPE_ID: [u8; 4];
}
/// Format is TYPE_ID ++ encode(parachain ID) ++ 00.... where 00... is indefinite trailing zeroes to
/// fill AccountId.
impl<T: Encode + Decode + Default, Id: Encode + Decode + TypeId> AccountIdConversion<T> for Id {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment