mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-07 03:19:30 +00:00
b296be8515
* Add SignalsConfig to chain_spec * Correct multiexp feature flagging for rand_core std * Remove bincode for borsh Replaces a non-canonical encoding with a canonical encoding which additionally should be faster. Also fixes an issue where we used bincode in transcripts where it cannot be trusted. This ended up fixing a myriad of other bugs observed, unfortunately. Accordingly, it either has to be merged or the bug fixes from it must be ported to a new PR. * Make serde optional, minimize usage * Make borsh an optional dependency of substrate/ crates * Remove unused dependencies * Use [u8; 64] where possible in the processor messages * Correct borsh feature flagging
54 lines
1.7 KiB
Rust
54 lines
1.7 KiB
Rust
#![cfg_attr(docsrs, feature(doc_cfg))]
|
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
|
|
|
#[cfg(feature = "std")]
|
|
use zeroize::Zeroize;
|
|
|
|
#[cfg(feature = "borsh")]
|
|
use borsh::{BorshSerialize, BorshDeserialize};
|
|
#[cfg(feature = "serde")]
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
use scale::{Encode, Decode, MaxEncodedLen};
|
|
use scale_info::TypeInfo;
|
|
|
|
use serai_primitives::{Balance, SeraiAddress, ExternalAddress, Data, system_address};
|
|
|
|
pub const FEE_ACCOUNT: SeraiAddress = system_address(b"Coins-fees");
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
pub struct OutInstruction {
|
|
pub address: ExternalAddress,
|
|
pub data: Option<Data>,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
pub struct OutInstructionWithBalance {
|
|
pub instruction: OutInstruction,
|
|
pub balance: Balance,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
pub enum Destination {
|
|
Native(SeraiAddress),
|
|
External(OutInstruction),
|
|
}
|
|
|
|
#[test]
|
|
fn address() {
|
|
use sp_runtime::traits::TrailingZeroInput;
|
|
assert_eq!(
|
|
FEE_ACCOUNT,
|
|
SeraiAddress::decode(&mut TrailingZeroInput::new(b"Coins-fees")).unwrap()
|
|
);
|
|
}
|