use super::arithmetic::AtLeast32BitUnsigned;
use ink_primitives::{
AccountId,
Clear,
Hash,
};
#[cfg(feature = "std")]
use scale_info::TypeInfo;
pub trait FromLittleEndian {
type Bytes: Default + AsRef<[u8]> + AsMut<[u8]>;
fn from_le_bytes(bytes: Self::Bytes) -> Self;
}
impl FromLittleEndian for u8 {
type Bytes = [u8; 1];
#[inline]
fn from_le_bytes(bytes: Self::Bytes) -> Self {
u8::from_le_bytes(bytes)
}
}
impl FromLittleEndian for u16 {
type Bytes = [u8; 2];
#[inline]
fn from_le_bytes(bytes: Self::Bytes) -> Self {
u16::from_le_bytes(bytes)
}
}
impl FromLittleEndian for u32 {
type Bytes = [u8; 4];
#[inline]
fn from_le_bytes(bytes: Self::Bytes) -> Self {
u32::from_le_bytes(bytes)
}
}
impl FromLittleEndian for u64 {
type Bytes = [u8; 8];
#[inline]
fn from_le_bytes(bytes: Self::Bytes) -> Self {
u64::from_le_bytes(bytes)
}
}
impl FromLittleEndian for u128 {
type Bytes = [u8; 16];
#[inline]
fn from_le_bytes(bytes: Self::Bytes) -> Self {
u128::from_le_bytes(bytes)
}
}
pub trait Environment {
const MAX_EVENT_TOPICS: usize;
type AccountId: 'static
+ scale::Codec
+ Clone
+ PartialEq
+ Eq
+ Ord
+ AsRef<[u8]>
+ AsMut<[u8]>
+ Default;
type Balance: 'static
+ scale::Codec
+ Copy
+ Clone
+ PartialEq
+ Eq
+ AtLeast32BitUnsigned
+ FromLittleEndian;
type Hash: 'static
+ scale::Codec
+ Copy
+ Clone
+ Clear
+ PartialEq
+ Eq
+ Ord
+ AsRef<[u8]>
+ AsMut<[u8]>;
type Timestamp: 'static
+ scale::Codec
+ Copy
+ Clone
+ PartialEq
+ Eq
+ AtLeast32BitUnsigned
+ FromLittleEndian;
type BlockNumber: 'static
+ scale::Codec
+ Copy
+ Clone
+ PartialEq
+ Eq
+ AtLeast32BitUnsigned
+ FromLittleEndian;
type ChainExtension;
}
pub enum NoChainExtension {}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(TypeInfo))]
pub enum DefaultEnvironment {}
impl Environment for DefaultEnvironment {
const MAX_EVENT_TOPICS: usize = 4;
type AccountId = AccountId;
type Balance = Balance;
type Hash = Hash;
type Timestamp = Timestamp;
type BlockNumber = BlockNumber;
type ChainExtension = NoChainExtension;
}
pub type Balance = u128;
pub type Timestamp = u64;
pub type Gas = u64;
pub type BlockNumber = u32;