mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Get all processors to compile again
Requires splitting `serai-cosign` into `serai-cosign` and `serai-cosign-types` so the processor don't require `serai-client/serai` (not correct yet).
This commit is contained in:
@@ -25,16 +25,18 @@ scale-info = { version = "2", default-features = false, features = ["derive"], o
|
||||
sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "2bfdaed4b3614de2fe7d10e4ece3e6a912833e90", default-features = false }
|
||||
|
||||
ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["alloc"] }
|
||||
dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = false }
|
||||
dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = false, features = ["alloc"] }
|
||||
dkg = { package = "dkg-musig", path = "../../crypto/dkg/musig", default-features = false }
|
||||
|
||||
schnorrkel = { version = "0.11", default-features = false }
|
||||
|
||||
bech32 = { version = "0.11", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
rand_core = { version = "0.6", default-features = false, features = ["std"] }
|
||||
|
||||
[features]
|
||||
std = ["zeroize/std", "borsh/std", "bitvec/std", "scale/std", "scale-info/std", "sp-core/std", "ciphersuite/std", "dalek-ff-group/std", "dkg/std", "bech32/std"]
|
||||
std = ["zeroize/std", "borsh/std", "bitvec/std", "scale?/std", "scale-info?/std", "sp-core/std", "ciphersuite/std", "dalek-ff-group/std", "dkg/std", "schnorrkel/std", "bech32/std"]
|
||||
serde = []
|
||||
non_canonical_scale_derivations = ["scale", "scale-info"]
|
||||
default = ["std"]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use core::convert::AsRef;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use zeroize::Zeroize;
|
||||
@@ -150,13 +151,18 @@ impl TryFrom<Vec<u8>> for ExternalAddress {
|
||||
vec.try_into().map(ExternalAddress).map_err(|_| FromVecError::TooLong)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ExternalAddress> for Vec<u8> {
|
||||
fn from(ext: ExternalAddress) -> Vec<u8> {
|
||||
ext.0.into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for ExternalAddress {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl zeroize::Zeroize for ExternalAddress {
|
||||
fn zeroize(&mut self) {
|
||||
self.0.as_mut().zeroize();
|
||||
|
||||
@@ -40,6 +40,11 @@ impl From<Public> for sp_core::sr25519::Public {
|
||||
)
|
||||
)]
|
||||
pub struct Signature(pub [u8; 64]);
|
||||
impl From<schnorrkel::Signature> for Signature {
|
||||
fn from(signature: schnorrkel::Signature) -> Self {
|
||||
Self(signature.to_bytes())
|
||||
}
|
||||
}
|
||||
impl From<sp_core::sr25519::Signature> for Signature {
|
||||
fn from(signature: sp_core::sr25519::Signature) -> Self {
|
||||
Self(signature.0)
|
||||
@@ -71,6 +76,12 @@ pub struct ExternalKey(
|
||||
pub BoundedVec<u8, ConstU32<{ ExternalKey::MAX_LEN }>>,
|
||||
);
|
||||
|
||||
impl AsRef<[u8]> for ExternalKey {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl Zeroize for ExternalKey {
|
||||
fn zeroize(&mut self) {
|
||||
self.0.as_mut().zeroize();
|
||||
|
||||
@@ -93,6 +93,7 @@ impl BorshDeserialize for Batch {
|
||||
}
|
||||
|
||||
/// An error incurred while pushing an instruction onto a `Batch`.
|
||||
#[derive(Debug)]
|
||||
pub enum PushInstructionError {
|
||||
/// The Batch's max size was exceeded.
|
||||
MaxSizeExceeded,
|
||||
|
||||
@@ -80,7 +80,7 @@ pub struct RefundableInInstruction {
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
||||
pub struct InInstructionWithBalance {
|
||||
/// The instruction on how to handle coins in.
|
||||
pub instruction: OutInstruction,
|
||||
pub instruction: InInstruction,
|
||||
/// The coins in.
|
||||
pub balance: ExternalBalance,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
mod r#in;
|
||||
pub use r#in::{InInstruction, InInstructionWithBalance, PushInstructionError, Batch, SignedBatch};
|
||||
pub use r#in::{
|
||||
InInstruction, InInstructionWithBalance, RefundableInInstruction, PushInstructionError, Batch,
|
||||
SignedBatch,
|
||||
};
|
||||
|
||||
mod out;
|
||||
pub use out::{OutInstruction, OutInstructionWithBalance};
|
||||
|
||||
@@ -62,11 +62,11 @@ impl ExternalNetworkId {
|
||||
}
|
||||
|
||||
/// The coins native to this network.
|
||||
pub fn coins(&self) -> &'static [ExternalCoin] {
|
||||
pub fn coins(&self) -> impl Iterator<Item = ExternalCoin> {
|
||||
match self {
|
||||
Self::Bitcoin => &[ExternalCoin::Bitcoin],
|
||||
Self::Ethereum => &[ExternalCoin::Ether, ExternalCoin::Dai],
|
||||
Self::Monero => &[ExternalCoin::Monero],
|
||||
Self::Bitcoin => [ExternalCoin::Bitcoin].as_slice().iter().copied(),
|
||||
Self::Ethereum => [ExternalCoin::Ether, ExternalCoin::Dai].as_slice().iter().copied(),
|
||||
Self::Monero => [ExternalCoin::Monero].as_slice().iter().copied(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,11 +119,11 @@ impl NetworkId {
|
||||
|
||||
/// The coins native to this network.
|
||||
pub fn coins(self) -> impl Iterator<Item = Coin> {
|
||||
let (coins, external_coins): (&[Coin], &[ExternalCoin]) = match self {
|
||||
NetworkId::Serai => (&[Coin::Serai], &[]),
|
||||
NetworkId::External(ext) => (&[], ext.coins()),
|
||||
let (coins, external_coins): (&[Coin], _) = match self {
|
||||
NetworkId::Serai => (&[Coin::Serai], None),
|
||||
NetworkId::External(ext) => (&[], Some(ext.coins())),
|
||||
};
|
||||
coins.iter().copied().chain(external_coins.iter().copied().map(Into::into))
|
||||
coins.iter().copied().chain(external_coins.into_iter().flatten().map(Into::into))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user