mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-13 06:29:25 +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`).
56 lines
1.6 KiB
Rust
56 lines
1.6 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 serai_primitives::{Amount, ExternalAddress, ExternalCoin, SeraiAddress};
|
|
|
|
use coins_primitives::OutInstruction;
|
|
|
|
use crate::RefundableInInstruction;
|
|
#[cfg(feature = "std")]
|
|
use crate::InInstruction;
|
|
|
|
#[derive(Clone, PartialEq, Eq, 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 enum Shorthand {
|
|
Raw(RefundableInInstruction),
|
|
Swap {
|
|
origin: Option<ExternalAddress>,
|
|
coin: ExternalCoin,
|
|
minimum: Amount,
|
|
out: OutInstruction,
|
|
},
|
|
SwapAndAddLiquidity {
|
|
origin: Option<ExternalAddress>,
|
|
minimum: Amount,
|
|
gas: Amount,
|
|
address: SeraiAddress,
|
|
},
|
|
}
|
|
|
|
impl Shorthand {
|
|
#[cfg(feature = "std")]
|
|
pub fn transfer(origin: Option<ExternalAddress>, address: SeraiAddress) -> Self {
|
|
Self::Raw(RefundableInInstruction { origin, instruction: InInstruction::Transfer(address) })
|
|
}
|
|
}
|
|
|
|
impl TryFrom<Shorthand> for RefundableInInstruction {
|
|
type Error = &'static str;
|
|
fn try_from(shorthand: Shorthand) -> Result<RefundableInInstruction, &'static str> {
|
|
Ok(match shorthand {
|
|
Shorthand::Raw(instruction) => instruction,
|
|
Shorthand::Swap { .. } => todo!(),
|
|
Shorthand::SwapAndAddLiquidity { .. } => todo!(),
|
|
})
|
|
}
|
|
}
|