whisky_provider/maestro/
submitter.rs

1use async_trait::async_trait;
2use whisky_common::{Submitter, WError};
3
4use super::MaestroProvider;
5
6#[async_trait]
7impl Submitter for MaestroProvider {
8    async fn submit_tx(&self, tx_hex: &str) -> Result<String, WError> {
9        let url = "/txmanager";
10        let maestro_client = &self.maestro_client;
11
12        let tx_binary = hex::decode(tx_hex).map_err(WError::from_err("Invalid hex data"))?;
13
14        let req = maestro_client
15            .http_client
16            .post(format!("{}{}", &maestro_client.base_url, url))
17            .header("Content-Type", "application/cbor")
18            .body(tx_binary);
19
20        let mut response_body = String::new();
21        self.maestro_client
22            .send_request(req, &mut response_body)
23            .await
24            .map_err(WError::from_err("Maestro - submit_tx"))?;
25
26        Ok(response_body)
27    }
28}