mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Allows us to finally remove the old `serai-dex/substrate` repository _and_ should have CI pass without issue on `develop` again. The changes made here should be trivial and maintain all prior behavior/functionality. The most notable are to `chain_spec.rs`, in order to still use a SCALE-encoded `GenesisConfig` (avoiding `serde_json`).
67 lines
1.7 KiB
Rust
67 lines
1.7 KiB
Rust
#[cfg(feature = "std")]
|
|
use zeroize::Zeroize;
|
|
|
|
#[cfg(feature = "borsh")]
|
|
use borsh::{BorshSerialize, BorshDeserialize};
|
|
#[cfg(feature = "serde")]
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
use scale::{Encode, Decode, DecodeWithMemTracking, MaxEncodedLen};
|
|
|
|
use sp_core::H256;
|
|
|
|
/// The type used to identify block numbers.
|
|
#[derive(
|
|
Clone,
|
|
Copy,
|
|
Default,
|
|
PartialEq,
|
|
Eq,
|
|
Hash,
|
|
Debug,
|
|
Encode,
|
|
Decode,
|
|
DecodeWithMemTracking,
|
|
MaxEncodedLen,
|
|
)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
pub struct BlockNumber(pub u64);
|
|
impl From<u64> for BlockNumber {
|
|
fn from(number: u64) -> BlockNumber {
|
|
BlockNumber(number)
|
|
}
|
|
}
|
|
|
|
/// The type used to identify block hashes.
|
|
// This may not be universally compatible
|
|
// If a block exists with a hash which isn't 32-bytes, it can be hashed into a value with 32-bytes
|
|
// This would require the processor to maintain a mapping of 32-byte IDs to actual hashes, which
|
|
// would be fine
|
|
#[derive(
|
|
Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen,
|
|
)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
pub struct BlockHash(pub [u8; 32]);
|
|
|
|
impl AsRef<[u8]> for BlockHash {
|
|
fn as_ref(&self) -> &[u8] {
|
|
self.0.as_ref()
|
|
}
|
|
}
|
|
|
|
impl From<[u8; 32]> for BlockHash {
|
|
fn from(hash: [u8; 32]) -> BlockHash {
|
|
BlockHash(hash)
|
|
}
|
|
}
|
|
|
|
impl From<H256> for BlockHash {
|
|
fn from(hash: H256) -> BlockHash {
|
|
BlockHash(hash.into())
|
|
}
|
|
}
|