use core::future::Future; use crate::transaction::Transaction; #[derive(Clone)] pub(crate) struct TransactionPublisher { relayer_url: String, } impl TransactionPublisher { pub(crate) fn new(relayer_url: String) -> Self { Self { relayer_url } } } impl signers::TransactionPublisher for TransactionPublisher { type EphemeralError = (); fn publish( &self, tx: Transaction, ) -> impl Send + Future> { // Convert from an Action (an internal representation of a signable event) to a TxLegacy /* TODO match tx.0 { Action::SetKey { chain_id: _, nonce: _, key } => self.router.update_serai_key(key, tx.1), Action::Batch { chain_id: _, nonce: _, outs } => self.router.execute(outs, tx.1), } */ async move { /* use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, net::TcpStream, }; let mut msg = vec![]; match completion.command() { RouterCommand::UpdateSeraiKey { nonce, .. } | RouterCommand::Execute { nonce, .. } => { msg.extend(&u32::try_from(nonce).unwrap().to_le_bytes()); } } completion.write(&mut msg).unwrap(); let Ok(mut socket) = TcpStream::connect(&self.relayer_url).await else { log::warn!("couldn't connect to the relayer server"); Err(NetworkError::ConnectionError)? }; let Ok(()) = socket.write_all(&u32::try_from(msg.len()).unwrap().to_le_bytes()).await else { log::warn!("couldn't send the message's len to the relayer server"); Err(NetworkError::ConnectionError)? }; let Ok(()) = socket.write_all(&msg).await else { log::warn!("couldn't write the message to the relayer server"); Err(NetworkError::ConnectionError)? }; if socket.read_u8().await.ok() != Some(1) { log::warn!("didn't get the ack from the relayer server"); Err(NetworkError::ConnectionError)?; } Ok(()) */ todo!("TODO") } } }