mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +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:
@@ -22,7 +22,6 @@ group = { version = "0.13", default-features = false }
|
||||
|
||||
serai-primitives = { path = "../../substrate/primitives", default-features = false, features = ["std"] }
|
||||
|
||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std"] }
|
||||
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||
|
||||
log = { version = "0.4", default-features = false, features = ["std"] }
|
||||
|
||||
@@ -6,7 +6,6 @@ use core::{hash::Hash, fmt::Debug};
|
||||
|
||||
use group::GroupEncoding;
|
||||
|
||||
use scale::{Encode, Decode};
|
||||
use borsh::{BorshSerialize, BorshDeserialize};
|
||||
|
||||
/// A module for task-related structs and functionality.
|
||||
@@ -40,8 +39,6 @@ pub trait Id:
|
||||
+ AsRef<[u8]>
|
||||
+ AsMut<[u8]>
|
||||
+ Debug
|
||||
+ Encode
|
||||
+ Decode
|
||||
+ BorshSerialize
|
||||
+ BorshDeserialize
|
||||
{
|
||||
@@ -57,22 +54,15 @@ impl<
|
||||
+ AsRef<[u8]>
|
||||
+ AsMut<[u8]>
|
||||
+ Debug
|
||||
+ Encode
|
||||
+ Decode
|
||||
+ BorshSerialize
|
||||
+ BorshDeserialize,
|
||||
> Id for I
|
||||
{
|
||||
}
|
||||
|
||||
/// A wrapper for a group element which implements the scale/borsh traits.
|
||||
/// A wrapper for a group element which implements the `borsh` traits.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub struct EncodableG<G: GroupEncoding>(pub G);
|
||||
impl<G: GroupEncoding> Encode for EncodableG<G> {
|
||||
fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R {
|
||||
f(self.0.to_bytes().as_ref())
|
||||
}
|
||||
}
|
||||
impl<G: GroupEncoding> BorshSerialize for EncodableG<G> {
|
||||
fn serialize<W: borsh::io::Write>(&self, writer: &mut W) -> borsh::io::Result<()> {
|
||||
writer.write_all(self.0.to_bytes().as_ref())
|
||||
|
||||
@@ -5,7 +5,7 @@ use group::GroupEncoding;
|
||||
|
||||
use borsh::{BorshSerialize, BorshDeserialize};
|
||||
|
||||
use serai_primitives::{ExternalAddress, ExternalBalance};
|
||||
use serai_primitives::{address::ExternalAddress, balance::ExternalBalance};
|
||||
|
||||
use crate::Id;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use std::io;
|
||||
|
||||
use scale::{Encode, Decode, IoReader};
|
||||
use borsh::{BorshSerialize, BorshDeserialize};
|
||||
|
||||
use serai_primitives::ExternalBalance;
|
||||
use serai_coins_primitives::OutInstructionWithBalance;
|
||||
use serai_primitives::{
|
||||
balance::ExternalBalance,
|
||||
instructions::{OutInstruction, OutInstructionWithBalance},
|
||||
};
|
||||
|
||||
use crate::Address;
|
||||
|
||||
@@ -18,9 +19,11 @@ pub struct Payment<A: Address> {
|
||||
impl<A: Address> TryFrom<OutInstructionWithBalance> for Payment<A> {
|
||||
type Error = ();
|
||||
fn try_from(out_instruction_with_balance: OutInstructionWithBalance) -> Result<Self, ()> {
|
||||
Ok(Payment {
|
||||
address: out_instruction_with_balance.instruction.address.try_into().map_err(|_| ())?,
|
||||
balance: out_instruction_with_balance.balance,
|
||||
Ok(match out_instruction_with_balance.instruction {
|
||||
OutInstruction::Transfer(address) => Payment {
|
||||
address: address.try_into().map_err(|_| ())?,
|
||||
balance: out_instruction_with_balance.balance,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -43,14 +46,12 @@ impl<A: Address> Payment<A> {
|
||||
/// Read a Payment.
|
||||
pub fn read(reader: &mut impl io::Read) -> io::Result<Self> {
|
||||
let address = A::deserialize_reader(reader)?;
|
||||
let reader = &mut IoReader(reader);
|
||||
let balance = ExternalBalance::decode(reader).map_err(io::Error::other)?;
|
||||
let balance = ExternalBalance::deserialize_reader(reader).map_err(io::Error::other)?;
|
||||
Ok(Self { address, balance })
|
||||
}
|
||||
/// Write the Payment.
|
||||
pub fn write(&self, writer: &mut impl io::Write) -> io::Result<()> {
|
||||
self.address.serialize(writer)?;
|
||||
self.balance.encode_to(writer);
|
||||
Ok(())
|
||||
self.balance.serialize(writer)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user