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:
@@ -23,7 +23,7 @@ thiserror = { version = "2", default-features = false, optional = true }
|
||||
bitvec = { version = "1", default-features = false, features = ["alloc", "serde"] }
|
||||
|
||||
hex = "0.4"
|
||||
scale = { package = "parity-scale-codec", version = "3" }
|
||||
scale = { package = "parity-scale-codec", version = "3", optional = true }
|
||||
borsh = { version = "1", features = ["derive"] }
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
serde_json = { version = "1", optional = true }
|
||||
@@ -64,7 +64,7 @@ dockertest = "0.5"
|
||||
serai-docker-tests = { path = "../../tests/docker" }
|
||||
|
||||
[features]
|
||||
serai = ["thiserror/std", "serde", "serde_json", "multiaddr", "sp-core", "sp-runtime", "frame-system", "simple-request"]
|
||||
serai = ["thiserror/std", "scale", "serde", "serde_json", "multiaddr", "sp-core", "sp-runtime", "frame-system", "simple-request"]
|
||||
|
||||
networks = []
|
||||
bitcoin = ["networks", "dep:bitcoin"]
|
||||
@@ -73,4 +73,4 @@ monero = ["networks", "dalek-ff-group", "ciphersuite", "monero-address"]
|
||||
|
||||
# Assumes the default usage is to use Serai as a DEX, which doesn't actually
|
||||
# require connecting to a Serai node
|
||||
default = ["bitcoin", "monero"]
|
||||
default = ["bitcoin", "ethereum", "monero"]
|
||||
|
||||
@@ -8,20 +8,6 @@ pub use serai::*;
|
||||
|
||||
#[cfg(not(feature = "serai"))]
|
||||
pub use serai_abi::primitives;
|
||||
#[cfg(not(feature = "serai"))]
|
||||
mod other_primitives {
|
||||
pub mod coins {
|
||||
pub use serai_abi::coins::primitives;
|
||||
}
|
||||
pub mod validator_sets {
|
||||
pub use serai_abi::validator_sets::primitives;
|
||||
}
|
||||
pub mod in_instructions {
|
||||
pub use serai_abi::in_instructions::primitives;
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "serai"))]
|
||||
pub use other_primitives::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use core::{str::FromStr, fmt};
|
||||
|
||||
use scale::{Encode, Decode};
|
||||
use borsh::{BorshSerialize, BorshDeserialize};
|
||||
|
||||
use bitcoin::{
|
||||
@@ -11,10 +10,10 @@ use bitcoin::{
|
||||
address::{AddressType, NetworkChecked, Address as BAddress},
|
||||
};
|
||||
|
||||
use crate::primitives::ExternalAddress;
|
||||
use crate::primitives::address::ExternalAddress;
|
||||
|
||||
// SCALE-encodable representation of Bitcoin addresses, used internally.
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
||||
enum EncodedAddress {
|
||||
P2PKH([u8; 20]),
|
||||
P2SH([u8; 20]),
|
||||
@@ -124,7 +123,7 @@ impl TryFrom<ExternalAddress> for Address {
|
||||
fn try_from(data: ExternalAddress) -> Result<Address, ()> {
|
||||
// Decode as an EncodedAddress, then map to a ScriptBuf
|
||||
let mut data = data.as_ref();
|
||||
let encoded = EncodedAddress::decode(&mut data).map_err(|_| ())?;
|
||||
let encoded = EncodedAddress::deserialize_reader(&mut data).map_err(|_| ())?;
|
||||
if !data.is_empty() {
|
||||
Err(())?
|
||||
}
|
||||
@@ -141,8 +140,8 @@ impl From<Address> for EncodedAddress {
|
||||
|
||||
impl From<Address> for ExternalAddress {
|
||||
fn from(addr: Address) -> ExternalAddress {
|
||||
// Safe since all variants are fixed-length and fit into MAX_ADDRESS_LEN
|
||||
ExternalAddress::new(EncodedAddress::from(addr).encode()).unwrap()
|
||||
// Safe since all variants are fixed-length and fit into `MAX_ADDRESS_LEN`
|
||||
ExternalAddress::try_from(borsh::to_vec(&EncodedAddress::from(addr)).unwrap()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::io::Read;
|
||||
|
||||
use borsh::{BorshSerialize, BorshDeserialize};
|
||||
|
||||
use crate::primitives::{MAX_ADDRESS_LEN, ExternalAddress};
|
||||
use crate::primitives::address::ExternalAddress;
|
||||
|
||||
/// THe maximum amount of gas an address is allowed to specify as its gas limit.
|
||||
///
|
||||
@@ -33,7 +33,8 @@ impl ContractDeployment {
|
||||
}
|
||||
|
||||
// The max address length, minus the type byte, minus the size of the gas
|
||||
const MAX_CODE_LEN: usize = (MAX_ADDRESS_LEN as usize) - (1 + core::mem::size_of::<u32>());
|
||||
const MAX_CODE_LEN: usize =
|
||||
(ExternalAddress::MAX_LEN as usize) - (1 + core::mem::size_of::<u32>());
|
||||
if code.len() > MAX_CODE_LEN {
|
||||
None?;
|
||||
}
|
||||
@@ -111,7 +112,7 @@ impl From<Address> for ExternalAddress {
|
||||
}
|
||||
}
|
||||
// We only construct addresses whose code is small enough this can safely be constructed
|
||||
ExternalAddress::new(res).unwrap()
|
||||
ExternalAddress::try_from(res).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use ciphersuite::Ciphersuite;
|
||||
|
||||
use monero_address::{Network, AddressType as MoneroAddressType, MoneroAddress};
|
||||
|
||||
use crate::primitives::ExternalAddress;
|
||||
use crate::primitives::address::ExternalAddress;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
enum AddressType {
|
||||
@@ -123,7 +123,7 @@ impl TryFrom<ExternalAddress> for Address {
|
||||
impl From<Address> for ExternalAddress {
|
||||
fn from(address: Address) -> ExternalAddress {
|
||||
// This is 65 bytes which is less than MAX_ADDRESS_LEN
|
||||
ExternalAddress::new(borsh::to_vec(&address).unwrap()).unwrap()
|
||||
ExternalAddress::try_from(borsh::to_vec(&address).unwrap()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user