use alloy_primitives::{Address, address};
use chrono::{DateTime, SecondsFormat, Utc};
use serde_json::Value;
pub(crate) mod fixtures;
pub(crate) mod harness;
pub(crate) mod http;
pub(crate) mod json;
pub(crate) const NOW: i64 = 1_790_000_000;
pub(crate) const OWNER: Address = address!("84026d3beff123aab7dff957574d1362d6f880a5");
pub(crate) const MAKER: Address = address!("669ed91296e0098eb827d85eae6f2a60c5f14f8d");
pub(crate) const OPERATOR: Address = address!("9965507d1a55bcc2695c58ba16fb37d819b0a4dc");
pub(crate) const OTHER: Address = address!("1111111111111111111111111111111111111111");
pub(crate) const IDENTITY: &str = "0192f1c2-3d4e-7f00-8a1b-2c3d4e5f6a30";
pub(crate) const FILL: &str = "0192f0a1-b2c3-7d4e-8f90-a1b2c3d4e5f6";
pub(crate) const ORDER: &str = "0x2222222222222222222222222222222222222222222222222222222222222222";
pub(crate) const SWAP: &str = "0xabababababababababababababababababababababababababababababababab";
pub(crate) const HASHLOCK: &str =
"0x1111111111111111111111111111111111111111111111111111111111111111";
pub(crate) const POOL: &str = "0x4444444444444444444444444444444444444444444444444444444444444444";
const SERVER: &str =
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/vectors/server-typed-data.json"));
pub(crate) fn at(offset: i64) -> DateTime<Utc> {
DateTime::from_timestamp(NOW + offset, 0).unwrap()
}
pub(crate) fn stamp(time: DateTime<Utc>) -> String {
time.to_rfc3339_opts(SecondsFormat::Secs, true)
}
pub(crate) fn time(offset: i64) -> String {
stamp(at(offset))
}
pub(crate) fn sample(name: &str) -> Value {
let server: Value = serde_json::from_str(SERVER).unwrap();
server[name].clone()
}
pub(crate) fn edited(mut value: Value, edit: impl FnOnce(&mut Value)) -> Value {
edit(&mut value);
value
}
pub(crate) fn replaced(
fields: Vec<(&'static str, String)>,
name: &str,
value: &str,
) -> Vec<(&'static str, String)> {
fields
.into_iter()
.map(|(field, old)| (field, if field == name { value.to_owned() } else { old }))
.collect()
}