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:
Luke Parker
2025-09-02 02:16:21 -04:00
parent 75240ed327
commit ada94e8c5d
87 changed files with 413 additions and 301 deletions

View File

@@ -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();

View File

@@ -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();

View File

@@ -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,

View File

@@ -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,
}

View File

@@ -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};

View File

@@ -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))
}
}